* [RFC 1/2] of: reserved_mem: check return value of_dma_configure
@ 2017-11-26 13:13 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-26 13:13 UTC (permalink / raw)
To: hch, m.szyprowski, robin.murphy, gregkh, robh+dt, frowand.list
Cc: iommu, linux-kernel, devicetree, van.freenix, Peng Fan
In commit <7b07cbefb6>("iommu: of: Handle IOMMU lookup failure
with deferred probing or error"), there is possibility that
of_dma_configure may fail. So in of_reserved_mem_device_init_by_idx,
also need to propagate the return value of_dma_configure to caller,
when need to use reserved memory for a device which needs iommu.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/of/of_reserved_mem.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 22b75c82e377..61523819b50e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -357,9 +357,12 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
/* ensure that dma_ops is set for virtual devices
* using reserved memory
*/
- of_dma_configure(dev, np);
-
- dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
+ ret = of_dma_configure(dev, np);
+ if (ret)
+ of_reserved_mem_device_release(dev);
+ else
+ dev_info(dev, "assigned reserved memory node %s\n",
+ rmem->name);
} else {
kfree(rd);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 1/2] of: reserved_mem: check return value of_dma_configure
@ 2017-11-26 13:13 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-26 13:13 UTC (permalink / raw)
To: hch-jcswGhMUV9g, m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ,
robin.murphy-5wv7dgnIgG8,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w
Cc: van.freenix-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Peng Fan,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In commit <7b07cbefb6>("iommu: of: Handle IOMMU lookup failure
with deferred probing or error"), there is possibility that
of_dma_configure may fail. So in of_reserved_mem_device_init_by_idx,
also need to propagate the return value of_dma_configure to caller,
when need to use reserved memory for a device which needs iommu.
Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
---
drivers/of/of_reserved_mem.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 22b75c82e377..61523819b50e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -357,9 +357,12 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
/* ensure that dma_ops is set for virtual devices
* using reserved memory
*/
- of_dma_configure(dev, np);
-
- dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
+ ret = of_dma_configure(dev, np);
+ if (ret)
+ of_reserved_mem_device_release(dev);
+ else
+ dev_info(dev, "assigned reserved memory node %s\n",
+ rmem->name);
} else {
kfree(rd);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-26 13:13 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-26 13:13 UTC (permalink / raw)
To: hch, m.szyprowski, robin.murphy, gregkh, robh+dt, frowand.list
Cc: iommu, linux-kernel, devicetree, van.freenix, Peng Fan
Invoke of_reserved_mem_device_init at dma_configure, then
there is no need to call of_reserved_mem_device_init in device
specific probe function.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/base/dma-mapping.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index e584eddef0a7..55dca06a7b55 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -12,6 +12,7 @@
#include <linux/export.h>
#include <linux/gfp.h>
#include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
@@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
}
if (dma_dev->of_node) {
- ret = of_dma_configure(dev, dma_dev->of_node);
+ ret = of_reserved_mem_device_init(dev);
+ if (ret)
+ ret = of_dma_configure(dev, dma_dev->of_node);
} else if (has_acpi_companion(dma_dev)) {
attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
if (attr != DEV_DMA_NOT_SUPPORTED)
@@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
void dma_deconfigure(struct device *dev)
{
of_dma_deconfigure(dev);
+ of_reserved_mem_device_release(dev);
acpi_dma_deconfigure(dev);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-26 13:13 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-26 13:13 UTC (permalink / raw)
To: hch-jcswGhMUV9g, m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ,
robin.murphy-5wv7dgnIgG8,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
van.freenix-Re5JQEeQqe8AvxtiuMwx3w, Peng Fan
Invoke of_reserved_mem_device_init at dma_configure, then
there is no need to call of_reserved_mem_device_init in device
specific probe function.
Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
---
drivers/base/dma-mapping.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index e584eddef0a7..55dca06a7b55 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -12,6 +12,7 @@
#include <linux/export.h>
#include <linux/gfp.h>
#include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
@@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
}
if (dma_dev->of_node) {
- ret = of_dma_configure(dev, dma_dev->of_node);
+ ret = of_reserved_mem_device_init(dev);
+ if (ret)
+ ret = of_dma_configure(dev, dma_dev->of_node);
} else if (has_acpi_companion(dma_dev)) {
attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
if (attr != DEV_DMA_NOT_SUPPORTED)
@@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
void dma_deconfigure(struct device *dev)
{
of_dma_deconfigure(dev);
+ of_reserved_mem_device_release(dev);
acpi_dma_deconfigure(dev);
}
--
2.14.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 15+ messages in thread
* RE: [RFC 1/2] of: reserved_mem: check return value of_dma_configure
@ 2017-11-27 4:15 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-27 4:15 UTC (permalink / raw)
To: hch, m.szyprowski, robin.murphy, gregkh, robh+dt, frowand.list
Cc: iommu, linux-kernel, devicetree, van.freenix
> -----Original Message-----
> From: Peng Fan
> Sent: Sunday, November 26, 2017 9:14 PM
> To: hch@lst.de; m.szyprowski@samsung.com; robin.murphy@arm.com;
> gregkh@linuxfoundation.org; robh+dt@kernel.org; frowand.list@gmail.com
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> devicetree@vger.kernel.org; van.freenix@gmail.com; Peng Fan
> <peng.fan@nxp.com>
> Subject: [RFC 1/2] of: reserved_mem: check return value of_dma_configure
>
> In commit <7b07cbefb6>("iommu: of: Handle IOMMU lookup failure with
> deferred probing or error"), there is possibility that of_dma_configure may fail.
> So in of_reserved_mem_device_init_by_idx,
> also need to propagate the return value of_dma_configure to caller, when
> need to use reserved memory for a device which needs iommu.
Seems my understanding is wrong, with iommu enabled, reserved memory will not be used
for devices with memory-region. Please still help review RFC 2/2.
Thanks,
Peng.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/of/of_reserved_mem.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 22b75c82e377..61523819b50e 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -357,9 +357,12 @@ int of_reserved_mem_device_init_by_idx(struct
> device *dev,
> /* ensure that dma_ops is set for virtual devices
> * using reserved memory
> */
> - of_dma_configure(dev, np);
> -
> - dev_info(dev, "assigned reserved memory node %s\n", rmem-
> >name);
> + ret = of_dma_configure(dev, np);
> + if (ret)
> + of_reserved_mem_device_release(dev);
> + else
> + dev_info(dev, "assigned reserved memory node %s\n",
> + rmem->name);
> } else {
> kfree(rd);
> }
> --
> 2.14.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [RFC 1/2] of: reserved_mem: check return value of_dma_configure
@ 2017-11-27 4:15 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-27 4:15 UTC (permalink / raw)
To: hch-jcswGhMUV9g, m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ,
robin.murphy-5wv7dgnIgG8,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w
Cc: van.freenix-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
> -----Original Message-----
> From: Peng Fan
> Sent: Sunday, November 26, 2017 9:14 PM
> To: hch-jcswGhMUV9g@public.gmane.org; m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org; robin.murphy-5wv7dgnIgG8@public.gmane.org;
> gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org; robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org; frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org;
> devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; van.freenix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; Peng Fan
> <peng.fan-3arQi8VN3Tc@public.gmane.org>
> Subject: [RFC 1/2] of: reserved_mem: check return value of_dma_configure
>
> In commit <7b07cbefb6>("iommu: of: Handle IOMMU lookup failure with
> deferred probing or error"), there is possibility that of_dma_configure may fail.
> So in of_reserved_mem_device_init_by_idx,
> also need to propagate the return value of_dma_configure to caller, when
> need to use reserved memory for a device which needs iommu.
Seems my understanding is wrong, with iommu enabled, reserved memory will not be used
for devices with memory-region. Please still help review RFC 2/2.
Thanks,
Peng.
>
> Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
> ---
> drivers/of/of_reserved_mem.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 22b75c82e377..61523819b50e 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -357,9 +357,12 @@ int of_reserved_mem_device_init_by_idx(struct
> device *dev,
> /* ensure that dma_ops is set for virtual devices
> * using reserved memory
> */
> - of_dma_configure(dev, np);
> -
> - dev_info(dev, "assigned reserved memory node %s\n", rmem-
> >name);
> + ret = of_dma_configure(dev, np);
> + if (ret)
> + of_reserved_mem_device_release(dev);
> + else
> + dev_info(dev, "assigned reserved memory node %s\n",
> + rmem->name);
> } else {
> kfree(rd);
> }
> --
> 2.14.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 8:31 ` Marek Szyprowski
0 siblings, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2017-11-27 8:31 UTC (permalink / raw)
To: Peng Fan, hch, robin.murphy, gregkh, robh+dt, frowand.list
Cc: iommu, linux-kernel, devicetree, van.freenix
Hi
On 2017-11-26 14:13, Peng Fan wrote:
> Invoke of_reserved_mem_device_init at dma_configure, then
> there is no need to call of_reserved_mem_device_init in device
> specific probe function.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This has been already tried long time ago, without success:
http://patches.linaro.org/patch/33558/
> ---
> drivers/base/dma-mapping.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index e584eddef0a7..55dca06a7b55 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -12,6 +12,7 @@
> #include <linux/export.h>
> #include <linux/gfp.h>
> #include <linux/of_device.h>
> +#include <linux/of_reserved_mem.h>
> #include <linux/slab.h>
> #include <linux/vmalloc.h>
>
> @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
> }
>
> if (dma_dev->of_node) {
> - ret = of_dma_configure(dev, dma_dev->of_node);
> + ret = of_reserved_mem_device_init(dev);
> + if (ret)
> + ret = of_dma_configure(dev, dma_dev->of_node);
> } else if (has_acpi_companion(dma_dev)) {
> attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
> if (attr != DEV_DMA_NOT_SUPPORTED)
> @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
> void dma_deconfigure(struct device *dev)
> {
> of_dma_deconfigure(dev);
> + of_reserved_mem_device_release(dev);
> acpi_dma_deconfigure(dev);
> }
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 8:31 ` Marek Szyprowski
0 siblings, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2017-11-27 8:31 UTC (permalink / raw)
To: Peng Fan, hch-jcswGhMUV9g, robin.murphy-5wv7dgnIgG8,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
van.freenix-Re5JQEeQqe8AvxtiuMwx3w
Hi
On 2017-11-26 14:13, Peng Fan wrote:
> Invoke of_reserved_mem_device_init at dma_configure, then
> there is no need to call of_reserved_mem_device_init in device
> specific probe function.
>
> Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
This has been already tried long time ago, without success:
http://patches.linaro.org/patch/33558/
> ---
> drivers/base/dma-mapping.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index e584eddef0a7..55dca06a7b55 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -12,6 +12,7 @@
> #include <linux/export.h>
> #include <linux/gfp.h>
> #include <linux/of_device.h>
> +#include <linux/of_reserved_mem.h>
> #include <linux/slab.h>
> #include <linux/vmalloc.h>
>
> @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
> }
>
> if (dma_dev->of_node) {
> - ret = of_dma_configure(dev, dma_dev->of_node);
> + ret = of_reserved_mem_device_init(dev);
> + if (ret)
> + ret = of_dma_configure(dev, dma_dev->of_node);
> } else if (has_acpi_companion(dma_dev)) {
> attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
> if (attr != DEV_DMA_NOT_SUPPORTED)
> @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
> void dma_deconfigure(struct device *dev)
> {
> of_dma_deconfigure(dev);
> + of_reserved_mem_device_release(dev);
> acpi_dma_deconfigure(dev);
> }
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 8:37 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-27 8:37 UTC (permalink / raw)
To: Marek Szyprowski
Cc: Peng Fan, hch, robin.murphy, gregkh, robh+dt, frowand.list,
iommu, linux-kernel, devicetree
Hi Marek,
On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>Hi
>
>On 2017-11-26 14:13, Peng Fan wrote:
>> Invoke of_reserved_mem_device_init at dma_configure, then
>> there is no need to call of_reserved_mem_device_init in device
>> specific probe function.
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>
>This has been already tried long time ago, without success:
>http://patches.linaro.org/patch/33558/
Thanks for the info. I should first search mail list before
sending out patches.
Thanks,
Peng.
>
>> ---
>> drivers/base/dma-mapping.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>> index e584eddef0a7..55dca06a7b55 100644
>> --- a/drivers/base/dma-mapping.c
>> +++ b/drivers/base/dma-mapping.c
>> @@ -12,6 +12,7 @@
>> #include <linux/export.h>
>> #include <linux/gfp.h>
>> #include <linux/of_device.h>
>> +#include <linux/of_reserved_mem.h>
>> #include <linux/slab.h>
>> #include <linux/vmalloc.h>
>> @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
>> }
>> if (dma_dev->of_node) {
>> - ret = of_dma_configure(dev, dma_dev->of_node);
>> + ret = of_reserved_mem_device_init(dev);
>> + if (ret)
>> + ret = of_dma_configure(dev, dma_dev->of_node);
>> } else if (has_acpi_companion(dma_dev)) {
>> attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
>> if (attr != DEV_DMA_NOT_SUPPORTED)
>> @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
>> void dma_deconfigure(struct device *dev)
>> {
>> of_dma_deconfigure(dev);
>> + of_reserved_mem_device_release(dev);
>> acpi_dma_deconfigure(dev);
>> }
>
>Best regards
>--
>Marek Szyprowski, PhD
>Samsung R&D Institute Poland
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 8:37 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-27 8:37 UTC (permalink / raw)
To: Marek Szyprowski
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Peng Fan,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, hch-jcswGhMUV9g
Hi Marek,
On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>Hi
>
>On 2017-11-26 14:13, Peng Fan wrote:
>> Invoke of_reserved_mem_device_init at dma_configure, then
>> there is no need to call of_reserved_mem_device_init in device
>> specific probe function.
>>
>> Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
>
>This has been already tried long time ago, without success:
>http://patches.linaro.org/patch/33558/
Thanks for the info. I should first search mail list before
sending out patches.
Thanks,
Peng.
>
>> ---
>> drivers/base/dma-mapping.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>> index e584eddef0a7..55dca06a7b55 100644
>> --- a/drivers/base/dma-mapping.c
>> +++ b/drivers/base/dma-mapping.c
>> @@ -12,6 +12,7 @@
>> #include <linux/export.h>
>> #include <linux/gfp.h>
>> #include <linux/of_device.h>
>> +#include <linux/of_reserved_mem.h>
>> #include <linux/slab.h>
>> #include <linux/vmalloc.h>
>> @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
>> }
>> if (dma_dev->of_node) {
>> - ret = of_dma_configure(dev, dma_dev->of_node);
>> + ret = of_reserved_mem_device_init(dev);
>> + if (ret)
>> + ret = of_dma_configure(dev, dma_dev->of_node);
>> } else if (has_acpi_companion(dma_dev)) {
>> attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
>> if (attr != DEV_DMA_NOT_SUPPORTED)
>> @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
>> void dma_deconfigure(struct device *dev)
>> {
>> of_dma_deconfigure(dev);
>> + of_reserved_mem_device_release(dev);
>> acpi_dma_deconfigure(dev);
>> }
>
>Best regards
>--
>Marek Szyprowski, PhD
>Samsung R&D Institute Poland
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 8:44 ` Marek Szyprowski
0 siblings, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2017-11-27 8:44 UTC (permalink / raw)
To: Peng Fan
Cc: Peng Fan, hch, robin.murphy, gregkh, robh+dt, frowand.list,
iommu, linux-kernel, devicetree
Hi Peng,
On 2017-11-27 09:37, Peng Fan wrote:
> Hi Marek,
>
> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>> Hi
>>
>> On 2017-11-26 14:13, Peng Fan wrote:
>>> Invoke of_reserved_mem_device_init at dma_configure, then
>>> there is no need to call of_reserved_mem_device_init in device
>>> specific probe function.
>>>
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> This has been already tried long time ago, without success:
>> http://patches.linaro.org/patch/33558/
> Thanks for the info. I should first search mail list before
> sending out patches.
It doesn't mean that I'm against such idea. I just pointed that I've
already tried. That time, however there was no dma_configure() function
yet, which seems to be better place for of_rmem_device_init().
I would however always call of_dma_configure(), even when reserved mem
node is there. IIRC on ARM64 that function configures dma_ops, without
which no dma is possible at all.
>
> Thanks,
> Peng.
>
>>> ---
>>> drivers/base/dma-mapping.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>>> index e584eddef0a7..55dca06a7b55 100644
>>> --- a/drivers/base/dma-mapping.c
>>> +++ b/drivers/base/dma-mapping.c
>>> @@ -12,6 +12,7 @@
>>> #include <linux/export.h>
>>> #include <linux/gfp.h>
>>> #include <linux/of_device.h>
>>> +#include <linux/of_reserved_mem.h>
>>> #include <linux/slab.h>
>>> #include <linux/vmalloc.h>
>>> @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
>>> }
>>> if (dma_dev->of_node) {
>>> - ret = of_dma_configure(dev, dma_dev->of_node);
>>> + ret = of_reserved_mem_device_init(dev);
>>> + if (ret)
>>> + ret = of_dma_configure(dev, dma_dev->of_node);
>>> } else if (has_acpi_companion(dma_dev)) {
>>> attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
>>> if (attr != DEV_DMA_NOT_SUPPORTED)
>>> @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
>>> void dma_deconfigure(struct device *dev)
>>> {
>>> of_dma_deconfigure(dev);
>>> + of_reserved_mem_device_release(dev);
>>> acpi_dma_deconfigure(dev);
>>> }
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 8:44 ` Marek Szyprowski
0 siblings, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2017-11-27 8:44 UTC (permalink / raw)
To: Peng Fan
Cc: Peng Fan, hch-jcswGhMUV9g, robin.murphy-5wv7dgnIgG8,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA
Hi Peng,
On 2017-11-27 09:37, Peng Fan wrote:
> Hi Marek,
>
> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>> Hi
>>
>> On 2017-11-26 14:13, Peng Fan wrote:
>>> Invoke of_reserved_mem_device_init at dma_configure, then
>>> there is no need to call of_reserved_mem_device_init in device
>>> specific probe function.
>>>
>>> Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
>> This has been already tried long time ago, without success:
>> http://patches.linaro.org/patch/33558/
> Thanks for the info. I should first search mail list before
> sending out patches.
It doesn't mean that I'm against such idea. I just pointed that I've
already tried. That time, however there was no dma_configure() function
yet, which seems to be better place for of_rmem_device_init().
I would however always call of_dma_configure(), even when reserved mem
node is there. IIRC on ARM64 that function configures dma_ops, without
which no dma is possible at all.
>
> Thanks,
> Peng.
>
>>> ---
>>> drivers/base/dma-mapping.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>>> index e584eddef0a7..55dca06a7b55 100644
>>> --- a/drivers/base/dma-mapping.c
>>> +++ b/drivers/base/dma-mapping.c
>>> @@ -12,6 +12,7 @@
>>> #include <linux/export.h>
>>> #include <linux/gfp.h>
>>> #include <linux/of_device.h>
>>> +#include <linux/of_reserved_mem.h>
>>> #include <linux/slab.h>
>>> #include <linux/vmalloc.h>
>>> @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
>>> }
>>> if (dma_dev->of_node) {
>>> - ret = of_dma_configure(dev, dma_dev->of_node);
>>> + ret = of_reserved_mem_device_init(dev);
>>> + if (ret)
>>> + ret = of_dma_configure(dev, dma_dev->of_node);
>>> } else if (has_acpi_companion(dma_dev)) {
>>> attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
>>> if (attr != DEV_DMA_NOT_SUPPORTED)
>>> @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
>>> void dma_deconfigure(struct device *dev)
>>> {
>>> of_dma_deconfigure(dev);
>>> + of_reserved_mem_device_release(dev);
>>> acpi_dma_deconfigure(dev);
>>> }
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 9:04 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-27 9:04 UTC (permalink / raw)
To: Marek Szyprowski
Cc: Peng Fan, hch, robin.murphy, gregkh, robh+dt, frowand.list,
iommu, linux-kernel, devicetree
Hi Marek,
On Mon, Nov 27, 2017 at 09:44:20AM +0100, Marek Szyprowski wrote:
>Hi Peng,
>
>On 2017-11-27 09:37, Peng Fan wrote:
>> Hi Marek,
>>
>> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>> > Hi
>> >
>> > On 2017-11-26 14:13, Peng Fan wrote:
>> > > Invoke of_reserved_mem_device_init at dma_configure, then
>> > > there is no need to call of_reserved_mem_device_init in device
>> > > specific probe function.
>> > >
>> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> > This has been already tried long time ago, without success:
>> > http://patches.linaro.org/patch/33558/
>> Thanks for the info. I should first search mail list before
>> sending out patches.
>
>It doesn't mean that I'm against such idea. I just pointed that I've
>already tried. That time, however there was no dma_configure() function
>yet, which seems to be better place for of_rmem_device_init().
>
>I would however always call of_dma_configure(), even when reserved mem
>node is there. IIRC on ARM64 that function configures dma_ops, without
>which no dma is possible at all.
So, you prefer this?
if (dma_dev->of_node) {
+ of_reserved_mem_device_init(dev);
ret = of_dma_configure(dev, dma_dev->of_node);
However in of_reserved_mem_device, there is also an call to
of_dma_configure.
"
/* ensure that dma_ops is set for virtual devices
* using reserved memory
*/
ret = of_dma_configure(dev, np);
"
If always call of_dma_configure, of_dma_configure maybe called twice.
I just checked more. of_reserved_mem_device_init only handle the first
memory-region. To nodes which have multiple memory-region, seems 2nd and etc
could not be handled, such as drivers/media/platform/s5p-mfc/s5p_mfc.c.
Thanks,
Peng.
>
>>
>> Thanks,
>> Peng.
>>
>> > > ---
>> > > drivers/base/dma-mapping.c | 6 +++++-
>> > > 1 file changed, 5 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>> > > index e584eddef0a7..55dca06a7b55 100644
>> > > --- a/drivers/base/dma-mapping.c
>> > > +++ b/drivers/base/dma-mapping.c
>> > > @@ -12,6 +12,7 @@
>> > > #include <linux/export.h>
>> > > #include <linux/gfp.h>
>> > > #include <linux/of_device.h>
>> > > +#include <linux/of_reserved_mem.h>
>> > > #include <linux/slab.h>
>> > > #include <linux/vmalloc.h>
>> > > @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
>> > > }
>> > > if (dma_dev->of_node) {
>> > > - ret = of_dma_configure(dev, dma_dev->of_node);
>> > > + ret = of_reserved_mem_device_init(dev);
>> > > + if (ret)
>> > > + ret = of_dma_configure(dev, dma_dev->of_node);
>> > > } else if (has_acpi_companion(dma_dev)) {
>> > > attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
>> > > if (attr != DEV_DMA_NOT_SUPPORTED)
>> > > @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
>> > > void dma_deconfigure(struct device *dev)
>> > > {
>> > > of_dma_deconfigure(dev);
>> > > + of_reserved_mem_device_release(dev);
>> > > acpi_dma_deconfigure(dev);
>> > > }
>
>Best regards
>--
>Marek Szyprowski, PhD
>Samsung R&D Institute Poland
>
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
@ 2017-11-27 9:04 ` Peng Fan
0 siblings, 0 replies; 15+ messages in thread
From: Peng Fan @ 2017-11-27 9:04 UTC (permalink / raw)
To: Marek Szyprowski
Cc: Peng Fan, hch-jcswGhMUV9g, robin.murphy-5wv7dgnIgG8,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA
Hi Marek,
On Mon, Nov 27, 2017 at 09:44:20AM +0100, Marek Szyprowski wrote:
>Hi Peng,
>
>On 2017-11-27 09:37, Peng Fan wrote:
>> Hi Marek,
>>
>> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>> > Hi
>> >
>> > On 2017-11-26 14:13, Peng Fan wrote:
>> > > Invoke of_reserved_mem_device_init at dma_configure, then
>> > > there is no need to call of_reserved_mem_device_init in device
>> > > specific probe function.
>> > >
>> > > Signed-off-by: Peng Fan <peng.fan-3arQi8VN3Tc@public.gmane.org>
>> > This has been already tried long time ago, without success:
>> > http://patches.linaro.org/patch/33558/
>> Thanks for the info. I should first search mail list before
>> sending out patches.
>
>It doesn't mean that I'm against such idea. I just pointed that I've
>already tried. That time, however there was no dma_configure() function
>yet, which seems to be better place for of_rmem_device_init().
>
>I would however always call of_dma_configure(), even when reserved mem
>node is there. IIRC on ARM64 that function configures dma_ops, without
>which no dma is possible at all.
So, you prefer this?
if (dma_dev->of_node) {
+ of_reserved_mem_device_init(dev);
ret = of_dma_configure(dev, dma_dev->of_node);
However in of_reserved_mem_device, there is also an call to
of_dma_configure.
"
/* ensure that dma_ops is set for virtual devices
* using reserved memory
*/
ret = of_dma_configure(dev, np);
"
If always call of_dma_configure, of_dma_configure maybe called twice.
I just checked more. of_reserved_mem_device_init only handle the first
memory-region. To nodes which have multiple memory-region, seems 2nd and etc
could not be handled, such as drivers/media/platform/s5p-mfc/s5p_mfc.c.
Thanks,
Peng.
>
>>
>> Thanks,
>> Peng.
>>
>> > > ---
>> > > drivers/base/dma-mapping.c | 6 +++++-
>> > > 1 file changed, 5 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
>> > > index e584eddef0a7..55dca06a7b55 100644
>> > > --- a/drivers/base/dma-mapping.c
>> > > +++ b/drivers/base/dma-mapping.c
>> > > @@ -12,6 +12,7 @@
>> > > #include <linux/export.h>
>> > > #include <linux/gfp.h>
>> > > #include <linux/of_device.h>
>> > > +#include <linux/of_reserved_mem.h>
>> > > #include <linux/slab.h>
>> > > #include <linux/vmalloc.h>
>> > > @@ -351,7 +352,9 @@ int dma_configure(struct device *dev)
>> > > }
>> > > if (dma_dev->of_node) {
>> > > - ret = of_dma_configure(dev, dma_dev->of_node);
>> > > + ret = of_reserved_mem_device_init(dev);
>> > > + if (ret)
>> > > + ret = of_dma_configure(dev, dma_dev->of_node);
>> > > } else if (has_acpi_companion(dma_dev)) {
>> > > attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode));
>> > > if (attr != DEV_DMA_NOT_SUPPORTED)
>> > > @@ -367,5 +370,6 @@ int dma_configure(struct device *dev)
>> > > void dma_deconfigure(struct device *dev)
>> > > {
>> > > of_dma_deconfigure(dev);
>> > > + of_reserved_mem_device_release(dev);
>> > > acpi_dma_deconfigure(dev);
>> > > }
>
>Best regards
>--
>Marek Szyprowski, PhD
>Samsung R&D Institute Poland
>
--
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time
2017-11-27 9:04 ` Peng Fan
(?)
@ 2017-12-07 12:01 ` Marek Szyprowski
-1 siblings, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2017-12-07 12:01 UTC (permalink / raw)
To: Peng Fan
Cc: Peng Fan, hch, robin.murphy, gregkh, robh+dt, frowand.list,
iommu, linux-kernel, devicetree
Hi Peng,
On 2017-11-27 10:04, Peng Fan wrote:
> On Mon, Nov 27, 2017 at 09:44:20AM +0100, Marek Szyprowski wrote:
>> On 2017-11-27 09:37, Peng Fan wrote:
>>> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote:
>>>> On 2017-11-26 14:13, Peng Fan wrote:
>>>>> Invoke of_reserved_mem_device_init at dma_configure, then
>>>>> there is no need to call of_reserved_mem_device_init in device
>>>>> specific probe function.
>>>>>
>>>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>>> This has been already tried long time ago, without success:
>>>> http://patches.linaro.org/patch/33558/
>>> Thanks for the info. I should first search mail list before
>>> sending out patches.
>> It doesn't mean that I'm against such idea. I just pointed that I've
>> already tried. That time, however there was no dma_configure() function
>> yet, which seems to be better place for of_rmem_device_init().
>>
>> I would however always call of_dma_configure(), even when reserved mem
>> node is there. IIRC on ARM64 that function configures dma_ops, without
>> which no dma is possible at all.
> So, you prefer this?
> if (dma_dev->of_node) {
> + of_reserved_mem_device_init(dev);
> ret = of_dma_configure(dev, dma_dev->of_node);
>
> However in of_reserved_mem_device, there is also an call to
> of_dma_configure.
>
> "
> /* ensure that dma_ops is set for virtual devices
> * using reserved memory
> */
> ret = of_dma_configure(dev, np);
> "
>
> If always call of_dma_configure, of_dma_configure maybe called twice.
Right, I forgot about this.
> I just checked more. of_reserved_mem_device_init only handle the first
> memory-region. To nodes which have multiple memory-region, seems 2nd and etc
> could not be handled, such as drivers/media/platform/s5p-mfc/s5p_mfc.c.
Well, maybe automatic assignment should be done only when there is only
one reserved region set? In case more than one region assigned to a device,
the driver has to create virtual child devices and configure DMA for them
to be able to let dma-mapping API to use those reserved regions. It looks
that the call to of_dma_configure(dev, np) can be moved back to the driver
(it was not possible at the time that code was merged due to missing
export symbols).
Configuring more than one reserved memory region for given device might
then moved to some helper function to have a common code for that across
the drivers.
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-12-07 12:01 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-26 13:13 [RFC 1/2] of: reserved_mem: check return value of_dma_configure Peng Fan
2017-11-26 13:13 ` Peng Fan
2017-11-26 13:13 ` [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time Peng Fan
2017-11-26 13:13 ` Peng Fan
2017-11-27 8:31 ` Marek Szyprowski
2017-11-27 8:31 ` Marek Szyprowski
2017-11-27 8:37 ` Peng Fan
2017-11-27 8:37 ` Peng Fan
2017-11-27 8:44 ` Marek Szyprowski
2017-11-27 8:44 ` Marek Szyprowski
2017-11-27 9:04 ` Peng Fan
2017-11-27 9:04 ` Peng Fan
2017-12-07 12:01 ` Marek Szyprowski
2017-11-27 4:15 ` [RFC 1/2] of: reserved_mem: check return value of_dma_configure Peng Fan
2017-11-27 4:15 ` Peng Fan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.