Skip to contentSkip to conversation

mmc: sdhci-pci-gli: GL9767: Wait for UHS-II PHY before LPM

PATCH Superseded Matthew Schwartz 3 participants 5 messages Oct 21 – Nov 4

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-pci-gli: GL9767: Wait for UHS-II PHY before LPM

sdhci_gl9767_set_clock() re-enables low power negotiation right after releasing the UHS-II PHY reset. If the bus then goes idle before the PHY has settled, every SDHCI MMIO read returns all-ones for about 250 us. sdhci_uhs2_interface_detect() takes that as IF_DETECT and LANE_SYNC set, so a UHS-I only microSD card is treated as UHS-II. The attach then either fails with "SDHCI_UHS2_CAPS_PTR(65535) is wrong" or, if the registers come back before the CAPS_PTR read, runs DEVICE_INIT 30 times with a 10 second timeout each and delays card detection by 5 minutes.

Config register 0x8CC reads 0x2000 from clock enable until about 250-300 us after the PHY reset release and 0x1000 otherwise. Poll its bit 13 before re-enabling low power negotiation. The register meaning is inferred from that behaviour, and with the wait in place 12 of 12 UHS-II probes of a UHS-I card correctly found no UHS-II interface.

Fixes 27dd3b82557a ("mmc: sdhci-pci-gli: enable UHS-II mode for GL9767")
---
 drivers/mmc/host/sdhci-pci-gli.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-gli.c +28 -1
index b55618566d651..bd383918d27c7 100644
@@ -205,6 +205,9 @@
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN		  BIT(6)
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN	  BIT(10)
 
+#define PCIE_GLI_9767_PHY_STS			0x8CC
+#define   PCIE_GLI_9767_PHY_STS_UHS2_BUSY	  BIT(13)
+
 #define PCIE_GLI_9767_PWR_MACRO_CTL					0x8D0
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE			  GENMASK(3, 0)
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE		  GENMASK(15, 12)
@@ -1190,6 +1193,27 @@ static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable)
 	gl9767_vhs_read(pdev);
 }
 
+static u32 gl9767_read_phy_sts(struct pci_dev *pdev)
+{
+	u32 value;
+
+	pci_read_config_dword(pdev, PCIE_GLI_9767_PHY_STS, &value);
+
+	return value;
+}
+
+static void sdhci_gl9767_uhs2_wait_phy_ready(struct sdhci_host *host)
+{
+	struct sdhci_pci_slot *slot = sdhci_priv(host);
+	struct pci_dev *pdev = slot->chip->pdev;
+	u32 value;
+
+	if (read_poll_timeout_atomic(gl9767_read_phy_sts, value,
+				     !(value & PCIE_GLI_9767_PHY_STS_UHS2_BUSY),
+				     10, 10000, false, pdev))
+		pr_warn("%s: UHS-II PHY not ready after reset.\n", mmc_hostname(host->mmc));
+}
+
 static void sdhci_gl9767_uhs2_phy_reset(struct sdhci_host *host, bool assert)
 {
 	struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -1276,9 +1300,12 @@ static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	sdhci_enable_clk(host, clk);
 
-	if (mmc_card_uhs2(host->mmc))
+	if (mmc_card_uhs2(host->mmc)) {
 		/* De-assert reset */
 		sdhci_gl9767_uhs2_phy_reset(host, false);
+		/* Low power negotiation before the PHY settles makes MMIO read all-ones */
+		sdhci_gl9767_uhs2_wait_phy_ready(host);
+	}
 
 	gl9767_set_low_power_negotiation(pdev, true);
 }
Signature · 1 line
2.56.0
Tested-by on v1 1/1
#1 lore raw
Quoted 20 lines

