public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Andreas Bombe <aeb@debian.org>
Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] amiflop: get rid of sleep_on calls
Date: Tue, 9 Dec 2008 09:31:11 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.0812090927580.29640@anakin> (raw)
In-Reply-To: <1228755578-26069-1-git-send-email-aeb@debian.org>

On Mon, 8 Dec 2008, Andreas Bombe wrote:
> Apart from sleep_on() calls that could be easily converted to
> wait_event() and completion calls amiflop also used a flag in ms_delay()
> and ms_isr() as a custom mutex for ms_delay() without a need for
> explicit unlocking.  I converted that to a standard mutex semaphore.
> 
> The replacement for the unconditional sleep_on() in fd_motor_on() is a
> complete_all() together with a INIT_COMPLETION() before the mod_timer()
> call.  It appears to me that fd_motor_on() might be called concurrently
> and fd_select() does not guarantee mutual exclusivity in the case the
> same drive gets selected again.
> 
> Signed-off-by: Andreas Bombe <aeb@debian.org>
> ---
> 
> Note: I haven't tested these changes beyond correct compilation.
> 
> The complete_all() with INIT_COMPLETION() was because I'm not sure about
> whether fd_motor_on() might run concurrently.  Better safe than sorry.

I'm afraid my Amiga floppy drive doesn't work anymore...
Any other testers available?

> --- a/drivers/block/amiflop.c
> +++ b/drivers/block/amiflop.c
> @@ -220,19 +218,17 @@ static irqreturn_t ms_isr(int irq, void *dummy)
>     A more generic routine would do a schedule a la timer.device */
>  static void ms_delay(int ms)
>  {
> -	unsigned long flags;
>  	int ticks;
> +	static DECLARE_MUTEX(mutex);
               ^^^^^^^^^^^^^
Shouldn't this be a real mutex (declared using DEFINE_MUTEX(mutex)) instead of
a semaphore used as a mutex?

> +
>  	if (ms > 0) {
> -		local_irq_save(flags);
> -		while (ms_busy == 0)
> -			sleep_on(&ms_wait);
> -		ms_busy = 0;
> -		local_irq_restore(flags);
> +		down(&mutex);
                ^^^^
		mutex_lock

>  		ticks = MS_TICKS*ms-1;
>  		ciaa.tblo=ticks%256;
>  		ciaa.tbhi=ticks/256;
>  		ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */
> -		sleep_on(&ms_wait);
> +		wait_for_completion(&ms_wait_completion);
> +		up(&mutex);
		mutex_unlock

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

  parent reply	other threads:[~2008-12-09  8:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-08 16:59 [PATCH] amiflop: get rid of sleep_on calls Andreas Bombe
2008-12-09  8:26 ` Joerg Dorchain
2008-12-10  0:48   ` Andreas Bombe
2008-12-10  8:16     ` Joerg Dorchain
2008-12-16 20:23   ` Geert Uytterhoeven
2008-12-17  8:00     ` Joerg Dorchain
2008-12-09  8:31 ` Geert Uytterhoeven [this message]
2008-12-09 18:34   ` Andreas Bombe
2008-12-10  1:02   ` [PATCH v2] " Andreas Bombe
2008-12-14 16:21     ` Geert Uytterhoeven
2008-12-23 14:22       ` Andreas Bombe
2008-12-31 16:30         ` Geert Uytterhoeven
2008-12-13 15:20   ` [PATCH] " Kolbjørn Barmen
2008-12-13 21:30     ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0812090927580.29640@anakin \
    --to=geert@linux-m68k.org \
    --cc=aeb@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox