linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] nand: ranw: qcom_nand: stop using phys_to_dma()
@ 2018-07-17 20:27 Arnd Bergmann
  2018-07-17 20:33 ` Boris Brezillon
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-07-17 20:27 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, David Woodhouse, Brian Norris,
	Marek Vasut, Richard Weinberger
  Cc: Arnd Bergmann, Abhishek Sahu, Archit Taneja, Masahiro Yamada,
	linux-mtd, linux-kernel

Compile-testing this driver on x86 caused a link error:

ERROR: "__phys_to_dma" [drivers/mtd/nand/raw/qcom_nandc.ko] undefined!

The problem here is that the driver attempts to convert the physical
address into the DMA controller as a dma_addr_t and calls phys_to_dma()
to do the conversion.

The correct way to do the conversion is using the dma mapping interfaces.

Fixes: c76b78d8ec05 ("mtd: nand: Qualcomm NAND controller driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/mtd/nand/raw/qcom_nandc.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 994f980c6d86..645630953f38 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -2957,14 +2957,6 @@ static int qcom_nandc_probe(struct platform_device *pdev)
 
 	nandc->props = dev_data;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	nandc->base = devm_ioremap_resource(dev, res);
-	if (IS_ERR(nandc->base))
-		return PTR_ERR(nandc->base);
-
-	nandc->base_phys = res->start;
-	nandc->base_dma = phys_to_dma(dev, (phys_addr_t)res->start);
-
 	nandc->core_clk = devm_clk_get(dev, "core");
 	if (IS_ERR(nandc->core_clk))
 		return PTR_ERR(nandc->core_clk);
@@ -2977,9 +2969,21 @@ static int qcom_nandc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	nandc->base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(nandc->base))
+		return PTR_ERR(nandc->base);
+
+	nandc->base_phys = res->start;
+	nandc->base_dma = dma_map_resource(dev, res->start,
+					   resource_size(res),
+					   DMA_BIDIRECTIONAL, 0);
+	if (!nandc->base_dma)
+		return -ENXIO;
+
 	ret = qcom_nandc_alloc(nandc);
 	if (ret)
-		goto err_core_clk;
+		goto err_nandc_alloc;
 
 	ret = clk_prepare_enable(nandc->core_clk);
 	if (ret)
@@ -3005,6 +3009,9 @@ static int qcom_nandc_probe(struct platform_device *pdev)
 	clk_disable_unprepare(nandc->core_clk);
 err_core_clk:
 	qcom_nandc_unalloc(nandc);
+err_nandc_alloc:
+	dma_unmap_resource(dev, res->start, resource_size(res),
+			   DMA_BIDIRECTIONAL, 0);
 
 	return ret;
 }
@@ -3012,16 +3019,21 @@ static int qcom_nandc_probe(struct platform_device *pdev)
 static int qcom_nandc_remove(struct platform_device *pdev)
 {
 	struct qcom_nand_controller *nandc = platform_get_drvdata(pdev);
+	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	struct qcom_nand_host *host;
 
 	list_for_each_entry(host, &nandc->host_list, node)
 		nand_release(nand_to_mtd(&host->chip));
 
+
 	qcom_nandc_unalloc(nandc);
 
 	clk_disable_unprepare(nandc->aon_clk);
 	clk_disable_unprepare(nandc->core_clk);
 
+	dma_unmap_resource(&pdev->dev, nandc->base_dma, resource_size(res),
+			   DMA_BIDIRECTIONAL, 0);
+
 	return 0;
 }
 
-- 
2.9.0


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

* Re: [PATCH v2] nand: ranw: qcom_nand: stop using phys_to_dma()
  2018-07-17 20:27 [PATCH v2] nand: ranw: qcom_nand: stop using phys_to_dma() Arnd Bergmann
@ 2018-07-17 20:33 ` Boris Brezillon
  2018-07-18  7:47   ` Miquel Raynal
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2018-07-17 20:33 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Miquel Raynal, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Abhishek Sahu, Archit Taneja,
	Masahiro Yamada, linux-mtd, linux-kernel

On Tue, 17 Jul 2018 22:27:42 +0200
Arnd Bergmann <arnd@arndb.de> wrote:

> Compile-testing this driver on x86 caused a link error:
> 
> ERROR: "__phys_to_dma" [drivers/mtd/nand/raw/qcom_nandc.ko] undefined!
> 
> The problem here is that the driver attempts to convert the physical
> address into the DMA controller as a dma_addr_t and calls phys_to_dma()
> to do the conversion.
> 
> The correct way to do the conversion is using the dma mapping interfaces.
> 
> Fixes: c76b78d8ec05 ("mtd: nand: Qualcomm NAND controller driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>

Miquel, can you fix the subject prefix when applying?

Thanks,

Boris

> ---
>  drivers/mtd/nand/raw/qcom_nandc.c | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index 994f980c6d86..645630953f38 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -2957,14 +2957,6 @@ static int qcom_nandc_probe(struct platform_device *pdev)
>  
>  	nandc->props = dev_data;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	nandc->base = devm_ioremap_resource(dev, res);
> -	if (IS_ERR(nandc->base))
> -		return PTR_ERR(nandc->base);
> -
> -	nandc->base_phys = res->start;
> -	nandc->base_dma = phys_to_dma(dev, (phys_addr_t)res->start);
> -
>  	nandc->core_clk = devm_clk_get(dev, "core");
>  	if (IS_ERR(nandc->core_clk))
>  		return PTR_ERR(nandc->core_clk);
> @@ -2977,9 +2969,21 @@ static int qcom_nandc_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	nandc->base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(nandc->base))
> +		return PTR_ERR(nandc->base);
> +
> +	nandc->base_phys = res->start;
> +	nandc->base_dma = dma_map_resource(dev, res->start,
> +					   resource_size(res),
> +					   DMA_BIDIRECTIONAL, 0);
> +	if (!nandc->base_dma)
> +		return -ENXIO;
> +
>  	ret = qcom_nandc_alloc(nandc);
>  	if (ret)
> -		goto err_core_clk;
> +		goto err_nandc_alloc;
>  
>  	ret = clk_prepare_enable(nandc->core_clk);
>  	if (ret)
> @@ -3005,6 +3009,9 @@ static int qcom_nandc_probe(struct platform_device *pdev)
>  	clk_disable_unprepare(nandc->core_clk);
>  err_core_clk:
>  	qcom_nandc_unalloc(nandc);
> +err_nandc_alloc:
> +	dma_unmap_resource(dev, res->start, resource_size(res),
> +			   DMA_BIDIRECTIONAL, 0);
>  
>  	return ret;
>  }
> @@ -3012,16 +3019,21 @@ static int qcom_nandc_probe(struct platform_device *pdev)
>  static int qcom_nandc_remove(struct platform_device *pdev)
>  {
>  	struct qcom_nand_controller *nandc = platform_get_drvdata(pdev);
> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	struct qcom_nand_host *host;
>  
>  	list_for_each_entry(host, &nandc->host_list, node)
>  		nand_release(nand_to_mtd(&host->chip));
>  
> +
>  	qcom_nandc_unalloc(nandc);
>  
>  	clk_disable_unprepare(nandc->aon_clk);
>  	clk_disable_unprepare(nandc->core_clk);
>  
> +	dma_unmap_resource(&pdev->dev, nandc->base_dma, resource_size(res),
> +			   DMA_BIDIRECTIONAL, 0);
> +
>  	return 0;
>  }
>  


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

* Re: [PATCH v2] nand: ranw: qcom_nand: stop using phys_to_dma()
  2018-07-17 20:33 ` Boris Brezillon
