CINXE.COM

LKML: Matthew Garrett: RFC: ACPI/scsi/libata integration and hotswap

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Matthew Garrett: RFC: ACPI/scsi/libata integration and hotswap</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Matthew Garrett" href="/groupie.php?aid=6180" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/12"> [Dec]</a> 聽 <a class="nb" href="/lkml/2005/12/7"> [7]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/12/7/425" onclick="this.href='/lkml/headers'+'/2005/12/7/425';">[headers]</a>聽 <a href="/lkml/bounce/2005/12/7/425">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/12/7/425">First message in thread</a></li><li class="origin"><a href="/lkml/2005/12/8/42">Matthew Garrett</a><ul><li><a href="/lkml/2005/12/8/42">Christoph Hellwig</a><ul><li><a href="/lkml/2005/12/8/76">Matthew Garrett</a><ul><li><a href="/lkml/2005/12/8/79">Christoph Hellwig</a><ul><li><a href="/lkml/2005/12/8/80">Matthew Garrett</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2005/12/13/268">Randy Dunlap</a><ul><li><a href="/lkml/2005/12/13/273">Matthew Garrett</a><ul><li><a href="/lkml/2005/12/13/288">Randy Dunlap</a></li></ul></li></ul></li></ul></li></ul><div class="threadlist">Patch in this message</div><ul class="threadlist"><li><a href="/lkml/diff/2005/12/7/425/1">Get diff 1</a></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Thu, 8 Dec 2005 03:02:42 +0000</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Matthew Garrett &lt;&gt;</td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">RFC: ACPI/scsi/libata integration and hotswap</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">Hi!<br /><br />The included patch does three things:<br /><br />1) It adds basic support for binding SCSI and SATA devices to ACPI <br />device handles. At the moment this is limited to hosts, and in practice <br />it's probably limited to SATA ones (ACPI doesn't spec how SCSI devices <br />should appear in the DSDT, so I'm guessing that in general they don't). <br />Given a host, you can DEVICE_ACPI_HANDLE(dev) it to get the handle to <br />the ACPI device - this should be handy for implementing suspend <br />functions, since the methods should be in a standard location underneath <br />this.<br /><br />Support for binding the devices hasn't been implemented yet. I'm not <br />entire sure where they should be bound (the target, presumably?), and I <br />haven't actually got it to work...<br /><br />2) It adds support for attaching notification events to the host. These <br />can be host-driver specific (they're just part of the host template). <br />Whenever the hardware generates an event on that bus, the host will be <br />called. I've added one of these to ata_piix (since that's what I have), <br />which should really be implemented in the host and only call the generic <br />one when appropriate. But still.<br /><br />3) Adds a generic libata notification handler that currently treats all <br />notifications as drive removal/insertion. It then calls Lukasz <br />Kosewski's hotplug code to remove/add the drive as appropriate.<br /><br />Most laptops generate ACPI notifications requesting bus rescans whenever <br />a bay drive is inserted or removed. This handles the event <br />appropriately. On my Dell d610, removing or plugging the drive results <br />in it appearing or disappearing from /proc/scsi/scsi as appropriate.<br /><br />Patch:<br /><br />diff -u drivers/scsi/ata_piix.c /tmp/drivers/scsi/ata_piix.c<br />--- drivers/scsi/ata_piix.c 2005-12-05 14:30:58 +0000<br />+++ /tmp/drivers/scsi/ata_piix.c 2005-12-08 02:16:59 +0000<br />&#64;&#64; -148,6 +148,7 &#64;&#64;<br /> .ordered_flush = 1,<br /> .resume = ata_scsi_device_resume,<br /> .suspend = ata_scsi_device_suspend,<br />+ .acpi_notify = ata_acpi_notify,<br /> };<br /> <br /> static const struct ata_port_operations piix_pata_ops = {<br />diff -u drivers/scsi/libata-core.c /tmp/drivers/scsi/libata-core.c<br />--- drivers/scsi/libata-core.c 2005-12-08 02:27:02 +0000<br />+++ /tmp/drivers/scsi/libata-core.c 2005-12-08 02:16:50 +0000<br />&#64;&#64; -50,6 +50,7 &#64;&#64;<br /> #include &lt;linux/workqueue.h&gt;<br /> #include &lt;linux/jiffies.h&gt;<br /> #include &lt;linux/scatterlist.h&gt;<br />+#include &lt;linux/acpi.h&gt;<br /> #include &lt;scsi/scsi.h&gt;<br /> #include "scsi_priv.h"<br /> #include &lt;scsi/scsi_cmnd.h&gt;<br />&#64;&#64; -75,9 +76,11 &#64;&#64;<br /> unsigned int *xfer_shift_out);<br /> static void __ata_qc_complete(struct ata_queued_cmd *qc);<br /> static void ata_pio_error(struct ata_port *ap);<br />+static int ata_bus_probe(struct ata_port *ap);<br /> <br /> static unsigned int ata_unique_id = 1;<br /> static struct workqueue_struct *ata_wq;<br />+static struct workqueue_struct *ata_hotplug_wq;<br /> <br /> int atapi_enabled = 1;<br /> module_param(atapi_enabled, int, 0444);<br />&#64;&#64; -88,6 +91,17 &#64;&#64;<br /> MODULE_LICENSE("GPL");<br /> MODULE_VERSION(DRV_VERSION);<br /> <br />+void ata_acpi_notify(acpi_handle device, u32 type, void *data) {<br />+ struct device *dev = acpi_get_physical_device(device);<br />+ struct Scsi_Host *shost = dev_to_shost(dev);<br />+ struct ata_port *ap = (struct ata_port *) &amp;shost-&gt;hostdata[0];<br />+ <br />+ if (!ata_bus_probe(ap))<br />+ ata_hotplug_plug(ap);<br />+ else<br />+ ata_hotplug_unplug(ap);<br />+}<br />+<br /> /**<br /> * ata_tf_load_pio - send taskfile registers to host controller<br /> * &#64;ap: Port to which output is sent<br />diff -u drivers/scsi/scsi.c /tmp/drivers/scsi/scsi.c<br />--- drivers/scsi/scsi.c 2005-12-04 16:48:07 +0000<br />+++ /tmp/drivers/scsi/scsi.c 2005-12-08 02:16:28 +0000<br />&#64;&#64; -55,6 +55,7 &#64;&#64;<br /> #include &lt;linux/interrupt.h&gt;<br /> #include &lt;linux/notifier.h&gt;<br /> #include &lt;linux/cpu.h&gt;<br />+#include &lt;linux/acpi.h&gt;<br /> <br /> #include &lt;scsi/scsi.h&gt;<br /> #include &lt;scsi/scsi_cmnd.h&gt;<br />&#64;&#64; -1305,6 +1306,48 &#64;&#64;<br /> #define unregister_scsi_cpu()<br /> #endif /* CONFIG_HOTPLUG_CPU */<br /> <br />+#ifdef CONFIG_ACPI<br />+static int scsi_acpi_find_device(struct device *dev, acpi_handle *handle)<br />+{<br />+ return -ENODEV;<br />+}<br />+<br />+void ata_acpi_notify(acpi_handle handle, u32 type, void *data);<br />+<br />+static int scsi_acpi_find_channel(struct device *dev, acpi_handle *handle)<br />+{<br />+ int i;<br />+ struct Scsi_Host *shost;<br />+ <br />+ if (sscanf(dev-&gt;bus_id, "host%u", &amp;i) != 1) {<br />+ return -ENODEV;<br />+ }<br />+<br />+ *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev-&gt;parent), (acpi_integer) i); <br />+ if (!*handle)<br />+ return -ENODEV;<br />+<br />+ shost = dev_to_shost(dev);<br />+ <br />+ if (shost-&gt;hostt-&gt;acpi_notify) { <br />+ acpi_install_notify_handler(*handle, ACPI_ALL_NOTIFY, &amp;ata_acpi_notify, (void *)i);<br />+ }<br />+ <br />+ return 0;<br />+}<br />+<br />+static struct acpi_bus_type scsi_acpi_bus = {<br />+ .bus = &amp;scsi_bus_type,<br />+ .find_bridge = scsi_acpi_find_channel,<br />+ .find_device = scsi_acpi_find_device,<br />+};<br />+<br />+static __init int scsi_acpi_register(void)<br />+{<br />+ return register_acpi_bus_type(&amp;scsi_acpi_bus);<br />+}<br />+#endif /* CONFIG_ACPI */<br />+<br /> MODULE_DESCRIPTION("SCSI core");<br /> MODULE_LICENSE("GPL");<br /> <br />&#64;&#64; -1333,6 +1376,11 &#64;&#64;<br /> error = scsi_sysfs_register();<br /> if (error)<br /> goto cleanup_sysctl;<br />+#ifdef CONFIG_ACPI<br />+ error = scsi_acpi_register();<br />+ if (error)<br />+ goto cleanup_sysfs;<br />+#endif<br /> <br /> for (i = 0; i &lt; NR_CPUS; i++)<br /> INIT_LIST_HEAD(&amp;per_cpu(scsi_done_q, i));<br />&#64;&#64; -1343,6 +1391,8 &#64;&#64;<br /> printk(KERN_NOTICE "SCSI subsystem initialized\n");<br /> return 0;<br /> <br />+cleanup_sysfs:<br />+ scsi_sysfs_unregister();<br /> cleanup_sysctl:<br /> scsi_exit_sysctl();<br /> cleanup_hosts:<br />--- include/linux/libata.h 2005-12-05 14:32:50 +0000<br />+++ /tmp/include/linux/libata.h 2005-12-08 02:35:59 +0000<br />&#64;&#64; -453,7 +468,9 &#64;&#64;<br /> extern int ata_scsi_device_suspend(struct scsi_device *);<br /> extern int ata_device_resume(struct ata_port *, struct ata_device *);<br /> extern int ata_device_suspend(struct ata_port *, struct ata_device *);<br />-<br />+#ifdef CONFIG_ACPI<br />+extern void ata_acpi_notify(acpi_handle device, u32 type, void *data);<br />+#endif<br /> /*<br /> * Default driver ops implementations<br /> */<br />diff -u include/linux/libata.h /tmp/include/linux/libata.h<br />--- include/linux/libata.h 2005-12-05 14:32:50 +0000<br />+++ /tmp/include/linux/libata.h 2005-12-08 02:10:03 +0000<br />&#64;&#64; -448,12 +463,16 &#64;&#64;<br /> extern int ata_scsi_error(struct Scsi_Host *host);<br /> extern int ata_scsi_release(struct Scsi_Host *host);<br /> extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);<br />+extern void ata_hotplug_unplug(struct ata_port *ap);<br />+extern void ata_hotplug_plug(struct ata_port *ap);<br /> extern int ata_ratelimit(void);<br /> extern int ata_scsi_device_resume(struct scsi_device *);<br /> extern int ata_scsi_device_suspend(struct scsi_device *);<br /> extern int ata_device_resume(struct ata_port *, struct ata_device *);<br /> extern int ata_device_suspend(struct ata_port *, struct ata_device *);<br />-<br />+#ifdef CONFIG_ACPI<br />+extern void ata_acpi_notify(acpi_handle device, u32 type, void *data);<br />+#endif<br /> /*<br /> * Default driver ops implementations<br /> */<br />diff -u include/scsi/scsi_host.h /tmp/include/scsi/scsi_host.h<br />--- include/scsi/scsi_host.h 2005-11-14 14:57:13 +0000<br />+++ /tmp/include/scsi/scsi_host.h 2005-12-08 02:12:14 +0000<br />&#64;&#64; -5,6 +5,7 &#64;&#64;<br /> #include &lt;linux/list.h&gt;<br /> #include &lt;linux/types.h&gt;<br /> #include &lt;linux/workqueue.h&gt;<br />+#include &lt;linux/acpi.h&gt;<br /> <br /> struct block_device;<br /> struct completion;<br />&#64;&#64; -300,6 +301,13 &#64;&#64;<br /> */<br /> int (*resume)(struct scsi_device *);<br /> int (*suspend)(struct scsi_device *);<br />+ <br />+#ifdef CONFIG_ACPI<br />+ /*<br />+ * ACPI notification handler<br />+ */<br />+ void (*acpi_notify)(acpi_handle device, u32 type, void *data); <br />+#endif<br /> <br /> /*<br /> * Name of proc directory<br />-- <br />Matthew Garrett | mjg59&#64;srcf.ucam.org<br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo&#64;vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-12-08 04:05 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10