-----Original Message-----
From: Matthew Schwartz <[email protected]>
Sent: Thursday, October 22, 2026 7:33 AM
To: Adrian Hunter <[email protected]>; Ulf Hansson <[email protected]>
Cc: [email protected]; [email protected]; Victor Shih <[email protected]>; Lucas Lai <[email protected]>; BenChuang[莊智量] <[email protected]>; Matthew Schwartz <[email protected]>
Subject: [PATCH] mmc: sdhci-pci-gli: GL9767: Wait for UHS-II PHY before LPM

sdhci_gl9767_set_clock() re-enables low power negotiation right after releasing the UHS-II PHY reset. If the bus then goes idle before the PHY has settled, every SDHCI MMIO read returns all-ones for about 250 us. sdhci_uhs2_interface_detect() takes that as IF_DETECT and LANE_SYNC set, so a UHS-I only microSD card is treated as UHS-II. The attach then either fails with "SDHCI_UHS2_CAPS_PTR(65535) is wrong" or, if the registers come back before the CAPS_PTR read, runs DEVICE_INIT 30 times with a 10 second timeout each and delays card detection by 5 minutes.

Quoted 8 lines

Config register 0x8CC reads 0x2000 from clock enable until about 250-300 us after the PHY reset release and 0x1000 otherwise. Poll its bit 13 before re-enabling low power negotiation. The register meaning is inferred from that behaviour, and with the wait in place 12 of 12 UHS-II probes of a UHS-I card correctly found no UHS-II interface.

Fixes 27dd3b82557a ("mmc: sdhci-pci-gli: enable UHS-II mode for GL9767")

Hi Matthew,

Thanks for the patch.

I checked the GL9767 register definition. Register 0x8CC is the UHS-II Status Register, and bit 13 is documented as UHS2_WAKEUP_ACTIVATE.

I was able to reproduce the "SDHCI_UHS2_CAPS_PTR(65535) is wrong" issue on my GL9767 test system, and I can no longer reproduce it with this patch applied.

Quoted 9 lines
---
 drivers/mmc/host/sdhci-pci-gli.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-gli.c +0 -0
index b55618566d651..bd383918d27c7 100644

drivers/mmc/host/sdhci-pci-gli.c line 209

Quoted 5 lines
drivers/mmc/host/sdhci-pci-gli.c +2 -0
@@ -205,6 +205,9 @@
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN           BIT(6)
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN    BIT(10)
 
+#define PCIE_GLI_9767_PHY_STS                        0x8CC
+#define   PCIE_GLI_9767_PHY_STS_UHS2_BUSY      BIT(13)

maybe PCIE_GLI_9767_UHS2_STS and PCIE_GLI_9767_UHS2_STS_WAKEUP_ACTIVATE

Quoted 19 lines
drivers/mmc/host/sdhci-pci-gli.c +12 -0
+
 #define PCIE_GLI_9767_PWR_MACRO_CTL                                  0x8D0
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE                      GENMASK(3, 0)
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE           GENMASK(15, 12)
@@ -1190,6 +1193,27 @@ static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable)
      gl9767_vhs_read(pdev);
 }
 
+static u32 gl9767_read_phy_sts(struct pci_dev *pdev)
+{
+     u32 value;
+
+     pci_read_config_dword(pdev, PCIE_GLI_9767_PHY_STS, &value);
+
+     return value;
+}
+
+static void sdhci_gl9767_uhs2_wait_phy_ready(struct sdhci_host *host)
+{

drivers/mmc/host/sdhci-pci-gli.c static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable) · line 1216

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c +10 -0
+     struct sdhci_pci_slot *slot = sdhci_priv(host);
+     struct pci_dev *pdev = slot->chip->pdev;
+     u32 value;
+
+     if (read_poll_timeout_atomic(gl9767_read_phy_sts, value,
+                                  !(value & PCIE_GLI_9767_PHY_STS_UHS2_BUSY),
+                                  10, 10000, false, pdev))
+             pr_warn("%s: UHS-II PHY not ready after reset.\n", mmc_hostname(host->mmc));
+}
+

