* [PATCH] [Outreachy kernel] staging: speakup: prefer usleep_range over udelay
@ 2019-03-18 18:06 Payal Kshirsagar
2019-03-18 18:45 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Payal Kshirsagar @ 2019-03-18 18:06 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Payal Kshirsagar
Since usleep_range is built on top of hrtimers, the
wakeup will be very precise (ish), thus a simple
usleep function would likely introduce a large number
of undesired interrupts.
Thus udelay replaced with usleep_range.
Signed-off-by: Payal Kshirsagar <payal.s.kshirsagar.98@gmail.com>
---
drivers/staging/speakup/speakup_decpc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c
index 798c42d..10ca19b 100644
--- a/drivers/staging/speakup/speakup_decpc.c
+++ b/drivers/staging/speakup/speakup_decpc.c
@@ -251,7 +251,7 @@ static int dt_waitbit(int bit)
while (--timeout > 0) {
if ((dt_getstatus() & bit) == bit)
return 1;
- udelay(50);
+ usleep_range(50, 50 + 10);
}
return 0;
}
@@ -265,7 +265,7 @@ static int dt_wait_dma(void)
while (--timeout > 0) {
if ((dt_getstatus() & STAT_dma_state) == state)
return 1;
- udelay(50);
+ usleep_range(50, 50 + 10);
}
dma_state = dt_getstatus() & STAT_dma_state;
return 1;
@@ -283,7 +283,7 @@ static int dt_ctrl(u_int cmd)
dt_sendcmd(CMD_control | cmd);
outb_p(0, speakup_info.port_tts + 6);
while (dt_getstatus() & STAT_cmd_ready) {
- udelay(20);
+ usleep_range(20, 20 + 10);
if (--timeout == 0)
break;
}
@@ -302,20 +302,20 @@ static void synth_flush(struct spk_synth *synth)
while (dt_ctrl(CTRL_flush)) {
if (--timeout == 0)
break;
- udelay(50);
+ usleep_range(50, 50 + 10);
}
for (timeout = 0; timeout < 10; timeout++) {
if (dt_waitbit(STAT_dma_ready))
break;
- udelay(50);
+ usleep_range(50, 50 + 10);
}
outb_p(DMA_sync, speakup_info.port_tts + 4);
outb_p(0, speakup_info.port_tts + 4);
- udelay(100);
+ usleep_range(100, 100 + 10);
for (timeout = 0; timeout < 10; timeout++) {
if (!(dt_getstatus() & STAT_flushing))
break;
- udelay(50);
+ usleep_range(50, 50 + 10);
}
dma_state = dt_getstatus() & STAT_dma_state;
dma_state ^= STAT_dma_state;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [Outreachy kernel] staging: speakup: prefer usleep_range over udelay
2019-03-18 18:06 [PATCH] [Outreachy kernel] staging: speakup: prefer usleep_range over udelay Payal Kshirsagar
@ 2019-03-18 18:45 ` Greg KH
2019-03-19 0:53 ` Payal Kshirsagar
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2019-03-18 18:45 UTC (permalink / raw)
To: Payal Kshirsagar; +Cc: outreachy-kernel
On Mon, Mar 18, 2019 at 11:36:24PM +0530, Payal Kshirsagar wrote:
> Since usleep_range is built on top of hrtimers, the
> wakeup will be very precise (ish), thus a simple
> usleep function would likely introduce a large number
> of undesired interrupts.
> Thus udelay replaced with usleep_range.
>
> Signed-off-by: Payal Kshirsagar <payal.s.kshirsagar.98@gmail.com>
> ---
> drivers/staging/speakup/speakup_decpc.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c
> index 798c42d..10ca19b 100644
> --- a/drivers/staging/speakup/speakup_decpc.c
> +++ b/drivers/staging/speakup/speakup_decpc.c
> @@ -251,7 +251,7 @@ static int dt_waitbit(int bit)
> while (--timeout > 0) {
> if ((dt_getstatus() & bit) == bit)
> return 1;
> - udelay(50);
> + usleep_range(50, 50 + 10);
I've said this in the past, only do this type of change if you can
actually test it, and know it will be ok. For some stuff like this, it
_might_ be ok, but you just expanded the timeout range potentially a lot
longer than before, and do we know that is ok?
I sure do not :)
So just leave these things alone unless you know the hardware will keep
working properly.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [Outreachy kernel] staging: speakup: prefer usleep_range over udelay
2019-03-18 18:45 ` Greg KH
@ 2019-03-19 0:53 ` Payal Kshirsagar
0 siblings, 0 replies; 3+ messages in thread
From: Payal Kshirsagar @ 2019-03-19 0:53 UTC (permalink / raw)
To: Greg KH; +Cc: outreachy-kernel
[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]
On Tue, Mar 19, 2019, 12:15 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> On Mon, Mar 18, 2019 at 11:36:24PM +0530, Payal Kshirsagar wrote:
> > Since usleep_range is built on top of hrtimers, the
> > wakeup will be very precise (ish), thus a simple
> > usleep function would likely introduce a large number
> > of undesired interrupts.
> > Thus udelay replaced with usleep_range.
> >
> > Signed-off-by: Payal Kshirsagar <payal.s.kshirsagar.98@gmail.com>
> > ---
> > drivers/staging/speakup/speakup_decpc.c | 14 +++++++-------
> > 1 file changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/staging/speakup/speakup_decpc.c
> b/drivers/staging/speakup/speakup_decpc.c
> > index 798c42d..10ca19b 100644
> > --- a/drivers/staging/speakup/speakup_decpc.c
> > +++ b/drivers/staging/speakup/speakup_decpc.c
> > @@ -251,7 +251,7 @@ static int dt_waitbit(int bit)
> > while (--timeout > 0) {
> > if ((dt_getstatus() & bit) == bit)
> > return 1;
> > - udelay(50);
> > + usleep_range(50, 50 + 10);
>
> I've said this in the past, only do this type of change if you can
> actually test it, and know it will be ok. For some stuff like this, it
> _might_ be ok, but you just expanded the timeout range potentially a lot
> longer than before, and do we know that is ok?
>
> I sure do not :)
>
> So just leave these things alone unless you know the hardware will keep
> working properly.
>
> thanks,
>
> greg k-h
>
Okay I'll drop this patch .
Regards,
Payal
>
[-- Attachment #2: Type: text/html, Size: 2403 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-19 0:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 18:06 [PATCH] [Outreachy kernel] staging: speakup: prefer usleep_range over udelay Payal Kshirsagar
2019-03-18 18:45 ` Greg KH
2019-03-19 0:53 ` Payal Kshirsagar
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.