linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size
@ 2020-04-16  8:33 Ashish Kumar
  2020-04-16  9:36 ` Schrempf Frieder
  0 siblings, 1 reply; 3+ messages in thread
From: Ashish Kumar @ 2020-04-16  8:33 UTC (permalink / raw)
  To: broonie, boris.brezillon, frieder.schrempf
  Cc: linux-spi, linux-kernel, Ashish Kumar, Kuldeep Singh, Ashish Kumar

Reduce devm_ioremap size to (4 * AHB_BUFER_SIZE) rather than mapping
complete QSPI-Memmory as driver is now independent of flash size.
Flash of any size can be accessed.

Issue was reported on platform where devm_ioremap failure is observed
with size > 256M.
Error log on LS1021ATWR :
 fsl-quadspi 1550000.spi: ioremap failed for resource [mem 0x40000000-0x7fffffff]
 fsl-quadspi 1550000.spi: Freescale QuadSPI probe failed
 fsl-quadspi: probe of 1550000.spi failed with error -12

This change was also suggested previously:
https://patchwork.kernel.org/patch/10508753/#22166385

Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
Signed-off-by: Ashish Kumar <Ashish.kumar@nxp.com>
---
 drivers/spi/spi-fsl-qspi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 63c9f7e..a41ce81 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -859,14 +859,15 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 					"QuadSPI-memory");
-	q->ahb_addr = devm_ioremap_resource(dev, res);
+	q->memmap_phy = res->start;
+	/* Since there are 4 CS max MAP required is 4 time ahb_buf_size */
+	q->ahb_addr = devm_ioremap(dev, q->memmap_phy,
+				   (q->devtype_data->ahb_buf_size * 4));
 	if (IS_ERR(q->ahb_addr)) {
 		ret = PTR_ERR(q->ahb_addr);
 		goto err_put_ctrl;
 	}
 
-	q->memmap_phy = res->start;
-
 	/* find the clocks */
 	q->clk_en = devm_clk_get(dev, "qspi_en");
 	if (IS_ERR(q->clk_en)) {
@@ -939,6 +940,9 @@ static int fsl_qspi_remove(struct platform_device *pdev)
 
 	mutex_destroy(&q->lock);
 
+	if (q->ahb_addr)
+		devm_iounmap(q->dev, q->ahb_addr);
+
 	return 0;
 }
 
-- 
2.7.4


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

* Re: [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size
  2020-04-16  8:33 [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size Ashish Kumar
@ 2020-04-16  9:36 ` Schrempf Frieder
  2020-04-16 10:39   ` [EXT] " Ashish Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Schrempf Frieder @ 2020-04-16  9:36 UTC (permalink / raw)
  To: Ashish Kumar, broonie, boris.brezillon
  Cc: linux-spi, linux-kernel, Kuldeep Singh

Hi Ashish,

On 16.04.20 10:33, Ashish Kumar wrote:
> Reduce devm_ioremap size to (4 * AHB_BUFER_SIZE) rather than mapping
> complete QSPI-Memmory as driver is now independent of flash size.
> Flash of any size can be accessed.
> 
> Issue was reported on platform where devm_ioremap failure is observed
> with size > 256M.
> Error log on LS1021ATWR :
>   fsl-quadspi 1550000.spi: ioremap failed for resource [mem 0x40000000-0x7fffffff]
>   fsl-quadspi 1550000.spi: Freescale QuadSPI probe failed
>   fsl-quadspi: probe of 1550000.spi failed with error -12
> 
> This change was also suggested previously:
> https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F10508753%2F%2322166385&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7Cba26817e759b460819a708d7e1e0d083%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637226228543132272&amp;sdata=z7wekDTg%2FN7CZUy7ikM%2BVHOKT95YbDJ0cr2JE62Wgzw%3D&amp;reserved=0

So if you want you could add a "Suggested-by" tag referring to Boris.

> 
> Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
> Signed-off-by: Ashish Kumar <Ashish.kumar@nxp.com>
> ---
>   drivers/spi/spi-fsl-qspi.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
> index 63c9f7e..a41ce81 100644
> --- a/drivers/spi/spi-fsl-qspi.c
> +++ b/drivers/spi/spi-fsl-qspi.c
> @@ -859,14 +859,15 @@ static int fsl_qspi_probe(struct platform_device *pdev)
>   
>   	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>   					"QuadSPI-memory");
> -	q->ahb_addr = devm_ioremap_resource(dev, res);
> +	q->memmap_phy = res->start;
> +	/* Since there are 4 CS max MAP required is 4 time ahb_buf_size */

/* Since there are 4 cs, map size required is 4 times ahb_buf_size */

> +	q->ahb_addr = devm_ioremap(dev, q->memmap_phy,
> +				   (q->devtype_data->ahb_buf_size * 4));
>   	if (IS_ERR(q->ahb_addr)) {
>   		ret = PTR_ERR(q->ahb_addr);
>   		goto err_put_ctrl;
>   	}
>   
> -	q->memmap_phy = res->start;
> -
>   	/* find the clocks */
>   	q->clk_en = devm_clk_get(dev, "qspi_en");
>   	if (IS_ERR(q->clk_en)) {
> @@ -939,6 +940,9 @@ static int fsl_qspi_remove(struct platform_device *pdev)
>   
>   	mutex_destroy(&q->lock);
>   
> +	if (q->ahb_addr)
> +		devm_iounmap(q->dev, q->ahb_addr);

You don't need to unmap explicitly. Using devm_*(), lifetime of the 
resource is already tied to the device.

Thanks,
Frieder

> +
>   	return 0;
>   }
>   
> 

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

* RE: [EXT] Re: [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size
  2020-04-16  9:36 ` Schrempf Frieder
