RE: [RFC 1/2] of: reserved_mem: check return value of_dma_configure

2017-11-26 Thread Peng Fan


> -Original Message-
> From: Peng Fan
> Sent: Sunday, November 26, 2017 9:14 PM
> To: h...@lst.de; m.szyprow...@samsung.com; robin.mur...@arm.com;
> gre...@linuxfoundation.org; robh...@kernel.org; frowand.l...@gmail.com
> Cc: iommu@lists.linux-foundation.org; linux-ker...@vger.kernel.org;
> devicet...@vger.kernel.org; van.free...@gmail.com; Peng Fan
> <peng....@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@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

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[RFC 1/2] of: reserved_mem: check return value of_dma_configure

2017-11-26 Thread 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 
---
 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

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu