From: Baolin Wang <hidden> Date: 2016-06-07 08:30:07
Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if
it did not call 'arch_setup_dma_ops' at device creation time by issuing
platform_device_alloc() function, that will cause failure when setting
the dma mask for device.
Hence We need to hook the archdata to setup proper dma_ops for these devices.
Signed-off-by: Baolin Wang <redacted>
---
arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
From: Robin Murphy <robin.murphy@arm.com> Date: 2016-06-07 09:16:03
On 07/06/16 09:29, Baolin Wang wrote:
Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if
it did not call 'arch_setup_dma_ops' at device creation time by issuing
platform_device_alloc() function, that will cause failure when setting
the dma mask for device.
Yes, that's rather the whole point. DMA-capable devices are real
hardware, therefore don't spring out of thin air without being described
in DT or ACPI.
Please elaborate on the situation that you're attempting to address here
(please don't let it be the ongoing Designware USB catastrophe ;))
Robin.
quoted hunk
Hence We need to hook the archdata to setup proper dma_ops for these devices.
Signed-off-by: Baolin Wang <redacted>
---
arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
From: Baolin Wang <hidden> Date: 2016-06-07 09:22:36
On 7 June 2016 at 17:15, Robin Murphy [off-list ref] wrote:
On 07/06/16 09:29, Baolin Wang wrote:
quoted
Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if
it did not call 'arch_setup_dma_ops' at device creation time by issuing
platform_device_alloc() function, that will cause failure when setting
the dma mask for device.
Yes, that's rather the whole point. DMA-capable devices are real hardware,
therefore don't spring out of thin air without being described in DT or
ACPI.
OK.
Please elaborate on the situation that you're attempting to address here
(please don't let it be the ongoing Designware USB catastrophe ;))
Yes, like you mentioned, we met problems at DesignWare USB3 controller
host glue, do you have any better solutions to solve this problem?
Thanks.
Robin.
quoted
Hence We need to hook the archdata to setup proper dma_ops for these
devices.
Signed-off-by: Baolin Wang <redacted>
---
arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
dma_base, u64 size,
dev->archdata.dma_coherent = coherent;
__iommu_setup_dma_ops(dev, dma_base, size, iommu);
}
+
+void arch_setup_pdev_archdata(struct platform_device *pdev)
+{
+ if (!pdev->dev.archdata.dma_ops)
+ pdev->dev.archdata.dma_ops = &swiotlb_dma_ops;
+
+ /*
+ * Set default coherent_dma_mask to 32 bit. Drivers are expected
to
+ * setup the correct supported mask.
+ */
+ if (!pdev->dev.coherent_dma_mask)
+ pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
+ /*
+ * Set it to coherent_dma_mask by default if the architecture
+ * code has not set it.
+ */
+ if (!pdev->dev.dma_mask)
+ pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+}
On Tuesday, June 7, 2016 4:29:21 PM CEST Baolin Wang wrote:
quoted hunk
Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if
it did not call 'arch_setup_dma_ops' at device creation time by issuing
platform_device_alloc() function, that will cause failure when setting
the dma mask for device.
Hence We need to hook the archdata to setup proper dma_ops for these devices.
Signed-off-by: Baolin Wang <redacted>
---
arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
You need to check the DT here to see if these are the right ops,
or if you have to go through an IOMMU. Also, you have to set up the
other fields that are controlled by arch_setup_dma_ops: whether
it's coherent and what the offset is.
+ /*
+ * Set default coherent_dma_mask to 32 bit. Drivers are expected to
+ * setup the correct supported mask.
+ */
+ if (!pdev->dev.coherent_dma_mask)
+ pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
+ /*
+ * Set it to coherent_dma_mask by default if the architecture
+ * code has not set it.
+ */
+ if (!pdev->dev.dma_mask)
+ pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+}
We still have an open bug about the dma_set_mask() function on ARM64:
we have to check the dma-ranges property to ensure that no device can
set a mask wider than what its parent bus can support.
What is your plan for this in case of these devices?
Arnd
From: Baolin Wang <hidden> Date: 2016-06-13 08:26:41
On 7 June 2016 at 16:43, Arnd Bergmann [off-list ref] wrote:
On Tuesday, June 7, 2016 4:29:21 PM CEST Baolin Wang wrote:
quoted
Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if
it did not call 'arch_setup_dma_ops' at device creation time by issuing
platform_device_alloc() function, that will cause failure when setting
the dma mask for device.
Hence We need to hook the archdata to setup proper dma_ops for these devices.
Signed-off-by: Baolin Wang <redacted>
---
arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
You need to check the DT here to see if these are the right ops,
or if you have to go through an IOMMU. Also, you have to set up the
other fields that are controlled by arch_setup_dma_ops: whether
it's coherent and what the offset is.
That's right. This is just set the platform device arch data, after
that the dma ops will be re-setup by issuing arch_setup_dma_ops(). But
some platform devices created by platform_device_alloc() will not
issue the arch_setup_dma_ops() function to setup the dma ops. So I
want to set the default dma ops by arch_setup_pdev_archdata(), but
that is not reasonable according to Robin's explanation.
quoted
+ /*
+ * Set default coherent_dma_mask to 32 bit. Drivers are expected to
+ * setup the correct supported mask.
+ */
+ if (!pdev->dev.coherent_dma_mask)
+ pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
+ /*
+ * Set it to coherent_dma_mask by default if the architecture
+ * code has not set it.
+ */
+ if (!pdev->dev.dma_mask)
+ pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+}
We still have an open bug about the dma_set_mask() function on ARM64:
we have to check the dma-ranges property to ensure that no device can
set a mask wider than what its parent bus can support.
What is your plan for this in case of these devices?
I think these are just default setup for dma mask. I suppose the
checking you mentioned should be added in of_dma_configure()?
--
Baolin.wang
Best Regards