linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: Use managed device resources
@ 2022-04-11 11:21 Zheyu Ma
  2022-04-11 12:47 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Zheyu Ma @ 2022-04-11 11:21 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr; +Cc: linux-mtd, linux-kernel, Zheyu Ma

All of the resources used by this driver has managed interfaces, so use
them. Otherwise we will get the following splat:

[    4.472703] denali-nand-pci 0000:00:05.0: timeout while waiting for irq 0x1000
[    4.474071] denali-nand-pci: probe of 0000:00:05.0 failed with error -5
[    4.473538] nand: No NAND device found
[    4.474068] BUG: unable to handle page fault for address: ffffc90005000410
[    4.475169] #PF: supervisor write access in kernel mode
[    4.475579] #PF: error_code(0x0002) - not-present page
[    4.478362] RIP: 0010:iowrite32+0x9/0x50
[    4.486068] Call Trace:
[    4.486269]  <IRQ>
[    4.486443]  denali_isr+0x15b/0x300 [denali]
[    4.486788]  ? denali_direct_write+0x50/0x50 [denali]
[    4.487189]  __handle_irq_event_percpu+0x161/0x3b0
[    4.487571]  handle_irq_event+0x7d/0x1b0
[    4.487884]  handle_fasteoi_irq+0x2b0/0x770
[    4.488219]  __common_interrupt+0xc8/0x1b0
[    4.488549]  common_interrupt+0x9a/0xc0

Fixes: 93db446a424c ("mtd: nand: move raw NAND related code to the raw/ subdir")

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/mtd/nand/raw/denali_pci.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/raw/denali_pci.c b/drivers/mtd/nand/raw/denali_pci.c
index 20c085a30adc..de7e722d3826 100644
--- a/drivers/mtd/nand/raw/denali_pci.c
+++ b/drivers/mtd/nand/raw/denali_pci.c
@@ -74,22 +74,21 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		return ret;
 	}
 
-	denali->reg = ioremap(csr_base, csr_len);
+	denali->reg = devm_ioremap(denali->dev, csr_base, csr_len);
 	if (!denali->reg) {
 		dev_err(&dev->dev, "Spectra: Unable to remap memory region\n");
 		return -ENOMEM;
 	}
 
-	denali->host = ioremap(mem_base, mem_len);
+	denali->host = devm_ioremap(denali->dev, mem_base, mem_len);
 	if (!denali->host) {
 		dev_err(&dev->dev, "Spectra: ioremap failed!");
-		ret = -ENOMEM;
-		goto out_unmap_reg;
+		return -ENOMEM;
 	}
 
 	ret = denali_init(denali);
 	if (ret)
-		goto out_unmap_host;
+		return ret;
 
 	nsels = denali->nbanks;
 
@@ -117,10 +116,6 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 out_remove_denali:
 	denali_remove(denali);
-out_unmap_host:
-	iounmap(denali->host);
-out_unmap_reg:
-	iounmap(denali->reg);
 	return ret;
 }
 
@@ -129,8 +124,6 @@ static void denali_pci_remove(struct pci_dev *dev)
 	struct denali_controller *denali = pci_get_drvdata(dev);
 
 	denali_remove(denali);
-	iounmap(denali->reg);
-	iounmap(denali->host);
 }
 
 static struct pci_driver denali_pci_driver = {
-- 
2.25.1


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

* Re: [PATCH] mtd: rawnand: Use managed device resources
  2022-04-11 11:21 [PATCH] mtd: rawnand: Use managed device resources Zheyu Ma
@ 2022-04-11 12:47 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-04-11 12:47 UTC (permalink / raw)
  To: Zheyu Ma; +Cc: richard, vigneshr, linux-mtd, linux-kernel

Hello,

zheyuma97@gmail.com wrote on Mon, 11 Apr 2022 19:21:24 +0800:

Prefix should be "mtd: rawnand: denali:"

> All of the resources used by this driver has managed interfaces, so use
> them. Otherwise we will get the following splat:
> 
> [    4.472703] denali-nand-pci 0000:00:05.0: timeout while waiting for irq 0x1000
> [    4.474071] denali-nand-pci: probe of 0000:00:05.0 failed with error -5
> [    4.473538] nand: No NAND device found
> [    4.474068] BUG: unable to handle page fault for address: ffffc90005000410
> [    4.475169] #PF: supervisor write access in kernel mode
> [    4.475579] #PF: error_code(0x0002) - not-present page
> [    4.478362] RIP: 0010:iowrite32+0x9/0x50
> [    4.486068] Call Trace:
> [    4.486269]  <IRQ>
> [    4.486443]  denali_isr+0x15b/0x300 [denali]
> [    4.486788]  ? denali_direct_write+0x50/0x50 [denali]
> [    4.487189]  __handle_irq_event_percpu+0x161/0x3b0
> [    4.487571]  handle_irq_event+0x7d/0x1b0
> [    4.487884]  handle_fasteoi_irq+0x2b0/0x770
> [    4.488219]  __common_interrupt+0xc8/0x1b0
> [    4.488549]  common_interrupt+0x9a/0xc0
> 
> Fixes: 93db446a424c ("mtd: nand: move raw NAND related code to the raw/ subdir")
> 

Extra space

> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>

Otherwise LGTM.

> ---
>  drivers/mtd/nand/raw/denali_pci.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/denali_pci.c b/drivers/mtd/nand/raw/denali_pci.c
> index 20c085a30adc..de7e722d3826 100644
> --- a/drivers/mtd/nand/raw/denali_pci.c
> +++ b/drivers/mtd/nand/raw/denali_pci.c
> @@ -74,22 +74,21 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  		return ret;
>  	}
>  
> -	denali->reg = ioremap(csr_base, csr_len);
> +	denali->reg = devm_ioremap(denali->dev, csr_base, csr_len);
>  	if (!denali->reg) {
>  		dev_err(&dev->dev, "Spectra: Unable to remap memory region\n");
>  		return -ENOMEM;
>  	}
>  
> -	denali->host = ioremap(mem_base, mem_len);
> +	denali->host = devm_ioremap(denali->dev, mem_base, mem_len);
>  	if (!denali->host) {
>  		dev_err(&dev->dev, "Spectra: ioremap failed!");
> -		ret = -ENOMEM;
> -		goto out_unmap_reg;
> +		return -ENOMEM;
>  	}
>  
>  	ret = denali_init(denali);
>  	if (ret)
> -		goto out_unmap_host;
> +		return ret;
>  
>  	nsels = denali->nbanks;
>  
> @@ -117,10 +116,6 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  
>  out_remove_denali:
>  	denali_remove(denali);
> -out_unmap_host:
> -	iounmap(denali->host);
> -out_unmap_reg:
> -	iounmap(denali->reg);
>  	return ret;
>  }
>  
> @@ -129,8 +124,6 @@ static void denali_pci_remove(struct pci_dev *dev)
>  	struct denali_controller *denali = pci_get_drvdata(dev);
>  
>  	denali_remove(denali);
> -	iounmap(denali->reg);
> -	iounmap(denali->host);
>  }
>  
>  static struct pci_driver denali_pci_driver = {


Thanks,
Miquèl

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

end of thread, other threads:[~2022-04-11 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 11:21 [PATCH] mtd: rawnand: Use managed device resources Zheyu Ma
2022-04-11 12: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).