From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221535; b=eM2eRJXkPZJ4ukamr3YG8T/R40xrRzofphx0+DbV2FeWtbF+A0ygRH0DWReTmyWKDlIh GNFiIOfpuiI7trhOD7ZGkiyg/PQTSQGWjotfGj7USYnyOqwyC3pTKgAySnIWy73/n1dtV Y5c29OBbS4biS/vBreII/jgliJe+mEHLN2pGZBPCbAccLCQ66cHYvyrJEp2dnNRPnigvD 3CXVbDBefjVzungy2VhcsPDnKkqdGb9ZYdlFeKYPcnsXFLdpGfJvYba3LG7mL1H/hdKbq X3sipdFHMJ7eAsXjmSFns21OiCBYbrdHtxipClR+cV8cQUCVq3514MOE9ndTEvuL2Zw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221535; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=sLuLbIfbaMkfyt6Sdteq9zh00WmuHoOIDUuz+MqG1Rc=; b=cuhYTyMWEyMPPp5QrkCDyzrPuyVMj5KRQi6ptpwYOWUNYMKwfA9imFwpR1Y+1yUtH2vt s9U4GpBqzkWqMQMFGUZe2shGhMHnNb8UnVCsDUolew5Fu53m2e1jDoPEgF+0GVnx65RE+ Ukz/73Au9YNmwCQrsWKbYkafrYjwhHcc+r+emKz1VYWyul1O51OlfpxJOLvZELX9f1VLU 4gAgoM3qGjpu5ftiuts/12fGZtxAsk1TRjKhaBZ+pr1Ib2qVNKZ5gl/bEzCZSKjQm51kC fW+muZlSF8yBpLI6q5M4XowBCNqZfO30dAcIpCk2oNCXwOLrXMrctA6IiAvKbzSSBHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LmWdcV3t; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C4AC606A323 for ; Wed, 2 Dec 2026 14:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LmWdcV3t Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56581F00925; Wed, 2 Dec 2026 14:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221535; bh=sLuLbIfbaMkfyt6Sdteq9zh00WmuHoOIDUuz+MqG1Rc=; h=Subject:To:Cc:From:Date; b=LmWdcV3trVtcspqdyf29XiWA3D56Tb4lcyey/B/qegOW16JONuUVIYA3amayDMPlA uYEgqe0bUSfaQcHTq7izyM19CkB/LXXICQj3HZbtYvrpjftu2wfKdxfNpxnJLwxKQy 67bR3B3aX+fyk1tLqmP5P2KHIYe1Xdwm2dUbimsw= Subject: FAILED: patch "[PATCH] scsi: ufs: sysfs: Propagate runtime PM resume errors" failed to apply to 6.6-stable tree To: stanleyjhu@google.com,bvanassche@acm.org,mkp@kernel.org,peter.wang@mediatek.com Cc: From: Date: Wed, 02 Dec 2026 14:54:51 +0100 Message-ID: <2026120251-removed-reach-5694@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 93891d1c486efcef2267c32e6e73ca2fd243704e # git commit -s git send-email --to '' --in-reply-to '2026120251-removed-reach-5694@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 93891d1c486efcef2267c32e6e73ca2fd243704e Mon Sep 17 00:00:00 2001 From: Stanley Jhu Date: Thu, 29 Oct 2026 15:08:38 +0800 Subject: [PATCH] scsi: ufs: sysfs: Propagate runtime PM resume errors All 14 ufshcd_rpm_get_sync() callers in ufs-sysfs.c resume the UFS device W-LUN and ignore the return value. For example, for a UFS descriptor read: 1. The W-LUN is runtime suspended. 2. User space reads a UFS descriptor attribute in sysfs. 3. ufs_sysfs_read_desc_param() calls ufshcd_rpm_get_sync(). 4. The W-LUN runtime resume fails and the W-LUN stays suspended. 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 6. ufs_sysfs_read_desc_param() sends a query UPIU while the W-LUN is still suspended. The other sysfs callers follow the same sequence. They send other query UPIUs, or read a host register in ufshcd_read_hci_reg(). Switch all 14 sysfs callers to ufshcd_rpm_resume_and_get() and return the error after releasing any held buffer and hba->host_sem. Fixes: aef80fd1da32 ("scsi: ufs: sysfs: Resume the proper SCSI device") Fixes: b9d104465a6c ("scsi: ufs: Prepare to add HCI capabilities sysfs") Fixes: 600edc6620a4 ("scsi: ufs: sysfs: Make max_number_of_rtt read-write") Fixes: 6c4148ce7cc1 ("scsi: ufs: wb: Add explicit flush sysfs attribute") Fixes: 500d4b742e0c ("scsi: ufs: core: Add WB buffer resize support") Fixes: ae7795a8c258 ("scsi: ufs: core: Add HID support") Fixes: 1fd2e77b8897 ("scsi: ufs: core: Add device level exception support") Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper" Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-4-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index cf49ad0258e1..19b62cf52410 100644 --- a/drivers/ufs/core/ufs-sysfs.c +++ b/drivers/ufs/core/ufs-sysfs.c @@ -250,13 +250,19 @@ EXPORT_SYMBOL_GPL(ufshcd_us_to_ahit); static int ufshcd_read_hci_reg(struct ufs_hba *hba, u32 *val, unsigned int reg) { + int ret; + down(&hba->host_sem); if (!ufshcd_is_user_access_allowed(hba)) { up(&hba->host_sem); return -EBUSY; } - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) { + up(&hba->host_sem); + return ret; + } ufshcd_hold(hba); *val = ufshcd_readl(hba, reg); ufshcd_release(hba); @@ -350,7 +356,9 @@ static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr, goto out; } - ufshcd_rpm_get_sync(hba); + res = ufshcd_rpm_resume_and_get(hba); + if (res) + goto out; res = ufshcd_wb_toggle(hba, wb_enable); ufshcd_rpm_put_sync(hba); out: @@ -421,7 +429,9 @@ static ssize_t enable_wb_buf_flush_store(struct device *dev, goto out; } - ufshcd_rpm_get_sync(hba); + res = ufshcd_rpm_resume_and_get(hba); + if (res) + goto out; res = ufshcd_wb_toggle_buf_flush(hba, enable_wb_buf_flush); ufshcd_rpm_put_sync(hba); @@ -490,7 +500,9 @@ static ssize_t wb_resize_enable_store(struct device *dev, goto out; } - ufshcd_rpm_get_sync(hba); + res = ufshcd_rpm_resume_and_get(hba); + if (res) + goto out; res = ufshcd_wb_set_resize_en(hba, mode); ufshcd_rpm_put_sync(hba); @@ -598,7 +610,9 @@ static ssize_t device_lvl_exception_id_show(struct device *dev, if (hba->dev_info.wspecversion < 0x410) return -EOPNOTSUPP; - ufshcd_rpm_get_sync(hba); + err = ufshcd_rpm_resume_and_get(hba); + if (err) + return err; err = ufshcd_query_attr_qword(hba, UPIU_QUERY_OPCODE_READ_ATTR, QUERY_ATTR_IDN_DEV_LVL_EXCEPTION_ID, 0, 0, &exception_id); @@ -1101,7 +1115,9 @@ static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba, goto out; } - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) + goto out; ret = ufshcd_read_desc_param(hba, desc_id, desc_index, param_offset, desc_buf, param_size); ufshcd_rpm_put_sync(hba); @@ -1482,7 +1498,12 @@ static ssize_t _name##_show(struct device *dev, \ up(&hba->host_sem); \ return -ENOMEM; \ } \ - ufshcd_rpm_get_sync(hba); \ + ret = ufshcd_rpm_resume_and_get(hba); \ + if (ret) { \ + kfree(desc_buf); \ + up(&hba->host_sem); \ + return ret; \ + } \ ret = ufshcd_query_descriptor_retry(hba, \ UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE, \ 0, 0, desc_buf, &desc_len); \ @@ -1548,7 +1569,9 @@ static ssize_t _name##_show(struct device *dev, \ } \ if (ufshcd_is_wb_flags(QUERY_FLAG_IDN##_uname)) \ index = ufshcd_wb_get_query_index(hba); \ - ufshcd_rpm_get_sync(hba); \ + ret = ufshcd_rpm_resume_and_get(hba); \ + if (ret) \ + goto out; \ ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, \ QUERY_FLAG_IDN##_uname, index, &flag); \ ufshcd_rpm_put_sync(hba); \ @@ -1608,7 +1631,9 @@ static ssize_t max_number_of_rtt_show(struct device *dev, return -EBUSY; } - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) + goto out; ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, QUERY_ATTR_IDN_MAX_NUM_OF_RTT, 0, 0, &rtt); ufshcd_rpm_put_sync(hba); @@ -1648,7 +1673,9 @@ static ssize_t max_number_of_rtt_store(struct device *dev, goto out; } - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) + goto out; memflags = memalloc_noio_save(); shost_for_each_device(sdev, hba->host) @@ -1700,7 +1727,11 @@ static int wb_read_resize_attrs(struct ufs_hba *hba, } index = ufshcd_wb_get_query_index(hba); - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) { + up(&hba->host_sem); + return ret; + } ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, idn, index, 0, attr_val); ufshcd_rpm_put_sync(hba); @@ -1760,7 +1791,9 @@ static ssize_t _name##_show(struct device *dev, \ } \ if (ufshcd_is_wb_attrs(QUERY_ATTR_IDN##_uname)) \ index = ufshcd_wb_get_query_index(hba); \ - ufshcd_rpm_get_sync(hba); \ + ret = ufshcd_rpm_resume_and_get(hba); \ + if (ret) \ + goto out; \ if (ufshcd_is_qword_attr(QUERY_ATTR_IDN##_uname)) \ ret = ufshcd_query_attr_qword(hba, \ UPIU_QUERY_OPCODE_READ_ATTR, \ @@ -1848,7 +1881,11 @@ static int hid_query_attr(struct ufs_hba *hba, enum query_opcode opcode, return -EBUSY; } - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) { + up(&hba->host_sem); + return ret; + } ret = ufshcd_query_attr(hba, opcode, idn, 0, 0, attr_val); ufshcd_rpm_put_sync(hba); @@ -2121,7 +2158,9 @@ static ssize_t dyn_cap_needed_attribute_show(struct device *dev, goto out; } - ufshcd_rpm_get_sync(hba); + ret = ufshcd_rpm_resume_and_get(hba); + if (ret) + goto out; ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value); ufshcd_rpm_put_sync(hba);