Refactor TI K3 R5, DSP and M4 Remoteproc Drivers
v12 cover Refactor TI K3 R5, DSP and M4 Remoteproc Drivers
This series refactors a lot of functions & callbacks from ti_k3_dsp_remoteproc.c, ti_k3_r5_remoteproc.c and ti_k3_m4_remoteproc.c drivers. This is a consolidated and final series as part of the refactoring of K3 remoteproc drivers. Below is the breakdown:
1. PATCHES #1-#4 fixes important bugs in R5 and DSP drivers before refactoring them into a common driver.
2. PATCHES #5-#11 does the pre-cleanup and aligns R5, DSP, M4 data structures.
3. PATCHES #12-#36 does the actual refactoring R5, DSP and M4 drivers into ti_k3_common.c driver.
NOTE:
This series supersedes below series:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
Testing Done:
1. Tested boot of R5Fs, C66x DSPs, C71x DSPs across Jacinto J7* devices in remoteproc mode and IPC-Only mode.
2. Tested boot of M4F core _only_ in _AM62xx SK_ board in Remoteproc mode and IPC-Only mode.
3. Tested Core stop and detach operations from sysfs for R5Fs, C66x DSPs, C71x DSPs
4. Tested device removal paths by executing 'modprobe -r ti_k3_dsp_remoteproc' and 'modprobe -r ti_k3_r5_remoteproc'.
5. Tested usecases where firmware not available at device probe time, but later in sysfs, able to load firmware into a remotecore and start it. [R5Fs]
6. Tested that each patch in this series generates no new warnings/errors.
7. Tested IPC on AM64x EVM Device. [Thanks to Judith].
8. Tested compilation of the remoteproc drivers as modules.
v12: Changelog:
Mathieu:
1. Use data pointer to set num_mems in PATCHES [08/36] and [11/36].
2. Declare const before variables in PATCH [11/35].
3. Compile ti_k3_common driver with ti_k3_r5_remoteproc driver in PATCH [13/36]. General:
1. New patch: [04/36]. Fix the state detection logic in M4 driver to prevent resetting the rproc in detach routine.
2. Update comments in ti_k3_common.{h/c} files to call out it is refactored out of R5, DSP and M4 drivers in PATCHES [12/36] and [13/36].
3. Carry R/B Tags from Andrew throughout series.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. New patches: [v11 15/35] and [v11 18/35].
Broken down rproc_reset() and rproc_release() refactoring patches into more atomic changes.
2. Carried T/B on all patches from Judith.
3. Carried A/B on [PATCH v11 13/35] by Andrew.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Re-ordered Bug Fixes to the start of the series, before starting pre-cleanup and finally the actual refactor. [Andrew]
2. Broken down commits into more atomic changes for ease of review. [Andrew].
3. Updated commit messages to have uniform flow throughout the series.
4. Carried R/B tags in applicable patches.
5. Further patch specific changelog is attached with patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
v9: Changelog:
1. Added R5 cleanup & refactoring along with existing DSP, M4 refactoring into this series. [Andrew]
2. Dropped Mailbox level IPC checks across R5, DSP, M4 drivers in IPC-only mode. [Andrew]
Link to v8:
https://lore.kernel.org/all/[email protected]/
v8: Changelog:
1. Broken down refactoring into patches, each patch dealing with one function for ease in review. [Andrew]
Links to older versions:
v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
Thanks,
Beleswar
Beleswar Padhi (34):
remoteproc: k3-r5: Refactor sequential core power up/down operations
remoteproc: k3-m4: Don't assert reset in detach routine
remoteproc: k3-r5: Re-order internal memory initialization functions
remoteproc: k3-r5: Re-order k3_r5_release_tsp() function
remoteproc: k3-r5: Refactor Data Structures to Align with DSP and M4
remoteproc: k3-r5: Use k3_r5_rproc_mem_data structure for memory info
remoteproc: k3-{m4/dsp}: Add a void ptr member in rproc internal
struct
remoteproc: k3-m4: Add pointer to rproc struct within k3_m4_rproc
remoteproc: k3-m4: Use k3_rproc_mem_data structure for memory info
remoteproc: k3: Refactor shared data structures
remoteproc: k3: Refactor mailbox rx_callback functions into common
driver
remoteproc: k3: Refactor .kick rproc ops into common driver
remoteproc: k3-dsp: Correct Reset logic for devices without lresets
remoteproc: k3-m4: Introduce central function to put rproc into reset
remoteproc: k3: Refactor rproc_reset() implementation into common
driver
remoteproc: k3-dsp: Correct Reset deassert logic for devices w/o
lresets
remoteproc: k3-m4: Introduce central function to release rproc from
reset
remoteproc: k3: Refactor rproc_release() implementation into common
driver
remoteproc: k3-m4: Ping the mbox while acquiring the channel
remoteproc: k3: Refactor rproc_request_mbox() implementations into
common driver
remoteproc: k3-dsp: Don't override rproc ops in IPC-only mode
remoteproc: k3-dsp: Assert local reset during .prepare callback
remoteproc: k3: Refactor .prepare rproc ops into common driver
remoteproc: k3: Refactor .unprepare rproc ops into common driver
remoteproc: k3: Refactor .start rproc ops into common driver
remoteproc: k3: Refactor .stop rproc ops into common driver
remoteproc: k3: Refactor .attach rproc ops into common driver
remoteproc: k3: Refactor .detach rproc ops into common driver
remoteproc: k3: Refactor .get_loaded_rsc_table ops into common driver
remoteproc: k3: Refactor .da_to_va rproc ops into common driver
remoteproc: k3: Refactor of_get_memories() functions into common
driver
remoteproc: k3: Refactor mem_release() functions into common driver
remoteproc: k3: Refactor reserved_mem_init() functions into common
driver
remoteproc: k3: Refactor release_tsp() functions into common driver
Siddharth Vadapalli (2):
remoteproc: k3-r5: Drop check performed in
k3_r5_rproc_{mbox_callback/kick}
remoteproc: k3-dsp: Drop check performed in
k3_dsp_rproc_{mbox_callback/kick}drivers/remoteproc/Makefile | 6 +- drivers/remoteproc/ti_k3_common.c | 551 +++++++++++ drivers/remoteproc/ti_k3_common.h | 118 +++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 616 +------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 583 +----------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 1018 +++++++-------------- 6 files changed, 1088 insertions(+), 1804 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_common.c create mode 100644 drivers/remoteproc/ti_k3_common.h
Signature · 1 line
2.34.1
PATCH v12 1/36 remoteproc: k3-r5: Drop check performed in k3_r5_rproc_{mbox_callback/kick}
From: Siddharth Vadapalli <[email protected]>
Commit f3f11cfe8907 ("remoteproc: k3-r5: Acquire mailbox handle during probe routine") introduced a check in the "k3_r5_rproc_mbox_callback()" and "k3_r5_rproc_kick()" callbacks, causing them to exit if the remote core's state is "RPROC_DETACHED". However, the "__rproc_attach()" function that is responsible for attaching to a remote core, updates the state of the remote core to "RPROC_ATTACHED" only after invoking "rproc_start_subdevices()".
The "rproc_start_subdevices()" function triggers the probe of the Virtio RPMsg devices associated with the remote core, which require that the "k3_r5_rproc_kick()" and "k3_r5_rproc_mbox_callback()" callbacks are functional. Hence, drop the check in the callbacks.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Re-ordered this patch to come at the start of the series.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_r5_remoteproc.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +0 -8
@@ -194,10 +194,6 @@ static void k3_r5_rproc_mbox_callback(struct mbox_client *client, void *data)const char *name = kproc->rproc->name;u32 msg =omap_mbox_message (data); -/* Do not forward message from a detached core */ -if (kproc->rproc->state ==RPROC_DETACHED ) -return ; -dev_dbg (dev,"mbox msg: 0x%x\n" , msg);switch (msg) {
@@ -233,10 +229,6 @@ static void k3_r5_rproc_kick(struct rproc *rproc, int vqid)mbox_msg_t msg = (mbox_msg_t )vqid;int ret; -/* Do not forward message to a detached core */ -if (kproc->rproc->state ==RPROC_DETACHED ) -return ; -/* send the index of the triggered virtqueue in the mailbox payload */ ret =mbox_send_message (kproc->mbox, (void *)msg);if (ret <0 )
Signature · 1 line
2.34.1
PATCH v12 2/36 remoteproc: k3-dsp: Drop check performed in k3_dsp_rproc_{mbox_callback/kick}
In reply to Beleswar PadhiFrom: Siddharth Vadapalli <[email protected]>
Commit ea1d6fb5b571 ("remoteproc: k3-dsp: Acquire mailbox handle during probe routine") introduced a check in the "k3_dsp_rproc_mbox_callback()" and "k3_dsp_rproc_kick()" callbacks, causing them to exit if the remote core's state is "RPROC_DETACHED". However, the "__rproc_attach()" function that is responsible for attaching to a remote core, updates the state of the remote core to "RPROC_ATTACHED" only after invoking "rproc_start_subdevices()".
The "rproc_start_subdevices()" function triggers the probe of the Virtio RPMsg devices associated with the remote core, which require that the "k3_dsp_rproc_kick()" and "k3_dsp_rproc_mbox_callback()" callbacks are functional. Hence, drop the check in the callbacks.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Re-ordered this patch from [v9 07/26] to [v10 02/33].
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -8
@@ -115,10 +115,6 @@ static void k3_dsp_rproc_mbox_callback(struct mbox_client *client, void *data)const char *name = kproc->rproc->name;u32 msg =omap_mbox_message (data); -/* Do not forward messages from a detached core */ -if (kproc->rproc->state ==RPROC_DETACHED ) -return ; -dev_dbg (dev,"mbox msg: 0x%x\n" , msg);switch (msg) {
@@ -159,10 +155,6 @@ static void k3_dsp_rproc_kick(struct rproc *rproc, int vqid)mbox_msg_t msg = (mbox_msg_t )vqid;int ret; -/* Do not forward messages to a detached core */ -if (kproc->rproc->state ==RPROC_DETACHED ) -return ; -/* send the index of the triggered virtqueue in the mailbox payload */ ret =mbox_send_message (kproc->mbox, (void *)msg);if (ret <0 )
Signature · 1 line
2.34.1
PATCH v12 3/36 remoteproc: k3-r5: Refactor sequential core power up/down operations
In reply to Beleswar PadhiThe existing implementation of the waiting mechanism in "k3_r5_cluster_rproc_init()" waits for the "released_from_reset" flag to be set as part of the firmware boot process in "k3_r5_rproc_start()". The "k3_r5_cluster_rproc_init()" function is invoked in the probe routine which causes unexpected failures in cases where the firmware is unavailable at boot time, resulting in probe failure and removal of the remoteproc handles in the sysfs paths.
To address this, the waiting mechanism is refactored out of the probe routine into the appropriate "k3_r5_rproc_{prepare/unprepare}()" functions. This allows the probe routine to complete without depending on firmware booting, while still maintaining the required power-synchronization between cores.
Further, this wait mechanism is dropped from "k3_r5_rproc_{start/stop}()" functions as they deal with Core Run/Halt operations, and as such, there is no constraint in Running or Halting the cores of a cluster in order.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Re-ordered this patch from [v9 08/26] to [v10 03/33].
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_r5_remoteproc.c | 110 +++++++++++++---------- 1 file changed, 63 insertions(+), 47 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +63 -47
@@ -440,13 +440,36 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv;struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core; +struct k3_r5_core *core = kproc->core, *core0, *core1;struct device *dev = kproc->dev;u32 ctrl =0 , cfg =0 , stat =0 ;u64 boot_vec =0 ;bool mem_init_dis;int ret; +/* +* R5 cores require to be powered on sequentially, core0 should be in +* higher power state than core1 in a cluster. So, wait for core0 to +* power up before proceeding to core1 and put timeout of 2sec. This +* waiting mechanism is necessary because rproc_auto_boot_callback() for +* core1 can be called before core0 due to thread execution order. +* +* By placing the wait mechanism here in .prepare() ops, this condition +* is enforced for rproc boot requests from sysfs as well. +*/ + core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); + core1 = list_last_entry(&cluster->cores, struct k3_r5_core, elem); +if (cluster->mode ==CLUSTER_MODE_SPLIT && core == core1 && + !core0->released_from_reset) { + ret =wait_event_interruptible_timeout (cluster->core_transition, + core0->released_from_reset, +msecs_to_jiffies (2000 )); +if (ret <=0 ) { +dev_err (dev,"can not power up core1 before core0" ); +return -EPERM ; + } + } + ret =ti_sci_proc_get_status (core->tsp, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret;
@@ -462,6 +485,14 @@ static int k3_r5_rproc_prepare(struct rproc *rproc)return ret; } +/* +* Notify all threads in the wait queue when core0 state has changed so +* that threads waiting for this condition can be executed. +*/ + core->released_from_reset = true; +if (core == core0) +wake_up_interruptible (&cluster->core_transition); +/* * Newer IP revisions like on J7200 SoCs support h/w auto-initialization * of TCMs, so there is no need to perform the s/w memzero. This bit is
@@ -507,10 +538,30 @@ static int k3_r5_rproc_unprepare(struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv;struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core; +struct k3_r5_core *core = kproc->core, *core0, *core1;struct device *dev = kproc->dev;int ret; +/* +* Ensure power-down of cores is sequential in split mode. Core1 must +* power down before Core0 to maintain the expected state. By placing +* the wait mechanism here in .unprepare() ops, this condition is +* enforced for rproc stop or shutdown requests from sysfs and device +* removal as well. +*/ + core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); + core1 = list_last_entry(&cluster->cores, struct k3_r5_core, elem); +if (cluster->mode ==CLUSTER_MODE_SPLIT && core == core0 && + core1->released_from_reset) { + ret =wait_event_interruptible_timeout (cluster->core_transition, + !core1->released_from_reset, +msecs_to_jiffies (2000 )); +if (ret <=0 ) { +dev_err (dev,"can not power down core0 before core1" ); +return -EPERM ; + } + } +/* Re-use LockStep-mode reset logic for Single-CPU mode */ ret = (cluster->mode ==CLUSTER_MODE_LOCKSTEP || cluster->mode == CLUSTER_MODE_SINGLECPU) ?
@@ -518,6 +569,14 @@ static int k3_r5_rproc_unprepare(struct rproc *rproc)if (ret)dev_err (dev,"unable to disable cores, ret = %d\n" , ret); +/* +* Notify all threads in the wait queue when core1 state has changed so +* that threads waiting for this condition can be executed. +*/ + core->released_from_reset = false; +if (core == core1) +wake_up_interruptible (&cluster->core_transition); +return ret; }
@@ -543,7 +602,7 @@ static int k3_r5_rproc_start(struct rproc *rproc)struct k3_r5_rproc *kproc = rproc->priv;struct k3_r5_cluster *cluster = kproc->cluster;struct device *dev = kproc->dev; -struct k3_r5_core *core0, *core; +struct k3_r5_core *core;u32 boot_addr;int ret;
@@ -565,21 +624,9 @@ static int k3_r5_rproc_start(struct rproc *rproc) goto unroll_core_run; } }else { -/* do not allow core 1 to start before core 0 */ - core0 = list_first_entry(&cluster->cores, struct k3_r5_core, - elem); -if (core != core0 && core0->rproc->state ==RPROC_OFFLINE ) { -dev_err (dev,"%s: can not start core 1 before core 0\n" , - __func__); -return -EPERM ; - } - ret =k3_r5_core_run (core);if (ret)return ret; - - core->released_from_reset = true; -wake_up_interruptible (&cluster->core_transition); }return 0 ;
@@ -620,8 +667,7 @@ static int k3_r5_rproc_stop(struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv;struct k3_r5_cluster *cluster = kproc->cluster; -struct device *dev = kproc->dev; -struct k3_r5_core *core1, *core = kproc->core; +struct k3_r5_core *core = kproc->core;int ret;/* halt all applicable cores */
@@ -634,16 +680,6 @@ static int k3_r5_rproc_stop(struct rproc *rproc) } } }else { -/* do not allow core 0 to stop before core 1 */ - core1 = list_last_entry(&cluster->cores, struct k3_r5_core, - elem); -if (core != core1 && core1->rproc->state !=RPROC_OFFLINE ) { -dev_err (dev,"%s: can not stop core 0 before core 1\n" , - __func__); - ret = -EPERM ; - goto out; - } - ret =k3_r5_core_halt (core);if (ret) goto out;
@@ -1271,26 +1307,6 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) cluster->mode ==CLUSTER_MODE_SINGLECPU || cluster->mode == CLUSTER_MODE_SINGLECORE) break; - -/* -* R5 cores require to be powered on sequentially, core0 -* should be in higher power state than core1 in a cluster -* So, wait for current core to power up before proceeding -* to next core and put timeout of 2sec for each core. -* -* This waiting mechanism is necessary because -* rproc_auto_boot_callback() for core1 can be called before -* core0 due to thread execution order. -*/ - ret =wait_event_interruptible_timeout (cluster->core_transition, - core->released_from_reset, -msecs_to_jiffies (2000 )); -if (ret <=0 ) { -dev_err (dev, -"Timed out waiting for %s core to power up!\n" , - rproc->name); - goto out; - } }return 0 ;
Signature · 1 line
2.34.1
PATCH v12 4/36 remoteproc: k3-m4: Don't assert reset in detach routine
In reply to Beleswar PadhiThe rproc_detach() function invokes __rproc_detach() before rproc_unprepare_device(). The __rproc_detach() function sets the rproc->state to "RPROC_DETACHED".
However, the TI K3 M4 driver erroneously looks for "RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.
Therefore, correct the IPC-only mode detection logic to look for "RPROC_DETACHED" in k3_m4_rproc_unprepare() function.
---
v12: Changelog:
1. New patch. Fixup a state detection logic.
drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -1
@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc)int ret;/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_ATTACHED ) +if (rproc->state ==RPROC_DETACHED )return 0 ; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
Signature · 1 line
2.34.1
Mathieu Poirier
maintainerRe: [PATCH v12 04/36] remoteproc: k3-m4: Don't assert reset in detach routine
Quoted 11 lines · Beleswar Padhi
The
rproc_detach()function invokes__rproc_detach()beforerproc_unprepare_device(). The__rproc_detach()function sets therproc->stateto "RPROC_DETACHED".However, the TI K3 M4 driver erroneously looks for "
RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.Therefore, correct the IPC-only mode detection logic to look for "
RPROC_DETACHED" ink3_m4_rproc_unprepare()function.
This driver has been upstream for 9 whole months, it is hard for me to believe this but was just noticed. Martyn from Collabora should be CC'ed on this, and I will also need the required R-b/T-b tags.
Typically bug fixes are not part of refactoring exercises. I suggest to apply this set without this patch - you can then work on fixing this bug.
Thanks,
Mathieu
Quoted 25 lines
Fixes ebcf9008a895 ("remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem")Signed-off-by Beleswar Padhi <[email protected]>---
v12: Changelog:
1. New patch. Fixup a state detection logic.drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/ti_k3_m4_remoteproc.c +1
-1@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc)int ret;/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_ATTACHED ) +if (rproc->state ==RPROC_DETACHED )return 0 ; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,Signature · 1 line
2.34.1
Re: [PATCH v12 04/36] remoteproc: k3-m4: Don't assert reset in detach routine
Quoted 9 lines · Mathieu Poirier
Quoted 8 lines · Beleswar Padhi
The
rproc_detach()function invokes__rproc_detach()beforerproc_unprepare_device(). The__rproc_detach()function sets therproc->stateto "RPROC_DETACHED".However, the TI K3 M4 driver erroneously looks for "
RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.
Quoted 6 lines
Quoted 3 lines
Therefore, correct the IPC-only mode detection logic to look for "
RPROC_DETACHED" ink3_m4_rproc_unprepare()function.This driver has been upstream for 9 whole months, it is hard for me to believe this but was just noticed. Martyn from Collabora should be CC'ed on this, and I will also need the required R-b/T-b tags.
Requesting Andrew/Judith for review and test too.
Quoted 2 lines
Typically bug fixes are not part of refactoring exercises.
Typically, yes. But the refactor depends on this fix. This k3_m4_rproc_unprepare() function is entirely refactored to common driver in [PATCH v12 26/36].
So, If the refactor is picked without this patch fix, the mainline M4 driver would be fixed, but the older stable kernels would always have this bug. Let me know what you think.
Thanks,
Beleswar
Quoted 31 lines
I suggest to apply
this set without this patch - you can then work on fixing this bug.Thanks,
MathieuQuoted 25 lines
Fixes ebcf9008a895 ("remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem")Signed-off-by Beleswar Padhi <[email protected]>---
v12: Changelog:
1. New patch. Fixup a state detection logic.drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/ti_k3_m4_remoteproc.c +1
-1@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc)int ret;/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_ATTACHED ) +if (rproc->state ==RPROC_DETACHED )return 0 ; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,Signature · 1 line
2.34.1
Mathieu Poirier
maintainerRe: [PATCH v12 04/36] remoteproc: k3-m4: Don't assert reset in detach routine
Quoted 27 lines · Beleswar Prasad Padhi
Quoted 9 lines · Mathieu Poirier
Quoted 8 lines · Beleswar Padhi
The
rproc_detach()function invokes__rproc_detach()beforerproc_unprepare_device(). The__rproc_detach()function sets therproc->stateto "RPROC_DETACHED".However, the TI K3 M4 driver erroneously looks for "
RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.Quoted 6 lines
Quoted 3 lines
Therefore, correct the IPC-only mode detection logic to look for "
RPROC_DETACHED" ink3_m4_rproc_unprepare()function.This driver has been upstream for 9 whole months, it is hard for me to believe this but was just noticed. Martyn from Collabora should be CC'ed on this, and I will also need the required R-b/T-b tags.
Cc Martyn Welch [email protected]Requesting Andrew/Judith for review and test too.
Quoted 2 lines
Typically bug fixes are not part of refactoring exercises.
Quoted 8 lines
Typically, yes. But the refactor depends on this fix. This
k3_m4_rproc_unprepare()function is entirely refactored to common driver in [PATCH v12 26/36].So, If the refactor is picked without this patch fix, the mainline M4 driver would be fixed, but the older stable kernels would always have this bug. Let me know what you think.
I suggest you send this patch on its own and then the series (without this patch) with a note in the cover letter that it depends on the fix. That way we get the best of both worlds.
Quoted 32 lines
Thanks,
BeleswarQuoted 29 lines
I suggest to apply
this set without this patch - you can then work on fixing this bug.Thanks,
MathieuQuoted 23 lines
Fixes ebcf9008a895 ("remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem")Signed-off-by Beleswar Padhi <[email protected]>---
v12: Changelog:
1. New patch. Fixup a state detection logic.drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/ti_k3_m4_remoteproc.c +1
-1@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc)int ret;/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_ATTACHED ) +if (rproc->state ==RPROC_DETACHED )return 0 ; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,Signature · 1 line
2.34.1
Re: [PATCH v12 04/36] remoteproc: k3-m4: Don't assert reset in detach routine
Hi Mathieu,
Quoted 28 lines · Mathieu Poirier
Quoted 27 lines · Beleswar Prasad Padhi
Quoted 9 lines · Mathieu Poirier
Quoted 8 lines · Beleswar Padhi
The
rproc_detach()function invokes__rproc_detach()beforerproc_unprepare_device(). The__rproc_detach()function sets therproc->stateto "RPROC_DETACHED".However, the TI K3 M4 driver erroneously looks for "
RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.Quoted 6 lines
Quoted 3 lines
Therefore, correct the IPC-only mode detection logic to look for "
RPROC_DETACHED" ink3_m4_rproc_unprepare()function.This driver has been upstream for 9 whole months, it is hard for me to believe this but was just noticed. Martyn from Collabora should be CC'ed on this, and I will also need the required R-b/T-b tags.
Cc Martyn Welch [email protected]Requesting Andrew/Judith for review and test too.
Quoted 1 line
Typically bug fixes are not part of refactoring exercises.
Typically, yes. But the refactor depends on this fix. This
k3_m4_rproc_unprepare()function is entirely refactored to common driver in [PATCH v12 26/36].
Quoted 7 lines
Quoted 4 lines
So, If the refactor is picked without this patch fix, the mainline M4 driver would be fixed, but the older stable kernels would always have this bug. Let me know what you think.
I suggest you send this patch on its own and then the series (without this patch) with a note in the cover letter that it depends on the fix. That way we get the best of both worlds.
Sure. If I get any comments/reviews on this version, I will re-spin this patch separately than the series.
Thanks,
Beleswar
Quoted 33 lines
Quoted 33 lines
Thanks,
BeleswarQuoted 29 lines
I suggest to apply
this set without this patch - you can then work on fixing this bug.Thanks,
MathieuQuoted 23 lines
Fixes ebcf9008a895 ("remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem")Signed-off-by Beleswar Padhi <[email protected]>---
v12: Changelog:
1. New patch. Fixup a state detection logic.drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/ti_k3_m4_remoteproc.c +1
-1@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc)int ret;/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_ATTACHED ) +if (rproc->state ==RPROC_DETACHED )return 0 ; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,Signature · 1 line
2.34.1
Hari Nagalla
Reviewed-byRe: [PATCH v12 04/36] remoteproc: k3-m4: Don't assert reset in detach routine
Quoted 40 lines · Beleswar Prasad Padhi
Hi Mathieu,
Quoted 28 lines · Mathieu Poirier
Quoted 27 lines · Beleswar Prasad Padhi
Quoted 9 lines · Mathieu Poirier
Quoted 8 lines · Beleswar Padhi
The
rproc_detach()function invokes__rproc_detach()beforerproc_unprepare_device(). The__rproc_detach()function sets therproc->stateto "RPROC_DETACHED".However, the TI K3 M4 driver erroneously looks for "
RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.Quoted 6 lines
Quoted 3 lines
Therefore, correct the IPC-only mode detection logic to look for "
RPROC_DETACHED" ink3_m4_rproc_unprepare()function.This driver has been upstream for 9 whole months, it is hard for me to believe this but was just noticed. Martyn from Collabora should be CC'ed on this, and I will also need the required R-b/T-b tags.
Cc Martyn Welch [email protected]Requesting Andrew/Judith for review and test too.
Quoted 1 line
Typically bug fixes are not part of refactoring exercises.
Typically, yes. But the refactor depends on this fix. This
k3_m4_rproc_unprepare()function is entirely refactored to common driver in [PATCH v12 26/36].Quoted 7 lines
Quoted 4 lines
So, If the refactor is picked without this patch fix, the mainline M4 driver would be fixed, but the older stable kernels would always have this bug. Let me know what you think.
I suggest you send this patch on its own and then the series (without this patch) with a note in the cover letter that it depends on the fix. That way we get the best of both worlds.
Quoted 5 lines
Sure. If I get any comments/reviews on this version, I will re-spin this patch separately than the series.
Thanks,
Beleswar
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Thanks,
BeleswarQuoted 29 lines
I suggest to apply
this set without this patch - you can then work on fixing this bug.Thanks,
MathieuQuoted 23 lines
Fixes ebcf9008a895 ("remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem")Signed-off-by Beleswar Padhi <[email protected]>---
v12: Changelog:
1. New patch. Fixup a state detection logic.drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/ti_k3_m4_remoteproc.c +1
-1@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc)int ret;/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_ATTACHED ) +if (rproc->state ==RPROC_DETACHED )return 0 ; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,Signature · 1 line
2.34.1
Martyn Welch
Reviewed-byRe: [PATCH v12 04/36] remoteproc: k3-m4: Don't assert reset in detach routine
In reply to Beleswar Prasad PadhiQuoted 14 lines · Beleswar Prasad Padhi
Quoted 12 lines · Mathieu Poirier
Quoted 11 lines · Beleswar Padhi
The
rproc_detach()function invokes__rproc_detach()beforerproc_unprepare_device(). The__rproc_detach()function sets therproc->stateto "RPROC_DETACHED".However, the TI K3 M4 driver erroneously looks for "
RPROC_ATTACHED" state in its .unprepare ops to identify IPC-only mode; which leads to resetting the rproc in detach routine.Therefore, correct the IPC-only mode detection logic to look for "
RPROC_DETACHED" ink3_m4_rproc_unprepare()function.
Quoted 9 lines
Quoted 3 lines
This driver has been upstream for 9 whole months, it is hard for me to believe this but was just noticed. Martyn from Collabora should be CC'ed on this, and I will also need the required R-b/T-b tags.
Cc Martyn Welch [email protected]Requesting Andrew/Judith for review and test too.
It's been a while since I used this, IIRC the project I thought we needed this for went in a different direction almost as soon as I'd managed to get the driver upstream... ...But I've spent some time to review as best as I can:
Quoted 41 lines
Quoted 2 lines
Typically bug fixes are not part of refactoring exercises.
Typically, yes. But the refactor depends on this fix. This
k3_m4_rproc_unprepare()function is entirely refactored to common driver in [PATCH v12 26/36].So, If the refactor is picked without this patch fix, the mainline M4 driver would be fixed, but the older stable kernels would always have this bug. Let me know what you think.
Thanks,
BeleswarQuoted 30 lines
I suggest to apply
this set without this patch - you can then work on fixing this bug.Thanks,
MathieuQuoted 24 lines
Fixes ebcf9008a895 ("remoteproc: k3-m4: Add a remoteproc driver for M4F subsystem")Signed-off-by Beleswar Padhi <[email protected]>---
v12: Changelog:
1. New patch. Fixup a state detection logic.
drivers/remoteproc/ti_k3_m4_remoteproc.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/ti_k3_m4_remoteproc.c +1
-1@@ -228,7 +228,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc) int ret; /* If the core is going to be detached do not assert the module reset */ - if (rproc->state == RPROC_ATTACHED) + if (rproc->state == RPROC_DETACHED) return 0; ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,Signature · 1 line
2.34.1
PATCH v12 5/36 remoteproc: k3-r5: Re-order internal memory initialization functions
In reply to Beleswar PadhiThe internal memory struct pointer, 'mem', will be refactored from k3_r5_core struct into k3_r5_rproc struct in a future commit.
Therefore, move the internal memory initialization function, k3_r5_core_of_get_internal_memories() above k3_r5_cluster_rproc_init() so that the former can be invoked by the later.
While at it, also re-order the k3_r5_core_of_get_sram_memories() to keep all the internal memory initialization functions at one place.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Re-ordered both core_of_get_{internal/sram}_memories() together.
2. Moved release_tsp() re-ordering into a separate future commit.
3. Updated commit message to call out changes in a better way.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_r5_remoteproc.c | 258 +++++++++++------------ 1 file changed, 129 insertions(+), 129 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +129 -129
@@ -1227,6 +1227,135 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)return ret; } +static int k3_r5_core_of_get_internal_memories (struct platform_device *pdev, +struct k3_r5_core *core) +{ +static const char *const mem_names[] = {"atcm" ,"btcm" }; +struct device *dev = &pdev->dev; +struct resource *res; +int num_mems; +int i; + + num_mems =ARRAY_SIZE (mem_names); + core->mem =devm_kcalloc (dev, num_mems,sizeof (*core->mem),GFP_KERNEL ); +if (!core->mem) +return -ENOMEM ; + +for (i =0 ; i < num_mems; i++) { + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , + mem_names[i]); +if (!res) { +dev_err (dev,"found no memory resource for %s\n" , + mem_names[i]); +return -EINVAL ; + } +if (!devm_request_mem_region (dev, res->start, +resource_size (res), +dev_name (dev))) { +dev_err (dev,"could not request %s region for resource\n" , + mem_names[i]); +return -EBUSY ; + } + +/* +* TCMs are designed in general to support RAM-like backing +* memories. So, map these as Normal Non-Cached memories. This +* also avoids/fixes any potential alignment faults due to +* unaligned data accesses when using memcpy() or memset() +* functions (normally seen with device type memory). +*/ + core->mem[i].cpu_addr =devm_ioremap_wc (dev, res->start, +resource_size (res)); +if (!core->mem[i].cpu_addr) { +dev_err (dev,"failed to map %s memory\n" , mem_names[i]); +return -ENOMEM ; + } + core->mem[i].bus_addr = res->start; + +/* +* TODO: +* The R5F cores can place ATCM & BTCM anywhere in its address +* based on the corresponding Region Registers in the System +* Control coprocessor. For now, place ATCM and BTCM at +* addresses 0 and 0x41010000 (same as the bus address on AM65x +* SoCs) based on loczrama setting +*/ +if (!strcmp (mem_names[i],"atcm" )) { + core->mem[i].dev_addr = core->loczrama ? +0 :K3_R5_TCM_DEV_ADDR ; + }else { + core->mem[i].dev_addr = core->loczrama ? +K3_R5_TCM_DEV_ADDR :0 ; + } + core->mem[i].size =resource_size (res); + +dev_dbg (dev,"memory %5s: bus addr %pa size 0x%zx va %pK da 0x%x\n" , + mem_names[i], &core->mem[i].bus_addr, + core->mem[i].size, core->mem[i].cpu_addr, + core->mem[i].dev_addr); + } + core->num_mems = num_mems; + +return 0 ; +} + +static int k3_r5_core_of_get_sram_memories (struct platform_device *pdev, +struct k3_r5_core *core) +{ +struct device_node *np = pdev->dev.of_node; +struct device *dev = &pdev->dev; +struct device_node *sram_np; +struct resource res; +int num_sram; +int i, ret; + + num_sram =of_property_count_elems_of_size (np,"sram" ,sizeof (phandle)); +if (num_sram <=0 ) { +dev_dbg (dev,"device does not use reserved on-chip memories, num_sram = %d\n" , + num_sram); +return 0 ; + } + + core->sram =devm_kcalloc (dev, num_sram,sizeof (*core->sram),GFP_KERNEL ); +if (!core->sram) +return -ENOMEM ; + +for (i =0 ; i < num_sram; i++) { + sram_np =of_parse_phandle (np,"sram" , i); +if (!sram_np) +return -EINVAL ; + +if (!of_device_is_available (sram_np)) { +of_node_put (sram_np); +return -EINVAL ; + } + + ret =of_address_to_resource (sram_np,0 , &res); +of_node_put (sram_np); +if (ret) +return -EINVAL ; + + core->sram[i].bus_addr = res.start; + core->sram[i].dev_addr = res.start; + core->sram[i].size =resource_size (&res); + core->sram[i].cpu_addr =devm_ioremap_wc (dev, res.start, +resource_size (&res)); +if (!core->sram[i].cpu_addr) { +dev_err (dev,"failed to parse and map sram%d memory at %pad\n" , + i, &res.start); +return -ENOMEM ; + } + +dev_dbg (dev,"memory sram%d: bus addr %pa size 0x%zx va %pK da 0x%x\n" , + i, &core->sram[i].bus_addr, + core->sram[i].size, core->sram[i].cpu_addr, + core->sram[i].dev_addr); + } + core->num_sram = num_sram; + +return 0 ; +} +static int k3_r5_cluster_rproc_init (struct platform_device *pdev) {struct k3_r5_cluster *cluster =platform_get_drvdata (pdev);
@@ -1366,135 +1495,6 @@ static void k3_r5_cluster_rproc_exit(void *data) } } -static int k3_r5_core_of_get_internal_memories (struct platform_device *pdev, -struct k3_r5_core *core) -{ -static const char *const mem_names[] = {"atcm" ,"btcm" }; -struct device *dev = &pdev->dev; -struct resource *res; -int num_mems; -int i; - - num_mems =ARRAY_SIZE (mem_names); - core->mem =devm_kcalloc (dev, num_mems,sizeof (*core->mem),GFP_KERNEL ); -if (!core->mem) -return -ENOMEM ; - -for (i =0 ; i < num_mems; i++) { - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , - mem_names[i]); -if (!res) { -dev_err (dev,"found no memory resource for %s\n" , - mem_names[i]); -return -EINVAL ; - } -if (!devm_request_mem_region (dev, res->start, -resource_size (res), -dev_name (dev))) { -dev_err (dev,"could not request %s region for resource\n" , - mem_names[i]); -return -EBUSY ; - } - -/* -* TCMs are designed in general to support RAM-like backing -* memories. So, map these as Normal Non-Cached memories. This -* also avoids/fixes any potential alignment faults due to -* unaligned data accesses when using memcpy() or memset() -* functions (normally seen with device type memory). -*/ - core->mem[i].cpu_addr =devm_ioremap_wc (dev, res->start, -resource_size (res)); -if (!core->mem[i].cpu_addr) { -dev_err (dev,"failed to map %s memory\n" , mem_names[i]); -return -ENOMEM ; - } - core->mem[i].bus_addr = res->start; - -/* -* TODO: -* The R5F cores can place ATCM & BTCM anywhere in its address -* based on the corresponding Region Registers in the System -* Control coprocessor. For now, place ATCM and BTCM at -* addresses 0 and 0x41010000 (same as the bus address on AM65x -* SoCs) based on loczrama setting -*/ -if (!strcmp (mem_names[i],"atcm" )) { - core->mem[i].dev_addr = core->loczrama ? -0 :K3_R5_TCM_DEV_ADDR ; - }else { - core->mem[i].dev_addr = core->loczrama ? -K3_R5_TCM_DEV_ADDR :0 ; - } - core->mem[i].size =resource_size (res); - -dev_dbg (dev,"memory %5s: bus addr %pa size 0x%zx va %pK da 0x%x\n" , - mem_names[i], &core->mem[i].bus_addr, - core->mem[i].size, core->mem[i].cpu_addr, - core->mem[i].dev_addr); - } - core->num_mems = num_mems; - -return 0 ; -} - -static int k3_r5_core_of_get_sram_memories (struct platform_device *pdev, -struct k3_r5_core *core) -{ -struct device_node *np = pdev->dev.of_node; -struct device *dev = &pdev->dev; -struct device_node *sram_np; -struct resource res; -int num_sram; -int i, ret; - - num_sram =of_property_count_elems_of_size (np,"sram" ,sizeof (phandle)); -if (num_sram <=0 ) { -dev_dbg (dev,"device does not use reserved on-chip memories, num_sram = %d\n" , - num_sram); -return 0 ; - } - - core->sram =devm_kcalloc (dev, num_sram,sizeof (*core->sram),GFP_KERNEL ); -if (!core->sram) -return -ENOMEM ; - -for (i =0 ; i < num_sram; i++) { - sram_np =of_parse_phandle (np,"sram" , i); -if (!sram_np) -return -EINVAL ; - -if (!of_device_is_available (sram_np)) { -of_node_put (sram_np); -return -EINVAL ; - } - - ret =of_address_to_resource (sram_np,0 , &res); -of_node_put (sram_np); -if (ret) -return -EINVAL ; - - core->sram[i].bus_addr = res.start; - core->sram[i].dev_addr = res.start; - core->sram[i].size =resource_size (&res); - core->sram[i].cpu_addr =devm_ioremap_wc (dev, res.start, -resource_size (&res)); -if (!core->sram[i].cpu_addr) { -dev_err (dev,"failed to parse and map sram%d memory at %pad\n" , - i, &res.start); -return -ENOMEM ; - } - -dev_dbg (dev,"memory sram%d: bus addr %pa size 0x%zx va %pK da 0x%x\n" , - i, &core->sram[i].bus_addr, - core->sram[i].size, core->sram[i].cpu_addr, - core->sram[i].dev_addr); - } - core->num_sram = num_sram; - -return 0 ; -} -static void k3_r5_release_tsp (void *data) {struct ti_sci_proc *tsp = data;
Signature · 1 line
2.34.1
PATCH v12 6/36 remoteproc: k3-r5: Re-order k3_r5_release_tsp() function
In reply to Beleswar PadhiThe TI-SCI processor control handle, 'tsp', will be refactored from k3_r5_core struct into k3_r5_rproc struct in a future commit. So, the 'tsp' pointer will be initialized inside k3_r5_cluster_rproc_init() now.
Move the k3_r5_release_tsp() function, which releases the tsp handle, above k3_r5_cluster_rproc_init(), so that the later can register the former as a devm action.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split release_tsp() re-ordering from [v9 01/26] into this patch.
2. Updated commit message to call out changes in a better way.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_r5_remoteproc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +7 -7
@@ -1356,6 +1356,13 @@ static int k3_r5_core_of_get_sram_memories(struct platform_device *pdev,return 0 ; } +static void k3_r5_release_tsp (void *data) +{ +struct ti_sci_proc *tsp = data; + +ti_sci_proc_release (tsp); +} +static int k3_r5_cluster_rproc_init (struct platform_device *pdev) {struct k3_r5_cluster *cluster =platform_get_drvdata (pdev);
@@ -1495,13 +1502,6 @@ static void k3_r5_cluster_rproc_exit(void *data) } } -static void k3_r5_release_tsp (void *data) -{ -struct ti_sci_proc *tsp = data; - -ti_sci_proc_release (tsp); -} -static int k3_r5_core_of_init (struct platform_device *pdev) {struct device *dev = &pdev->dev;
Signature · 1 line
2.34.1
PATCH v12 7/36 remoteproc: k3-r5: Refactor Data Structures to Align with DSP and M4
In reply to Beleswar PadhiCurrently, struct members such as mem, num_mems, reset, tsp, ti_sci and ti_sci_id are part of the k3_r5_core structure. To align the rproc->priv data structure of the R5 remote processor with that of the DSP and M4, move the above members from k3_r5_core to k3_r5_rproc struct.
Additionally, introduce a void *priv pointer in k3_r5_rproc that can be typecasted to point to the k3_r5_core structure. This abstraction is done to ensure common functionalities across R5, DSP and M4 drivers can be refactored at a later stage.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
None
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_r5_remoteproc.c | 375 ++++++++++++----------- 1 file changed, 195 insertions(+), 180 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +195 -180
@@ -114,19 +114,16 @@ struct k3_r5_cluster {const struct k3_r5_soc_data *soc_data; }; +struct k3_r5_rproc ; +/** * struct k3_r5_core - K3 R5 core structure * @elem: linked list item * @dev: cached device pointer -* @rproc: rproc handle representing this core -* @mem: internal memory regions data +* @kproc: K3 rproc handle representing this core +* @cluster: cached pointer to parent cluster structure * @sram: on-chip SRAM memory regions data -* @num_mems: number of internal memory regions * @num_sram: number of on-chip SRAM memory regions -* @reset: reset control handle -* @tsp: TI-SCI processor control handle -* @ti_sci: TI-SCI handle -* @ti_sci_id: TI-SCI device identifier * @atcm_enable: flag to control ATCM enablement * @btcm_enable: flag to control BTCM enablement * @loczrama: flag to dictate which TCM is at device address 0x0
@@ -135,15 +132,10 @@ struct k3_r5_cluster {struct k3_r5_core {struct list_head elem;struct device *dev; -struct rproc *rproc; -struct k3_r5_mem *mem; +struct k3_r5_rproc *kproc; +struct k3_r5_cluster *cluster;struct k3_r5_mem *sram; -int num_mems;int num_sram; -struct reset_control *reset; -struct ti_sci_proc *tsp; -const struct ti_sci_handle *ti_sci; -u32 ti_sci_id;u32 atcm_enable;u32 btcm_enable;u32 loczrama;
@@ -153,23 +145,33 @@ struct k3_r5_core {/** * struct k3_r5_rproc - K3 remote processor state * @dev: cached device pointer -* @cluster: cached pointer to parent cluster structure -* @mbox: mailbox channel handle -* @client: mailbox client to request the mailbox channel * @rproc: rproc handle -* @core: cached pointer to r5 core structure being used +* @mem: internal memory regions data +* @num_mems: number of internal memory regions * @rmem: reserved memory regions data * @num_rmems: number of reserved memory regions +* @reset: reset control handle +* @tsp: TI-SCI processor 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: Remote processor private data */ struct k3_r5_rproc {struct device *dev; -struct k3_r5_cluster *cluster; -struct mbox_chan *mbox; -struct mbox_client client;struct rproc *rproc; -struct k3_r5_core *core; +struct k3_r5_mem *mem; +int num_mems;struct k3_r5_mem *rmem;int num_rmems; +struct reset_control *reset; +struct ti_sci_proc *tsp; +const struct ti_sci_handle *ti_sci; +u32 ti_sci_id; +struct mbox_chan *mbox; +struct mbox_client client; +void *priv; };/**
@@ -236,48 +238,48 @@ static void k3_r5_rproc_kick(struct rproc *rproc, int vqid) ret); } -static int k3_r5_split_reset (struct k3_r5_core *core) +static int k3_r5_split_reset (struct k3_r5_rproc *kproc) {int ret; - ret =reset_control_assert (core->reset); + ret =reset_control_assert (kproc->reset);if (ret) { -dev_err (core->dev,"local-reset assert failed, ret = %d\n" , +dev_err (kproc->dev,"local-reset assert failed, ret = %d\n" , ret);return ret; } - ret = core->ti_sci->ops.dev_ops.put_device (core->ti_sci, - core->ti_sci_id); + ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id);if (ret) { -dev_err (core->dev,"module-reset assert failed, ret = %d\n" , +dev_err (kproc->dev,"module-reset assert failed, ret = %d\n" , ret); -if (reset_control_deassert (core->reset)) -dev_warn (core->dev,"local-reset deassert back failed\n" ); +if (reset_control_deassert (kproc->reset)) +dev_warn (kproc->dev,"local-reset deassert back failed\n" ); }return ret; } -static int k3_r5_split_release (struct k3_r5_core *core) +static int k3_r5_split_release (struct k3_r5_rproc *kproc) {int ret; - ret = core->ti_sci->ops.dev_ops.get_device (core->ti_sci, - core->ti_sci_id); + ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, + kproc->ti_sci_id);if (ret) { -dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , +dev_err (kproc->dev,"module-reset deassert failed, ret = %d\n" , ret);return ret; } - ret =reset_control_deassert (core->reset); + ret =reset_control_deassert (kproc->reset);if (ret) { -dev_err (core->dev,"local-reset deassert failed, ret = %d\n" , +dev_err (kproc->dev,"local-reset deassert failed, ret = %d\n" , ret); -if (core->ti_sci->ops.dev_ops.put_device (core->ti_sci, - core->ti_sci_id)) -dev_warn (core->dev,"module-reset assert back failed\n" ); +if (kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id)) +dev_warn (kproc->dev,"module-reset assert back failed\n" ); }return ret;
@@ -286,11 +288,12 @@ static int k3_r5_split_release(struct k3_r5_core *core)static int k3_r5_lockstep_reset (struct k3_r5_cluster *cluster) {struct k3_r5_core *core; +struct k3_r5_rproc *kproc;int ret;/* assert local reset on all applicable cores */ list_for_each_entry (core, &cluster->cores, elem) { - ret =reset_control_assert (core->reset); + ret =reset_control_assert (core->kproc->reset);if (ret) {dev_err (core->dev,"local-reset assert failed, ret = %d\n" , ret);
@@ -301,8 +304,9 @@ 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) { - ret = core->ti_sci->ops.dev_ops.put_device (core->ti_sci, - core->ti_sci_id); + kproc = core->kproc; + ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id);if (ret) {dev_err (core->dev,"module-reset assert failed, ret = %d\n" , ret);
@@ -314,14 +318,15 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster) unroll_module_reset:list_for_each_entry_continue_reverse (core, &cluster->cores, elem) { -if (core->ti_sci->ops.dev_ops.put_device (core->ti_sci, - core->ti_sci_id)) + kproc = core->kproc; +if (kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id))dev_warn (core->dev,"module-reset assert back failed\n" ); } core = list_last_entry(&cluster->cores, struct k3_r5_core, elem); unroll_local_reset:list_for_each_entry_from_reverse (core, &cluster->cores, elem) { -if (reset_control_deassert (core->reset)) +if (reset_control_deassert (core->kproc->reset))dev_warn (core->dev,"local-reset deassert back failed\n" ); }
@@ -331,12 +336,14 @@ static int k3_r5_lockstep_reset(struct k3_r5_cluster *cluster)static int k3_r5_lockstep_release (struct k3_r5_cluster *cluster) {struct k3_r5_core *core; +struct k3_r5_rproc *kproc;int ret;/* enable PSC modules on all applicable cores */ list_for_each_entry_reverse (core, &cluster->cores, elem) { - ret = core->ti_sci->ops.dev_ops.get_device (core->ti_sci, - core->ti_sci_id); + kproc = core->kproc; + ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, + kproc->ti_sci_id);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);
@@ -347,7 +354,7 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster)/* deassert local reset on all applicable cores */ list_for_each_entry_reverse (core, &cluster->cores, elem) { - ret =reset_control_deassert (core->reset); + ret =reset_control_deassert (core->kproc->reset);if (ret) {dev_err (core->dev,"module-reset deassert failed, ret = %d\n" , ret);
@@ -359,29 +366,30 @@ static int k3_r5_lockstep_release(struct k3_r5_cluster *cluster) unroll_local_reset:list_for_each_entry_continue (core, &cluster->cores, elem) { -if (reset_control_assert (core->reset)) +if (reset_control_assert (core->kproc->reset))dev_warn (core->dev,"local-reset assert back failed\n" ); } core = list_first_entry(&cluster->cores, struct k3_r5_core, elem); unroll_module_reset:list_for_each_entry_from (core, &cluster->cores, elem) { -if (core->ti_sci->ops.dev_ops.put_device (core->ti_sci, - core->ti_sci_id)) + kproc = core->kproc; +if (kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id))dev_warn (core->dev,"module-reset assert back failed\n" ); }return ret; } -static inline int k3_r5_core_halt (struct k3_r5_core *core) +static inline int k3_r5_core_halt (struct k3_r5_rproc *kproc) { -return ti_sci_proc_set_control (core->tsp, +return ti_sci_proc_set_control (kproc->tsp,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ,0 ); } -static inline int k3_r5_core_run (struct k3_r5_core *core) +static inline int k3_r5_core_run (struct k3_r5_rproc *kproc) { -return ti_sci_proc_set_control (core->tsp, +return ti_sci_proc_set_control (kproc->tsp,0 ,PROC_BOOT_CTRL_FLAG_R5_CORE_HALT ); }
@@ -439,8 +447,8 @@ static int k3_r5_rproc_request_mbox(struct rproc *rproc)static int k3_r5_rproc_prepare (struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv; -struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core, *core0, *core1; +struct k3_r5_core *core = kproc->priv, *core0, *core1; +struct k3_r5_cluster *cluster = core->cluster;struct device *dev = kproc->dev;u32 ctrl =0 , cfg =0 , stat =0 ;u64 boot_vec =0 ;
@@ -470,7 +478,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc) } } - ret =ti_sci_proc_get_status (core->tsp, &boot_vec, &cfg, &ctrl, &stat); + ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret; mem_init_dis = !!(cfg &PROC_BOOT_CFG_FLAG_R5_MEM_INIT_DIS );
@@ -478,7 +486,7 @@ static int k3_r5_rproc_prepare(struct rproc *rproc)/* Re-use LockStep-mode reset logic for Single-CPU mode */ ret = (cluster->mode ==CLUSTER_MODE_LOCKSTEP || cluster->mode ==CLUSTER_MODE_SINGLECPU ) ? -k3_r5_lockstep_release (cluster) :k3_r5_split_release (core); +k3_r5_lockstep_release (cluster) :k3_r5_split_release (kproc);if (ret) {dev_err (dev,"unable to enable cores for TCM loading, ret = %d\n" , ret);
@@ -510,10 +518,10 @@ static int k3_r5_rproc_prepare(struct rproc *rproc)* can be effective on all TCM addresses. */ dev_dbg (dev,"zeroing out ATCM memory\n" ); -memset_io (core->mem[0 ].cpu_addr,0x00 , core->mem[0 ].size); +memset_io (kproc->mem[0 ].cpu_addr,0x00 , kproc->mem[0 ].size);dev_dbg (dev,"zeroing out BTCM memory\n" ); -memset_io (core->mem[1 ].cpu_addr,0x00 , core->mem[1 ].size); +memset_io (kproc->mem[1 ].cpu_addr,0x00 , kproc->mem[1 ].size);return 0 ; }
@@ -537,8 +545,8 @@ static int k3_r5_rproc_prepare(struct rproc *rproc)static int k3_r5_rproc_unprepare (struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv; -struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core, *core0, *core1; +struct k3_r5_core *core = kproc->priv, *core0, *core1; +struct k3_r5_cluster *cluster = core->cluster;struct device *dev = kproc->dev;int ret;
@@ -565,7 +573,7 @@ static int k3_r5_rproc_unprepare(struct rproc *rproc)/* Re-use LockStep-mode reset logic for Single-CPU mode */ ret = (cluster->mode ==CLUSTER_MODE_LOCKSTEP || cluster->mode ==CLUSTER_MODE_SINGLECPU ) ? -k3_r5_lockstep_reset (cluster) :k3_r5_split_reset (core); +k3_r5_lockstep_reset (cluster) :k3_r5_split_reset (kproc);if (ret)dev_err (dev,"unable to disable cores, ret = %d\n" , ret);
@@ -600,9 +608,9 @@ static int k3_r5_rproc_unprepare(struct rproc *rproc)static int k3_r5_rproc_start (struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv; -struct k3_r5_cluster *cluster = kproc->cluster; +struct k3_r5_core *core = kproc->priv; +struct k3_r5_cluster *cluster = core->cluster;struct device *dev = kproc->dev; -struct k3_r5_core *core;u32 boot_addr;int ret;
@@ -611,20 +619,19 @@ 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 */ - core = kproc->core; - ret =ti_sci_proc_set_config (core->tsp, boot_addr,0 ,0 ); + ret =ti_sci_proc_set_config (kproc->tsp, boot_addr,0 ,0 );if (ret)return ret;/* unhalt/run all applicable cores */ if (cluster->mode ==CLUSTER_MODE_LOCKSTEP ) {list_for_each_entry_reverse (core, &cluster->cores, elem) { - ret =k3_r5_core_run (core); + ret =k3_r5_core_run (core->kproc);if (ret) goto unroll_core_run; } }else { - ret =k3_r5_core_run (core); + ret =k3_r5_core_run (core->kproc);if (ret)return ret; }
@@ -633,7 +640,7 @@ static int k3_r5_rproc_start(struct rproc *rproc) unroll_core_run:list_for_each_entry_continue (core, &cluster->cores, elem) { -if (k3_r5_core_halt (core)) +if (k3_r5_core_halt (core->kproc))dev_warn (core->dev,"core halt back failed\n" ); }return ret;
@@ -666,21 +673,21 @@ static int k3_r5_rproc_start(struct rproc *rproc)static int k3_r5_rproc_stop (struct rproc *rproc) {struct k3_r5_rproc *kproc = rproc->priv; -struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core; +struct k3_r5_core *core = kproc->priv; +struct k3_r5_cluster *cluster = core->cluster;int ret;/* halt all applicable cores */ if (cluster->mode ==CLUSTER_MODE_LOCKSTEP ) {list_for_each_entry (core, &cluster->cores, elem) { - ret =k3_r5_core_halt (core); + ret =k3_r5_core_halt (core->kproc);if (ret) { core =list_prev_entry (core, elem); goto unroll_core_halt; } } }else { - ret =k3_r5_core_halt (core); + ret =k3_r5_core_halt (core->kproc);if (ret) goto out; }
@@ -689,7 +696,7 @@ static int k3_r5_rproc_stop(struct rproc *rproc) unroll_core_halt:list_for_each_entry_from_reverse (core, &cluster->cores, elem) { -if (k3_r5_core_run (core)) +if (k3_r5_core_run (core->kproc))dev_warn (core->dev,"core run back failed\n" ); } out:
@@ -759,7 +766,7 @@ static struct resource_table *k3_r5_get_loaded_rsc_table(struct rproc *rproc,static void *k3_r5_rproc_da_to_va (struct rproc *rproc,u64 da,size_t len,bool *is_iomem) {struct k3_r5_rproc *kproc = rproc->priv; -struct k3_r5_core *core = kproc->core; +struct k3_r5_core *core = kproc->priv;void __iomem *va =NULL ;phys_addr_t bus_addr;u32 dev_addr, offset;
@@ -770,22 +777,22 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolreturn NULL ;/* handle both R5 and SoC views of ATCM and BTCM */ -for (i =0 ; i < core->num_mems; i++) { - bus_addr = core->mem[i].bus_addr; - dev_addr = core->mem[i].dev_addr; - size = core->mem[i].size; +for (i =0 ; i < kproc->num_mems; i++) { + bus_addr = kproc->mem[i].bus_addr; + dev_addr = kproc->mem[i].dev_addr; + size = kproc->mem[i].size;/* handle R5-view addresses of TCMs */ if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { offset = da - dev_addr; - va = core->mem[i].cpu_addr + offset; + va = kproc->mem[i].cpu_addr + offset;return (__force void *)va; }/* handle SoC-view addresses of TCMs */ if (da >= bus_addr && ((da + len) <= (bus_addr + size))) { offset = da - bus_addr; - va = core->mem[i].cpu_addr + offset; + va = kproc->mem[i].cpu_addr + offset;return (__force void *)va; } }
@@ -863,9 +870,9 @@ static const struct rproc_ops k3_r5_rproc_ops = {*/ static int k3_r5_rproc_configure (struct k3_r5_rproc *kproc) { -struct k3_r5_cluster *cluster = kproc->cluster; +struct k3_r5_core *temp, *core0, *core = kproc->priv; +struct k3_r5_cluster *cluster = core->cluster;struct device *dev = kproc->dev; -struct k3_r5_core *core0, *core, *temp;u32 ctrl =0 , cfg =0 , stat =0 ;u32 set_cfg =0 , clr_cfg =0 ;u64 boot_vec =0 ;
@@ -879,10 +886,10 @@ static int k3_r5_rproc_configure(struct k3_r5_rproc *kproc) cluster->mode == CLUSTER_MODE_SINGLECORE) { core = core0; } else { - core = kproc->core; + core = kproc->priv; } - ret =ti_sci_proc_get_status (core->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_proc_get_status (core->kproc->tsp, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 )return ret;
@@ -952,7 +959,7 @@ static int k3_r5_rproc_configure(struct k3_r5_rproc *kproc)* and TEINIT config is only allowed with Core0. */ list_for_each_entry (temp, &cluster->cores, elem) { - ret =k3_r5_core_halt (temp); + ret =k3_r5_core_halt (temp->kproc);if (ret) goto out;
@@ -960,7 +967,7 @@ static int k3_r5_rproc_configure(struct k3_r5_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->tsp, boot_vec, + ret =ti_sci_proc_set_config (temp->kproc->tsp, boot_vec, set_cfg, clr_cfg);if (ret) goto out;
@@ -968,14 +975,14 @@ static int k3_r5_rproc_configure(struct k3_r5_rproc *kproc) set_cfg =PROC_BOOT_CFG_FLAG_R5_LOCKSTEP ; clr_cfg =0 ; - ret =ti_sci_proc_set_config (core->tsp, boot_vec, + ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, set_cfg, clr_cfg); }else { - ret =k3_r5_core_halt (core); + ret =k3_r5_core_halt (core->kproc);if (ret) goto out; - ret =ti_sci_proc_set_config (core->tsp, boot_vec, + ret =ti_sci_proc_set_config (core->kproc->tsp, boot_vec, set_cfg, clr_cfg); }
@@ -1085,10 +1092,9 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)*/ static void k3_r5_adjust_tcm_sizes (struct k3_r5_rproc *kproc) { -struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core; +struct k3_r5_core *core0, *core = kproc->priv; +struct k3_r5_cluster *cluster = core->cluster;struct device *cdev = core->dev; -struct k3_r5_core *core0; if (cluster->mode == CLUSTER_MODE_LOCKSTEP || cluster->mode == CLUSTER_MODE_SINGLECPU ||
@@ -1098,14 +1104,14 @@ static void k3_r5_adjust_tcm_sizes(struct k3_r5_rproc *kproc) core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem);if (core == core0) { -WARN_ON (core->mem[0 ].size !=SZ_64K ); -WARN_ON (core->mem[1 ].size !=SZ_64K ); +WARN_ON (kproc->mem[0 ].size !=SZ_64K ); +WARN_ON (kproc->mem[1 ].size !=SZ_64K ); - core->mem[0 ].size /=2 ; - core->mem[1 ].size /=2 ; + kproc->mem[0 ].size /=2 ; + kproc->mem[1 ].size /=2 ;dev_dbg (cdev,"adjusted TCM sizes, ATCM = 0x%zx BTCM = 0x%zx\n" , - core->mem[0 ].size, core->mem[1 ].size); + kproc->mem[0 ].size, kproc->mem[1 ].size); } }
@@ -1124,22 +1130,21 @@ static void k3_r5_adjust_tcm_sizes(struct k3_r5_rproc *kproc)*/ static int k3_r5_rproc_configure_mode (struct k3_r5_rproc *kproc) { -struct k3_r5_cluster *cluster = kproc->cluster; -struct k3_r5_core *core = kproc->core; +struct k3_r5_core *core0, *core = kproc->priv; +struct k3_r5_cluster *cluster = core->cluster;struct device *cdev = core->dev;bool r_state = false, c_state = false, lockstep_en = false, single_cpu = false;u32 ctrl =0 , cfg =0 , stat =0 , halted =0 ;u64 boot_vec =0 ;u32 atcm_enable, btcm_enable, loczrama; -struct k3_r5_core *core0;enum cluster_mode mode = cluster->mode;int reset_ctrl_status;int ret; core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem); - ret = core->ti_sci->ops.dev_ops.is_on (core->ti_sci, core->ti_sci_id, - &r_state, &c_state); + ret = kproc->ti_sci->ops.dev_ops.is_on (kproc->ti_sci, kproc->ti_sci_id, + &r_state, &c_state);if (ret) {dev_err (cdev,"failed to get initial state, mode cannot be determined, ret = %d\n" , ret);
@@ -1150,7 +1155,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc) r_state, c_state); } - reset_ctrl_status =reset_control_status (core->reset); + reset_ctrl_status =reset_control_status (kproc->reset);if (reset_ctrl_status <0 ) {dev_err (cdev,"failed to get initial local reset status, ret = %d\n" , reset_ctrl_status);
@@ -1163,7 +1168,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)*/ core->released_from_reset = c_state; - ret =ti_sci_proc_get_status (core->tsp, &boot_vec, &cfg, &ctrl, + ret =ti_sci_proc_get_status (kproc->tsp, &boot_vec, &cfg, &ctrl, &stat);if (ret <0 ) { dev_err(cdev, "failed to get initial processor status, ret = %d\n",
@@ -1220,25 +1225,26 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc) core->atcm_enable = atcm_enable; core->btcm_enable = btcm_enable; core->loczrama = loczrama; - core->mem[0 ].dev_addr = loczrama ?0 :K3_R5_TCM_DEV_ADDR ; - core->mem[1 ].dev_addr = loczrama ?K3_R5_TCM_DEV_ADDR :0 ; + kproc->mem[0 ].dev_addr = loczrama ?0 :K3_R5_TCM_DEV_ADDR ; + kproc->mem[1 ].dev_addr = loczrama ?K3_R5_TCM_DEV_ADDR :0 ; }return ret; }static int k3_r5_core_of_get_internal_memories (struct platform_device *pdev, -struct k3_r5_core *core) +struct k3_r5_rproc *kproc) {static const char *const mem_names[] = {"atcm" ,"btcm" };struct device *dev = &pdev->dev; +struct k3_r5_core *core = kproc->priv;struct resource *res;int num_mems;int i; num_mems =ARRAY_SIZE (mem_names); - core->mem =devm_kcalloc (dev, num_mems,sizeof (*core->mem),GFP_KERNEL ); -if (!core->mem) + kproc->mem =devm_kcalloc (dev, num_mems,sizeof (*kproc->mem),GFP_KERNEL ); +if (!kproc->mem)return -ENOMEM ;for (i =0 ; i < num_mems; i++) {
@@ -1264,13 +1270,13 @@ static int k3_r5_core_of_get_internal_memories(struct platform_device *pdev,* unaligned data accesses when using memcpy() or memset() * functions (normally seen with device type memory). */ - core->mem[i].cpu_addr =devm_ioremap_wc (dev, res->start, -resource_size (res)); -if (!core->mem[i].cpu_addr) { + kproc->mem[i].cpu_addr =devm_ioremap_wc (dev, res->start, +resource_size (res)); +if (!kproc->mem[i].cpu_addr) {dev_err (dev,"failed to map %s memory\n" , mem_names[i]);return -ENOMEM ; } - core->mem[i].bus_addr = res->start; + kproc->mem[i].bus_addr = res->start;/* * TODO:
@@ -1281,20 +1287,20 @@ static int k3_r5_core_of_get_internal_memories(struct platform_device *pdev,* SoCs) based on loczrama setting */ if (!strcmp (mem_names[i],"atcm" )) { - core->mem[i].dev_addr = core->loczrama ? + kproc->mem[i].dev_addr = core->loczrama ?0 :K3_R5_TCM_DEV_ADDR ; }else { - core->mem[i].dev_addr = core->loczrama ? + kproc->mem[i].dev_addr = core->loczrama ?K3_R5_TCM_DEV_ADDR :0 ; } - core->mem[i].size =resource_size (res); + kproc->mem[i].size =resource_size (res);dev_dbg (dev,"memory %5s: bus addr %pa size 0x%zx va %pK da 0x%x\n" , - mem_names[i], &core->mem[i].bus_addr, - core->mem[i].size, core->mem[i].cpu_addr, - core->mem[i].dev_addr); + mem_names[i], &kproc->mem[i].bus_addr, + kproc->mem[i].size, kproc->mem[i].cpu_addr, + kproc->mem[i].dev_addr); } - core->num_mems = num_mems; + kproc->num_mems = num_mems;return 0 ; }
@@ -1369,6 +1375,7 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)struct device *dev = &pdev->dev;struct k3_r5_rproc *kproc;struct k3_r5_core *core, *core1; +struct device_node *np;struct device *cdev;const char *fw_name;struct rproc *rproc;
@@ -1377,6 +1384,7 @@ 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",
@@ -1397,11 +1405,63 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) rproc->recovery_disabled = true; kproc = rproc->priv; - kproc->cluster = cluster; - kproc->core = core; + kproc->priv = core; kproc->dev = cdev; kproc->rproc = rproc; - core->rproc = rproc; + core->kproc = kproc; + + kproc->ti_sci =devm_ti_sci_get_by_phandle (cdev,"ti,sci" ); +if (IS_ERR (kproc->ti_sci)) { + ret =dev_err_probe (cdev,PTR_ERR (kproc->ti_sci), +"failed to get ti-sci handle\n" ); + kproc->ti_sci =NULL ; + 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_OR_NULL (kproc->reset)) { + ret =PTR_ERR_OR_ZERO (kproc->reset); +if (!ret) + ret = -ENODEV ; +dev_err_probe (cdev, ret,"failed to get reset handle\n" ); + 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; + } + + 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" , + ret); + goto out; + } + + ret =ti_sci_proc_request (kproc->tsp); +if (ret <0 ) { +dev_err (cdev,"ti_sci_proc_request failed, ret = %d\n" , ret); + goto out; + } + + ret =devm_add_action_or_reset (cdev, k3_r5_release_tsp, kproc->tsp); +if (ret) + goto out; + } + +list_for_each_entry (core, &cluster->cores, elem) { + cdev = core->dev; + kproc = core->kproc; + rproc = kproc->rproc; ret =k3_r5_rproc_request_mbox (rproc);if (ret)
@@ -1415,7 +1475,7 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) ret =k3_r5_rproc_configure (kproc);if (ret) { -dev_err (dev,"initial configure failed, ret = %d\n" , +dev_err (cdev,"initial configure failed, ret = %d\n" , ret); goto out; }
@@ -1425,14 +1485,14 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) ret =k3_r5_reserved_mem_init (kproc);if (ret) { -dev_err (dev,"reserved memory init failed, ret = %d\n" , +dev_err (cdev,"reserved memory init failed, ret = %d\n" , ret); goto out; } - ret =devm_rproc_add (dev, rproc); + ret =devm_rproc_add (cdev, rproc);if (ret) { -dev_err_probe (dev, ret,"rproc_add failed\n" ); +dev_err_probe (cdev, ret,"rproc_add failed\n" ); goto out; }
@@ -1461,8 +1521,8 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev)/* undo core0 upon any failures on core1 in split-mode */ if (cluster->mode ==CLUSTER_MODE_SPLIT && core == core1) { core =list_prev_entry (core, elem); - rproc = core->rproc; - kproc = rproc->priv; + kproc = core->kproc; + rproc = kproc->rproc; goto err_split; }return ret;
@@ -1487,8 +1547,8 @@ static void k3_r5_cluster_rproc_exit(void *data) list_last_entry(&cluster->cores, struct k3_r5_core, elem);list_for_each_entry_from_reverse (core, &cluster->cores, elem) { - rproc = core->rproc; - kproc = rproc->priv; + kproc = core->kproc; + rproc = kproc->rproc;if (rproc->state ==RPROC_ATTACHED ) { ret =rproc_detach (rproc);
@@ -1547,58 +1607,12 @@ static int k3_r5_core_of_init(struct platform_device *pdev) goto err; } - core->ti_sci =devm_ti_sci_get_by_phandle (dev,"ti,sci" ); -if (IS_ERR (core->ti_sci)) { - ret =dev_err_probe (dev,PTR_ERR (core->ti_sci),"failed to get ti-sci handle\n" ); - core->ti_sci =NULL ; - goto err; - } - - ret =of_property_read_u32 (np,"ti,sci-dev-id" , &core->ti_sci_id); -if (ret) { -dev_err (dev,"missing 'ti,sci-dev-id' property\n" ); - goto err; - } - - core->reset =devm_reset_control_get_exclusive (dev,NULL ); -if (IS_ERR_OR_NULL (core->reset)) { - ret =PTR_ERR_OR_ZERO (core->reset); -if (!ret) - ret = -ENODEV ; -dev_err_probe (dev, ret,"failed to get reset handle\n" ); - goto err; - } - - core->tsp =ti_sci_proc_of_get_tsp (dev, core->ti_sci); -if (IS_ERR (core->tsp)) { - ret =dev_err_probe (dev,PTR_ERR (core->tsp), -"failed to construct ti-sci proc control\n" ); - goto err; - } - - ret =k3_r5_core_of_get_internal_memories (pdev, core); -if (ret) { -dev_err (dev,"failed to get internal memories, ret = %d\n" , - ret); - goto err; - } - ret =k3_r5_core_of_get_sram_memories (pdev, core);if (ret) {dev_err (dev,"failed to get sram memories, ret = %d\n" , ret); goto err; } - ret =ti_sci_proc_request (core->tsp); -if (ret <0 ) { -dev_err (dev,"ti_sci_proc_request failed, ret = %d\n" , ret); - goto err; - } - - ret =devm_add_action_or_reset (dev, k3_r5_release_tsp, core->tsp); -if (ret) - goto err; -platform_set_drvdata (pdev, core);devres_close_group (dev, k3_r5_core_of_init);
@@ -1660,6 +1674,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev) } core =platform_get_drvdata (cpdev); + core->cluster = cluster;put_device (&cpdev->dev);list_add_tail (&core->elem, &cluster->cores); }
Signature · 1 line
2.34.1
PATCH v12 8/36 remoteproc: k3-r5: Use k3_r5_rproc_mem_data structure for memory info
In reply to Beleswar PadhiThe ti_k3_r5_remoteproc.c driver previously hardcoded device memory region addresses and names. Change this to use the k3_r5_rproc_mem_data structure to store memory information. This aligns with K3 DSP and M4 drivers, and can be refactored out later.
---
v12: Changelog:
1. Assign data->num_mems to num_mems. [Mathieu]
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Collected R/B from v9 version of this patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_r5_remoteproc.c | 65 ++++++++++++++++++++---- 1 file changed, 56 insertions(+), 9 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +56 -9
@@ -84,18 +84,44 @@ enum cluster_mode { CLUSTER_MODE_SINGLECORE }; +/** +* struct k3_r5_mem_data - memory definitions for a R5 +* @name: name for this memory entry +* @dev_addr: device address for the memory entry +*/ +struct k3_r5_mem_data { +const char *name; +const u32 dev_addr; +}; + +/** +* struct k3_r5_dev_data - device data structure for a R5 +* @mems: pointer to memory definitions for a R5 +* @num_mems: number of memory regions in @mems +* @boot_align_addr: boot vector address alignment granularity +* @uses_lreset: flag to denote the need for local reset management +*/ +struct k3_r5_dev_data { +const struct k3_r5_mem_data *mems; +u32 num_mems; +u32 boot_align_addr; +bool uses_lreset; +}; +/** * struct k3_r5_soc_data - match data to handle SoC variations * @tcm_is_double: flag to denote the larger unified TCMs in certain modes * @tcm_ecc_autoinit: flag to denote the auto-initialization of TCMs for ECC * @single_cpu_mode: flag to denote if SoC/IP supports Single-CPU mode * @is_single_core: flag to denote if SoC/IP has only single core R5 +* @core_data: pointer to R5-core-specific device data */ struct k3_r5_soc_data {bool tcm_is_double;bool tcm_ecc_autoinit;bool single_cpu_mode;bool is_single_core; +const struct k3_r5_dev_data *core_data; };/**
@@ -151,6 +177,7 @@ struct k3_r5_core {* @rmem: reserved memory regions data * @num_rmems: number of reserved memory regions * @reset: reset control handle +* @data: pointer to R5-core-specific device data * @tsp: TI-SCI processor control handle * @ti_sci: TI-SCI handle * @ti_sci_id: TI-SCI device identifier
@@ -166,6 +193,7 @@ struct k3_r5_rproc {struct k3_r5_mem *rmem;int num_rmems;struct reset_control *reset; +const struct k3_r5_dev_data *data;struct ti_sci_proc *tsp;const struct ti_sci_handle *ti_sci;u32 ti_sci_id;
@@ -1235,31 +1263,32 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)static int k3_r5_core_of_get_internal_memories (struct platform_device *pdev,struct k3_r5_rproc *kproc) { -static const char *const mem_names[] = {"atcm" ,"btcm" }; +const struct k3_r5_dev_data *data = kproc->data;struct device *dev = &pdev->dev;struct k3_r5_core *core = kproc->priv;struct resource *res;int num_mems;int i; - num_mems =ARRAY_SIZE (mem_names); - kproc->mem =devm_kcalloc (dev, num_mems,sizeof (*kproc->mem),GFP_KERNEL ); + num_mems = data->num_mems; + kproc->mem =devm_kcalloc (kproc->dev, num_mems,sizeof (*kproc->mem), +GFP_KERNEL );if (!kproc->mem)return -ENOMEM ;for (i =0 ; i < num_mems; i++) { res =platform_get_resource_byname (pdev,IORESOURCE_MEM , - mem_names[i]); + data->mems[i].name);if (!res) {dev_err (dev,"found no memory resource for %s\n" , - mem_names[i]); + data->mems[i].name);return -EINVAL ; }if (!devm_request_mem_region (dev, res->start,resource_size (res),dev_name (dev))) {dev_err (dev,"could not request %s region for resource\n" , - mem_names[i]); + data->mems[i].name);return -EBUSY ; }
@@ -1273,7 +1302,8 @@ static int k3_r5_core_of_get_internal_memories(struct platform_device *pdev, kproc->mem[i].cpu_addr =devm_ioremap_wc (dev, res->start,resource_size (res));if (!kproc->mem[i].cpu_addr) { -dev_err (dev,"failed to map %s memory\n" , mem_names[i]); +dev_err (dev,"failed to map %s memory\n" , + data->mems[i].name);return -ENOMEM ; } kproc->mem[i].bus_addr = res->start;
@@ -1286,7 +1316,7 @@ static int k3_r5_core_of_get_internal_memories(struct platform_device *pdev,* addresses 0 and 0x41010000 (same as the bus address on AM65x * SoCs) based on loczrama setting */ -if (!strcmp (mem_names[i],"atcm" )) { +if (!strcmp (data->mems[i].name,"atcm" )) { kproc->mem[i].dev_addr = core->loczrama ?0 :K3_R5_TCM_DEV_ADDR ; }else {
@@ -1296,7 +1326,7 @@ static int k3_r5_core_of_get_internal_memories(struct platform_device *pdev, kproc->mem[i].size =resource_size (res);dev_dbg (dev,"memory %5s: bus addr %pa size 0x%zx va %pK da 0x%x\n" , - mem_names[i], &kproc->mem[i].bus_addr, + data->mems[i].name, &kproc->mem[i].bus_addr, kproc->mem[i].size, kproc->mem[i].cpu_addr, kproc->mem[i].dev_addr); }
@@ -1408,6 +1438,7 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) kproc->priv = core; kproc->dev = cdev; kproc->rproc = rproc; + kproc->data = cluster->soc_data->core_data; core->kproc = kproc; kproc->ti_sci =devm_ti_sci_get_by_phandle (cdev,"ti,sci" );
@@ -1772,11 +1803,24 @@ static int k3_r5_probe(struct platform_device *pdev)return 0 ; } +static const struct k3_r5_mem_data r5_mems[] = { + { .name ="atcm" , .dev_addr =0x0 }, + { .name ="btcm" , .dev_addr =K3_R5_TCM_DEV_ADDR }, +}; + +static const struct k3_r5_dev_data r5_data = { + .mems = r5_mems, + .num_mems =ARRAY_SIZE (r5_mems), + .boot_align_addr =0 , + .uses_lreset = true, +}; +static const struct k3_r5_soc_data am65_j721e_soc_data = { .tcm_is_double = false, .tcm_ecc_autoinit = false, .single_cpu_mode = false, .is_single_core = false, + .core_data = &r5_data, };static const struct k3_r5_soc_data j7200_j721s2_soc_data = {
@@ -1784,6 +1828,7 @@ static const struct k3_r5_soc_data j7200_j721s2_soc_data = { .tcm_ecc_autoinit = true, .single_cpu_mode = false, .is_single_core = false, + .core_data = &r5_data, };static const struct k3_r5_soc_data am64_soc_data = {
@@ -1791,6 +1836,7 @@ static const struct k3_r5_soc_data am64_soc_data = { .tcm_ecc_autoinit = true, .single_cpu_mode = true, .is_single_core = false, + .core_data = &r5_data, };static const struct k3_r5_soc_data am62_soc_data = {
@@ -1798,6 +1844,7 @@ static const struct k3_r5_soc_data am62_soc_data = { .tcm_ecc_autoinit = true, .single_cpu_mode = false, .is_single_core = true, + .core_data = &r5_data, };static const struct of_device_id k3_r5_of_match[] = {
Signature · 1 line
2.34.1
PATCH v12 9/36 remoteproc: k3-{m4/dsp}: Add a void ptr member in rproc internal struct
In reply to Beleswar PadhiIntroduce a void pointer in the k3_{m4/dsp}_rproc internal data structure which can be used to point to any private data needed by the driver. Currently, the M4/DSP drivers do not have any private data, so the pointer can be left pointing to NULL.
This is done to align the data structures with R5 driver which can be factored out at a later stage.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 04/26] into [v10 08/33] and [v10 09/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 2 ++ drivers/remoteproc/ti_k3_m4_remoteproc.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -0
@@ -76,6 +76,7 @@ struct k3_dsp_dev_data {* @ti_sci_id: TI-SCI device identifier * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel +* @priv: Remote processor private data */ struct k3_dsp_rproc {struct device *dev;
@@ -91,6 +92,7 @@ struct k3_dsp_rproc {u32 ti_sci_id;struct mbox_chan *mbox;struct mbox_client client; +void *priv; };/**
drivers/remoteproc/ti_k3_m4_remoteproc.c +2 -0
@@ -60,6 +60,7 @@ struct k3_m4_rproc_mem_data {* @ti_sci_id: TI-SCI device identifier * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel +* @priv: Remote processor private data */ struct k3_m4_rproc {struct device *dev;
@@ -73,6 +74,7 @@ struct k3_m4_rproc {u32 ti_sci_id;struct mbox_chan *mbox;struct mbox_client client; +void *priv; };/**
Signature · 1 line
2.34.1
PATCH v12 10/36 remoteproc: k3-m4: Add pointer to rproc struct within k3_m4_rproc
In reply to Beleswar PadhiAdd a pointer to the rproc struct within k3_m4_rproc internal struct. This is done to align the M4 internal rproc data structure with R5 driver which can be factored out at a later stage.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 04/26] into [v10 08/33] and [v10 09/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_m4_remoteproc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/ti_k3_m4_remoteproc.c +3 -0
@@ -50,6 +50,7 @@ struct k3_m4_rproc_mem_data {/** * struct k3_m4_rproc - k3 remote processor driver structure * @dev: cached device pointer +* @rproc: remoteproc device handle * @mem: internal memory regions data * @num_mems: number of internal memory regions * @rmem: reserved memory regions data
@@ -64,6 +65,7 @@ struct k3_m4_rproc_mem_data {*/ struct k3_m4_rproc {struct device *dev; +struct rproc *rproc;struct k3_m4_rproc_mem *mem;int num_mems;struct k3_m4_rproc_mem *rmem;
@@ -580,6 +582,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) rproc->recovery_disabled = true; kproc = rproc->priv; kproc->dev = dev; + kproc->rproc = rproc;platform_set_drvdata (pdev, rproc); kproc->ti_sci =devm_ti_sci_get_by_phandle (dev,"ti,sci" );
Signature · 1 line
2.34.1
PATCH v12 11/36 remoteproc: k3-m4: Use k3_rproc_mem_data structure for memory info
In reply to Beleswar PadhiThe ti_k3_m4_remoteproc.c driver previously hardcoded device memory region addresses and names. Change this to use the k3_rproc_mem_data structure to store memory information. This aligns with DSP and R5 drivers, and can be refactored out later.
---
v12: Changelog:
1. Assign data->num_mems to num_mems. [Mathieu]
2. Move const declaration above variables. [Mathieu]
3. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
None
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_m4_remoteproc.c | 60 ++++++++++++++++++------ 1 file changed, 45 insertions(+), 15 deletions(-)
drivers/remoteproc/ti_k3_m4_remoteproc.c +45 -15
@@ -20,9 +20,6 @@#include "remoteproc_internal.h" #include "ti_sci_proc.h" -#define K3_M4_IRAM_DEV_ADDR 0x00000 -#define K3_M4_DRAM_DEV_ADDR 0x30000 -/** * struct k3_m4_rproc_mem - internal memory structure * @cpu_addr: MPU virtual address of the memory region
@@ -38,15 +35,29 @@ struct k3_m4_rproc_mem { };/** -* struct k3_m4_rproc_mem_data - memory definitions for a remote processor +* struct k3_m4_mem_data - memory definitions for a remote processor * @name: name for this memory entry * @dev_addr: device address for the memory entry */ -struct k3_m4_rproc_mem_data { +struct k3_m4_mem_data {const char *name;const u32 dev_addr; }; +/** +* struct k3_m4_dev_data - device data structure for a M4 core +* @mems: pointer to memory definitions for a M4 core +* @num_mems: number of memory regions in @mems +* @boot_align_addr: boot vector address alignment granularity +* @uses_lreset: flag to denote the need for local reset management +*/ +struct k3_m4_dev_data { +const struct k3_m4_mem_data *mems; +u32 num_mems; +u32 boot_align_addr; +bool uses_lreset; +}; +/** * struct k3_m4_rproc - k3 remote processor driver structure * @dev: cached device pointer
@@ -56,6 +67,7 @@ struct k3_m4_rproc_mem_data {* @rmem: reserved memory regions data * @num_rmems: number of reserved memory regions * @reset: reset control handle +* @data: pointer to M4-specific device data * @tsp: TI-SCI processor control handle * @ti_sci: TI-SCI handle * @ti_sci_id: TI-SCI device identifier
@@ -71,6 +83,7 @@ struct k3_m4_rproc {struct k3_m4_rproc_mem *rmem;int num_rmems;struct reset_control *reset; +const struct k3_m4_dev_data *data;struct ti_sci_proc *tsp;const struct ti_sci_handle *ti_sci;u32 ti_sci_id;
@@ -336,14 +349,13 @@ static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolstatic int k3_m4_rproc_of_get_memories (struct platform_device *pdev,struct k3_m4_rproc *kproc) { -static const char *const mem_names[] = {"iram" ,"dram" }; -static const u32 mem_addrs[] = {K3_M4_IRAM_DEV_ADDR ,K3_M4_DRAM_DEV_ADDR }; +const struct k3_m4_dev_data *data = kproc->data;struct device *dev = &pdev->dev;struct resource *res;int num_mems;int i; - num_mems =ARRAY_SIZE (mem_names); + num_mems = data->num_mems; kproc->mem =devm_kcalloc (kproc->dev, num_mems,sizeof (*kproc->mem),GFP_KERNEL );if (!kproc->mem)
@@ -351,17 +363,17 @@ static int k3_m4_rproc_of_get_memories(struct platform_device *pdev,for (i =0 ; i < num_mems; i++) { res =platform_get_resource_byname (pdev,IORESOURCE_MEM , - mem_names[i]); + data->mems[i].name);if (!res) {dev_err (dev,"found no memory resource for %s\n" , - mem_names[i]); + data->mems[i].name);return -EINVAL ; }if (!devm_request_mem_region (dev, res->start,resource_size (res),dev_name (dev))) {dev_err (dev,"could not request %s region for resource\n" , - mem_names[i]); + data->mems[i].name);return -EBUSY ; }
@@ -369,15 +381,15 @@ static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, resource_size(res));if (!kproc->mem[i].cpu_addr) {dev_err (dev,"failed to map %s memory\n" , - mem_names[i]); + data->mems[i].name);return -ENOMEM ; } kproc->mem[i].bus_addr = res->start; - kproc->mem[i].dev_addr = mem_addrs[i]; + kproc->mem[i].dev_addr = data->mems[i].dev_addr; kproc->mem[i].size =resource_size (res);dev_dbg (dev,"memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n" , - mem_names[i], &kproc->mem[i].bus_addr, + data->mems[i].name, &kproc->mem[i].bus_addr, kproc->mem[i].size, kproc->mem[i].cpu_addr, kproc->mem[i].dev_addr); }
@@ -561,6 +573,7 @@ static const struct rproc_ops k3_m4_rproc_ops = {static int k3_m4_rproc_probe (struct platform_device *pdev) { +const struct k3_m4_dev_data *data;struct device *dev = &pdev->dev;struct k3_m4_rproc *kproc;struct rproc *rproc;
@@ -569,6 +582,10 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)bool p_state = false;int ret; + data =of_device_get_match_data (dev); +if (!data) +return -ENODEV ; + ret =rproc_of_parse_firmware (dev,0 , &fw_name);if (ret)return dev_err_probe (dev, ret,"failed to parse firmware-name property\n" );
@@ -583,6 +600,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) kproc = rproc->priv; kproc->dev = dev; kproc->rproc = rproc; + kproc->data = data;platform_set_drvdata (pdev, rproc); kproc->ti_sci =devm_ti_sci_get_by_phandle (dev,"ti,sci" );
@@ -650,8 +668,20 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)return 0 ; } +static const struct k3_m4_mem_data am64_m4_mems[] = { + { .name ="iram" , .dev_addr =0x0 }, + { .name ="dram" , .dev_addr =0x30000 }, +}; + +static const struct k3_m4_dev_data am64_m4_data = { + .mems = am64_m4_mems, + .num_mems =ARRAY_SIZE (am64_m4_mems), + .boot_align_addr =SZ_1K , + .uses_lreset = true, +}; +static const struct of_device_id k3_m4_of_match[] = { - { .compatible ="ti,am64-m4fss" , }, + { .compatible ="ti,am64-m4fss" , .data = &am64_m4_data, }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, k3_m4_of_match);
Signature · 1 line
2.34.1
PATCH v12 12/36 remoteproc: k3: Refactor shared data structures
In reply to Beleswar PadhiThe TI K3 R5, DSP and M4 remoteproc drivers share the same data structure definitions. Refactor the shared data structures into a new common header file, 'ti_k3_common.h', and update the drivers to use the unified data structures.
---
v12: Changelog:
1. Updated comment to call out that the header file is refactored out of R5, DSP and M4 drivers.
2. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
None
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.h | 96 ++++++++++++++++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 120 ++++---------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 105 +++-------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 132 +++++----------------- 4 files changed, 166 insertions(+), 287 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_common.h
drivers/remoteproc/ti_k3_common.h new file +96 -0
@@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* TI K3 Remote Processor(s) driver common code +* +* Refactored out of ti_k3_r5_remoteproc.c, ti_k3_dsp_remoteproc.c and +* ti_k3_m4_remoteproc.c. +* +* ti_k3_r5_remoteproc.c: +* Copyright (C) 2017-2022 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +* +* ti_k3_dsp_remoteproc.c: +* Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ +* Suman Anna <[email protected]> +* +* ti_k3_m4_remoteproc.c: +* Copyright (C) 2021-2024 Texas Instruments Incorporated - https://www.ti.com/ +* Hari Nagalla <[email protected]> +*/ + +#ifndef REMOTEPROC_TI_K3_COMMON_H +#define REMOTEPROC_TI_K3_COMMON_H + +/** +* struct k3_rproc_mem - internal memory structure +* @cpu_addr: MPU virtual address of the memory region +* @bus_addr: Bus address used to access the memory region +* @dev_addr: Device address of the memory region from remote processor view +* @size: Size of the memory region +*/ +struct k3_rproc_mem { +void __iomem *cpu_addr; +phys_addr_t bus_addr; +u32 dev_addr; +size_t size; +}; + +/** +* struct k3_rproc_mem_data - memory definitions for a remote processor +* @name: name for this memory entry +* @dev_addr: device address for the memory entry +*/ +struct k3_rproc_mem_data { +const char *name; +const u32 dev_addr; +}; + +/** +* struct k3_rproc_dev_data - device data structure for a remote processor +* @mems: pointer to memory definitions for a remote processor +* @num_mems: number of memory regions in @mems +* @boot_align_addr: boot vector address alignment granularity +* @uses_lreset: flag to denote the need for local reset management +*/ +struct k3_rproc_dev_data { +const struct k3_rproc_mem_data *mems; +u32 num_mems; +u32 boot_align_addr; +bool uses_lreset; +}; + +/** +* struct k3_rproc - k3 remote processor driver structure +* @dev: cached device pointer +* @rproc: remoteproc device handle +* @mem: internal memory regions data +* @num_mems: number of internal memory regions +* @rmem: reserved memory regions 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 +* @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 +*/ +struct k3_rproc { +struct device *dev; +struct rproc *rproc; +struct k3_rproc_mem *mem; +int num_mems; +struct k3_rproc_mem *rmem; +int num_rmems; +struct reset_control *reset; +const struct k3_rproc_dev_data *data; +struct ti_sci_proc *tsp; +const struct ti_sci_handle *ti_sci; +u32 ti_sci_id; +struct mbox_chan *mbox; +struct mbox_client client; +void *priv; +}; + +#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +24 -96
251 lines not on this page · raw message
drivers/remoteproc/ti_k3_m4_remoteproc.c +17 -88
195 lines not on this page · raw message
drivers/remoteproc/ti_k3_r5_remoteproc.c +29 -103
317 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 13/36 remoteproc: k3: Refactor mailbox rx_callback functions into common driver
In reply to Beleswar PadhiThe mailbox .rx_callback implementations in TI K3 R5, DSP and M4 remoteproc drivers handle inbound mailbox messages in the same way. Introduce a common driver 'ti_k3_common.c' and refactor the implementations into a common function 'k3_rproc_mbox_callback'() in it.
---
v12: Changelog:
1. Compile ti_k3_common driver with ti_k3_r5_remoteproc driver. [Mathieu]
2. Update comment to call out that the driver is refactored out of R5, DSP and M4 drivers.
3. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
None
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/Makefile | 6 +- drivers/remoteproc/ti_k3_common.c | 88 +++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 50 +------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 49 +------------ drivers/remoteproc/ti_k3_r5_remoteproc.c | 50 +------------ 6 files changed, 95 insertions(+), 149 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_common.c
drivers/remoteproc/Makefile +3 -3
@@ -36,7 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC) += rcar_rproc.o obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o -obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o -obj-$(CONFIG_TI_K3_M4_REMOTEPROC) += ti_k3_m4_remoteproc.o -obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o +obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o ti_k3_common.o +obj-$(CONFIG_TI_K3_M4_REMOTEPROC) += ti_k3_m4_remoteproc.o ti_k3_common.o +obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o ti_k3_common.o obj-$(CONFIG_XLNX_R5_REMOTEPROC) += xlnx_r5_remoteproc.o
drivers/remoteproc/ti_k3_common.c new file +88 -0
88 lines not on this page · raw message
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -93,4 +93,5 @@ struct k3_rproc { void *priv; }; +void k3_rproc_mbox_callback (struct mbox_client *client,void *data);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -49
62 lines not on this page · raw message
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -48
61 lines not on this page · raw message
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -49
62 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 14/36 remoteproc: k3: Refactor .kick rproc ops into common driver
In reply to Beleswar PadhiThe .kick rproc ops implementations in TI K3 R5, DSP and M4 remoteproc drivers sends a mailbox message to the remote processor in the same way. Refactor the implementations into a common function 'k3_rproc_kick()' in the ti_k3_common.c driver.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B and A/B tags.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
None
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 25 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 22 +------------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 26 +---------------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 17 +-------------- 5 files changed, 29 insertions(+), 62 deletions(-)
drivers/remoteproc/ti_k3_common.c +25 -0
@@ -84,5 +84,30 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data) }EXPORT_SYMBOL_GPL (k3_rproc_mbox_callback); +/* +* Kick the remote processor to notify about pending unprocessed messages. +* The vqid usage is not used and is inconsequential, as the kick is performed +* through a simulated GPIO (a bit in an IPC interrupt-triggering register), +* the remote processor is expected to process both its Tx and Rx virtqueues. +*/ +void k3_rproc_kick (struct rproc *rproc,int vqid) +{ +struct k3_rproc *kproc = rproc->priv; +struct device *dev = kproc->dev; +u32 msg = (u32 )vqid; +int ret; + +/* +* Send the index of the triggered virtqueue in the mailbox payload. +* NOTE: msg is cast to uintptr_t to prevent compiler warnings when +* void* is 64bit. It is safely cast back to u32 in the mailbox driver. +*/ + ret =mbox_send_message (kproc->mbox, (void *)(uintptr_t )msg); +if (ret <0 ) +dev_err (dev,"failed to send mailbox message, status = %d\n" , + ret); +} +EXPORT_SYMBOL_GPL (k3_rproc_kick); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -94,4 +94,5 @@ struct k3_rproc { };void k3_rproc_mbox_callback (struct mbox_client *client,void *data); +void k3_rproc_kick (struct rproc *rproc,int vqid);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -21
@@ -24,26 +24,6 @@#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* -* Kick the remote processor to notify about pending unprocessed messages. -* The vqid usage is not used and is inconsequential, as the kick is performed -* through a simulated GPIO (a bit in an IPC interrupt-triggering register), -* the remote processor is expected to process both its Tx and Rx virtqueues. -*/ -static void k3_dsp_rproc_kick (struct rproc *rproc,int vqid) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = rproc->dev.parent; -mbox_msg_t msg = (mbox_msg_t )vqid; -int ret; - -/* send the index of the triggered virtqueue in the mailbox payload */ - ret =mbox_send_message (kproc->mbox, (void *)msg); -if (ret <0 ) -dev_err (dev,"failed to send mailbox message (%pe)\n" , -ERR_PTR (ret)); -} -/* Put the DSP processor into reset */ static int k3_dsp_rproc_reset (struct k3_rproc *kproc) {
@@ -342,7 +322,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolstatic const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_dsp_rproc_stop, - .kick = k3_dsp_rproc_kick, + .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, };
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -25
@@ -21,30 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -/* -* Kick the remote processor to notify about pending unprocessed messages. -* The vqid usage is not used and is inconsequential, as the kick is performed -* through a simulated GPIO (a bit in an IPC interrupt-triggering register), -* the remote processor is expected to process both its Tx and Rx virtqueues. -*/ -static void k3_m4_rproc_kick (struct rproc *rproc,int vqid) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; -u32 msg = (u32 )vqid; -int ret; - -/* -* Send the index of the triggered virtqueue in the mailbox payload. -* NOTE: msg is cast to uintptr_t to prevent compiler warnings when -* void* is 64bit. It is safely cast back to u32 in the mailbox driver. -*/ - ret =mbox_send_message (kproc->mbox, (void *)(uintptr_t )msg); -if (ret <0 ) -dev_err (dev,"failed to send mailbox message, status = %d\n" , - ret); -} -static int k3_m4_rproc_ping_mbox (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -448,7 +424,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .stop = k3_m4_rproc_stop, .attach = k3_m4_rproc_attach, .detach = k3_m4_rproc_detach, - .kick = k3_m4_rproc_kick, + .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, .get_loaded_rsc_table = k3_m4_get_loaded_rsc_table, };
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -16
@@ -129,21 +129,6 @@ struct k3_r5_core {bool released_from_reset; }; -/* kick a virtqueue */ -static void k3_r5_rproc_kick (struct rproc *rproc,int vqid) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = rproc->dev.parent; -mbox_msg_t msg = (mbox_msg_t )vqid; -int ret; - -/* send the index of the triggered virtqueue in the mailbox payload */ - ret =mbox_send_message (kproc->mbox, (void *)msg); -if (ret <0 ) -dev_err (dev,"failed to send mailbox message, status = %d\n" , - ret); -} -static int k3_r5_split_reset (struct k3_rproc *kproc) {int ret;
@@ -735,7 +720,7 @@ static const struct rproc_ops k3_r5_rproc_ops = { .unprepare = k3_r5_rproc_unprepare, .start = k3_r5_rproc_start, .stop = k3_r5_rproc_stop, - .kick = k3_r5_rproc_kick, + .kick = k3_rproc_kick, .da_to_va = k3_r5_rproc_da_to_va, };
Signature · 1 line
2.34.1
PATCH v12 15/36 remoteproc: k3-dsp: Correct Reset logic for devices without lresets
In reply to Beleswar PadhiThe k3_dsp_rproc_reset() function erroneously asserts the local reset even for devices which do not support it. Even though it results in a no-operation, Update the logic to explicitly assert the local reset for devices that support it and only the global reset for those that do not.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Don't deassert lreset back if asserting module reset fails. [Andrew]
2. Put if-else block for code path with lreset and w/o lreset. [Andrew]
3. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 12/26] into [v10 14/33] and [v10 15/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 24 +++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +9 -15
@@ -30,21 +30,15 @@ static int k3_dsp_rproc_reset(struct k3_rproc *kproc)struct device *dev = kproc->dev;int ret; - ret =reset_control_assert (kproc->reset); -if (ret) { -dev_err (dev,"local-reset assert failed (%pe)\n" ,ERR_PTR (ret)); -return ret; - } - -if (kproc->data->uses_lreset) -return ret; - - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); -if (ret) { -dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); -if (reset_control_deassert (kproc->reset)) -dev_warn (dev,"local-reset deassert back failed\n" ); +if (kproc->data->uses_lreset) { + ret =reset_control_assert (kproc->reset); +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); +if (ret) +dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); }return ret;
Signature · 1 line
2.34.1
PATCH v12 16/36 remoteproc: k3-m4: Introduce central function to put rproc into reset
In reply to Beleswar PadhiCurrently, the TI K3 M4 remoteproc driver assumes all of the M4 devices have local resets. Even though its true for all existing M4 devices, keep room for future devices which possibly may not have local resets and only have a module reset.
Therefore introduce a central function, k3_m4_rproc_reset() which handles both type of devices (with and without local resets), and use it throughout the driver to put the remote processor into reset. This is done to align the reset implementation with DSP remoteproc driver and can be factored out later.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
0. New patch in this series.
1. Split [v10 15/33] into [v11 15/35] and [v11 16/35]. [Andrew]
Link to v10:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_m4_remoteproc.c | 36 +++++++++++++++--------- 1 file changed, 23 insertions(+), 13 deletions(-)
drivers/remoteproc/ti_k3_m4_remoteproc.c +23 -13
@@ -21,6 +21,26 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" +/* Put the M4 remote processor into reset */ +static int k3_m4_rproc_reset (struct k3_rproc *kproc) +{ +struct device *dev = kproc->dev; +int ret; + +if (kproc->data->uses_lreset) { + ret =reset_control_assert (kproc->reset); +if (ret) +dev_err (dev,"local-reset assert failed, ret = %d\n" , ret); + }else { + ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id); +if (ret) +dev_err (dev,"module-reset assert failed, ret = %d\n" , ret); + } + +return ret; +} +static int k3_m4_rproc_ping_mbox (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -65,11 +85,9 @@ static int k3_m4_rproc_prepare(struct rproc *rproc)* Ensure the local reset is asserted so the core doesn't * execute bogus code when the module reset is released. */ - ret =reset_control_assert (kproc->reset); -if (ret) { -dev_err (dev,"could not assert local reset\n" ); + ret =k3_m4_rproc_reset (kproc); +if (ret)return ret; - } ret =reset_control_status (kproc->reset);if (ret <=0 ) {
@@ -374,16 +392,8 @@ static int k3_m4_rproc_start(struct rproc *rproc)static int k3_m4_rproc_stop (struct rproc *rproc) {struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; -int ret; - ret =reset_control_assert (kproc->reset); -if (ret) { -dev_err (dev,"local-reset assert failed, ret = %d\n" , ret); -return ret; - } - -return 0 ; +return k3_m4_rproc_reset (kproc); }/*
Signature · 1 line
2.34.1
PATCH v12 17/36 remoteproc: k3: Refactor rproc_reset() implementation into common driver
In reply to Beleswar PadhiThe rproc_reset() implementations in TI K3 DSP and M4 remoteproc drivers assert reset in the same way. Refactor the above function into the ti_k3_common.c driver as k3_rproc_reset() and use it throughout DSP and M4 drivers for resetting the remote processor.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Split [v10 15/33] into [v11 15/35] and [v11 16/35].
2. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 12/26] into [v10 14/33] and [v10 15/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 21 ++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 24 ++--------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 24 ++--------------------- 4 files changed, 26 insertions(+), 44 deletions(-)
drivers/remoteproc/ti_k3_common.c +21 -0
@@ -109,5 +109,26 @@ void k3_rproc_kick(struct rproc *rproc, int vqid) }EXPORT_SYMBOL_GPL (k3_rproc_kick); +/* Put the remote processor into reset */ +int k3_rproc_reset (struct k3_rproc *kproc) +{ +struct device *dev = kproc->dev; +int ret; + +if (kproc->data->uses_lreset) { + ret =reset_control_assert (kproc->reset); +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); +if (ret) +dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); + } + +return ret; +} +EXPORT_SYMBOL_GPL (k3_rproc_reset); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -95,4 +95,5 @@ struct k3_rproc {void k3_rproc_mbox_callback (struct mbox_client *client,void *data);void k3_rproc_kick (struct rproc *rproc,int vqid); +int k3_rproc_reset (struct k3_rproc *kproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -22
@@ -24,26 +24,6 @@#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* Put the DSP processor into reset */ -static int k3_dsp_rproc_reset (struct k3_rproc *kproc) -{ -struct device *dev = kproc->dev; -int ret; - -if (kproc->data->uses_lreset) { - ret =reset_control_assert (kproc->reset); -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); -if (ret) -dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); - } - -return ret; -} -/* Release the DSP processor from reset */ static int k3_dsp_rproc_release (struct k3_rproc *kproc) {
@@ -197,7 +177,7 @@ static int k3_dsp_rproc_stop(struct rproc *rproc) {struct k3_rproc *kproc = rproc->priv; -k3_dsp_rproc_reset (kproc); +k3_rproc_reset (kproc);return 0 ; }
@@ -561,7 +541,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"failed to get reset status\n" ); }else if (ret ==0 ) {dev_warn (dev,"local reset is deasserted for device\n" ); -k3_dsp_rproc_reset (kproc); +k3_rproc_reset (kproc); } } }
drivers/remoteproc/ti_k3_m4_remoteproc.c +2 -22
@@ -21,26 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -/* Put the M4 remote processor into reset */ -static int k3_m4_rproc_reset (struct k3_rproc *kproc) -{ -struct device *dev = kproc->dev; -int ret; - -if (kproc->data->uses_lreset) { - ret =reset_control_assert (kproc->reset); -if (ret) -dev_err (dev,"local-reset assert failed, ret = %d\n" , ret); - }else { - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); -if (ret) -dev_err (dev,"module-reset assert failed, ret = %d\n" , ret); - } - -return ret; -} -static int k3_m4_rproc_ping_mbox (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -85,7 +65,7 @@ static int k3_m4_rproc_prepare(struct rproc *rproc)* Ensure the local reset is asserted so the core doesn't * execute bogus code when the module reset is released. */ - ret =k3_m4_rproc_reset (kproc); + ret =k3_rproc_reset (kproc);if (ret)return ret;
@@ -393,7 +373,7 @@ static int k3_m4_rproc_stop(struct rproc *rproc) {struct k3_rproc *kproc = rproc->priv; -return k3_m4_rproc_reset (kproc); +return k3_rproc_reset (kproc); }/*
Signature · 1 line
2.34.1
PATCH v12 18/36 remoteproc: k3-dsp: Correct Reset deassert logic for devices w/o lresets
In reply to Beleswar PadhiThe k3_dsp_rproc_release() function erroneously deasserts the local reset even for devices which do not support it. Even though it results in a no-operation, Update the logic to explicitly deassert only the global reset for devices that do not have a local reset.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Put if-else block for code path with lreset and w/o lreset. [Andrew]
2. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 13/26] into [v10 16/33] and [v10 17/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 30 ++++++++++------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +13 -17
@@ -30,23 +30,19 @@ static int k3_dsp_rproc_release(struct k3_rproc *kproc)struct device *dev = kproc->dev;int ret; -if (kproc->data->uses_lreset) - goto lreset; - - ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, - kproc->ti_sci_id); -if (ret) { -dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); -return ret; - } - -lreset: - 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)) -dev_warn (dev,"module-reset assert back failed\n" ); +if (kproc->data->uses_lreset) { + 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)) +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); +if (ret) +dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); }return ret;
Signature · 1 line
2.34.1
PATCH v12 19/36 remoteproc: k3-m4: Introduce central function to release rproc from reset
In reply to Beleswar PadhiCurrently, the TI K3 M4 remoteproc driver assumes all of the M4 devices have local resets. Even though its true for all existing M4 devices, keep room for future devices which possibly may not have local resets and only have a module reset.
Therefore introduce a central function, k3_m4_rproc_release() which handles both type of devices (with and without local resets), and use it throughout the driver to release the remote processor from reset. Also, for devices with local reset, Assert the module reset back in case the local reset deassert operation failed.
This is done to align the reset release implementation with DSP remoteproc driver and can be factored out later.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
0. New patch in this series.
1. Split [v10 17/33] into [v11 18/35] and [v11 19/35].
Link to v10:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_m4_remoteproc.c | 33 +++++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-)
drivers/remoteproc/ti_k3_m4_remoteproc.c +26 -7
@@ -21,6 +21,30 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" +/* Release the M4 remote processor from reset */ +static int k3_m4_rproc_release (struct k3_rproc *kproc) +{ +struct device *dev = kproc->dev; +int ret; + +if (kproc->data->uses_lreset) { + ret =reset_control_deassert (kproc->reset); +if (ret) { +dev_err (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)) +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); +if (ret) +dev_err (dev,"module-reset deassert failed, ret = %d\n" , ret); + } + +return ret; +} +static int k3_m4_rproc_ping_mbox (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -347,20 +371,15 @@ static void k3_m4_release_tsp(void *data)static int k3_m4_rproc_start (struct rproc *rproc) {struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev;int ret; ret =k3_m4_rproc_ping_mbox (kproc);if (ret)return ret; - ret =reset_control_deassert (kproc->reset); -if (ret) { -dev_err (dev,"local-reset deassert failed, ret = %d\n" , ret); -return ret; - } + ret =k3_m4_rproc_release (kproc); -return 0 ; +return ret; }/*
Signature · 1 line
2.34.1
PATCH v12 20/36 remoteproc: k3: Refactor rproc_release() implementation into common driver
In reply to Beleswar PadhiThe rproc_release() implementations in TI K3 DSP and M4 remoteproc drivers deassert reset in the same way. Refactor the above function into the ti_k3_common.c driver as k3_rproc_release() and use it throughout DSP and M4 drivers for releasing the reset from the remote processor.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Split [v10 17/33] into [v11 18/35] and [v11 19/35].
2. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 13/26] into [v10 16/33] and [v10 17/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 25 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 26 +---------------------- 4 files changed, 28 insertions(+), 50 deletions(-)
drivers/remoteproc/ti_k3_common.c +25 -0
@@ -130,5 +130,30 @@ int k3_rproc_reset(struct k3_rproc *kproc) }EXPORT_SYMBOL_GPL (k3_rproc_reset); +/* Release the remote processor from reset */ +int k3_rproc_release (struct k3_rproc *kproc) +{ +struct device *dev = kproc->dev; +int ret; + +if (kproc->data->uses_lreset) { + 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)) +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); +if (ret) +dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); + } + +return ret; +} +EXPORT_SYMBOL_GPL (k3_rproc_release); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -96,4 +96,5 @@ struct k3_rproc {void k3_rproc_mbox_callback (struct mbox_client *client,void *data);void k3_rproc_kick (struct rproc *rproc,int vqid);int k3_rproc_reset (struct k3_rproc *kproc); +int k3_rproc_release (struct k3_rproc *kproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -25
@@ -24,30 +24,6 @@#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* Release the DSP processor from reset */ -static int k3_dsp_rproc_release (struct k3_rproc *kproc) -{ -struct device *dev = kproc->dev; -int ret; - -if (kproc->data->uses_lreset) { - 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)) -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); -if (ret) -dev_err (dev,"module-reset deassert failed (%pe)\n" ,ERR_PTR (ret)); - } - -return ret; -} -static int k3_dsp_rproc_request_mbox (struct rproc *rproc) {struct k3_rproc *kproc = rproc->priv;
@@ -156,7 +132,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc)if (ret)return ret; - ret =k3_dsp_rproc_release (kproc); + ret =k3_rproc_release (kproc);if (ret)return ret;
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -25
@@ -21,30 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -/* Release the M4 remote processor from reset */ -static int k3_m4_rproc_release (struct k3_rproc *kproc) -{ -struct device *dev = kproc->dev; -int ret; - -if (kproc->data->uses_lreset) { - ret =reset_control_deassert (kproc->reset); -if (ret) { -dev_err (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)) -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); -if (ret) -dev_err (dev,"module-reset deassert failed, ret = %d\n" , ret); - } - -return ret; -} -static int k3_m4_rproc_ping_mbox (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -377,7 +353,7 @@ static int k3_m4_rproc_start(struct rproc *rproc)if (ret)return ret; - ret =k3_m4_rproc_release (kproc); + ret =k3_rproc_release (kproc);return ret; }
Signature · 1 line
2.34.1
PATCH v12 21/36 remoteproc: k3-m4: Ping the mbox while acquiring the channel
In reply to Beleswar PadhiThe TI K3 M4 remoteproc driver acquires the mailbox channel in probe but sends a message through the acquired channel later in .attach()/.start() callbacks.
Put both the things together in the form of 'k3_m4_rproc_request_mbox()' function and invoke that in the probe routine. This is done to align the rproc_request_mbox() implementation with R5 and DSP drivers which can be factored out at a later stage.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 14/26] into [v10 18/33] and [v10 19/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_m4_remoteproc.c | 44 ++++++++++-------------- 1 file changed, 19 insertions(+), 25 deletions(-)
drivers/remoteproc/ti_k3_m4_remoteproc.c +19 -25
@@ -21,11 +21,24 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -static int k3_m4_rproc_ping_mbox (struct k3_rproc *kproc) +static int k3_m4_rproc_request_mbox (struct rproc *rproc) { +struct k3_rproc *kproc = rproc->priv; +struct mbox_client *client = &kproc->client;struct device *dev = kproc->dev;int ret; + client->dev = dev; + client->tx_done =NULL ; + client->rx_callback = k3_rproc_mbox_callback; + client->tx_block = false; + client->knows_txdone = false; + + kproc->mbox =mbox_request_channel (client,0 ); +if (IS_ERR (kproc->mbox)) +return dev_err_probe (dev,PTR_ERR (kproc->mbox), +"mbox_request_channel failed\n" ); +/* * Ping the remote processor, this is only for sanity-sake for now; * there is no functional effect whatsoever.
@@ -36,6 +49,7 @@ static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) ret =mbox_send_message (kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST );if (ret <0 ) {dev_err (dev,"mbox_send_message failed: %d\n" , ret); +mbox_free_channel (kproc->mbox);return ret; }
@@ -347,15 +361,8 @@ static void k3_m4_release_tsp(void *data)static int k3_m4_rproc_start (struct rproc *rproc) {struct k3_rproc *kproc = rproc->priv; -int ret; - - ret =k3_m4_rproc_ping_mbox (kproc); -if (ret) -return ret; - - ret =k3_rproc_release (kproc); -return ret; +return k3_rproc_release (kproc); }/*
@@ -380,13 +387,6 @@ static int k3_m4_rproc_stop(struct rproc *rproc)*/ static int k3_m4_rproc_attach (struct rproc *rproc) { -struct k3_rproc *kproc = rproc->priv; -int ret; - - ret =k3_m4_rproc_ping_mbox (kproc); -if (ret) -return ret; -return 0 ; }
@@ -493,15 +493,9 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)dev_info (dev,"configured M4F for remoteproc mode\n" ); } - kproc->client.dev = dev; - kproc->client.tx_done =NULL ; - kproc->client.rx_callback = k3_rproc_mbox_callback; - kproc->client.tx_block = false; - kproc->client.knows_txdone = false; - kproc->mbox =mbox_request_channel (&kproc->client,0 ); -if (IS_ERR (kproc->mbox)) -return dev_err_probe (dev,PTR_ERR (kproc->mbox), -"mbox_request_channel failed\n" ); + ret =k3_m4_rproc_request_mbox (rproc); +if (ret) +return ret; ret =devm_rproc_add (dev, rproc);if (ret)
Signature · 1 line
2.34.1
PATCH v12 22/36 remoteproc: k3: Refactor rproc_request_mbox() implementations into common driver
In reply to Beleswar PadhiThe rproc_request_mbox() implementations in TI K3 R5, DSP and M4 remoteproc drivers acquire the mailbox channel and send the same message through the acquired channel.
Refactor the above function into the ti_k3_common.c driver as k3_rproc_request_mbox() and use it throughout R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 14/26] into [v10 18/33] and [v10 19/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 36 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 36 +--------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 37 +---------------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 37 +---------------------- 5 files changed, 40 insertions(+), 107 deletions(-)
drivers/remoteproc/ti_k3_common.c +36 -0
@@ -155,5 +155,41 @@ int k3_rproc_release(struct k3_rproc *kproc) }EXPORT_SYMBOL_GPL (k3_rproc_release); +int k3_rproc_request_mbox (struct rproc *rproc) +{ +struct k3_rproc *kproc = rproc->priv; +struct mbox_client *client = &kproc->client; +struct device *dev = kproc->dev; +int ret; + + client->dev = dev; + client->tx_done =NULL ; + client->rx_callback = k3_rproc_mbox_callback; + client->tx_block = false; + client->knows_txdone = false; + + kproc->mbox =mbox_request_channel (client,0 ); +if (IS_ERR (kproc->mbox)) +return dev_err_probe (dev,PTR_ERR (kproc->mbox), +"mbox_request_channel failed\n" ); + +/* +* Ping the remote processor, this is only for sanity-sake for now; +* there is no functional effect whatsoever. +* +* Note that the reply will _not_ arrive immediately: this message +* will wait in the mailbox fifo until the remote processor is booted. +*/ + ret =mbox_send_message (kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST ); +if (ret <0 ) { +dev_err (dev,"mbox_send_message failed (%pe)\n" ,ERR_PTR (ret)); +mbox_free_channel (kproc->mbox); +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (k3_rproc_request_mbox); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -97,4 +97,5 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data);void k3_rproc_kick (struct rproc *rproc,int vqid);int k3_rproc_reset (struct k3_rproc *kproc);int k3_rproc_release (struct k3_rproc *kproc); +int k3_rproc_request_mbox (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -35
@@ -24,40 +24,6 @@#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -static int k3_dsp_rproc_request_mbox (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; -struct mbox_client *client = &kproc->client; -struct device *dev = kproc->dev; -int ret; - - client->dev = dev; - client->tx_done =NULL ; - client->rx_callback = k3_rproc_mbox_callback; - client->tx_block = false; - client->knows_txdone = false; - - kproc->mbox =mbox_request_channel (client,0 ); -if (IS_ERR (kproc->mbox)) -return dev_err_probe (dev,PTR_ERR (kproc->mbox), -"mbox_request_channel failed\n" ); - -/* -* Ping the remote processor, this is only for sanity-sake for now; -* there is no functional effect whatsoever. -* -* Note that the reply will _not_ arrive immediately: this message -* will wait in the mailbox fifo until the remote processor is booted. -*/ - ret =mbox_send_message (kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST ); -if (ret <0 ) { -dev_err (dev,"mbox_send_message failed (%pe)\n" ,ERR_PTR (ret)); -mbox_free_channel (kproc->mbox); -return ret; - } - -return 0 ; -}/* * The C66x DSP cores have a local reset that affects only the CPU, and a * generic module reset that powers on the device and allows the DSP internal
@@ -443,7 +409,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) kproc->dev = dev; kproc->data = data; - ret =k3_dsp_rproc_request_mbox (rproc); + ret =k3_rproc_request_mbox (rproc);if (ret)return ret;
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -36
@@ -21,41 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -static int k3_m4_rproc_request_mbox (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; -struct mbox_client *client = &kproc->client; -struct device *dev = kproc->dev; -int ret; - - client->dev = dev; - client->tx_done =NULL ; - client->rx_callback = k3_rproc_mbox_callback; - client->tx_block = false; - client->knows_txdone = false; - - kproc->mbox =mbox_request_channel (client,0 ); -if (IS_ERR (kproc->mbox)) -return dev_err_probe (dev,PTR_ERR (kproc->mbox), -"mbox_request_channel failed\n" ); - -/* -* Ping the remote processor, this is only for sanity-sake for now; -* there is no functional effect whatsoever. -* -* Note that the reply will _not_ arrive immediately: this message -* will wait in the mailbox fifo until the remote processor is booted. -*/ - ret =mbox_send_message (kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST ); -if (ret <0 ) { -dev_err (dev,"mbox_send_message failed: %d\n" , ret); -mbox_free_channel (kproc->mbox); -return ret; - } - -return 0 ; -} -/* * The M4 cores have a local reset that affects only the CPU, and a * generic module reset that powers on the device and allows the internal
@@ -493,7 +458,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)dev_info (dev,"configured M4F for remoteproc mode\n" ); } - ret =k3_m4_rproc_request_mbox (rproc); + ret =k3_rproc_request_mbox (rproc);if (ret)return ret;
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -36
@@ -284,41 +284,6 @@ static inline int k3_r5_core_run(struct k3_rproc *kproc) 0, PROC_BOOT_CTRL_FLAG_R5_CORE_HALT); } -static int k3_r5_rproc_request_mbox (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; -struct mbox_client *client = &kproc->client; -struct device *dev = kproc->dev; -int ret; - - client->dev = dev; - client->tx_done =NULL ; - client->rx_callback = k3_rproc_mbox_callback; - client->tx_block = false; - client->knows_txdone = false; - - kproc->mbox =mbox_request_channel (client,0 ); -if (IS_ERR (kproc->mbox)) -return dev_err_probe (dev,PTR_ERR (kproc->mbox), -"mbox_request_channel failed\n" ); - -/* -* Ping the remote processor, this is only for sanity-sake for now; -* there is no functional effect whatsoever. -* -* Note that the reply will _not_ arrive immediately: this message -* will wait in the mailbox fifo until the remote processor is booted. -*/ - ret =mbox_send_message (kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST ); -if (ret <0 ) { -dev_err (dev,"mbox_send_message failed: %d\n" , ret); -mbox_free_channel (kproc->mbox); -return ret; - } - -return 0 ; -} -/* * The R5F cores have controls for both a reset and a halt/run. The code * execution from DDR requires the initial boot-strapping code to be run
@@ -1357,7 +1322,7 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) kproc = core->kproc; rproc = kproc->rproc; - ret =k3_r5_rproc_request_mbox (rproc); + ret =k3_rproc_request_mbox (rproc);if (ret)return ret;
Signature · 1 line
2.34.1
PATCH v12 23/36 remoteproc: k3-dsp: Don't override rproc ops in IPC-only mode
In reply to Beleswar PadhiCurrently, the driver overrides the rproc ops when booting in IPC-only mode. Remove these overrides and register the ops unconditionally. This requires to have IPC-only mode checks in the .prepare and .unprepare ops and returning early. The other rproc ops are invoked when booting either in IPC-only mode or in remoteproc mode but not both.
This is done to align the rproc ops implementations of DSP driver with M4 driver and can be factored out at a later stage.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. New patch. Gets rid of overriding function pointers. Makes further commits more atomic.
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +15 -12
@@ -40,6 +40,10 @@ static int k3_dsp_rproc_prepare(struct rproc *rproc)struct device *dev = kproc->dev;int ret; +/* If the core is running already no need to deassert the module reset */ +if (rproc->state ==RPROC_DETACHED ) +return 0 ; + ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, kproc->ti_sci_id);if (ret)
@@ -64,6 +68,10 @@ static int k3_dsp_rproc_unprepare(struct rproc *rproc)struct device *dev = kproc->dev;int ret; +/* If the core is running already no need to deassert the module reset */ +if (rproc->state ==RPROC_DETACHED ) +return 0 ; + ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, kproc->ti_sci_id);if (ret)
@@ -232,10 +240,13 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool }static const struct rproc_ops k3_dsp_rproc_ops = { - .start = k3_dsp_rproc_start, - .stop = k3_dsp_rproc_stop, - .kick = k3_rproc_kick, - .da_to_va = k3_dsp_rproc_da_to_va, + .start = k3_dsp_rproc_start, + .stop = k3_dsp_rproc_stop, + .attach = k3_dsp_rproc_attach, + .detach = k3_dsp_rproc_detach, + .kick = k3_rproc_kick, + .da_to_va = k3_dsp_rproc_da_to_va, + .get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table, }; static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
@@ -458,14 +469,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)if (p_state) {dev_info (dev,"configured DSP for IPC-only mode\n" ); rproc->state =RPROC_DETACHED ; -/* override rproc ops with only required IPC-only mode ops */ - rproc->ops->prepare =NULL ; - rproc->ops->unprepare =NULL ; - rproc->ops->start =NULL ; - rproc->ops->stop =NULL ; - rproc->ops->attach = k3_dsp_rproc_attach; - rproc->ops->detach = k3_dsp_rproc_detach; - rproc->ops->get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table; }else {dev_info (dev,"configured DSP for remoteproc mode\n" );/*
Signature · 1 line
2.34.1
PATCH v12 24/36 remoteproc: k3-dsp: Assert local reset during .prepare callback
In reply to Beleswar PadhiThe ti_k3_dsp_remoteproc.c driver asserts the local reset in probe and releases the module reset in .prepare callback. This is done to ensure the core does not execute bogus code when module reset is deasserted.
Put both of these operations together in .prepare callback, which is more suitable as it ensures local reset is asserted for subsequent core start operations from sysfs. This is done to align the .prepare callback of DSP with the M4 driver which can be factored out at a later stage.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 15/26] into [v10 21/33] and [v10 22/33] patches.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +16 -14
@@ -44,6 +44,22 @@ static int k3_dsp_rproc_prepare(struct rproc *rproc)if (rproc->state ==RPROC_DETACHED )return 0 ; +/* +* Ensure the local reset is asserted so the core doesn't +* execute bogus code when the module reset is released. +*/ +if (kproc->data->uses_lreset) { + ret =k3_rproc_reset (kproc); +if (ret) +return ret; + + ret =reset_control_status (kproc->reset); +if (ret <=0 ) { +dev_err (dev,"local reset still not asserted\n" ); +return ret; + } + } + ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, kproc->ti_sci_id);if (ret)
@@ -471,20 +487,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) rproc->state =RPROC_DETACHED ; }else {dev_info (dev,"configured DSP for remoteproc mode\n" ); -/* -* ensure the DSP local reset is asserted to ensure the DSP -* doesn't execute bogus code in .prepare() when the module -* reset is released. -*/ -if (data->uses_lreset) { - ret =reset_control_status (kproc->reset); -if (ret <0 ) { -return dev_err_probe (dev, ret,"failed to get reset status\n" ); - }else if (ret ==0 ) { -dev_warn (dev,"local reset is deasserted for device\n" ); -k3_rproc_reset (kproc); - } - } } ret =devm_rproc_add (dev, rproc);
Signature · 1 line
2.34.1
PATCH v12 25/36 remoteproc: k3: Refactor .prepare rproc ops into common driver
In reply to Beleswar PadhiThe .prepare rproc ops implementations in TI K3 DSP and M4 remoteproc drivers deasserts the local and module reset of the processor to allow firmware loading into internal memory.
Refactor the implementations into the ti_k3_common.c driver as k3_rproc_prepare() and register this common function as .prepare ops in the DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Split [v9 15/26] into [v10 21/33] and [v10 22/33] patches.
2. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 46 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 47 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 45 +--------------------- 4 files changed, 49 insertions(+), 90 deletions(-)
drivers/remoteproc/ti_k3_common.c +46 -0
@@ -191,5 +191,51 @@ int k3_rproc_request_mbox(struct rproc *rproc) }EXPORT_SYMBOL_GPL (k3_rproc_request_mbox); +/* +* The K3 DSP and M4 cores have a local reset that affects only the CPU, and a +* generic module reset that powers on the device and allows the internal +* memories to be accessed while the local reset is asserted. This function is +* used to release the global reset on remote cores to allow loading into the +* internal RAMs. The .prepare() ops is invoked by remoteproc core before any +* firmware loading, and is followed by the .start() ops after loading to +* actually let the remote cores to run. +*/ +int k3_rproc_prepare (struct rproc *rproc) +{ +struct k3_rproc *kproc = rproc->priv; +struct device *dev = kproc->dev; +int ret; + +/* If the core is running already no need to deassert the module reset */ +if (rproc->state ==RPROC_DETACHED ) +return 0 ; + +/* +* Ensure the local reset is asserted so the core doesn't +* execute bogus code when the module reset is released. +*/ +if (kproc->data->uses_lreset) { + ret =k3_rproc_reset (kproc); +if (ret) +return ret; + + ret =reset_control_status (kproc->reset); +if (ret <=0 ) { +dev_err (dev,"local reset still not asserted\n" ); +return ret; + } + } + + ret = kproc->ti_sci->ops.dev_ops.get_device (kproc->ti_sci, + kproc->ti_sci_id); +if (ret) { +dev_err (dev,"could not deassert module-reset for internal RAM loading\n" ); +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (k3_rproc_prepare); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -98,4 +98,5 @@ void k3_rproc_kick(struct rproc *rproc, int vqid);int k3_rproc_reset (struct k3_rproc *kproc);int k3_rproc_release (struct k3_rproc *kproc);int k3_rproc_request_mbox (struct rproc *rproc); +int k3_rproc_prepare (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -46
59 lines not on this page · raw message
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -44
57 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 26/36 remoteproc: k3: Refactor .unprepare rproc ops into common driver
In reply to Beleswar PadhiThe .unprepare rproc ops implementations in TI K3 DSP and M4 remoteproc drivers assert the module reset on the remote processor. Refactor the implementations into ti_k3_common.c driver as k3_rproc_unprepare() and register this common function as .unprepare ops in DSP and M4 drivers.
---
v12: Changelog:
1. Updated the check in k3_rproc_unprepare() to look for RPROC_DETACHED.
2. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 30 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 29 +-------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 31 +---------------------- 4 files changed, 33 insertions(+), 58 deletions(-)
drivers/remoteproc/ti_k3_common.c +30 -0
@@ -237,5 +237,35 @@ int k3_rproc_prepare(struct rproc *rproc) }EXPORT_SYMBOL_GPL (k3_rproc_prepare); +/* +* This function implements the .unprepare() ops and performs the complimentary +* operations to that of the .prepare() ops. The function is used to assert the +* global reset on applicable K3 DSP and M4 cores. This completes the second +* portion of powering down the remote core. The cores themselves are only +* halted in the .stop() callback through the local reset, and the .unprepare() +* ops is invoked by the remoteproc core after the remoteproc is stopped to +* balance the global reset. +*/ +int k3_rproc_unprepare (struct rproc *rproc) +{ +struct k3_rproc *kproc = rproc->priv; +struct device *dev = kproc->dev; +int ret; + +/* If the core is going to be detached do not assert the module reset */ +if (rproc->state ==RPROC_DETACHED ) +return 0 ; + + ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, + kproc->ti_sci_id); +if (ret) { +dev_err (dev,"module-reset assert failed\n" ); +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (k3_rproc_unprepare); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -99,4 +99,5 @@ int k3_rproc_reset(struct k3_rproc *kproc);int k3_rproc_release (struct k3_rproc *kproc);int k3_rproc_request_mbox (struct rproc *rproc);int k3_rproc_prepare (struct rproc *rproc); +int k3_rproc_unprepare (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -28
@@ -24,33 +24,6 @@#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* -* This function implements the .unprepare() ops and performs the complimentary -* operations to that of the .prepare() ops. The function is used to assert the -* global reset on applicable C66x cores. This completes the second portion of -* powering down the C66x DSP cores. The cores themselves are only halted in the -* .stop() callback through the local reset, and the .unprepare() ops is invoked -* by the remoteproc core after the remoteproc is stopped to balance the global -* reset. This callback is invoked only in remoteproc mode. -*/ -static int k3_dsp_rproc_unprepare (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; -int ret; - -/* If the core is running already no need to deassert the module reset */ -if (rproc->state ==RPROC_DETACHED ) -return 0 ; - - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); -if (ret) -dev_err (dev,"module-reset assert failed (%pe)\n" ,ERR_PTR (ret)); - -return ret; -} -/* * Power up the DSP remote processor. *
@@ -384,7 +357,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) rproc->recovery_disabled = true;if (data->uses_lreset) { rproc->ops->prepare = k3_rproc_prepare; - rproc->ops->unprepare = k3_dsp_rproc_unprepare; + rproc->ops->unprepare = k3_rproc_unprepare; } kproc = rproc->priv; kproc->rproc = rproc;
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -30
@@ -21,35 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -/* -* This function implements the .unprepare() ops and performs the complimentary -* operations to that of the .prepare() ops. The function is used to assert the -* global reset on applicable cores. This completes the second portion of -* powering down the remote core. The cores themselves are only halted in the -* .stop() callback through the local reset, and the .unprepare() ops is invoked -* by the remoteproc core after the remoteproc is stopped to balance the global -* reset. -*/ -static int k3_m4_rproc_unprepare (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; -int ret; - -/* If the core is going to be detached do not assert the module reset */ -if (rproc->state ==RPROC_DETACHED ) -return 0 ; - - ret = kproc->ti_sci->ops.dev_ops.put_device (kproc->ti_sci, - kproc->ti_sci_id); -if (ret) { -dev_err (dev,"module-reset assert failed\n" ); -return ret; - } - -return 0 ; -} -/* * This function implements the .get_loaded_rsc_table() callback and is used * to provide the resource table for a booted remote processor in IPC-only
@@ -326,7 +297,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc)static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, - .unprepare = k3_m4_rproc_unprepare, + .unprepare = k3_rproc_unprepare, .start = k3_m4_rproc_start, .stop = k3_m4_rproc_stop, .attach = k3_m4_rproc_attach,
Signature · 1 line
2.34.1
PATCH v12 27/36 remoteproc: k3: Refactor .start rproc ops into common driver
In reply to Beleswar PadhiThe k3_dsp_rproc_start() function sets the boot vector and releases the reset on the remote processor. Whereas, the k3_m4_rproc_start() function only needs to release the reset.
Refactor the k3_m4_rproc_start() into ti_k3_common.c as k3_rproc_start() and align the DSP and M4 drivers to invoke this common function when releasing the reset on the remote processor.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 15 +++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 3 ++- drivers/remoteproc/ti_k3_m4_remoteproc.c | 16 +--------------- 4 files changed, 19 insertions(+), 16 deletions(-)
drivers/remoteproc/ti_k3_common.c +15 -0
@@ -267,5 +267,20 @@ int k3_rproc_unprepare(struct rproc *rproc) }EXPORT_SYMBOL_GPL (k3_rproc_unprepare); +/* +* Power up the remote processor. +* +* This function will be invoked only after the firmware for this rproc +* was loaded, parsed successfully, and all of its resource requirements +* were met. This callback is invoked only in remoteproc mode. +*/ +int k3_rproc_start (struct rproc *rproc) +{ +struct k3_rproc *kproc = rproc->priv; + +return k3_rproc_release (kproc); +} +EXPORT_SYMBOL_GPL (k3_rproc_start); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -100,4 +100,5 @@ int k3_rproc_release(struct k3_rproc *kproc);int k3_rproc_request_mbox (struct rproc *rproc);int k3_rproc_prepare (struct rproc *rproc);int k3_rproc_unprepare (struct rproc *rproc); +int k3_rproc_start (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -1
@@ -50,7 +50,8 @@ static int k3_dsp_rproc_start(struct rproc *rproc)if (ret)return ret; - ret =k3_rproc_release (kproc); +/* Call the K3 common start function after doing DSP specific stuff */ + ret =k3_rproc_start (rproc);if (ret)return ret;
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -15
@@ -244,20 +244,6 @@ static void k3_m4_release_tsp(void *data)ti_sci_proc_release (tsp); } -/* -* Power up the M4 remote processor. -* -* This function will be invoked only after the firmware for this rproc -* was loaded, parsed successfully, and all of its resource requirements -* were met. This callback is invoked only in remoteproc mode. -*/ -static int k3_m4_rproc_start (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; - -return k3_rproc_release (kproc); -} -/* * Stop the M4 remote processor. *
@@ -298,7 +284,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc)static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, - .start = k3_m4_rproc_start, + .start = k3_rproc_start, .stop = k3_m4_rproc_stop, .attach = k3_m4_rproc_attach, .detach = k3_m4_rproc_detach,
Signature · 1 line
2.34.1
PATCH v12 28/36 remoteproc: k3: Refactor .stop rproc ops into common driver
In reply to Beleswar PadhiThe .stop rproc ops implementations in TI K3 DSP and M4 remoteproc drivers put the remote processor into reset. Refactor the implementations into ti_k3_common.c driver as k3_rproc_stop() and register this common function as .stop ops in DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 14 ++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 17 +---------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 15 +-------------- 4 files changed, 17 insertions(+), 30 deletions(-)
drivers/remoteproc/ti_k3_common.c +14 -0
@@ -282,5 +282,19 @@ int k3_rproc_start(struct rproc *rproc) }EXPORT_SYMBOL_GPL (k3_rproc_start); +/* +* Stop the remote processor. +* +* This function puts the remote processor into reset, and finishes processing +* of any pending messages. This callback is invoked only in remoteproc mode. +*/ +int k3_rproc_stop (struct rproc *rproc) +{ +struct k3_rproc *kproc = rproc->priv; + +return k3_rproc_reset (kproc); +} +EXPORT_SYMBOL_GPL (k3_rproc_stop); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -101,4 +101,5 @@ int k3_rproc_request_mbox(struct rproc *rproc);int k3_rproc_prepare (struct rproc *rproc);int k3_rproc_unprepare (struct rproc *rproc);int k3_rproc_start (struct rproc *rproc); +int k3_rproc_stop (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -16
@@ -58,21 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc)return 0 ; } -/* -* Stop the DSP remote processor. -* -* This function puts the DSP processor into reset, and finishes processing -* of any pending messages. This callback is invoked only in remoteproc mode. -*/ -static int k3_dsp_rproc_stop (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; - -k3_rproc_reset (kproc); - -return 0 ; -} -/* * Attach to a running DSP remote processor (IPC-only mode) *
@@ -186,7 +171,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolstatic const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, - .stop = k3_dsp_rproc_stop, + .stop = k3_rproc_stop, .attach = k3_dsp_rproc_attach, .detach = k3_dsp_rproc_detach, .kick = k3_rproc_kick,
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -14
@@ -244,19 +244,6 @@ static void k3_m4_release_tsp(void *data)ti_sci_proc_release (tsp); } -/* -* Stop the M4 remote processor. -* -* This function puts the M4 processor into reset, and finishes processing -* of any pending messages. This callback is invoked only in remoteproc mode. -*/ -static int k3_m4_rproc_stop (struct rproc *rproc) -{ -struct k3_rproc *kproc = rproc->priv; - -return k3_rproc_reset (kproc); -} -/* * Attach to a running M4 remote processor (IPC-only mode) *
@@ -285,7 +272,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, .start = k3_rproc_start, - .stop = k3_m4_rproc_stop, + .stop = k3_rproc_stop, .attach = k3_m4_rproc_attach, .detach = k3_m4_rproc_detach, .kick = k3_rproc_kick,
Signature · 1 line
2.34.1
PATCH v12 29/36 remoteproc: k3: Refactor .attach rproc ops into common driver
In reply to Beleswar PadhiThe .attach rproc ops implementations in TI K3 R5, DSP and M4 drivers are NOPs. Refactor the implementations into ti_k3_common.c driver as k3_rproc_attach() and register this common function as .attach ops in R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 12 ++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 13 +------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 14 +------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 13 +------------ 5 files changed, 16 insertions(+), 37 deletions(-)
drivers/remoteproc/ti_k3_common.c +12 -0
@@ -296,5 +296,17 @@ int k3_rproc_stop(struct rproc *rproc) }EXPORT_SYMBOL_GPL (k3_rproc_stop); +/* +* Attach to a running remote processor (IPC-only mode) +* +* The rproc attach callback is a NOP. The remote processor is already booted, +* and all required resources have been acquired during probe routine, so there +* is no need to issue any TI-SCI commands to boot the remote cores in IPC-only +* mode. This callback is invoked only in IPC-only mode and exists because +* rproc_validate() checks for its existence. +*/ +int k3_rproc_attach (struct rproc *rproc) {return 0 ; } +EXPORT_SYMBOL_GPL (k3_rproc_attach); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -102,4 +102,5 @@ int k3_rproc_prepare(struct rproc *rproc);int k3_rproc_unprepare (struct rproc *rproc);int k3_rproc_start (struct rproc *rproc);int k3_rproc_stop (struct rproc *rproc); +int k3_rproc_attach (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -12
@@ -58,17 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc)return 0 ; } -/* -* Attach to a running DSP remote processor (IPC-only mode) -* -* This rproc attach callback is a NOP. The remote processor is already booted, -* and all required resources have been acquired during probe routine, so there -* is no need to issue any TI-SCI commands to boot the DSP core. This callback -* is invoked only in IPC-only mode and exists because rproc_validate() checks -* for its existence. -*/ -static int k3_dsp_rproc_attach (struct rproc *rproc) {return 0 ; } -/* * Detach from a running DSP remote processor (IPC-only mode) *
@@ -172,7 +161,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolstatic const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_rproc_stop, - .attach = k3_dsp_rproc_attach, + .attach = k3_rproc_attach, .detach = k3_dsp_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va,
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -13
@@ -244,18 +244,6 @@ static void k3_m4_release_tsp(void *data)ti_sci_proc_release (tsp); } -/* -* Attach to a running M4 remote processor (IPC-only mode) -* -* The remote processor is already booted, so there is no need to issue any -* TI-SCI commands to boot the M4 core. This callback is used only in IPC-only -* mode. -*/ -static int k3_m4_rproc_attach (struct rproc *rproc) -{ -return 0 ; -} -/* * Detach from a running M4 remote processor (IPC-only mode) *
@@ -273,7 +261,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .unprepare = k3_rproc_unprepare, .start = k3_rproc_start, .stop = k3_rproc_stop, - .attach = k3_m4_rproc_attach, + .attach = k3_rproc_attach, .detach = k3_m4_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va,
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -12
@@ -559,17 +559,6 @@ static int k3_r5_rproc_stop(struct rproc *rproc)return ret; } -/* -* Attach to a running R5F remote processor (IPC-only mode) -* -* The R5F attach callback is a NOP. The remote processor is already booted, and -* all required resources have been acquired during probe routine, so there is -* no need to issue any TI-SCI commands to boot the R5F cores in IPC-only mode. -* This callback is invoked only in IPC-only mode and exists because -* rproc_validate() checks for its existence. -*/ -static int k3_r5_rproc_attach (struct rproc *rproc) {return 0 ; } -/* * Detach from a running R5F remote processor (IPC-only mode) *
@@ -1059,7 +1048,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) kproc->rproc->ops->unprepare =NULL ; kproc->rproc->ops->start =NULL ; kproc->rproc->ops->stop =NULL ; - kproc->rproc->ops->attach = k3_r5_rproc_attach; + kproc->rproc->ops->attach = k3_rproc_attach; kproc->rproc->ops->detach = k3_r5_rproc_detach; kproc->rproc->ops->get_loaded_rsc_table = k3_r5_get_loaded_rsc_table;
Signature · 1 line
2.34.1
PATCH v12 30/36 remoteproc: k3: Refactor .detach rproc ops into common driver
In reply to Beleswar PadhiThe .detach rproc ops implementations in TI K3 R5, DSP and M4 remoteproc drivers are NOPs. Refactor the implementations into ti_k3_common.c driver as k3_rproc_detach() and register this common function as .detach ops in R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 10 ++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 11 +---------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 14 +------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 11 +---------- 5 files changed, 14 insertions(+), 33 deletions(-)
drivers/remoteproc/ti_k3_common.c +10 -0
@@ -308,5 +308,15 @@ EXPORT_SYMBOL_GPL(k3_rproc_stop);int k3_rproc_attach (struct rproc *rproc) {return 0 ; }EXPORT_SYMBOL_GPL (k3_rproc_attach); +/* +* Detach from a running remote processor (IPC-only mode) +* +* The rproc detach callback is a NOP. The remote processor is not stopped and +* will be left in booted state in IPC-only mode. This callback is invoked only +* in IPC-only mode and exists for sanity sake +*/ +int k3_rproc_detach (struct rproc *rproc) {return 0 ; } +EXPORT_SYMBOL_GPL (k3_rproc_detach); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -103,4 +103,5 @@ int k3_rproc_unprepare(struct rproc *rproc);int k3_rproc_start (struct rproc *rproc);int k3_rproc_stop (struct rproc *rproc);int k3_rproc_attach (struct rproc *rproc); +int k3_rproc_detach (struct rproc *rproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -10
@@ -58,15 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc)return 0 ; } -/* -* Detach from a running DSP remote processor (IPC-only mode) -* -* This rproc detach callback is a NOP. The DSP core is not stopped and will be -* left to continue to run its booted firmware. This callback is invoked only in -* IPC-only mode and exists for sanity sake. -*/ -static int k3_dsp_rproc_detach (struct rproc *rproc) {return 0 ; } -/* * This function implements the .get_loaded_rsc_table() callback and is used * to provide the resource table for a booted DSP in IPC-only mode. The K3 DSP
@@ -162,7 +153,7 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_rproc_stop, .attach = k3_rproc_attach, - .detach = k3_dsp_rproc_detach, + .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, .get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table,
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -13
@@ -244,25 +244,13 @@ static void k3_m4_release_tsp(void *data)ti_sci_proc_release (tsp); } -/* -* Detach from a running M4 remote processor (IPC-only mode) -* -* This rproc detach callback performs the opposite operation to attach -* callback, the M4 core is not stopped and will be left to continue to -* run its booted firmware. This callback is invoked only in IPC-only mode. -*/ -static int k3_m4_rproc_detach (struct rproc *rproc) -{ -return 0 ; -} -static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, .start = k3_rproc_start, .stop = k3_rproc_stop, .attach = k3_rproc_attach, - .detach = k3_m4_rproc_detach, + .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, .get_loaded_rsc_table = k3_m4_get_loaded_rsc_table,
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -10
@@ -559,15 +559,6 @@ static int k3_r5_rproc_stop(struct rproc *rproc)return ret; } -/* -* Detach from a running R5F remote processor (IPC-only mode) -* -* The R5F detach callback is a NOP. The R5F cores are not stopped and will be -* left in booted state in IPC-only mode. This callback is invoked only in -* IPC-only mode and exists for sanity sake. -*/ -static int k3_r5_rproc_detach (struct rproc *rproc) {return 0 ; } -/* * This function implements the .get_loaded_rsc_table() callback and is used * to provide the resource table for the booted R5F in IPC-only mode. The K3 R5F
@@ -1049,7 +1040,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) kproc->rproc->ops->start =NULL ; kproc->rproc->ops->stop =NULL ; kproc->rproc->ops->attach = k3_rproc_attach; - kproc->rproc->ops->detach = k3_r5_rproc_detach; + kproc->rproc->ops->detach = k3_rproc_detach; kproc->rproc->ops->get_loaded_rsc_table = k3_r5_get_loaded_rsc_table; }else if (!c_state) {
Signature · 1 line
2.34.1
PATCH v12 31/36 remoteproc: k3: Refactor .get_loaded_rsc_table ops into common driver
In reply to Beleswar PadhiThe .get_loaded_rsc_table rproc ops implementations in TI K3 R5, DSP and M4 remoteproc drivers return a pointer to the resource table that was pre-loaded at the base address of the DDR region reserved for firmware usage.
Refactor the implementations into ti_k3_common.c driver as k3_get_loaded_rsc_table() and register this common function as .get_loaded_rsc_table ops in R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Don't remove dsp func override. Already done by [v10 20/33] patch.
2. Update commit message to call out changes in a better way.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 33 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 2 ++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 34 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 34 +---------------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 34 +---------------------- 5 files changed, 38 insertions(+), 99 deletions(-)
drivers/remoteproc/ti_k3_common.c +33 -0
@@ -318,5 +318,38 @@ EXPORT_SYMBOL_GPL(k3_rproc_attach);int k3_rproc_detach (struct rproc *rproc) {return 0 ; }EXPORT_SYMBOL_GPL (k3_rproc_detach); +/* +* This function implements the .get_loaded_rsc_table() callback and is used +* to provide the resource table for a booted remote processor in IPC-only +* mode. The remote processor firmwares follow a design-by-contract approach +* and are expected to have the resource table at the base of the DDR region +* reserved for firmware usage. This provides flexibility for the remote +* processor to be booted by different bootloaders that may or may not have the +* ability to publish the resource table address and size through a DT +* property. +*/ +struct resource_table *k3_get_loaded_rsc_table (struct rproc *rproc, +size_t *rsc_table_sz) +{ +struct k3_rproc *kproc = rproc->priv; +struct device *dev = kproc->dev; + +if (!kproc->rmem[0 ].cpu_addr) { +dev_err (dev,"memory-region #1 does not exist, loaded rsc table can't be found" ); +return ERR_PTR (-ENOMEM ); + } + +/* +* NOTE: The resource table size is currently hard-coded to a maximum +* of 256 bytes. The most common resource table usage for K3 firmwares +* is to only have the vdev resource entry and an optional trace entry. +* The exact size could be computed based on resource table address, but +* the hard-coded value suffices to support the IPC-only mode. +*/ + *rsc_table_sz =256 ; +return (__force struct resource_table *)kproc->rmem[0 ].cpu_addr; +} +EXPORT_SYMBOL_GPL (k3_get_loaded_rsc_table); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +2 -0
@@ -104,4 +104,6 @@ int k3_rproc_start(struct rproc *rproc);int k3_rproc_stop (struct rproc *rproc);int k3_rproc_attach (struct rproc *rproc);int k3_rproc_detach (struct rproc *rproc); +struct resource_table *k3_get_loaded_rsc_table (struct rproc *rproc, +size_t *rsc_table_sz);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -33
@@ -58,38 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc)return 0 ; } -/* -* This function implements the .get_loaded_rsc_table() callback and is used -* to provide the resource table for a booted DSP in IPC-only mode. The K3 DSP -* firmwares follow a design-by-contract approach and are expected to have the -* resource table at the base of the DDR region reserved for firmware usage. -* This provides flexibility for the remote processor to be booted by different -* bootloaders that may or may not have the ability to publish the resource table -* address and size through a DT property. This callback is invoked only in -* IPC-only mode. -*/ -static struct resource_table *k3_dsp_get_loaded_rsc_table (struct rproc *rproc, -size_t *rsc_table_sz) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; - -if (!kproc->rmem[0 ].cpu_addr) { -dev_err (dev,"memory-region #1 does not exist, loaded rsc table can't be found" ); -return ERR_PTR (-ENOMEM ); - } - -/* -* NOTE: The resource table size is currently hard-coded to a maximum -* of 256 bytes. The most common resource table usage for K3 firmwares -* is to only have the vdev resource entry and an optional trace entry. -* The exact size could be computed based on resource table address, but -* the hard-coded value suffices to support the IPC-only mode. -*/ - *rsc_table_sz =256 ; -return (__force struct resource_table *)kproc->rmem[0 ].cpu_addr; -} -/* * Custom function to translate a DSP device address (internal RAMs only) to a * kernel virtual address. The DSPs can access their RAMs at either an internal
@@ -156,7 +124,7 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, - .get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table, + .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -33
@@ -21,38 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -/* -* This function implements the .get_loaded_rsc_table() callback and is used -* to provide the resource table for a booted remote processor in IPC-only -* mode. The remote processor firmwares follow a design-by-contract approach -* and are expected to have the resource table at the base of the DDR region -* reserved for firmware usage. This provides flexibility for the remote -* processor to be booted by different bootloaders that may or may not have the -* ability to publish the resource table address and size through a DT -* property. -*/ -static struct resource_table *k3_m4_get_loaded_rsc_table (struct rproc *rproc, -size_t *rsc_table_sz) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; - -if (!kproc->rmem[0 ].cpu_addr) { -dev_err (dev,"memory-region #1 does not exist, loaded rsc table can't be found" ); -return ERR_PTR (-ENOMEM ); - } - -/* -* NOTE: The resource table size is currently hard-coded to a maximum -* of 256 bytes. The most common resource table usage for K3 firmwares -* is to only have the vdev resource entry and an optional trace entry. -* The exact size could be computed based on resource table address, but -* the hard-coded value suffices to support the IPC-only mode. -*/ - *rsc_table_sz =256 ; -return (__force struct resource_table *)kproc->rmem[0 ].cpu_addr; -} -/* * Custom function to translate a remote processor device address (internal * RAMs only) to a kernel virtual address. The remote processors can access
@@ -253,7 +221,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, - .get_loaded_rsc_table = k3_m4_get_loaded_rsc_table, + .get_loaded_rsc_table = k3_get_loaded_rsc_table, };static int k3_m4_rproc_probe (struct platform_device *pdev)
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -33
@@ -559,38 +559,6 @@ static int k3_r5_rproc_stop(struct rproc *rproc)return ret; } -/* -* This function implements the .get_loaded_rsc_table() callback and is used -* to provide the resource table for the booted R5F in IPC-only mode. The K3 R5F -* firmwares follow a design-by-contract approach and are expected to have the -* resource table at the base of the DDR region reserved for firmware usage. -* This provides flexibility for the remote processor to be booted by different -* bootloaders that may or may not have the ability to publish the resource table -* address and size through a DT property. This callback is invoked only in -* IPC-only mode. -*/ -static struct resource_table *k3_r5_get_loaded_rsc_table (struct rproc *rproc, -size_t *rsc_table_sz) -{ -struct k3_rproc *kproc = rproc->priv; -struct device *dev = kproc->dev; - -if (!kproc->rmem[0 ].cpu_addr) { -dev_err (dev,"memory-region #1 does not exist, loaded rsc table can't be found" ); -return ERR_PTR (-ENOMEM ); - } - -/* -* NOTE: The resource table size is currently hard-coded to a maximum -* of 256 bytes. The most common resource table usage for K3 firmwares -* is to only have the vdev resource entry and an optional trace entry. -* The exact size could be computed based on resource table address, but -* the hard-coded value suffices to support the IPC-only mode. -*/ - *rsc_table_sz =256 ; -return (__force struct resource_table *)kproc->rmem[0 ].cpu_addr; -} -/* * Internal Memory translation helper *
@@ -1042,7 +1010,7 @@ static int k3_r5_rproc_configure_mode(struct k3_rproc *kproc) kproc->rproc->ops->attach = k3_rproc_attach; kproc->rproc->ops->detach = k3_rproc_detach; kproc->rproc->ops->get_loaded_rsc_table = - k3_r5_get_loaded_rsc_table; + k3_get_loaded_rsc_table; }else if (!c_state) {dev_info (cdev,"configured R5F for remoteproc mode\n" ); ret =0 ;
Signature · 1 line
2.34.1
PATCH v12 32/36 remoteproc: k3: Refactor .da_to_va rproc ops into common driver
In reply to Beleswar PadhiThe .da_to_va rproc ops implementations in TI K3 R5, DSP and M4 remoteproc drivers return the Kernel virtual address for a corresponding rproc device address.
Refactor the implementations into the ti_k3_common.c driver as k3_rproc_da_to_va and use this common function for address translation of DDR and internal memory regions in R5, DSP and M4 drivers.
Note: The R5 SRAM memory translations are still handled in the .da_to_va ops of the R5 remoteproc driver.
---
v12: Changelog:
1. Added R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Updated commit message to call out the changes better.
2. Don't remove dsp func override. Already done by [v10 20/33] patch.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 57 ++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 4 ++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 63 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 58 +-------------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 37 +------------ 5 files changed, 65 insertions(+), 154 deletions(-)
drivers/remoteproc/ti_k3_common.c +57 -0
@@ -351,5 +351,62 @@ struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, }EXPORT_SYMBOL_GPL (k3_get_loaded_rsc_table); +/* +* Custom function to translate a remote processor device address (internal +* RAMs only) to a kernel virtual address. The remote processors can access +* their RAMs at either an internal address visible only from a remote +* processor, or at the SoC-level bus address. Both these addresses need to be +* looked through for translation. The translated addresses can be used either +* by the remoteproc core for loading (when using kernel remoteproc loader), or +* by any rpmsg bus drivers. +*/ +void *k3_rproc_da_to_va (struct rproc *rproc,u64 da,size_t len,bool *is_iomem) +{ +struct k3_rproc *kproc = rproc->priv; +void __iomem *va =NULL ; +phys_addr_t bus_addr; +u32 dev_addr, offset; +size_t size; +int i; + +if (len ==0 ) +return NULL ; + +for (i =0 ; i < kproc->num_mems; i++) { + bus_addr = kproc->mem[i].bus_addr; + dev_addr = kproc->mem[i].dev_addr; + size = kproc->mem[i].size; + +/* handle rproc-view addresses */ +if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { + offset = da - dev_addr; + va = kproc->mem[i].cpu_addr + offset; +return (__force void *)va; + } + +/* handle SoC-view addresses */ +if (da >= bus_addr && (da + len) <= (bus_addr + size)) { + offset = da - bus_addr; + va = kproc->mem[i].cpu_addr + offset; +return (__force void *)va; + } + } + +/* handle static DDR reserved memory regions */ +for (i =0 ; i < kproc->num_rmems; i++) { + dev_addr = kproc->rmem[i].dev_addr; + size = kproc->rmem[i].size; + +if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { + offset = da - dev_addr; + va = kproc->rmem[i].cpu_addr + offset; +return (__force void *)va; + } + } + +return NULL ; +} +EXPORT_SYMBOL_GPL (k3_rproc_da_to_va); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +4 -0
@@ -21,6 +21,8 @@#ifndef REMOTEPROC_TI_K3_COMMON_H #define REMOTEPROC_TI_K3_COMMON_H +#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) +/** * struct k3_rproc_mem - internal memory structure * @cpu_addr: MPU virtual address of the memory region
@@ -106,4 +108,6 @@ int k3_rproc_attach(struct rproc *rproc);int k3_rproc_detach (struct rproc *rproc);struct resource_table *k3_get_loaded_rsc_table (struct rproc *rproc,size_t *rsc_table_sz); +void *k3_rproc_da_to_va (struct rproc *rproc,u64 da,size_t len, +bool *is_iomem);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -62
81 lines not on this page · raw message
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -57
70 lines not on this page · raw message
drivers/remoteproc/ti_k3_r5_remoteproc.c +2 -35
@@ -572,7 +572,6 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolstruct k3_rproc *kproc = rproc->priv;struct k3_r5_core *core = kproc->priv;void __iomem *va =NULL ; -phys_addr_t bus_addr;u32 dev_addr, offset;size_t size;int i;
@@ -580,27 +579,6 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, boolif (len ==0 )return NULL ; -/* handle both R5 and SoC views of ATCM and BTCM */ -for (i =0 ; i < kproc->num_mems; i++) { - bus_addr = kproc->mem[i].bus_addr; - dev_addr = kproc->mem[i].dev_addr; - size = kproc->mem[i].size; - -/* handle R5-view addresses of TCMs */ -if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { - offset = da - dev_addr; - va = kproc->mem[i].cpu_addr + offset; -return (__force void *)va; - } - -/* handle SoC-view addresses of TCMs */ -if (da >= bus_addr && ((da + len) <= (bus_addr + size))) { - offset = da - bus_addr; - va = kproc->mem[i].cpu_addr + offset; -return (__force void *)va; - } - } -/* handle any SRAM regions using SoC-view addresses */ for (i =0 ; i < core->num_sram; i++) { dev_addr = core->sram[i].dev_addr;
@@ -613,19 +591,8 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool } } -/* handle static DDR reserved memory regions */ -for (i =0 ; i < kproc->num_rmems; i++) { - dev_addr = kproc->rmem[i].dev_addr; - size = kproc->rmem[i].size; - -if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { - offset = da - dev_addr; - va = kproc->rmem[i].cpu_addr + offset; -return (__force void *)va; - } - } - -return NULL ; +/* handle both TCM and DDR memory regions */ +return k3_rproc_da_to_va (rproc, da, len, is_iomem); }static const struct rproc_ops k3_r5_rproc_ops = {
Signature · 1 line
2.34.1
PATCH v12 33/36 remoteproc: k3: Refactor of_get_memories() functions into common driver
In reply to Beleswar PadhiThe of_get_memories() implementations in the TI K3 R5, DSP and M4 remoteproc drivers initialize and assign memory regions used by the remote processor in the same way. Refactor these implementations into ti_k3_common.c driver as k3_rproc_of_get_memories() use this common function for mem initialization in R5, DSP and M4 drivers.
Note: The TCM addresses for R5 core are configurable based on the 'loczrama' setting. Therefore, override the bus_addr assignment done by the common function for TCMs of R5 remote processors by reading the 'loczrama' DT property in k3_r5_core_of_get_internal_memories().
---
v12: Changelog:
1. Assign data->num_mems to num_mems. [Mathieu]
2. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Updated commit message to call out the changes better.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 53 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 2 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 54 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 54 +---------------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 49 ++++---------------- 5 files changed, 66 insertions(+), 146 deletions(-)
drivers/remoteproc/ti_k3_common.c +53 -0
@@ -408,5 +408,58 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) }EXPORT_SYMBOL_GPL (k3_rproc_da_to_va); +int k3_rproc_of_get_memories (struct platform_device *pdev, +struct k3_rproc *kproc) +{ +const struct k3_rproc_dev_data *data = kproc->data; +struct device *dev = &pdev->dev; +struct resource *res; +int num_mems =0 ; +int i; + + num_mems = data->num_mems; + kproc->mem =devm_kcalloc (kproc->dev, num_mems, +sizeof (*kproc->mem),GFP_KERNEL ); +if (!kproc->mem) +return -ENOMEM ; + +for (i =0 ; i < num_mems; i++) { + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , + data->mems[i].name); +if (!res) { +dev_err (dev,"found no memory resource for %s\n" , + data->mems[i].name); +return -EINVAL ; + } +if (!devm_request_mem_region (dev, res->start, +resource_size (res), +dev_name (dev))) { +dev_err (dev,"could not request %s region for resource\n" , + data->mems[i].name); +return -EBUSY ; + } + + kproc->mem[i].cpu_addr =devm_ioremap_wc (dev, res->start, +resource_size (res)); +if (!kproc->mem[i].cpu_addr) { +dev_err (dev,"failed to map %s memory\n" , + data->mems[i].name); +return -ENOMEM ; + } + kproc->mem[i].bus_addr = res->start; + kproc->mem[i].dev_addr = data->mems[i].dev_addr; + kproc->mem[i].size =resource_size (res); + +dev_dbg (dev,"memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n" , + data->mems[i].name, &kproc->mem[i].bus_addr, + kproc->mem[i].size, kproc->mem[i].cpu_addr, + kproc->mem[i].dev_addr); + } + kproc->num_mems = num_mems; + +return 0 ; +} +EXPORT_SYMBOL_GPL (k3_rproc_of_get_memories); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +2 -0
@@ -110,4 +110,6 @@ struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, size_t *rsc_table_sz);void *k3_rproc_da_to_va (struct rproc *rproc,u64 da,size_t len,bool *is_iomem); +int k3_rproc_of_get_memories (struct platform_device *pdev, +struct k3_rproc *kproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -53
66 lines not on this page · raw message
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -53
66 lines not on this page · raw message
drivers/remoteproc/ti_k3_r5_remoteproc.c +9 -40
77 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 34/36 remoteproc: k3: Refactor mem_release() functions into common driver
In reply to Beleswar PadhiThe mem_release() implementations in the TI K3 R5, DSP and M4 remoteproc drivers release the reserved memory of the device, which get auto triggered upon device removal.
Refactor these functions into ti_k3_common.c driver as k3_mem_release() and use this common function in R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Update commit message to call out changes in a better way.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 8 ++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 9 +-------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 9 +-------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 9 +-------- 5 files changed, 12 insertions(+), 24 deletions(-)
drivers/remoteproc/ti_k3_common.c +8 -0
@@ -461,5 +461,13 @@ int k3_rproc_of_get_memories(struct platform_device *pdev, }EXPORT_SYMBOL_GPL (k3_rproc_of_get_memories); +void k3_mem_release (void *data) +{ +struct device *dev = data; + +of_reserved_mem_device_release (dev); +} +EXPORT_SYMBOL_GPL (k3_mem_release); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -112,4 +112,5 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem);int k3_rproc_of_get_memories (struct platform_device *pdev,struct k3_rproc *kproc); +void k3_mem_release (void *data);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -8
@@ -66,13 +66,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; -static void k3_dsp_mem_release (void *data) -{ -struct device *dev = data; - -of_reserved_mem_device_release (dev); -} -static int k3_dsp_reserved_mem_init (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -102,7 +95,7 @@ static int k3_dsp_reserved_mem_init(struct k3_rproc *kproc) ERR_PTR(ret));return ret; } - ret =devm_add_action_or_reset (dev, k3_dsp_mem_release, dev); + ret =devm_add_action_or_reset (dev, k3_mem_release, dev);if (ret)return ret;
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -8
@@ -21,13 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -static void k3_m4_rproc_dev_mem_release (void *data) -{ -struct device *dev = data; - -of_reserved_mem_device_release (dev); -} -static int k3_m4_reserved_mem_init (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -56,7 +49,7 @@ static int k3_m4_reserved_mem_init(struct k3_rproc *kproc)dev_err (dev,"device cannot initialize DMA pool (%d)\n" , ret);return ret; } - ret =devm_add_action_or_reset (dev, k3_m4_rproc_dev_mem_release, dev); + ret =devm_add_action_or_reset (dev, k3_mem_release, dev);if (ret)return ret;
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -8
@@ -761,13 +761,6 @@ static int k3_r5_rproc_configure(struct k3_rproc *kproc)return ret; } -static void k3_r5_mem_release (void *data) -{ -struct device *dev = data; - -of_reserved_mem_device_release (dev); -} -static int k3_r5_reserved_mem_init (struct k3_rproc *kproc) {struct device *dev = kproc->dev;
@@ -798,7 +791,7 @@ static int k3_r5_reserved_mem_init(struct k3_rproc *kproc)return ret; } - ret =devm_add_action_or_reset (dev, k3_r5_mem_release, dev); + ret =devm_add_action_or_reset (dev, k3_mem_release, dev);if (ret)return ret;
Signature · 1 line
2.34.1
PATCH v12 35/36 remoteproc: k3: Refactor reserved_mem_init() functions into common driver
In reply to Beleswar PadhiThe reserved_mem_init() implementations in the R5, DSP and M4 remoteproc drivers initialize the reserved memory regions associated with the remote processor.
Refactor these functions into the ti_k3_common.c driver as k3_reserved_mem_init() and use this common function throughout in R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Update commit message to call out changes in a better way.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 70 +++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 72 +------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 71 +------------------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 82 +---------------------- 5 files changed, 74 insertions(+), 222 deletions(-)
drivers/remoteproc/ti_k3_common.c +70 -0
@@ -469,5 +469,75 @@ void k3_mem_release(void *data) }EXPORT_SYMBOL_GPL (k3_mem_release); +int k3_reserved_mem_init (struct k3_rproc *kproc) +{ +struct device *dev = kproc->dev; +struct device_node *np = dev->of_node; +struct device_node *rmem_np; +struct reserved_mem *rmem; +int num_rmems; +int ret, i; + + num_rmems =of_property_count_elems_of_size (np,"memory-region" , +sizeof (phandle)); +if (num_rmems <0 ) { +dev_err (dev,"device does not reserved memory regions (%d)\n" , + num_rmems); +return -EINVAL ; + } +if (num_rmems <2 ) { +dev_err (dev,"device needs at least two memory regions to be defined, num = %d\n" , + num_rmems); +return -EINVAL ; + } + +/* use reserved memory region 0 for vring DMA allocations */ + ret =of_reserved_mem_device_init_by_idx (dev, np,0 ); +if (ret) { +dev_err (dev,"device cannot initialize DMA pool (%d)\n" , ret); +return ret; + } + ret =devm_add_action_or_reset (dev, k3_mem_release, dev); +if (ret) +return ret; + + num_rmems--; + kproc->rmem =devm_kcalloc (dev, num_rmems,sizeof (*kproc->rmem),GFP_KERNEL ); +if (!kproc->rmem) +return -ENOMEM ; + +/* use remaining reserved memory regions for static carveouts */ +for (i =0 ; i < num_rmems; i++) { + rmem_np =of_parse_phandle (np,"memory-region" , i +1 ); +if (!rmem_np) +return -EINVAL ; + + rmem =of_reserved_mem_lookup (rmem_np); +of_node_put (rmem_np); +if (!rmem) +return -EINVAL ; + + kproc->rmem[i].bus_addr = rmem->base; +/* 64-bit address regions currently not supported */ + kproc->rmem[i].dev_addr = (u32 )rmem->base; + kproc->rmem[i].size = rmem->size; + kproc->rmem[i].cpu_addr =devm_ioremap_wc (dev, rmem->base, rmem->size); +if (!kproc->rmem[i].cpu_addr) { +dev_err (dev,"failed to map reserved memory#%d at %pa of size %pa\n" , + i +1 , &rmem->base, &rmem->size); +return -ENOMEM ; + } + +dev_dbg (dev,"reserved memory%d: bus addr %pa size 0x%zx va %pK da 0x%x\n" , + i +1 , &kproc->rmem[i].bus_addr, + kproc->rmem[i].size, kproc->rmem[i].cpu_addr, + kproc->rmem[i].dev_addr); + } + kproc->num_rmems = num_rmems; + +return 0 ; +} +EXPORT_SYMBOL_GPL (k3_reserved_mem_init); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -113,4 +113,5 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len,int k3_rproc_of_get_memories (struct platform_device *pdev,struct k3_rproc *kproc);void k3_mem_release (void *data); +int k3_reserved_mem_init (struct k3_rproc *kproc);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -71
84 lines not on this page · raw message
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -70
83 lines not on this page · raw message
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -81
94 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 36/36 remoteproc: k3: Refactor release_tsp() functions into common driver
In reply to Beleswar PadhiThe release_tsp() implementations in the TI K3 R5, DSP and M4 remoteproc drivers release the TI-SCI processor control of a remote processor, which is auto triggered upon device removal.
Refactor these functions into ti_k3_common.c driver as k3_release_tsp() and use this common function throughout in R5, DSP and M4 drivers.
---
v12: Changelog:
1. Carried R/B tag.
Link to v11:
https://lore.kernel.org/all/[email protected]/
v11: Changelog:
1. Carried T/B tag.
Link to v10:
https://lore.kernel.org/all/[email protected]/
v10: Changelog:
1. Update commit message to call out changes in a better way.
Link to v9:
https://lore.kernel.org/all/[email protected]/
drivers/remoteproc/ti_k3_common.c | 8 ++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 9 +-------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 9 +-------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 9 +-------- 5 files changed, 12 insertions(+), 24 deletions(-)
drivers/remoteproc/ti_k3_common.c +8 -0
@@ -539,5 +539,13 @@ int k3_reserved_mem_init(struct k3_rproc *kproc) }EXPORT_SYMBOL_GPL (k3_reserved_mem_init); +void k3_release_tsp (void *data) +{ +struct ti_sci_proc *tsp = data; + +ti_sci_proc_release (tsp); +} +EXPORT_SYMBOL_GPL (k3_release_tsp); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("TI K3 common Remoteproc code" );
drivers/remoteproc/ti_k3_common.h +1 -0
@@ -114,4 +114,5 @@ int k3_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc);void k3_mem_release (void *data);int k3_reserved_mem_init (struct k3_rproc *kproc); +void k3_release_tsp (void *data);#endif /* REMOTEPROC_TI_K3_COMMON_H */
drivers/remoteproc/ti_k3_dsp_remoteproc.c +1 -8
@@ -66,13 +66,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; -static void k3_dsp_release_tsp (void *data) -{ -struct ti_sci_proc *tsp = data; - -ti_sci_proc_release (tsp); -} -static int k3_dsp_rproc_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -136,7 +129,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" );return ret; } - ret =devm_add_action_or_reset (dev, k3_dsp_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp);if (ret)return ret;
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -8
@@ -21,13 +21,6 @@#include "ti_sci_proc.h" #include "ti_k3_common.h" -static void k3_m4_release_tsp (void *data) -{ -struct ti_sci_proc *tsp = data; - -ti_sci_proc_release (tsp); -} -static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare,
@@ -93,7 +86,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) ret =ti_sci_proc_request (kproc->tsp);if (ret <0 )return dev_err_probe (dev, ret,"ti_sci_proc_request failed\n" ); - ret =devm_add_action_or_reset (dev, k3_m4_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (dev, k3_release_tsp, kproc->tsp);if (ret)return ret;
drivers/remoteproc/ti_k3_r5_remoteproc.c +1 -8
@@ -1017,13 +1017,6 @@ static int k3_r5_core_of_get_sram_memories(struct platform_device *pdev,return 0 ; } -static void k3_r5_release_tsp (void *data) -{ -struct ti_sci_proc *tsp = data; - -ti_sci_proc_release (tsp); -} -static int k3_r5_cluster_rproc_init (struct platform_device *pdev) {struct k3_r5_cluster *cluster =platform_get_drvdata (pdev);
@@ -1109,7 +1102,7 @@ static int k3_r5_cluster_rproc_init(struct platform_device *pdev) goto out; } - ret =devm_add_action_or_reset (cdev, k3_r5_release_tsp, kproc->tsp); + ret =devm_add_action_or_reset (cdev, k3_release_tsp, kproc->tsp);if (ret) goto out; }
Signature · 1 line
2.34.1
Quoted 143 lines · Beleswar Padhi
This series refactors a lot of functions & callbacks from
ti_k3_dsp_remoteproc.c,ti_k3_r5_remoteproc.candti_k3_m4_remoteproc.cdrivers. This is a consolidated and final series as part of the refactoring of K3 remoteproc drivers. Below is the breakdown:
1. PATCHES #1-#4 fixes important bugs in R5 and DSP drivers before refactoring them into a common driver.
2. PATCHES #5-#11 does the pre-cleanup and aligns R5, DSP, M4 data structures.
3. PATCHES #12-#36 does the actual refactoring R5, DSP and M4 drivers intoti_k3_common.cdriver.NOTE:
This series supersedes below series:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/Testing Done:
1. Tested boot of R5Fs, C66x DSPs, C71x DSPs across Jacinto J7* devices in remoteproc mode and IPC-Only mode.
2. Tested boot of M4F core _only_ in_AM62xxSK_board in Remoteproc mode and IPC-Only mode.
3. Tested Core stop and detach operations from sysfs for R5Fs, C66x DSPs, C71x DSPs
4. Tested device removal paths by executing 'modprobe -rti_k3_dsp_remoteproc' and 'modprobe -rti_k3_r5_remoteproc'.
5. Tested usecases where firmware not available at device probe time, but later in sysfs, able to load firmware into a remotecore and start it. [R5Fs]
6. Tested that each patch in this series generates no new warnings/errors.
7. Tested IPC on AM64x EVM Device. [Thanks to Judith].
8. Tested compilation of the remoteproc drivers as modules.v12: Changelog:
Mathieu:
1. Use data pointer to setnum_memsin PATCHES [08/36] and [11/36].
2. Declare const before variables in PATCH [11/35].
3. Compileti_k3_commondriver withti_k3_r5_remoteprocdriver in PATCH [13/36]. General:
1. New patch: [04/36]. Fix the state detection logic in M4 driver to prevent resetting the rproc in detach routine.
2. Update comments in ti_k3_common.{h/c} files to call out it is refactored out of R5, DSP and M4 drivers in PATCHES [12/36] and [13/36].
3. Carry R/B Tags from Andrew throughout series.Link to v11:
https://lore.kernel.org/all/[email protected]/v11: Changelog:
1. New patches: [v11 15/35] and [v11 18/35].
Broken downrproc_reset()andrproc_release()refactoring patches into more atomic changes.
2. Carried T/B on all patches from Judith.
3. Carried A/B on [PATCH v11 13/35] by Andrew.Link to v10:
https://lore.kernel.org/all/[email protected]/v10: Changelog:
1. Re-ordered Bug Fixes to the start of the series, before starting pre-cleanup and finally the actual refactor. [Andrew]
2. Broken down commits into more atomic changes for ease of review. [Andrew].
3. Updated commit messages to have uniform flow throughout the series.
4. Carried R/B tags in applicable patches.
5. Further patch specific changelog is attached with patches.Link to v9:
https://lore.kernel.org/all/[email protected]/v9: Changelog:
1. Added R5 cleanup & refactoring along with existing DSP, M4 refactoring into this series. [Andrew]
2. Dropped Mailbox level IPC checks across R5, DSP, M4 drivers in IPC-only mode. [Andrew]Link to v8:
https://lore.kernel.org/all/[email protected]/v8: Changelog:
1. Broken down refactoring into patches, each patch dealing with one function for ease in review. [Andrew]Links to older versions:
v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/Thanks,
BeleswarBeleswar Padhi (34):
remoteproc: k3-r5: Refactor sequential core power up/down operations
remoteproc: k3-m4: Don't assert reset in detach routine
remoteproc: k3-r5: Re-order internal memory initialization functions
remoteproc: k3-r5: Re-orderk3_r5_release_tsp()function
remoteproc: k3-r5: Refactor Data Structures to Align with DSP and M4
remoteproc: k3-r5: Usek3_r5_rproc_mem_datastructure for memory info
remoteproc: k3-{m4/dsp}: Add a void ptr member in rproc internal
struct
remoteproc: k3-m4: Add pointer to rproc struct withink3_m4_rproc
remoteproc: k3-m4: Usek3_rproc_mem_datastructure for memory info
remoteproc: k3: Refactor shared data structures
remoteproc: k3: Refactor mailboxrx_callbackfunctions into common
driver
remoteproc: k3: Refactor .kick rproc ops into common driver
remoteproc: k3-dsp: Correct Reset logic for devices without lresets
remoteproc: k3-m4: Introduce central function to put rproc into reset
remoteproc: k3: Refactorrproc_reset()implementation into common
driver
remoteproc: k3-dsp: Correct Reset deassert logic for devices w/o
lresets
remoteproc: k3-m4: Introduce central function to release rproc from
reset
remoteproc: k3: Refactorrproc_release()implementation into common
driver
remoteproc: k3-m4: Ping the mbox while acquiring the channel
remoteproc: k3: Refactorrproc_request_mbox()implementations into
common driver
remoteproc: k3-dsp: Don't override rproc ops in IPC-only mode
remoteproc: k3-dsp: Assert local reset during .prepare callback
remoteproc: k3: Refactor .prepare rproc ops into common driver
remoteproc: k3: Refactor .unprepare rproc ops into common driver
remoteproc: k3: Refactor .start rproc ops into common driver
remoteproc: k3: Refactor .stop rproc ops into common driver
remoteproc: k3: Refactor .attach rproc ops into common driver
remoteproc: k3: Refactor .detach rproc ops into common driver
remoteproc: k3: Refactor .get_loaded_rsc_table ops into common driver
remoteproc: k3: Refactor .da_to_va rproc ops into common driver
remoteproc: k3: Refactorof_get_memories()functions into common
driver
remoteproc: k3: Refactormem_release()functions into common driver
remoteproc: k3: Refactorreserved_mem_init()functions into common
driver
remoteproc: k3: Refactorrelease_tsp()functions into common driverSiddharth Vadapalli (2):
remoteproc: k3-r5: Drop check performed ink3_r5_rproc_{mbox_callback/kick} remoteproc: k3-dsp: Drop check performed in k3_dsp_rproc_{mbox_callback/kick}
Quoted 9 lines
drivers/remoteproc/Makefile | 6 +- drivers/remoteproc/ti_k3_common.c | 551 +++++++++++ drivers/remoteproc/ti_k3_common.h | 118 +++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 616 +------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 583 +----------- drivers/remoteproc/ti_k3_r5_remoteproc.c | 1018 +++++++-------------- 6 files changed, 1088 insertions(+), 1804 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_common.c create mode 100644 drivers/remoteproc/ti_k3_common.h
I have applied this set. Thanks to eveyone involved in making this happen.
Mathieu
Quoted 4 lines
Signature · 2 lines
-- 2.34.1