History

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

Linus Torvalds committed 6 years ago

Commit 0f710a52 parents 8ae40a6 bf0e5018 files · +128 −44Browse files

Unified · Split

8 files
  1. drivers/ata/ahci_brcm.c +94 −39
  2. drivers/ata/libahci_platform.c +4 −2
  3. drivers/ata/libata-core.c +24 −0
  4. drivers/ata/sata_fsl.c +1 −1
  5. drivers/ata/sata_mv.c +1 −1
  6. drivers/ata/sata_nv.c +1 −1
  7. include/linux/ahci_platform.h +2 −0
  8. include/linux/libata.h +1 −0
drivers/ata/ahci_brcm.c+94−39
@@ -76,8 +76,7 @@ enum brcm_ahci_version { · 75 unmodified lines
76};76};
77 77
78enum brcm_ahci_quirks {78enum brcm_ahci_quirks {
79 BRCM_AHCI_QUIRK_NO_NCQ = BIT(0),79 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(0),
80 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1),
81};80};
82 81
83struct brcm_ahci_priv {82struct brcm_ahci_priv {
@@ -213,19 +212,12 @@ static void brcm_sata_phys_disable(struct brcm_ahci_priv *priv) · 129 unmodified lines
213 brcm_sata_phy_disable(priv, i);212 brcm_sata_phy_disable(priv, i);
214}213}
215 214
216static u32 brcm_ahci_get_portmask(struct platform_device *pdev,215static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv,
217 struct brcm_ahci_priv *priv)216 struct brcm_ahci_priv *priv)
218{217{
219 void __iomem *ahci;
220 struct resource *res;
221 u32 impl;218 u32 impl;
222 219
223 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci");220 impl = readl(hpriv->mmio + HOST_PORTS_IMPL);
224 ahci = devm_ioremap_resource(&pdev->dev, res);
225 if (IS_ERR(ahci))
226 return 0;
227
228 impl = readl(ahci + HOST_PORTS_IMPL);
229 221
230 if (fls(impl) > SATA_TOP_MAX_PHYS)222 if (fls(impl) > SATA_TOP_MAX_PHYS)
231 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n",223 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n",
@@ -233,9 +225,6 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev, · 1 unmodified line
233 else if (!impl)225 else if (!impl)
234 dev_info(priv->dev, "no ports found\n");226 dev_info(priv->dev, "no ports found\n");
235 227
236 devm_iounmap(&pdev->dev, ahci);
237 devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
238
239 return impl;228 return impl;
240}229}
241 230
@@ -285,6 +274,13 @@ static unsigned int brcm_ahci_read_id(struct ata_device *dev, · 43 unmodified lines
285 /* Perform the SATA PHY reset sequence */274 /* Perform the SATA PHY reset sequence */
286 brcm_sata_phy_disable(priv, ap->port_no);275 brcm_sata_phy_disable(priv, ap->port_no);
287 276
277 /* Reset the SATA clock */
278 ahci_platform_disable_clks(hpriv);
279 msleep(10);
280
281 ahci_platform_enable_clks(hpriv);
282 msleep(10);
283
288 /* Bring the PHY back on */284 /* Bring the PHY back on */
289 brcm_sata_phy_enable(priv, ap->port_no);285 brcm_sata_phy_enable(priv, ap->port_no);
290 286
@@ -347,11 +343,10 @@ static int brcm_ahci_suspend(struct device *dev) · 56 unmodified lines
347 struct ata_host *host = dev_get_drvdata(dev);343 struct ata_host *host = dev_get_drvdata(dev);
348 struct ahci_host_priv *hpriv = host->private_data;344 struct ahci_host_priv *hpriv = host->private_data;
349 struct brcm_ahci_priv *priv = hpriv->plat_data;345 struct brcm_ahci_priv *priv = hpriv->plat_data;
350 int ret;
351 346
352 ret = ahci_platform_suspend(dev);
353 brcm_sata_phys_disable(priv);347 brcm_sata_phys_disable(priv);
354 return ret;348
349 return ahci_platform_suspend(dev);
355}350}
356 351
357static int brcm_ahci_resume(struct device *dev)352static int brcm_ahci_resume(struct device *dev)
@@ -359,11 +354,44 @@ static int brcm_ahci_resume(struct device *dev) · 1 unmodified line
359 struct ata_host *host = dev_get_drvdata(dev);354 struct ata_host *host = dev_get_drvdata(dev);
360 struct ahci_host_priv *hpriv = host->private_data;355 struct ahci_host_priv *hpriv = host->private_data;
361 struct brcm_ahci_priv *priv = hpriv->plat_data;356 struct brcm_ahci_priv *priv = hpriv->plat_data;
357 int ret;
358
359 /* Make sure clocks are turned on before re-configuration */
360 ret = ahci_platform_enable_clks(hpriv);
361 if (ret)
362 return ret;
362 363
363 brcm_sata_init(priv);364 brcm_sata_init(priv);
364 brcm_sata_phys_enable(priv);365 brcm_sata_phys_enable(priv);
365 brcm_sata_alpm_init(hpriv);366 brcm_sata_alpm_init(hpriv);
366 return ahci_platform_resume(dev);367
368 /* Since we had to enable clocks earlier on, we cannot use
369 * ahci_platform_resume() as-is since a second call to
370 * ahci_platform_enable_resources() would bump up the resources
371 * (regulators, clocks, PHYs) count artificially so we copy the part
372 * after ahci_platform_enable_resources().
373 */
374 ret = ahci_platform_enable_phys(hpriv);
375 if (ret)
376 goto out_disable_phys;
377
378 ret = ahci_platform_resume_host(dev);
379 if (ret)
380 goto out_disable_platform_phys;
381
382 /* We resumed so update PM runtime state */
383 pm_runtime_disable(dev);
384 pm_runtime_set_active(dev);
385 pm_runtime_enable(dev);
386
387 return 0;
388
389out_disable_platform_phys:
390 ahci_platform_disable_phys(hpriv);
391out_disable_phys:
392 brcm_sata_phys_disable(priv);
393 ahci_platform_disable_clks(hpriv);
394 return ret;
367}395}
368#endif396#endif
369 397
@@ -410,44 +438,71 @@ static int brcm_ahci_probe(struct platform_device *pdev) · 40 unmodified lines
410 if (!IS_ERR_OR_NULL(priv->rcdev))438 if (!IS_ERR_OR_NULL(priv->rcdev))
411 reset_control_deassert(priv->rcdev);439 reset_control_deassert(priv->rcdev);
412 440
413 if ((priv->version == BRCM_SATA_BCM7425) ||441 hpriv = ahci_platform_get_resources(pdev, 0);
414 (priv->version == BRCM_SATA_NSP)) {442 if (IS_ERR(hpriv)) {
415 priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ;443 ret = PTR_ERR(hpriv);
444 goto out_reset;
445 }
446
447 hpriv->plat_data = priv;
448 hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP | AHCI_HFLAG_NO_WRITE_TO_RO;
449
450 switch (priv->version) {
451 case BRCM_SATA_BCM7425:
452 hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE;
453 /* fall through */
454 case BRCM_SATA_NSP:
455 hpriv->flags |= AHCI_HFLAG_NO_NCQ;
416 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;456 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;
457 break;
458 default:
459 break;
417 }460 }
418 461
462 ret = ahci_platform_enable_clks(hpriv);
463 if (ret)
464 goto out_reset;
465
466 /* Must be first so as to configure endianness including that
467 * of the standard AHCI register space.
468 */
419 brcm_sata_init(priv);469 brcm_sata_init(priv);
420 470
421 priv->port_mask = brcm_ahci_get_portmask(pdev, priv);471 /* Initializes priv->port_mask which is used below */
422 if (!priv->port_mask)472 priv->port_mask = brcm_ahci_get_portmask(hpriv, priv);
423 return -ENODEV;473 if (!priv->port_mask) {
474 ret = -ENODEV;
475 goto out_disable_clks;
476 }
424 477
478 /* Must be done before ahci_platform_enable_phys() */
425 brcm_sata_phys_enable(priv);479 brcm_sata_phys_enable(priv);
426 480
427 hpriv = ahci_platform_get_resources(pdev, 0);
428 if (IS_ERR(hpriv))
429 return PTR_ERR(hpriv);
430 hpriv->plat_data = priv;
431 hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP;
432
433 brcm_sata_alpm_init(hpriv);481 brcm_sata_alpm_init(hpriv);
434 482
435 ret = ahci_platform_enable_resources(hpriv);483 ret = ahci_platform_enable_phys(hpriv);
436 if (ret)484 if (ret)
437 return ret;485 goto out_disable_phys;
438
439 if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ)
440 hpriv->flags |= AHCI_HFLAG_NO_NCQ;
441 hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO;
442 486
443 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info,487 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info,
444 &ahci_platform_sht);488 &ahci_platform_sht);
445 if (ret)489 if (ret)
446 return ret;490 goto out_disable_platform_phys;
447 491
448 dev_info(dev, "Broadcom AHCI SATA3 registered\n");492 dev_info(dev, "Broadcom AHCI SATA3 registered\n");
449 493
450 return 0;494 return 0;
495
496out_disable_platform_phys:
497 ahci_platform_disable_phys(hpriv);
498out_disable_phys:
499 brcm_sata_phys_disable(priv);
500out_disable_clks:
501 ahci_platform_disable_clks(hpriv);
502out_reset:
503 if (!IS_ERR_OR_NULL(priv->rcdev))
504 reset_control_assert(priv->rcdev);
505 return ret;
451}506}
452 507
453static int brcm_ahci_remove(struct platform_device *pdev)508static int brcm_ahci_remove(struct platform_device *pdev)
@@ -457,12 +512,12 @@ static int brcm_ahci_remove(struct platform_device *pdev) · 3 unmodified lines
457 struct brcm_ahci_priv *priv = hpriv->plat_data;512 struct brcm_ahci_priv *priv = hpriv->plat_data;
458 int ret;513 int ret;
459 514
515 brcm_sata_phys_disable(priv);
516
460 ret = ata_platform_remove_one(pdev);517 ret = ata_platform_remove_one(pdev);
461 if (ret)518 if (ret)
462 return ret;519 return ret;
463 520
464 brcm_sata_phys_disable(priv);
465
466 return 0;521 return 0;
467}522}
468 523
drivers/ata/libahci_platform.c+4−2
@@ -43,7 +43,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_ops); · 42 unmodified lines
43 * RETURNS:43 * RETURNS:
44 * 0 on success otherwise a negative error code44 * 0 on success otherwise a negative error code
45 */45 */
46static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)46int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
47{47{
48 int rc, i;48 int rc, i;
49 49
@@ -74,6 +74,7 @@ disable_phys: · 24 unmodified lines
74 }74 }
75 return rc;75 return rc;
76}76}
77EXPORT_SYMBOL_GPL(ahci_platform_enable_phys);
77 78
78/**79/**
79 * ahci_platform_disable_phys - Disable PHYs80 * ahci_platform_disable_phys - Disable PHYs
@@ -81,7 +82,7 @@ disable_phys: · 1 unmodified line
81 *82 *
82 * This function disables all PHYs found in hpriv->phys.83 * This function disables all PHYs found in hpriv->phys.
83 */84 */
84static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)85void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
85{86{
86 int i;87 int i;
87 88
@@ -90,6 +91,7 @@ static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) · 2 unmodified lines
90 phy_exit(hpriv->phys[i]);91 phy_exit(hpriv->phys[i]);
91 }92 }
92}93}
94EXPORT_SYMBOL_GPL(ahci_platform_disable_phys);
93 95
94/**96/**
95 * ahci_platform_enable_clks - Enable platform clocks97 * ahci_platform_enable_clks - Enable platform clocks
drivers/ata/libata-core.c+24−0
@@ -5328,6 +5328,30 @@ void ata_qc_complete(struct ata_queued_cmd *qc) · 5327 unmodified lines
5328 }5328 }
5329}5329}
5330 5330
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 */
5341u64 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}
5353EXPORT_SYMBOL_GPL(ata_qc_get_active);
5354
5331/**5355/**
5332 * ata_qc_complete_multiple - Complete multiple qcs successfully5356 * ata_qc_complete_multiple - Complete multiple qcs successfully
5333 * @ap: port in question5357 * @ap: port in question
drivers/ata/sata_fsl.c+1−1
@@ -1280,7 +1280,7 @@ static void sata_fsl_host_intr(struct ata_port *ap) · 1279 unmodified lines
1280 i, ioread32(hcr_base + CC),1280 i, ioread32(hcr_base + CC),
1281 ioread32(hcr_base + CA));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 return;1284 return;
1285 1285
1286 } else if ((ap->qc_active & (1ULL << ATA_TAG_INTERNAL))) {1286 } else if ((ap->qc_active & (1ULL << ATA_TAG_INTERNAL))) {
drivers/ata/sata_mv.c+1−1
@@ -2829,7 +2829,7 @@ static void mv_process_crpb_entries(struct ata_port *ap, struct mv_port_priv *pp · 2828 unmodified lines
2829 }2829 }
2830 2830
2831 if (work_done) {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 /* Update the software queue position index in hardware */2834 /* Update the software queue position index in hardware */
2835 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) |2835 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) |
drivers/ata/sata_nv.c+1−1
@@ -984,7 +984,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) · 983 unmodified lines
984 check_commands = 0;984 check_commands = 0;
985 check_commands &= ~(1 << pos);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
include/linux/ahci_platform.h+2−0
@@ -19,6 +19,8 @@ struct ahci_host_priv; · 18 unmodified lines
19struct platform_device;19struct platform_device;
20struct scsi_host_template;20struct scsi_host_template;
21 21
22int ahci_platform_enable_phys(struct ahci_host_priv *hpriv);
23void ahci_platform_disable_phys(struct ahci_host_priv *hpriv);
22int ahci_platform_enable_clks(struct ahci_host_priv *hpriv);24int ahci_platform_enable_clks(struct ahci_host_priv *hpriv);
23void ahci_platform_disable_clks(struct ahci_host_priv *hpriv);25void ahci_platform_disable_clks(struct ahci_host_priv *hpriv);
24int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv);26int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv);
include/linux/libata.h+1−0
@@ -1175,6 +1175,7 @@ extern unsigned int ata_do_dev_read_id(struct ata_device *dev, · 1174 unmodified lines
1175 struct ata_taskfile *tf, u16 *id);1175 struct ata_taskfile *tf, u16 *id);
1176extern void ata_qc_complete(struct ata_queued_cmd *qc);1176extern void ata_qc_complete(struct ata_queued_cmd *qc);
1177extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active);1177extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active);
1178extern u64 ata_qc_get_active(struct ata_port *ap);
1178extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd);1179extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd);
1179extern int ata_std_bios_param(struct scsi_device *sdev,1180extern int ata_std_bios_param(struct scsi_device *sdev,
1180 struct block_device *bdev,1181 struct block_device *bdev,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t