remoteproc: Merge ti_sci_dev and ti_sci_proc abstraction
v2 cover remoteproc: Merge ti_sci_dev and ti_sci_proc abstraction
The previous version of the patch had a new header ti_sci_dev.h, that mirrors ti_sci_proc.h in terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members like ti_sci_dev_ops from being invoked directly in the driver code.
Lore link to the v1 patch:
https://lore.kernel.org/all/[email protected]/
Upon discussing in the original patch thread, it seemed better to combine ti_sci_proc.h and ti_sci_dev.h's structs and merge all their helpers into a single header. That is what ti_sci_ctrl.h aims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed with ti_sci_ctrl_dev and ti_sci_ctrl_proc respectively.
The goal of the patch (v2) is to maintain a single source of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header (ti_sci_ctrl.h).
In the future we can try to abstract tsd's dev_ops even further through pm_runtime, but there are some roadblocks that I am unaware of, so that warranties a different patch.
Siddharth Karanam (2):
remoteproc: Add ti_sci_dev_ops abstraction
remoteproc: Merge ti_sci_dev and ti_sci_proc abstraction
drivers/remoteproc/ti_k3_common.c | 21 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 23 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 66 +++----- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 7 files changed, 231 insertions(+), 218 deletions(-) create mode 100644 drivers/remoteproc/ti_sci_ctrl.h delete mode 100644 drivers/remoteproc/ti_sci_proc.h
Signature · 1 line
2.55.0
PATCH v2 1/2 remoteproc: Add ti_sci_dev_ops abstraction
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.
--- 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
drivers/remoteproc/ti_k3_common.c +6 -10
@@ -32,6 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h"
@@ -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 = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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 =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 = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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) } } - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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 ==RPROC_DETACHED )return 0 ; - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;
drivers/remoteproc/ti_k3_common.h +2 -2
@@ -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;
drivers/remoteproc/ti_k3_dsp_remoteproc.c +7 -7
@@ -19,6 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h"
@@ -69,7 +70,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = {static int k3_dsp_rproc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *np = 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" ); - ret =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 =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" ); + kproc->tsd =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 =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 *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, -NULL , &p_state); + ret =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" );
drivers/remoteproc/ti_k3_m4_remoteproc.c +7 -6
@@ -18,6 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h"
@@ -70,10 +71,6 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->ti_sci),"failed to get ti-sci handle\n" ); - ret =of_property_read_u32 (dev->of_node,"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 =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 *pdev)return dev_err_probe (dev,PTR_ERR (kproc->tsp),"failed to construct ti-sci proc control\n" ); + kproc->tsd =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 =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 *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, - &r_state, &p_state); + ret =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" );
drivers/remoteproc/ti_k3_r5_remoteproc.c +16 -24
@@ -25,6 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h"
@@ -140,8 +141,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);
@@ -156,8 +156,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_get_device (kproc->tsd);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %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 = %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" ); }
@@ -196,8 +194,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);
@@ -210,8 +207,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = 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 = 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 = core->kproc; - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_get_device (kproc->tsd);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %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 = 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" ); }
@@ -827,8 +821,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, - &r_state, &c_state); + ret =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, ret = %d\n" , ret);
@@ -1023,7 +1016,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)struct device *dev = &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_device *pdev) core1 = list_last_entry(&cluster->cores, struct k3_r5_core, elem);list_for_each_entry (core, &cluster->cores, elem) { cdev = core->dev; - np =dev_of_node (cdev); ret =rproc_of_parse_firmware (cdev,0 , &fw_name);if (ret) { dev_err(dev, "failed to parse firmware-name property, ret = %d\n",
@@ -1067,12 +1058,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =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 =devm_reset_control_get_exclusive (cdev,NULL );if (IS_ERR (kproc->reset)) { ret = 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; } + kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsd)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), +"failed to construct ti-sci dev control\n" ); + goto out; + } + ret =k3_r5_core_of_get_internal_memories (to_platform_device (cdev), kproc);if (ret) { dev_err(cdev, "failed to get internal memories, ret = %d\n",
drivers/remoteproc/ti_sci_dev.h new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH v2 1/2] remoteproc: Add ti_sci_dev_ops abstraction
Quoted 344 lines · Siddharth Karanam
Instead of invoking ti_sci_handle's
ti_sci_dev_opsmember directly in the driver code, this abstracts the property read of "ti,sci-dev-id" and the function pointers supported byti_sci_dev_opssuch asis_on,get_deviceandput_device.The goal of the patch is to maintain a single source of origin for all
ti_sci_dev_opscall sites. Any stray calls to anydev_opsfunction pointer members in driver code should eventually be abstracted through this header.Signed-off-by Siddharth Karanam <[email protected]>--- 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.hdrivers/remoteproc/ti_k3_common.c +6
-10@@ -32,6 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -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 = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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 =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 = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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) } } - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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 ==RPROC_DETACHED )return 0 ; - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.h +2
-2@@ -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;drivers/remoteproc/ti_k3_dsp_remoteproc.c +7
-7@@ -19,6 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -69,7 +70,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = {static int k3_dsp_rproc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *np = 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" ); - ret =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 =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" ); + kproc->tsd =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 =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 *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, -NULL , &p_state); + ret =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" );drivers/remoteproc/ti_k3_m4_remoteproc.c +7
-6@@ -18,6 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -70,10 +71,6 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->ti_sci),"failed to get ti-sci handle\n" ); - ret =of_property_read_u32 (dev->of_node,"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 =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 *pdev)return dev_err_probe (dev,PTR_ERR (kproc->tsp),"failed to construct ti-sci proc control\n" ); + kproc->tsd =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 =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 *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, - &r_state, &p_state); + ret =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" );drivers/remoteproc/ti_k3_r5_remoteproc.c +16
-24@@ -25,6 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -140,8 +141,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,8 +156,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_get_device (kproc->tsd);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %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 = %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" ); }@@ -196,8 +194,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -210,8 +207,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = 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 = 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 = core->kproc; - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_get_device (kproc->tsd);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %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 = 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" ); }@@ -827,8 +821,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, - &r_state, &c_state); + ret =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, ret = %d\n" , ret);@@ -1023,7 +1016,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)struct device *dev = &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_device *pdev) core1 = list_last_entry(&cluster->cores, struct k3_r5_core, elem);list_for_each_entry (core, &cluster->cores, elem) { cdev = core->dev; - np =dev_of_node (cdev); ret =rproc_of_parse_firmware (cdev,0 , &fw_name);if (ret) { dev_err(dev, "failed to parse firmware-name property, ret = %d\n",@@ -1067,12 +1058,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =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 =devm_reset_control_get_exclusive (cdev,NULL );if (IS_ERR (kproc->reset)) { ret = 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; } + kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsd)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), +"failed to construct ti-sci dev control\n" ); + goto out; + } + ret =k3_r5_core_of_get_internal_memories (to_platform_device (cdev), kproc);if (ret) { dev_err(cdev, "failed to get internal memories, ret = %d\n",drivers/remoteproc/ti_sci_dev.h new file +2
-0@@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/*
drivers/remoteproc/ti_sci_dev.h line 12
Quoted 10 lines
drivers/remoteproc/ti_sci_dev.h new file +10
-0+* 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 <linux/soc/ti/ti_sci_protocol.h> +#include <linux/pm_runtime.h>
Unnecessary header.
Quoted 36 lines
drivers/remoteproc/ti_sci_dev.h new file +36
-0+ +/** +* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); +if (!tsd) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsd->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + tsd->dev = dev; + tsd->sci = sci; + tsd->ops = &sci->ops.dev_ops; + +return tsd;
drivers/remoteproc/ti_sci_dev.h line 58
Quoted 10 lines
drivers/remoteproc/ti_sci_dev.h new file +10
-0+} + +static inline int ti_sci_dev_is_on (struct ti_sci_dev *tsd,bool *r_state, +bool *c_state) +{ +int ret; + + ret = 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);
New line before return statement.
Thanks,
Beleswar
Quoted 24 lines
drivers/remoteproc/ti_sci_dev.h new file +24
-0+ return ret; +} + +static inline int ti_sci_dev_get_device (struct ti_sci_dev *tsd) +{ +int ret; + + ret = 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 = 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 */
Re: [PATCH v2 1/2] remoteproc: Add ti_sci_dev_ops abstraction
In reply to Siddharth KaranamAlso, in both the patches, please add k3 prefix in $Subject-line.
Something like: "remoteproc: k3: Add ti_sci_dev_ops abstraction"
Thanks,
Beleswar
Quoted 424 lines · Siddharth Karanam
Instead of invoking ti_sci_handle's
ti_sci_dev_opsmember directly in the driver code, this abstracts the property read of "ti,sci-dev-id" and the function pointers supported byti_sci_dev_opssuch asis_on,get_deviceandput_device.The goal of the patch is to maintain a single source of origin for all
ti_sci_dev_opscall sites. Any stray calls to anydev_opsfunction pointer members in driver code should eventually be abstracted through this header.Signed-off-by Siddharth Karanam <[email protected]>--- 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.hdrivers/remoteproc/ti_k3_common.c +6
-10@@ -32,6 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -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 = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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 =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 = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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) } } - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =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 ==RPROC_DETACHED )return 0 ; - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.h +2
-2@@ -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;drivers/remoteproc/ti_k3_dsp_remoteproc.c +7
-7@@ -19,6 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -69,7 +70,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = {static int k3_dsp_rproc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *np = 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" ); - ret =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 =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" ); + kproc->tsd =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 =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 *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, -NULL , &p_state); + ret =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" );drivers/remoteproc/ti_k3_m4_remoteproc.c +7
-6@@ -18,6 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -70,10 +71,6 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->ti_sci),"failed to get ti-sci handle\n" ); - ret =of_property_read_u32 (dev->of_node,"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 =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 *pdev)return dev_err_probe (dev,PTR_ERR (kproc->tsp),"failed to construct ti-sci proc control\n" ); + kproc->tsd =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 =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 *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, - &r_state, &p_state); + ret =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" );drivers/remoteproc/ti_k3_r5_remoteproc.c +16
-24@@ -25,6 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" +#include "ti_sci_dev.h" #include "ti_sci_proc.h" #include "ti_k3_common.h" @@ -140,8 +141,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,8 +156,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_get_device (kproc->tsd);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %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 = %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" ); }@@ -196,8 +194,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_put_device (kproc->tsd);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -210,8 +207,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = 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 = 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 = core->kproc; - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); + ret =ti_sci_dev_get_device (kproc->tsd);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %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 = 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" ); }@@ -827,8 +821,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, - &r_state, &c_state); + ret =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, ret = %d\n" , ret);@@ -1023,7 +1016,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)struct device *dev = &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_device *pdev) core1 = list_last_entry(&cluster->cores, struct k3_r5_core, elem);list_for_each_entry (core, &cluster->cores, elem) { cdev = core->dev; - np =dev_of_node (cdev); ret =rproc_of_parse_firmware (cdev,0 , &fw_name);if (ret) { dev_err(dev, "failed to parse firmware-name property, ret = %d\n",@@ -1067,12 +1058,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =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 =devm_reset_control_get_exclusive (cdev,NULL );if (IS_ERR (kproc->reset)) { ret = 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; } + kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsd)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), +"failed to construct ti-sci dev control\n" ); + goto out; + } + ret =k3_r5_core_of_get_internal_memories (to_platform_device (cdev), kproc);if (ret) { dev_err(cdev, "failed to get internal memories, ret = %d\n",drivers/remoteproc/ti_sci_dev.h new file +82
-0@@ -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 <linux/soc/ti/ti_sci_protocol.h> +#include <linux/pm_runtime.h> + +/** +* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); +if (!tsd) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsd->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + tsd->dev = dev; + tsd->sci = sci; + tsd->ops = &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 = 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 = 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 = 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 */
PATCH v2 2/2 remoteproc: Merge ti_sci_dev and ti_sci_proc abstraction
In reply to Siddharth KaranamThe previous version of the patch had a new header ti_sci_dev.h, that mirrors ti_sci_proc.h in terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members like ti_sci_dev_ops from being invoked directly in the driver code.
Upon discussing in the original patch thread, it seemed better to combine ti_sci_proc.h and ti_sci_dev.h's structs and merge all their helpers into a single header. That is what ti_sci_ctrl.h aims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed with ti_sci_ctrl_dev and ti_sci_ctrl_proc respectively.
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.
In the future we can try to abstract tsd's dev_ops even further through pm_runtime, but there are some roadblocks that I am unaware of, so that warranties a different patch.
--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-) create mode 100644 drivers/remoteproc/ti_sci_ctrl.h delete mode 100644 drivers/remoteproc/ti_sci_dev.h delete mode 100644 drivers/remoteproc/ti_sci_proc.h
drivers/remoteproc/ti_k3_common.c +8 -9
@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /**
@@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }
@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }
@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;
@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;
@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data) { -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);
drivers/remoteproc/ti_k3_common.h +2 -4
@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel
@@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;
drivers/remoteproc/ti_k3_dsp_remoteproc.c +10 -16
@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /*
@@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;
@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;
@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );
drivers/remoteproc/ti_k3_m4_remoteproc.c +9 -15
@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {
@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;
@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );
drivers/remoteproc/ti_k3_r5_remoteproc.c +25 -33
188 lines not on this page · raw message
drivers/remoteproc/ti_sci_ctrl.h new file +177 -0
177 lines not on this page · raw message
drivers/remoteproc/ti_sci_dev.h deleted +0 -82
82 lines not on this page · raw message
drivers/remoteproc/ti_sci_proc.h deleted +0 -130
130 lines not on this page · raw message
Signature · 1 line
2.55.0
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.
Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.
You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 8 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks that
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;
drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)
Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. *
drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);
Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis
259 +#374: FILE: drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc, &boot_vec, &cfg, &ctrl, 261 + &stat);
Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }
drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);
s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0
drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions
Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +
drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;
Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;
Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}
drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
Beleswar
Quoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Quoted 2 lines
You can put this changelog in diffstat. We may not need this info in commit message.
I have mentioned what v1 was about and the changes this brings as Andrew told me to do so (I had unfortunately replied only to him so I think other members were not able to view that, so he recommended that I mention that in the cover letter).
Quoted 2 lines
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Sure thing.
Quoted 3 lines
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
No problem, I'll fix those issues.
Thanks,
Siddharth
Quoted 913 lines · Beleswar
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 8 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks thatSince a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. * drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis 259 +#374: FILE:
drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc,&boot_vec, &cfg, &ctrl,
261 + &stat);Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
BeleswarQuoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Quoted 6 lines · Sidd
Quoted 2 lines
You can put this changelog in diffstat. We may not need this info in commit message.
I have mentioned what v1 was about and the changes this brings as Andrew told me to do so (I had unfortunately replied only to him so I think other members were not able to view that, so he recommended that I mention that in the cover letter).
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Example of changelog in cover-letter:
https://lore.kernel.org/all/[email protected]/
Example of changelog in patch diffstat:
https://lore.kernel.org/all/[email protected]/
Thanks,
Beleswar
Quoted 916 lines
Quoted 3 lines
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Sure thing.
Quoted 3 lines
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
No problem, I'll fix those issues.
Thanks,
SiddharthQuoted 902 lines · Beleswar
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 7 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks thatSince a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. * drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis 259 +#374: FILE:
drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc,&boot_vec, &cfg, &ctrl,
261 + &stat);Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
BeleswarQuoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Quoted 5 lines
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Oh right so I don't need to mention the "original thread" related text in the commit message right (just the cover letter)?
Thanks,
Siddharth
Quoted 942 lines · Beleswar Prasad Padhi
Quoted 6 lines · Sidd
Quoted 2 lines
You can put this changelog in diffstat. We may not need this info in commit message.
I have mentioned what v1 was about and the changes this brings as Andrew told me to do so (I had unfortunately replied only to him so I think other members were not able to view that, so he recommended that I mention that in the cover letter).
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Example of changelog in cover-letter:
https://lore.kernel.org/all/[email protected]/Example of changelog in patch diffstat:
https://lore.kernel.org/all/[email protected]/Thanks,
BeleswarQuoted 916 lines
Quoted 3 lines
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Sure thing.
Quoted 3 lines
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
No problem, I'll fix those issues.
Thanks,
SiddharthQuoted 902 lines · Beleswar
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 7 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks thatSince a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. * drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis 259 +#374: FILE:
drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc,&boot_vec, &cfg, &ctrl,
261 + &stat);Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
BeleswarQuoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Quoted 7 lines · Sidd
Quoted 5 lines
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Oh right so I don't need to mention the "original thread" related text in the commit message right (just the cover letter)?
Yes exactly.
Thanks,
Beleswar
Quoted 935 lines
Thanks,
SiddharthQuoted 930 lines · Beleswar Prasad Padhi
Quoted 6 lines · Sidd
Quoted 2 lines
You can put this changelog in diffstat. We may not need this info in commit message.
I have mentioned what v1 was about and the changes this brings as Andrew told me to do so (I had unfortunately replied only to him so I think other members were not able to view that, so he recommended that I mention that in the cover letter).
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Example of changelog in cover-letter:
https://lore.kernel.org/all/[email protected]/Example of changelog in patch diffstat:
https://lore.kernel.org/all/[email protected]/Thanks,
BeleswarQuoted 906 lines
Quoted 2 lines
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Sure thing.
Quoted 3 lines
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
No problem, I'll fix those issues.
Thanks,
SiddharthQuoted 893 lines · Beleswar
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 7 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks thatSince a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. * drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis 259 +#374: FILE:
drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc,&boot_vec, &cfg, &ctrl,
261 + &stat);Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
BeleswarQuoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Quoted 1 line
Function needs to be renamed.
I assume that you are talking about k3_release_tsp right? If so then my reasoning for not renaming the function is that logically it is still only calling proc_ops->set_config(...), just through an abstraction via ti_sci_ctrl's helper instead. Do I still need to rename the function to something like k3_release_tsc instead?
Thanks,
Siddharth
Quoted 952 lines · Beleswar
Quoted 7 lines · Sidd
Quoted 5 lines
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Oh right so I don't need to mention the "original thread" related text in the commit message right (just the cover letter)?
Yes exactly.
Thanks,
BeleswarQuoted 935 lines
Thanks,
SiddharthQuoted 930 lines · Beleswar Prasad Padhi
Quoted 6 lines · Sidd
Quoted 2 lines
You can put this changelog in diffstat. We may not need this info in commit message.
I have mentioned what v1 was about and the changes this brings as Andrew told me to do so (I had unfortunately replied only to him so I think other members were not able to view that, so he recommended that I mention that in the cover letter).
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Example of changelog in cover-letter:
https://lore.kernel.org/all/[email protected]/Example of changelog in patch diffstat:
https://lore.kernel.org/all/[email protected]/Thanks,
BeleswarQuoted 906 lines
Quoted 2 lines
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Sure thing.
Quoted 3 lines
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
No problem, I'll fix those issues.
Thanks,
SiddharthQuoted 893 lines · Beleswar
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 7 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks thatSince a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. * drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis 259 +#374: FILE:
drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc,&boot_vec, &cfg, &ctrl,
261 + &stat);Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
BeleswarQuoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Quoted 6 lines · Sidd
Quoted 1 line
Function needs to be renamed.
I assume that you are talking about
k3_release_tspright? If so then my reasoning for not renaming the function is that logically it is still only callingproc_ops->set_config(...), just through an abstraction via ti_sci_ctrl's helper instead. Do I still need to rename the function to something likek3_release_tscinstead?
Yes please do rename. It matches the prefix with all other similar functions.
Thanks,
Beleswar
Quoted 952 lines
Thanks,
SiddharthQuoted 947 lines · Beleswar
Quoted 7 lines · Sidd
Quoted 5 lines
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Oh right so I don't need to mention the "original thread" related text in the commit message right (just the cover letter)?
Yes exactly.
Thanks,
BeleswarQuoted 932 lines
Thanks,
SiddharthQuoted 928 lines · Beleswar Prasad Padhi
Quoted 6 lines · Sidd
Quoted 2 lines
You can put this changelog in diffstat. We may not need this info in commit message.
I have mentioned what v1 was about and the changes this brings as Andrew told me to do so (I had unfortunately replied only to him so I think other members were not able to view that, so he recommended that I mention that in the cover letter).
Yes this information is good to mention in cover-letter and diffstat section of patches. But you have mentioned it in the commit message of the patch which lives forever in the tree after merge. Cover-letters and texts in diffstat section are not merged into tree and are just archived in lore if you want to get back to it someday.
Example of changelog in cover-letter:
https://lore.kernel.org/all/[email protected]/Example of changelog in patch diffstat:
https://lore.kernel.org/all/[email protected]/Thanks,
BeleswarQuoted 906 lines
Quoted 2 lines
Since a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Sure thing.
Quoted 3 lines
Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
No problem, I'll fix those issues.
Thanks,
SiddharthQuoted 893 lines · Beleswar
Hi Siddharth,
Quoted 6 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Quoted 7 lines
Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.You can put this changelog in diffstat. We may not need this info in commit message.
Quoted 7 lines
The goal of the patch is to maintain a single source
of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header.In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks thatSince a RFC is posted, you can drop this part of the text and just mention we could switch to pm runtime calls in the future.
Quoted 73 lines
I am unaware of, so that warranties a different patch.
Signed-off-by Siddharth Karanam <[email protected]>--- drivers/remoteproc/ti_k3_common.c | 17 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 58 +++---- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_dev.h | 82 ---------- drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 8 files changed, 231 insertions(+), 289 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_dev.hdelete mode 100644drivers/remoteproc/ti_sci_proc.hdrivers/remoteproc/ti_k3_common.c +6
-7@@ -32,8 +32,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /** @@ -121,7 +120,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 =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret)dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -140,11 +139,11 @@ int k3_rproc_release(struct k3_rproc *kproc) ret =reset_control_deassert (kproc->reset);if (ret) {dev_err (dev,"local-reset deassert failed, (%pe)\n" ,ERR_PTR (ret)); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (dev,"module-reset assert back failed\n" ); } }else { - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret)dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }@@ -221,7 +220,7 @@ int k3_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (dev,"could not deassert module-reset for internal RAM loading\n" );return ret;@@ -250,7 +249,7 @@ int k3_rproc_unprepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (dev,"module-reset assert failed\n" );return ret;drivers/remoteproc/ti_k3_common.c EXPORT_SYMBOL_GPL(k3_reserved_mem_init); · line 528
Quoted 2 lines
drivers/remoteproc/ti_k3_common.c +0
-0@@ -528,9 +527,9 @@ EXPORT_SYMBOL_GPL(k3_reserved_mem_init);void k3_release_tsp (void *data)Function needs to be renamed.
Quoted 267 lines
drivers/remoteproc/ti_k3_common.c +2
-2{ -struct ti_sci_proc *tsp = data; +struct ti_sci_ctrl *tsc = data; -ti_sci_proc_release (tsp); +ti_sci_ctrl_proc_release (tsc); }EXPORT_SYMBOL_GPL (k3_release_tsp);drivers/remoteproc/ti_k3_common.h +2
-4@@ -71,8 +71,7 @@ struct k3_rproc_dev_data {* @num_rmems: number of reserved memory regions * @reset: reset control handle * @data: pointer to DSP-specific device data -* @tsp: TI-SCI processor control handle -* @tsd: TI-SCI device control handle +* @tsc: TI-SCI control handle * @ti_sci: TI-SCI handle * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel @@ -87,8 +86,7 @@ struct k3_rproc {int num_rmems;struct reset_control *reset;const struct k3_rproc_dev_data *data; -struct ti_sci_proc *tsp; -struct ti_sci_dev *tsd; +struct ti_sci_ctrl *tsc;const struct ti_sci_handle *ti_sci;struct mbox_chan *mbox;struct mbox_client client;drivers/remoteproc/ti_k3_dsp_remoteproc.c +10
-16@@ -19,8 +19,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* @@ -45,7 +44,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) }dev_dbg (dev,"booting DSP core using boot addr = 0x%x\n" , boot_addr); - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -115,22 +114,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to get construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) { -dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); +dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -142,7 +136,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd,NULL , &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc,NULL , &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_m4_remoteproc.c +9
-15@@ -18,8 +18,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" static const struct rproc_ops k3_m4_rproc_ops = {@@ -75,20 +74,15 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (IS_ERR (kproc->reset))return dev_err_probe (dev,PTR_ERR (kproc->reset),"failed to get reset\n" ); - kproc->tsp =ti_sci_proc_of_get_tsp (dev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) -return dev_err_probe (dev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (dev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) +return dev_err_probe (dev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); - kproc->tsd =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 =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) -return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp); +return dev_err_probe (dev, ret,"ti_sci_ctrl_proc_request failed\n" ); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsc);if (ret)return ret;@@ -100,7 +94,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"reserved memory init failed\n" ); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &p_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &p_state);if (ret)return dev_err_probe (dev, ret,"failed to get initial state, mode cannot be determined\n" );drivers/remoteproc/ti_k3_r5_remoteproc.c +13
-14@@ -25,8 +25,7 @@#include "omap_remoteproc.h" #include "remoteproc_internal.h" -#include "ti_sci_dev.h" -#include "ti_sci_proc.h" +#include "ti_sci_ctrl.h" #include "ti_k3_common.h" /* This address can either be for ATCM or BTCM with the other at address 0x0 */ @@ -141,7 +140,7 @@ static int k3_r5_split_reset(struct k3_rproc *kproc)return ret; } - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -156,7 +155,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc) {int ret; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -167,7 +166,7 @@ static int k3_r5_split_release(struct k3_rproc *kproc)if (ret) {dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (kproc->dev,"module-reset assert back failed\n" ); }@@ -194,7 +193,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)/* disable PSC modules on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { kproc = core->kproc; - ret =ti_sci_dev_put_device (kproc->tsd); + ret =ti_sci_ctrl_dev_put_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);@@ -207,7 +206,7 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { kproc = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem);@@ -229,7 +228,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 = core->kproc; - ret =ti_sci_dev_get_device (kproc->tsd); + ret =ti_sci_ctrl_dev_get_device (kproc->tsc);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);@@ -259,7 +258,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 = core->kproc; -if (ti_sci_dev_put_device (kproc->tsd)) +if (ti_sci_ctrl_dev_put_device (kproc->tsc))dev_warn (core->dev,"module-reset assert back failed\n" ); }@@ -268,13 +267,13 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)static inline int k3_r5_core_halt (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); }static inline int k3_r5_core_run (struct k3_rproc *kproc) { -return ti_sci_proc_set_control (kproc->tsp, +return ti_sci_ctrl_proc_set_control (kproc->tsc,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }@@ -328,7 +327,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );@@ -469,7 +468,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)dev_dbg (dev,"booting R5F core using boot addr = 0x%x\n" , boot_addr);/* boot vector need not be programmed for Core1 in LockStep mode */ - ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 ); + ret =ti_sci_ctrl_proc_set_config (kproc->tsc, boot_addr,0 ,0 );if (ret)return ret;@@ -612,7 +611,7 @@ static const struct rproc_ops k3_r5_rproc_ops = {* by the System Processor. * * This function is used to pre-configure these settings for each R5F core, and -* the configuration is all done through various ti_sci_proc functions that +* the configuration is all done through various ti_sci_ctrl functions that * communicate with the System Processor. The function also ensures that both * the cores are halted before the .prepare() step. * drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_rproc_configure(struct k3_rproc *kproc) · line 657
Quoted 6 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -654,7 +653,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) core = kproc->priv; } - ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (core->kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);Here and everywhere else, fix the parantheses alignment:
258 +CHECK: Alignment should match open parenthesis 259 +#374: FILE:
drivers/remoteproc/ti_k3_r5_remoteproc.c:652:
260 ++ ret = ti_sci_ctrl_proc_get_status(core->kproc->tsc,&boot_vec, &cfg, &ctrl,
261 + &stat);Quoted 69 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +9
-16if (ret <0 )return ret;@@ -732,7 +731,7 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg &= ~PROC_BOOT_CFG_FLAG_R5_TEINIT ; } - ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (temp->kproc->tsc, boot_vec, set_cfg, clr_cfg);if (ret) goto out;@@ -740,14 +739,14 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }else { ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, + ret =ti_sci_ctrl_proc_set_config (core->kproc->tsc, boot_vec, set_cfg, clr_cfg); }@@ -821,7 +820,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret =ti_sci_dev_is_on (kproc->tsd, &r_state, &c_state); + ret =ti_sci_ctrl_dev_is_on (kproc->tsc, &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);@@ -845,7 +844,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_ctrl_proc_get_status (kproc->tsc, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",@@ -1065,17 +1064,10 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - kproc->tsp =ti_sci_proc_of_get_tsp (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsp)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsp), -"failed to construct ti-sci proc control\n" ); - goto out; - } - - kproc->tsd =ti_sci_dev_of_get_tsd (cdev, kproc->ti_sci); -if (IS_ERR (kproc->tsd)) { - ret =dev_err_probe (cdev,PTR_ERR (kproc->tsd), -"failed to construct ti-sci dev control\n" ); + kproc->tsc =ti_sci_ctrl_of_get (cdev, kproc->ti_sci); +if (IS_ERR (kproc->tsc)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->tsc), +"failed to construct ti-sci control\n" ); goto out; }drivers/remoteproc/ti_k3_r5_remoteproc.c static int k3_r5_cluster_rproc_init(struct platform_device *pdev) · line 1083
Quoted 7 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1@@ -1086,13 +1078,13 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =ti_sci_proc_request (kproc->tsp); + ret =ti_sci_ctrl_proc_request (kproc->tsc);if (ret <0 ) {dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret);s/ti_sci_proc_request/ti_sci_ctrl_proc_request
Quoted 14 lines
drivers/remoteproc/ti_k3_r5_remoteproc.c +1
-1goto out; } - ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsc);if (ret) goto out; }drivers/remoteproc/ti_sci_ctrl.h new file +0
-0drivers/remoteproc/ti_sci_ctrl.h line 3
Quoted 3 lines
drivers/remoteproc/ti_sci_ctrl.h new file +3
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Texas Instruments TI-SCI Processor Controller Helper Functions Processor and Device
Quoted 70 lines
drivers/remoteproc/ti_sci_ctrl.h new file +70
-0+* +* Copyright (C) 2018-2026 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_SCI_CTRL_H +#define REMOTEPROC_TI_SCI_CTRL_H + +#include <linux/of.h> +#include <linux/soc/ti/ti_sci_protocol.h> + +/** +* struct ti_sci_ctrl - structure representing a remoteproc control client +* @sci: cached TI-SCI protocol handle +* @dev: cached client device pointer +* @dev_ops: cached TI-SCI device ops +* @proc_ops: cached TI-SCI proc ops +* @dev_id: TI-SCI device id for the consumer remoteproc device +* @proc_id: processor id for the consumer remoteproc device +* @host_id: host id to pass the control over for this consumer remoteproc +* device +*/ +struct ti_sci_ctrl { +const struct ti_sci_handle *sci; +struct device *dev; +const struct ti_sci_dev_ops *dev_ops; +const struct ti_sci_proc_ops *proc_ops; +u32 dev_id; +u8 proc_id; +u8 host_id; +}; + +static inline +struct ti_sci_ctrl *ti_sci_ctrl_of_get (struct device *dev, +const struct ti_sci_handle *sci) +{ +struct ti_sci_ctrl *tsc; +u32 proc_ids[2 ]; +int ret; + + tsc =devm_kzalloc (dev,sizeof (*tsc),GFP_KERNEL ); +if (!tsc) +return ERR_PTR (-ENOMEM ); + + ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , + &tsc->dev_id); +if (ret <0 ) +return ERR_PTR (ret); + + ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , + proc_ids,2 ); +if (ret <0 ) +return ERR_PTR (ret); + + tsc->dev = dev; + tsc->sci = sci; + tsc->dev_ops = &sci->ops.dev_ops; + tsc->proc_ops = &sci->ops.proc_ops; + tsc->proc_id = proc_ids[0 ]; + tsc->host_id = proc_ids[1 ]; + +return tsc; +} + +/* Power-management helper functions */ +static inline int ti_sci_ctrl_dev_is_on (struct ti_sci_ctrl *tsc,bool *r_state, +bool *c_state) +{ +int ret; +drivers/remoteproc/ti_sci_ctrl.h line 83
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ ret = tsc->dev_ops->is_on (tsc->sci, tsc->dev_id, r_state, c_state); +if (ret) +dev_err (tsc->dev,"ti-sci device is_on failed: %d\n" , ret); +return ret; +} + +/* Request power on to rproc */ +static inline int ti_sci_ctrl_dev_get_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
drivers/remoteproc/ti_sci_ctrl.h line 94
Quoted 11 lines
drivers/remoteproc/ti_sci_ctrl.h new file +11
-0+ + ret = tsc->dev_ops->get_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device get failed: %d\n" , ret); +return ret; +} + +/* Request power off to a rproc */ +static inline int ti_sci_ctrl_dev_put_device (struct ti_sci_ctrl *tsc) +{ +int ret =0 ;Initialization not needed.
Quoted 6 lines
drivers/remoteproc/ti_sci_ctrl.h new file +6
-0+ + ret = tsc->dev_ops->put_device (tsc->sci, tsc->dev_id); +if (ret) +dev_err (tsc->dev,"ti-sci device put failed: %d\n" , ret); +return ret; +}drivers/remoteproc/ti_sci_ctrl.h line 110
Quoted 10 lines
drivers/remoteproc/ti_sci_ctrl.h new file +10
-0+ +/* Processor control helper functions */ +static inline int ti_sci_ctrl_proc_request (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->request (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor request failed: %d\n" , + ret);Here and everywhere else, can you add an empty line before return statement? No hard and fast rule, but this has been followed throughout the existing TI remoteproc drivers.
Thanks,
BeleswarQuoted 291 lines
drivers/remoteproc/ti_sci_ctrl.h new file +67
-0+return ret; +} + +static inline int ti_sci_ctrl_proc_release (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->release (tsc->sci, tsc->proc_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor release failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_handover (struct ti_sci_ctrl *tsc) +{ +int ret; + + ret = tsc->proc_ops->handover (tsc->sci, tsc->proc_id, tsc->host_id); +if (ret) +dev_err (tsc->dev,"ti-sci processor handover of %d to %d failed: %d\n" , + tsc->proc_id, tsc->host_id, ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_config (struct ti_sci_ctrl *tsc, +u64 boot_vector, +u32 cfg_set,u32 cfg_clr) +{ +int ret; + + ret = tsc->proc_ops->set_config (tsc->sci, tsc->proc_id, boot_vector, + cfg_set, cfg_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_config failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_set_control (struct ti_sci_ctrl *tsc, +u32 ctrl_set,u32 ctrl_clr) +{ +int ret; + + ret = tsc->proc_ops->set_control (tsc->sci, tsc->proc_id, ctrl_set, + ctrl_clr); +if (ret) +dev_err (tsc->dev,"ti-sci processor set_control failed: %d\n" , + ret); +return ret; +} + +static inline int ti_sci_ctrl_proc_get_status (struct ti_sci_ctrl *tsc, +u64 *boot_vector,u32 *cfg_flags, +u32 *ctrl_flags,u32 *status_flags) +{ +int ret; + + ret = tsc->proc_ops->get_status (tsc->sci, tsc->proc_id, boot_vector, + cfg_flags, ctrl_flags, status_flags); +if (ret) +dev_err (tsc->dev,"ti-sci processor get_status failed: %d\n" , + ret); +return ret; +} + +#endif /* REMOTEPROC_TI_SCI_CTRL_H */ drivers/remoteproc/ti_sci_dev.h deleted +0
-82@@ -1,82 +0,0 @@ -/* 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 <linux/soc/ti/ti_sci_protocol.h> -#include <linux/pm_runtime.h> - -/** -* 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 =devm_kzalloc (dev,sizeof (*tsd),GFP_KERNEL ); -if (!tsd) -return ERR_PTR (-ENOMEM ); - - ret =of_property_read_u32 (dev_of_node (dev),"ti,sci-dev-id" , - &tsd->dev_id); -if (ret <0 ) -return ERR_PTR (ret); - - tsd->dev = dev; - tsd->sci = sci; - tsd->ops = &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 = 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 = 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 = 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 */ drivers/remoteproc/ti_sci_proc.h deleted +0
-130@@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Texas Instruments TI-SCI Processor Controller Helper Functions -* -* Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ -* Suman Anna <[email protected]> -*/ - -#ifndef REMOTEPROC_TI_SCI_PROC_H -#define REMOTEPROC_TI_SCI_PROC_H - -#include <linux/soc/ti/ti_sci_protocol.h> - -/** -* struct ti_sci_proc - structure representing a processor control client -* @sci: cached TI-SCI protocol handle -* @ops: cached TI-SCI proc ops -* @dev: cached client device pointer -* @proc_id: processor id for the consumer remoteproc device -* @host_id: host id to pass the control over for this consumer remoteproc -* device -*/ -struct ti_sci_proc { -const struct ti_sci_handle *sci; -const struct ti_sci_proc_ops *ops; -struct device *dev; -u8 proc_id; -u8 host_id; -}; - -static inline -struct ti_sci_proc *ti_sci_proc_of_get_tsp (struct device *dev, -const struct ti_sci_handle *sci) -{ -struct ti_sci_proc *tsp; -u32 temp[2 ]; -int ret; - - ret =of_property_read_u32_array (dev_of_node (dev),"ti,sci-proc-ids" , - temp,2 ); -if (ret <0 ) -return ERR_PTR (ret); - - tsp =devm_kzalloc (dev,sizeof (*tsp),GFP_KERNEL ); -if (!tsp) -return ERR_PTR (-ENOMEM ); - - tsp->dev = dev; - tsp->sci = sci; - tsp->ops = &sci->ops.proc_ops; - tsp->proc_id = temp[0 ]; - tsp->host_id = temp[1 ]; - -return tsp; -} - -static inline int ti_sci_proc_request (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->request (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor request failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_release (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->release (tsp->sci, tsp->proc_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor release failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_handover (struct ti_sci_proc *tsp) -{ -int ret; - - ret = tsp->ops->handover (tsp->sci, tsp->proc_id, tsp->host_id); -if (ret) -dev_err (tsp->dev,"ti-sci processor handover of %d to %d failed: %d\n" , - tsp->proc_id, tsp->host_id, ret); -return ret; -} - -static inline int ti_sci_proc_set_config (struct ti_sci_proc *tsp, -u64 boot_vector, -u32 cfg_set,u32 cfg_clr) -{ -int ret; - - ret = tsp->ops->set_config (tsp->sci, tsp->proc_id, boot_vector, - cfg_set, cfg_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_config failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_set_control (struct ti_sci_proc *tsp, -u32 ctrl_set,u32 ctrl_clr) -{ -int ret; - - ret = tsp->ops->set_control (tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr); -if (ret) -dev_err (tsp->dev,"ti-sci processor set_control failed: %d\n" , - ret); -return ret; -} - -static inline int ti_sci_proc_get_status (struct ti_sci_proc *tsp, -u64 *boot_vector,u32 *cfg_flags, -u32 *ctrl_flags,u32 *status_flags) -{ -int ret; - - ret = tsp->ops->get_status (tsp->sci, tsp->proc_id, boot_vector, - cfg_flags, ctrl_flags, status_flags); -if (ret) -dev_err (tsp->dev,"ti-sci processor get_status failed: %d\n" , - ret); -return ret; -} - -#endif /* REMOTEPROC_TI_SCI_PROC_H */
Mathieu Poirier
maintainerI will wait for Andrew and Beleswar to review this set before moving forward.
Thanks,
Mathieu
Quoted 45 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Lore link to the v1 patch:
https://lore.kernel.org/all/[email protected]/Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.The goal of the patch (v2) is to maintain a single source of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header (
ti_sci_ctrl.h).In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks that I am unaware of, so that warranties a different patch.Siddharth Karanam (2):
remoteproc: Addti_sci_dev_opsabstraction
remoteproc: Mergeti_sci_devandti_sci_procabstractiondrivers/remoteproc/ti_k3_common.c | 21 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 23 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 66 +++----- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 7 files changed, 231 insertions(+), 218 deletions(-) create mode 100644 drivers/remoteproc/ti_sci_ctrl.h delete mode 100644 drivers/remoteproc/ti_sci_proc.h--
2.55.0
Quoted 17 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Lore link to the v1 patch:
https://lore.kernel.org/all/[email protected]/Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.
Quoted 8 lines
The goal of the patch (v2) is to maintain a single source of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header (
ti_sci_ctrl.h).In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks that I am unaware of, so that warranties a different patch.
You might be interested in this:
https://lore.kernel.org/all/[email protected]/
Thanks,
Beleswar
Quoted 16 lines
Siddharth Karanam (2):
remoteproc: Addti_sci_dev_opsabstraction
remoteproc: Mergeti_sci_devandti_sci_procabstractiondrivers/remoteproc/ti_k3_common.c | 21 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 23 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 66 +++----- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 7 files changed, 231 insertions(+), 218 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_proc.h
Quoted 2 lines
You might be interested in this:
https://lore.kernel.org/all/[email protected]/
Sounds good, am assuming the RFC will be implemented after this is merged (provided this patch has no issues) right?
Thanks,
Siddharth
Quoted 53 lines · Beleswar
Quoted 17 lines · Siddharth Karanam
The previous version of the patch had a new header
ti_sci_dev.h, that mirrorsti_sci_proc.hin terms of the struct decl and its helper function structure, with the goal of abstracting all ti_sci_handle's members liketi_sci_dev_opsfrom being invoked directly in the driver code.Lore link to the v1 patch:
https://lore.kernel.org/all/[email protected]/Upon discussing in the original patch thread, it seemed better to combine
ti_sci_proc.hand ti_sci_dev.h's structs and merge all their helpers into a single header. That is whatti_sci_ctrl.haims to do: It has the union of tsd (ti_sci_dev) and tsp (ti_sci_proc) and both their helper functions are prefixed withti_sci_ctrl_devandti_sci_ctrl_procrespectively.Quoted 8 lines
The goal of the patch (v2) is to maintain a single source of origin for all ti_sci_dev/proc_ops call sites. Any stray calls to dev_ops/proc_ops function pointer members in driver code should eventually be abstracted through this header (
ti_sci_ctrl.h).In the future we can try to abstract tsd's
dev_opseven further throughpm_runtime, but there are some roadblocks that I am unaware of, so that warranties a different patch.You might be interested in this:
https://lore.kernel.org/all/[email protected]/
Thanks,
BeleswarQuoted 16 lines
Siddharth Karanam (2):
remoteproc: Addti_sci_dev_opsabstraction
remoteproc: Mergeti_sci_devandti_sci_procabstractiondrivers/remoteproc/ti_k3_common.c | 21 +-- drivers/remoteproc/ti_k3_common.h | 6 +- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 23 ++- drivers/remoteproc/ti_k3_r5_remoteproc.c | 66 +++----- drivers/remoteproc/ti_sci_ctrl.h | 177 ++++++++++++++++++++++ drivers/remoteproc/ti_sci_proc.h | 130 ---------------- 7 files changed, 231 insertions(+), 218 deletions(-)create mode 100644
drivers/remoteproc/ti_sci_ctrl.hdelete mode 100644drivers/remoteproc/ti_sci_proc.h