From nobody Wed Dec 17 15:41:29 2025 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (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 512DF1FFC4B; Tue, 13 May 2025 05:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747115234; cv=none; b=uJ+VIxmK6Q4f+cnBcZhi5oHhqac5njJVvDGWNmxAoL1DGToa2v7Pv12Xlwxry3RMasI7haHHrraaHnDA3APfoisHRP7EK7GHulbWdq3d5nDu50v5JDP1o57IfYzXX/qPr0cgo8gCecN/ZZ5KSR5JbLZjeBG+ikjcQ3pLHIz/KO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747115234; c=relaxed/simple; bh=uktFr7tP4QiGVTbArqqBdR+WIiOVtkVXeLFRpB06RPQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qd2c19ezF9/J+NOU1nAjHaFFYM1+kGBpqBkkuI8s3JynkRPg8jfEFjY37x/SrFLXMQvtRdh5GmXExMQwaF0vqt5sLA6mBSVklcltmXMV8FqUEDMzAyjrFb02hmkA0mLMyk3p8ZVQ5ijFji3A3+GmS+UBbBe4usJ9xy87bRacht8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=m9kMXL7M; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="m9kMXL7M" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 54D5l3AP2226513 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 May 2025 00:47:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1747115223; bh=JlDalmT9AiO1XRoPfWEWkIeyC14DwdDgNrpfVAUOfwk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=m9kMXL7MAehaFhg04R9MS0haM5KCen0uEYxGv69uQC4XYMx5va3qiR6zpiTYJSvtq WOpEMrE7CQSGkHOG/Xg98tdVNvBR8ENdWEVqkOf3G8B9ycRjN9BOJEyrsReMOCFegl dJ+cTdks1pjkeFoAlsjDfQ6jmitp0ccTYsyFmAzM= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 54D5l3Bx032662 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 May 2025 00:47:03 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 13 May 2025 00:47:03 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 13 May 2025 00:47:02 -0500 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 54D5jAqZ131001; Tue, 13 May 2025 00:46:59 -0500 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v12 26/36] remoteproc: k3: Refactor .unprepare rproc ops into common driver Date: Tue, 13 May 2025 11:15:00 +0530 Message-ID: <20250513054510.3439842-27-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250513054510.3439842-1-b-padhi@ti.com> References: <20250513054510.3439842-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" The .unprepare rproc ops implementations in TI K3 DSP and M4 remoteproc drivers assert the module reset on the remote processor. Refactor the implementations into ti_k3_common.c driver as k3_rproc_unprepare() and register this common function as .unprepare ops in DSP and M4 drivers. Signed-off-by: Beleswar Padhi Tested-by: Judith Mendez Reviewed-by: Andrew Davis --- v12: Changelog: 1. Updated the check in k3_rproc_unprepare() to look for RPROC_DETACHED. 2. Carried R/B tag. Link to v11: https://lore.kernel.org/all/20250425104135.830255-26-b-padhi@ti.com/ v11: Changelog: 1. Carried T/B tag. Link to v10: https://lore.kernel.org/all/20250417182001.3903905-24-b-padhi@ti.com/ v10: Changelog: 1. Don't remove dsp func override. Already done by [v10 20/33] patch. Link to v9: https://lore.kernel.org/all/20250317120622.1746415-17-b-padhi@ti.com/ drivers/remoteproc/ti_k3_common.c | 30 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 29 +-------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 31 +---------------------- 4 files changed, 33 insertions(+), 58 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_c= ommon.c index 66839c694b693..235f6fca675a3 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -237,5 +237,35 @@ int k3_rproc_prepare(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_prepare); =20 +/* + * This function implements the .unprepare() ops and performs the complime= ntary + * operations to that of the .prepare() ops. The function is used to asser= t the + * global reset on applicable K3 DSP and M4 cores. This completes the seco= nd + * portion of powering down the remote core. The cores themselves are only + * halted in the .stop() callback through the local reset, and the .unprep= are() + * ops is invoked by the remoteproc core after the remoteproc is stopped to + * balance the global reset. + */ +int k3_rproc_unprepare(struct rproc *rproc) +{ + struct k3_rproc *kproc =3D rproc->priv; + struct device *dev =3D kproc->dev; + int ret; + + /* If the core is going to be detached do not assert the module reset */ + if (rproc->state =3D=3D RPROC_DETACHED) + return 0; + + ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) { + dev_err(dev, "module-reset assert failed\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_unprepare); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_c= ommon.h index f1fce91190128..e0909fe0578e8 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -99,4 +99,5 @@ int k3_rproc_reset(struct k3_rproc *kproc); int k3_rproc_release(struct k3_rproc *kproc); int k3_rproc_request_mbox(struct rproc *rproc); int k3_rproc_prepare(struct rproc *rproc); +int k3_rproc_unprepare(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc= /ti_k3_dsp_remoteproc.c index 0f81e7c3e798e..5099d21ce066f 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,33 +24,6 @@ =20 #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) =20 -/* - * This function implements the .unprepare() ops and performs the complime= ntary - * operations to that of the .prepare() ops. The function is used to asser= t the - * global reset on applicable C66x cores. This completes the second portio= n of - * powering down the C66x DSP cores. The cores themselves are only halted = in the - * .stop() callback through the local reset, and the .unprepare() ops is i= nvoked - * by the remoteproc core after the remoteproc is stopped to balance the g= lobal - * reset. This callback is invoked only in remoteproc mode. - */ -static int k3_dsp_rproc_unprepare(struct rproc *rproc) -{ - struct k3_rproc *kproc =3D rproc->priv; - struct device *dev =3D kproc->dev; - int ret; - - /* If the core is running already no need to deassert the module reset */ - if (rproc->state =3D=3D RPROC_DETACHED) - return 0; - - ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) - dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret)); - - return ret; -} - /* * Power up the DSP remote processor. * @@ -384,7 +357,7 @@ static int k3_dsp_rproc_probe(struct platform_device *p= dev) rproc->recovery_disabled =3D true; if (data->uses_lreset) { rproc->ops->prepare =3D k3_rproc_prepare; - rproc->ops->unprepare =3D k3_dsp_rproc_unprepare; + rproc->ops->unprepare =3D k3_rproc_unprepare; } kproc =3D rproc->priv; kproc->rproc =3D rproc; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/= ti_k3_m4_remoteproc.c index 7faa979f5caa9..6e7d78ff78941 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,35 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" =20 -/* - * This function implements the .unprepare() ops and performs the complime= ntary - * operations to that of the .prepare() ops. The function is used to asser= t the - * global reset on applicable cores. This completes the second portion of - * powering down the remote core. The cores themselves are only halted in = the - * .stop() callback through the local reset, and the .unprepare() ops is i= nvoked - * by the remoteproc core after the remoteproc is stopped to balance the g= lobal - * reset. - */ -static int k3_m4_rproc_unprepare(struct rproc *rproc) -{ - struct k3_rproc *kproc =3D rproc->priv; - struct device *dev =3D kproc->dev; - int ret; - - /* If the core is going to be detached do not assert the module reset */ - if (rproc->state =3D=3D RPROC_DETACHED) - return 0; - - ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) { - dev_err(dev, "module-reset assert failed\n"); - return ret; - } - - return 0; -} - /* * This function implements the .get_loaded_rsc_table() callback and is us= ed * to provide the resource table for a booted remote processor in IPC-only @@ -326,7 +297,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc) =20 static const struct rproc_ops k3_m4_rproc_ops =3D { .prepare =3D k3_rproc_prepare, - .unprepare =3D k3_m4_rproc_unprepare, + .unprepare =3D k3_rproc_unprepare, .start =3D k3_m4_rproc_start, .stop =3D k3_m4_rproc_stop, .attach =3D k3_m4_rproc_attach, --=20 2.34.1