From: sthumma@codeaurora.org
To: sthumma@codeaurora.org
Cc: Aaron Lu <aaron.lu@intel.com>,
stern@rowland.harvard.edu, linux-scsi@vger.kernel.org
Subject: Re: Race condition in block layer runtime PM init and scsi disk driver
Date: Wed, 9 Oct 2013 08:32:31 -0000 [thread overview]
Message-ID: <4ed022cf2fedc9ee1049254ea274f705.squirrel@www.codeaurora.org> (raw)
In-Reply-To: <6c835b531761fe70209d015daa6b87e8.squirrel@www.codeaurora.org>
> Hi Aaron,
>
> I found a race condition with the block layer runtime PM due to which
> the q->nr_pending is decremented to less than zero (0xFFFF_FFFF (-1))
> and hence the blk pre-runtime suspend always returns -EBUSY.
>
>
> The issue is easily reproduced with a scsi disk with disabled tagged
> command queuing
>
> sd_probe_async() ->
> add_disk() ->
> disk_add_event() ->
> schedule(disk_events_workfn)
> sd_revalidate_disk()
> blk_pm_runtime_init()
> return;
>
> Let's say the disk_events_workfn() calls sd_check_events() which tries
> to send test_unit_ready() and because of sd_revalidate_disk() trying to
> send another commands the test_unit_ready() might be re-queued as the
> tagged command queuing is disabled.
>
> So the race condition is -
>
> Thread 1 | Thread 2
> sd_revalidate_disk() | sd_check_events()
> ...nr_pending = 0 as q->dev = NULL| scsi_queue_insert()
> blk_runtime_pm_init() | blk_pm_requeue_request() ->
> | nr_pending = -1 since
> | q->dev != NULL
>
> Do you have any suggestions on how to fix this issue?
>
>
> --
> Regards,
> Sujit
>
next prev parent reply other threads:[~2013-10-09 8:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 8:32 (unknown), sthumma
2013-10-09 8:32 ` sthumma [this message]
2013-10-09 9:07 ` Race condition in block layer runtime PM init and scsi disk driver Aaron Lu
2013-10-10 4:55 ` sthumma
2013-10-10 5:22 ` [PATCH] [SCSI] sd: call blk_pm_runtime_init before add_disk Aaron Lu
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=4ed022cf2fedc9ee1049254ea274f705.squirrel@www.codeaurora.org \
--to=sthumma@codeaurora.org \
--cc=aaron.lu@intel.com \
--cc=linux-scsi@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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).