2023-09-12 12:07:20

by Bibek Kumar Patro

[permalink] [raw]
Subject: [PATCH v3] mtd: rawnand: qcom: unmap dma address during probe failure

Fix address argument of nand controller currently being
passed to dma_unmap_resource() in probe error path.
This address argument should be the dma address returned by
dma_map_resource() instead of the physical address of nand controller.

Fixes: 7330fc505af4 ("mtd: rawnand: qcom: stop using phys_to_dma()")
Signed-off-by: Bibek Kumar Patro <[email protected]>
---
v3: Incorporated comments from Miquel
- Modified the commit message and title as per suggestions.

v2: Incorporated comments from Pavan/Mani.
https://lore.kernel.org/all/[email protected]/

v1: https://lore.kernel.org/all/[email protected]/

drivers/mtd/nand/raw/qcom_nandc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 64499c1b3603..b079605c84d3 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -3444,7 +3444,7 @@ static int qcom_nandc_probe(struct platform_device *pdev)
err_aon_clk:
clk_disable_unprepare(nandc->core_clk);
err_core_clk:
- dma_unmap_resource(dev, res->start, resource_size(res),
+ dma_unmap_resource(dev, nandc->base_dma, resource_size(res),
DMA_BIDIRECTIONAL, 0);
return ret;
}
--
2.17.1


2023-09-12 20:52:50

by Bibek Kumar Patro

[permalink] [raw]
Subject: Re: [PATCH v3] mtd: rawnand: qcom: unmap dma address during probe failure

Hi Miquel,

On 9/12/2023 3:56 PM, Miquel Raynal wrote:
> Hi Bibek,
>
> [email protected] wrote on Tue, 12 Sep 2023 15:48:14 +0530:
>
> Title: s/during/upon/?
>
>> Fix address argument of nand controller currently being
>> passed to dma_unmap_resource() in probe error path.
>
> What about:
>

Sure, this looks more compact and simpler.
will use this for the title.
v

> Unmap the right resource upon probe failure: we currently
> provide the physical address of the DMA region rather than the
> output of dma_map_resource() which is obviously wrong.
>
^
Will keep the rest in commit description. Thanks for this suggestion

>> This address argument should be the dma address returned by
>> dma_map_resource() instead of the physical address of nand controller.
>>
>>
>> Fixes: 7330fc505af4 ("mtd: rawnand: qcom: stop using phys_to_dma()")
>> Signed-off-by: Bibek Kumar Patro <[email protected]>
>> ---
>> v3: Incorporated comments from Miquel
>> - Modified the commit message and title as per suggestions.
>>
>> v2: Incorporated comments from Pavan/Mani.
>> https://lore.kernel.org/all/[email protected]/
>>
>> v1: https://lore.kernel.org/all/[email protected]/
>>
>> drivers/mtd/nand/raw/qcom_nandc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
>> index 64499c1b3603..b079605c84d3 100644
>> --- a/drivers/mtd/nand/raw/qcom_nandc.c
>> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
>> @@ -3444,7 +3444,7 @@ static int qcom_nandc_probe(struct platform_device *pdev)
>> err_aon_clk:
>> clk_disable_unprepare(nandc->core_clk);
>> err_core_clk:
>> - dma_unmap_resource(dev, res->start, resource_size(res),
>> + dma_unmap_resource(dev, nandc->base_dma, resource_size(res),
>> DMA_BIDIRECTIONAL, 0);
>> return ret;
>> }
>> --
>> 2.17.1
>>
>
>
> Thanks,
> Miquèl

Thanks & regards,
Bibek

2023-09-13 02:44:48

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH v3] mtd: rawnand: qcom: unmap dma address during probe failure

Hi Bibek,

[email protected] wrote on Tue, 12 Sep 2023 15:48:14 +0530:

Title: s/during/upon/?

> Fix address argument of nand controller currently being
> passed to dma_unmap_resource() in probe error path.

What about:

Unmap the right resource upon probe failure: we currently
provide the physical address of the DMA region rather than the
output of dma_map_resource() which is obviously wrong.

> This address argument should be the dma address returned by
> dma_map_resource() instead of the physical address of nand controller.
>
>
> Fixes: 7330fc505af4 ("mtd: rawnand: qcom: stop using phys_to_dma()")
> Signed-off-by: Bibek Kumar Patro <[email protected]>
> ---
> v3: Incorporated comments from Miquel
> - Modified the commit message and title as per suggestions.
>
> v2: Incorporated comments from Pavan/Mani.
> https://lore.kernel.org/all/[email protected]/
>
> v1: https://lore.kernel.org/all/[email protected]/
>
> drivers/mtd/nand/raw/qcom_nandc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index 64499c1b3603..b079605c84d3 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -3444,7 +3444,7 @@ static int qcom_nandc_probe(struct platform_device *pdev)
> err_aon_clk:
> clk_disable_unprepare(nandc->core_clk);
> err_core_clk:
> - dma_unmap_resource(dev, res->start, resource_size(res),
> + dma_unmap_resource(dev, nandc->base_dma, resource_size(res),
> DMA_BIDIRECTIONAL, 0);
> return ret;
> }
> --
> 2.17.1
>


Thanks,
Miquèl