* [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout
@ 2015-03-03 9:55 ` Maxime Ripard
0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2015-03-03 9:55 UTC (permalink / raw)
To: Ezequiel Garcia, Brian Norris
Cc: Boris Brezillon, linux-mtd, Maxime Ripard, linux-arm-kernel
Now that the driver handles the FIFO draining in a threaded interrupt, we can
base our timeout on jiffies and sleeping, instead of using mdelay.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/mtd/nand/pxa3xx_nand.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 3f09f2e9aeb4..1eb957c347cd 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -496,16 +496,15 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
while (len > 8) {
__raw_readsl(info->mmio_base + NDDB, data, 8);
- for (timeout = 0;
- !(nand_readl(info, NDSR) & NDSR_RDDREQ);
- timeout++) {
- if (timeout >= 5) {
+ timeout = jiffies + msecs_to_jiffies(5);
+ while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
+ if (!time_before(jiffies, timeout)) {
dev_err(&info->pdev->dev,
"Timeout on RDDREQ while draining the FIFO\n");
return;
}
- mdelay(1);
+ msleep(1);
}
data += 32;
--
2.3.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout
@ 2015-03-03 9:55 ` Maxime Ripard
0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2015-03-03 9:55 UTC (permalink / raw)
To: linux-arm-kernel
Now that the driver handles the FIFO draining in a threaded interrupt, we can
base our timeout on jiffies and sleeping, instead of using mdelay.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/mtd/nand/pxa3xx_nand.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 3f09f2e9aeb4..1eb957c347cd 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -496,16 +496,15 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
while (len > 8) {
__raw_readsl(info->mmio_base + NDDB, data, 8);
- for (timeout = 0;
- !(nand_readl(info, NDSR) & NDSR_RDDREQ);
- timeout++) {
- if (timeout >= 5) {
+ timeout = jiffies + msecs_to_jiffies(5);
+ while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
+ if (!time_before(jiffies, timeout)) {
dev_err(&info->pdev->dev,
"Timeout on RDDREQ while draining the FIFO\n");
return;
}
- mdelay(1);
+ msleep(1);
}
data += 32;
--
2.3.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout
2015-03-03 9:55 ` Maxime Ripard
@ 2015-03-03 10:18 ` Baruch Siach
-1 siblings, 0 replies; 6+ messages in thread
From: Baruch Siach @ 2015-03-03 10:18 UTC (permalink / raw)
To: Maxime Ripard
Cc: Boris Brezillon, Brian Norris, linux-mtd, linux-arm-kernel,
Ezequiel Garcia
Hi Maxime,
On Tue, Mar 03, 2015 at 10:55:29AM +0100, Maxime Ripard wrote:
> Now that the driver handles the FIFO draining in a threaded interrupt, we can
> base our timeout on jiffies and sleeping, instead of using mdelay.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/mtd/nand/pxa3xx_nand.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> index 3f09f2e9aeb4..1eb957c347cd 100644
> --- a/drivers/mtd/nand/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/pxa3xx_nand.c
> @@ -496,16 +496,15 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
> while (len > 8) {
> __raw_readsl(info->mmio_base + NDDB, data, 8);
>
> - for (timeout = 0;
> - !(nand_readl(info, NDSR) & NDSR_RDDREQ);
> - timeout++) {
> - if (timeout >= 5) {
> + timeout = jiffies + msecs_to_jiffies(5);
> + while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
> + if (!time_before(jiffies, timeout)) {
> dev_err(&info->pdev->dev,
> "Timeout on RDDREQ while draining the FIFO\n");
> return;
> }
>
> - mdelay(1);
> + msleep(1);
> }
You may want to consider using readl_relaxed_poll_timeout() from
linux/iopoll.h, which was introduced in v4.0-rc1.
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout
@ 2015-03-03 10:18 ` Baruch Siach
0 siblings, 0 replies; 6+ messages in thread
From: Baruch Siach @ 2015-03-03 10:18 UTC (permalink / raw)
To: linux-arm-kernel
Hi Maxime,
On Tue, Mar 03, 2015 at 10:55:29AM +0100, Maxime Ripard wrote:
> Now that the driver handles the FIFO draining in a threaded interrupt, we can
> base our timeout on jiffies and sleeping, instead of using mdelay.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/mtd/nand/pxa3xx_nand.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> index 3f09f2e9aeb4..1eb957c347cd 100644
> --- a/drivers/mtd/nand/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/pxa3xx_nand.c
> @@ -496,16 +496,15 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
> while (len > 8) {
> __raw_readsl(info->mmio_base + NDDB, data, 8);
>
> - for (timeout = 0;
> - !(nand_readl(info, NDSR) & NDSR_RDDREQ);
> - timeout++) {
> - if (timeout >= 5) {
> + timeout = jiffies + msecs_to_jiffies(5);
> + while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
> + if (!time_before(jiffies, timeout)) {
> dev_err(&info->pdev->dev,
> "Timeout on RDDREQ while draining the FIFO\n");
> return;
> }
>
> - mdelay(1);
> + msleep(1);
> }
You may want to consider using readl_relaxed_poll_timeout() from
linux/iopoll.h, which was introduced in v4.0-rc1.
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout
2015-03-03 10:18 ` Baruch Siach
@ 2015-03-04 16:18 ` maxime.ripard at free-electrons.com
-1 siblings, 0 replies; 6+ messages in thread
From: maxime.ripard @ 2015-03-04 16:18 UTC (permalink / raw)
To: Baruch Siach
Cc: Boris Brezillon, Brian Norris, linux-mtd, linux-arm-kernel,
Ezequiel Garcia
[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]
Hi Baruch,
On Tue, Mar 03, 2015 at 12:18:46PM +0200, Baruch Siach wrote:
> Hi Maxime,
>
> On Tue, Mar 03, 2015 at 10:55:29AM +0100, Maxime Ripard wrote:
> > Now that the driver handles the FIFO draining in a threaded interrupt, we can
> > base our timeout on jiffies and sleeping, instead of using mdelay.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> > drivers/mtd/nand/pxa3xx_nand.c | 9 ++++-----
> > 1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> > index 3f09f2e9aeb4..1eb957c347cd 100644
> > --- a/drivers/mtd/nand/pxa3xx_nand.c
> > +++ b/drivers/mtd/nand/pxa3xx_nand.c
> > @@ -496,16 +496,15 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
> > while (len > 8) {
> > __raw_readsl(info->mmio_base + NDDB, data, 8);
> >
> > - for (timeout = 0;
> > - !(nand_readl(info, NDSR) & NDSR_RDDREQ);
> > - timeout++) {
> > - if (timeout >= 5) {
> > + timeout = jiffies + msecs_to_jiffies(5);
> > + while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
> > + if (!time_before(jiffies, timeout)) {
> > dev_err(&info->pdev->dev,
> > "Timeout on RDDREQ while draining the FIFO\n");
> > return;
> > }
> >
> > - mdelay(1);
> > + msleep(1);
> > }
>
> You may want to consider using readl_relaxed_poll_timeout() from
> linux/iopoll.h, which was introduced in v4.0-rc1.
Thanks for pointing this out.
I'll send a new version using this.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout
@ 2015-03-04 16:18 ` maxime.ripard at free-electrons.com
0 siblings, 0 replies; 6+ messages in thread
From: maxime.ripard at free-electrons.com @ 2015-03-04 16:18 UTC (permalink / raw)
To: linux-arm-kernel
Hi Baruch,
On Tue, Mar 03, 2015 at 12:18:46PM +0200, Baruch Siach wrote:
> Hi Maxime,
>
> On Tue, Mar 03, 2015 at 10:55:29AM +0100, Maxime Ripard wrote:
> > Now that the driver handles the FIFO draining in a threaded interrupt, we can
> > base our timeout on jiffies and sleeping, instead of using mdelay.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> > drivers/mtd/nand/pxa3xx_nand.c | 9 ++++-----
> > 1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> > index 3f09f2e9aeb4..1eb957c347cd 100644
> > --- a/drivers/mtd/nand/pxa3xx_nand.c
> > +++ b/drivers/mtd/nand/pxa3xx_nand.c
> > @@ -496,16 +496,15 @@ static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len)
> > while (len > 8) {
> > __raw_readsl(info->mmio_base + NDDB, data, 8);
> >
> > - for (timeout = 0;
> > - !(nand_readl(info, NDSR) & NDSR_RDDREQ);
> > - timeout++) {
> > - if (timeout >= 5) {
> > + timeout = jiffies + msecs_to_jiffies(5);
> > + while (!(nand_readl(info, NDSR) & NDSR_RDDREQ)) {
> > + if (!time_before(jiffies, timeout)) {
> > dev_err(&info->pdev->dev,
> > "Timeout on RDDREQ while draining the FIFO\n");
> > return;
> > }
> >
> > - mdelay(1);
> > + msleep(1);
> > }
>
> You may want to consider using readl_relaxed_poll_timeout() from
> linux/iopoll.h, which was introduced in v4.0-rc1.
Thanks for pointing this out.
I'll send a new version using this.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150304/06bd1069/attachment-0001.sig>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-04 16:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03 9:55 [PATCH] mtd: nand: pxa3xx: Switch FIFO draining to jiffies-based timeout Maxime Ripard
2015-03-03 9:55 ` Maxime Ripard
2015-03-03 10:18 ` Baruch Siach
2015-03-03 10:18 ` Baruch Siach
2015-03-04 16:18 ` maxime.ripard
2015-03-04 16:18 ` maxime.ripard at free-electrons.com
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.