From nobody Thu Sep 24 15:10:12 2026 Received: from mail-dy2-f43.google.com (mail-dy2-f43.google.com [74.125.229.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B20533E37A for ; Tue, 22 Sep 2026 19:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790104525; cv=none; b=aFeKSJPv2eV9TOvZ1P0jWMx82ldIQ1giCcHrKRwuZ5bmAjx5foODJqvExvhykJvx1nYBuEIsEiix68AynMBIS2BczSw6PHw1Tm99uG/FWseEjF6EzaOshsAVAD0w7ZZrl1JZ2AKeSvgzA1oqD8JK2h1WGvqknN9zDb2Y268b944= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790104525; c=relaxed/simple; bh=k5Qyor29tzBsTWmwWdVh29APqoc4vh744onEzj9T7Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MQGyTVbqdqx6Bna46QSfEhrSkphIQzy+a+49u7T3gp4Bf/R4QLPakv7Ep7kBokl8kciix2vfprg2T9wprk65vtFlge0sytFgL41DFwOOPJmETPsqMKJitWw93wFv09gXecBLcd3tPTnL6aLCEzpUNqvUxr4SUuHH5+4HgvvJAW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=avbrS/8T; arc=none smtp.client-ip=74.125.229.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="avbrS/8T" Received: by mail-dy2-f43.google.com with SMTP id 5a478bee46e88-33c11ef641aso186084eec.1 for ; Tue, 22 Sep 2026 12:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790104522; x=1790709322; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wpfV3RKytzyGrgL5fJq8xvrdmnsOtkjkjFMt1Pl1qgk=; b=avbrS/8TT9caeZYAIp74hjTLqF+K5Lz5nl2G24RvZJXB6jrPlJkMg2XoUlNsgrU0Tw r1YA3cilyB6ui9zsXzRsdB6y5DyGpEXrKMV0BvFIrBHgLlj7StweoxJoZs7CvdD7g7G0 WiCpo5kgVAKSJbf2kzpDRRTTZnrmhS3O0X5aMsREY2U7KYKLy495wM76cHcbqOGeyb2f 0/MjwLss8/8GitYpdGhjizH3sTYkxa6DvITZ1Ev5HQq9FdiA4APdq9R2/vILRVbqp5MU sVgJqNHLj4Dw6Z89Jifd3LKDiHizWbO3HEhwfo4u9Kez0rn00WTwQNUKJ5lPDx9V6ai8 QZvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790104522; x=1790709322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wpfV3RKytzyGrgL5fJq8xvrdmnsOtkjkjFMt1Pl1qgk=; b=Cvrbm1wFnnUNsa6fXPnt/oJVNWvpOhFGOvh/99l+tfeW4yBjbLXrSsE+VhtuY+SMr2 2wPqH+TeZRkjZQ7dHW/e7PevzY6uQvdak5jHIeTpE+JUZ9Lx2UMpsniRMs9DJe79et3O HnE7MYveI8catzoONMjpj+IyWDtIOvIWx0f/PpH7AaUqtqKp1wPt6CFjLsR/5J7meVkB YvX9O4OU4Laypsbxk7UShtor1Swt/tv6IvENre9pBj0vjMjhQhDHkulzO7snYTGQha1v Ru9wFSEE/FPYENVMmuOJFmFF7VQk07KFFMBVywoo9yBDeICBtKPsCYn+toIr/3EHwemO V7lg== X-Gm-Message-State: AFuF++kdsWCgbfiUh5of7rNvY8R0IjGhXt7g7My9CGDZqN18Rva7WvV/ N7sWmYsvFQhM7NuppaIYAxr3Juci+ANE5T3lavf5Hl2MlPlzQjQI0AwX X-Gm-Gg: AYBFou3ahieljiPckpc+K7+oWzxafnRBVwmt/DsiV20iRuJe5H8G58XX/NNyqwpHY56 QuyTpubUGbL68Pqtd1see1ozwkdxAdeiRrfECxbql5gg1qdQsg8dXCk9xCuqL0Q3T8h1JXgmvqd y1ZkJznGv8bh8Fg0NNdYBPng1I2uhiznbLIrLkoPrhJZrmnhYtzhgzTT62QbvgvdC6buhARLW3E aM9zlchtELw+RAZto6bZcQTXTQ69R/NiGVWqQ8QPJ7ACKfZmkJOx75jyG3Xec4vIfiEswY+M4lr +zsYlK9fb98rjlatkNMacr7XGRmP2HatrhvZasjik36wQUhN494U734U6fHgfc8qGO53uwuEJ+V XTVW1Fi5NR4djQ4BMVh1wsEhUIPDS6pFmncmpF3ql8wMBrqkuAP8mKWqhJPhGy15uNPO/8jU1ue hd/dpc+icooE3UYNydZUe4UQLdRFlFQv7/xrWtvTSXtNMS5s45cszycRieVXx2O9FXTBJRvq0Fz pRWkYOmnw== X-Received: by 2002:a05:7301:2e34:b0:33e:6812:29d7 with SMTP id 5a478bee46e88-33e8d9ce170mr187897eec.19.1790104522199; Tue, 22 Sep 2026 12:15:22 -0700 (PDT) Received: from nevers1dd ([118.95.161.132]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e96d497e1sm310518eec.25.2026.09.22.12.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 12:15:21 -0700 (PDT) From: Siddharth Karanam To: andersson@kernel.org, mathieu.poirier@linaro.org Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, Siddharth Karanam Subject: [PATCH 1/2] remoteproc: Add ti_sci_dev_ops abstraction Date: Wed, 23 Sep 2026 00:44:52 +0530 Message-ID: <20260922191453.324983-2-sid9.karanam@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260922191453.324983-1-sid9.karanam@gmail.com> References: <20260922191453.324983-1-sid9.karanam@gmail.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 Content-Type: text/plain; charset="utf-8" Instead of invoking ti_sci_handle's ti_sci_dev_ops member directly in the driver code, this abstracts the property read of "ti,sci-dev-id" and the function pointers supported by ti_sci_dev_ops such as is_on, get_device and put_device. The goal of the patch is to maintain a single source of origin for all ti_sci_dev_ops call sites. Any stray calls to any dev_ops function pointer members in driver code should eventually be abstracted through this header. Signed-off-by: Siddharth Karanam --- drivers/remoteproc/ti_k3_common.c | 16 ++--- drivers/remoteproc/ti_k3_common.h | 4 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 14 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 13 ++-- drivers/remoteproc/ti_k3_r5_remoteproc.c | 40 +++++------ drivers/remoteproc/ti_sci_dev.h | 82 +++++++++++++++++++++++ 6 files changed, 120 insertions(+), 49 deletions(-) create mode 100644 drivers/remoteproc/ti_sci_dev.h diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_c= ommon.c index 3cb8ae5d72f6..befa9a9bea3a 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -32,6 +32,7 @@ =20 #include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" =20 @@ -120,8 +121,7 @@ int k3_rproc_reset(struct k3_rproc *kproc) if (ret) dev_err(dev, "local-reset assert failed (%pe)\n", ERR_PTR(ret)); } else { - ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_put_device(kproc->tsd); if (ret) dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret)); } @@ -140,13 +140,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =3D reset_control_deassert(kproc->reset); if (ret) { dev_err(dev, "local-reset deassert failed, (%pe)\n", ERR_PTR(ret)); - if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id)) + if (ti_sci_dev_put_device(kproc->tsd)) dev_warn(dev, "module-reset assert back failed\n"); } } else { - ret =3D kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_get_device(kproc->tsd); if (ret) dev_err(dev, "module-reset deassert failed (%pe)\n", ERR_PTR(ret)); } @@ -223,8 +221,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } =20 - ret =3D kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_get_device(kproc->tsd); if (ret) { dev_err(dev, "could not deassert module-reset for internal RAM loading\n= "); return ret; @@ -253,8 +250,7 @@ int k3_rproc_unprepare(struct rproc *rproc) if (rproc->state =3D=3D RPROC_DETACHED) return 0; =20 - ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_put_device(kproc->tsd); if (ret) { dev_err(dev, "module-reset assert failed\n"); return ret; diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_c= ommon.h index aee3c28dbe51..7ba0903ebe0a 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -72,8 +72,8 @@ struct k3_rproc_dev_data { * @reset: reset control handle * @data: pointer to DSP-specific device data * @tsp: TI-SCI processor control handle + * @tsd: TI-SCI device control handle * @ti_sci: TI-SCI handle - * @ti_sci_id: TI-SCI device identifier * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel * @priv: void pointer to carry any private data @@ -88,8 +88,8 @@ struct k3_rproc { struct reset_control *reset; const struct k3_rproc_dev_data *data; struct ti_sci_proc *tsp; + struct ti_sci_dev *tsd; const struct ti_sci_handle *ti_sci; - u32 ti_sci_id; struct mbox_chan *mbox; struct mbox_client client; void *priv; diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc= /ti_k3_dsp_remoteproc.c index d6ceea6dc920..b6042fe7bae7 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -19,6 +19,7 @@ =20 #include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" =20 @@ -69,7 +70,6 @@ static const struct rproc_ops k3_dsp_rproc_ops =3D { static int k3_dsp_rproc_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device_node *np =3D dev->of_node; const struct k3_rproc_dev_data *data; struct k3_rproc *kproc; struct rproc *rproc; @@ -110,10 +110,6 @@ static int k3_dsp_rproc_probe(struct platform_device *= pdev) return dev_err_probe(dev, PTR_ERR(kproc->ti_sci), "failed to get ti-sci handle\n"); =20 - ret =3D of_property_read_u32(np, "ti,sci-dev-id", &kproc->ti_sci_id); - if (ret) - return dev_err_probe(dev, ret, "missing 'ti,sci-dev-id' property\n"); - kproc->reset =3D devm_reset_control_get_exclusive(dev, NULL); if (IS_ERR(kproc->reset)) return dev_err_probe(dev, PTR_ERR(kproc->reset), @@ -124,6 +120,11 @@ static int k3_dsp_rproc_probe(struct platform_device *= pdev) return dev_err_probe(dev, PTR_ERR(kproc->tsp), "failed to construct ti-sci proc control\n"); =20 + kproc->tsd =3D ti_sci_dev_of_get_tsd(dev, kproc->ti_sci); + if (IS_ERR(kproc->tsd)) + return dev_err_probe(dev, PTR_ERR(kproc->tsd), + "failed to construct ti-sci dev control\n"); + ret =3D ti_sci_proc_request(kproc->tsp); if (ret < 0) { dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); @@ -141,8 +142,7 @@ static int k3_dsp_rproc_probe(struct platform_device *p= dev) if (ret) return dev_err_probe(dev, ret, "reserved memory init failed\n"); =20 - ret =3D kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, - NULL, &p_state); + ret =3D ti_sci_dev_is_on(kproc->tsd, NULL, &p_state); if (ret) return dev_err_probe(dev, ret, "failed to get initial state, mode cannot= be determined\n"); =20 diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/= ti_k3_m4_remoteproc.c index 3a11fd24eb52..ddf8cb9974ca 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -18,6 +18,7 @@ =20 #include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" =20 @@ -70,10 +71,6 @@ static int k3_m4_rproc_probe(struct platform_device *pde= v) return dev_err_probe(dev, PTR_ERR(kproc->ti_sci), "failed to get ti-sci handle\n"); =20 - ret =3D of_property_read_u32(dev->of_node, "ti,sci-dev-id", &kproc->ti_sc= i_id); - if (ret) - return dev_err_probe(dev, ret, "missing 'ti,sci-dev-id' property\n"); - kproc->reset =3D devm_reset_control_get_exclusive(dev, NULL); if (IS_ERR(kproc->reset)) return dev_err_probe(dev, PTR_ERR(kproc->reset), "failed to get reset\n"= ); @@ -83,6 +80,11 @@ static int k3_m4_rproc_probe(struct platform_device *pde= v) return dev_err_probe(dev, PTR_ERR(kproc->tsp), "failed to construct ti-sci proc control\n"); =20 + kproc->tsd =3D ti_sci_dev_of_get_tsd(dev, kproc->ti_sci); + if (IS_ERR(kproc->tsd)) + return dev_err_probe(dev, PTR_ERR(kproc->tsd), + "failed to construct ti-sci dev control\n"); + ret =3D ti_sci_proc_request(kproc->tsp); if (ret < 0) return dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); @@ -98,8 +100,7 @@ static int k3_m4_rproc_probe(struct platform_device *pde= v) if (ret) return dev_err_probe(dev, ret, "reserved memory init failed\n"); =20 - ret =3D kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, - &r_state, &p_state); + ret =3D ti_sci_dev_is_on(kproc->tsd, &r_state, &p_state); if (ret) return dev_err_probe(dev, ret, "failed to get initial state, mode cannot be determined\n"); diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/= ti_k3_r5_remoteproc.c index b1d04d082e44..a387848ac400 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -25,6 +25,7 @@ =20 #include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" =20 @@ -140,8 +141,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc) return ret; } =20 - ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_put_device(kproc->tsd); if (ret) { dev_err(kproc->dev, "module-reset assert failed, ret =3D %d\n", ret); @@ -156,8 +156,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) { int ret; =20 - ret =3D kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_get_device(kproc->tsd); if (ret) { dev_err(kproc->dev, "module-reset deassert failed, ret =3D %d\n", ret); @@ -168,8 +167,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) if (ret) { dev_err(kproc->dev, "local-reset deassert failed, ret =3D %d\n", ret); - if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id)) + if (ti_sci_dev_put_device(kproc->tsd)) dev_warn(kproc->dev, "module-reset assert back failed\n"); } =20 @@ -196,8 +194,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *c= luster) /* disable PSC modules on all applicable cores */ list_for_each_entry(core, &cluster->cores, elem) { kproc =3D core->kproc; - ret =3D kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_put_device(kproc->tsd); if (ret) { dev_err(core->dev, "module-reset assert failed, ret =3D %d\n", ret); @@ -210,8 +207,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *c= luster) unroll_module_reset: list_for_each_entry_continue_reverse(core, &cluster->cores, elem) { kproc =3D core->kproc; - if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id)) + if (ti_sci_dev_put_device(kproc->tsd)) dev_warn(core->dev, "module-reset assert back failed\n"); } core =3D list_last_entry(&cluster->cores, struct k3_r5_core, elem); @@ -233,8 +229,7 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster = *cluster) /* enable PSC modules on all applicable cores */ list_for_each_entry_reverse(core, &cluster->cores, elem) { kproc =3D core->kproc; - ret =3D kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); + ret =3D ti_sci_dev_get_device(kproc->tsd); if (ret) { dev_err(core->dev, "module-reset deassert failed, ret =3D %d\n", ret); @@ -264,8 +259,7 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster = *cluster) unroll_module_reset: list_for_each_entry_from(core, &cluster->cores, elem) { kproc =3D core->kproc; - if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id)) + if (ti_sci_dev_put_device(kproc->tsd)) dev_warn(core->dev, "module-reset assert back failed\n"); } =20 @@ -827,8 +821,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *= kproc) =20 core0 =3D list_first_entry(&cluster->cores, struct k3_r5_core, elem); =20 - ret =3D kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, - &r_state, &c_state); + ret =3D ti_sci_dev_is_on(kproc->tsd, &r_state, &c_state); if (ret) { dev_err(cdev, "failed to get initial state, mode cannot be determined, r= et =3D %d\n", ret); @@ -1023,7 +1016,6 @@ static int k3_r5_cluster_rproc_init(struct platform_d= evice *pdev) struct device *dev =3D &pdev->dev; struct k3_rproc *kproc; struct k3_r5_core *core, *core1; - struct device_node *np; struct device *cdev; const char *fw_name; struct rproc *rproc; @@ -1032,7 +1024,6 @@ static int k3_r5_cluster_rproc_init(struct platform_d= evice *pdev) core1 =3D list_last_entry(&cluster->cores, struct k3_r5_core, elem); list_for_each_entry(core, &cluster->cores, elem) { cdev =3D core->dev; - np =3D dev_of_node(cdev); ret =3D rproc_of_parse_firmware(cdev, 0, &fw_name); if (ret) { dev_err(dev, "failed to parse firmware-name property, ret =3D %d\n", @@ -1067,12 +1058,6 @@ static int k3_r5_cluster_rproc_init(struct platform_= device *pdev) goto out; } =20 - ret =3D of_property_read_u32(np, "ti,sci-dev-id", &kproc->ti_sci_id); - if (ret) { - dev_err(cdev, "missing 'ti,sci-dev-id' property\n"); - goto out; - } - kproc->reset =3D devm_reset_control_get_exclusive(cdev, NULL); if (IS_ERR(kproc->reset)) { ret =3D dev_err_probe(cdev, PTR_ERR(kproc->reset), @@ -1087,6 +1072,13 @@ static int k3_r5_cluster_rproc_init(struct platform_= device *pdev) goto out; } =20 + kproc->tsd =3D ti_sci_dev_of_get_tsd(cdev, kproc->ti_sci); + if (IS_ERR(kproc->tsd)) { + ret =3D dev_err_probe(cdev, PTR_ERR(kproc->tsd), + "failed to construct ti-sci dev control\n"); + goto out; + } + ret =3D k3_r5_core_of_get_internal_memories(to_platform_device(cdev), kp= roc); if (ret) { dev_err(cdev, "failed to get internal memories, ret =3D %d\n", diff --git a/drivers/remoteproc/ti_sci_dev.h b/drivers/remoteproc/ti_sci_de= v.h new file mode 100644 index 000000000000..897998a97d7f --- /dev/null +++ b/drivers/remoteproc/ti_sci_dev.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Texas Instruments TI-SCI Device Controller Helper Functions + * + * Copyright (C) 2026 Texas Instruments Incorporated - https://www.ti.com/ + */ + +#ifndef REMOTEPROC_TI_SCI_DEV_H +#define REMOTEPROC_TI_SCI_DEV_H + +#include +#include + +/** + * struct ti_sci_dev - structure representing a device control client + * @sci: cached TI-SCI protocol handle + * @ops: cached TI-SCI device ops + * @dev: cached client device pointer + * @dev_id: TI-SCI device id for the consumer remoteproc device + */ +struct ti_sci_dev { + const struct ti_sci_handle *sci; + const struct ti_sci_dev_ops *ops; + struct device *dev; + u32 dev_id; +}; + +static inline +struct ti_sci_dev *ti_sci_dev_of_get_tsd(struct device *dev, + const struct ti_sci_handle *sci) +{ + struct ti_sci_dev *tsd; + int ret; + + tsd =3D devm_kzalloc(dev, sizeof(*tsd), GFP_KERNEL); + if (!tsd) + return ERR_PTR(-ENOMEM); + + ret =3D of_property_read_u32(dev_of_node(dev), "ti,sci-dev-id", + &tsd->dev_id); + if (ret < 0) + return ERR_PTR(ret); + + tsd->dev =3D dev; + tsd->sci =3D sci; + tsd->ops =3D &sci->ops.dev_ops; + + return tsd; +} + +static inline int ti_sci_dev_is_on(struct ti_sci_dev *tsd, bool *r_state, + bool *c_state) +{ + int ret; + + ret =3D tsd->ops->is_on(tsd->sci, tsd->dev_id, r_state, c_state); + if (ret) + dev_err(tsd->dev, "ti-sci device is_on failed: %d\n", ret); + return ret; +} + +static inline int ti_sci_dev_get_device(struct ti_sci_dev *tsd) +{ + int ret; + + ret =3D tsd->ops->get_device(tsd->sci, tsd->dev_id); + if (ret) + dev_err(tsd->dev, "ti-sci device get failed: %d\n", ret); + return ret; +} + +static inline int ti_sci_dev_put_device(struct ti_sci_dev *tsd) +{ + int ret; + + ret =3D tsd->ops->put_device(tsd->sci, tsd->dev_id); + if (ret) + dev_err(tsd->dev, "ti-sci device put failed: %d\n", ret); + return ret; +} + +#endif /* REMOTEPROC_TI_SCI_DEV_H */ --=20 2.55.0 From nobody Thu Sep 24 15:10:12 2026 Received: from mail-dy2-f12.google.com (mail-dy2-f12.google.com [74.125.229.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01EB34A2058 for ; Tue, 22 Sep 2026 19:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790104532; cv=none; b=Cy7utBdmEAn2oNPECABQ+ii+xdPL+fgPdtLwUF7E4UtFwjuO7IMd5lfi4Du6Uvco/d7DzXt1wUp0hpeGmM+BMIYwoBJsh9LMXo+g+Jo30RHjwtatoZBCK/wFkSSdURKUxYGgK7T4TZSfBQHAKxZiU5xCUunV0Ilnm+KqwHgVqAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790104532; c=relaxed/simple; bh=GGGrHfPUNnU7vN3InUKRrHMF5nRSvl60onh/MkaxJiQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W3wks+7RI05k5otj8vXBcOAbSmMiZrUHzsn5hlgIi8Tj4xfuq15WRVOJ3/DXINxHpTzTgFMD8a44nQDIiU4QtW2sAQLjJnzV4QZPSOKOt0TSf1qnxJGsqqVPSydcoid6WR99ew+eQ4NDMCAdSGSpYjyqsBfEMZJ52OoUplIfcaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=raZq2TV5; arc=none smtp.client-ip=74.125.229.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="raZq2TV5" Received: by mail-dy2-f12.google.com with SMTP id 5a478bee46e88-328664ef78fso79662eec.2 for ; Tue, 22 Sep 2026 12:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790104530; x=1790709330; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qphYHRO7sCmm53m8nDFwegl6mi2o4Xt3NOVldHfpRrE=; b=raZq2TV5rREXb9pxtJTj407/2OXizaZdAidN1MXQr9JjjmJ2uDiMHC0OLxNw8gom3/ RBjq2hcSTamUKlvx0IhB7h8bV4E/Ej8DkH2TNzKalSf977SKsnIHtP+A/huTfmisePN6 eWTszahDhl+L+3tPfqUOCwqjYU9Xa00cGlvdm0p7UsFyRuUNuRUmY4k6Gl8/ZGHQa4RJ WnzoFkJYDQOVInnTHVSOMsbi1lDIft9N11PRmXxWhU3DcFyT/ZzWSdwnCo4ukVxMvFQI Rmb9VXXoPmOC8XYcBJ9QeWypJMqhvRxI5bVo/RQ4SvLVG/ul1XraHWuncoo/rfBfJHq+ Y2EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790104530; x=1790709330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qphYHRO7sCmm53m8nDFwegl6mi2o4Xt3NOVldHfpRrE=; b=BWLE+48f8hmD42WVS+T1cRzCtGdRZGxYHmkmp8vjo78wB6cZ3+1ixBp64a4jD5Xy1I EF/E0ClMQDZgiQ0vWwC5hzOA9QGtgJQ7eDFcdSIy2rgGZjk4P2F4DX2eqZs8BkeTxmwo LnrJ4R2IWJxE/nVxkusDsGvTBYQ78FIy+k05uqw9buYCDvWvzYEtTNyuujjQwddrWGnS eYkXSJZLLviSDpzi88RubZ8gj3whKrwrl5wTjX0v1T8It4X3imEMA4UGfXjOlgDlbOOe Whm9y4Pr3VVuKiWryPjOW9Cgpg2Qt+NGilVziB/5Q1oyTqERXluV3EcMjL3VlaQKlA6z JvDg== X-Gm-Message-State: AFuF++mdpjkv7VbL3GLYq8DEPaXQuEhAhQBqDt7M3KYhukbgfPn4lUYs 3kwPNNEmR/TxvKuWjcfepHp1HuEr3BjOiEghGLslSVbsZzhbB7ER51ZV X-Gm-Gg: AYBFou1qNHMBYgwbk22TP3oX7STK/yIPSeS3akLc18XUpVARqQfFEl7H0gGzsVn4MH5 oELPGIHpeTXBh/nn8yTmMJZMOma80+31JTyVLFG3DfskUeK/ngcC1sTgsLoySLwQVnSpzwqyWDX h/YQDs+nYVxb3J21WaIwpgojn6WhjwE3OSwRgx4XrZIZ8tFTM+4w9/rvuO51gXsEvvJ3SPcTQKY AZooaZWnPzTaJvfRKzUJupViTddxEmYcgoIkkFjM3dMptb6RsXc1LuhVq0ZL80I3k7yToxcy7PS CMPlbfQ1vlGD5xHZesomMglOmKvbrrdVdlxcBIPvHyqHyleJgUZ+6VTh7sxD4EWhMuVqWXjzSwL CVF9YHQtxJ5Zi94j7FJ3LkeZpB+pkyjO+9pQzP6bKyob4hu4HPZAWrc5dY2Qj8WIR2UCFeBvM46 Mih1LdMbza92lMaUBxRpa4yXhO3iO6XMb4loKlHhn5HQ74wJTboY7KfeGbtVXRJa6KZjNOe3fVK uqy9EKyFw== X-Received: by 2002:a05:7300:c3a4:b0:33b:e264:362a with SMTP id 5a478bee46e88-33e8c24d878mr232313eec.13.1790104529788; Tue, 22 Sep 2026 12:15:29 -0700 (PDT) Received: from nevers1dd ([118.95.161.132]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33e96d497e1sm310518eec.25.2026.09.22.12.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 12:15:29 -0700 (PDT) From: Siddharth Karanam To: andersson@kernel.org, mathieu.poirier@linaro.org Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, Siddharth Karanam Subject: [PATCH 2/2] remoteproc: k3: Abstract ti_sci_handle's dev_ops calls through pm_runtime Date: Wed, 23 Sep 2026 00:44:53 +0530 Message-ID: <20260922191453.324983-3-sid9.karanam@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260922191453.324983-1-sid9.karanam@gmail.com> References: <20260922191453.324983-1-sid9.karanam@gmail.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 Content-Type: text/plain; charset="utf-8" Instead of directly invoking ti_sci_handle->dev_ops.get_device / put_device (that is direct firmware logic), it is better to abstract it through linux/pm_runtime.h's pm_runtime_put/get_sync which will call the vendor's specific firmware logic automatically. The rationale here being better code quality and reduced scope for refactoring in case of any changes to the ti_sci protocol. Signed-off-by: Siddharth Karanam --- drivers/remoteproc/ti_sci_dev.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/ti_sci_dev.h b/drivers/remoteproc/ti_sci_de= v.h index 897998a97d7f..ec17af3ebf5e 100644 --- a/drivers/remoteproc/ti_sci_dev.h +++ b/drivers/remoteproc/ti_sci_dev.h @@ -59,23 +59,30 @@ static inline int ti_sci_dev_is_on(struct ti_sci_dev *t= sd, bool *r_state, return ret; } =20 +/* Request power on to rproc through the TI-SCI PM domain */ static inline int ti_sci_dev_get_device(struct ti_sci_dev *tsd) { - int ret; + int ret =3D 0; + + ret =3D pm_runtime_get_sync(tsd->dev); + if (ret < 0) { + dev_err(tsd->dev, "pm_runtime_get_sync failed, ret =3D %d\n", ret); + pm_runtime_put_noidle(tsd->dev); + } =20 - ret =3D tsd->ops->get_device(tsd->sci, tsd->dev_id); - if (ret) - dev_err(tsd->dev, "ti-sci device get failed: %d\n", ret); return ret; } =20 +/* Request power off to a rproc through the TI-SCI PM domain */ static inline int ti_sci_dev_put_device(struct ti_sci_dev *tsd) { - int ret; + int ret =3D 0; + + ret =3D pm_runtime_put_sync(tsd->dev); + + if (ret < 0) + dev_err(tsd->dev, "pm_runtime_put_sync failed, ret =3D %d\n", ret); =20 - ret =3D tsd->ops->put_device(tsd->sci, tsd->dev_id); - if (ret) - dev_err(tsd->dev, "ti-sci device put failed: %d\n", ret); return ret; } =20 --=20 2.55.0