From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796140641; b=rE2MHaxgFJqt84yc1O+fZ5TGW5/d8FmgKnsGPnerykzW/4bh5GJS+m+wl/AhATOD6Vp5 YcepDqu04svlspEs2MFUps991kk525gRu7QdzBlw361LRCE81RkIXmHQRS0G0cWcNNaJi 9IIZxf37jMfHX0em7vyM9CgTcl1rX+9k2ieHNR+qkrx/HPE6pDfU8I36OsSEzmKvm3NmM x2U8ue/PtpieFHxeNyOzKmWSv4iDkFo3gq+zg9EGgpbcsvotWYZ1zoefxJZCavqPV4wrw 6le5AlztsElwMLYjSKULWXBW45egsL6v4Ibnet1fDGlvgCH4u5Lo96Pu3XA1KZJQlxg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796140641; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-Spam-Details-Enc: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=OZ8XNeug5aja6CKCBbQUT8VJWCRc3AJiWFAAhW5Qnxc=; b=phq0zyNKFawuoDQQ7Hm1toqwSFDTpLoeOOnfevf/hDBRUWRHYINFX4655fWZQcstysGM D7CtEYstFGTQbuBzbLI/e8OeEk5Aso1kIfpkSnOOT3gA2b3cd2pE53jWgGgrWIwMftpfb +yKuKNx3n17JzVoodoaLVemDPqAFnmwbqymQD9u9yOY+kF0bao5Ex/3i+udrYLwdnvFNm /QmVhurlLg6NWUxIawAYzNFLTdwakOioIeDFb6+e3OoUaj/CBVqmz7hKlwYI2VgvdIeHU cW2qnoRISNSrRB2VXLMdadirh8TckE0NJ+ivI5HoT80ICxgVxKg70Pf3YZWgjvgx8fQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=kytFELwC; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b="ixRRXx/8"; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 112B6606A322 for ; Tue, 1 Dec 2026 15:57:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 112B6606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=kytFELwC; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=ixRRXx/8 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F6xvX1079746 for ; Tue, 1 Dec 2026 15:57:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= OZ8XNeug5aja6CKCBbQUT8VJWCRc3AJiWFAAhW5Qnxc=; b=kytFELwCTj12D+IP rhmZNa2bsi9aCziQO3Nqn38yZch6uPcXphw9z5limQ9qmaQPVtWl58ByI1Lmo1KQ OP9R0U8aciedvCPnqsw79TaLqgZsO7jYj+OPl37C59FBX1buxBit7Wd6eenEQ6ZJ 3N47eQfg+vQvoP1LVwgOSKNXaauQYnWWdOLvPJLAtoyfBZmFZWmD/5DBU2XZrp8M 9NwIkuap3FnSrRi3R2HT2fSOr9VoiBawXsl/ZhgcRqA+A2nhZCOssTlN/rNZfGvH m4fLrjmSVpCHu0Z0V4HRzxFgeDrbqfYkZHUpbuF/MseBIECnCuO6QQj0nQqNYrXQ Hi2JsA== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9qth2msy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 15:57:19 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-33c35f5ca6cso13891805eec.1 for ; Tue, 01 Dec 2026 07:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796140639; x=1796745439; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OZ8XNeug5aja6CKCBbQUT8VJWCRc3AJiWFAAhW5Qnxc=; b=ixRRXx/830B03xLtjMKeJzWuRqn1ugorhsRV5C2dypELUqBzSJ0WU+CJeSFGpz7Up6 F4+D+MH++LwSkd7+pRI8ojYk73vH5BRknIlzNiHavMMJqqvZsrNXPFbe+aH/nkxLJaLK oLrpY5J0pWzul7idZdVNOcazHOwb5yDg2loVdsnNXoNVC1//+aVVEibCCJUZfGwxjqeU TMtOAAprveDEa0NglcgAACtT03fdxB9B+ZxwLp2xr1XuzNzzIeQM0Tk/q5UOmVY51CHJ lG5kfDQtGub+AFzL98RqaToRnB47u/H0uhDRzxSu2cbx0iCklD76l9NDEPWvIY7EvIdH zL/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796140639; x=1796745439; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OZ8XNeug5aja6CKCBbQUT8VJWCRc3AJiWFAAhW5Qnxc=; b=oBzQH1lhMgj5FvzIvQayGP94yn8QmzNuNxw51dkx8krvd2u7YkwFizzj0VzHyq0qym lFR5essN4MBOllLS8wypJqwJamXGmOm4L8s6+67qrCASNq0Spu5RQq0PwgfM/Pc12a5M Lw7nkJ+6EV5uDvTIHEswIMgKhGkZg0u5pQhY062Y9sQnsJSARNX8x9p8MamGQRmVBXB8 oHXGXDgyA/OfsDUQ4oiGTw9fDVkhEs0r98VQgupfoyCXojw2N2Qw9SwRK1++g4XrpgGr guQrwLw33AxcizdypSj3tQ1Lu5kwR4WjhoPNKt66q2SRorXGOI1Ynp6B/1aru3Dq9wjt liww== X-Forwarded-Encrypted: i=1; AL+hErETxCqaZnnXPGPTbXYD+YkuraAdGQISGK9MBD1DHlxKFkjQwh/mXQey5OIBXe5ioXeQu2pjF6gipX115Do=@vger.kernel.org X-Gm-Message-State: APuU4Z/u8Lb0lpWa/3SkPjuBHc+QsFkoay+HtbjU6FnrTRqP59/gfg/l RoRN8Jk5dE7ovptK7vtxm8wbNsS6p/GMrk+7TzLLinKUug/Zf2sO27DxdtKEDf246HhfxdSQIga 1rmloOzu8dXyA5UiCQjV3E30hX1zPcMVHyT+SqGsHYJt741ZyC6YmGyN4OmaFynfVcLs= X-Gm-Gg: AZFdTZfKN/dW063dIagTVwhqmaSooEUffC4Pc3uylBuTPFeifyaHPLH+6eBe7blZiqs r/kWjgxefaDPArGGPDh0WJ23X+RSijYZNC8G75zczv2JaVVryMwRbnSuVJfBSBPFrxa0wz4WGHZ BPmqhvTBZTcEKZSLl6GM1rusc1+QGMLeQmVWCkbgdEnVWmFHsY6czlXrWAPiWENMPlK+fAsvk0v 01mlAGepRFsW6eo5Ha5fkD8wvX42ccwx6r2Eg+ATPsa0Ibe/zhqZTW8KUCIsKjaBJfgCgqqpon5 s7OziaRoenLwoVLkd6wh5WUiDggyOtFGeYTIETRMgv1gmydYgFYmUG2qoi21nw90gfi1lEezqz1 WtRqizfijPQt+ZYwkenxzso4cf08vkFDBW2YZJkKf492+1e6dtJ7zF5+RaWgfeBq+0AJlkWNCXK Sy9g== X-Received: by 2002:a05:7301:241b:b0:386:b526:24d2 with SMTP id 5a478bee46e88-386b52636aemr28144143eec.41.1796140639229; Tue, 01 Dec 2026 07:57:19 -0800 (PST) X-Received: by 2002:a05:7301:241b:b0:386:b526:24d2 with SMTP id 5a478bee46e88-386b52636aemr28144100eec.41.1796140638491; Tue, 01 Dec 2026 07:57:18 -0800 (PST) Received: from [192.168.1.8] ([122.177.246.50]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38707b612cbsm45128901eec.4.2026.12.01.07.57.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 07:57:18 -0800 (PST) Message-ID: <7cf2d678-6785-49f4-85df-a3fcf4741405@oss.qualcomm.com> Date: Tue, 1 Dec 2026 21:27:10 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] scsi: ufs: core: Do not recover the link concurrently with a PM callback To: Peter Wang , Stanley Jhu , linux-scsi@vger.kernel.org, "Martin K. Petersen" Cc: "James E.J. Bottomley" , Bart Van Assche , Alim Akhtar , Bean Huo , Brian Kao , Can Guo , "Bao D. Nguyen" , Hongjie Fang , Praveen Talari , Hoyoung Seo , John Garry , Hyeoncheol Jeong , Jens Axboe , "Rafael J. Wysocki" , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261113111202.3551341-1-stanleyjhu@google.com> <20261113111202.3551341-3-stanleyjhu@google.com> <77e60c6e52705b3abd97d72ab3a766a5e6ba229e.camel@mediatek.com> Content-Language: en-US From: Manish Pandey In-Reply-To: <77e60c6e52705b3abd97d72ab3a766a5e6ba229e.camel@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: ZfkQGSOz4yyDiUA69QwZc1JwQN9FBJD5 X-Proofpoint-GUID: ZfkQGSOz4yyDiUA69QwZc1JwQN9FBJD5 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA2MyBTYWx0ZWRfX7oj0mjI108UV 4n9iAgk5PZMy5g3Ugg3u3K3tgpxg5qVieDewBWddPAtLCRxVlZFUaC+RJIQbtvzhUhvA7cSIKOy PSF23INEMKdZbaFAEWbjL3awzUF2U7I= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA2MyBTYWx0ZWRfX8Ln8otmhwCyB pn7M969qEfM27f8YSJ/4Mp/kNNmF2WKnxszSpsaxuyAINZXe0/NYlM3sHOnv09PlW0W4TuRcL9t PALqhC+54sjav7p8VCMYRDsQ5cYakdRrk6/KXKXlhwcDChDP3OMd/IerKwno5B0RllA3fKsvcNr 30dZg4he4UdfJot0T7FBpVqLlcu3fNxC9O9JJST166eX3T5+dWmWemeapaw3CihVcIxQOqju99t yPah4oJXq1Wj0KzZPST+sRL9FhXh6DJ/YW4v3SBtLWxN94uyznsnmzMlN5xPex3PFfAfI7nbWI4 BtKoJsxg5QvgKyPqHT76DXLQ2TX5m9+qWlls0TNWrW/dTFdlV3k83HNj8orxeP2LH3s6F/gkaYD +utuL7/+j1laahQTwO8RGnqsIPqezzzwkNtrTrFx8AZjAyMHH4fyZO6Wz4bOBcuTQGBM1ZMI0n0 fzoLbuTsIhV9LbwDNfQ== X-Authority-Analysis: v=2.4 cv=MLn1C8Zl c=1 sm=1 tr=0 ts=6b0eee5f cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=k4niG6xp1VCxvVHM/Mvj1Q==:17 a=hN65tFJlujthaZ5p:21 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=1XWaLZrsAAAA:8 a=CmJMYcYKsVcbLq2nu0IA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 suspectscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010063 Hi Stanley, This fix is helping as far as it goes with ufshcd_err_handler Vs __ufshcd_wl_resume but there is a second, structurally identical bypass that the commit didn't touch, in ufshcd_eh_host_reset_handler() (the SCSI .eh_host_reset_handler callback), static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd) { ... if (hba->pm_op_in_progress) { if (ufshcd_link_recovery(hba)) err = FAILED; return err; } ... } This has exactly the same shape: it calls ufshcd_link_recovery(hba) directly, without taking hba->host_sem and without going through ufshcd_err_handling_prepare() / ufshcd_rpm_get_sync(). Also i would like to know what is the plan for Stable kernels Like kernel 6.18 ? As same issue is observed there also. Thanks Manish On 16-11-2026 18:23, Peter Wang wrote: > On Fri, 2026-11-13 at 19:12 +0800, Stanley Jhu wrote: >> From: Brian Kao >> >> ufshcd_set_dev_pwr_mode() now recovers the link after a START STOP >> UNIT timeout. ufshcd_err_handler() must not recover the link while a >> PM callback runs. Its pm_op_in_progress branch still does so when a >> fatal UIC error arrives during that recovery. >> > > Hi Stanley, > > Could we just add a check to prevent the concurrency issue > in ufshcd_link_recovery? > > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -1,10 +1,16 @@ > int ufshcd_link_recovery(struct ufs_hba *hba) > { > int ret; > unsigned long flags; > > spin_lock_irqsave(hba->host->host_lock, flags); > + if (ufshcd_eh_in_progress(hba)) { > + spin_unlock_irqrestore(hba->host->host_lock, flags); > + dev_info(hba->dev, "%s: link recovery already in > progress, skipping\n", > + __func__); > + return -EBUSY; > + } > hba->ufshcd_state = UFSHCD_STATE_RESET; > ufshcd_set_eh_in_progress(hba); > spin_unlock_irqrestore(hba->host->host_lock, flags); > > > >> @@ -7074,23 +7074,6 @@ static void ufshcd_err_handler(struct >> work_struct *work) >>   hba->saved_uic_err, hba->force_reset, >>   ufshcd_is_link_broken(hba) ? "; link is broken" : >> ""); >> >> - if (hba->ufs_device_wlun) { >> - /* >> - * Use ufshcd_rpm_get_noresume() here to safely >> perform link >> - * recovery even if an error occurs during runtime >> suspend or >> - * runtime resume. This avoids potential deadlocks >> that could >> - * happen if we tried to resume the device while a >> PM operation >> - * is already in progress. >> - */ >> - ufshcd_rpm_get_noresume(hba); >> - if (hba->pm_op_in_progress) { >> - ufshcd_link_recovery(hba); >> - ufshcd_rpm_put(hba); >> - return; >> - } >> - ufshcd_rpm_put(hba); >> - } >> - >> > > This section of code is used when a UIC error occurs > before SSU is sent. > > Because the error handler uses link recovery, it will > recover from the error quickly rather than waiting for > the 10s SSU timeout. The end user will feel lag because > the I/O cannot resume for 10s. > > Thanks > Peter