stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods
@ 2022-05-20  8:44 Peng Wu
  2022-05-20 16:53 ` Christophe JAILLET
  2022-06-09 12:44 ` Miquel Raynal
  0 siblings, 2 replies; 4+ messages in thread
From: Peng Wu @ 2022-05-20  8:44 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, christophe.jaillet
  Cc: linux-mtd, linux-kernel, stable, liwei391, wupeng58

Driver should call pci_disable_device() if it returns from
cafe_nand_probe() with error.

Meanwhile, the driver calls pci_enable_device() in
cafe_nand_probe(), but never calls pci_disable_device()
during removal.

Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
v2:
- fix the subject prefix with "mtd: ranwnand: cafe:"
---
 drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
index 9dbf031716a6..af119e376352 100644
--- a/drivers/mtd/nand/raw/cafe_nand.c
+++ b/drivers/mtd/nand/raw/cafe_nand.c
@@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 
 	cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
-	if (!cafe)
-		return  -ENOMEM;
+	if (!cafe) {
+		err = -ENOMEM;
+		goto out_disable_device;
+	}
 
 	mtd = nand_to_mtd(&cafe->nand);
 	mtd->dev.parent = &pdev->dev;
@@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	pci_iounmap(pdev, cafe->mmio);
  out_free_mtd:
 	kfree(cafe);
+ out_disable_device:
+	pci_disable_device(pdev);
  out:
 	return err;
 }
@@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
 	pci_iounmap(pdev, cafe->mmio);
 	dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
 	kfree(cafe);
