All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Asutosh Das <asutoshd@codeaurora.org>
Cc: cang@codeaurora.org, martin.petersen@oracle.com,
	Bart Van Assche <bvanassche@acm.org>,
	linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [RFC PATCH v2 0/2] Fix deadlock in ufs
Date: Thu, 4 Feb 2021 14:48:31 -0500	[thread overview]
Message-ID: <20210204194831.GA567391@rowland.harvard.edu> (raw)
In-Reply-To: <20210204001354.GD37557@stor-presley.qualcomm.com>

On Wed, Feb 03, 2021 at 04:13:54PM -0800, Asutosh Das wrote:
> Thanks Alan.
> I understand the issues with the current ufs design.
> 
> ufs has a wlun (well-known lun) that handles power management commands,
> such as SSUs. Now this wlun (device wlun) is registered as a scsi_device.
> It's queue is also set up for runtime-pm. Likewise there're 2
> more wluns, BOOT and RPMB.
> 
> Currently, the scsi devices independently runtime suspend/resume - request driven.
> So to send SSU while suspending wlun (scsi_device) this scsi device should
> be the last to be runtime suspended amongst all other ufs luns (scsi devices). The
> reason is syncronize_cache() is sent to luns during their suspend and if SSU has
> been sent already, it mostly would fail.

The SCSI subsystem assumes that different LUNs operate independently.
Evidently that isn't true here.

> Perhaps that's the reason to send SSU during platform-device suspend. I'm not
> sure if that's the right thing to do, but that's what it is now and is causing
> this deadlock.
> Now this wlun is also registered to bsg and some applications interact with rpmb
> wlun and the device-wlun using that interface. Registering the corresponding
> queues to runtime-pm ensures that the whole path is resumed before the request
> is issued.
> Because, we see this deadlock, in the RFC patch, I skipped registering the
> queues representing the wluns to runtime-pm, thus removing the restrictions to
> issue the request until queue is resumed.
> But when the requests come-in via bsg, the device has to be resumed. Hence the
> get_sync()/put_sync() in bsg driver.

Does the bsg interface send its I/O requests to the LUNs through the
block request queue?

> The reason for initiating get_sync()/put_sync() on the parent device was because
> the corresponding queue of this wlun was not setup for runtime-pm anymore.
> And for ufs resuming the scsi device essentially means sending a SSU to wlun
> which the ufs platform device does in its runtime resume now. I'm not sure if
> that was a good idea though, hence the RFC on the patches.
> 
> And now it looks to me that adding a cb to sd_suspend_runtime may not work.
> Because the scsi devices suspend asynchronously and the wlun suspends earlier than the others.
> 
> [    7.846165]scsi 0:0:0:49488: scsi_runtime_idle
> [    7.851547]scsi 0:0:0:49488: device wlun
> [    7.851809]sd 0:0:0:49488: scsi_runtime_idle
> [    7.861536]sd 0:0:0:49488: scsi_runtime_suspend < suspends prior to other luns
> [...]
> [   12.861984]sd 0:0:0:1: [sdb] Synchronizing SCSI cache
> [   12.868894]sd 0:0:0:2: [sdc] Synchronizing SCSI cache
> [   13.124331]sd 0:0:0:0: [sda] Synchronizing SCSI cache
> [   13.143961]sd 0:0:0:3: [sdd] Synchronizing SCSI cache
> [   13.163876]sd 0:0:0:6: [sdg] Synchronizing SCSI cache
> [   13.164024]sd 0:0:0:4: [sde] Synchronizing SCSI cache
> [   13.167066]sd 0:0:0:5: [sdf] Synchronizing SCSI cache
> [   17.101285]sd 0:0:0:7: [sdh] Synchronizing SCSI cache
> [   73.889551]sd 0:0:0:4: [sde] Synchronizing SCSI cache
> 
> I'm not sure if there's a way to force the wlun to suspend only after all other luns are suspended.
> Is there? I hope Bart/others help provide some inputs on this.

I don't know what would work best for you; it depends on how the LUNs
are used.  But one possibility is to make sure that whenever the boot
and rpmb wluns are resumed, the device wlun is also resumed.  So for
example, the runtime-resume callback routines for the rpmb and boot
wluns could call pm_runtime_get_sync() for the device wlun, and their
runtime-suspend callback routines could call pm_runtime_put() for the
device wlun.  And of course there would have to be appropriate 
operations when those LUNs are bound to and unbound from their drivers.

Alan Stern

  reply	other threads:[~2021-02-04 19:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  4:00 [RFC PATCH v1 0/2] Fix deadlock in ufs Asutosh Das
2021-01-28  3:26 ` [RFC PATCH v2 " Asutosh Das
2021-01-27  4:00 ` [RFC PATCH v1 1/2] block: bsg: resume scsi device before accessing Asutosh Das
2021-01-27  7:09   ` Avri Altman
2021-01-27  7:59     ` Can Guo
2021-01-27  8:53       ` Can Guo
2021-02-07  2:23   ` Bart Van Assche
2021-01-27  4:00 ` [RFC PATCH v1 2/2] scsi: ufs: Fix deadlock while suspending ufs host Asutosh Das
2021-01-27 15:22 ` [RFC PATCH v1 0/2] Fix deadlock in ufs Bjorn Andersson
2021-01-27 16:16   ` Asutosh Das
2021-01-27 19:36     ` Bjorn Andersson
2021-01-28  2:47       ` Can Guo
2021-01-28  3:26 ` [RFC PATCH v2 1/2] block: bsg: resume platform device before accessing Asutosh Das
2021-01-28  3:26   ` [RFC PATCH v2 2/2] scsi: ufs: Fix deadlock while suspending ufs host Asutosh Das
2021-01-28 12:21     ` Avri Altman
2021-01-28 16:39       ` Asutosh Das
2021-01-28  9:33 ` [RFC PATCH v2 0/2] Fix deadlock in ufs Avri Altman
2021-01-28 17:19   ` Asutosh Das
2021-02-01 20:11 ` Asutosh Das (asd)
2021-02-01 20:27   ` Bart Van Assche
2021-02-01 21:48   ` Alan Stern
2021-02-02 20:52     ` Asutosh Das
2021-02-02 22:05       ` Alan Stern
2021-02-04  0:13         ` Asutosh Das
2021-02-04 19:48           ` Alan Stern [this message]
2021-02-04 21:14             ` Asutosh Das
2021-02-05  7:56               ` Avri Altman
2021-02-05 16:11                 ` Asutosh Das
2021-02-06  2:37                   ` Asutosh Das
2021-02-06 19:24                   ` Avri Altman
2021-02-08 16:24                     ` Asutosh Das

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=20210204194831.GA567391@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=asutoshd@codeaurora.org \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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 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.