From: Michael Schmitz <schmitzmic@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>,
"James E.J. Bottomley" <JBottomley@parallels.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 02/16] scsi: atari_scsi: fix sleep_on race
Date: Sat, 01 Mar 2014 13:24:42 +1300 [thread overview]
Message-ID: <531128CA.5040700@gmail.com> (raw)
In-Reply-To: <201402272144.50946.arnd@arndb.de>
Hello Arnd,
> On Thursday 27 February 2014, Michael Schmitz wrote:
>
>> Arnd Bergmann wrote:
>>
>>>
>>>
>> Nack - the completion condition in the first hunk has its logic
>> reversed. Try this instead (while() loops while condition true, do {}
>> until () loops while condition false, no?)
>>
>
> Sorry about messing it up again. I though I had fixed it up the
> way you commented when you said it worked.
>
>
>> I'm 99% confident I had tested your current version of the patch before
>> and found it still attempts to schedule while in interrupt. I can retest
>> if you prefer, but that'll have to wait a few days.
>>
>
> I definitely trust you to have the right version, since you did the
> testing.
>
I'm glad I double checked, since there's one other error left in my
correction to your patch below:
The in_irq() condition is not sufficient, we need in_interrupt() there.
This has somehow slipped into a related patch sent to linux-scsi, so
I'll have to refactor the lot. Bugger.
I'll resend the correct version via Geert.
>
>> diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
>> index a3e6c8a..cc1b013 100644
>> --- a/drivers/scsi/atari_scsi.c
>> +++ b/drivers/scsi/atari_scsi.c
>> @@ -90,6 +90,7 @@
>> #include <linux/init.h>
>> #include <linux/nvram.h>
>> #include <linux/bitops.h>
>> +#include <linux/wait.h>
>>
>> #include <asm/setup.h>
>> #include <asm/atarihw.h>
>> @@ -549,8 +550,10 @@ static void falcon_get_lock(void)
>>
>> local_irq_save(flags);
>>
>> - while (!in_irq() && falcon_got_lock && stdma_others_waiting())
>> - sleep_on(&falcon_fairness_wait);
>> + wait_event_cmd(falcon_fairness_wait,
>> + in_irq() || !falcon_got_lock || !stdma_others_waiting(),
>> + local_irq_restore(flags),
>> + local_irq_save(flags));
>>
>> while (!falcon_got_lock) {
>> if (in_irq())
>>
>
> Yes, by inspection your version looks correct and mine looks wrong.
> I had figured this out before, just sent the wrong version.
>
These things happen if you bother fixing other people's weird code :-)
And as I mentioned above, I missed another detail myself
>
>> @@ -562,7 +565,10 @@ static void falcon_get_lock(void)
>> falcon_trying_lock = 0;
>> wake_up(&falcon_try_wait);
>> } else {
>> - sleep_on(&falcon_try_wait);
>> + wait_event_cmd(falcon_try_wait,
>> + falcon_got_lock && !falcon_trying_lock,
>> + local_irq_restore(flags),
>> + local_irq_save(flags));
>> }
>>
>
> I did correct this part compared to my first patch, but forgot
> to change the other hunk.
>
> Can you send your version of the patch to Geert for inclusion?
> That way I don't have the danger of missing another negation.
> This code is clearly too weird to rely on inspection alone and
> we know that your version was working when you last tested it.
>
Will do - I'll CC: you in so you can ACK the patch if Geert needs
convincing.
Cheers,
Michael
next prev parent reply other threads:[~2014-03-01 0:24 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 11:01 [PATCH 00/16] sleep_on removal, second try Arnd Bergmann
2014-02-26 11:01 ` [PATCH 01/16] ataflop: fix sleep_on races Arnd Bergmann
2014-02-26 11:01 ` [PATCH 02/16] scsi: atari_scsi: fix sleep_on race Arnd Bergmann
2014-02-27 7:58 ` Michael Schmitz
2014-02-27 20:44 ` Arnd Bergmann
2014-03-01 0:24 ` Michael Schmitz [this message]
2014-02-26 11:01 ` [PATCH 03/16] DAC960: remove sleep_on usage Arnd Bergmann
2014-02-26 11:01 ` [PATCH 04/16] swim3: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 05/16] [media] omap_vout: avoid sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 06/16] [media] usbvision: drop unused define USBVISION_SAY_AND_WAIT Arnd Bergmann
2014-02-26 11:01 ` [PATCH 07/16] [media] radio-cadet: avoid interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 08/16] [media] arv: fix sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 09/16] parport: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 11:01 ` [PATCH 10/16] atm: nicstar: remove interruptible_sleep_on_timeout Arnd Bergmann
2014-02-26 16:06 ` David Miller
2014-02-27 18:51 ` [PATCH v3] " Arnd Bergmann
2014-02-27 20:23 ` David Miller
2014-02-26 11:01 ` [PATCH 11/16] atm: firestream: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 21:08 ` David Miller
2014-02-26 11:01 ` [PATCH 12/16] isdn: pcbit: " Arnd Bergmann
2014-02-26 21:08 ` David Miller
2014-02-26 11:01 ` [PATCH 13/16] isdn: hisax/elsa: fix sleep_on race in elsa FSM Arnd Bergmann
2014-02-26 21:08 ` David Miller
2014-02-26 11:01 ` [PATCH 14/16] isdn: divert, hysdn: fix interruptible_sleep_on race Arnd Bergmann
2014-02-26 21:08 ` David Miller
2014-02-26 11:01 ` [PATCH 15/16] isdn: fix multiple sleep_on races Arnd Bergmann
2014-02-26 21:08 ` David Miller
2014-02-26 11:01 ` [PATCH 16/16] NOTYET: sched: remove sleep_on() and friends Arnd Bergmann
2014-02-26 17:36 ` [PATCH 00/16] sleep_on removal, second try Jens Axboe
2014-02-27 6:37 ` Michael Schmitz
2014-02-27 11:55 ` Geert Uytterhoeven
2014-02-28 8:53 ` Karsten Keil
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=531128CA.5040700@gmail.com \
--to=schmitzmic@gmail.com \
--cc=JBottomley@parallels.com \
--cc=arnd@arndb.de \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@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;
as well as URLs for NNTP newsgroup(s).