+	pci_disable_device(pdev);
 }
 
 static const struct pci_device_id cafe_nand_tbl[] = {
-- 
2.17.1


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

* Re: [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods
  2022-05-20  8:44 [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods Peng Wu
@ 2022-05-20 16:53 ` Christophe JAILLET
  2022-05-20 17:09   ` Marion & Christophe JAILLET
  2022-06-09 12:44 ` Miquel Raynal
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2022-05-20 16:53 UTC (permalink / raw)
  To: Peng Wu, miquel.raynal, richard, vigneshr
  Cc: linux-mtd, linux-kernel, stable, liwei391, Kernel Janitors

Le 20/05/2022 à 10:44, Peng Wu a écrit :
> Driver should call pci_disable_device() if it returns from
> cafe_nand_probe() with error.
> 
> Meanwhile, the driver calls pci_enable_device() in
> cafe_nand_probe(), but never calls pci_disable_device()
> during removal.
> 
> Signed-off-by: Peng Wu <wupeng58@huawei.com>
> ---
> v2:
> - fix the subject prefix with "mtd: ranwnand: cafe:"
> ---
>   drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
> index 9dbf031716a6..af119e376352 100644
> --- a/drivers/mtd/nand/raw/cafe_nand.c
> +++ b/drivers/mtd/nand/raw/cafe_nand.c
> @@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
>   	pci_set_master(pdev);
>   
>   	cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
> -	if (!cafe)
> -		return  -ENOMEM;
> +	if (!cafe) {
> +		err = -ENOMEM;
> +		goto out_disable_device;
> +	}
>   
>   	mtd = nand_to_mtd(&cafe->nand);
>   	mtd->dev.parent = &pdev->dev;
> @@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
>   	pci_iounmap(pdev, cafe->mmio);
>    out_free_mtd:
>   	kfree(cafe);
> + out_disable_device:
> +	pci_disable_device(pdev);
>    out:
>   	return err;
>   }
> @@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
>   	pci_iounmap(pdev, cafe->mmio);
>   	dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);

Hi,

Not related to this patch , but I wonder if this dma_free_coherent() is 
needed.
It is already part of cafe_nand_detach_chip() which is a .detach_chip() 
function.

Is this .detach_chip() function already called (by nand_cleanup()) 
somewhere in the removal process?

CJ


>   	kfree(cafe);
> +	pci_disable_device(pdev);
>   }
>   
>   static const struct pci_device_id cafe_nand_tbl[] = {


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

* Re: [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods
  2022-05-20 16:53 ` Christophe JAILLET
@ 2022-05-20 17:09   ` Marion & Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Marion & Christophe JAILLET @ 2022-05-20 17:09 UTC (permalink / raw)
  To: Peng Wu, miquel.raynal, richard, vigneshr
  Cc: linux-mtd, linux-kernel, stable, liwei391, Kernel Janitors



Le 20/05/2022 à 18:53, Christophe JAILLET a écrit :
> Le 20/05/2022 à 10:44, Peng Wu a écrit :
>> Driver should call pci_disable_device() if it returns from
>> cafe_nand_probe() with error.
>>
>> Meanwhile, the driver calls pci_enable_device() in
>> cafe_nand_probe(), but never calls pci_disable_device()
>> during removal.
>>
>> Signed-off-by: Peng Wu <wupeng58@huawei.com>
>> ---
>> v2:
>> - fix the subject prefix with "mtd: ranwnand: cafe:"
>> ---
>>   drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/cafe_nand.c 
>> b/drivers/mtd/nand/raw/cafe_nand.c
>> index 9dbf031716a6..af119e376352 100644
>> --- a/drivers/mtd/nand/raw/cafe_nand.c
>> +++ b/drivers/mtd/nand/raw/cafe_nand.c
>> @@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev,
>>       pci_set_master(pdev);
>>       cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
>> -    if (!cafe)
>> -        return  -ENOMEM;
>> +    if (!cafe) {
>> +        err = -ENOMEM;
>> +        goto out_disable_device;
>> +    }
>>       mtd = nand_to_mtd(&cafe->nand);
>>       mtd->dev.parent = &pdev->dev;
>> @@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
>>       pci_iounmap(pdev, cafe->mmio);
>>    out_free_mtd:
>>       kfree(cafe);
>> + out_disable_device:
>> +    pci_disable_device(pdev);
>>    out:
>>       return err;
>>   }
>> @@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
>>       pci_iounmap(pdev, cafe->mmio);
>>       dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, 
>> cafe->dmaaddr);
> 
> Hi,
> 
> Not related to this patch , but I wonder if this dma_free_coherent() is 
> needed.
> It is already part of cafe_nand_detach_chip() which is a .detach_chip() 
> function.
> 
> Is this .detach_chip() function already called (by nand_cleanup()) 
> somewhere in the removal process?
> 

In fact the "somewhere" is just 3 lines above the dma_free_coherent() 
call. So I definitively think that this line should be axed.

CJ


> CJ
> 
> 
>>       kfree(cafe);
>> +    pci_disable_device(pdev);
>>   }
>>   static const struct pci_device_id cafe_nand_tbl[] = {
> 
> 

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

* Re: [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods
  2022-05-20  8:44 [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods Peng Wu
  2022-05-20 16:53 ` Christophe JAILLET
@ 2022-06-09 12:44 ` Miquel Raynal
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2022-06-09 12:44 UTC (permalink / raw)
  To: Peng Wu, miquel.raynal, richard, vigneshr, christophe.jaillet
  Cc: linux-mtd, linux-kernel, stable, liwei391

On Fri, 2022-05-20 at 08:44:25 UTC, Peng Wu wrote:
> Driver should call pci_disable_device() if it returns from
> cafe_nand_probe() with error.
> 
> Meanwhile, the driver calls pci_enable_device() in
> cafe_nand_probe(), but never calls pci_disable_device()
> during removal.
> 
> Signed-off-by: Peng Wu <wupeng58@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

end of thread, other threads:[~2022-06-09 12:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20  8:44 [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods Peng Wu
2022-05-20 16:53 ` Christophe JAILLET
2022-05-20 17:09   ` Marion & Christophe JAILLET
2022-06-09 12:44 ` 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).