@ 2018-07-18  7:47   ` Miquel Raynal
  0 siblings, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2018-07-18  7:47 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Arnd Bergmann, David Woodhouse, Brian Norris, Marek Vasut,
	Richard Weinberger, Abhishek Sahu, Archit Taneja,
	Masahiro Yamada, linux-mtd, linux-kernel

Hi Boris,

Boris Brezillon <boris.brezillon@bootlin.com> wrote on Tue, 17 Jul 2018
22:33:59 +0200:

> On Tue, 17 Jul 2018 22:27:42 +0200
> Arnd Bergmann <arnd@arndb.de> wrote:
> 
> > Compile-testing this driver on x86 caused a link error:
> > 
> > ERROR: "__phys_to_dma" [drivers/mtd/nand/raw/qcom_nandc.ko] undefined!
> > 
> > The problem here is that the driver attempts to convert the physical
> > address into the DMA controller as a dma_addr_t and calls phys_to_dma()
> > to do the conversion.
> > 
> > The correct way to do the conversion is using the dma mapping interfaces.
> > 
> > Fixes: c76b78d8ec05 ("mtd: nand: Qualcomm NAND controller driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>  
> 
> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
> 
> Miquel, can you fix the subject prefix when applying?

Applied to nand/next with the subject prefix being:
"mtd: rawnand: qcom:"

Thanks
Miquèl

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

end of thread, other threads:[~2018-07-18  7:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 20:27 [PATCH v2] nand: ranw: qcom_nand: stop using phys_to_dma() Arnd Bergmann
2018-07-17 20:33 ` Boris Brezillon
2018-07-18  7:47   ` Miquel Raynal

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).