From nobody Wed Jan 7 23:06:39 2026 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 465C3279DCE for ; Mon, 5 Jan 2026 06:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767592973; cv=none; b=BFkfCmIRFVbPCUBOYCW7W9xqnCtCF77FkN75FH7XGMBFicqNBO9uN7grqlOD2u5hbcwtozx4g+6DOsz6eGRFWel9wDZy+2VQ1kx6KCxoCjxSMm9mWkZmjq3nhUcEjDCQH29Re4SyANE0o735j3I9HqnBKmAGRSm+cbxjrzmlTVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767592973; c=relaxed/simple; bh=nDbdPA9ndGVjTQeDdCrcstq8/o/mLx5PUKUleDJKv0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nFUtFWUwsLoUJos97ITjdqHvpNB3CGzsPGw8ChT/+DdR8y56n+aS+leSFzJyJi06HyTHuSo+YO5cOLlRlR+aZR7fO/FwXhCihiNm1DpoGg7TA7PDKV1qlIXu87hX8+d3kUqUudvMjpuTMmU89AoDailARTmI6txLoI/siU7AukU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xfCiektz; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xfCiektz" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767592969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=llFKcS1KI3udgKGsj6Aicnjnw1BtILGJ2Zx4ZI9yBZI=; b=xfCiektzLzvGnrVOu+FgzbEulUkqobWfEgwZJ4GFXR0pUME8+T673OYWACOGSHkOupZrj0 PRSDy7+t0bt2d+HwpCwCizPABVpzli6ZM5d8GFgnhzoHZzfZojeDhhHeMvP4PCcWpM7h/T gRbfrwWemKdvhRCoYdURuL2kAnegrMc= From: Matthew Schwartz To: Ulf Hansson , Arnd Bergmann , Ricky Wu , Greg Kroah-Hartman Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Schwartz Subject: [PATCH 1/2] mmc: rtsx: reset power state on suspend Date: Sun, 4 Jan 2026 22:02:35 -0800 Message-ID: <20260105060236.400366-2-matthew.schwartz@linux.dev> In-Reply-To: <20260105060236.400366-1-matthew.schwartz@linux.dev> References: <20260105060236.400366-1-matthew.schwartz@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" When rtsx_pci suspends, the card reader hardware powers off but the sdmmc driver's prev_power_state remains as MMC_POWER_ON. This causes sd_power_on to skip reinitialization on the next I/O request, leading to DMA transfer timeouts and errors on resume 20% of the time. Add a power_off slot callback so the PCR can notify the sdmmc driver during suspend. The sdmmc driver resets prev_power_state, and sd_request checks this to reinitialize the card before the next I/O. Signed-off-by: Matthew Schwartz --- drivers/misc/cardreader/rtsx_pcr.c | 9 +++++++++ drivers/mmc/host/rtsx_pci_sdmmc.c | 22 ++++++++++++++++++++++ include/linux/rtsx_common.h | 1 + 3 files changed, 32 insertions(+) diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/r= tsx_pcr.c index f9952d76d6ed..f1f4d8ed544d 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1654,6 +1654,7 @@ static int __maybe_unused rtsx_pci_suspend(struct dev= ice *dev_d) struct pci_dev *pcidev =3D to_pci_dev(dev_d); struct pcr_handle *handle =3D pci_get_drvdata(pcidev); struct rtsx_pcr *pcr =3D handle->pcr; + struct rtsx_slot *slot =3D &pcr->slots[RTSX_SD_CARD]; =20 dev_dbg(&(pcidev->dev), "--> %s\n", __func__); =20 @@ -1661,6 +1662,9 @@ static int __maybe_unused rtsx_pci_suspend(struct dev= ice *dev_d) =20 mutex_lock(&pcr->pcr_mutex); =20 + if (slot->p_dev && slot->power_off) + slot->power_off(slot->p_dev); + rtsx_pci_power_off(pcr, HOST_ENTER_S3, false); =20 mutex_unlock(&pcr->pcr_mutex); @@ -1772,12 +1776,17 @@ static int rtsx_pci_runtime_suspend(struct device *= device) struct pci_dev *pcidev =3D to_pci_dev(device); struct pcr_handle *handle =3D pci_get_drvdata(pcidev); struct rtsx_pcr *pcr =3D handle->pcr; + struct rtsx_slot *slot =3D &pcr->slots[RTSX_SD_CARD]; =20 dev_dbg(device, "--> %s\n", __func__); =20 cancel_delayed_work_sync(&pcr->carddet_work); =20 mutex_lock(&pcr->pcr_mutex); + + if (slot->p_dev && slot->power_off) + slot->power_off(slot->p_dev); + rtsx_pci_power_off(pcr, HOST_ENTER_S3, true); =20 mutex_unlock(&pcr->pcr_mutex); diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_= sdmmc.c index 792ebae46697..74ee8623ad4e 100644 --- a/drivers/mmc/host/rtsx_pci_sdmmc.c +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c @@ -47,6 +47,7 @@ struct realtek_pci_sdmmc { }; =20 static int sdmmc_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios= ); +static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power= _mode); =20 static inline struct device *sdmmc_dev(struct realtek_pci_sdmmc *host) { @@ -821,6 +822,15 @@ static void sd_request(struct work_struct *work) =20 rtsx_pci_start_run(pcr); =20 + if (host->prev_power_state =3D=3D MMC_POWER_OFF) { + err =3D sd_power_on(host, MMC_POWER_ON); + if (err) { + cmd->error =3D err; + mutex_unlock(&pcr->pcr_mutex); + goto finish; + } + } + rtsx_pci_switch_clock(pcr, host->clock, host->ssc_depth, host->initial_mode, host->double_clk, host->vpclk); rtsx_pci_write_register(pcr, CARD_SELECT, 0x07, SD_MOD_SEL); @@ -1524,6 +1534,16 @@ static void rtsx_pci_sdmmc_card_event(struct platfor= m_device *pdev) mmc_detect_change(host->mmc, 0); } =20 +static void rtsx_pci_sdmmc_power_off(struct platform_device *pdev) +{ + struct realtek_pci_sdmmc *host =3D platform_get_drvdata(pdev); + + if (!host) + return; + + host->prev_power_state =3D MMC_POWER_OFF; +} + static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev) { struct mmc_host *mmc; @@ -1556,6 +1576,7 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_d= evice *pdev) platform_set_drvdata(pdev, host); pcr->slots[RTSX_SD_CARD].p_dev =3D pdev; pcr->slots[RTSX_SD_CARD].card_event =3D rtsx_pci_sdmmc_card_event; + pcr->slots[RTSX_SD_CARD].power_off =3D rtsx_pci_sdmmc_power_off; =20 mutex_init(&host->host_mutex); =20 @@ -1587,6 +1608,7 @@ static void rtsx_pci_sdmmc_drv_remove(struct platform= _device *pdev) pcr =3D host->pcr; pcr->slots[RTSX_SD_CARD].p_dev =3D NULL; pcr->slots[RTSX_SD_CARD].card_event =3D NULL; + pcr->slots[RTSX_SD_CARD].power_off =3D NULL; mmc =3D host->mmc; =20 cancel_work_sync(&host->work); diff --git a/include/linux/rtsx_common.h b/include/linux/rtsx_common.h index da9c8c6b5d50..f294f478f0c0 100644 --- a/include/linux/rtsx_common.h +++ b/include/linux/rtsx_common.h @@ -32,6 +32,7 @@ struct platform_device; struct rtsx_slot { struct platform_device *p_dev; void (*card_event)(struct platform_device *p_dev); + void (*power_off)(struct platform_device *p_dev); }; =20 #endif --=20 2.52.0 From nobody Wed Jan 7 23:06:39 2026 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA07228DB56 for ; Mon, 5 Jan 2026 06:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767592977; cv=none; b=PGdZfUuk9wUpsDL6OY7bCPfX7CqFbd9gbUfBTIPtkLFZPPOZHmDJOTpz9kYhYA+IrwiAAuafl5KtzVDB9FK+2F5X/1co1J/pP1lZUXG4RLA6p9wQip/iTj1corEYlptSSWMrmRTrap2wRVc5YubhSv8uR1VHJ+ziSGfXL3vnLmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767592977; c=relaxed/simple; bh=TjZ0jKbAPXqYFoV+5Ef2uzYrkI9/jkDXYyRnolUp0wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OHF1UfMWDcPeYBCWBWFzkm0OaUUkYbOGUTE6GSpFcD6XHAFnLlEOm42UGqkDxBU9+eCyitIaNdsNHVrGqee8dCFp5nz8vvWnK5p88OQQCfYMjiTobEj9i2TZmdBsaoBgnJiilwEkMb6ADstTcyxrnzqxEMJi66G0YrL61/R61jw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QbCiuxUm; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QbCiuxUm" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767592973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKPZ3eLToROYAddzYBkGoAiIlgpb06BIwoIoHGkRDCg=; b=QbCiuxUmqIo6kucQ3VL52YKCTAttVh4LSu+wULxk/mYlCCbeQsF1UvH71c8DYRvUMs45IA 1IyPTlpIaeFsclUMYOPn/T2i++R5MkdJ3VNJpaZfkf5qQws0wX6VgFZ2LUxHar1f0/HlFq dmfREecVl1xhO8WVXPYKwIVEfNj0WiI= From: Matthew Schwartz To: Ulf Hansson , Arnd Bergmann , Ricky Wu , Greg Kroah-Hartman Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Schwartz Subject: [PATCH 2/2] mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms Date: Sun, 4 Jan 2026 22:02:36 -0800 Message-ID: <20260105060236.400366-3-matthew.schwartz@linux.dev> In-Reply-To: <20260105060236.400366-1-matthew.schwartz@linux.dev> References: <20260105060236.400366-1-matthew.schwartz@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The existing 1ms delay in sd_power_on is insufficient and causes resume errors around 4% of the time. Increasing the delay to 5ms resolves this issue after testing 300 s2idle cycles. Fixes: 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") Signed-off-by: Matthew Schwartz --- drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_= sdmmc.c index 74ee8623ad4e..9e95c6000256 100644 --- a/drivers/mmc/host/rtsx_pci_sdmmc.c +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c @@ -947,7 +947,7 @@ static int sd_power_on(struct realtek_pci_sdmmc *host, = unsigned char power_mode) if (err < 0) return err; =20 - mdelay(1); + mdelay(5); =20 err =3D rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); if (err < 0) --=20 2.52.0