@ 2020-04-16 10:39   ` Ashish Kumar
  0 siblings, 0 replies; 3+ messages in thread
From: Ashish Kumar @ 2020-04-16 10:39 UTC (permalink / raw)
  To: Schrempf Frieder, broonie, boris.brezillon
  Cc: linux-spi, linux-kernel, Kuldeep Singh

Hi Frieder,

> -----Original Message-----
> From: Schrempf Frieder <frieder.schrempf@kontron.de>
> Sent: Thursday, April 16, 2020 3:06 PM
> To: Ashish Kumar <ashish.kumar@nxp.com>; broonie@kernel.org;
> boris.brezillon@collabora.com
> Cc: linux-spi@vger.kernel.org; linux-kernel@vger.kernel.org; Kuldeep Singh
> <kuldeep.singh@nxp.com>
> Subject: [EXT] Re: [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4
> times AHB buffer size
> 
> Caution: EXT Email
> 
> Hi Ashish,
> 
> On 16.04.20 10:33, Ashish Kumar wrote:
> > Reduce devm_ioremap size to (4 * AHB_BUFER_SIZE) rather than mapping
> > complete QSPI-Memmory as driver is now independent of flash size.
> > Flash of any size can be accessed.
> >
> > Issue was reported on platform where devm_ioremap failure is observed
> > with size > 256M.
> > Error log on LS1021ATWR :
> >   fsl-quadspi 1550000.spi: ioremap failed for resource [mem 0x40000000-
> 0x7fffffff]
> >   fsl-quadspi 1550000.spi: Freescale QuadSPI probe failed
> >   fsl-quadspi: probe of 1550000.spi failed with error -12
> >
> > This change was also suggested previously:
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc
> >
> hwork.kernel.org%2Fpatch%2F10508753%2F%2322166385&amp;data=02%7C
> 01%7Ca
> >
> shish.kumar%40nxp.com%7C7e4a6913030f4f5a4a0408d7e1e9a342%7C686ea
> 1d3bc2
> >
> b4c6fa92cd99c5c301635%7C0%7C0%7C637226265903575933&amp;sdata=JDb
> k0rA2L
> > 5EwAah8S3srd5u26bOxaD1MVR3voUKFxyI%3D&amp;reserved=0
> 
> So if you want you could add a "Suggested-by" tag referring to Boris.
Sure, I will add in next version.

> 
> >
> > Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
> > Signed-off-by: Ashish Kumar <Ashish.kumar@nxp.com>
> > ---
> >   drivers/spi/spi-fsl-qspi.c | 10 +++++++---
> >   1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
> > index 63c9f7e..a41ce81 100644
> > --- a/drivers/spi/spi-fsl-qspi.c
> > +++ b/drivers/spi/spi-fsl-qspi.c
> > @@ -859,14 +859,15 @@ static int fsl_qspi_probe(struct platform_device
> > *pdev)
> >
> >       res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> >                                       "QuadSPI-memory");
> > -     q->ahb_addr = devm_ioremap_resource(dev, res);
> > +     q->memmap_phy = res->start;
> > +     /* Since there are 4 CS max MAP required is 4 time ahb_buf_size
> > + */
> 
> /* Since there are 4 cs, map size required is 4 times ahb_buf_size */
> 
> > +     q->ahb_addr = devm_ioremap(dev, q->memmap_phy,
> > +                                (q->devtype_data->ahb_buf_size * 4));
> >       if (IS_ERR(q->ahb_addr)) {
> >               ret = PTR_ERR(q->ahb_addr);
> >               goto err_put_ctrl;
> >       }
> >
> > -     q->memmap_phy = res->start;
> > -
> >       /* find the clocks */
> >       q->clk_en = devm_clk_get(dev, "qspi_en");
> >       if (IS_ERR(q->clk_en)) {
> > @@ -939,6 +940,9 @@ static int fsl_qspi_remove(struct platform_device
> > *pdev)
> >
> >       mutex_destroy(&q->lock);
> >
> > +     if (q->ahb_addr)
> > +             devm_iounmap(q->dev, q->ahb_addr);
> 
> You don't need to unmap explicitly. Using devm_*(), lifetime of the resource
> is already tied to the device.
Thanks. I will remove this.

Regards
Ashish 
> 
> Thanks,
> Frieder
> 
> > +
> >       return 0;
> >   }
> >
> >

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

end of thread, other threads:[~2020-04-16 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16  8:33 [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size Ashish Kumar
2020-04-16  9:36 ` Schrempf Frieder
2020-04-16 10:39   ` [EXT] " Ashish Kumar

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