mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Beleswar Padhi <b-padhi@ti.com>, <andersson@kernel.org>,
	<mathieu.poirier@linaro.org>
Cc: <hnagalla@ti.com>, <u-kumar1@ti.com>, <jm@ti.com>,
	<jan.kiszka@siemens.com>, <christophe.jaillet@wanadoo.fr>,
	<jkangas@redhat.com>, <eballetbo@redhat.com>,
	<linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v9 01/26] remoteproc: k3-r5: Re-order internal memory initialization function
Date: Mon, 7 Apr 2025 08:29:38 -0500	[thread overview]
Message-ID: <4502a296-5380-4339-bfb1-1d741b74cf01@ti.com> (raw)
In-Reply-To: <20250317120622.1746415-2-b-padhi@ti.com>

On 3/17/25 7:05 AM, Beleswar Padhi wrote:
> The core's internal memory data structure will be refactored to be part
> of the k3_r5_rproc structure in a future commit. As a result, internal
> memory initialization will need to be performed inside
> k3_r5_cluster_rproc_init() after rproc_alloc().
> 
> Therefore, move the internal memory initialization function,
> k3_r5_core_of_get_internal_memories() above k3_r5_rproc_init() so that
> it can be invoked from there.
> 
> Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
> ---

Just to keep things organized, does it make sense to also move
the other k3_r5_core_of_get_*_memories() up with this?

Also, you move k3_r5_release_tsp() up too but don't mention
that in the commit message.

Andrew

>   drivers/remoteproc/ti_k3_r5_remoteproc.c | 158 +++++++++++------------
>   1 file changed, 79 insertions(+), 79 deletions(-)
> 
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index dbc513c5569c..b2738b9a1b2d 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1199,6 +1199,85 @@ 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 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);
> @@ -1358,78 +1437,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)
>   {
> @@ -1487,13 +1494,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_core_of_init(struct platform_device *pdev)
>   {
>   	struct device *dev = &pdev->dev;

  reply	other threads:[~2025-04-07 13:30 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17 12:05 [PATCH v9 00/26] Refactor TI K3 R5, DSP and M4 Remoteproc Drivers Beleswar Padhi
2025-03-17 12:05 ` [PATCH v9 01/26] remoteproc: k3-r5: Re-order internal memory initialization function Beleswar Padhi
2025-04-07 13:29   ` Andrew Davis [this message]
2025-04-08  8:14     ` Beleswar Prasad Padhi
2025-03-17 12:05 ` [PATCH v9 02/26] remoteproc: k3-r5: Refactor Data Structures to Align with DSP and M4 Beleswar Padhi
2025-04-07 13:33   ` Andrew Davis
2025-04-08  8:28     ` Beleswar Prasad Padhi
2025-03-17 12:05 ` [PATCH v9 03/26] remoteproc: k3-r5: Use k3_r5_rproc_mem_data structure for memory info Beleswar Padhi
2025-04-07 13:37   ` Andrew Davis
2025-03-17 12:06 ` [PATCH v9 04/26] remoteproc: k3-{m4/dsp}: Align internal rproc data structure with R5 Beleswar Padhi
2025-04-07 13:40   ` Andrew Davis
2025-03-17 12:06 ` [PATCH v9 05/26] remoteproc: k3-m4: Use k3_rproc_mem_data structure for memory info Beleswar Padhi
2025-04-07 13:43   ` Andrew Davis
2025-04-08  8:38     ` Beleswar Prasad Padhi
2025-03-17 12:06 ` [PATCH v9 06/26] remoteproc: k3-r5: Drop check performed in k3_r5_rproc_{mbox_callback/kick} Beleswar Padhi
2025-04-07 13:25   ` Andrew Davis
2025-03-17 12:06 ` [PATCH v9 07/26] remoteproc: k3-dsp: Drop check performed in k3_dsp_rproc_{mbox_callback/kick} Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 08/26] remoteproc: k3-r5: Refactor sequential core power up/down operations Beleswar Padhi
2025-04-07 13:45   ` Andrew Davis
2025-04-08  8:41     ` Beleswar Prasad Padhi
2025-03-17 12:06 ` [PATCH v9 09/26] remoteproc: k3: Refactor shared data structures Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 10/26] remoteproc: k3: Refactor mailbox rx_callback functions into common driver Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 11/26] remoteproc: k3: Refactor .kick rproc ops " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 12/26] remoteproc: k3: Refactor rproc_reset() implementation " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 13/26] remoteproc: k3: Refactor rproc_release() " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 14/26] remoteproc: k3: Refactor rproc_request_mbox() implementations " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 15/26] remoteproc: k3: Refactor .prepare rproc ops " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 16/26] remoteproc: k3: Refactor .unprepare " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 17/26] remoteproc: k3: Refactor .start " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 18/26] remoteproc: k3: Refactor .stop " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 19/26] remoteproc: k3: Refactor .attach " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 20/26] remoteproc: k3: Refactor .detach " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 21/26] remoteproc: k3: Refactor .get_loaded_rsc_table " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 22/26] remoteproc: k3: Refactor .da_to_va rproc " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 23/26] remoteproc: k3: Refactor of_get_memories() functions " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 24/26] remoteproc: k3: Refactor mem_release() " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 25/26] remoteproc: k3: Refactor reserved_mem_init() " Beleswar Padhi
2025-03-17 12:06 ` [PATCH v9 26/26] remoteproc: k3: Refactor release_tsp() " Beleswar Padhi
2025-04-07 13:04 ` [PATCH v9 00/26] Refactor TI K3 R5, DSP and M4 Remoteproc Drivers Beleswar Prasad Padhi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4502a296-5380-4339-bfb1-1d741b74cf01@ti.com \
    --to=afd@ti.com \
    --cc=andersson@kernel.org \
    --cc=b-padhi@ti.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=eballetbo@redhat.com \
    --cc=hnagalla@ti.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jkangas@redhat.com \
    --cc=jm@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=u-kumar1@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®