All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mg_disk: remove prohibited sleep operation
@ 2009-07-23  4:57 unsik Kim
  2009-07-23  4:57 ` [PATCH 2/2] mg_disk: fix reading invalid status when use polling driver unsik Kim
  2009-07-27 21:32 ` [PATCH 1/2] mg_disk: remove prohibited sleep operation Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: unsik Kim @ 2009-07-23  4:57 UTC (permalink / raw)
  To: axboe, tj; +Cc: linux-kernel, unsik Kim

mflash's polling driver operate in standard request_fn_proc's context,
sleep in this isn't permitted.
Signed-off-by: unsik Kim <donari75@gmail.com>
---
 drivers/block/mg_disk.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 64f90f5..26371d5 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -244,8 +244,6 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec)
 			mg_dump_status("not ready", status, host);
 			return MG_ERR_INV_STAT;
 		}
-		if (prv_data->use_polling)
-			msleep(1);
 
 		status = inb((unsigned long)host->dev_base + MG_REG_STATUS);
 	} while (time_before(cur_jiffies, expire));
-- 
1.6.0.6


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

* [PATCH 2/2] mg_disk: fix reading invalid status when use polling driver
  2009-07-23  4:57 [PATCH 1/2] mg_disk: remove prohibited sleep operation unsik Kim
@ 2009-07-23  4:57 ` unsik Kim
  2009-07-27 21:32 ` [PATCH 1/2] mg_disk: remove prohibited sleep operation Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: unsik Kim @ 2009-07-23  4:57 UTC (permalink / raw)
  To: axboe, tj; +Cc: linux-kernel, unsik Kim

When using polling driver, little delay is required to access
status register. Without this, host might read invalid status.

Signed-off-by: unsik Kim <donari75@gmail.com>
---
 drivers/block/mg_disk.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 26371d5..6d7fbaa 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -218,6 +218,16 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec)
 	host->error = MG_ERR_NONE;
 	expire = jiffies + msecs_to_jiffies(msec);
 
+	/* These 2 times dummy status read prevents reading invalid
+	 * status. A very little time (3 times of mflash operating clk)
+	 * is required for busy bit is set. Use dummy read instead of
+	 * busy wait, because mflash's PLL is machine dependent.
+	 */
+	if (prv_data->use_polling) {
+		status = inb((unsigned long)host->dev_base + MG_REG_STATUS);
+		status = inb((unsigned long)host->dev_base + MG_REG_STATUS);
+	}
+
 	status = inb((unsigned long)host->dev_base + MG_REG_STATUS);
 
 	do {
-- 
1.6.0.6


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

* Re: [PATCH 1/2] mg_disk: remove prohibited sleep operation
  2009-07-23  4:57 [PATCH 1/2] mg_disk: remove prohibited sleep operation unsik Kim
  2009-07-23  4:57 ` [PATCH 2/2] mg_disk: fix reading invalid status when use polling driver unsik Kim
@ 2009-07-27 21:32 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2009-07-27 21:32 UTC (permalink / raw)
  To: unsik Kim; +Cc: axboe, tj, linux-kernel, donari75

On Thu, 23 Jul 2009 13:57:45 +0900
unsik Kim <donari75@gmail.com> wrote:

> mflash's polling driver operate in standard request_fn_proc's context,
> sleep in this isn't permitted.
> Signed-off-by: unsik Kim <donari75@gmail.com>
> ---
>  drivers/block/mg_disk.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
> index 64f90f5..26371d5 100644
> --- a/drivers/block/mg_disk.c
> +++ b/drivers/block/mg_disk.c
> @@ -244,8 +244,6 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec)
>  			mg_dump_status("not ready", status, host);
>  			return MG_ERR_INV_STAT;
>  		}
> -		if (prv_data->use_polling)
> -			msleep(1);
>  
>  		status = inb((unsigned long)host->dev_base + MG_REG_STATUS);
>  	} while (time_before(cur_jiffies, expire));

This change has the potential to cause the driver to use much much more
CPU time and power.  Are you really sure that the driver is optimal in
this area?

On possibility is to pass a flag into mg_wait() telling it whether it
is permitted to sleep:

		if (may_sleep && prv_data->use_polling)
			msleep(1);
		else
			mdelay(1);

or

		if (may_sleep && prv_data->use_polling)
			msleep(1);
		else
			/* nothing */;


so that then we only consume extra power if the caller is the
request_fn handler.


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

end of thread, other threads:[~2009-07-27 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23  4:57 [PATCH 1/2] mg_disk: remove prohibited sleep operation unsik Kim
2009-07-23  4:57 ` [PATCH 2/2] mg_disk: fix reading invalid status when use polling driver unsik Kim
2009-07-27 21:32 ` [PATCH 1/2] mg_disk: remove prohibited sleep operation Andrew Morton

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.