public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ricky WU <ricky_wu@realtek.com>
To: "arnd@arndb.de" <arnd@arndb.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
	Ricky WU <ricky_wu@realtek.com>,
	"kai.heng.feng@canonical.com" <kai.heng.feng@canonical.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>
Subject: [PATCH] misc: rtsx: Fix an error access Page fault
Date: Wed, 6 Sep 2023 08:03:36 +0000	[thread overview]
Message-ID: <2ce258f371234b1f8a1a470d5488d00e@realtek.com> (raw)

an error occurs on insert SD7.0 card.
The pci slot of rtsx_pci will Link Down when the SD7.0 card inserted,
but the rtsx_pci not exit from runtime_idle at that time,
then do the power_saving function to access the wrong resource

Fixes: 597568e8df04 ("misc: rtsx: Rework runtime power management flow")
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
---
 drivers/misc/cardreader/rtsx_pcr.c | 14 ++++++++------
 drivers/mmc/host/rtsx_pci_sdmmc.c  |  1 +
 include/linux/rtsx_pci.h           |  1 +
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
index a3f4b52bb159..536a3681fd5e 100644
--- a/drivers/misc/cardreader/rtsx_pcr.c
+++ b/drivers/misc/cardreader/rtsx_pcr.c
@@ -1526,6 +1526,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
 	pcr->host_sg_tbl_addr = pcr->rtsx_resv_buf_addr + HOST_CMDS_BUF_LEN;
 	pcr->card_inserted = 0;
 	pcr->card_removed = 0;
+	pcr->is_sd_express = false;
 	INIT_DELAYED_WORK(&pcr->carddet_work, rtsx_pci_card_detect);
 
 	pcr->msi_en = msi_en;
@@ -1735,12 +1736,13 @@ static int rtsx_pci_runtime_idle(struct device *device)
 
 	pcr->state = PDEV_STAT_IDLE;
 
-	if (pcr->ops->disable_auto_blink)
-		pcr->ops->disable_auto_blink(pcr);
-	if (pcr->ops->turn_off_led)
-		pcr->ops->turn_off_led(pcr);
-
-	rtsx_pm_power_saving(pcr);
+	if (!pcr->is_sd_express) {
+		if (pcr->ops->disable_auto_blink)
+			pcr->ops->disable_auto_blink(pcr);
+		if (pcr->ops->turn_off_led)
+			pcr->ops->turn_off_led(pcr);
+		rtsx_pm_power_saving(pcr);
+	}
 
 	mutex_unlock(&pcr->pcr_mutex);
 
diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 87d78432a1e0..80b2f2a31fdc 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1393,6 +1393,7 @@ static int sdmmc_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios)
 		RTS5261_MCU_BUS_SEL_MASK | RTS5261_MCU_CLOCK_SEL_MASK
 		| RTS5261_DRIVER_ENABLE_FW,
 		RTS5261_MCU_CLOCK_SEL_16M | RTS5261_DRIVER_ENABLE_FW);
+	pcr->is_sd_express = true;
 	host->eject = true;
 	return 0;
 }
diff --git a/include/linux/rtsx_pci.h b/include/linux/rtsx_pci.h
index 534038d962e4..295e92224fd0 100644
--- a/include/linux/rtsx_pci.h
+++ b/include/linux/rtsx_pci.h
@@ -1262,6 +1262,7 @@ struct rtsx_pcr {
 	u8			ocp_stat;
 	u8			ocp_stat2;
 	u8			rtd3_en;
+	bool			is_sd_express;
 };
 
 #define PID_524A	0x524A
-- 
2.25.1


             reply	other threads:[~2023-09-06  8:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06  8:03 Ricky WU [this message]
2023-09-07  1:04 ` [PATCH] misc: rtsx: Fix an error access Page fault Kai-Heng Feng
2023-09-08  6:35   ` Ricky WU
2023-09-18  6:08     ` Kai-Heng Feng
2023-09-18  7:29       ` Ricky WU
2023-09-21  6:07         ` Kai-Heng Feng
2023-09-14 14:47 ` Ulf Hansson
2023-09-26 15:03   ` Ulf Hansson
2023-10-06  5:00     ` Kai-Heng Feng
2023-10-11  3:22       ` Ricky WU

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ce258f371234b1f8a1a470d5488d00e@realtek.com \
    --to=ricky_wu@realtek.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox