From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 BBDD42D6E64 for ; Thu, 28 May 2026 03:31:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779939086; cv=none; b=ggtKFpsprwoxIXM6ZcPIZfi0wGCZ9tWCDSnKJe3mTg1u5FluGnghe9lOb5V7Kgb9dYXZOpMmv0Lu5BmYDW8N0qxJ6mN85DYPwjTJifPUB//wdSc1Ec3grUWaQjMP9Xitq+KxV6rRom3GxhXWrXINfarO4cmsbgAJynYjy1US9Hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779939086; c=relaxed/simple; bh=du2G9E0eYqG3UwmHKht+kFdDKGQAkHnhyxpzU8Jme40=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YMg7myD4bT66wcw+4EIb+Nzk5/l5OnqgmCoz3tqNimwF2dEigL7nn+ZvwCZ9fbfqCZ/ZdHEU+k59WsAp+Zga7Y3Lwk2hctfKipoRHyxsIPadp1pudLOZLl6ZpC++nBrt69J+Hmksjmprt1u2YTUohMoz+MAiTF+V3N6ryH/iLqs= 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=BARKo82Y; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=A8DpJtb7; arc=none smtp.client-ip=205.220.180.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="BARKo82Y"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="A8DpJtb7" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64RKlCPP1225112 for ; Thu, 28 May 2026 03:31:23 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= obRGzyMev3GPdcUIXXbGVZQIyEJ+0cKopg6lhDeWLhY=; b=BARKo82YVAz1/2Pf iP33St2iHDusefBDwPI/Ib5kGuxHg1UzrQfu3m395bj5WZfERCpO/HK0A8ToT+re kS5b4DWPPSOkJPffttY+8Mfluc+gezUuII6izutjYKuyO5OYTLp+LFL1Tvl3mS4d k+OcvzePvqb+aynMzoWlY4yBrue5sQEPdlxvSAV2flNQideFbxktB7BwFw6vDu+p XzL5wUQk7FNt1KUH5V7AHsKfRj6rXqK3dJl+72b0Ie4Eng0Doaxk9xbM0lyJzeSd JAritaE+yfiJTnszFxFP9ppJ5RGjC2hgqkVsvSjy37ftZaYWmD51pGrpYA3FFFqw NPYyfw== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ee7y1s6hp-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2026 03:31:23 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2bf0607b5f5so4590485ad.0 for ; Wed, 27 May 2026 20:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779939082; x=1780543882; 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=obRGzyMev3GPdcUIXXbGVZQIyEJ+0cKopg6lhDeWLhY=; b=A8DpJtb7gwl9gbxFdOUvQEfxpS45Lj2bsbgDOPW59upRM+zKRcTV1Wtauy/L4MyiNL b9mnP0iFbmAnxS88ZaAmeD3q8tcI2JmFgAtQUs2m1PJyi7ayTZ5kHCFH5LDhX2N5OkkD 0+5QZjN8y16LERqmcyEvUvg2RJMSt/hQGzsSQPQcoySnBWGx5qaPngUE75aJNPRLzWlD /T7oeeZOYkGfGVy7CXONZSjd650SrzbNmM9dAUcrNhX6ZCdWVqZftxIqMlm3of+d+/+n PpYJMjhAU/FsZJWP4aNk0haHSRYV+VFpLpDXAjup59GgY3sqWTB5i3HL4kuU7/+u32qN RoWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779939082; x=1780543882; 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=obRGzyMev3GPdcUIXXbGVZQIyEJ+0cKopg6lhDeWLhY=; b=Wt1jI0Qsn5oC6J6EMW2+VsvvfLGdEM02ERkHfgQCEWjSEkrzUQudfGQk+Yx8uOrIZD yjCyTY9q/kxot/JK81yOYaucyH15LYAcLCO7XNa2NckGOvXNJ7ZhPuUmf08aFyqRgb/W 24JPdcXvsJF9vBnLsvGE7QaEkiQ5+H2Gd2AyhFhw/LUqah6cS82GFlceQLibRNFGMB31 X8O3Oh4GRuRxyjegh9eIzyRcZFJTL5uWi2Z5EFFonhUbe8RYzaw5HtaDYYTpJ3zEL5gt fJWeKseNY3uCpMraJrBy6RsEeKGPpHPa8wZZpN1BJ2yn6bcGPvHXQprtu2kxgNgTn6GK eljA== X-Forwarded-Encrypted: i=1; AFNElJ/U1DFG0TOEj3leOtb8KOWkS53X38wDvv52NkmSGv/OEDvI0TXDD/zjNPh0FV4ZoNhxjv+mCsZ9KKasT3I=@vger.kernel.org X-Gm-Message-State: AOJu0YzMfII13HXt21wvy4LwRjcmb5AGu7ruh/9nYKmg78kduWQjOqFs cgoEgFfkyZ4tyEfj+++V2wrkYnYMUwTGKSiSIeyTX3uBZJkIJJyGqRLVks+WLAvYz7izTw/9Qzd dVxXJIDshyGfLnHKSdOkZHDKMpU6qAwq17OeHkeAdj+vjgqFB80NWj2AvNiPkmXXY3+g= X-Gm-Gg: Acq92OGoJ5Nuw0hJVe2sZnOalbwYNs1pMhHDh9ZqHcLUmxXWIPnrzeZQ6a2Vnn8QMvV 5QsLxtEbnf2sBFbmpMdzdxg2pR8+EFNQnAEslM3ZrtQC8NfOPFvSnB0lkwSvwHDFAhjIveWWkY2 5QYtXJgSWduO15xBRDH39VN+3jBaPwZfkXPcOD3gwsNJTwgl4lRoMj7JBriSUWktp1f++r/8/jd qd7QJjbsYfI0SetNjT79Vfd4HnBSvQE8C9BGHw5vrKj0bZoCHsdLe/nHtB0MYm2EX1Ki2snoAzi p12NT8cFfmbp1nUDaE1g9cWiJSeO57n+aI3wn+HsvoN+f6N+emrHdU2QTbVIZNT7TkWcGUZWQWN Bbu9aJh/YeB3g8RB2vkRmB2VxuPOrbkUJztJEb9UOnCiHzTQIjBfPtK+KD822b1L2Q+JbCl1bqm TGdYdBJ/OUrwnPEXhZRurvBKzi99w= X-Received: by 2002:a17:902:e885:b0:2bf:26d:3f42 with SMTP id d9443c01a7336-2bf026d491emr19844355ad.18.1779939082505; Wed, 27 May 2026 20:31:22 -0700 (PDT) X-Received: by 2002:a17:902:e885:b0:2bf:26d:3f42 with SMTP id d9443c01a7336-2bf026d491emr19843835ad.18.1779939081994; Wed, 27 May 2026 20:31:21 -0700 (PDT) Received: from [10.133.33.221] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bf0825ee37sm6238045ad.41.2026.05.27.20.31.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 May 2026 20:31:21 -0700 (PDT) Message-ID: Date: Thu, 28 May 2026 11:31:17 +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 v2 2/3] remoteproc: core: Check subdev start status in rproc_stop() To: Stephan Gerhold Cc: Bjorn Andersson , Mathieu Poirier , aiqun.yu@oss.qualcomm.com, tingwei.zhang@oss.qualcomm.com, trilok.soni@oss.qualcomm.com, yijie.yang@oss.qualcomm.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260519-rproc-attach-issue-v2-0-caa1eaf75081@oss.qualcomm.com> <20260519-rproc-attach-issue-v2-2-caa1eaf75081@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-Authority-Analysis: v=2.4 cv=DsNmPm/+ c=1 sm=1 tr=0 ts=6a17b70b cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=tv7k-BTZGpM39zBJeD4A:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-ORIG-GUID: hMmdDJBsKMECtkE45YonAfb6pG_1-5HL X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI4MDAzMSBTYWx0ZWRfXyGJ2t6Ji2g/e 3jb5uqx04y1Iy+eqmtWFYWIAaTP5lTZmHqeN7k/fYCtsEXO0PXc/kwQUDLeUbNblJrOgTyREGC3 2RRv3po4ZAUYc+GKKC5njxnlr+n1WFPvD75ryo1pf3kFYEj6MP4fqIYecpjZIlz/cT8zZk/vEhI 2jY404Nlk9K2FVq4LSsNvUGiRDfb8UaoZfTneLMC+c+7q2/6GX55avK6jCN8h/lQnTZ+VsrucOI hF4ScMZRtxxTiXXrM7iFrbAs+ozp1QX3n+cWnXERoO/ZB7nT+moLZ/am9Yu+Mb2lzjESZp9xTzK 2mwRmiSibVPNr48AbJ7pjoIExUeLH3VwDNquyDBn8Q5rCj039rSDR2DiMNuon1m9E6R7qc0DkpR 9KyJ7dUYx4ohdqaMALHomTbL5iQFkL+ynMxwKK7oeGCjgbJlTsKscrIPcCLoHrMFMjl9Jyib1Vo CBF6Bhy2Jj2KAw6YMEw== X-Proofpoint-GUID: hMmdDJBsKMECtkE45YonAfb6pG_1-5HL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-05-28_01,2026-05-26_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2605280031 On 5/22/2026 8:14 PM, Stephan Gerhold wrote: > On Tue, May 19, 2026 at 12:20:03AM -0700, Jingyi Wang wrote: >> For rproc that doing attach, rproc_start_subdevices() is called only when >> attach successfully. If rproc_report_crash() is called in the attach >> function, rproc_boot_recovery()->rproc_stop()->rproc_stop_subdevices()-> >> glink_subdev_stop() could be called and cause NULL pointer dereference: >> >> Unable to handle kernel NULL pointer dereference at virtual address 0000000000000300 >> Mem abort info: >> ... >> pc : qcom_glink_smem_unregister+0x14/0x48 [qcom_glink_smem] >> lr : glink_subdev_stop+0x1c/0x30 [qcom_common] >> ... >> Call trace: >> qcom_glink_smem_unregister+0x14/0x48 [qcom_glink_smem] (P) >> glink_subdev_stop+0x1c/0x30 [qcom_common] >> rproc_stop+0x58/0x17c >> rproc_trigger_recovery+0xb0/0x150 >> rproc_crash_handler_work+0xa4/0xc4 >> process_scheduled_works+0x18c/0x2d8 >> worker_thread+0x144/0x280 >> kthread+0x124/0x138 >> ret_from_fork+0x10/0x20 >> Code: a9be7bfd 910003fd a90153f3 aa0003f3 (b9430000) >> ---[ end trace 0000000000000000 ]--- >> >> Introduce "subdevs_started" flag to indicate rproc_start_subdevices() has >> been called successfully. Ensure subdevices are only stopped if they have >> been started. >> >> Signed-off-by: Jingyi Wang >> --- >> drivers/remoteproc/remoteproc_core.c | 4 +++- >> include/linux/remoteproc.h | 2 ++ >> 2 files changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c >> index f02db1113fae..6e23cb11e515 100644 >> --- a/drivers/remoteproc/remoteproc_core.c >> +++ b/drivers/remoteproc/remoteproc_core.c >> @@ -1308,6 +1308,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) >> goto stop_rproc; >> } >> >> + rproc->subdevs_started = true; >> rproc->state = RPROC_RUNNING; >> >> dev_info(dev, "remote processor %s is now up\n", rproc->name); >> @@ -1712,7 +1713,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed) >> return -EINVAL; >> >> /* Stop any subdevices for the remote processor */ >> - rproc_stop_subdevices(rproc, crashed); >> + if (rproc->subdevs_started) >> + rproc_stop_subdevices(rproc, crashed); > > Thanks, this approach looks better. But where do we clear this flag? > Shouldn't we do that here? > > In addition, I think we also need to set subdevs_started = true if > attach succeeds. And clear it when detaching a remoteproc. I think you > just need to update all the callers of rproc_stop_subdevices() and > rproc_start_subdevices(). Or, which is probably simpler, just make the > check directly inside these two functions to cover all users. > > Thanks, > Stephan Thx, I think it be better to modify the flag inside these two functions. Will fix in next version. Thanks, Jingyi