Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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()

+140 -45
+5 -1
drivers/ata/ahci.c
··· 433 433 /* board_ahci_sb600 */ 434 434 { 435 435 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | 436 + AHCI_HFLAG_32BIT_ONLY | 436 437 AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), 437 438 .flags = AHCI_FLAG_COMMON, 438 439 .link_flags = AHCI_LFLAG_COMMON, ··· 1218 1217 { 1219 1218 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; 1220 1219 1221 - if (hpriv->flags & AHCI_HFLAG_SECT255) 1220 + if (hpriv->flags & AHCI_HFLAG_SECT255) { 1222 1221 dev->max_sectors = 255; 1222 + ata_dev_printk(dev, KERN_INFO, 1223 + "SB600 AHCI: limiting to 255 sectors per cmd\n"); 1224 + } 1223 1225 } 1224 1226 1225 1227 static unsigned int ahci_dev_classify(struct ata_port *ap)
+28 -18
drivers/ata/libata-core.c
··· 1416 1416 /* read native max address */ 1417 1417 rc = ata_read_native_max_address(dev, &native_sectors); 1418 1418 if (rc) { 1419 - /* If HPA isn't going to be unlocked, skip HPA 1420 - * resizing from the next try. 1419 + /* If device aborted the command or HPA isn't going to 1420 + * be unlocked, skip HPA resizing. 1421 1421 */ 1422 - if (!ata_ignore_hpa) { 1422 + if (rc == -EACCES || !ata_ignore_hpa) { 1423 1423 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1424 - "broken, will skip HPA handling\n"); 1424 + "broken, skipping HPA handling\n"); 1425 1425 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1426 1426 1427 1427 /* we can continue if device aborted the command */ ··· 2092 2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2093 2093 if (err_mask) { 2094 2094 if (err_mask & AC_ERR_NODEV_HINT) { 2095 - DPRINTK("ata%u.%d: NODEV after polling detection\n", 2096 - ap->print_id, dev->devno); 2095 + ata_dev_printk(dev, KERN_DEBUG, 2096 + "NODEV after polling detection\n"); 2097 2097 return -ENOENT; 2098 2098 } 2099 2099 2100 - /* Device or controller might have reported the wrong 2101 - * device class. Give a shot at the other IDENTIFY if 2102 - * the current one is aborted by the device. 2103 - */ 2104 - if (may_fallback && 2105 - (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2106 - may_fallback = 0; 2100 + if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2101 + /* Device or controller might have reported 2102 + * the wrong device class. Give a shot at the 2103 + * other IDENTIFY if the current one is 2104 + * aborted by the device. 2105 + */ 2106 + if (may_fallback) { 2107 + may_fallback = 0; 2107 2108 2108 - if (class == ATA_DEV_ATA) 2109 - class = ATA_DEV_ATAPI; 2110 - else 2111 - class = ATA_DEV_ATA; 2112 - goto retry; 2109 + if (class == ATA_DEV_ATA) 2110 + class = ATA_DEV_ATAPI; 2111 + else 2112 + class = ATA_DEV_ATA; 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 2125 rc = -EIO;
+11 -3
drivers/ata/libata-scsi.c
··· 527 527 return qc; 528 528 } 529 529 530 + static 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 539 * ata_dump_status - user friendly display of error info 532 540 * @id: id of the port in question ··· 2547 2539 } 2548 2540 2549 2541 qc->tf.command = ATA_CMD_PACKET; 2550 - qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2542 + ata_qc_set_pc_nbytes(qc); 2551 2543 2552 2544 /* check whether ATAPI DMA is safe */ 2553 2545 if (!using_pio && ata_check_atapi_dma(qc)) ··· 2558 2550 * want to set it properly, and for DMA where it is 2559 2551 * effectively meaningless. 2560 2552 */ 2561 - nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024); 2553 + nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024); 2562 2554 2563 2555 /* Most ATAPI devices which honor transfer chunk size don't 2564 2556 * behave according to the spec when odd chunk size which ··· 2884 2876 * TODO: find out if we need to do more here to 2885 2877 * cover scatter/gather case. 2886 2878 */ 2887 - qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2879 + ata_qc_set_pc_nbytes(qc); 2888 2880 2889 2881 /* request result TF and be quiet about device error */ 2890 2882 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
+1 -1
drivers/ata/pata_it821x.c
··· 564 564 struct it821x_dev *itdev = ap->private_data; 565 565 566 566 /* Only use dma for transfers to/from the media. */ 567 - if (qc->nbytes < 2048) 567 + if (ata_qc_raw_nbytes(qc) < 2048) 568 568 return -EOPNOTSUPP; 569 569 570 570 /* No ATAPI DMA in smart mode */
+88 -21
drivers/ata/sata_promise.c
··· 46 46 #include "sata_promise.h" 47 47 48 48 #define DRV_NAME "sata_promise" 49 - #define DRV_VERSION "2.11" 49 + #define DRV_VERSION "2.12" 50 50 51 51 enum { 52 52 PDC_MAX_PORTS = 4, ··· 145 145 static void pdc_irq_clear(struct ata_port *ap); 146 146 static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 147 147 static void pdc_freeze(struct ata_port *ap); 148 + static void pdc_sata_freeze(struct ata_port *ap); 148 149 static void pdc_thaw(struct ata_port *ap); 150 + static void pdc_sata_thaw(struct ata_port *ap); 149 151 static void pdc_pata_error_handler(struct ata_port *ap); 150 152 static void pdc_sata_error_handler(struct ata_port *ap); 151 153 static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); ··· 182 180 183 181 .qc_prep = pdc_qc_prep, 184 182 .qc_issue = pdc_qc_issue_prot, 185 - .freeze = pdc_freeze, 186 - .thaw = pdc_thaw, 183 + .freeze = pdc_sata_freeze, 184 + .thaw = pdc_sata_thaw, 187 185 .error_handler = pdc_sata_error_handler, 188 186 .post_internal_cmd = pdc_post_internal_cmd, 189 187 .cable_detect = pdc_sata_cable_detect, ··· 207 205 208 206 .qc_prep = pdc_qc_prep, 209 207 .qc_issue = pdc_qc_issue_prot, 210 - .freeze = pdc_freeze, 211 - .thaw = pdc_thaw, 208 + .freeze = pdc_sata_freeze, 209 + .thaw = pdc_sata_thaw, 212 210 .error_handler = pdc_sata_error_handler, 213 211 .post_internal_cmd = pdc_post_internal_cmd, 214 212 .cable_detect = pdc_sata_cable_detect, ··· 633 631 } 634 632 } 635 633 634 + static int pdc_is_sataii_tx4(unsigned long flags) 635 + { 636 + const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS; 637 + return (flags & mask) == mask; 638 + } 639 + 640 + static unsigned int pdc_port_no_to_ata_no(unsigned int port_no, 641 + int is_sataii_tx4) 642 + { 643 + static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2}; 644 + return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no; 645 + } 646 + 647 + static unsigned int pdc_sata_nr_ports(const struct ata_port *ap) 648 + { 649 + return (ap->flags & PDC_FLAG_4_PORTS) ? 4 : 2; 650 + } 651 + 652 + static unsigned int pdc_sata_ata_port_to_ata_no(const struct ata_port *ap) 653 + { 654 + const struct ata_host *host = ap->host; 655 + unsigned int nr_ports = pdc_sata_nr_ports(ap); 656 + unsigned int i; 657 + 658 + for(i = 0; i < nr_ports && host->ports[i] != ap; ++i) 659 + ; 660 + BUG_ON(i >= nr_ports); 661 + return pdc_port_no_to_ata_no(i, pdc_is_sataii_tx4(ap->flags)); 662 + } 663 + 664 + static unsigned int pdc_sata_hotplug_offset(const struct ata_port *ap) 665 + { 666 + return (ap->flags & PDC_FLAG_GEN_II) ? PDC2_SATA_PLUG_CSR : PDC_SATA_PLUG_CSR; 667 + } 668 + 636 669 static void pdc_freeze(struct ata_port *ap) 637 670 { 638 671 void __iomem *mmio = ap->ioaddr.cmd_addr; ··· 678 641 tmp &= ~PDC_DMA_ENABLE; 679 642 writel(tmp, mmio + PDC_CTLSTAT); 680 643 readl(mmio + PDC_CTLSTAT); /* flush */ 644 + } 645 + 646 + static void pdc_sata_freeze(struct ata_port *ap) 647 + { 648 + struct ata_host *host = ap->host; 649 + void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR]; 650 + unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap); 651 + unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap); 652 + u32 hotplug_status; 653 + 654 + /* Disable hotplug events on this port. 655 + * 656 + * Locking: 657 + * 1) hotplug register accesses must be serialised via host->lock 658 + * 2) ap->lock == &ap->host->lock 659 + * 3) ->freeze() and ->thaw() are called with ap->lock held 660 + */ 661 + hotplug_status = readl(host_mmio + hotplug_offset); 662 + hotplug_status |= 0x11 << (ata_no + 16); 663 + writel(hotplug_status, host_mmio + hotplug_offset); 664 + readl(host_mmio + hotplug_offset); /* flush */ 665 + 666 + pdc_freeze(ap); 681 667 } 682 668 683 669 static void pdc_thaw(struct ata_port *ap) ··· 716 656 tmp &= ~PDC_IRQ_DISABLE; 717 657 writel(tmp, mmio + PDC_CTLSTAT); 718 658 readl(mmio + PDC_CTLSTAT); /* flush */ 659 + } 660 + 661 + static void pdc_sata_thaw(struct ata_port *ap) 662 + { 663 + struct ata_host *host = ap->host; 664 + void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR]; 665 + unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap); 666 + unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap); 667 + u32 hotplug_status; 668 + 669 + pdc_thaw(ap); 670 + 671 + /* Enable hotplug events on this port. 672 + * Locking: see pdc_sata_freeze(). 673 + */ 674 + hotplug_status = readl(host_mmio + hotplug_offset); 675 + hotplug_status |= 0x11 << ata_no; 676 + hotplug_status &= ~(0x11 << (ata_no + 16)); 677 + writel(hotplug_status, host_mmio + hotplug_offset); 678 + readl(host_mmio + hotplug_offset); /* flush */ 719 679 } 720 680 721 681 static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset) ··· 845 765 readl(mmio + PDC_INT_SEQMASK); 846 766 } 847 767 848 - static int pdc_is_sataii_tx4(unsigned long flags) 849 - { 850 - const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS; 851 - return (flags & mask) == mask; 852 - } 853 - 854 - static unsigned int pdc_port_no_to_ata_no(unsigned int port_no, 855 - int is_sataii_tx4) 856 - { 857 - static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2}; 858 - return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no; 859 - } 860 - 861 768 static irqreturn_t pdc_interrupt(int irq, void *dev_instance) 862 769 { 863 770 struct ata_host *host = dev_instance; ··· 866 799 867 800 mmio_base = host->iomap[PDC_MMIO_BAR]; 868 801 802 + spin_lock(&host->lock); 803 + 869 804 /* read and clear hotplug flags for all ports */ 870 805 if (host->ports[0]->flags & PDC_FLAG_GEN_II) 871 806 hotplug_offset = PDC2_SATA_PLUG_CSR; ··· 883 814 884 815 if (mask == 0xffffffff && hotplug_status == 0) { 885 816 VPRINTK("QUICK EXIT 2\n"); 886 - return IRQ_NONE; 817 + goto done_irq; 887 818 } 888 - 889 - spin_lock(&host->lock); 890 819 891 820 mask &= 0xffff; /* only 16 tags possible */ 892 821 if (mask == 0 && hotplug_status == 0) {
+7 -1
include/linux/libata.h
··· 463 463 unsigned int sect_size; 464 464 465 465 unsigned int nbytes; 466 + unsigned int extrabytes; 466 467 unsigned int curbytes; 467 468 468 469 struct scatterlist *cursg; ··· 1337 1336 return NULL; 1338 1337 } 1339 1338 1339 + static inline unsigned int ata_qc_raw_nbytes(struct ata_queued_cmd *qc) 1340 + { 1341 + return qc->nbytes - min(qc->extrabytes, qc->nbytes); 1342 + } 1343 + 1340 1344 static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) 1341 1345 { 1342 1346 memset(tf, 0, sizeof(*tf)); ··· 1360 1354 qc->flags = 0; 1361 1355 qc->cursg = NULL; 1362 1356 qc->cursg_ofs = 0; 1363 - qc->nbytes = qc->curbytes = 0; 1357 + qc->nbytes = qc->extrabytes = qc->curbytes = 0; 1364 1358 qc->n_elem = 0; 1365 1359 qc->err_mask = 0; 1366 1360 qc->sect_size = ATA_SECT_SIZE;