From patchwork Wed Sep 6 08:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricky WU X-Patchwork-Id: 13375354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9646EB8FAD for ; Wed, 6 Sep 2023 08:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231322AbjIFIEH (ORCPT ); Wed, 6 Sep 2023 04:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbjIFIEH (ORCPT ); Wed, 6 Sep 2023 04:04:07 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F36BECF0; Wed, 6 Sep 2023 01:03:59 -0700 (PDT) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 386839PB0008536, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.81/5.90) with ESMTPS id 386839PB0008536 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Sep 2023 16:03:09 +0800 Received: from RTEXMBS03.realtek.com.tw (172.21.6.96) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Wed, 6 Sep 2023 16:03:37 +0800 Received: from RTEXMBS01.realtek.com.tw (172.21.6.94) by RTEXMBS03.realtek.com.tw (172.21.6.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Sep 2023 16:03:37 +0800 Received: from RTEXMBS01.realtek.com.tw ([fe80::9cb8:8d5:b6b3:213b]) by RTEXMBS01.realtek.com.tw ([fe80::9cb8:8d5:b6b3:213b%5]) with mapi id 15.01.2375.007; Wed, 6 Sep 2023 16:03:37 +0800 From: Ricky WU To: "arnd@arndb.de" , "gregkh@linuxfoundation.org" , "ulf.hansson@linaro.org" , Ricky WU , "kai.heng.feng@canonical.com" , "linux-kernel@vger.kernel.org" , "linux-mmc@vger.kernel.org" Subject: [PATCH] misc: rtsx: Fix an error access Page fault Thread-Topic: [PATCH] misc: rtsx: Fix an error access Page fault Thread-Index: AQHZ4Jftyjh/fSClKUGC38rBdS0qoQ== Date: Wed, 6 Sep 2023 08:03:36 +0000 Message-ID: <2ce258f371234b1f8a1a470d5488d00e@realtek.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.22.81.102] x-kse-serverinfo: RTEXMBS03.realtek.com.tw, 9 x-kse-antispam-interceptor-info: fallback x-kse-antivirus-interceptor-info: fallback MIME-Version: 1.0 X-KSE-AntiSpam-Interceptor-Info: fallback Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Signed-off-by: Ricky Wu Tested-by: Ricky Wu --- 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