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 46B30377011 for ; Thu, 9 Apr 2026 08:46:39 +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=1775724400; cv=none; b=YnpeG261hjYo6ZhUD4F+wy9DaS4yyQnbKjasMBiglHtKOpNd2aI+mPuoKprSYhgbyXUlnvcKH5Ek7iBvrnEFbPfWVBquuEvadKRcDgo+xdpecjlzxzJNgxFZ286sFwGC7UJ3JoNi4veFS9D+S834gVbEzNyGUIeggtiJ2n7XT7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775724400; c=relaxed/simple; bh=LILZ401zz4H4PYaJRtQNOEsPKwxxLyAST3STgzRbi68=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pIkH6B/qkwE06wYD5xvYdvfnsQ7/xq7aJS3qa+4ouoytDCelgIWujqhiqL9Dw0T2p7suSCQNJ6e3dHRlu17S3o2z3sV5Qzg2gmrEtAJ3p7hQJfA1f1597n2wloR7mWJDSZtQwS1jbZl7NPwR3IoZzWWwBmUPSxDXZ+HcKmzj6Qs= 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=N8CnON4u; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=fMc1u06c; 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="N8CnON4u"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="fMc1u06c" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6397NQHb2845134 for ; Thu, 9 Apr 2026 08:46:38 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= 6Irp+xgmj9Ik34RHCahjt5RaucthCedcYg4gNt6nNrw=; b=N8CnON4uIERbWLMl w9fK/vSu1ncvMdTgo9FcHm51bTsDYrLBJKpRnN3gPG8jY6B2q3p5pPFmRJ9U5gP4 zICdkso2gBKmIAVnyn1UpV6/tilCesggfTAxHMN8aGSh2+Rq9+T6rzjswe77C4OM 9oImUIJ+hhCg2VzoSHZ+jfBM6jZhOBJ7Tp854GLypZBhgdL05AE+Yx+L9akkyqsd E0fBlaw7dcT1I9Nf3RqUNEwLHzIgPZe28vdrE/YBblV64N+C4RQTCcjpucozmc7W eP9y9n/uU/3Pa7XdtFgewNB98Lgb/b55239DcE4uRrCZ3cGRZZvaZaP5oqVdQ6c7 V5m/BA== Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ddt7hk7kj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 09 Apr 2026 08:46:38 +0000 (GMT) Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-12711ec96fbso2794492c88.0 for ; Thu, 09 Apr 2026 01:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1775724397; x=1776329197; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6Irp+xgmj9Ik34RHCahjt5RaucthCedcYg4gNt6nNrw=; b=fMc1u06c47erWy7664ZqzsoePxG4gCaW0baXmBkICiHI9nW33LX59tTT4Xk+3Uv99N j/59zDSem7JxZ/29jnKSHMuGVGGxh6DiJhUZlSIXDbsT9LwfpXs6vlITTHmTuDXBir1+ ARX6/z02csIw2PKpOgC0EzpOYpk9kZOQ1OmOec035w8PNCiWyExGlyTYEbx/mTgcLzX9 Vb3Ylt5oSsNoubeFm/eII195Bq29JuaRRBk9uicn017gHzWkPOfWWPisXo5O1S7iLYUw 7SAJOI8iUZJeemFyQWrbn2FHV15NEFRmGxa4PN7E96lCB0N+v0gE/E5KNlyFWF6NggoK lPww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775724397; x=1776329197; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=6Irp+xgmj9Ik34RHCahjt5RaucthCedcYg4gNt6nNrw=; b=o0qEPzswA9dCwqMRyLe6znE98HQ9N2VUOOgKzGq9uVgoLhyUnfrNMR/6y06XSKMKxk l8rqRTMB51XCKObPWxyh0JouPczPvh15V5SU1cPAU0j/s1Bmz40oYTjX+utWv7cV8Nms igAfJQT1xINZdpWncrYwXZDLELgrmngFtE9kgcn0j0dLiwGAAtNoDTnGYHo/FrbLDvlb ETamPihNcB9ynQdL/l9OGNxLHhKMjDsq/JFftpjQNJaW7CR3MrVRp0gApj9RMek/OGOd uppxo8fdhGvF/TRGduppVCo8xINygBUEM1HgSOD40237u8dZP+Gt7d2LPkxUKPtRJBze nS8Q== X-Forwarded-Encrypted: i=1; AJvYcCUDwR8PGKSWD/eFYzg13KWBiB70vJPIVzerURrvr/JrB2D9+aWeNqbhnac+SiOCytjSdegjWq/qDelTllw=@vger.kernel.org X-Gm-Message-State: AOJu0YzBxI+Lnc9x/gwG3MUNIPdg7VTBOVkEM/3UGyEx94xqwz9G/hGe NRvaaWau6ac5m6RC+v85HwqG5S/pq8U+s3EL+sXshvadt21sU7rl9TSx98qbEK9qqACvsnQZvCz mlufXTtiyFD7pPaTOHFVI+5TCE+TDLOhs5rnIrOvKdfUimN+7JMH5igqNFEtFK7Gw7V+S73gYZr U= X-Gm-Gg: AeBDievPb6wOj5HKm6xfScdhTorcHn8XkFOVQTVCRGGDimLXnyeiobZcuEh4Vc8GZ0b Z1/1vcRdY4xhwJfQUt5yxqTN89V4jEm2t4/wz7QDT0YZwOYIEttfopOr9AfSK0bn8R/bL9pp5pq ehENXzR9ks56rjakq5aVD+woYYJkjVbBHkIJ6UxvMmOlcPFx5aSCHoBgXwTfXecrW841P6Zty8W w7zZKuEJU3prm3aJlf+2OFR5dBwDMyGvEM01D/2iGT34wb6t9G/K7YX5tg30EWT+Vt3zoaF1STc lo3SpdW0bW/tuZiWzgLkHpEddkuM4/SP8qBFQQS3ngAMgrtmY8Wgv4nCp3NSXQ81QEEMplJBE/a ILCfaPIDNH//Lrbi3HBDtphbWcfwpOY7k1L6KeH9LZJKr4r/gWLW8DfoBlN1xwdXHZPcal0fq X-Received: by 2002:a05:7022:4381:b0:11d:e40f:ee69 with SMTP id a92af1059eb24-12c28c179dbmr1491442c88.36.1775724397046; Thu, 09 Apr 2026 01:46:37 -0700 (PDT) X-Received: by 2002:a05:7022:4381:b0:11d:e40f:ee69 with SMTP id a92af1059eb24-12c28c179dbmr1491413c88.36.1775724396463; Thu, 09 Apr 2026 01:46:36 -0700 (PDT) Received: from hu-jingyw-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12bede54ba8sm28451931c88.10.2026.04.09.01.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2026 01:46:35 -0700 (PDT) From: Jingyi Wang Date: Thu, 09 Apr 2026 01:46:21 -0700 Subject: [PATCH 1/2] remoteproc: core: Attach rproc asynchronously in rproc_add() path Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260409-rproc-attach-issue-v1-1-088a1c348e7a@oss.qualcomm.com> References: <20260409-rproc-attach-issue-v1-0-088a1c348e7a@oss.qualcomm.com> In-Reply-To: <20260409-rproc-attach-issue-v1-0-088a1c348e7a@oss.qualcomm.com> To: Bjorn Andersson , Mathieu Poirier Cc: 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, Jingyi Wang X-Mailer: b4 0.15-dev-3d134 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775724394; l=2493; i=jingyi.wang@oss.qualcomm.com; s=20250911; h=from:subject:message-id; bh=LILZ401zz4H4PYaJRtQNOEsPKwxxLyAST3STgzRbi68=; b=qPNHNb8mVXkDQ+pA4e1qin4F/5ybw8Ks5xZVj0AN7q3zBfhv66RDYgyVzURhJMeRihMAnAemM KjmNghF9PTOD3B8IIGNwsc5SpHkIyUpjAZlldVTBwCzEAPrHS60ZsGD X-Developer-Key: i=jingyi.wang@oss.qualcomm.com; a=ed25519; pk=PSoHZ6KbUss3IW8FPRVMHMK0Jkkr/jV347mBYJO3iLo= X-Authority-Analysis: v=2.4 cv=O5IJeh9W c=1 sm=1 tr=0 ts=69d7676e cx=c_pps a=kVLUcbK0zfr7ocalXnG1qA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=k_JL0JQvz4wm1xcudgQA:9 a=QEXdDO2ut3YA:10 a=vr4QvYf-bLy2KjpDp97w:22 X-Proofpoint-ORIG-GUID: srvWj2OtRJzrGK0_UXQhN_uDE5Pg-2fR X-Proofpoint-GUID: srvWj2OtRJzrGK0_UXQhN_uDE5Pg-2fR X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA5MDA3NiBTYWx0ZWRfXw/qXrvPXG47+ XreAsXm9XvZP6JhOV8ut/RWPksGYmOQ0SCu4TosfMSu5RBEFiE2OCU9oNHHlhu8yLlg0sKWjPco nmI6yK4CU+8Pqz+U8aqoae5eWwo1PUq6dLSZehEv1twzpxYmyr6gln1cYRNhzUB159FjA+21ER+ f0bqDR/mXuPlV3jF1HwdldbIxWhNlmuZeSj3fdLvomRkWeHJRLtEUTrazzpTvoJk81IvPP3K2KF SdBQVddb2ZP0pMDAkHh26uXDlh6gNT+7RzlUBKl+3cxIWIColXlbi1SI0IHEYTdqxC4WBXMMLXj qgdY2x0OWvwWlhc4NxNh7eMY72F9QmxfTeCP95pV1JshbpPKdrKGfAvkmx7Azcv4lcdTzwtNRYF 02BaMn9rTXUWpfbqLivSUfLFdBHcXf3FdvlkGpvVDhEIhVZz3DcZg3jdgPKHWSfHf6MXjbQFdX0 LK04S9waWdNUDxX5jOA== 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-09_02,2026-04-08_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604090076 For rproc with state RPROC_DETACHED and auto_boot enabled, the attach callback will be called in the rproc_add()->rproc_trigger_auto_boot()-> rproc_boot() path, the failure in this path will cause the rproc_add() fail and the resource release, which will cause issue like rproc recovery or falling back to firmware load fail. Add attach_work for rproc and call it asynchronously in rproc_add() path like what rproc_start() do. Signed-off-by: Jingyi Wang --- drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++-------- include/linux/remoteproc.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index b087ed21858a..f02db1113fae 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1673,18 +1673,21 @@ static void rproc_auto_boot_callback(const struct firmware *fw, void *context) release_firmware(fw); } +static void rproc_attach_work(struct work_struct *work) +{ + struct rproc *rproc = container_of(work, struct rproc, attach_work); + + rproc_boot(rproc); +} + static int rproc_trigger_auto_boot(struct rproc *rproc) { int ret; - /* - * Since the remote processor is in a detached state, it has already - * been booted by another entity. As such there is no point in waiting - * for a firmware image to be loaded, we can simply initiate the process - * of attaching to it immediately. - */ - if (rproc->state == RPROC_DETACHED) - return rproc_boot(rproc); + if (rproc->state == RPROC_DETACHED) { + schedule_work(&rproc->attach_work); + return 0; + } /* * We're initiating an asynchronous firmware loading, so we can @@ -2512,6 +2515,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, INIT_LIST_HEAD(&rproc->dump_segments); INIT_WORK(&rproc->crash_handler, rproc_crash_handler_work); + INIT_WORK(&rproc->attach_work, rproc_attach_work); rproc->state = RPROC_OFFLINE; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b4795698d8c2..9b3f748e9eca 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -568,6 +568,7 @@ struct rproc { struct list_head subdevs; struct idr notifyids; int index; + struct work_struct attach_work; struct work_struct crash_handler; unsigned int crash_cnt; bool recovery_disabled; -- 2.34.1