mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-pci-gli: GL9763E: Fix LPM ordering and restore hw settings on resume
@ 2026-11-26  9:04 Athira Palliprath via B4 Relay
  2026-11-29 16:35 ` Adrian Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: Athira Palliprath via B4 Relay @ 2026-11-26  9:04 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson
  Cc: linux-mmc, Victor Shih, Ben Chuang, Sven van Ashbrook,
	Tomasz Figa, linux-kernel, stable, Athira Palliprath

From: Athira Palliprath <palliprath@chromium.org>

In gl9763e_runtime_suspend() and gl9763e_suspend(), LPM negotiation is
currently enabled before SDHCI/CQHCI MMIO register accesses finish, and
in gl9763e_runtime_resume() and gl9763e_resume(), SDHCI/CQHCI MMIO
registers are accessed before LPM negotiation is disabled. Because the
GL9763E has known hardware ASPM/L1 exit and replay-timer issues when
accessed while L1 negotiation is enabled, this ordering allows the
controller to enter L1 mid-transition and become inaccessible (0xffffffff
MMIO reads).

In addition, gl9763e_hw_setting() (which programs AXI_REQ, L1DLY,
HS400_RXDLY, and masks the AER replay timer timeout) is only executed
during probe and is not restored after D3cold or a controller reset.

Fix the ordering so LPM negotiation is disabled (and gl9763e_hw_setting()
is re-applied) before touching SDHCI/CQHCI MMIO on resume, and LPM
negotiation is re-enabled only after MMIO accesses complete on suspend.

Fixes: f9e5b33934ce ("mmc: host: Improve I/O read/write performance for GL9763E")
Fixes: 1202d617e3d0 ("mmc: sdhci-pci-gli: fix LPM negotiation so x86/S0ix SoCs can suspend")
Fixes: 340be332e420 ("mmc: sdhci-pci-gli: GL9763e: Mask the replay timer timeout of AER")
Cc: stable@vger.kernel.org
Signed-off-by: Athira Palliprath <palliprath@chromium.org>
---
 drivers/mmc/host/sdhci-pci-gli.c | 56 ++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c
index 66452ed8c..da3ee8b90 100644
--- a/drivers/mmc/host/sdhci-pci-gli.c
+++ b/drivers/mmc/host/sdhci-pci-gli.c
@@ -1880,13 +1880,13 @@ static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip)
 	struct sdhci_host *host = slot->host;
 	u16 clock;
 
-	/* Enable LPM negotiation to allow entering L1 state */
-	gl9763e_set_low_power_negotiation(slot, true);
-
 	clock = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
 	clock &= ~(SDHCI_CLOCK_PLL_EN | SDHCI_CLOCK_CARD_EN);
 	sdhci_writew(host, clock, SDHCI_CLOCK_CONTROL);
 
+	/* Enable LPM negotiation only after SDHCI MMIO accesses complete. */
+	gl9763e_set_low_power_negotiation(slot, true);
+
 	return 0;
 }
 
@@ -1896,6 +1896,13 @@ static int gl9763e_runtime_resume(struct sdhci_pci_chip *chip)
 	struct sdhci_host *host = slot->host;
 	u16 clock;
 
+	/*
+	 * Restore vendor PCI settings (lost across D3cold/reset) and disable
+	 * LPM negotiation before touching SDHCI MMIO registers.
+	 */
+	gl9763e_hw_setting(slot);
+	gl9763e_set_low_power_negotiation(slot, false);
+
 	if (host->mmc->ios.power_mode != MMC_POWER_ON)
 		return 0;
 
@@ -1916,9 +1923,6 @@ static int gl9763e_runtime_resume(struct sdhci_pci_chip *chip)
 	clock |= SDHCI_CLOCK_CARD_EN;
 	sdhci_writew(host, clock, SDHCI_CLOCK_CONTROL);
 
-	/* Disable LPM negotiation to avoid entering L1 state. */
-	gl9763e_set_low_power_negotiation(slot, false);
-
 	return 0;
 }
 #endif
@@ -1939,21 +1943,19 @@ static int gl9763e_resume(struct sdhci_pci_chip *chip)
 	struct sdhci_pci_slot *slot = chip->slots[0];
 	int ret;
 
-	ret = sdhci_pci_gli_resume(chip);
-	if (ret)
-		return ret;
-
-	ret = cqhci_resume(slot->host->mmc);
-	if (ret)
-		return ret;
-
 	/*
-	 * Disable LPM negotiation to bring device back in sync
-	 * with its runtime_pm state.
+	 * Restore vendor PCI config settings (AXI_REQ, L1DLY, HS400_RXDLY,
+	 * AER replay-timer-timeout mask) lost across D3cold/reset and disable
+	 * LPM negotiation before touching SDHCI/CQHCI MMIO registers.
 	 */
+	gl9763e_hw_setting(slot);
 	gl9763e_set_low_power_negotiation(slot, false);
 
-	return 0;
+	ret = sdhci_pci_gli_resume(chip);
+	if (ret)
+		return ret;
+
+	return cqhci_resume(slot->host->mmc);
 }
 
 static int gl9763e_suspend(struct sdhci_pci_chip *chip)
@@ -1961,28 +1963,26 @@ static int gl9763e_suspend(struct sdhci_pci_chip *chip)
 	struct sdhci_pci_slot *slot = chip->slots[0];
 	int ret;
 
-	/*
-	 * Certain SoCs can suspend only with the bus in low-
-	 * power state, notably x86 SoCs when using S0ix.
-	 * Re-enable LPM negotiation to allow entering L1 state
-	 * and entering system suspend.
-	 */
-	gl9763e_set_low_power_negotiation(slot, true);
-
 	ret = cqhci_suspend(slot->host->mmc);
 	if (ret)
-		goto err_suspend;
+		return ret;
 
 	ret = sdhci_suspend_host(slot->host);
 	if (ret)
 		goto err_suspend_host;
 
+	/*
+	 * Certain SoCs can suspend only with the bus in low-
+	 * power state, notably x86 SoCs when using S0ix.
+	 * Re-enable LPM negotiation to allow entering L1 state
+	 * only after CQHCI/SDHCI MMIO suspend accesses finish.
+	 */
+	gl9763e_set_low_power_negotiation(slot, true);
+
 	return 0;
 
 err_suspend_host:
 	cqhci_resume(slot->host->mmc);
-err_suspend:
-	gl9763e_set_low_power_negotiation(slot, false);
 	return ret;
 }
 #endif

---
base-commit: d2616724e01132376c78872b8324f38659af9f28
change-id: 20261126-gl9763e-lpm-ordering-cd55919f8cc2

Best regards,
-- 
Athira Palliprath <palliprath@chromium.org>



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: sdhci-pci-gli: GL9763E: Fix LPM ordering and restore hw settings on resume
  2026-11-26  9:04 [PATCH] mmc: sdhci-pci-gli: GL9763E: Fix LPM ordering and restore hw settings on resume Athira Palliprath via B4 Relay
@ 2026-11-29 16:35 ` Adrian Hunter
  0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2026-11-29 16:35 UTC (permalink / raw)
  To: Ben Chuang, Victor Shih
  Cc: linux-mmc, Sven van Ashbrook, Tomasz Figa, linux-kernel, stable,
	Seth Coulter, palliprath, Ulf Hansson

