Skip to content

Commit e543c8a

Browse files
committed
Merge branch 'for-4.12-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata fixes from Tejun Heo: - Revert of sata_mv devm_ioremap_resource() conversion. It made init fail if there are overlapping resources which led to detection failures on some setups. - A workaround for an Acer laptop which sometimes reports corrupt port map. - Other non-critical fixes. * 'for-4.12-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: libata: fix error checking in in ata_parse_force_one() Revert "ata: sata_mv: Convert to devm_ioremap_resource()" ata: libahci: properly propagate return value of platform_get_irq() ata: sata_rcar: Handle return value of clk_prepare_enable ahci: Acer SA5-271 SSD Not Detected Fix
2 parents 112eb07 + f7cf69a commit e543c8a

File tree

5 files changed

+62
-11
lines changed

5 files changed

+62
-11
lines changed

drivers/ata/ahci.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,40 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
13641364
{}
13651365
#endif
13661366

1367+
/*
1368+
* On the Acer Aspire Switch Alpha 12, sometimes all SATA ports are detected
1369+
* as DUMMY, or detected but eventually get a "link down" and never get up
1370+
* again. When this happens, CAP.NP may hold a value of 0x00 or 0x01, and the
1371+
* port_map may hold a value of 0x00.
1372+
*
1373+
* Overriding CAP.NP to 0x02 and the port_map to 0x7 will reveal all 3 ports
1374+
* and can significantly reduce the occurrence of the problem.
1375+
*
1376+
* https://bugzilla.kernel.org/show_bug.cgi?id=189471
1377+
*/
1378+
static void acer_sa5_271_workaround(struct ahci_host_priv *hpriv,
1379+
struct pci_dev *pdev)
1380+
{
1381+
static const struct dmi_system_id sysids[] = {
1382+
{
1383+
.ident = "Acer Switch Alpha 12",
1384+
.matches = {
1385+
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1386+
DMI_MATCH(DMI_PRODUCT_NAME, "Switch SA5-271")
1387+
},
1388+
},
1389+
{ }
1390+
};
1391+
1392+
if (dmi_check_system(sysids)) {
1393+
dev_info(&pdev->dev, "enabling Acer Switch Alpha 12 workaround\n");
1394+
if ((hpriv->saved_cap & 0xC734FF00) == 0xC734FF00) {
1395+
hpriv->port_map = 0x7;
1396+
hpriv->cap = 0xC734FF02;
1397+
}
1398+
}
1399+
}
1400+
13671401
#ifdef CONFIG_ARM64
13681402
/*
13691403
* Due to ERRATA#22536, ThunderX needs to handle HOST_IRQ_STAT differently.
@@ -1636,6 +1670,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
16361670
"online status unreliable, applying workaround\n");
16371671
}
16381672

1673+
1674+
/* Acer SA5-271 workaround modifies private_data */
1675+
acer_sa5_271_workaround(hpriv, pdev);
1676+
16391677
/* CAP.NP sometimes indicate the index of the last enabled
16401678
* port, at other times, that of the last possible port, so
16411679
* determining the maximum port number requires looking at

drivers/ata/libahci_platform.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,9 @@ int ahci_platform_init_host(struct platform_device *pdev,
514514

515515
irq = platform_get_irq(pdev, 0);
516516
if (irq <= 0) {
517-
dev_err(dev, "no irq\n");
518-
return -EINVAL;
517+
if (irq != -EPROBE_DEFER)
518+
dev_err(dev, "no irq\n");
519+
return irq;
519520
}
520521

521522
hpriv->irq = irq;

drivers/ata/libata-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6800,7 +6800,7 @@ static int __init ata_parse_force_one(char **cur,
68006800
}
68016801

68026802
force_ent->port = simple_strtoul(id, &endp, 10);
6803-
if (p == endp || *endp != '\0') {
6803+
if (id == endp || *endp != '\0') {
68046804
*reason = "invalid port/link";
68056805
return -EINVAL;
68066806
}

drivers/ata/sata_mv.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,7 +4067,6 @@ static int mv_platform_probe(struct platform_device *pdev)
40674067
struct ata_host *host;
40684068
struct mv_host_priv *hpriv;
40694069
struct resource *res;
4070-
void __iomem *mmio;
40714070
int n_ports = 0, irq = 0;
40724071
int rc;
40734072
int port;
@@ -4086,9 +4085,8 @@ static int mv_platform_probe(struct platform_device *pdev)
40864085
* Get the register base first
40874086
*/
40884087
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
4089-
mmio = devm_ioremap_resource(&pdev->dev, res);
4090-
if (IS_ERR(mmio))
4091-
return PTR_ERR(mmio);
4088+
if (res == NULL)
4089+
return -EINVAL;
40924090

40934091
/* allocate host */
40944092
if (pdev->dev.of_node) {
@@ -4132,7 +4130,12 @@ static int mv_platform_probe(struct platform_device *pdev)
41324130
hpriv->board_idx = chip_soc;
41334131

41344132
host->iomap = NULL;
4135-
hpriv->base = mmio - SATAHC0_REG_BASE;
4133+
hpriv->base = devm_ioremap(&pdev->dev, res->start,
4134+
resource_size(res));
4135+
if (!hpriv->base)
4136+
return -ENOMEM;
4137+
4138+
hpriv->base -= SATAHC0_REG_BASE;
41364139

41374140
hpriv->clk = clk_get(&pdev->dev, NULL);
41384141
if (IS_ERR(hpriv->clk))

drivers/ata/sata_rcar.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,10 @@ static int sata_rcar_probe(struct platform_device *pdev)
890890
dev_err(&pdev->dev, "failed to get access to sata clock\n");
891891
return PTR_ERR(priv->clk);
892892
}
893-
clk_prepare_enable(priv->clk);
893+
894+
ret = clk_prepare_enable(priv->clk);
895+
if (ret)
896+
return ret;
894897

895898
host = ata_host_alloc(&pdev->dev, 1);
896899
if (!host) {
@@ -970,8 +973,11 @@ static int sata_rcar_resume(struct device *dev)
970973
struct ata_host *host = dev_get_drvdata(dev);
971974
struct sata_rcar_priv *priv = host->private_data;
972975
void __iomem *base = priv->base;
976+
int ret;
973977

974-
clk_prepare_enable(priv->clk);
978+
ret = clk_prepare_enable(priv->clk);
979+
if (ret)
980+
return ret;
975981

976982
/* ack and mask */
977983
iowrite32(0, base + SATAINTSTAT_REG);
@@ -988,8 +994,11 @@ static int sata_rcar_restore(struct device *dev)
988994
{
989995
struct ata_host *host = dev_get_drvdata(dev);
990996
struct sata_rcar_priv *priv = host->private_data;
997+
int ret;
991998

992-
clk_prepare_enable(priv->clk);
999+
ret = clk_prepare_enable(priv->clk);
1000+
if (ret)
1001+
return ret;
9931002

9941003
sata_rcar_setup_port(host);
9951004

0 commit comments

Comments
 (0)