From c3a44a47e8f60e8e4ae58d3a024b9a7ab293e673 Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Tue, 5 Jun 2007 22:33:29 +0900 Subject: [PATCH 01/15] remove unused variable in pata_isapnp This patch has removed unused variable in pata_ispnp. Signed-off-by: Yoichi Yuasa Signed-off-by: Jeff Garzik --- drivers/ata/pata_isapnp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c index 1f647b648204..5525518204e6 100644 --- a/drivers/ata/pata_isapnp.c +++ b/drivers/ata/pata_isapnp.c @@ -77,7 +77,6 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev struct ata_host *host; struct ata_port *ap; void __iomem *cmd_addr, *ctl_addr; - int rc; if (pnp_port_valid(idev, 0) == 0) return -ENODEV; From bd9c5a39e4141678bd6242e5b74bfe39d8d0be35 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 8 Jun 2007 22:20:59 +0900 Subject: [PATCH 02/15] libata: disable NCQ for HITACHI HTS541680J9SA00/SB21C7EP HITACHI HTS541680J9SA00/SB21C7EP spuriously completes NCQ commands. Blacklist it for NCQ. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4733f009c7c9..6a8a5179ceef 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3791,6 +3791,8 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, }, { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, }, + /* Drives which do spurious command completion */ + { "HTS541680J9SA00", "SB2IC7EP", ATA_HORKAGE_NONCQ, }, /* Devices with NCQ limits */ From 22888423b3b1b96573250671afb5b72ea4364902 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Sun, 3 Jun 2007 18:35:10 -0500 Subject: [PATCH 03/15] libata: fix probe time irq printouts Most drivers don't seem to fill out the host->irq field, resulting in the wrong (no) irq being reported at probe time. For example, sil24 on my system: ata1: SATA max UDMA/100 cmd 0xd00008009001f000 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 0 ata2: SATA max UDMA/100 cmd 0xd000080090021000 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 0 Since they're allocated and set up in ata_host_activate(), just save them away there. Signed-off-by: Olof Johansson Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 6a8a5179ceef..c90c8e0fc49c 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6435,6 +6435,9 @@ int ata_host_activate(struct ata_host *host, int irq, if (rc) devm_free_irq(host->dev, irq, host); + /* Used to print device info at probe */ + host->irq = irq; + return rc; } From ef143d577ba98c8a53aee9aa60e7d1f07c32fd7a Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Tue, 5 Jun 2007 13:01:33 +0800 Subject: [PATCH 04/15] libata: print device model and firmware revision for ATAPI devices For ATA/CFA devices, libata prints out the device model and firmware revision. Do the same for ATAPI devices. Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index c90c8e0fc49c..e7937166a8ba 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -1900,6 +1900,13 @@ int ata_dev_configure(struct ata_device *dev) if (ata_msg_probe(ap)) ata_dump_id(id); + /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ + ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, + sizeof(fwrevbuf)); + + ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD, + sizeof(modelbuf)); + /* ATA-specific feature tests */ if (dev->class == ATA_DEV_ATA) { if (ata_id_is_cfa(id)) { @@ -1914,13 +1921,6 @@ int ata_dev_configure(struct ata_device *dev) dev->n_sectors = ata_id_n_sectors(id); - /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ - ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, - sizeof(fwrevbuf)); - - ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD, - sizeof(modelbuf)); - if (dev->id[59] & 0x100) dev->multi_count = dev->id[59] & 0xff; @@ -2009,7 +2009,9 @@ int ata_dev_configure(struct ata_device *dev) /* print device info to dmesg */ if (ata_msg_drv(ap) && print_info) - ata_dev_printk(dev, KERN_INFO, "ATAPI, max %s%s\n", + ata_dev_printk(dev, KERN_INFO, + "ATAPI: %s, %s, max %s%s\n", + modelbuf, fwrevbuf, ata_mode_string(xfer_mask), cdb_intr_string); } From afe3cc51ba4be6b25b721c40f178ea4157751161 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 6 Jun 2007 16:35:55 +0900 Subject: [PATCH 05/15] libata: fix hw_sata_spd_limit initialization hw_sata_spd_limit used to be incorrectly initialized to zero instead of UINT_MAX if SPD is zero in SControl register. This breaks PHY speed down. Fix it. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index e7937166a8ba..bf8d3b8c171d 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6317,7 +6317,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) /* init sata_spd_limit to the current value */ if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { int spd = (scontrol >> 4) & 0xf; - ap->hw_sata_spd_limit &= (1 << spd) - 1; + if (spd) + ap->hw_sata_spd_limit &= (1 << spd) - 1; } ap->sata_spd_limit = ap->hw_sata_spd_limit; From 0522b2869d89b095bf417c8cc6fa404842e91903 Mon Sep 17 00:00:00 2001 From: Peer Chen Date: Thu, 7 Jun 2007 18:05:12 +0800 Subject: [PATCH 06/15] ahci: Add MCP73/MCP77 support to AHCI driver Add the MCP73/MCP77 support to ahci driver. Signed-off-by: Peer Chen Signed-off-by: Jeff Garzik --- drivers/ata/ahci.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 7baeaffefe7a..545f330e59a5 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -426,6 +426,30 @@ static const struct pci_device_id ahci_pci_tbl[] = { { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */ { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */ { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */ + { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci }, /* MCP73 */ + { PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad3), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad4), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad5), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad6), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad7), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad8), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ad9), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0ada), board_ahci }, /* MCP77 */ + { PCI_VDEVICE(NVIDIA, 0x0adb), board_ahci }, /* MCP77 */ /* SiS */ { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ From d92e74d353345d19f762e9501a50b0a5f43f7ba8 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 7 Jun 2007 16:19:15 +0100 Subject: [PATCH 07/15] libata-core/sff: Fix multiple assumptions about DMA The ata IRQ ack functions are only used when debugging. Unfortunately almost every controller that calls them can cause crashes in some configurations as there are missing checks for bmdma presence. In addition ata_port_start insists of installing DMA buffers and pad buffers for controllers regardless. The SFF controllers actually need to make that decision dynamically at controller setup time and all need the same helper - so we add ata_sff_port_start. Future patches will switch the SFF drivers to use this. Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 1 + drivers/ata/libata-sff.c | 37 +++++++++++++++++++++++++++++-------- include/linux/libata.h | 1 + 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index bf8d3b8c171d..85283c04d642 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6826,6 +6826,7 @@ EXPORT_SYMBOL_GPL(ata_check_status); EXPORT_SYMBOL_GPL(ata_altstatus); EXPORT_SYMBOL_GPL(ata_exec_command); EXPORT_SYMBOL_GPL(ata_port_start); +EXPORT_SYMBOL_GPL(ata_sff_port_start); EXPORT_SYMBOL_GPL(ata_interrupt); EXPORT_SYMBOL_GPL(ata_do_set_mode); EXPORT_SYMBOL_GPL(ata_data_xfer); diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index e35d13466c69..ce84805ba5f1 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c @@ -80,25 +80,25 @@ u8 ata_dummy_irq_on (struct ata_port *ap) { return 0; } u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) { unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; - u8 host_stat, post_stat, status; + u8 host_stat = 0, post_stat = 0, status; status = ata_busy_wait(ap, bits, 1000); if (status & bits) if (ata_msg_err(ap)) printk(KERN_ERR "abnormal status 0x%X\n", status); - /* get controller status; clear intr, err bits */ - host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); - iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR, - ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); - - post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); + if (ap->ioaddr.bmdma_addr) { + /* get controller status; clear intr, err bits */ + host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); + iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR, + ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); + post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); + } if (ata_msg_intr(ap)) printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", __FUNCTION__, host_stat, post_stat, status); - return status; } @@ -516,6 +516,27 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc) ata_bmdma_stop(qc); } +/** + * ata_sff_port_start - Set port up for dma. + * @ap: Port to initialize + * + * Called just after data structures for each port are + * initialized. Allocates space for PRD table if the device + * is DMA capable SFF. + * + * May be used as the port_start() entry in ata_port_operations. + * + * LOCKING: + * Inherited from caller. + */ + +int ata_sff_port_start(struct ata_port *ap) +{ + if (ap->ioaddr.bmdma_addr) + return ata_port_start(ap); + return 0; +} + #ifdef CONFIG_PCI static int ata_resources_present(struct pci_dev *pdev, int port) diff --git a/include/linux/libata.h b/include/linux/libata.h index a6a3113120a4..745c4f9b4caa 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -753,6 +753,7 @@ extern u8 ata_check_status(struct ata_port *ap); extern u8 ata_altstatus(struct ata_port *ap); extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); extern int ata_port_start (struct ata_port *ap); +extern int ata_sff_port_start (struct ata_port *ap); extern irqreturn_t ata_interrupt (int irq, void *dev_instance); extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data); From 6070068b875f604ff3f62e6e342bbd4c1f34a895 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 7 Jun 2007 16:13:55 +0100 Subject: [PATCH 08/15] libata: Correct abuse of language The controller is not reporting an unlawful type, it is reporting an invalid type. Illegal specifically means "prohibited by law" Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 85283c04d642..4b3c45e91c76 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -1727,7 +1727,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, /* sanity check */ rc = -EINVAL; - reason = "device reports illegal type"; + reason = "device reports invalid type"; if (class == ATA_DEV_ATA) { if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) From f93f1078d08e0f63a6a4bdaa154de3642fc03d5d Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 7 Jun 2007 15:47:13 +0800 Subject: [PATCH 09/15] libata passthru: update protocol numbers Update the ATA passthru protocol numbers according to the new spec. Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index b3900cfbd880..f70431a4c9e9 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2512,16 +2512,15 @@ ata_scsi_map_proto(u8 byte1) case 5: /* PIO Data-out */ return ATA_PROT_PIO; - case 10: /* Device Reset */ case 0: /* Hard Reset */ case 1: /* SRST */ - case 2: /* Bus Idle */ - case 7: /* Packet */ - case 8: /* DMA Queued */ - case 9: /* Device Diagnostic */ - case 11: /* UDMA Data-in */ - case 12: /* UDMA Data-Out */ - case 13: /* FPDMA */ + case 8: /* Device Diagnostic */ + case 9: /* Device Reset */ + case 7: /* DMA Queued */ + case 10: /* UDMA Data-in */ + case 11: /* UDMA Data-Out */ + case 12: /* FPDMA */ + case 15: /* Return Response Info */ default: /* Reserved */ break; } From 1dce589c38c36ae69614840ee230183f3a7d43c5 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 7 Jun 2007 15:49:22 +0800 Subject: [PATCH 10/15] libata passthru: support PIO multi commands support the pass through of PIO multi commands. Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 20 ++++++++++++++++---- include/linux/ata.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index f70431a4c9e9..8a66ca5f9530 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2551,10 +2551,6 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) goto invalid_fld; - if (cdb[1] & 0xe0) - /* PIO multi not supported yet */ - goto invalid_fld; - /* * 12 and 16 byte CDBs use different offsets to * provide the various register values. @@ -2606,6 +2602,22 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) tf->device = qc->dev->devno ? tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; + /* sanity check for pio multi commands */ + if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf)) + goto invalid_fld; + + if (is_multi_taskfile(tf)) { + unsigned int multi_count = 1 << (cdb[1] >> 5); + + /* compare the passed through multi_count + * with the cached multi_count of libata + */ + if (multi_count != dev->multi_count) + ata_dev_printk(dev, KERN_WARNING, + "invalid multi_count %u ignored\n", + multi_count); + } + /* READ/WRITE LONG use a non-standard sect_size */ qc->sect_size = ATA_SECT_SIZE; switch (tf->command) { diff --git a/include/linux/ata.h b/include/linux/ata.h index edb31bfff68f..3e95e5c402d4 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -249,7 +249,7 @@ enum ata_tf_protocols { /* ATA taskfile protocols */ ATA_PROT_UNKNOWN, /* unknown/invalid */ ATA_PROT_NODATA, /* no data */ - ATA_PROT_PIO, /* PIO single sector */ + ATA_PROT_PIO, /* PIO data xfer */ ATA_PROT_DMA, /* DMA */ ATA_PROT_NCQ, /* NCQ */ ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ From 23cb1d718ddbeb718ed7ca5be283dcbfb63993c3 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 7 Jun 2007 15:50:44 +0800 Subject: [PATCH 11/15] libata passthru: map UDMA protocols Map the ATA passthru UDMA protocols to ATA_PROT_DMA. Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 8a66ca5f9530..8c6a2b2e81b4 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2506,6 +2506,8 @@ ata_scsi_map_proto(u8 byte1) return ATA_PROT_NODATA; case 6: /* DMA */ + case 10: /* UDMA Data-in */ + case 11: /* UDMA Data-Out */ return ATA_PROT_DMA; case 4: /* PIO Data-in */ @@ -2517,8 +2519,6 @@ ata_scsi_map_proto(u8 byte1) case 8: /* Device Diagnostic */ case 9: /* Device Reset */ case 7: /* DMA Queued */ - case 10: /* UDMA Data-in */ - case 11: /* UDMA Data-Out */ case 12: /* FPDMA */ case 15: /* Return Response Info */ default: /* Reserved */ From fa4453c4c94a61bbefe470b16ddbb6218481c6dc Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 7 Jun 2007 15:52:07 +0800 Subject: [PATCH 12/15] libata passthru: always enforce correct DEV bit Always enforce correct DEV bit since we know which drive the command is targeted. SAT demands to ignore the DEV bit, too. Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 8c6a2b2e81b4..884f52f43f8f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2595,12 +2595,10 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) tf->device = cdb[8]; tf->command = cdb[9]; } - /* - * If slave is possible, enforce correct master/slave bit - */ - if (qc->ap->flags & ATA_FLAG_SLAVE_POSS) - tf->device = qc->dev->devno ? - tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; + + /* enforce correct master/slave bit */ + tf->device = dev->devno ? + tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; /* sanity check for pio multi commands */ if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf)) From 2c3d2a46f1ccf591850b20f4fdde12bcf2bf3dfd Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 7 Jun 2007 16:01:17 +0800 Subject: [PATCH 13/15] libata passthru: update cached device paramters INIT_DEV_PARAMS and SET_MULTI_MODE change the device parameters cached by libata. Re-read IDENTIFY DEVICE info and update the cached device paramters when seeing these commands. Signed-off-by: Albert Lee Signed-off-by: Jeff Garzik --- drivers/ata/libata-scsi.c | 22 ++++++++++++++++------ include/linux/ata.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 884f52f43f8f..c228df298bd8 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1363,12 +1363,22 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE * cache */ - if (ap->ops->error_handler && - !need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) && - ((qc->tf.feature == SETFEATURES_WC_ON) || - (qc->tf.feature == SETFEATURES_WC_OFF))) { - ap->eh_info.action |= ATA_EH_REVALIDATE; - ata_port_schedule_eh(ap); + if (ap->ops->error_handler && !need_sense) { + switch (qc->tf.command) { + case ATA_CMD_SET_FEATURES: + if ((qc->tf.feature == SETFEATURES_WC_ON) || + (qc->tf.feature == SETFEATURES_WC_OFF)) { + ap->eh_info.action |= ATA_EH_REVALIDATE; + ata_port_schedule_eh(ap); + } + break; + + case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ + case ATA_CMD_SET_MULTI: /* multi_count changed */ + ap->eh_info.action |= ATA_EH_REVALIDATE; + ata_port_schedule_eh(ap); + break; + } } /* For ATA pass thru (SAT) commands, generate a sense block if diff --git a/include/linux/ata.h b/include/linux/ata.h index 3e95e5c402d4..703febb2df31 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -151,6 +151,7 @@ enum { ATA_CMD_WRITE_MULTI_EXT = 0x39, ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE, ATA_CMD_SET_FEATURES = 0xEF, + ATA_CMD_SET_MULTI = 0xC6, ATA_CMD_PACKET = 0xA0, ATA_CMD_VERIFY = 0x40, ATA_CMD_VERIFY_EXT = 0x42, From 5acd50f641e697cb42240f278350a4f8eac9b4f5 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sun, 10 Jun 2007 14:52:36 +0900 Subject: [PATCH 14/15] libata: force PIO on IOMEGA ZIP 250 ATAPI IOMEGA ZIP 250 ATAPI claims MWDMA0 support but fails SETXFERMODE if asked to configure itself to MWDMA0. Force PIO. This fixes bugzilla bug#8497. Signed-off-by: Tejun Heo Cc: Calvin Walton Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4b3c45e91c76..76aa94f55af9 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3771,6 +3771,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, + { "IOMEGA ZIP 250 ATAPI", NULL, ATA_HORKAGE_NODMA }, /* temporary fix */ /* Weird ATAPI devices */ { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 | From e141d999b682cda9907179e3b843acb64c34a1d8 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sun, 10 Jun 2007 14:26:20 +0900 Subject: [PATCH 15/15] libata: limit post SRST nsect/lbal wait to ~100ms After SRST, libata used to wait for nsect/lbal to be set to 1/1 for the slave device. However, some ATAPI devices don't set nsect/lbal after SRST and the wait itself isn't too useful as we're gonna wait for !BSY right after that anyway. Before reset-seq update, nsect/lbal wait failure used to be ignored and caused 30sec delay during detection. After reset-seq, all timeouts are considered error conditions making libata fail to detect such ATAPI devices. This patch limits nsect/lbal wait to around 100ms. This should give acceptable behavior to such ATAPI devices while not disturbing the heavily used code path too much. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 76aa94f55af9..047eabd75363 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3061,22 +3061,28 @@ static int ata_bus_post_reset(struct ata_port *ap, unsigned int devmask, } } - /* if device 1 was found in ata_devchk, wait for - * register access, then wait for BSY to clear + /* if device 1 was found in ata_devchk, wait for register + * access briefly, then wait for BSY to clear. */ - while (dev1) { - u8 nsect, lbal; + if (dev1) { + int i; ap->ops->dev_select(ap, 1); - nsect = ioread8(ioaddr->nsect_addr); - lbal = ioread8(ioaddr->lbal_addr); - if ((nsect == 1) && (lbal == 1)) - break; - if (time_after(jiffies, deadline)) - return -EBUSY; - msleep(50); /* give drive a breather */ - } - if (dev1) { + + /* Wait for register access. Some ATAPI devices fail + * to set nsect/lbal after reset, so don't waste too + * much time on it. We're gonna wait for !BSY anyway. + */ + for (i = 0; i < 2; i++) { + u8 nsect, lbal; + + nsect = ioread8(ioaddr->nsect_addr); + lbal = ioread8(ioaddr->lbal_addr); + if ((nsect == 1) && (lbal == 1)) + break; + msleep(50); /* give drive a breather */ + } + rc = ata_wait_ready(ap, deadline); if (rc) { if (rc != -ENODEV)