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

ata: ahci_brcm: Avoid writing to read-only registers

This commit makes use of the AHCI_HFLAG_YES_ALPM flag to prevent
the driver from writing to the read-only Host Capability register.

It also sets the AHCI_HFLAG_NO_WRITE_TO_RO flag to prevent the AHCI
library from writing to read-only registers.

Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Doug Berger and committed by
Tejun Heo
da8fa9cc 7fab72f8

+4 -8
+4 -8
drivers/ata/ahci_brcm.c
··· 39 39 #define PIODATA_ENDIAN_SHIFT 6 40 40 #define ENDIAN_SWAP_NONE 0 41 41 #define ENDIAN_SWAP_FULL 2 42 - #define OVERRIDE_HWINIT BIT(16) 43 42 #define SATA_TOP_CTRL_TP_CTRL 0x8 44 43 #define SATA_TOP_CTRL_PHY_CTRL 0xc 45 44 #define SATA_TOP_CTRL_PHY_CTRL_1 0x0 ··· 125 126 static void brcm_sata_alpm_init(struct ahci_host_priv *hpriv) 126 127 { 127 128 struct brcm_ahci_priv *priv = hpriv->plat_data; 128 - u32 bus_ctrl, port_ctrl, host_caps; 129 + u32 port_ctrl, host_caps; 129 130 int i; 130 131 131 132 /* Enable support for ALPM */ 132 - bus_ctrl = brcm_sata_readreg(priv->top_ctrl + 133 - SATA_TOP_CTRL_BUS_CTRL); 134 - brcm_sata_writereg(bus_ctrl | OVERRIDE_HWINIT, 135 - priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL); 136 133 host_caps = readl(hpriv->mmio + HOST_CAP); 137 - writel(host_caps | HOST_CAP_ALPM, hpriv->mmio); 138 - brcm_sata_writereg(bus_ctrl, priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL); 134 + if (!(host_caps & HOST_CAP_ALPM)) 135 + hpriv->flags |= AHCI_HFLAG_YES_ALPM; 139 136 140 137 /* 141 138 * Adjust timeout to allow PLL sufficient time to lock while waking ··· 355 360 356 361 if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ) 357 362 hpriv->flags |= AHCI_HFLAG_NO_NCQ; 363 + hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO; 358 364 359 365 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info, 360 366 &ahci_platform_sht);