From nobody Tue Apr 7 18:02:30 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F2F12F532C for ; Thu, 12 Mar 2026 12:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773317778; cv=none; b=qwBGTSPJ9ouT/JGNJ+/Y8xg8sljnyXv4nbJRDNSyJJ7Vt1jmXpLTkgRpRVbvhslGtiXuLj8yGLlONGVh9EapZ2NuFR7L7e5lLRSR5WrVoV9AIa4VgdxHC9cEdb3VPI54P0y1hGFuSXWiYd43j6NzwrciqroSuBGSsDvTDuXh7N4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773317778; c=relaxed/simple; bh=QfcpGq77fLYNDCobaNjjIeOj2imphrNCAcezXXgBA2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pln9tJAI0PqNxB69B2Ech/j7x8K+UHT2ZNFHH0HQv3CyvMZ9ELgz6hLXmLzZzU8LsNrNke0D1nHxyVM7gtL2HZt2uyfHYxZLXuL2BTgF56ojOc3BW3JtQLJurCZiShtMFYGR6I4nMqH+X6VlC5p2QzGeVdYeez+465LWhi08zA0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=starlabs.systems; spf=pass smtp.mailfrom=starlabs.systems; dkim=pass (2048-bit key) header.d=starlabs-systems.20230601.gappssmtp.com header.i=@starlabs-systems.20230601.gappssmtp.com header.b=0iNdwIYV; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=starlabs.systems Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starlabs.systems Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=starlabs-systems.20230601.gappssmtp.com header.i=@starlabs-systems.20230601.gappssmtp.com header.b="0iNdwIYV" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-439ac15f35fso893247f8f.0 for ; Thu, 12 Mar 2026 05:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=starlabs-systems.20230601.gappssmtp.com; s=20230601; t=1773317770; x=1773922570; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fdIy1fm/RRHFyWbC0yhnY1690tyzx/03AbGybTnU4TE=; b=0iNdwIYVXvXfMxMJzQRUstDg5kFYHo1FwHmc+PVHPpPrfVprih9s2DIavYhGHAqnDi Wm37Kubvh5rAbD5g1EwKGQ/Dkxvomc2L0to7a6amviBk0yEk2aRuWi2BWx7kI6gATAwM KXswJrT0dkh/MYeHlmyfeZfJoWQkW1/cZ//BN3WsFrixvqSnmz945wpEQXER4Zvh3yZz gmYXHtymP8Jr/xq4AXviII8EYM26I3tZgtl7GSLbMTgc5h9b00GB8jliiq6SzFyFoxm5 hYDiruFFLntm+07V1joYSH7UjQjhzu+XKxRHWVmgPWAxCczInolTKCFQcos/8pGR+Ri/ ihLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773317770; x=1773922570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fdIy1fm/RRHFyWbC0yhnY1690tyzx/03AbGybTnU4TE=; b=JrLlOKevOY4apskKI8h2T+y+TGR8GHaVPPSwNbXNCJhuBnCsJl0B7LXdQG9BqWuW1g ZgOBdTagRR71Yvdnml43IslhC9AanJAYJfYGdDv3rcGaRUwk0WXIXwQyjRRJOZE1gZlz 3XWMtwS9tarec6ueRqnk6hwqdCCIE2tQzXfRJovY9QZ8dwYPFBH/xwE6JXFyaTLj5X9r KDg4X/xE54un3IbUbekq2Byh2DiKBxnaj6FUyWXw+sk0nDThArwCeyGgLwUGH3Ia6Lq3 cDTsnWQcVQhTJR+hGmQIErsoNDG1wGzey6DCu3TlCcPvnaYm8TfTyMm7MZhdtD8A55k7 ftHw== X-Forwarded-Encrypted: i=1; AJvYcCX0/o6iNHuSEDM2EM0fCgiEbHE3USEft7/Ku9XYJxgvIkJBPe/nrYRXLsWqKhxvALzlZL0WowsJTPBlxXg=@vger.kernel.org X-Gm-Message-State: AOJu0YwXE6G0waaohnsXihnhCwGPX2VyLOraOAIlGhnoyP/tGOz1vxMP wjzhSBXaZHTnqEwxXXkoA99iPc+wfAufJytFQ+PUVvpE73tW2430Ol2tnTRMRvBQuA== X-Gm-Gg: ATEYQzxyy/+ymauPf9QJgkidIjrQ6NCKAGXQaFWOkTqr1KWS5GYIkDDMgqZoq0lP4S6 v4ARuAheJIFZXfW3vlAVTiS8mFLb15LVLFN+H6g9tq2P1x23qhYUJsJAeqnEQHekHIXie/FYfkT RO9GEm3MgisLSWeSGKPTyGaKgu8NBXIMmsuNml8dRl0fsdZ/XMut3EsO9rlTX5Mgo84PsX1ErA8 SwQbIRpXjKZay7YtAOWP3wLbaLOnaGRduKH7WLOoMr7WJ3f6hNt8WKNPuBKT5L6TcRK5QiyIEiG JjMSrUL3PcODSdthcN2ofjT2lWMs/CUV1IHOjTHkpKkFbX/MXcgTl0vMHEsyz5aIQ5QonUiGPdL c8EfgW/wIeBIgPI9l4gCMFLqU8yhcHUVnFegppSbYT9ya9Ef6GDNKwDHvoXm5rSP8vzDmkvOd5I m0kxZBZbJcadWHg4E4xM1eNmrq0y0wONe/44FMVHROTOG8Aq41lmMmURoMQ7Pej+dkldPxvg== X-Received: by 2002:a05:6000:250a:b0:439:be3b:ddb6 with SMTP id ffacd0b85a97d-439f8441487mr11829204f8f.59.1773317770061; Thu, 12 Mar 2026 05:16:10 -0700 (PDT) Received: from starbook.localdomain ([212.105.129.204]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439fe20c473sm8139874f8f.24.2026.03.12.05.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 05:16:09 -0700 (PDT) From: Sean Rhodes To: linux-mmc@vger.kernel.org, Ulf Hansson , Greg Kroah-Hartman Cc: Ricky Wu , Avri Altman , Binbin Zhou , Dan Carpenter , Jisheng Zhang , Nathan Chancellor , Arnd Bergmann , Huacai Chen , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2 RESEND 6/6] rtsx_usb: avoid USB I/O in runtime autosuspend Date: Thu, 12 Mar 2026 12:15:59 +0000 Message-ID: <20260312121559.19197-7-sean@starlabs.systems> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260312121559.19197-1-sean@starlabs.systems> References: <20260305194052.5120-1-sean@starlabs.systems> <20260312121559.19197-1-sean@starlabs.systems> 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 Content-Type: text/plain; charset="utf-8" The runtime autosuspend callback currently queries card status and clears OCP via USB register accesses. On some systems this can deadlock runtime PM and leave the USB device stuck in the "suspending" state. Avoid issuing USB commands from the runtime autosuspend callback. Instead, use the last cached card status (updated on successful status reads) and conservatively assume a card may be present until status is known. Signed-off-by: Sean Rhodes --- drivers/misc/cardreader/rtsx_usb.c | 11 +++++++---- include/linux/rtsx_usb.h | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/r= tsx_usb.c index 5d818b632788..63751797ee2b 100644 --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -336,6 +336,9 @@ int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 = *status) if (ret < 0) return ret; =20 + ucr->card_status_cache =3D *status; + ucr->card_status_valid =3D true; + return 0; } EXPORT_SYMBOL_GPL(rtsx_usb_get_card_status); @@ -743,16 +746,16 @@ static int rtsx_usb_suspend(struct usb_interface *int= f, pm_message_t message) =20 if (PMSG_IS_AUTO(message)) { if (mutex_trylock(&ucr->dev_mutex)) { - rtsx_usb_get_card_status(ucr, &val); + if (ucr->card_status_valid) + val =3D ucr->card_status_cache; + else + val =3D SD_CD | MS_CD; mutex_unlock(&ucr->dev_mutex); =20 /* Defer the autosuspend if card exists */ if (val & (SD_CD | MS_CD)) { device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child); return -EAGAIN; - } else { - /* if the card does not exists, clear OCP status */ - rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_CLEAR, MS_OCP_CLEAR); } } else { /* There is an ongoing operation*/ diff --git a/include/linux/rtsx_usb.h b/include/linux/rtsx_usb.h index 276b509c03e3..3188f6616729 100644 --- a/include/linux/rtsx_usb.h +++ b/include/linux/rtsx_usb.h @@ -59,6 +59,9 @@ struct rtsx_ucr { struct usb_interface *pusb_intf; struct usb_sg_request current_sg; =20 + u16 card_status_cache; + bool card_status_valid; + struct timer_list sg_timer; struct mutex dev_mutex; }; --=20 2.51.0