All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Adrian Hunter <adrian.hunter@intel.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-scsi@vger.kernel.org, dh0421.hwang@samsung.com,
	Asutosh Das <asutoshd@codeaurora.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Bean Huo <beanhuo@micron.com>, Avri Altman <avri.altman@wdc.com>,
	Jinyoung Choi <j-young.choi@samsung.com>
Subject: Re: [PATCH] scsi: ufs: Fix deadlocks between power management and error handler
Date: Mon, 19 Sep 2022 16:22:26 -0700	[thread overview]
Message-ID: <dd89017d-05a9-a517-e193-0edc0b04ae0e@acm.org> (raw)
In-Reply-To: <c98a4226-f1be-f84b-267c-5ce4e6c387d7@intel.com>

On 9/19/22 10:21, Adrian Hunter wrote:
> I guess it goes unnoticed because it is very unlikely i.e. the UFS
> device would need to be suspending but not yet have claimed host_sem.
> There would not be any outstanding requests otherwise the suspend
> would not have started, so chance of errors at that point is very low.
> 
> Maybe deadlock could be sidestepped by changing:
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 7256e6c43ca6..9cb04c6f8dc3 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -9258,7 +9261,10 @@ static int ufshcd_wl_suspend(struct device *dev)
>   	ktime_t start = ktime_get();
>   
>   	hba = shost_priv(sdev->host);
> -	down(&hba->host_sem);
> +	if (down_trylock(&hba->host_sem)) {
> +		ret = -EBUSY;
> +		goto out;
> +	}
>   
>   	if (pm_runtime_suspended(dev))
>   		goto out;

Hi Adrian,

Unfortunately I don't think that the above change would help. My 
conclusion from the logs that I analyzed is that ufshcd_wl_suspend() is 
called first and also that the error handler is invoked while 
ufshcd_wl_suspend() holds host_sem, resulting in a deadlock.

Thanks,

Bart.



      reply	other threads:[~2022-09-19 23:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 18:42 [PATCH] scsi: ufs: Fix deadlocks between power management and error handler Bart Van Assche
2022-09-19  3:10 ` Asutosh Das (asd)
2022-09-19 23:17   ` Bart Van Assche
2022-09-19 11:34 ` Adrian Hunter
2022-09-19 13:54   ` Bart Van Assche
2022-09-19 17:21     ` Adrian Hunter
2022-09-19 23:22       ` Bart Van Assche [this message]

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=dd89017d-05a9-a517-e193-0edc0b04ae0e@acm.org \
    --to=bvanassche@acm.org \
    --cc=adrian.hunter@intel.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=dh0421.hwang@samsung.com \
    --cc=j-young.choi@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --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.