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 tag 'libata-5.5-20191226' of git://git.kernel.dk/linux-block

Pull libata fixes from Jens Axboe:
"Two things in here:

- First half of a series that fixes ahci_brcm, also marked for
stable. The other part of the series is going into 5.6 (Florian)

- sata_nv regression fix that is also marked for stable (Sascha)"

* tag 'libata-5.5-20191226' of git://git.kernel.dk/linux-block:
ata: ahci_brcm: Add missing clock management during recovery
ata: ahci_brcm: BCM7425 AHCI requires AHCI_HFLAG_DELAY_ENGINE
ata: ahci_brcm: Fix AHCI resources management
ata: libahci_platform: Export again ahci_platform_<en/dis>able_phys()
libata: Fix retrieving of active qcs

+129 -45
+95 -40
drivers/ata/ahci_brcm.c
··· 76 76 }; 77 77 78 78 enum brcm_ahci_quirks { 79 - BRCM_AHCI_QUIRK_NO_NCQ = BIT(0), 80 - BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1), 79 + BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(0), 81 80 }; 82 81 83 82 struct brcm_ahci_priv { ··· 212 213 brcm_sata_phy_disable(priv, i); 213 214 } 214 215 215 - static u32 brcm_ahci_get_portmask(struct platform_device *pdev, 216 + static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv, 216 217 struct brcm_ahci_priv *priv) 217 218 { 218 - void __iomem *ahci; 219 - struct resource *res; 220 219 u32 impl; 221 220 222 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci"); 223 - ahci = devm_ioremap_resource(&pdev->dev, res); 224 - if (IS_ERR(ahci)) 225 - return 0; 226 - 227 - impl = readl(ahci + HOST_PORTS_IMPL); 221 + impl = readl(hpriv->mmio + HOST_PORTS_IMPL); 228 222 229 223 if (fls(impl) > SATA_TOP_MAX_PHYS) 230 224 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n", 231 225 impl); 232 226 else if (!impl) 233 227 dev_info(priv->dev, "no ports found\n"); 234 - 235 - devm_iounmap(&pdev->dev, ahci); 236 - devm_release_mem_region(&pdev->dev, res->start, resource_size(res)); 237 228 238 229 return impl; 239 230 } ··· 273 284 274 285 /* Perform the SATA PHY reset sequence */ 275 286 brcm_sata_phy_disable(priv, ap->port_no); 287 + 288 + /* Reset the SATA clock */ 289 + ahci_platform_disable_clks(hpriv); 290 + msleep(10); 291 + 292 + ahci_platform_enable_clks(hpriv); 293 + msleep(10); 276 294 277 295 /* Bring the PHY back on */ 278 296 brcm_sata_phy_enable(priv, ap->port_no); ··· 343 347 struct ata_host *host = dev_get_drvdata(dev); 344 348 struct ahci_host_priv *hpriv = host->private_data; 345 349 struct brcm_ahci_priv *priv = hpriv->plat_data; 346 - int ret; 347 350 348 - ret = ahci_platform_suspend(dev); 349 351 brcm_sata_phys_disable(priv); 350 - return ret; 352 + 353 + return ahci_platform_suspend(dev); 351 354 } 352 355 353 356 static int brcm_ahci_resume(struct device *dev) ··· 354 359 struct ata_host *host = dev_get_drvdata(dev); 355 360 struct ahci_host_priv *hpriv = host->private_data; 356 361 struct brcm_ahci_priv *priv = hpriv->plat_data; 362 + int ret; 363 + 364 + /* Make sure clocks are turned on before re-configuration */ 365 + ret = ahci_platform_enable_clks(hpriv); 366 + if (ret) 367 + return ret; 357 368 358 369 brcm_sata_init(priv); 359 370 brcm_sata_phys_enable(priv); 360 371 brcm_sata_alpm_init(hpriv); 361 - return ahci_platform_resume(dev); 372 + 373 + /* Since we had to enable clocks earlier on, we cannot use 374 + * ahci_platform_resume() as-is since a second call to 375 + * ahci_platform_enable_resources() would bump up the resources 376 + * (regulators, clocks, PHYs) count artificially so we copy the part 377 + * after ahci_platform_enable_resources(). 378 + */ 379 + ret = ahci_platform_enable_phys(hpriv); 380 + if (ret) 381 + goto out_disable_phys; 382 + 383 + ret = ahci_platform_resume_host(dev); 384 + if (ret) 385 + goto out_disable_platform_phys; 386 + 387 + /* We resumed so update PM runtime state */ 388 + pm_runtime_disable(dev); 389 + pm_runtime_set_active(dev); 390 + pm_runtime_enable(dev); 391 + 392 + return 0; 393 + 394 + out_disable_platform_phys: 395 + ahci_platform_disable_phys(hpriv); 396 + out_disable_phys: 397 + brcm_sata_phys_disable(priv); 398 + ahci_platform_disable_clks(hpriv); 399 + return ret; 362 400 } 363 401 #endif 364 402 ··· 438 410 if (!IS_ERR_OR_NULL(priv->rcdev)) 439 411 reset_control_deassert(priv->rcdev); 440 412 441 - if ((priv->version == BRCM_SATA_BCM7425) || 442 - (priv->version == BRCM_SATA_NSP)) { 443 - priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ; 444 - priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; 413 + hpriv = ahci_platform_get_resources(pdev, 0); 414 + if (IS_ERR(hpriv)) { 415 + ret = PTR_ERR(hpriv); 416 + goto out_reset; 445 417 } 446 418 419 + hpriv->plat_data = priv; 420 + hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP | AHCI_HFLAG_NO_WRITE_TO_RO; 421 + 422 + switch (priv->version) { 423 + case BRCM_SATA_BCM7425: 424 + hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE; 425 + /* fall through */ 426 + case BRCM_SATA_NSP: 427 + hpriv->flags |= AHCI_HFLAG_NO_NCQ; 428 + priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; 429 + break; 430 + default: 431 + break; 432 + } 433 + 434 + ret = ahci_platform_enable_clks(hpriv); 435 + if (ret) 436 + goto out_reset; 437 + 438 + /* Must be first so as to configure endianness including that 439 + * of the standard AHCI register space. 440 + */ 447 441 brcm_sata_init(priv); 448 442 449 - priv->port_mask = brcm_ahci_get_portmask(pdev, priv); 450 - if (!priv->port_mask) 451 - return -ENODEV; 443 + /* Initializes priv->port_mask which is used below */ 444 + priv->port_mask = brcm_ahci_get_portmask(hpriv, priv); 445 + if (!priv->port_mask) { 446 + ret = -ENODEV; 447 + goto out_disable_clks; 448 + } 452 449 450 + /* Must be done before ahci_platform_enable_phys() */ 453 451 brcm_sata_phys_enable(priv); 454 - 455 - hpriv = ahci_platform_get_resources(pdev, 0); 456 - if (IS_ERR(hpriv)) 457 - return PTR_ERR(hpriv); 458 - hpriv->plat_data = priv; 459 - hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP; 460 452 461 453 brcm_sata_alpm_init(hpriv); 462 454 463 - ret = ahci_platform_enable_resources(hpriv); 455 + ret = ahci_platform_enable_phys(hpriv); 464 456 if (ret) 465 - return ret; 466 - 467 - if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ) 468 - hpriv->flags |= AHCI_HFLAG_NO_NCQ; 469 - hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO; 457 + goto out_disable_phys; 470 458 471 459 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info, 472 460 &ahci_platform_sht); 473 461 if (ret) 474 - return ret; 462 + goto out_disable_platform_phys; 475 463 476 464 dev_info(dev, "Broadcom AHCI SATA3 registered\n"); 477 465 478 466 return 0; 467 + 468 + out_disable_platform_phys: 469 + ahci_platform_disable_phys(hpriv); 470 + out_disable_phys: 471 + brcm_sata_phys_disable(priv); 472 + out_disable_clks: 473 + ahci_platform_disable_clks(hpriv); 474 + out_reset: 475 + if (!IS_ERR_OR_NULL(priv->rcdev)) 476 + reset_control_assert(priv->rcdev); 477 + return ret; 479 478 } 480 479 481 480 static int brcm_ahci_remove(struct platform_device *pdev) ··· 512 457 struct brcm_ahci_priv *priv = hpriv->plat_data; 513 458 int ret; 514 459 460 + brcm_sata_phys_disable(priv); 461 + 515 462 ret = ata_platform_remove_one(pdev); 516 463 if (ret) 517 464 return ret; 518 - 519 - brcm_sata_phys_disable(priv); 520 465 521 466 return 0; 522 467 }
+4 -2
drivers/ata/libahci_platform.c
··· 43 43 * RETURNS: 44 44 * 0 on success otherwise a negative error code 45 45 */ 46 - static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) 46 + int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) 47 47 { 48 48 int rc, i; 49 49 ··· 74 74 } 75 75 return rc; 76 76 } 77 + EXPORT_SYMBOL_GPL(ahci_platform_enable_phys); 77 78 78 79 /** 79 80 * ahci_platform_disable_phys - Disable PHYs ··· 82 81 * 83 82 * This function disables all PHYs found in hpriv->phys. 84 83 */ 85 - static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) 84 + void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) 86 85 { 87 86 int i; 88 87 ··· 91 90 phy_exit(hpriv->phys[i]); 92 91 } 93 92 } 93 + EXPORT_SYMBOL_GPL(ahci_platform_disable_phys); 94 94 95 95 /** 96 96 * ahci_platform_enable_clks - Enable platform clocks
+24
drivers/ata/libata-core.c
··· 5329 5329 } 5330 5330 5331 5331 /** 5332 + * ata_qc_get_active - get bitmask of active qcs 5333 + * @ap: port in question 5334 + * 5335 + * LOCKING: 5336 + * spin_lock_irqsave(host lock) 5337 + * 5338 + * RETURNS: 5339 + * Bitmask of active qcs 5340 + */ 5341 + u64 ata_qc_get_active(struct ata_port *ap) 5342 + { 5343 + u64 qc_active = ap->qc_active; 5344 + 5345 + /* ATA_TAG_INTERNAL is sent to hw as tag 0 */ 5346 + if (qc_active & (1ULL << ATA_TAG_INTERNAL)) { 5347 + qc_active |= (1 << 0); 5348 + qc_active &= ~(1ULL << ATA_TAG_INTERNAL); 5349 + } 5350 + 5351 + return qc_active; 5352 + } 5353 + EXPORT_SYMBOL_GPL(ata_qc_get_active); 5354 + 5355 + /** 5332 5356 * ata_qc_complete_multiple - Complete multiple qcs successfully 5333 5357 * @ap: port in question 5334 5358 * @qc_active: new qc_active mask
+1 -1
drivers/ata/sata_fsl.c
··· 1280 1280 i, ioread32(hcr_base + CC), 1281 1281 ioread32(hcr_base + CA)); 1282 1282 } 1283 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); 1283 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); 1284 1284 return; 1285 1285 1286 1286 } else if ((ap->qc_active & (1ULL << ATA_TAG_INTERNAL))) {
+1 -1
drivers/ata/sata_mv.c
··· 2829 2829 } 2830 2830 2831 2831 if (work_done) { 2832 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); 2832 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); 2833 2833 2834 2834 /* Update the software queue position index in hardware */ 2835 2835 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) |
+1 -1
drivers/ata/sata_nv.c
··· 984 984 check_commands = 0; 985 985 check_commands &= ~(1 << pos); 986 986 } 987 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); 987 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); 988 988 } 989 989 } 990 990
+2
include/linux/ahci_platform.h
··· 19 19 struct platform_device; 20 20 struct scsi_host_template; 21 21 22 + int ahci_platform_enable_phys(struct ahci_host_priv *hpriv); 23 + void ahci_platform_disable_phys(struct ahci_host_priv *hpriv); 22 24 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); 23 25 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); 24 26 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv);
+1
include/linux/libata.h
··· 1175 1175 struct ata_taskfile *tf, u16 *id); 1176 1176 extern void ata_qc_complete(struct ata_queued_cmd *qc); 1177 1177 extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active); 1178 + extern u64 ata_qc_get_active(struct ata_port *ap); 1178 1179 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd); 1179 1180 extern int ata_std_bios_param(struct scsi_device *sdev, 1180 1181 struct block_device *bdev,