chengshan / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
Justin Vreeland 794d92
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Justin Vreeland 794d92
From: Robert Richter <rrichter@redhat.com>
Justin Vreeland 794d92
Date: Thu, 7 Jun 2018 22:59:33 -0400
Justin Vreeland 794d92
Subject: [PATCH] ahci: thunderx2: Fix for errata that affects stop engine
Justin Vreeland 794d92
Justin Vreeland 794d92
Message-id: <1528412373-19128-3-git-send-email-rrichter@redhat.com>
Justin Vreeland 794d92
Patchwork-id: 220952
Justin Vreeland 794d92
O-Subject: [RHEL-8.0 BZ 1563590 v2 2/2] ahci: thunderx2: Fix for errata that affects stop engine
Justin Vreeland 794d92
Bugzilla: 1563590
Justin Vreeland 794d92
RH-Acked-by: Dean Nelson <dnelson@redhat.com>
Justin Vreeland 794d92
RH-Acked-by: Mark Langsdorf <mlangsdo@redhat.com>
Justin Vreeland 794d92
RH-Acked-by: Mark Salter <msalter@redhat.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
From: Jayachandran C <jnair@caviumnetworks.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
Apply workaround for this errata:
Justin Vreeland 794d92
  Synopsis: Resetting PxCMD.ST may hang the SATA device
Justin Vreeland 794d92
Justin Vreeland 794d92
  Description: An internal ping-pong buffer state is not reset
Justin Vreeland 794d92
  correctly for an PxCMD.ST=0 command for a SATA channel. This
Justin Vreeland 794d92
  may cause the SATA interface to hang when a PxCMD.ST=0 command
Justin Vreeland 794d92
  is received.
Justin Vreeland 794d92
Justin Vreeland 794d92
  Workaround: A SATA_BIU_CORE_ENABLE.sw_init_bsi must be asserted
Justin Vreeland 794d92
  by the driver whenever the PxCMD.ST needs to be de-asserted. This
Justin Vreeland 794d92
  will reset both the ports. So, it may not always work in a 2
Justin Vreeland 794d92
  channel SATA system.
Justin Vreeland 794d92
Justin Vreeland 794d92
  Resolution: Fix in B0.
Justin Vreeland 794d92
Justin Vreeland 794d92
Add the code to ahci_stop_engine() to do this. It is not easy to
Justin Vreeland 794d92
stop the other "port" since it is associated with a different AHCI
Justin Vreeland 794d92
interface. Please note that with this fix, SATA reset does not
Justin Vreeland 794d92
hang any more, but it can cause failures on the other interface
Justin Vreeland 794d92
if that is in active use.
Justin Vreeland 794d92
Justin Vreeland 794d92
Unfortunately, we have nothing other the the CPU ID to check if the
Justin Vreeland 794d92
SATA block has this issue.
Justin Vreeland 794d92
Justin Vreeland 794d92
RHEL-only:
Justin Vreeland 794d92
Justin Vreeland 794d92
Both patches are in RHEL-7.6 also. Inclusion of the patches into RHEL-8
Justin Vreeland 794d92
was discussed. Since there are partners with Ax system configurations it
Justin Vreeland 794d92
was decided to carry them in RHEL8 too. See:
Justin Vreeland 794d92
Justin Vreeland 794d92
 https://bugzilla.redhat.com/show_bug.cgi?id=1563590#c1
Justin Vreeland 794d92
Justin Vreeland 794d92
[v3 with new delays]
Justin Vreeland 794d92
Signed-off-by: Jayachandran C <jnair@caviumnetworks.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
Upstream Status: RHEL only
Justin Vreeland 794d92
Signed-off-by: Robert Richter <rrichter@redhat.com>
Justin Vreeland 794d92
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Justin Vreeland 794d92
---
Justin Vreeland 794d92
 drivers/ata/libahci.c | 18 ++++++++++++++++++
Justin Vreeland 794d92
 1 file changed, 18 insertions(+)
Justin Vreeland 794d92
Justin Vreeland 794d92
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
Justin Vreeland 794d92
index ea5bf5f4cbed..71c55cae27ac 100644
Justin Vreeland 794d92
--- a/drivers/ata/libahci.c
Justin Vreeland 794d92
+++ b/drivers/ata/libahci.c
Justin Vreeland 794d92
@@ -666,6 +666,24 @@ int ahci_stop_engine(struct ata_port *ap)
Justin Vreeland 794d92
 	tmp &= ~PORT_CMD_START;
Justin Vreeland 794d92
 	writel(tmp, port_mmio + PORT_CMD);
Justin Vreeland 794d92
Justin Vreeland 794d92
+#ifdef CONFIG_ARM64
Justin Vreeland 794d92
+	/* Rev Ax of Cavium CN99XX needs a hack for port stop */
Justin Vreeland 794d92
+	if (dev_is_pci(ap->host->dev) &&
Justin Vreeland 794d92
+	    to_pci_dev(ap->host->dev)->vendor == 0x14e4 &&
Justin Vreeland 794d92
+	    to_pci_dev(ap->host->dev)->device == 0x9027 &&
Justin Vreeland 794d92
+	    midr_is_cpu_model_range(read_cpuid_id(),
Justin Vreeland 794d92
+			MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_VULCAN),
Justin Vreeland 794d92
+			MIDR_CPU_VAR_REV(0, 0),
Justin Vreeland 794d92
+			MIDR_CPU_VAR_REV(0, MIDR_REVISION_MASK))) {
Justin Vreeland 794d92
+		tmp = readl(hpriv->mmio + 0x8000);
Justin Vreeland 794d92
+		udelay(100);
Justin Vreeland 794d92
+		writel(tmp | (1 << 26), hpriv->mmio + 0x8000);
Justin Vreeland 794d92
+		udelay(100);
Justin Vreeland 794d92
+		writel(tmp & ~(1 << 26), hpriv->mmio + 0x8000);
Justin Vreeland 794d92
+		dev_warn(ap->host->dev, "CN99XX SATA reset workaround applied\n");
Justin Vreeland 794d92
+	}
Justin Vreeland 794d92
+#endif
Justin Vreeland 794d92
+
Justin Vreeland 794d92
 	/* wait for engine to stop. This could be as long as 500 msec */
Justin Vreeland 794d92
 	tmp = ata_wait_register(ap, port_mmio + PORT_CMD,
Justin Vreeland 794d92
 				PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
Justin Vreeland 794d92
-- 
Justin Vreeland 794d92
2.28.0
Justin Vreeland 794d92