One thing I was curious about.

The commit message mentions an observed settling time of approximately 250-300 us, while the polling loop allows up to 10 ms before reporting a timeout.

I assume the timeout is intentionally conservative, but I was wondering whether there was any particular reason for choosing 10 ms.

Best regards,
Ben Chuang

Quoted 18 lines
drivers/mmc/host/sdhci-pci-gli.c +4 -2
 static void sdhci_gl9767_uhs2_phy_reset(struct sdhci_host *host, bool assert)
 {
      struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -1276,9 +1300,12 @@ static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
 
      sdhci_enable_clk(host, clk);
 
-     if (mmc_card_uhs2(host->mmc))
+     if (mmc_card_uhs2(host->mmc)) {
              /* De-assert reset */
              sdhci_gl9767_uhs2_phy_reset(host, false);
+             /* Low power negotiation before the PHY settles makes MMIO read all-ones */
+             sdhci_gl9767_uhs2_wait_phy_ready(host);
+     }
 
      gl9767_set_low_power_negotiation(pdev, true);
 }
--
Quoted 1 line

2.56.0

________________________________

Genesys Logic Email Confidentiality Notice:
This mail and any attachments may contain information that is confidential, proprietary, privileged or otherwise protected by law. The mail is intended solely for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this mail, you are not authorized to read, print, copy or disseminate this mail.

If you have received this email in error, please notify us immediately by reply email and immediately delete this message and any attachments from your system. Please be noted that any unauthorized use, dissemination, distribution or copying of this email is strictly prohibited.
________________________________

#2 lore raw
Quoted 33 lines · BenChuang[莊智量]
Quoted 20 lines

-----Original Message-----
From: Matthew Schwartz <[email protected]>
Sent: Thursday, October 22, 2026 7:33 AM
To: Adrian Hunter <[email protected]>; Ulf Hansson <[email protected]>
Cc: [email protected]; [email protected]; Victor Shih <[email protected]>; Lucas Lai <[email protected]>; BenChuang[莊智量] <[email protected]>; Matthew Schwartz <[email protected]>
Subject: [PATCH] mmc: sdhci-pci-gli: GL9767: Wait for UHS-II PHY before LPM

sdhci_gl9767_set_clock() re-enables low power negotiation right after releasing the UHS-II PHY reset. If the bus then goes idle before the PHY has settled, every SDHCI MMIO read returns all-ones for about 250 us. sdhci_uhs2_interface_detect() takes that as IF_DETECT and LANE_SYNC set, so a UHS-I only microSD card is treated as UHS-II. The attach then either fails with "SDHCI_UHS2_CAPS_PTR(65535) is wrong" or, if the registers come back before the CAPS_PTR read, runs DEVICE_INIT 30 times with a 10 second timeout each and delays card detection by 5 minutes.

Quoted 8 lines

Config register 0x8CC reads 0x2000 from clock enable until about 250-300 us after the PHY reset release and 0x1000 otherwise. Poll its bit 13 before re-enabling low power negotiation. The register meaning is inferred from that behaviour, and with the wait in place 12 of 12 UHS-II probes of a UHS-I card correctly found no UHS-II interface.

Fixes 27dd3b82557a ("mmc: sdhci-pci-gli: enable UHS-II mode for GL9767")

Hi Matthew,

Thanks for the patch.

Quoted 7 lines

I checked the GL9767 register definition. Register 0x8CC is the UHS-II Status Register, and bit 13 is documented as UHS2_WAKEUP_ACTIVATE.

I was able to reproduce the "SDHCI_UHS2_CAPS_PTR(65535) is wrong" issue on my GL9767 test system, and I can no longer reproduce it with this patch applied.

Thanks for looking up the definition and for testing.

Quoted 15 lines
Quoted 12 lines
---
 drivers/mmc/host/sdhci-pci-gli.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-gli.c +0 -0
