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@xxxxxxxxx> 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); --
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@xxxxxxxxx> 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); --