Hi Ben,

Any comments on this?

On 26/11/2026 11:04, Athira Palliprath via B4 Relay wrote:
> From: Athira Palliprath <palliprath@chromium.org>
> 
> In gl9763e_runtime_suspend() and gl9763e_suspend(), LPM negotiation is
> currently enabled before SDHCI/CQHCI MMIO register accesses finish, and
> in gl9763e_runtime_resume() and gl9763e_resume(), SDHCI/CQHCI MMIO
> registers are accessed before LPM negotiation is disabled. Because the
> GL9763E has known hardware ASPM/L1 exit and replay-timer issues when
> accessed while L1 negotiation is enabled, this ordering allows the
> controller to enter L1 mid-transition and become inaccessible (0xffffffff
> MMIO reads).
> 
> In addition, gl9763e_hw_setting() (which programs AXI_REQ, L1DLY,
> HS400_RXDLY, and masks the AER replay timer timeout) is only executed
> during probe and is not restored after D3cold or a controller reset.
> 
> Fix the ordering so LPM negotiation is disabled (and gl9763e_hw_setting()
> is re-applied) before touching SDHCI/CQHCI MMIO on resume, and LPM
> negotiation is re-enabled only after MMIO accesses complete on suspend.
> 
> Fixes: f9e5b33934ce ("mmc: host: Improve I/O read/write performance for GL9763E")
> Fixes: 1202d617e3d0 ("mmc: sdhci-pci-gli: fix LPM negotiation so x86/S0ix SoCs can suspend")
> Fixes: 340be332e420 ("mmc: sdhci-pci-gli: GL9763e: Mask the replay timer timeout of AER")
> Cc: stable@vger.kernel.org
> Signed-off-by: Athira Palliprath <palliprath@chromium.org>
> ---
>  drivers/mmc/host/sdhci-pci-gli.c | 56 ++++++++++++++++++++--------------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c
> index 66452ed8c..da3ee8b90 100644
> --- a/drivers/mmc/host/sdhci-pci-gli.c
> +++ b/drivers/mmc/host/sdhci-pci-gli.c
> @@ -1880,13 +1880,13 @@ static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip)
>  	struct sdhci_host *host = slot->host;
>  	u16 clock;
>  
> -	/* Enable LPM negotiation to allow entering L1 state */
> -	gl9763e_set_low_power_negotiation(slot, true);
> -
>  	clock = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
>  	clock &= ~(SDHCI_CLOCK_PLL_EN | SDHCI_CLOCK_CARD_EN);
>  	sdhci_writew(host, clock, SDHCI_CLOCK_CONTROL);
>  
> +	/* Enable LPM negotiation only after SDHCI MMIO accesses complete. */
> +	gl9763e_set_low_power_negotiation(slot, true);
> +
>  	return 0;
>  }
>  
> @@ -1896,6 +1896,13 @@ static int gl9763e_runtime_resume(struct sdhci_pci_chip *chip)
>  	struct sdhci_host *host = slot->host;
>  	u16 clock;
>  
> +	/*
> +	 * Restore vendor PCI settings (lost across D3cold/reset) and disable
> +	 * LPM negotiation before touching SDHCI MMIO registers.
> +	 */
> +	gl9763e_hw_setting(slot);
> +	gl9763e_set_low_power_negotiation(slot, false);
> +
>  	if (host->mmc->ios.power_mode != MMC_POWER_ON)
>  		return 0;
>  
> @@ -1916,9 +1923,6 @@ static int gl9763e_runtime_resume(struct sdhci_pci_chip *chip)
>  	clock |= SDHCI_CLOCK_CARD_EN;
>  	sdhci_writew(host, clock, SDHCI_CLOCK_CONTROL);
>  
> -	/* Disable LPM negotiation to avoid entering L1 state. */
> -	gl9763e_set_low_power_negotiation(slot, false);
> -
>  	return 0;
>  }
>  #endif
> @@ -1939,21 +1943,19 @@ static int gl9763e_resume(struct sdhci_pci_chip *chip)
>  	struct sdhci_pci_slot *slot = chip->slots[0];
>  	int ret;
>  
> -	ret = sdhci_pci_gli_resume(chip);
> -	if (ret)
> -		return ret;
> -
> -	ret = cqhci_resume(slot->host->mmc);
> -	if (ret)
> -		return ret;
> -
>  	/*
> -	 * Disable LPM negotiation to bring device back in sync
> -	 * with its runtime_pm state.
> +	 * Restore vendor PCI config settings (AXI_REQ, L1DLY, HS400_RXDLY,
> +	 * AER replay-timer-timeout mask) lost across D3cold/reset and disable
> +	 * LPM negotiation before touching SDHCI/CQHCI MMIO registers.
>  	 */
> +	gl9763e_hw_setting(slot);
>  	gl9763e_set_low_power_negotiation(slot, false);
>  
> -	return 0;
> +	ret = sdhci_pci_gli_resume(chip);
> +	if (ret)
> +		return ret;
> +
> +	return cqhci_resume(slot->host->mmc);
>  }
>  
>  static int gl9763e_suspend(struct sdhci_pci_chip *chip)
> @@ -1961,28 +1963,26 @@ static int gl9763e_suspend(struct sdhci_pci_chip *chip)
>  	struct sdhci_pci_slot *slot = chip->slots[0];
>  	int ret;
>  
> -	/*
> -	 * Certain SoCs can suspend only with the bus in low-
> -	 * power state, notably x86 SoCs when using S0ix.
> -	 * Re-enable LPM negotiation to allow entering L1 state
> -	 * and entering system suspend.
> -	 */
> -	gl9763e_set_low_power_negotiation(slot, true);
> -
>  	ret = cqhci_suspend(slot->host->mmc);
>  	if (ret)
> -		goto err_suspend;
> +		return ret;
>  
>  	ret = sdhci_suspend_host(slot->host);
>  	if (ret)
>  		goto err_suspend_host;
>  
> +	/*
> +	 * Certain SoCs can suspend only with the bus in low-
> +	 * power state, notably x86 SoCs when using S0ix.
> +	 * Re-enable LPM negotiation to allow entering L1 state
> +	 * only after CQHCI/SDHCI MMIO suspend accesses finish.
> +	 */
> +	gl9763e_set_low_power_negotiation(slot, true);
> +
>  	return 0;
>  
>  err_suspend_host:
>  	cqhci_resume(slot->host->mmc);
> -err_suspend:
> -	gl9763e_set_low_power_negotiation(slot, false);
>  	return ret;
>  }
>  #endif
> 
> ---
> base-commit: d2616724e01132376c78872b8324f38659af9f28
> change-id: 20261126-gl9763e-lpm-ordering-cd55919f8cc2
> 
> Best regards,


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26  9:04 [PATCH] mmc: sdhci-pci-gli: GL9763E: Fix LPM ordering and restore hw settings on resume Athira Palliprath via B4 Relay
2026-11-29 16:35 ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®