Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev:
ahci: improve spurious SDB FIS handling
ahci/pata_jmicron: match class not function number
jmicron ATA: reimplement jmicron ATA quirk
pata_jmicron: drop unnecessary device programming in [re]init
libata: blacklist FUJITSU MHT2060BH for NCQ
sata_sil24: kill unused local variable idx in sil24_fill_sg()
libata: clear drvdata in ata_host_release(), take#2

+92 -102
+27 -28
drivers/ata/ahci.c
··· 200 /* for NCQ spurious interrupt analysis */ 201 unsigned int ncq_saw_d2h:1; 202 unsigned int ncq_saw_dmas:1; 203 }; 204 205 static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg); ··· 385 { PCI_VDEVICE(INTEL, 0x294d), board_ahci_pi }, /* ICH9 */ 386 { PCI_VDEVICE(INTEL, 0x294e), board_ahci_pi }, /* ICH9M */ 387 388 - /* JMicron */ 389 - { PCI_VDEVICE(JMICRON, 0x2360), board_ahci_ign_iferr }, /* JMB360 */ 390 - { PCI_VDEVICE(JMICRON, 0x2361), board_ahci_ign_iferr }, /* JMB361 */ 391 - { PCI_VDEVICE(JMICRON, 0x2363), board_ahci_ign_iferr }, /* JMB363 */ 392 - { PCI_VDEVICE(JMICRON, 0x2365), board_ahci_ign_iferr }, /* JMB365 */ 393 - { PCI_VDEVICE(JMICRON, 0x2366), board_ahci_ign_iferr }, /* JMB366 */ 394 395 /* ATI */ 396 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */ ··· 1158 } 1159 1160 if (status & PORT_IRQ_SDB_FIS) { 1161 - /* SDB FIS containing spurious completions might be 1162 - * dangerous, whine and fail commands with HSM 1163 - * violation. EH will turn off NCQ after several such 1164 - * failures. 1165 - */ 1166 const __le32 *f = pp->rx_fis + RX_FIS_SDB; 1167 1168 - ata_ehi_push_desc(ehi, "spurious completion during NCQ " 1169 - "issue=0x%x SAct=0x%x FIS=%08x:%08x", 1170 - readl(port_mmio + PORT_CMD_ISSUE), 1171 - readl(port_mmio + PORT_SCR_ACT), 1172 - le32_to_cpu(f[0]), le32_to_cpu(f[1])); 1173 - 1174 - ehi->err_mask |= AC_ERR_HSM; 1175 - ehi->action |= ATA_EH_SOFTRESET; 1176 - ata_port_freeze(ap); 1177 - 1178 known_irq = 1; 1179 } 1180 ··· 1670 1671 if (!printed_version++) 1672 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 1673 - 1674 - if (pdev->vendor == PCI_VENDOR_ID_JMICRON) { 1675 - /* Function 1 is the PATA controller except on the 368, where 1676 - we are not AHCI anyway */ 1677 - if (PCI_FUNC(pdev->devfn)) 1678 - return -ENODEV; 1679 - } 1680 1681 rc = pcim_enable_device(pdev); 1682 if (rc)
··· 200 /* for NCQ spurious interrupt analysis */ 201 unsigned int ncq_saw_d2h:1; 202 unsigned int ncq_saw_dmas:1; 203 + unsigned int ncq_saw_sdb:1; 204 }; 205 206 static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg); ··· 384 { PCI_VDEVICE(INTEL, 0x294d), board_ahci_pi }, /* ICH9 */ 385 { PCI_VDEVICE(INTEL, 0x294e), board_ahci_pi }, /* ICH9M */ 386 387 + /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 388 + { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 389 + PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci_ign_iferr }, 390 391 /* ATI */ 392 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */ ··· 1160 } 1161 1162 if (status & PORT_IRQ_SDB_FIS) { 1163 const __le32 *f = pp->rx_fis + RX_FIS_SDB; 1164 1165 + if (le32_to_cpu(f[1])) { 1166 + /* SDB FIS containing spurious completions 1167 + * might be dangerous, whine and fail commands 1168 + * with HSM violation. EH will turn off NCQ 1169 + * after several such failures. 1170 + */ 1171 + ata_ehi_push_desc(ehi, 1172 + "spurious completions during NCQ " 1173 + "issue=0x%x SAct=0x%x FIS=%08x:%08x", 1174 + readl(port_mmio + PORT_CMD_ISSUE), 1175 + readl(port_mmio + PORT_SCR_ACT), 1176 + le32_to_cpu(f[0]), le32_to_cpu(f[1])); 1177 + ehi->err_mask |= AC_ERR_HSM; 1178 + ehi->action |= ATA_EH_SOFTRESET; 1179 + ata_port_freeze(ap); 1180 + } else { 1181 + if (!pp->ncq_saw_sdb) 1182 + ata_port_printk(ap, KERN_INFO, 1183 + "spurious SDB FIS %08x:%08x during NCQ, " 1184 + "this message won't be printed again\n", 1185 + le32_to_cpu(f[0]), le32_to_cpu(f[1])); 1186 + pp->ncq_saw_sdb = 1; 1187 + } 1188 known_irq = 1; 1189 } 1190 ··· 1664 1665 if (!printed_version++) 1666 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 1667 1668 rc = pcim_enable_device(pdev); 1669 if (rc)
+4 -1
drivers/ata/libata-core.c
··· 3346 /* Devices where NCQ should be avoided */ 3347 /* NCQ is slow */ 3348 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, 3349 3350 /* Devices with NCQ limits */ 3351 ··· 5682 5683 if (host->ops->host_stop) 5684 host->ops->host_stop(host); 5685 } 5686 5687 /** ··· 5906 5907 err_out: 5908 devres_release_group(dev, ata_device_add); 5909 - dev_set_drvdata(dev, NULL); 5910 VPRINTK("EXIT, returning %d\n", rc); 5911 return 0; 5912 }
··· 3346 /* Devices where NCQ should be avoided */ 3347 /* NCQ is slow */ 3348 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, 3349 + /* http://thread.gmane.org/gmane.linux.ide/14907 */ 3350 + { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ }, 3351 3352 /* Devices with NCQ limits */ 3353 ··· 5680 5681 if (host->ops->host_stop) 5682 host->ops->host_stop(host); 5683 + 5684 + dev_set_drvdata(gendev, NULL); 5685 } 5686 5687 /** ··· 5902 5903 err_out: 5904 devres_release_group(dev, ata_device_add); 5905 VPRINTK("EXIT, returning %d\n", rc); 5906 return 0; 5907 }
-1
drivers/ata/pata_cs5520.c
··· 306 struct ata_host *host = dev_get_drvdata(dev); 307 308 ata_host_detach(host); 309 - dev_set_drvdata(dev, NULL); 310 } 311 312 /**
··· 306 struct ata_host *host = dev_get_drvdata(dev); 307 308 ata_host_detach(host); 309 } 310 311 /**
-1
drivers/ata/pata_isapnp.c
··· 128 struct ata_host *host = dev_get_drvdata(dev); 129 130 ata_host_detach(host); 131 - dev_set_drvdata(dev, NULL); 132 } 133 134 static struct pnp_device_id isapnp_devices[] = {
··· 128 struct ata_host *host = dev_get_drvdata(dev); 129 130 ata_host_detach(host); 131 } 132 133 static struct pnp_device_id isapnp_devices[] = {
+11 -40
drivers/ata/pata_jmicron.c
··· 202 }; 203 struct ata_port_info *port_info[2] = { &info, &info }; 204 205 - u32 reg; 206 - 207 - /* PATA controller is fn 1, AHCI is fn 0 */ 208 - if (id->driver_data != 368 && PCI_FUNC(pdev->devfn) != 1) 209 - return -ENODEV; 210 - 211 - /* The 365/66 have two PATA channels, redirect the second */ 212 - if (id->driver_data == 365 || id->driver_data == 366) { 213 - pci_read_config_dword(pdev, 0x80, &reg); 214 - reg |= (1 << 24); /* IDE1 to PATA IDE secondary */ 215 - pci_write_config_dword(pdev, 0x80, reg); 216 - } 217 - 218 return ata_pci_init_one(pdev, port_info, 2); 219 } 220 221 - static int jmicron_reinit_one(struct pci_dev *pdev) 222 - { 223 - u32 reg; 224 - 225 - switch(pdev->device) { 226 - case PCI_DEVICE_ID_JMICRON_JMB368: 227 - break; 228 - case PCI_DEVICE_ID_JMICRON_JMB365: 229 - case PCI_DEVICE_ID_JMICRON_JMB366: 230 - /* Restore mapping or disks swap and boy does it get ugly */ 231 - pci_read_config_dword(pdev, 0x80, &reg); 232 - reg |= (1 << 24); /* IDE1 to PATA IDE secondary */ 233 - pci_write_config_dword(pdev, 0x80, reg); 234 - /* Fall through */ 235 - default: 236 - /* Make sure AHCI is turned back on */ 237 - pci_write_config_byte(pdev, 0x41, 0xa1); 238 - } 239 - return ata_pci_device_resume(pdev); 240 - } 241 - 242 static const struct pci_device_id jmicron_pci_tbl[] = { 243 - { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 361}, 244 - { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 363}, 245 - { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365), 365}, 246 - { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366), 366}, 247 - { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368), 368}, 248 249 { } /* terminate list */ 250 }; ··· 226 .probe = jmicron_init_one, 227 .remove = ata_pci_remove_one, 228 .suspend = ata_pci_device_suspend, 229 - .resume = jmicron_reinit_one, 230 }; 231 232 static int __init jmicron_init(void)
··· 202 }; 203 struct ata_port_info *port_info[2] = { &info, &info }; 204 205 return ata_pci_init_one(pdev, port_info, 2); 206 } 207 208 static const struct pci_device_id jmicron_pci_tbl[] = { 209 + { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, 210 + PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 361 }, 211 + { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, 212 + PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 363 }, 213 + { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, 214 + PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 365 }, 215 + { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, 216 + PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 366 }, 217 + { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, 218 + PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 368 }, 219 220 { } /* terminate list */ 221 }; ··· 255 .probe = jmicron_init_one, 256 .remove = ata_pci_remove_one, 257 .suspend = ata_pci_device_suspend, 258 + .resume = ata_pci_device_resume, 259 }; 260 261 static int __init jmicron_init(void)
-1
drivers/ata/pata_platform.c
··· 228 struct ata_host *host = dev_get_drvdata(dev); 229 230 ata_host_detach(host); 231 - dev_set_drvdata(dev, NULL); 232 233 return 0; 234 }
··· 228 struct ata_host *host = dev_get_drvdata(dev); 229 230 ata_host_detach(host); 231 232 return 0; 233 }
-3
drivers/ata/sata_sil24.c
··· 647 struct sil24_sge *sge) 648 { 649 struct scatterlist *sg; 650 - unsigned int idx = 0; 651 652 ata_for_each_sg(sg, qc) { 653 sge->addr = cpu_to_le64(sg_dma_address(sg)); ··· 655 sge->flags = cpu_to_le32(SGE_TRM); 656 else 657 sge->flags = 0; 658 - 659 sge++; 660 - idx++; 661 } 662 } 663
··· 647 struct sil24_sge *sge) 648 { 649 struct scatterlist *sg; 650 651 ata_for_each_sg(sg, qc) { 652 sge->addr = cpu_to_le64(sg_dma_address(sg)); ··· 656 sge->flags = cpu_to_le32(SGE_TRM); 657 else 658 sge->flags = 0; 659 sge++; 660 } 661 } 662
+50 -27
drivers/pci/quirks.c
··· 1218 * do this early on to make the additional device appear during 1219 * the PCI scanning. 1220 */ 1221 - 1222 - static void quirk_jmicron_dualfn(struct pci_dev *pdev) 1223 { 1224 - u32 conf; 1225 u8 hdr; 1226 1227 /* Only poke fn 0 */ 1228 if (PCI_FUNC(pdev->devfn)) 1229 return; 1230 1231 - switch(pdev->device) { 1232 - case PCI_DEVICE_ID_JMICRON_JMB365: 1233 - case PCI_DEVICE_ID_JMICRON_JMB366: 1234 - /* Redirect IDE second PATA port to the right spot */ 1235 - pci_read_config_dword(pdev, 0x80, &conf); 1236 - conf |= (1 << 24); 1237 - /* Fall through */ 1238 - pci_write_config_dword(pdev, 0x80, conf); 1239 - case PCI_DEVICE_ID_JMICRON_JMB361: 1240 - case PCI_DEVICE_ID_JMICRON_JMB363: 1241 - pci_read_config_dword(pdev, 0x40, &conf); 1242 - /* Enable dual function mode, AHCI on fn 0, IDE fn1 */ 1243 - /* Set the class codes correctly and then direct IDE 0 */ 1244 - conf &= ~0x000FF200; /* Clear bit 9 and 12-19 */ 1245 - conf |= 0x00C2A102; /* Set 1, 8, 13, 15, 17, 22, 23 */ 1246 - pci_write_config_dword(pdev, 0x40, conf); 1247 1248 - /* Reconfigure so that the PCI scanner discovers the 1249 - device is now multifunction */ 1250 1251 - pci_read_config_byte(pdev, PCI_HEADER_TYPE, &hdr); 1252 - pdev->hdr_type = hdr & 0x7f; 1253 - pdev->multifunction = !!(hdr & 0x80); 1254 1255 - break; 1256 } 1257 } 1258 - DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, quirk_jmicron_dualfn); 1259 - DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, quirk_jmicron_dualfn); 1260 1261 #endif 1262
··· 1218 * do this early on to make the additional device appear during 1219 * the PCI scanning. 1220 */ 1221 + static void quirk_jmicron_ata(struct pci_dev *pdev) 1222 { 1223 + u32 conf1, conf5, class; 1224 u8 hdr; 1225 1226 /* Only poke fn 0 */ 1227 if (PCI_FUNC(pdev->devfn)) 1228 return; 1229 1230 + pci_read_config_dword(pdev, 0x40, &conf1); 1231 + pci_read_config_dword(pdev, 0x80, &conf5); 1232 1233 + conf1 &= ~0x00CFF302; /* Clear bit 1, 8, 9, 12-19, 22, 23 */ 1234 + conf5 &= ~(1 << 24); /* Clear bit 24 */ 1235 1236 + switch (pdev->device) { 1237 + case PCI_DEVICE_ID_JMICRON_JMB360: 1238 + /* The controller should be in single function ahci mode */ 1239 + conf1 |= 0x0002A100; /* Set 8, 13, 15, 17 */ 1240 + break; 1241 1242 + case PCI_DEVICE_ID_JMICRON_JMB365: 1243 + case PCI_DEVICE_ID_JMICRON_JMB366: 1244 + /* Redirect IDE second PATA port to the right spot */ 1245 + conf5 |= (1 << 24); 1246 + /* Fall through */ 1247 + case PCI_DEVICE_ID_JMICRON_JMB361: 1248 + case PCI_DEVICE_ID_JMICRON_JMB363: 1249 + /* Enable dual function mode, AHCI on fn 0, IDE fn1 */ 1250 + /* Set the class codes correctly and then direct IDE 0 */ 1251 + conf1 |= 0x00C2A102; /* Set 1, 8, 13, 15, 17, 22, 23 */ 1252 + break; 1253 + 1254 + case PCI_DEVICE_ID_JMICRON_JMB368: 1255 + /* The controller should be in single function IDE mode */ 1256 + conf1 |= 0x00C00000; /* Set 22, 23 */ 1257 + break; 1258 } 1259 + 1260 + pci_write_config_dword(pdev, 0x40, conf1); 1261 + pci_write_config_dword(pdev, 0x80, conf5); 1262 + 1263 + /* Update pdev accordingly */ 1264 + pci_read_config_byte(pdev, PCI_HEADER_TYPE, &hdr); 1265 + pdev->hdr_type = hdr & 0x7f; 1266 + pdev->multifunction = !!(hdr & 0x80); 1267 + 1268 + pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class); 1269 + pdev->class = class >> 8; 1270 } 1271 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, quirk_jmicron_ata); 1272 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, quirk_jmicron_ata); 1273 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, quirk_jmicron_ata); 1274 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); 1275 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); 1276 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); 1277 + DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, quirk_jmicron_ata); 1278 + DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, quirk_jmicron_ata); 1279 + DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, quirk_jmicron_ata); 1280 + DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); 1281 + DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); 1282 + DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); 1283 1284 #endif 1285