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 692E72D12E7 for ; Wed, 24 Dec 2025 04:43:30 +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=1766551412; cv=none; b=iEz6vxIaulzfnByHsAIz++hxkyzhB/u/aFWmoPWUZR5Xd3sNxuFQWUymwPLuGpWRCYQ9SImhOiPAO2zOLAC1J6Xy8Pyj0DqsLMCEnVwRlZZu2U7tbXjEuLegdBfevAoLS+KSDAbp7D4mq146+yEYjj+ic20r+0P9FsbUvGdtcv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766551412; c=relaxed/simple; bh=7AnAY1VSKRpLhFsr6vc0i3JglJIfczIn7APLeqeEZQw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=OW4jyhwLRSvsIRlWdngWHtU6P3XvhfLBBW9ILTUJI5ng0x9mDXO1KCMEebMfPMxirCrDJHXwq9nO/F2JVLOC2NkitOTfbbJICarHMvGq4rN/fzQ6+iIGVo0phvo2BZi84g0+MCxiwLV/RBxzRkF0jjtQIRFXNfWwOarMm4WAKLw= 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=lptUDiMD; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=J72xlBg5; 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="lptUDiMD"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="J72xlBg5" 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 5BNLY2Hs700570 for ; Wed, 24 Dec 2025 04:43:29 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= /NKX/57tYYBCmkhefEDajLW0SWz9CgJw4SMyS6Hgi3A=; b=lptUDiMD8lWvBeu0 OzkHjgLNGwbPOmWjlYj670wIGUXDFMgOm2/iVryRX5cASMdgkjfMLBYdLd5hb4Tt jJEensK4SuRIecb+F5JaPP8R16vytpGSOqyBwCCtbkXq3vETxUJHAQE2Rsu6COO4 8GwUG834w8LYbXl/drMvCMXHCoKDP1BCYMFclswbkZ9CFpOq0L9JKtBkQCFOjeZq ymGYM0TujPWCRgHUpUgOWNefx5puFOkTaSc8YkeQ17a50/gyqg7Da+eR0OBRN9cK zqYkEexns+3HcoS3LYS9h1ndi+UcJkcUExrwkOsimZgw45WBQOz2Tl5kDr8ep++i nvM/Vw== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4b7t7jtmjm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 24 Dec 2025 04:43:29 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-7b90740249dso9797049b3a.0 for ; Tue, 23 Dec 2025 20:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1766551408; x=1767156208; 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=/NKX/57tYYBCmkhefEDajLW0SWz9CgJw4SMyS6Hgi3A=; b=J72xlBg5AJmtqNjZV2c3LcUwRrLip8/essbTt/WccSiXjwZzJIN6dlM6VO+s/Ix6Iw p52AGXQmuPaH9I/jVb1Z5wMSD1EO7gerU3Szm1wJub5QxP5B5Tecv/xHH/tif5578Cfn 1WHfHM8wXSyv+VVXPcq8742w64nlvWJ70BDAU0LjpN5ZwlZIK1sXNybNTPrRXG67nFJL KmUNjw/20IR3qavJE5UJukGPMvEd5wX5WBAQ1mPBiIhehbjqh49NFYqtAwkZFQWl81yj YR9/TiOcrZtNEs7cyvuLlAkEdw2VH5POrE234jtTTD4GGxskbC0TYOfveMpvUSs93H1C 0lLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766551408; x=1767156208; 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=/NKX/57tYYBCmkhefEDajLW0SWz9CgJw4SMyS6Hgi3A=; b=oRj5KAkEw3RqOsINEQz+7ffOPYpNXq/TDB7ZLHt8yuqunqszGdTRtToy4bZohAUsyL mjY71fwEitpeRsbZS9GygAVETulafPJ/K8wBXVdvHnBRoTLh/FuIapDG7CYY8Q1byO78 rDElgLVLvojpQP0s05+in0GblXWN5uDuz3EJkcyGfOOP1VqNCiUtzPsPQw45JgFMZeLC Jc01akTo5pT7KIRLhzTdLc6c3LPWzqtbHqnW0xcoJDMdpuE9Gtz6a1EcCUVqKK1CzhRD E7mZWY++aLPltgMDamYR8ZbLmHHTu7Fylko/EodavEmW9yYMoqMp2U4Mjkrv0vhLi8RY YzEQ== X-Forwarded-Encrypted: i=1; AJvYcCWGoKsS/YVpZcV6bIPM9jc6r9y+7SgHVUsJPdUbZy90MSLFMlgi9eAMpv3TfNLcl7i3f4bZK/P/Jmt8jtE=@vger.kernel.org X-Gm-Message-State: AOJu0YzN7Kb446RFvn0UO86f5NgL2IQwyONm6yobWT+pKFwtnjnMhavc xlIgBoibab8pnoHPV6iPdKmttUWrfk9R3KKMbF5GeCuQZYgduggbdXzjKbupaURpWNeRws5e4YC EV52feRJpfRn7FRaZ4atdWuObkQM9HqEduBecGliDHFjkTyo3sy2En9zPEW1kcxv6ANc= X-Gm-Gg: AY/fxX77q6/Z66MfKfblCll8t9G2TXWNZ2MM9bgLL1c01AHRlJirlE28HHjeef5H1f1 5cL0UJTjYOgTHmX1H4+2fAZzNbYJOV0Urbl9QvJZfQX/L5jOsslrNGjG2NAZV7EZnj2Dr0bpQpT qXczjQ2/cD70B4xmv5VvyJLPhwGv1i+aNzGuociMvXr8Tjgai1EValS+7ZVIFHsEXQySVBewlcf 3ZD+R1WrKT6Cipv1DpPYfdNTOzCv1VKI2Ic5aSidqLiB1KlabNVSdUJfvV5iog2RxyUZbIvAdor ZpiRfj19J2SkiE5leA5+U85nZhxpqVg3SZuVUH70iuqAytDAlX6sS/DBGuAMpXab17H3eMALMta YJdVOzispIk7PnpHRCE+41EvMX+wDLZh5pNwL05IsLEfZgTx7EpBeFdG5FuFCtaZk1/7ndqy/w9 qVmyz9 X-Received: by 2002:a05:6a00:8d8e:b0:7b8:3549:85f9 with SMTP id d2e1a72fcca58-7ff64eca979mr14445121b3a.30.1766551408206; Tue, 23 Dec 2025 20:43:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvc4FrnFMsQMIBE3qVedvVFkxoaNx3NeqcjjCZI3I6L2rFmIE9Yn6mBYWW9e5zltIVhIzrsA== X-Received: by 2002:a05:6a00:8d8e:b0:7b8:3549:85f9 with SMTP id d2e1a72fcca58-7ff64eca979mr14445098b3a.30.1766551407668; Tue, 23 Dec 2025 20:43:27 -0800 (PST) Received: from [10.133.33.224] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e88c8f0sm15536300b3a.62.2025.12.23.20.43.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Dec 2025 20:43:27 -0800 (PST) Message-ID: <51e0665b-42c4-4084-8019-9fbeaefb5b56@oss.qualcomm.com> Date: Wed, 24 Dec 2025 12:43:20 +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 v3 4/5] remoteproc: qcom: pas: Add late attach support for subsystems To: Stephan Gerhold Cc: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , 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, Gokul krishna Krishnakumar References: <20251223-knp-remoteproc-v3-0-5b09885c55a5@oss.qualcomm.com> <20251223-knp-remoteproc-v3-4-5b09885c55a5@oss.qualcomm.com> Content-Language: en-US From: Jingyi Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjI0MDAzNiBTYWx0ZWRfX7ahHqSlQwP39 F+ebCyduAPGgsxmdT5ZMw0AY+N+MZFiXHS8ribb3iJx5XGpoF1OmURvFWhCMzJ8pP++vgczeiqW 8RXMxcMtFUyqioYd9Hr6WzffkrJ2FVCzTXZ7Gknmpo88X2h7xXkPhP3vMH4CDxDaTOdpvJJkf6i l341gJU/B6JtBrQUaQdamkl9iQ4THfUt0KtTzyhM7wZjvNFb+dkte/GgCvHF0wghjctN11TilJw jEaQqEFN2kH9VSsyrUiAkgFA9aKTu6iPVomk9YvsylS5kAawv/yiVVuSAYrj5bfMpRUcQ3FV20J L2NSFjzjhFoyO65HKoetXYh4RaYA8DPXA8gLf3YMbkmMFoeo+VRnt3bKTLMu4G5VsJjaFvhoGoV /wTwLXaQ7w4niR9jFoZoCUd164jeWJ1mNb+yT8r3WrNdFjnQuOB/orqqF9UCzDl+4RcCjuIlMps Gdpt8YMBLR+0eOvIw8A== X-Authority-Analysis: v=2.4 cv=IvATsb/g c=1 sm=1 tr=0 ts=694b6f71 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=xPClpbL46aL21xVsldcA:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-GUID: XFnNr4BDplR4C0ryxHzORz9cf3Jrvr04 X-Proofpoint-ORIG-GUID: XFnNr4BDplR4C0ryxHzORz9cf3Jrvr04 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-24_01,2025-12-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 impostorscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512240036 On 12/24/2025 6:15 AM, Stephan Gerhold wrote: > On Tue, Dec 23, 2025 at 01:13:50AM -0800, Jingyi Wang wrote: >> From: Gokul krishna Krishnakumar >> >> Subsystems can be brought out of reset by entities such as bootloaders. >> As the irq enablement could be later than subsystem bring up, the state >> of subsystem should be checked by reading SMP2P bits and performing ping >> test. >> >> A new qcom_pas_attach() function is introduced. if a crash state is >> detected for the subsystem, rproc_report_crash() is called. If the >> subsystem is ready either at the first check or within a 5-second timeout >> and the ping is successful, it will be marked as "attached". The ready >> state could be set by either ready interrupt or handover interrupt. >> >> If "early_boot" is set by kernel but "subsys_booted" is not completed >> within the timeout, It could be the early boot feature is not supported >> by other entities. In this case, the state will be marked as RPROC_OFFLINE >> so that the PAS driver can load the firmware and start the remoteproc. As >> the running state is set once attach function is called, the watchdog or >> fatal interrupt received can be handled correctly. >> >> Signed-off-by: Gokul krishna Krishnakumar >> Co-developed-by: Jingyi Wang >> Signed-off-by: Jingyi Wang >> --- >> drivers/remoteproc/qcom_q6v5.c | 87 ++++++++++++++++++++++++++++++++- >> drivers/remoteproc/qcom_q6v5.h | 11 ++++- >> drivers/remoteproc/qcom_q6v5_adsp.c | 2 +- >> drivers/remoteproc/qcom_q6v5_mss.c | 2 +- >> drivers/remoteproc/qcom_q6v5_pas.c | 97 ++++++++++++++++++++++++++++++++++++- >> drivers/remoteproc/qcom_q6v5_wcss.c | 2 +- >> 6 files changed, 195 insertions(+), 6 deletions(-) >> >> [...] >> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c >> index 52680ac99589..7e890e18dd82 100644 >> --- a/drivers/remoteproc/qcom_q6v5_pas.c >> +++ b/drivers/remoteproc/qcom_q6v5_pas.c >> [...] >> @@ -434,6 +440,85 @@ static unsigned long qcom_pas_panic(struct rproc *rproc) >> return qcom_q6v5_panic(&pas->q6v5); >> } >> >> +static int qcom_pas_attach(struct rproc *rproc) >> +{ >> + int ret; >> + struct qcom_pas *pas = rproc->priv; >> + bool ready_state; >> + bool crash_state; >> + >> + pas->q6v5.running = true; >> + ret = irq_get_irqchip_state(pas->q6v5.fatal_irq, >> + IRQCHIP_STATE_LINE_LEVEL, &crash_state); >> + >> + if (ret) >> + goto disable_running; >> + >> + if (crash_state) { >> + dev_err(pas->dev, "Sub system has crashed before driver probe\n"); >> + rproc_report_crash(rproc, RPROC_FATAL_ERROR); > > Have you tested this case? From quick review of the code in > remoteproc_core.c I'm skeptical if this will work correctly: > > 1. Remoteproc is in RPROC_DETACHED state during auto boot > 2. qcom_pas_attach() runs and calls rproc_report_crash(), then fails so > RPROC_DETACHED state remains > 3. rproc_crash_handler_work() sets RPROC_CRASHED and starts recovery > 4. rproc_boot_recovery() calls rproc_stop() > 5. rproc_stop() calls rproc_stop_subdevices(), but because the > remoteproc was never attached, the subdevices were never started. > > In this situation, rproc_stop_subdevices() should not be called. I would > expect you will need to make some minor changes to the remoteproc_core > to support handling crashes during RPROC_DETACHED state. > > I might be reading the code wrong, but please make sure that you > simulate this case at runtime and check that it works correctly. > Recheked this part, current path has some issue on recovery and subdev handling. As in current code, rproc_report_crash is called in the ISR/callback, it may take some effort to call it in this attach path. >> + ret = -EINVAL; >> + goto disable_running; >> + } >> + >> + ret = irq_get_irqchip_state(pas->q6v5.ready_irq, >> + IRQCHIP_STATE_LINE_LEVEL, &ready_state); >> + >> + if (ret) >> + goto disable_running; >> + >> + enable_irq(pas->q6v5.handover_irq); >> + >> + if (unlikely(!ready_state)) { >> + /* Set a 5 seconds timeout in case the early boot is delayed */ >> + ret = wait_for_completion_timeout(&pas->q6v5.subsys_booted, >> + msecs_to_jiffies(EARLY_ATTACH_TIMEOUT_MS)); >> + > > Again, have you tested this case? > > As I already wrote in v2, I don't see how this case will work reliably > in practice. How do you ensure that the handover resources will be kept > on during the Linux boot process until the remoteproc has completed > booting? > > Also, above you enable the handover_irq. Let's assume a handover IRQ > does come in while you are waiting here. Then q6v5_handover_interrupt() > will call q6v5->handover(q6v5); to disable the handover resources > (clocks, power domains), but you never enabled those. I would expect > that you get some bad reference count warnings in the kernel log. > > I would still suggest dropping this code entirely. As far as I > understand the response from Aiqun(Maria) Yu [1], there is no real use > case for this on current platforms. If you want to keep this, you would > need to vote for the handover resources during probe() (and perhaps > more, this case is quite tricky). > > Please test all your changes carefully in v4. > Thanks for your detailed review, the handover resources was indeed neglected in the design, we will re-evaluate this part. > Thanks, > Stephan > > [1]: https://lore.kernel.org/linux-arm-msm/c15f083d-a2c1-462a-aad4-a72b36fbe1ac@oss.qualcomm.com/ Thanks, Jingyi