index b55618566d651..bd383918d27c7 100644
@@ -205,6 +205,9 @@
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN           BIT(6)
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN    BIT(10)
 
Quoted 4 lines

drivers/mmc/host/sdhci-pci-gli.c line 209

Quoted 2 lines
drivers/mmc/host/sdhci-pci-gli.c +2 -0
+#define PCIE_GLI_9767_PHY_STS                        0x8CC
+#define   PCIE_GLI_9767_PHY_STS_UHS2_BUSY      BIT(13)

maybe PCIE_GLI_9767_UHS2_STS and PCIE_GLI_9767_UHS2_STS_WAKEUP_ACTIVATE

Sounds good, will do in v2.

Quoted 33 lines
Quoted 20 lines
drivers/mmc/host/sdhci-pci-gli.c +12 -0
+
 #define PCIE_GLI_9767_PWR_MACRO_CTL                                  0x8D0
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE                      GENMASK(3, 0)
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE           GENMASK(15, 12)
@@ -1190,6 +1193,27 @@ static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable)
      gl9767_vhs_read(pdev);
 }
 
+static u32 gl9767_read_phy_sts(struct pci_dev *pdev)
+{
+     u32 value;
+
+     pci_read_config_dword(pdev, PCIE_GLI_9767_PHY_STS, &value);
+
+     return value;
+}
+
+static void sdhci_gl9767_uhs2_wait_phy_ready(struct sdhci_host *host)
+{

drivers/mmc/host/sdhci-pci-gli.c static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable) · line 1216

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c +10 -0
+     struct sdhci_pci_slot *slot = sdhci_priv(host);
+     struct pci_dev *pdev = slot->chip->pdev;
+     u32 value;
+
+     if (read_poll_timeout_atomic(gl9767_read_phy_sts, value,
+                                  !(value & PCIE_GLI_9767_PHY_STS_UHS2_BUSY),
+                                  10, 10000, false, pdev))
+             pr_warn("%s: UHS-II PHY not ready after reset.\n", mmc_hostname(host->mmc));
+}
+

One thing I was curious about.

Quoted 6 lines

The commit message mentions an observed settling time of approximately 250-300 us, while the polling loop allows up to 10 ms before reporting a timeout.

I assume the timeout is intentionally conservative, but I was wondering whether there was any particular reason for choosing 10 ms.

No particular reason beyond headroom. I only had the measured 250-300 us to go on, so I picked a ceiling well above that which is only reached if the bit never clears. If the GL9767 spec gives a maximum wakeup time, I'm happy to use that instead.

Quoted 31 lines

Best regards,
Ben Chuang

Quoted 18 lines
drivers/mmc/host/sdhci-pci-gli.c +4 -2
 static void sdhci_gl9767_uhs2_phy_reset(struct sdhci_host *host, bool assert)
 {
      struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -1276,9 +1300,12 @@ static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
 
      sdhci_enable_clk(host, clk);
 
-     if (mmc_card_uhs2(host->mmc))
+     if (mmc_card_uhs2(host->mmc)) {
              /* De-assert reset */
              sdhci_gl9767_uhs2_phy_reset(host, false);
+             /* Low power negotiation before the PHY settles makes MMIO read all-ones */
+             sdhci_gl9767_uhs2_wait_phy_ready(host);
+     }
 
      gl9767_set_low_power_negotiation(pdev, true);
 }
--
Quoted 1 line

2.56.0

________________________________

Genesys Logic Email Confidentiality Notice:
This mail and any attachments may contain information that is confidential, proprietary, privileged or otherwise protected by law. The mail is intended solely for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this mail, you are not authorized to read, print, copy or disseminate this mail.

If you have received this email in error, please notify us immediately by reply email and immediately delete this message and any attachments from your system. Please be noted that any unauthorized use, dissemination, distribution or copying of this email is strictly prohibited.
________________________________

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Matthew Schwartz
Quoted 9 lines · Matthew Schwartz

