* Re: [patch 3/3] libata: handle AN interrupt
@ 2007-03-29 12:38 James Smart
2007-03-29 12:43 ` Jeff Garzik
0 siblings, 1 reply; 6+ messages in thread
From: James Smart @ 2007-03-29 12:38 UTC (permalink / raw)
To: Kristen Carlson Accardi; +Cc: linux-kernel, akpm, linux-ide, linux-scsi
fyi...
For FC, we have several async events, and allow for LLDDs to send their own
data or augment the generic transport event w/ additional LLDD-data. The
infrastructure is implemented generically within the scsi midlayer.
We are using Netlink w/ broadcasts to deliver the events rather than kobject_uevent().
We considered using a variant of kobject events, but the general consensus was
we didn't want to wrap transport events into the kobject infrastructure, and using
netlink natively allowed for transport data to be sent with the event. Additionally,
with the broadcast, we could support any number of tools concurrently listening for
change events. To date, this has worked very well. You may want to consider this,
especially if the types of events is expected to grow beyond the simple "change"
notification.
-- james s
>List: linux-kernel
>Subject: [patch 3/3] libata: handle AN interrupt
>From: Kristen Carlson Accardi <kristen.c.accardi () intel ! com>
>Date: 2007-03-28 23:44:57
>Message-ID: 20070328164457.a675a7d2.kristen.c.accardi () intel ! com
>[Download message RAW]
>
>When we get an SDB FIS with the 'N' bit set, we should send
>an event to user space to indicate that there has been a
>media change. The ahci host controller will send the
>event via KOBJ_CHANGE uevent.
>
>Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
>Index: 2.6-mm/drivers/ata/ahci.c
>===================================================================
>--- 2.6-mm.orig/drivers/ata/ahci.c
>+++ 2.6-mm/drivers/ata/ahci.c
>@@ -1164,6 +1164,26 @@ static void ahci_host_intr(struct ata_po
> return;
> }
>
>+ if (status & PORT_IRQ_SDB_FIS) {
>+ /*
>+ * if this is an ATAPI device with AN turned on,
>+ * then we should interrogate the device to
>+ * determine the cause of the interrupt
>+ *
>+ * for AN - this we should check the SDB FIS
>+ * and find the I and N bits set
>+ */
>+ const u32 *f = pp->rx_fis + RX_FIS_SDB;
>+
>+ /* check the 'N' bit in word 0 of the FIS */
>+ if (f[0] & (1 << 15)) {
>+ int port_addr = ((f[0] & 0x00000f00) >> 8);
>+ struct ata_device *adev = &ap->device[port_addr];
>+ ata_port_printk(ap, KERN_INFO, "N bit set on SDB FIS!\n");
>+ if (adev->flags & ATA_DFLAG_AN)
>+ ata_async_notify(adev);
>+ }
>+ }
> if (ap->sactive)
> qc_active = readl(port_mmio + PORT_SCR_ACT);
> else
>Index: 2.6-mm/include/linux/libata.h
>===================================================================
>--- 2.6-mm.orig/include/linux/libata.h
>+++ 2.6-mm/include/linux/libata.h
>@@ -492,6 +492,7 @@ struct ata_device {
> /* ACPI objects info */
> acpi_handle obj_handle;
> #endif
>+ struct work_struct async_notify;
> };
>
> /* Offset into struct ata_device. Fields above it are maintained
>@@ -826,6 +827,7 @@ extern void ata_scsi_slave_destroy(struc
> extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
> int queue_depth);
> extern struct ata_device *ata_dev_pair(struct ata_device *adev);
>+extern void ata_async_notify(struct ata_device *atadev);
> extern int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
> extern u8 ata_irq_on(struct ata_port *ap);
> extern u8 ata_dummy_irq_on(struct ata_port *ap);
>Index: 2.6-mm/drivers/ata/libata-core.c
>===================================================================
>--- 2.6-mm.orig/drivers/ata/libata-core.c
>+++ 2.6-mm/drivers/ata/libata-core.c
>@@ -1576,6 +1576,26 @@ static void ata_dev_config_ncq(struct at
> snprintf(desc, desc_sz, "NCQ (depth %d/%d)", hdepth, ddepth);
> }
>
>+static void async_notify_thread(struct work_struct *work)
>+{
>+ struct ata_device *atadev =
>+ container_of(work, struct ata_device, async_notify);
>+
>+ /*
>+ * TBD - who should send this event? I couldn't find an
>+ * easy way to map an ata_device to a genhd device, so
>+ * decided maybe the ata host should send the event and
>+ * allow user space to figure out what happened?
>+ */
>+ kobject_uevent(&atadev->ap->host->dev->kobj, KOBJ_CHANGE);
>+}
>+
>+void ata_async_notify(struct ata_device *atadev)
>+{
>+ schedule_work(&atadev->async_notify);
>+}
>+
>+
> /**
> * ata_dev_configure - Configure the specified ATA/ATAPI device
> * @dev: Target device to configure
>@@ -1761,6 +1781,7 @@ int ata_dev_configure(struct ata_device
> goto err_out_nosup;
> }
> dev->flags |= ATA_DFLAG_AN;
>+ INIT_WORK(&dev->async_notify, async_notify_thread);
> }
>
> if (ata_id_cdb_intr(dev->id)) {
>@@ -6650,6 +6671,7 @@ EXPORT_SYMBOL_GPL(ata_dummy_irq_on);
> EXPORT_SYMBOL_GPL(ata_irq_ack);
> EXPORT_SYMBOL_GPL(ata_dummy_irq_ack);
> EXPORT_SYMBOL_GPL(ata_dev_try_classify);
>+EXPORT_SYMBOL_GPL(ata_async_notify);
>
> EXPORT_SYMBOL_GPL(ata_cable_40wire);
> EXPORT_SYMBOL_GPL(ata_cable_80wire);
>
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch 3/3] libata: handle AN interrupt
2007-03-29 12:38 [patch 3/3] libata: handle AN interrupt James Smart
@ 2007-03-29 12:43 ` Jeff Garzik
2007-03-29 13:04 ` James Smart
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2007-03-29 12:43 UTC (permalink / raw)
To: James.Smart
Cc: Kristen Carlson Accardi, linux-kernel, akpm, linux-ide,
linux-scsi
James Smart wrote:
> For FC, we have several async events, and allow for LLDDs to send their own
> data or augment the generic transport event w/ additional LLDD-data. The
> infrastructure is implemented generically within the scsi midlayer.
> We are using Netlink w/ broadcasts to deliver the events rather than
> kobject_uevent().
> We considered using a variant of kobject events, but the general
> consensus was
> we didn't want to wrap transport events into the kobject infrastructure,
> and using
> netlink natively allowed for transport data to be sent with the event.
> Additionally,
> with the broadcast, we could support any number of tools concurrently
> listening for
> change events. To date, this has worked very well. You may want to
> consider this,
> especially if the types of events is expected to grow beyond the simple
> "change"
> notification.
Fair enough, though I definitely lean towards some use of sysfs / device
model for AN-style events specifically. The media change events are
generated by the device, not the transport, and we should definitely
have an object in the device model that represents the device (if we
don't already).
I could see transport-based events being delivered to a different
endpoint, because transport events differ from device events.
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 3/3] libata: handle AN interrupt
2007-03-29 12:43 ` Jeff Garzik
@ 2007-03-29 13:04 ` James Smart
0 siblings, 0 replies; 6+ messages in thread
From: James Smart @ 2007-03-29 13:04 UTC (permalink / raw)
To: Jeff Garzik
Cc: Kristen Carlson Accardi, linux-kernel, akpm, linux-ide,
linux-scsi
Jeff Garzik wrote:
> Fair enough, though I definitely lean towards some use of sysfs / device
> model for AN-style events specifically. The media change events are
> generated by the device, not the transport, and we should definitely
> have an object in the device model that represents the device (if we
> don't already).
>
> I could see transport-based events being delivered to a different
> endpoint, because transport events differ from device events.
>
> Jeff
Sure... although what object the event relates to is really a component of
either the socket (1 per object) or an object identifier within the event
message (1 socket with message headers). The transport, as we use it, really
isn't the object and isn't the one generating the events, it's just a well-known
listening point and serves as a nice library to insulate drivers from the
implementation.
Granted, what's being proposed now is fairly simple, so sysfs works fine.
But if you grow at all, you'll be confronted with the multiple-readers
and payload issues that we had.
-- james
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20070328230108.597741522@intel.com>]
* [patch 3/3] libata: handle AN interrupt
[not found] <20070328230108.597741522@intel.com>
@ 2007-03-28 23:44 ` Kristen Carlson Accardi
2007-03-29 2:13 ` Tejun Heo
0 siblings, 1 reply; 6+ messages in thread
From: Kristen Carlson Accardi @ 2007-03-28 23:44 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, linux-ide, jgarzik, Kristen Carlson Accardi
When we get an SDB FIS with the 'N' bit set, we should send
an event to user space to indicate that there has been a
media change. The ahci host controller will send the
event via KOBJ_CHANGE uevent.
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Index: 2.6-mm/drivers/ata/ahci.c
===================================================================
--- 2.6-mm.orig/drivers/ata/ahci.c
+++ 2.6-mm/drivers/ata/ahci.c
@@ -1164,6 +1164,26 @@ static void ahci_host_intr(struct ata_po
return;
}
+ if (status & PORT_IRQ_SDB_FIS) {
+ /*
+ * if this is an ATAPI device with AN turned on,
+ * then we should interrogate the device to
+ * determine the cause of the interrupt
+ *
+ * for AN - this we should check the SDB FIS
+ * and find the I and N bits set
+ */
+ const u32 *f = pp->rx_fis + RX_FIS_SDB;
+
+ /* check the 'N' bit in word 0 of the FIS */
+ if (f[0] & (1 << 15)) {
+ int port_addr = ((f[0] & 0x00000f00) >> 8);
+ struct ata_device *adev = &ap->device[port_addr];
+ ata_port_printk(ap, KERN_INFO, "N bit set on SDB FIS!\n");
+ if (adev->flags & ATA_DFLAG_AN)
+ ata_async_notify(adev);
+ }
+ }
if (ap->sactive)
qc_active = readl(port_mmio + PORT_SCR_ACT);
else
Index: 2.6-mm/include/linux/libata.h
===================================================================
--- 2.6-mm.orig/include/linux/libata.h
+++ 2.6-mm/include/linux/libata.h
@@ -492,6 +492,7 @@ struct ata_device {
/* ACPI objects info */
acpi_handle obj_handle;
#endif
+ struct work_struct async_notify;
};
/* Offset into struct ata_device. Fields above it are maintained
@@ -826,6 +827,7 @@ extern void ata_scsi_slave_destroy(struc
extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
int queue_depth);
extern struct ata_device *ata_dev_pair(struct ata_device *adev);
+extern void ata_async_notify(struct ata_device *atadev);
extern int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
extern u8 ata_irq_on(struct ata_port *ap);
extern u8 ata_dummy_irq_on(struct ata_port *ap);
Index: 2.6-mm/drivers/ata/libata-core.c
===================================================================
--- 2.6-mm.orig/drivers/ata/libata-core.c
+++ 2.6-mm/drivers/ata/libata-core.c
@@ -1576,6 +1576,26 @@ static void ata_dev_config_ncq(struct at
snprintf(desc, desc_sz, "NCQ (depth %d/%d)", hdepth, ddepth);
}
+static void async_notify_thread(struct work_struct *work)
+{
+ struct ata_device *atadev =
+ container_of(work, struct ata_device, async_notify);
+
+ /*
+ * TBD - who should send this event? I couldn't find an
+ * easy way to map an ata_device to a genhd device, so
+ * decided maybe the ata host should send the event and
+ * allow user space to figure out what happened?
+ */
+ kobject_uevent(&atadev->ap->host->dev->kobj, KOBJ_CHANGE);
+}
+
+void ata_async_notify(struct ata_device *atadev)
+{
+ schedule_work(&atadev->async_notify);
+}
+
+
/**
* ata_dev_configure - Configure the specified ATA/ATAPI device
* @dev: Target device to configure
@@ -1761,6 +1781,7 @@ int ata_dev_configure(struct ata_device
goto err_out_nosup;
}
dev->flags |= ATA_DFLAG_AN;
+ INIT_WORK(&dev->async_notify, async_notify_thread);
}
if (ata_id_cdb_intr(dev->id)) {
@@ -6650,6 +6671,7 @@ EXPORT_SYMBOL_GPL(ata_dummy_irq_on);
EXPORT_SYMBOL_GPL(ata_irq_ack);
EXPORT_SYMBOL_GPL(ata_dummy_irq_ack);
EXPORT_SYMBOL_GPL(ata_dev_try_classify);
+EXPORT_SYMBOL_GPL(ata_async_notify);
EXPORT_SYMBOL_GPL(ata_cable_40wire);
EXPORT_SYMBOL_GPL(ata_cable_80wire);
--
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch 3/3] libata: handle AN interrupt
2007-03-28 23:44 ` Kristen Carlson Accardi
@ 2007-03-29 2:13 ` Tejun Heo
0 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2007-03-29 2:13 UTC (permalink / raw)
To: Kristen Carlson Accardi; +Cc: linux-kernel, akpm, linux-ide, jgarzik
Kristen Carlson Accardi wrote:
> When we get an SDB FIS with the 'N' bit set, we should send
> an event to user space to indicate that there has been a
> media change. The ahci host controller will send the
> event via KOBJ_CHANGE uevent.
>
> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
>
> +static void async_notify_thread(struct work_struct *work)
> +{
> + struct ata_device *atadev =
> + container_of(work, struct ata_device, async_notify);
> +
> + /*
> + * TBD - who should send this event? I couldn't find an
> + * easy way to map an ata_device to a genhd device, so
> + * decided maybe the ata host should send the event and
> + * allow user space to figure out what happened?
> + */
> + kobject_uevent(&atadev->ap->host->dev->kobj, KOBJ_CHANGE);
> +}
I don't think this is right. If you're gonna make media_change_event
capability generic, you gotta make event delivery generic too. You can
make it a genhd event and make genhd supply the interface function, say,
genhd_notify_media_change() which is then forwarded by SCSI layer.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20070321004740.939006166@intel.com>]
* [patch 3/3] libata: handle AN interrupt
[not found] <20070321004740.939006166@intel.com>
@ 2007-03-21 0:52 ` Kristen Carlson Accardi
0 siblings, 0 replies; 6+ messages in thread
From: Kristen Carlson Accardi @ 2007-03-21 0:52 UTC (permalink / raw)
To: linux-ide; +Cc: jgarzik, Kristen Carlson Accardi
[-- Attachment #1: Type: text/plain, Size: 3324 bytes --]
When we get an SDB FIS with the 'N' bit set, we should send
an event to user space to indicate that there has been a
media change. The ahci host controller will send the
event via KOBJ_CHANGE uevent.
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Index: 2.6-git/drivers/ata/ahci.c
===================================================================
--- 2.6-git.orig/drivers/ata/ahci.c 2007-03-21 01:25:24.000000000 -0700
+++ 2.6-git/drivers/ata/ahci.c 2007-03-21 01:25:43.000000000 -0700
@@ -1126,6 +1126,26 @@
return;
}
+ if (status & PORT_IRQ_SDB_FIS) {
+ /*
+ * if this is an ATAPI device with AN turned on,
+ * then we should interrogate the device to
+ * determine the cause of the interrupt
+ *
+ * for AN - this we should check the SDB FIS
+ * and find the I and N bits set
+ */
+ const u32 *f = pp->rx_fis + RX_FIS_SDB;
+
+ /* check the 'N' bit in word 0 of the FIS */
+ if (f[0] & (1 << 15)) {
+ int port_addr = ((f[0] & 0x00000f00) >> 8);
+ struct ata_device *adev = &ap->device[port_addr];
+ ata_port_printk(ap, KERN_INFO, "N bit set on SDB FIS!\n");
+ if (adev->flags & ATA_DFLAG_AN)
+ ata_async_notify(adev);
+ }
+ }
if (ap->sactive)
qc_active = readl(port_mmio + PORT_SCR_ACT);
else
Index: 2.6-git/include/linux/libata.h
===================================================================
--- 2.6-git.orig/include/linux/libata.h 2007-03-21 01:25:24.000000000 -0700
+++ 2.6-git/include/linux/libata.h 2007-03-21 01:25:43.000000000 -0700
@@ -504,6 +504,7 @@
/* error history */
struct ata_ering ering;
unsigned int horkage; /* List of broken features */
+ struct work_struct async_notify;
};
/* Offset into struct ata_device. Fields above it are maintained
@@ -827,6 +828,7 @@
extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
int queue_depth);
extern struct ata_device *ata_dev_pair(struct ata_device *adev);
+extern void ata_async_notify(struct ata_device *atadev);
/*
* Timing helpers
Index: 2.6-git/drivers/ata/libata-core.c
===================================================================
--- 2.6-git.orig/drivers/ata/libata-core.c 2007-03-21 01:25:24.000000000 -0700
+++ 2.6-git/drivers/ata/libata-core.c 2007-03-21 01:25:43.000000000 -0700
@@ -1589,6 +1589,26 @@
}
}
+static void async_notify_thread(struct work_struct *work)
+{
+ struct ata_device *atadev =
+ container_of(work, struct ata_device, async_notify);
+
+ /*
+ * TBD - who should send this event? I couldn't find an
+ * easy way to map an ata_device to a genhd device, so
+ * decided maybe the ata host should send the event and
+ * allow user space to figure out what happened?
+ */
+ kobject_uevent(&atadev->ap->host->dev->kobj, KOBJ_CHANGE);
+}
+
+void ata_async_notify(struct ata_device *atadev)
+{
+ schedule_work(&atadev->async_notify);
+}
+
+
/**
* ata_dev_configure - Configure the specified ATA/ATAPI device
* @dev: Target device to configure
@@ -1755,6 +1775,7 @@
goto err_out_nosup;
}
dev->flags |= ATA_DFLAG_AN;
+ INIT_WORK(&dev->async_notify, async_notify_thread);
}
if (ata_id_cdb_intr(dev->id)) {
@@ -6545,3 +6566,4 @@
EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
EXPORT_SYMBOL_GPL(ata_do_eh);
+EXPORT_SYMBOL_GPL(ata_async_notify);
--
[-- Attachment #2: libata-send-async-event-on-media-change --]
[-- Type: text/plain, Size: 3324 bytes --]
When we get an SDB FIS with the 'N' bit set, we should send
an event to user space to indicate that there has been a
media change. The ahci host controller will send the
event via KOBJ_CHANGE uevent.
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Index: 2.6-git/drivers/ata/ahci.c
===================================================================
--- 2.6-git.orig/drivers/ata/ahci.c 2007-03-21 01:25:24.000000000 -0700
+++ 2.6-git/drivers/ata/ahci.c 2007-03-21 01:25:43.000000000 -0700
@@ -1126,6 +1126,26 @@
return;
}
+ if (status & PORT_IRQ_SDB_FIS) {
+ /*
+ * if this is an ATAPI device with AN turned on,
+ * then we should interrogate the device to
+ * determine the cause of the interrupt
+ *
+ * for AN - this we should check the SDB FIS
+ * and find the I and N bits set
+ */
+ const u32 *f = pp->rx_fis + RX_FIS_SDB;
+
+ /* check the 'N' bit in word 0 of the FIS */
+ if (f[0] & (1 << 15)) {
+ int port_addr = ((f[0] & 0x00000f00) >> 8);
+ struct ata_device *adev = &ap->device[port_addr];
+ ata_port_printk(ap, KERN_INFO, "N bit set on SDB FIS!\n");
+ if (adev->flags & ATA_DFLAG_AN)
+ ata_async_notify(adev);
+ }
+ }
if (ap->sactive)
qc_active = readl(port_mmio + PORT_SCR_ACT);
else
Index: 2.6-git/include/linux/libata.h
===================================================================
--- 2.6-git.orig/include/linux/libata.h 2007-03-21 01:25:24.000000000 -0700
+++ 2.6-git/include/linux/libata.h 2007-03-21 01:25:43.000000000 -0700
@@ -504,6 +504,7 @@
/* error history */
struct ata_ering ering;
unsigned int horkage; /* List of broken features */
+ struct work_struct async_notify;
};
/* Offset into struct ata_device. Fields above it are maintained
@@ -827,6 +828,7 @@
extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
int queue_depth);
extern struct ata_device *ata_dev_pair(struct ata_device *adev);
+extern void ata_async_notify(struct ata_device *atadev);
/*
* Timing helpers
Index: 2.6-git/drivers/ata/libata-core.c
===================================================================
--- 2.6-git.orig/drivers/ata/libata-core.c 2007-03-21 01:25:24.000000000 -0700
+++ 2.6-git/drivers/ata/libata-core.c 2007-03-21 01:25:43.000000000 -0700
@@ -1589,6 +1589,26 @@
}
}
+static void async_notify_thread(struct work_struct *work)
+{
+ struct ata_device *atadev =
+ container_of(work, struct ata_device, async_notify);
+
+ /*
+ * TBD - who should send this event? I couldn't find an
+ * easy way to map an ata_device to a genhd device, so
+ * decided maybe the ata host should send the event and
+ * allow user space to figure out what happened?
+ */
+ kobject_uevent(&atadev->ap->host->dev->kobj, KOBJ_CHANGE);
+}
+
+void ata_async_notify(struct ata_device *atadev)
+{
+ schedule_work(&atadev->async_notify);
+}
+
+
/**
* ata_dev_configure - Configure the specified ATA/ATAPI device
* @dev: Target device to configure
@@ -1755,6 +1775,7 @@
goto err_out_nosup;
}
dev->flags |= ATA_DFLAG_AN;
+ INIT_WORK(&dev->async_notify, async_notify_thread);
}
if (ata_id_cdb_intr(dev->id)) {
@@ -6545,3 +6566,4 @@
EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
EXPORT_SYMBOL_GPL(ata_do_eh);
+EXPORT_SYMBOL_GPL(ata_async_notify);
--
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-29 13:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-29 12:38 [patch 3/3] libata: handle AN interrupt James Smart
2007-03-29 12:43 ` Jeff Garzik
2007-03-29 13:04 ` James Smart
[not found] <20070328230108.597741522@intel.com>
2007-03-28 23:44 ` Kristen Carlson Accardi
2007-03-29 2:13 ` Tejun Heo
[not found] <20070321004740.939006166@intel.com>
2007-03-21 0:52 ` Kristen Carlson Accardi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).