From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 886553126B9 for ; Thu, 19 Mar 2026 04:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773894986; cv=none; b=fKl1ZedSgoLH2+yiwxTEoNbsnhy0/tG8zqEjbdgOVWMv0fxD7WLBlTcpBxY+CKNXA8Gq0SmW334bkcEyknQ7NG1EA5Du87yqfGihYINrzYAc6x6epDquLQOZGU7dsbAX+Q6ApFF93a9OUOHW4Knb22OVFMJYdASqUCfYBAeXNho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773894986; c=relaxed/simple; bh=3cvQrCwXJOWrGoiE6LKWnIc8rg0AExKcczPTqdkd/dM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MJ0PwhwWp7J0a9LMmilYiS0dFSG2OuN4mGr1I2D3EzYUaDBzz74bZkDsrwbZDtQ6XniyxOJH697IDDZRvd5bUIFWcF3NtOdBFweyrqxpzNL6xDe0Xbu6lrRB8cHGs+SURdRkHdfZ3XXlisOdOLcHyUwqxGbjwwPPSO//CU6RKo8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=IKgxTF7F; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=WoWbZpQ+; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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.b="IKgxTF7F"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="WoWbZpQ+" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62J0mNpZ914295 for ; Thu, 19 Mar 2026 04:36:25 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= mt7cpSYKm2/GL7spGWdPXjx+QWPZ+qBKA32f8+lpf7g=; b=IKgxTF7FZyYI6X7u rMqD494aRMfmPb8juLUL0weIKMuKQ0M/QU0ROso37FwrheQCvq6FuJfk4VtbITlC OZoZSr161VuU+5tgs+IAq8X0ytshMKARj7mcUSWJrO0qYMdfQODdg5pRQ3GmKFjZ +Ecsrc2/lIYD6hZ6A2ylBEFhzs2EauwZb/E24FRYl2/J/obemAOWPG9lMhZ/pzBc U++Hk3gwqJgoFDoInwi7/2DmTLocDlXu2t6YKU5CsZn5D0FWraDrCNPAZKeQd9QQ l7sMWWVSmADYoeFF21SuGVzE/7X7r1N0oqX807SDWmpp48In34R7VOSSOxc/ikj6 1HtL7A== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cytxyu35y-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 19 Mar 2026 04:36:24 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c737b6686ddso388230a12.3 for ; Wed, 18 Mar 2026 21:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773894984; x=1774499784; darn=vger.kernel.org; h=content-transfer-encoding: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; bh=mt7cpSYKm2/GL7spGWdPXjx+QWPZ+qBKA32f8+lpf7g=; b=WoWbZpQ+JmHud9ZiGoQv5liHV2ka0ZWua0avUO0x8eUDkhYjzFwdie8zeC96lhCWyc PGwaMDQNxHXdmXhFD3HltazI77k5JqBTBqlMeihs4ndDsR14eSZt+of1UjuyT5udH0/8 MCMXFcG8SMg27lepLU+eqjLTC3oVvQHZLDIB65t40AYmEegwSBjTNIXmm/v+694dZ6DQ o7hk9yDCbuAhWBEZeqrxumWOmHjly10TZb4Gyc5zHsjspCgKrzlu0PnoupSMhREk86JA Bv5xn6VNYFVqhT0G98fPUKkms4tNVVndtv+KMSJ7kysyv77i6pqfMvhb4nV3vVBWqidL FwAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773894984; x=1774499784; h=content-transfer-encoding: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; bh=mt7cpSYKm2/GL7spGWdPXjx+QWPZ+qBKA32f8+lpf7g=; b=B7LTsdgXlDsAU8GkFthhDv4L7rkk9d2G7lzQnMWuHQbIHIxDtD5bpN1/RaKxM0gKh9 FM2zauJHHh/Lk4BAuR2jxSwpXuuAbbw3E0bAm270S/G3ndcCFrOs074N3gn9fNucBZd+ DFDKHEwpKxu9CoRkaULDde6DW6qWibGIhnM9kMenEk0f8gnTVmKaO5rYD4JIKOiBX8f1 Z1LeikkYoEpgTDXV3rIyx86r24q4M/sdVns5Ua/LnDWrlQf+uoIYze48VondyHnx1ObN 57FamoHeak7JMrD+WTn5Wk2J26ZZpceAyq17MWVNloX+TN96seTZruX//WgeVGJcoGDf SDLA== X-Forwarded-Encrypted: i=1; AJvYcCXUyA/KsFB3J+UZGL1zz6MXZVwXlC2F05AA7ABcFz92PwB6GCszCAInDM30iLQouhzFcx42LpctmfC658Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwZLbHL7JITJ0BUh71LzTcFutxm+IjSjzsH4GhJEufqHZ6LLBej Svisj1uv4LmQcAFiuCKjIPZWpXtTuFQ1hv9BpWiRQHKdZ922Qh6gFrkjE/+C0habduec64by25L mUrkKHI2pQyutarKdMfhBNWunDOPQrX2rrkm4BIYUVpG5SMAuwiE7R+swCPTZUfOvjAE= X-Gm-Gg: ATEYQzx/4D82paWb+Kp0TxMIUI7U4fqhRfgcaj1Wa72dQUMeVhJ8h7j8fYjV5A2XfQf 7UbTqV9eZwu5mRbMoePnngmvD2GvWloamdor+smxAMvNwy0eRL3Ycg0D7KwnSqZxX3X/H1pJtUn rwl3G5AYalHBHkoDm4mjJIGP1p1NjvSiQPek5HL1qvtheBS7RIfAvwI1J4yWiBAjzFBSx3aJu7C LHQvo42tRBCJSRfc/XZ0yZMZ2GDxjdyepxxNvva9H0oQ2trNNCRaIkUS956F/Yw4bwWqnlDsglJ P4nQTJaQiq3FfJ6+KjriDTyA5C6orkCaSxzFQz5Ouz/h5vA5AlxHUK1RfoC4VGyiilN8nrbZM5P fWXuo5MKuNOZ5FHTGlVLa0mz+uvc0n93CRNlgUFJl7edCrMyTOMsD2eXTriwqR+SjK0CVVKvNDR ZxrwjITzpIw/psQOps X-Received: by 2002:a17:902:d54b:b0:2ae:c7dc:95a4 with SMTP id d9443c01a7336-2b06e34e487mr59339845ad.20.1773894983816; Wed, 18 Mar 2026 21:36:23 -0700 (PDT) X-Received: by 2002:a17:902:d54b:b0:2ae:c7dc:95a4 with SMTP id d9443c01a7336-2b06e34e487mr59339645ad.20.1773894983347; Wed, 18 Mar 2026 21:36:23 -0700 (PDT) Received: from [10.133.33.168] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b06e4199d4sm46413095ad.9.2026.03.18.21.36.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Mar 2026 21:36:22 -0700 (PDT) Message-ID: <9bdc6b6d-ddf0-47af-b1ed-8d1e75bf30c2@oss.qualcomm.com> Date: Thu, 19 Mar 2026 12:36:15 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 5/7] remoteproc: core: set recovery_disabled when doing rproc_add() To: Dmitry Baryshkov , Bartosz Golaszewski Cc: aiqun.yu@oss.qualcomm.com, tingwei.zhang@oss.qualcomm.com, trilok.soni@oss.qualcomm.com, yijie.yang@oss.qualcomm.com, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , Luca Weiss , Konrad Dybcio References: <20260310-knp-soccp-v4-0-0a91575e0e7e@oss.qualcomm.com> <20260310-knp-soccp-v4-5-0a91575e0e7e@oss.qualcomm.com> Content-Language: en-US From: Jingyi Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: cFWXDTfr3rHTq5XqH5YLD5Cnzplp86Db X-Authority-Analysis: v=2.4 cv=FKAWBuos c=1 sm=1 tr=0 ts=69bb7d48 cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=UbLAXycr_9YQHWOW9u0A:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzE5MDAzMyBTYWx0ZWRfX+G9tdAdC+ERn 06dGhS3KC/yytWR/rlXlIuk8NOwDdFWDTPqPc4fmRFStrFX53qrwHee0ZFewA3bLyL7qHy3chrH NzEYH5tRGGhUKQ1t3N0eD7oRwmA0g1OiK+iiji9yxIbaVCq1IlBQbcUAnxfFzfTUcf1wbIemjWW k14nmqwf31No2jyksRH37xhs7hiHkheDnWkYoStpdnj5/HMAcZgmBO/eWWEpeb8kQ9s1KtCdCGI G1LdR2UAB2PGRk24W0LqN7eGnBZSTxky8OTlis58Dg15uCN5zmCt09xMz0BW+an49M/qP7RFPZl 54ZBRvyaJCzUPxpuaMjyQyEFs8B1i4LK6NzqbDgOH0bAKWQTI6YGXEWU0JJEVrBV62wQOFUQAtE oe8yyfXrcVk3GMCQW38Z6rqtYzq/PEGSVZHUYw1MaP83Tdbk2xE7FASUDJo7hcvOPpi1YIgkpgE FARXI9w/xJpMxfsgl2g== X-Proofpoint-ORIG-GUID: cFWXDTfr3rHTq5XqH5YLD5Cnzplp86Db X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-18_02,2026-03-17_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603190033 On 3/13/2026 10:37 AM, Dmitry Baryshkov wrote: > On Wed, Mar 11, 2026 at 01:39:50AM -0700, Bartosz Golaszewski wrote: >> On Wed, 11 Mar 2026 03:11:42 +0100, Dmitry Baryshkov >> said: >>> On Tue, Mar 10, 2026 at 06:50:30AM -0700, Bartosz Golaszewski wrote: >>>> >>>> Ideally things like this would be passed to the rproc core in some kind of a >>>> config structure and only set when registration succeeds. This looks to me >>>> like papering over the real issue and I think it's still racy as there's no >>>> true synchronization. >>>> >>>> Wouldn't it be better to take rproc->lock for the entire duration of >>>> rproc_add()? It's already initialized in rproc_alloc(). >>> >>> It would still be racy as rproc_trigger_recovery() is called outside of >>> the lock. Instead the error cleanup path (and BTW, rproc_del() path too) >>> must explicitly call cancel_work_sync() on the crash_handler work (and >>> any other work items that can be scheduled). >>> >> >> This looks weird TBH. For example: rproc_crash_handler_work() takes the lock, >> but releases it right before calling inspecting rproc->recovery_disabled and >> calling rproc_trigger_recovery(). It looks wrong, I think it should keep the >> lock and rptoc_trigger_recovery() should enforce it being taken before the >> call. > > Yes. Nevertheless the driver should cancel the work too. > Hi Dmitry & Bartosz, rproc_crash_handler_work() may call rproc_trigger_recovery() and rproc_add() may call rproc_boot(), both the function have already hold the lock. And the lock cannot protect resources like glink_subdev in the patch. And there is a possible case for cancel_work, rproc_add tear down call cancel work and wait for the work finished, the reboot run successfully, and the tear down continued and the resources all released, including sysfs and glink_subdev. Indeed recovery_disabled is kind of hacky. The root cause for this issue is that for remoteproc with RPROC_OFFLINE state, the rproc_start will be called asynchronously, but for the remoteproc with RPROC_DETACHED, the attach function is called directly, the failure in this path will cause the rproc_add() fail and the resource release. I think the current patch can be dropped, we are thinking about make rproc_attach called asynchronously to avoid this race. Thanks, Jingyi