sdhci_gl9767_set_clock() re-enables low power negotiation right after releasing the UHS-II PHY reset. If the bus then goes idle before the PHY has settled, every SDHCI MMIO read returns all-ones for about 250 us. sdhci_uhs2_interface_detect() takes that as IF_DETECT and LANE_SYNC set, so a UHS-I only microSD card is treated as UHS-II. The attach then either fails with "SDHCI_UHS2_CAPS_PTR(65535) is wrong" or, if the registers come back before the CAPS_PTR read, runs DEVICE_INIT 30 times with a 10 second timeout each and delays card detection by 5 minutes.

Quoted 8 lines

Config register 0x8CC reads 0x2000 from clock enable until about 250-300 us after the PHY reset release and 0x1000 otherwise. Poll its bit 13 before re-enabling low power negotiation. The register meaning is inferred from that behaviour, and with the wait in place 12 of 12 UHS-II probes of a UHS-I card correctly found no UHS-II interface.

Fixes 27dd3b82557a ("mmc: sdhci-pci-gli: enable UHS-II mode for GL9767")

One comment below, otherwise:

Quoted 30 lines
---
 drivers/mmc/host/sdhci-pci-gli.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-gli.c +11 -0
index b55618566d651..bd383918d27c7 100644
@@ -205,6 +205,9 @@
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN		  BIT(6)
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN	  BIT(10)
 
+#define PCIE_GLI_9767_PHY_STS			0x8CC
+#define   PCIE_GLI_9767_PHY_STS_UHS2_BUSY	  BIT(13)
+
 #define PCIE_GLI_9767_PWR_MACRO_CTL					0x8D0
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE			  GENMASK(3, 0)
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE		  GENMASK(15, 12)
@@ -1190,6 +1193,27 @@ static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable)
 	gl9767_vhs_read(pdev);
 }
 
+static u32 gl9767_read_phy_sts(struct pci_dev *pdev)
+{
+	u32 value;
+
+	pci_read_config_dword(pdev, PCIE_GLI_9767_PHY_STS, &value);
+
+	return value;
+}

drivers/mmc/host/sdhci-pci-gli.c static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable) · line 1213

Quoted 10 lines
drivers/mmc/host/sdhci-pci-gli.c +10 -0
+
+static void sdhci_gl9767_uhs2_wait_phy_ready(struct sdhci_host *host)
+{
+	struct sdhci_pci_slot *slot = sdhci_priv(host);
+	struct pci_dev *pdev = slot->chip->pdev;
+	u32 value;
+
+	if (read_poll_timeout_atomic(gl9767_read_phy_sts, value,
+				     !(value & PCIE_GLI_9767_PHY_STS_UHS2_BUSY),
+				     10, 10000, false, pdev))

Doesn't look like this needs to be atomic

Quoted 20 lines
drivers/mmc/host/sdhci-pci-gli.c +7 -1
+		pr_warn("%s: UHS-II PHY not ready after reset.\n", mmc_hostname(host->mmc));
+}
+
 static void sdhci_gl9767_uhs2_phy_reset(struct sdhci_host *host, bool assert)
 {
 	struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -1276,9 +1300,12 @@ static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	sdhci_enable_clk(host, clk);
 
-	if (mmc_card_uhs2(host->mmc))
+	if (mmc_card_uhs2(host->mmc)) {
 		/* De-assert reset */
 		sdhci_gl9767_uhs2_phy_reset(host, false);
+		/* Low power negotiation before the PHY settles makes MMIO read all-ones */
+		sdhci_gl9767_uhs2_wait_phy_ready(host);
+	}
 
 	gl9767_set_low_power_negotiation(pdev, true);
 }
#4 lore raw
Quoted 57 lines · Adrian Hunter
Quoted 9 lines · Matthew Schwartz

