remoteproc: recopy parent dma_pfn_offset for vdev
PATCH 1/1 remoteproc: recopy parent dma_pfn_offset for vdev
When preparing the subdevice for the vdev, also copy dma_pfn_offset since this is used for sub device dma allocations. Without that, there is incoherency between the parent dma settings and the childs one, potentially leading to dma_alloc_coherent failure (due to phys_to_dma using dma_pfn_offset for translation).
--- drivers/remoteproc/remoteproc_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/remoteproc_core.c +1 -0
@@ -520,6 +520,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,/* Initialise vdev subdevice */ snprintf (name,sizeof (name),"vdev%dbuffer" , rvdev->index); rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release;dev_set_name (&rvdev->dev,"%s#%s" ,dev_name (rvdev->dev.parent), name);dev_set_drvdata (&rvdev->dev, rvdev);
Signature · 1 line
2.15.0.276.g89ea799
Hi Clement,
Quoted 10 lines
-----Original Message-----
From: [email protected] <linux-remoteproc- [email protected]> On Behalf Of Clement Leger
Sent: mercredi 12 juin 2019 11:55
To: Ohad Ben-Cohen <[email protected]>; Bjorn Andersson <[email protected]>; linux-remoteproc <linux- [email protected]>
Cc: Clement Leger <[email protected]>
Subject: [PATCH] remoteproc: recopy parentdma_pfn_offsetfor vdev
Quoted 5 lines
When preparing the subdevice for the vdev, also copy
dma_pfn_offsetsince this is used for sub device dma allocations. Without that, there is incoherency between the parent dma settings and the childs one, potentially leading todma_alloc_coherentfailure (due tophys_to_dmausingdma_pfn_offsetfor translation).
Thanks for this correction.
Could you please add fixes in message commit
Else
Regards,
Loic
Quoted 21 lines
--- drivers/remoteproc/remoteproc_core.c | 1 + 1 file changed, 1 insertion(+)drivers/remoteproc/remoteproc_core.c +1
-0@@ -520,6 +520,7 @@ static int rproc_handle_vdev(struct rproc *rproc,struct fw_rsc_vdev *rsc,/* Initialise vdev subdevice */ snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release; dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev-Quoted 1 line
dev.parent), name);
dev_set_drvdata(&rvdev->dev, rvdev);
--
2.15.0.276.g89ea799
Quoted 5 lines · Clement Leger
When preparing the subdevice for the vdev, also copy
dma_pfn_offsetsince this is used for sub device dma allocations. Without that, there is incoherency between the parent dma settings and the childs one, potentially leading todma_alloc_coherentfailure (due tophys_to_dmausingdma_pfn_offsetfor translation).
Hi Clement,
This looks reasonable, but I can't merge it without your Signed-off-by.
Can you please resubmit the change, with the Fixes: and Loic's ack?
Regards,
Bjorn
Quoted 19 lines
--- drivers/remoteproc/remoteproc_core.c | 1 + 1 file changed, 1 insertion(+)drivers/remoteproc/remoteproc_core.c +1
-0@@ -520,6 +520,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,/* Initialise vdev subdevice */ snprintf (name,sizeof (name),"vdev%dbuffer" , rvdev->index); rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release;dev_set_name (&rvdev->dev,"%s#%s" ,dev_name (rvdev->dev.parent), name);dev_set_drvdata (&rvdev->dev, rvdev);Signature · 1 line
2.15.0.276.g89ea799
PATCH v2 1/1 remoteproc: copy parent dma_pfn_offset for vdev
In reply to Clement LegerWhen preparing the subdevice for the vdev, also copy dma_pfn_offset since this is used for sub device dma allocations. Without that, there is incoherency between the parent dma settings and the childs one, potentially leading to dma_alloc_coherent failure (due to phys_to_dma using dma_pfn_offset for translation).
---
Changes in v2:
- Fix typo in commit message
- Add "Fixes" in commit message
- Add Signed-off
- Add Acked-by Loic Pallardy
--- drivers/remoteproc/remoteproc_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/remoteproc_core.c +1 -0
@@ -520,6 +520,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,/* Initialise vdev subdevice */ snprintf (name,sizeof (name),"vdev%dbuffer" , rvdev->index); rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release;dev_set_name (&rvdev->dev,"%s#%s" ,dev_name (rvdev->dev.parent), name);dev_set_drvdata (&rvdev->dev, rvdev);
Signature · 1 line
2.15.0.276.g89ea799
Re: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
Quoted 9 lines · Clement Leger
When preparing the subdevice for the vdev, also copy
dma_pfn_offsetsince this is used for sub device dma allocations. Without that, there is incoherency between the parent dma settings and the childs one, potentially leading todma_alloc_coherentfailure (due tophys_to_dmausingdma_pfn_offsetfor translation).Fixes 086d08725d34 ("remoteproc: create vdev subdevice with specific dma memory pool")Signed-off-by Clement Leger <[email protected]>Acked-by Loic Pallardy <[email protected]>
Thanks for the update. Applied
Regards,
Bjorn
Quoted 26 lines
---
Changes in v2:
- Fix typo in commit message
- Add "Fixes" in commit message
- Add Signed-off
- Add Acked-by Loic Pallardy--- drivers/remoteproc/remoteproc_core.c | 1 + 1 file changed, 1 insertion(+)drivers/remoteproc/remoteproc_core.c +1
-0@@ -520,6 +520,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,/* Initialise vdev subdevice */ snprintf (name,sizeof (name),"vdev%dbuffer" , rvdev->index); rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release;dev_set_name (&rvdev->dev,"%s#%s" ,dev_name (rvdev->dev.parent), name);dev_set_drvdata (&rvdev->dev, rvdev);Signature · 1 line
2.15.0.276.g89ea799
Re: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
In reply to Clement LegerThis is just increasing the mess remoteproc has created with the vdev. It is poking its nose way to deep into the DMA layer internals, and creating massive problems that way. Can we go back to the table and figure out what the root problem even was? To me it seems if you clearly need separate devices they should be declared as such in the device tree.
RE: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
Hi Christoph,
Quoted 9 lines
-----Original Message-----
From: Christoph Hellwig <[email protected]>
Sent: mardi 2 juillet 2019 15:22
To: Clement Leger <[email protected]>
Cc: Ohad Ben-Cohen <[email protected]>; Bjorn Andersson <[email protected]>; [email protected]; linux- [email protected]; Loic PALLARDY <[email protected]>
Subject: Re: [PATCH v2] remoteproc: copy parentdma_pfn_offsetfor vdev
Quoted 6 lines
This is just increasing the mess remoteproc has created with the vdev. It is poking its nose way to deep into the DMA layer internals, and creating massive problems that way. Can we go back to the table and figure out what the root problem even was? To me it seems if you clearly need separate devices they should be declared as such in the device tree.
Agree there is definitively an issue with the way virtio device are defined. Today definition is based on rproc firmware ressource table and rproc framework is in charge of vdev creation.
Device tree definition was discarded as vdev is not HW but SW definition. One solution would be to associate both resource table (which provides Firmware capabilities) and some virtio device tree nodes (declared as sub nodes of remote processor with associated resources like memory carveout). When we have a match between resource table and rproc DT sub node, we can register virtio device via of_platform_populate.
Then need to adapt virtio_rpmsg or to create a virtio_rproc to be DT probe compliant like virtio_mmio is.
But that's breaking legacy as all platforms will have to add a virtio device node in their DT file...
Is it aligned with your view ?
Regards,
Loic
Re: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
Quoted 4 lines · Loic PALLARDY
Agree there is definitively an issue with the way virtio device are defined. Today definition is based on rproc firmware ressource table and rproc framework is in charge of vdev creation.
Device tree definition was discarded as vdev is not HW but SW definition.
Well, it appears to be a firmware interface description.
Quoted 8 lines
One solution would be to associate both resource table (which provides Firmware capabilities) and some virtio device tree nodes (declared as sub nodes of remote processor with associated resources like memory carveout). When we have a match between resource table and rproc DT sub node, we can register virtio device via
of_platform_populate.
Then need to adaptvirtio_rpmsgor to create avirtio_rprocto be DT probe compliant likevirtio_mmiois.
Quoted 4 lines
But that's breaking legacy as all platforms will have to add a virtio device node in their DT file...
Is it aligned with your view ?
Yes, that is how I'd assume it works. But given that until recently you did now have these subdevices for dma coherent purposes we can't really break anything older than that, so I might still be missing something.
Re: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines
But that's breaking legacy as all platforms will have to add a virtio device node in their DT file...
Is it aligned with your view ?
Yes, that is how I'd assume it works. But given that until recently you did now have these subdevices for dma coherent purposes we can't really break anything older than that, so I might still be missing something.
Any chance we could expedite this? remoteproc is the only driver inheriting dma ops to subdevices, and the only one using dma_declare_coherent_memory. I'd really like to clean this mess up rather sooner than later.
RE: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
Quoted 24 lines
-----Original Message-----
From: Christoph Hellwig <[email protected]>
Sent: vendredi 19 juillet 2019 08:33
To: Loic PALLARDY <[email protected]>
Cc: Christoph Hellwig <[email protected]>; Clement Leger <[email protected]>; Ohad Ben-Cohen <[email protected]>; Bjorn Andersson <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH v2] remoteproc: copy parentdma_pfn_offsetfor vdevQuoted 1 line · Christoph Hellwig
Quoted 1 line
But that's breaking legacy as all platforms will have to add a virtio device
node in
Quoted 8 lines
Quoted 3 lines
their DT file...
Is it aligned with your view ?
Yes, that is how I'd assume it works. But given that until recently you did now have these subdevices for dma coherent purposes we can't really break anything older than that, so I might still be missing something.
Quoted 4 lines
Any chance we could expedite this? remoteproc is the only driver inheriting dma ops to subdevices, and the only one using
dma_declare_coherent_memory. I'd really like to clean this mess up rather sooner than later.
Ongoing...
Two topics to clean up:
- Sub device creation and DMA ops inheritance --> need to use platform_device or device tree
- dma_declare_coherent_memory use --> it has been introduced to support internal memories declared via reg field. I propose to migrate existing drivers on reserved memory usage and so remove dma_declare_coherent call from remoteproc core.
Re: [PATCH v2] remoteproc: copy parent dma_pfn_offset for vdev
Quoted 5 lines · Loic PALLARDY
Ongoing...
Two topics to clean up:
- Sub device creation and DMA ops inheritance --> need to useplatform_deviceor device tree
-dma_declare_coherent_memoryuse --> it has been introduced to support internal memories declared via reg field. I propose to migrate existing drivers on reserved memory usage and so removedma_declare_coherentcall from remoteproc core.
I thought this was inter-related in that you needed the additional field with the manual memory region for the subdevs, but I guess I misunderstood. Anyway, thanks for doing the work.