aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-03-24 23:02:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-03-24 23:02:32 -0400
commit5a17558f06993fdc509362f659582b52b0f921e3 (patch)
treed8c54416aff225097dee41f6cd0dd997639a4b28 /drivers
parentd56dc0b641da647012af573dac4a5fa7b9883fe0 (diff)
parent4cde32fc4b32e96a99063af3183acdfd54c563f0 (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: [libata] ahci: SB600 workaround is suspect... play it safe for now sata_promise: fix hardreset hotplug events, take 2 libata: improve HPA error handling libata: assume no device is attached if both IDENTIFYs are aborted pata_it821x: use raw nbytes in check_atapi_dma libata: implement ata_qc_raw_nbytes()
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ahci.c6
-rw-r--r--drivers/ata/libata-core.c46
-rw-r--r--drivers/ata/libata-scsi.c14
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/sata_promise.c109
5 files changed, 133 insertions, 44 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 17ee6ed985d9..b1eb4e24c86a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -433,6 +433,7 @@ static const struct ata_port_info ahci_port_info[] = {
433 /* board_ahci_sb600 */ 433 /* board_ahci_sb600 */
434 { 434 {
435 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | 435 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
436 AHCI_HFLAG_32BIT_ONLY |
436 AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), 437 AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP),
437 .flags = AHCI_FLAG_COMMON, 438 .flags = AHCI_FLAG_COMMON,
438 .link_flags = AHCI_LFLAG_COMMON, 439 .link_flags = AHCI_LFLAG_COMMON,
@@ -1217,8 +1218,11 @@ static void ahci_dev_config(struct ata_device *dev)
1217{ 1218{
1218 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; 1219 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
1219 1220
1220 if (hpriv->flags & AHCI_HFLAG_SECT255) 1221 if (hpriv->flags & AHCI_HFLAG_SECT255) {
1221 dev->max_sectors = 255; 1222 dev->max_sectors = 255;
1223 ata_dev_printk(dev, KERN_INFO,
1224 "SB600 AHCI: limiting to 255 sectors per cmd\n");
1225 }
1222} 1226}
1223 1227
1224static unsigned int ahci_dev_classify(struct ata_port *ap) 1228static unsigned int ahci_dev_classify(struct ata_port *ap)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4bbe31f98ef8..c4248b37ff64 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1416,12 +1416,12 @@ static int ata_hpa_resize(struct ata_device *dev)
1416 /* read native max address */ 1416 /* read native max address */
1417 rc = ata_read_native_max_address(dev, &native_sectors); 1417 rc = ata_read_native_max_address(dev, &native_sectors);
1418 if (rc) { 1418 if (rc) {
1419 /* If HPA isn't going to be unlocked, skip HPA 1419 /* If device aborted the command or HPA isn't going to
1420 * resizing from the next try. 1420 * be unlocked, skip HPA resizing.
1421 */ 1421 */
1422 if (!ata_ignore_hpa) { 1422 if (rc == -EACCES || !ata_ignore_hpa) {
1423 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1423 ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
1424 "broken, will skip HPA handling\n"); 1424 "broken, skipping HPA handling\n");
1425 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1425 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1426 1426
1427 /* we can continue if device aborted the command */ 1427 /* we can continue if device aborted the command */
@@ -2092,24 +2092,34 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0);
2093 if (err_mask) { 2093 if (err_mask) {
2094 if (err_mask & AC_ERR_NODEV_HINT) { 2094 if (err_mask & AC_ERR_NODEV_HINT) {
2095 DPRINTK("ata%u.%d: NODEV after polling detection\n", 2095 ata_dev_printk(dev, KERN_DEBUG,
2096 ap->print_id, dev->devno); 2096 "NODEV after polling detection\n");
2097 return -ENOENT; 2097 return -ENOENT;
2098 } 2098 }
2099 2099
2100 /* Device or controller might have reported the wrong 2100 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
2101 * device class. Give a shot at the other IDENTIFY if 2101 /* Device or controller might have reported
2102 * the current one is aborted by the device. 2102 * the wrong device class. Give a shot at the
2103 */ 2103 * other IDENTIFY if the current one is
2104 if (may_fallback && 2104 * aborted by the device.
2105 (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2105 */
2106 may_fallback = 0; 2106 if (may_fallback) {
2107 may_fallback = 0;
2107 2108
2108 if (class == ATA_DEV_ATA) 2109 if (class == ATA_DEV_ATA)
2109 class = ATA_DEV_ATAPI; 2110 class = ATA_DEV_ATAPI;
2110 else 2111 else
2111 class = ATA_DEV_ATA; 2112 class = ATA_DEV_ATA;
2112 goto retry; 2113 goto retry;
2114 }
2115
2116 /* Control reaches here iff the device aborted
2117 * both flavors of IDENTIFYs which happens
2118 * sometimes with phantom devices.
2119 */
2120 ata_dev_printk(dev, KERN_DEBUG,
2121 "both IDENTIFYs aborted, assuming NODEV\n");
2122 return -ENOENT;
2113 } 2123 }
2114 2124
2115 rc = -EIO; 2125 rc = -EIO;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8f0e8f2bc628..15795394b0a8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -527,6 +527,14 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
527 return qc; 527 return qc;
528} 528}
529 529
530static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc)
531{
532 struct scsi_cmnd *scmd = qc->scsicmd;
533
534 qc->extrabytes = scmd->request->extra_len;
535 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes;
536}
537
530/** 538/**
531 * ata_dump_status - user friendly display of error info 539 * ata_dump_status - user friendly display of error info
532 * @id: id of the port in question 540 * @id: id of the port in question
@@ -2539,7 +2547,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2539 } 2547 }
2540 2548
2541 qc->tf.command = ATA_CMD_PACKET; 2549 qc->tf.command = ATA_CMD_PACKET;
2542 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2550 ata_qc_set_pc_nbytes(qc);
2543 2551
2544 /* check whether ATAPI DMA is safe */ 2552 /* check whether ATAPI DMA is safe */
2545 if (!using_pio && ata_check_atapi_dma(qc)) 2553 if (!using_pio && ata_check_atapi_dma(qc))
@@ -2550,7 +2558,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2550 * want to set it properly, and for DMA where it is 2558 * want to set it properly, and for DMA where it is
2551 * effectively meaningless. 2559 * effectively meaningless.
2552 */ 2560 */
2553 nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024); 2561 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024);
2554 2562
2555 /* Most ATAPI devices which honor transfer chunk size don't 2563 /* Most ATAPI devices which honor transfer chunk size don't
2556 * behave according to the spec when odd chunk size which 2564 * behave according to the spec when odd chunk size which
@@ -2876,7 +2884,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2876 * TODO: find out if we need to do more here to 2884 * TODO: find out if we need to do more here to
2877 * cover scatter/gather case. 2885 * cover scatter/gather case.
2878 */ 2886 */
2879 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2887 ata_qc_set_pc_nbytes(qc);
2880 2888
2881 /* request result TF and be quiet about device error */ 2889 /* request result TF and be quiet about device error */
2882 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; 2890 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 109ddd42c266..257951d03dbb 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -564,7 +564,7 @@ static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
564 struct it821x_dev *itdev = ap->private_data; 564 struct it821x_dev *itdev = ap->private_data;
565 565
566 /* Only use dma for transfers to/from the media. */ 566 /* Only use dma for transfers to/from the media. */
567 if (qc->nbytes < 2048) 567 if (ata_qc_raw_nbytes(qc) < 2048)
568 return -EOPNOTSUPP; 568 return -EOPNOTSUPP;
569 569
570 /* No ATAPI DMA in smart mode */ 570 /* No ATAPI DMA in smart mode */
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index f251a5f569d5..11c1afea2db2 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -46,7 +46,7 @@
46#include "sata_promise.h" 46#include "sata_promise.h"
47 47
48#define DRV_NAME "sata_promise" 48#define DRV_NAME "sata_promise"
49#define DRV_VERSION "2.11" 49#define DRV_VERSION "2.12"
50 50
51enum { 51enum {
52 PDC_MAX_PORTS = 4, 52 PDC_MAX_PORTS = 4,
@@ -145,7 +145,9 @@ static int pdc_old_sata_check_atapi_dma(struct ata_queued_cmd *qc);
145static void pdc_irq_clear(struct ata_port *ap); 145static void pdc_irq_clear(struct ata_port *ap);
146static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 146static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
147static void pdc_freeze(struct ata_port *ap); 147static void pdc_freeze(struct ata_port *ap);
148static void pdc_sata_freeze(struct ata_port *ap);
148static void pdc_thaw(struct ata_port *ap); 149static void pdc_thaw(struct ata_port *ap);
150static void pdc_sata_thaw(struct ata_port *ap);
149static void pdc_pata_error_handler(struct ata_port *ap); 151static void pdc_pata_error_handler(struct ata_port *ap);
150static void pdc_sata_error_handler(struct ata_port *ap); 152static void pdc_sata_error_handler(struct ata_port *ap);
151static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); 153static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
@@ -180,8 +182,8 @@ static const struct ata_port_operations pdc_sata_ops = {
180 182
181 .qc_prep = pdc_qc_prep, 183 .qc_prep = pdc_qc_prep,
182 .qc_issue = pdc_qc_issue_prot, 184 .qc_issue = pdc_qc_issue_prot,
183 .freeze = pdc_freeze, 185 .freeze = pdc_sata_freeze,
184 .thaw = pdc_thaw, 186 .thaw = pdc_sata_thaw,
185 .error_handler = pdc_sata_error_handler, 187 .error_handler = pdc_sata_error_handler,
186 .post_internal_cmd = pdc_post_internal_cmd, 188 .post_internal_cmd = pdc_post_internal_cmd,
187 .cable_detect = pdc_sata_cable_detect, 189 .cable_detect = pdc_sata_cable_detect,
@@ -205,8 +207,8 @@ static const struct ata_port_operations pdc_old_sata_ops = {
205 207
206 .qc_prep = pdc_qc_prep, 208 .qc_prep = pdc_qc_prep,
207 .qc_issue = pdc_qc_issue_prot, 209 .qc_issue = pdc_qc_issue_prot,
208 .freeze = pdc_freeze, 210 .freeze = pdc_sata_freeze,
209 .thaw = pdc_thaw, 211 .thaw = pdc_sata_thaw,
210 .error_handler = pdc_sata_error_handler, 212 .error_handler = pdc_sata_error_handler,
211 .post_internal_cmd = pdc_post_internal_cmd, 213 .post_internal_cmd = pdc_post_internal_cmd,
212 .cable_detect = pdc_sata_cable_detect, 214 .cable_detect = pdc_sata_cable_detect,
@@ -631,6 +633,41 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
631 } 633 }
632} 634}
633 635
636static int pdc_is_sataii_tx4(unsigned long flags)
637{
638 const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS;
639 return (flags & mask) == mask;
640}
641
642static unsigned int pdc_port_no_to_ata_no(unsigned int port_no,
643 int is_sataii_tx4)
644{
645 static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
646 return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
647}
648
649static unsigned int pdc_sata_nr_ports(const struct ata_port *ap)
650{
651 return (ap->flags & PDC_FLAG_4_PORTS) ? 4 : 2;
652}
653
654static unsigned int pdc_sata_ata_port_to_ata_no(const struct ata_port *ap)
655{
656 const struct ata_host *host = ap->host;
657 unsigned int nr_ports = pdc_sata_nr_ports(ap);
658 unsigned int i;
659
660 for(i = 0; i < nr_ports && host->ports[i] != ap; ++i)
661 ;
662 BUG_ON(i >= nr_ports);
663 return pdc_port_no_to_ata_no(i, pdc_is_sataii_tx4(ap->flags));
664}
665
666static unsigned int pdc_sata_hotplug_offset(const struct ata_port *ap)
667{
668 return (ap->flags & PDC_FLAG_GEN_II) ? PDC2_SATA_PLUG_CSR : PDC_SATA_PLUG_CSR;
669}
670
634static void pdc_freeze(struct ata_port *ap) 671static void pdc_freeze(struct ata_port *ap)
635{ 672{
636 void __iomem *mmio = ap->ioaddr.cmd_addr; 673 void __iomem *mmio = ap->ioaddr.cmd_addr;
@@ -643,6 +680,29 @@ static void pdc_freeze(struct ata_port *ap)
643 readl(mmio + PDC_CTLSTAT); /* flush */ 680 readl(mmio + PDC_CTLSTAT); /* flush */
644} 681}
645 682
683static void pdc_sata_freeze(struct ata_port *ap)
684{
685 struct ata_host *host = ap->host;
686 void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR];
687 unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap);
688 unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap);
689 u32 hotplug_status;
690
691 /* Disable hotplug events on this port.
692 *
693 * Locking:
694 * 1) hotplug register accesses must be serialised via host->lock
695 * 2) ap->lock == &ap->host->lock
696 * 3) ->freeze() and ->thaw() are called with ap->lock held
697 */
698 hotplug_status = readl(host_mmio + hotplug_offset);
699 hotplug_status |= 0x11 << (ata_no + 16);
700 writel(hotplug_status, host_mmio + hotplug_offset);
701 readl(host_mmio + hotplug_offset); /* flush */
702
703 pdc_freeze(ap);
704}
705
646static void pdc_thaw(struct ata_port *ap) 706static void pdc_thaw(struct ata_port *ap)
647{ 707{
648 void __iomem *mmio = ap->ioaddr.cmd_addr; 708 void __iomem *mmio = ap->ioaddr.cmd_addr;
@@ -658,6 +718,26 @@ static void pdc_thaw(struct ata_port *ap)
658 readl(mmio + PDC_CTLSTAT); /* flush */ 718 readl(mmio + PDC_CTLSTAT); /* flush */
659} 719}
660 720
721static void pdc_sata_thaw(struct ata_port *ap)
722{
723 struct ata_host *host = ap->host;
724 void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR];
725 unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap);
726 unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap);
727 u32 hotplug_status;
728
729 pdc_thaw(ap);
730
731 /* Enable hotplug events on this port.
732 * Locking: see pdc_sata_freeze().
733 */
734 hotplug_status = readl(host_mmio + hotplug_offset);
735 hotplug_status |= 0x11 << ata_no;
736 hotplug_status &= ~(0x11 << (ata_no + 16));
737 writel(hotplug_status, host_mmio + hotplug_offset);
738 readl(host_mmio + hotplug_offset); /* flush */
739}
740
661static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset) 741static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset)
662{ 742{
663 if (!(ap->pflags & ATA_PFLAG_FROZEN)) 743 if (!(ap->pflags & ATA_PFLAG_FROZEN))
@@ -765,19 +845,6 @@ static void pdc_irq_clear(struct ata_port *ap)
765 readl(mmio + PDC_INT_SEQMASK); 845 readl(mmio + PDC_INT_SEQMASK);
766} 846}
767 847
768static int pdc_is_sataii_tx4(unsigned long flags)
769{
770 const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS;
771 return (flags & mask) == mask;
772}
773
774static unsigned int pdc_port_no_to_ata_no(unsigned int port_no,
775 int is_sataii_tx4)
776{
777 static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
778 return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
779}
780
781static irqreturn_t pdc_interrupt(int irq, void *dev_instance) 848static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
782{ 849{
783 struct ata_host *host = dev_instance; 850 struct ata_host *host = dev_instance;
@@ -799,6 +866,8 @@ static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
799 866
800 mmio_base = host->iomap[PDC_MMIO_BAR]; 867 mmio_base = host->iomap[PDC_MMIO_BAR];
801 868
869 spin_lock(&host->lock);
870
802 /* read and clear hotplug flags for all ports */ 871 /* read and clear hotplug flags for all ports */
803 if (host->ports[0]->flags & PDC_FLAG_GEN_II) 872 if (host->ports[0]->flags & PDC_FLAG_GEN_II)
804 hotplug_offset = PDC2_SATA_PLUG_CSR; 873 hotplug_offset = PDC2_SATA_PLUG_CSR;
@@ -814,11 +883,9 @@ static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
814 883
815 if (mask == 0xffffffff && hotplug_status == 0) { 884 if (mask == 0xffffffff && hotplug_status == 0) {
816 VPRINTK("QUICK EXIT 2\n"); 885 VPRINTK("QUICK EXIT 2\n");
817 return IRQ_NONE; 886 goto done_irq;
818 } 887 }
819 888
820 spin_lock(&host->lock);
821
822 mask &= 0xffff; /* only 16 tags possible */ 889 mask &= 0xffff; /* only 16 tags possible */
823 if (mask == 0 && hotplug_status == 0) { 890 if (mask == 0 && hotplug_status == 0) {
824 VPRINTK("QUICK EXIT 3\n"); 891 VPRINTK("QUICK EXIT 3\n");