linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: core: avoid duplicated rproc-virtio.[x] device
@ 2022-10-13 12:32 Peng Fan (OSS)
  2022-10-13 12:42 ` Mukesh Ojha
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan (OSS) @ 2022-10-13 12:32 UTC (permalink / raw)
  To: andersson, mathieu.poirier, arnaud.pouliquen, linux-remoteproc,
	linux-kernel
  Cc: Peng Fan

From: Peng Fan <peng.fan@nxp.com>

When there are multiple remoteproc cores(i.MX8QM has dual CM4), there
will be duplicated platform device created. When 1st CM4 rproc got
probed, rproc-virtio.0 was registered. Then 2nd CM4 rproc continue
register rproc-virtio.o will report failure.

So use PLATFORM_DEVID_AUTO here. Then the kernel log will has such:
rproc-virtio rproc-virtio.1.auto: registered virtio0 (type 7)

Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V1:
  I think this issue will happen when more than one rproc, saying CM4 + DSP,
or CM4 + CM4.
  I thought to add a index to rproc, then use
  'rproc->index * rvdev_data.index' as the id, but seems a bit complicated
  compared with use PLATFORM_DEVID_AUTO.


 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 8768cb64f560..03a26498e879 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -509,7 +509,7 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr,
 	rvdev_data.rsc_offset = offset;
 	rvdev_data.rsc = rsc;
 
-	pdev = platform_device_register_data(dev, "rproc-virtio", rvdev_data.index, &rvdev_data,
+	pdev = platform_device_register_data(dev, "rproc-virtio", PLATFORM_DEVID_AUTO, &rvdev_data,
 					     sizeof(rvdev_data));
 	if (IS_ERR(pdev)) {
 		dev_err(dev, "failed to create rproc-virtio device\n");
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] remoteproc: core: avoid duplicated rproc-virtio.[x] device
  2022-10-13 12:32 [PATCH] remoteproc: core: avoid duplicated rproc-virtio.[x] device Peng Fan (OSS)
@ 2022-10-13 12:42 ` Mukesh Ojha
  2022-10-13 12:44   ` Peng Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Mukesh Ojha @ 2022-10-13 12:42 UTC (permalink / raw)
  To: Peng Fan (OSS),
	andersson, mathieu.poirier, arnaud.pouliquen, linux-remoteproc,
	linux-kernel
  Cc: Peng Fan

Hi,

On 10/13/2022 6:02 PM, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> When there are multiple remoteproc cores(i.MX8QM has dual CM4), there
> will be duplicated platform device created. When 1st CM4 rproc got
> probed, rproc-virtio.0 was registered. Then 2nd CM4 rproc continue
> register rproc-virtio.o will report failure.
> 
> So use PLATFORM_DEVID_AUTO here. Then the kernel log will has such:
> rproc-virtio rproc-virtio.1.auto: registered virtio0 (type 7)
> 
> Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 
> V1:
>    I think this issue will happen when more than one rproc, saying CM4 + DSP,
> or CM4 + CM4.
>    I thought to add a index to rproc, then use
>    'rproc->index * rvdev_data.index' as the id, but seems a bit complicated
>    compared with use PLATFORM_DEVID_AUTO.
> 
> 
>   drivers/remoteproc/remoteproc_core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 8768cb64f560..03a26498e879 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -509,7 +509,7 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr,
>   	rvdev_data.rsc_offset = offset;
>   	rvdev_data.rsc = rsc;
>   
> -	pdev = platform_device_register_data(dev, "rproc-virtio", rvdev_data.index, &rvdev_data,
> +	pdev = platform_device_register_data(dev, "rproc-virtio", PLATFORM_DEVID_AUTO, &rvdev_data,
>   					     sizeof(rvdev_data));
>   	if (IS_ERR(pdev)) {
>   		dev_err(dev, "failed to create rproc-virtio device\n");


Looks to be same as

https://lore.kernel.org/lkml/1665628087-20829-1-git-send-email-shengjiu.wang@nxp.com/

-Mukesh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] remoteproc: core: avoid duplicated rproc-virtio.[x] device
  2022-10-13 12:42 ` Mukesh Ojha
@ 2022-10-13 12:44   ` Peng Fan
  0 siblings, 0 replies; 3+ messages in thread
From: Peng Fan @ 2022-10-13 12:44 UTC (permalink / raw)
  To: Mukesh Ojha, Peng Fan (OSS),
	andersson, mathieu.poirier, arnaud.pouliquen, linux-remoteproc,
	linux-kernel

> Subject: Re: [PATCH] remoteproc: core: avoid duplicated rproc-virtio.[x]
> device
> 
> Hi,
> 
> On 10/13/2022 6:02 PM, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > When there are multiple remoteproc cores(i.MX8QM has dual CM4), there
> > will be duplicated platform device created. When 1st CM4 rproc got
> > probed, rproc-virtio.0 was registered. Then 2nd CM4 rproc continue
> > register rproc-virtio.o will report failure.
> >
> > So use PLATFORM_DEVID_AUTO here. Then the kernel log will has such:
> > rproc-virtio rproc-virtio.1.auto: registered virtio0 (type 7)
> >
> > Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for
> > the remoteproc_virtio")
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >
> > V1:
> >    I think this issue will happen when more than one rproc, saying CM4
> > + DSP, or CM4 + CM4.
> >    I thought to add a index to rproc, then use
> >    'rproc->index * rvdev_data.index' as the id, but seems a bit complicated
> >    compared with use PLATFORM_DEVID_AUTO.
> >
> >
> >   drivers/remoteproc/remoteproc_core.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/remoteproc/remoteproc_core.c
> > b/drivers/remoteproc/remoteproc_core.c
> > index 8768cb64f560..03a26498e879 100644
> > --- a/drivers/remoteproc/remoteproc_core.c
> > +++ b/drivers/remoteproc/remoteproc_core.c
> > @@ -509,7 +509,7 @@ static int rproc_handle_vdev(struct rproc *rproc,
> void *ptr,
> >   	rvdev_data.rsc_offset = offset;
> >   	rvdev_data.rsc = rsc;
> >
> > -	pdev = platform_device_register_data(dev, "rproc-virtio",
> rvdev_data.index, &rvdev_data,
> > +	pdev = platform_device_register_data(dev, "rproc-virtio",
> > +PLATFORM_DEVID_AUTO, &rvdev_data,
> >   					     sizeof(rvdev_data));
> >   	if (IS_ERR(pdev)) {
> >   		dev_err(dev, "failed to create rproc-virtio device\n");
> 
> 
> Looks to be same as
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Flkml%2F1665628087-20829-1-git-send-email-
> shengjiu.wang%40nxp.com%2F&amp;data=05%7C01%7Cpeng.fan%40nxp.c
> om%7C668b13ed67d24714d51008daad185d69%7C686ea1d3bc2b4c6fa92cd
> 99c5c301635%7C0%7C0%7C638012617398936051%7CUnknown%7CTWFpb
> GZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI
> 6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=Blv30z3AYk6v3GTS4aEizM62v2
> zrTmK1rDFAdlxagB8%3D&amp;reserved=0

Ohh! Duplicated effort, I should check list before working on this (:

Thanks,
Peng.
> 
> -Mukesh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-13 12:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13 12:32 [PATCH] remoteproc: core: avoid duplicated rproc-virtio.[x] device Peng Fan (OSS)
2022-10-13 12:42 ` Mukesh Ojha
2022-10-13 12:44   ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).