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 60DA732F748 for ; Tue, 14 Apr 2026 03:23:57 +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=1776137040; cv=none; b=Sx4YBgi0qKEFEh6E+O7odKiz8Zxl9uNgmXYV38UdVJbWDePPofT73ffkDM+Ldt3jzkbwQXWoUJZnaH2jzD5q+QArGP8CKXV73h6fvRhNfw9pAwDYMmDAXu1G1kl2f252fNoc3lZO8R7VjS1SNMn8HQerqzyfrtETcm/1fxtFU68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776137040; c=relaxed/simple; bh=e+fdpsXXxqmh5T4lJEbG0vYDdBdc8dvNKOqB0Z6MDVU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NmNhApt4JADYOIt+EEG3fO4hF6juvpABMPYFjMFAqPo/Bm6uim4zVBoO91EgYs49/ulu76tIAKV12fGkd9aYgYC6Ui4KNva/ooIPV65f4MSONRuyAo8FQPL7XPZHhMcgREuhCwuQ1lc5DOXlccVYDHg+jlnETaAYlFkNVcFQ/bM= 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=JTl2+scl; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=JqKxplu9; 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="JTl2+scl"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="JqKxplu9" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63DLCqkX2387321 for ; Tue, 14 Apr 2026 03:23:56 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= o3R1wD2JeVV+ofiHbbAjdqUCiIXfouDrd59/7E1MjlA=; b=JTl2+sclBBXlfuol B5wp6P+mXivyeOPE4L5lUwfXGDFzfiByOy97Fb49mWjfcJXGQB0Hxlco5yDsPzvE CavE8jEHU04bR9UVfVK/dZiKfjQshn1E5BDIJF2dTuDTFZTy7gg2l/BvWomcyCJz IkIZPKPx2KzfFbPmeeVNE5OtxKGrN85xp8FaBfHftwpbTYokfvnqonypRDCGAK5a QIg57sFyonk4+7xN6D8npuEQBppy4+oixdF+cIP/lzfOAmGKquCd11rq//YyBs/L APHEuFMgwKgDJYDzHygkTJAo9OduvSH0TxeyFSsdAGnFNZlk7/6ezGDfW7LuHvpF wDjXhQ== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dh86w0tpe-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 14 Apr 2026 03:23:56 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-35d9f68d00fso10056345a91.2 for ; Mon, 13 Apr 2026 20:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776137036; x=1776741836; 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=o3R1wD2JeVV+ofiHbbAjdqUCiIXfouDrd59/7E1MjlA=; b=JqKxplu9FTOcbI4uhjzCL3C4z0SEY+QdPzj1yNNsVGgojytrCRyUDFIirxHtin6FU7 awN6xHYvglxt7NbuhbIKo4Hiu4RCfNZdaO7A9+oLRU+COtvjW4coTZHQfsjy4bG2GaZh jiQp0S28AmJG44HquCkSAi4YvJJpcKBONrUBdsUxrXwxA9Q+16FQtUIHyBA6Vph8o4rc Xukgmw/6JT6gj+JvpWPx29tZDy9S+DsYm64I+NuhQsigpijBgWi4pTZufvYDiJZUwGFG Z/wmf9YEPMUef+33bGai44xx5K6o7lQZWzJjC2y4vWTLS1JJXkM7MFfsMdjJOHhENJD8 Aouw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776137036; x=1776741836; 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=o3R1wD2JeVV+ofiHbbAjdqUCiIXfouDrd59/7E1MjlA=; b=Kswx2s+kf6XI3Gi8j6Zh+p+EpIcAxyo0SIbUxGp1Uibn3be4bEdOvDrVdjdMSZPjuj K7DHPvoIHqsp9bdQu2zKAtpbsocs0UI88Q5XLQWfeIuoe2zL1Cr1UQrsrcdVz3rjcSZN uSqc2WdhCsVbB5qY28zKEGeCfL2Z/i8zSw+DFz+PZA6fRm8ScL8Ron1xegWVYLsT6Evq XJIzdTyvtSIhsCwf2FSIvwy2LM9LZ9/D3M0clbRQCi+c2+MIVz7dyuZAwypcc3SV7eMx TE6t7Q5aKEXW5W5dW90nZy2uJNvRIW4+vD3Q+tlKGC2IEJUNStIGvCGoTRRbZxiZ6hYg BOww== X-Forwarded-Encrypted: i=1; AFNElJ/s1yFiVBk88S6nMEKs10Hb1db9ZyHTzjMRG7SMUt2mwppI4rmSl+LxTroEwfR1AqOUzTd7fMN/2JF/FS8=@vger.kernel.org X-Gm-Message-State: AOJu0YzIH9nVzr3eN4ZSGJGSQBOTNu+FMCQdyfJZOE29EZ/AV8BGu2St 0eowtbHCNA0iFFsw+//IDXRZLbh+8abnGwcJuF70ppjghz1ExIOOaW0M6Q43X0mgtFg7RikNajD +K+aVUhL9Be2llZZat67ywM6XyhFUewrJSlg7kHllCZeg47Y0jmdIR4Jc5AnmPcCiwvk= X-Gm-Gg: AeBDieurpX/7ofOctIIwRTCexzh70nLAgklKoh962HtgXR6peCQPCnteLepuD29t5vi LDEWrIX9g7S8s3Qqf119iUKGEQLu3GQ1h8cKg4wijlNmy84eG6a+I0oEkNV4mh0kiE1XpPdtjIL dW8eI0kJO8HSxkHY0V31j1J+pNb73EN+Je/nAbMSb8PnR8oLPfVbigirEYixw/qfqMGBpVsRwuU 3nVKaDJfoutwOu8ZjzfBzXHaZZ753HNLEjEbHgiJNGhOcfCw329cJt2GtESXhs5Ct6HJVJdVj3r TxcgVo31m86JhJkXlesNQr3t73VOOOdnOyNYvOE+F7jMGvZB9e8MLl31AXbDZqLQwJa6magN00l iYhFpqbNUEHRxqPpaDJiFpxBcmCo6o92P2+vP0QzRgV/y5tFZsoJiE1np7BNdQNqX8zejNMSRP8 0ZaIzYtMw0BhyrX3k= X-Received: by 2002:a05:6a20:9155:b0:39f:5671:921 with SMTP id adf61e73a8af0-39fe3c9126bmr17960667637.3.1776137035676; Mon, 13 Apr 2026 20:23:55 -0700 (PDT) X-Received: by 2002:a05:6a20:9155:b0:39f:5671:921 with SMTP id adf61e73a8af0-39fe3c9126bmr17960628637.3.1776137035223; Mon, 13 Apr 2026 20:23:55 -0700 (PDT) Received: from [10.133.33.94] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c79218fc462sm12018562a12.8.2026.04.13.20.23.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Apr 2026 20:23:54 -0700 (PDT) Message-ID: Date: Tue, 14 Apr 2026 11:23:50 +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 2/2] remoteproc: qcom: Check glink->edge in glink_subdev_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, linux-arm-msm@vger.kernel.org References: <20260409-rproc-attach-issue-v1-0-088a1c348e7a@oss.qualcomm.com> <20260409-rproc-attach-issue-v1-2-088a1c348e7a@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-ORIG-GUID: YcKbMszO_Y09MxbXZ7qnWXITi-jmHMX7 X-Authority-Analysis: v=2.4 cv=HKfz0Itv c=1 sm=1 tr=0 ts=69ddb34c cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=6NDAGjaxIoc3lUqdot4A:9 a=QEXdDO2ut3YA:10 a=O8hF6Hzn-FEA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE0MDAzMCBTYWx0ZWRfX11OcAAfNEqre Rh0hBZrLcgnqyY5Jf8E1w0Bvjbv1Buv/noDLzLPY/gZmNw4BajsZiKG9sxa9+ldr7i0OPscVZyV jkaZMJzBsnZySbMlCEltTlzYCzmRAKmkmBOwpxSThDonYaLZS1BC0vev1kjARZQOVvfbyKfJ2DQ 17kWtZ0turI2+Mka3TNE4MG11JmYSBhd3U/KrLD4UnFnFxk1zMwzGH+OIclj6x5BPYs10ihMtGV zMpWh49Th3IfsPQeJv+5yJoSHoSN7moZ9NsY9wJRr8nTe+HSzSJly0kWbqBRRTnY0qwgBrCWDsy gfV9czm69SV5kjF9BlWUzL21RQpI2/xpUno5zn165cF9ek20TdqmfcQVeRA/H7twj2g0X2rOUCD qlU/MjGpyyIN0OABnhezni0aTNz1C19AMAzPne08xeOG05s/b7itY1NbMpS81fKJalNQGjuvosk Ppv1wswWxo6FinNWEIw== X-Proofpoint-GUID: YcKbMszO_Y09MxbXZ7qnWXITi-jmHMX7 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-04-13_03,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604140030 On 4/10/2026 10:15 PM, Stephan Gerhold wrote: > On Thu, Apr 09, 2026 at 01:46:22AM -0700, Jingyi Wang wrote: >> For rproc that doing attach, glink_subdev_start() is called only when >> attach successfully. If rproc_report_crash() is called in the attach >> function, rproc_boot_recovery()->rproc_stop()->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 ]--- >> >> Add NULL pointer check in the glink_subdev_stop() to make sure >> qcom_glink_smem_unregister() will not be called if glink_subdev_start() >> is not called. >> > > You mention the actual root problem here: Why is glink_subdev_stop() > called if glink_subdev_start() wasn't called? > > The call to rproc_start_subdevices() in __rproc_attach() makes sure that > all subdevices are in consistent state when exiting the function (either > prepared+started or stopped+unprepared). Only if all subdevices were > started successfully, the rproc->state is changed to RPROC_ATTACHED. > > In your case, attaching the rproc failed so the rproc->state should be > still RPROC_DETACHED. All subdevices should be stopped+unprepared. We > shouldn't stop/unprepare any subdevices again in this state, they all > might crash like glink does here. > > We know that subdevices are already stopped+unprepared in RPROC_DETACHED > state, so I think you just need to skip rproc_stop_subdevices() and > rproc_unprepare_subdevices() inside rproc_stop() in this case, see diff > below. > > Thanks, > Stephan > > @@ -1708,8 +1709,9 @@ static int rproc_stop(struct rproc *rproc, bool crashed) > if (!rproc->ops->stop) > return -EINVAL; > > - /* Stop any subdevices for the remote processor */ > - rproc_stop_subdevices(rproc, crashed); > + /* Stop any subdevices for the remote processor if it was attached */ > + if (rproc->state != RPROC_DETACHED) > + rproc_stop_subdevices(rproc, crashed); > > /* the installed resource table is no longer accessible */ > ret = rproc_reset_rsc_table_on_stop(rproc); > @@ -1726,7 +1728,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed) > return ret; > } > > - rproc_unprepare_subdevices(rproc); > + if (rproc->state != RPROC_DETACHED) > + rproc_unprepare_subdevices(rproc); > > rproc->state = RPROC_OFFLINE; > Hi Stephen, In this case, rproc_crash_handler_work()->rproc_trigger_recovery()-> rproc_boot_recovery()->rproc_stop()->glink_subdev_stop() is called, "rproc->state = RPROC_CRASHED" is set in the rproc_crash_handler_work before rproc_boot_recovery is called, so checking RPROC_DETACHED can not work for this case. Thanks, Jingyi