sdhci_gl9767_set_clock() re-enables low power negotiation right after releasing the UHS-II PHY reset. If the bus then goes idle before the PHY has settled, every SDHCI MMIO read returns all-ones for about 250 us. sdhci_uhs2_interface_detect() takes that as IF_DETECT and LANE_SYNC set, so a UHS-I only microSD card is treated as UHS-II. The attach then either fails with "SDHCI_UHS2_CAPS_PTR(65535) is wrong" or, if the registers come back before the CAPS_PTR read, runs DEVICE_INIT 30 times with a 10 second timeout each and delays card detection by 5 minutes.

Quoted 8 lines

Config register 0x8CC reads 0x2000 from clock enable until about 250-300 us after the PHY reset release and 0x1000 otherwise. Poll its bit 13 before re-enabling low power negotiation. The register meaning is inferred from that behaviour, and with the wait in place 12 of 12 UHS-II probes of a UHS-I card correctly found no UHS-II interface.

Fixes 27dd3b82557a ("mmc: sdhci-pci-gli: enable UHS-II mode for GL9767")

One comment below, otherwise:

Quoted 34 lines
---
 drivers/mmc/host/sdhci-pci-gli.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-gli.c +15 -0
index b55618566d651..bd383918d27c7 100644
@@ -205,6 +205,9 @@
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_RST_EN		  BIT(6)
 #define   PCIE_GLI_9767_COMBO_MUX_CTL_WAIT_PERST_EN	  BIT(10)
 
+#define PCIE_GLI_9767_PHY_STS			0x8CC
+#define   PCIE_GLI_9767_PHY_STS_UHS2_BUSY	  BIT(13)
+
 #define PCIE_GLI_9767_PWR_MACRO_CTL					0x8D0
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LOW_VOLTAGE			  GENMASK(3, 0)
 #define   PCIE_GLI_9767_PWR_MACRO_CTL_LD0_LOW_OUTPUT_VOLTAGE		  GENMASK(15, 12)
@@ -1190,6 +1193,27 @@ static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable)
 	gl9767_vhs_read(pdev);
 }
 
+static u32 gl9767_read_phy_sts(struct pci_dev *pdev)
+{
+	u32 value;
+
+	pci_read_config_dword(pdev, PCIE_GLI_9767_PHY_STS, &value);
+
+	return value;
+}
+
+static void sdhci_gl9767_uhs2_wait_phy_ready(struct sdhci_host *host)
+{
+	struct sdhci_pci_slot *slot = sdhci_priv(host);
Quoted 8 lines

drivers/mmc/host/sdhci-pci-gli.c static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable) · line 1213

Quoted 6 lines
drivers/mmc/host/sdhci-pci-gli.c +6 -0
+	struct pci_dev *pdev = slot->chip->pdev;
+	u32 value;
+
+	if (read_poll_timeout_atomic(gl9767_read_phy_sts, value,
+				     !(value & PCIE_GLI_9767_PHY_STS_UHS2_BUSY),
+				     10, 10000, false, pdev))

Doesn't look like this needs to be atomic

Makes sense, will fix in v2.

Quoted 22 lines
Quoted 21 lines
drivers/mmc/host/sdhci-pci-gli.c +7 -1
+		pr_warn("%s: UHS-II PHY not ready after reset.\n", mmc_hostname(host->mmc));
+}
+
 static void sdhci_gl9767_uhs2_phy_reset(struct sdhci_host *host, bool assert)
 {
 	struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -1276,9 +1300,12 @@ static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
 
 	sdhci_enable_clk(host, clk);
 
-	if (mmc_card_uhs2(host->mmc))
+	if (mmc_card_uhs2(host->mmc)) {
 		/* De-assert reset */
 		sdhci_gl9767_uhs2_phy_reset(host, false);
+		/* Low power negotiation before the PHY settles makes MMIO read all-ones */
+		sdhci_gl9767_uhs2_wait_phy_ready(host);
+	}
 
 	gl9767_set_low_power_negotiation(pdev, true);
 }