From c84aac195f8d61431df93eedfafa201a88b9e08e Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Fri, 22 Sep 2017 15:46:50 -0600 Subject: [PATCH] UBUNTU: SAUCE: ahci: thunderx2: Fix for errata that affects stop engine BugLink: https://bugs.launchpad.net/bugs/1719031 Apply workaround for this errata: Synopsis: Resetting PxCMD.ST may hang the SATA device Description: An internal ping-pong buffer state is not reset correctly for an PxCMD.ST=0 command for a SATA channel. This may cause the SATA interface to hang when a PxCMD.ST=0 command is received. Workaround: A SATA_BIU_CORE_ENABLE.sw_init_bsi must be asserted by the driver whenever the PxCMD.ST needs to be de-asserted. This will reset both the ports. So, it may not always work in a 2 channel SATA system. Resolution: Fix in B0. Add the code to ahci_stop_engine() to do this. It is not easy to stop the other "port" since it is associated with a different AHCI interface. Please note that with this fix, SATA reset does not hang any more, but it can cause failures on the other interface if that is in active use. Unfortunately, we have nothing other the the CPU ID to check if the SATA block has this issue. Signed-off-by: Jayachandran C [ dannf: *** There is no need to carry this forward beyond artful *** ] Signed-off-by: dann frazier Signed-off-by: Seth Forshee --- drivers/ata/libahci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 3e286d86ab42..22eacef13bab 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -669,6 +669,20 @@ int ahci_stop_engine(struct ata_port *ap) tmp &= ~PORT_CMD_START; writel(tmp, port_mmio + PORT_CMD); +#ifdef CONFIG_ARM64 + /* Rev Ax of Cavium CN99XX needs a hack for port stop */ + if (MIDR_IS_CPU_MODEL_RANGE(read_cpuid_id(), + MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_VULCAN), + MIDR_CPU_VAR_REV(0, 0), + MIDR_CPU_VAR_REV(0, MIDR_REVISION_MASK))) { + tmp = readl(hpriv->mmio + 0x8000); + writel(tmp | (1 << 26), hpriv->mmio + 0x8000); + udelay(1); + writel(tmp & ~(1 << 26), hpriv->mmio + 0x8000); + dev_warn(ap->host->dev, "CN99XX stop engine fix applied!\n"); + } +#endif + /* wait for engine to stop. This could be as long as 500 msec */ tmp = ata_wait_register(ap, port_mmio + PORT_CMD, PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500); -- 2.39.2