public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>,
	Bean Huo <huobean@gmail.com>, Avri Altman <avri.altman@wdc.com>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Can Guo <cang@codeaurora.org>,
	Asutosh Das <asutoshd@codeaurora.org>,
	Daejun Park <daejun7.park@samsung.com>,
	Stanley Chu <stanley.chu@mediatek.com>,
	Luca Porzio <lporzio@micron.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH RFC] scsi: ufs-core: Do not use clk_scaling_lock in ufshcd_queuecommand()
Date: Tue, 2 Nov 2021 08:11:05 +0200	[thread overview]
Message-ID: <3f4ef5e8-38e8-2e90-6da4-abc67aac9e4d@intel.com> (raw)
In-Reply-To: <d3d70c8e-f260-ca2d-f4c1-2c9dd1a08c5d@acm.org>

On 01/11/2021 20:35, Bart Van Assche wrote:
> On 11/1/21 2:16 AM, Adrian Hunter wrote:
>> On 29/10/2021 19:31, Bart Van Assche wrote:
>>> @@ -5985,9 +5920,12 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
>>>           ufshcd_clk_scaling_allow(hba, false);
>>>       }
>>>       ufshcd_scsi_block_requests(hba);
>>> -    /* Drain ufshcd_queuecommand() */
>>> -    down_write(&hba->clk_scaling_lock);
>>> -    up_write(&hba->clk_scaling_lock);
>>> +    /*
>>> +     * Drain ufshcd_queuecommand(). Since ufshcd_queuecommand() does not
>>> +     * sleep, calling synchronize_rcu() is sufficient to wait for ongoing
>>> +     * ufshcd_queuecommand calls.
>>> +     */
>>> +    synchronize_rcu();
>>
>> This depends upon block layer internals, so it must be called via a block
>> layer function i.e. the block layer must guarantee this will always work. > Also, scsi_unjam_host() does not look like it uses RCU when issuing
>> requests.
> 
> I will add an rcu_read_lock() / rcu_read_unlock() pair in ufshcd_queuecommand().
> I think that addresses both points mentioned above.
> 
>>>       cancel_work_sync(&hba->eeh_work);
>>>   }
>>>
>>> @@ -6212,11 +6150,8 @@ static void ufshcd_err_handler(struct work_struct *work)
>>>        */
>>>       if (needs_restore) {
>>>           spin_unlock_irqrestore(hba->host->host_lock, flags);
>>> -        /*
>>> -         * Hold the scaling lock just in case dev cmds
>>> -         * are sent via bsg and/or sysfs.
>>> -         */
>>> -        down_write(&hba->clk_scaling_lock);
>>> +        /* Block TMF submission, e.g. through BSG or sysfs. */
>>
>> What about dev cmds?
> 
> ufshcd_exec_dev_cmd() and ufshcd_issue_devman_upiu_cmd() both allocate a
> request from hba->cmd_queue. blk_get_request() indirectly increments
> q->q_usage_counter and blk_mq_freeze_queue() waits until that counter drops
> to zero. Hence, hba->cmd_queue freezing only finishes after all pending dev
> cmds have finished. Additionally, if hba->cmd_queue is frozen,
> blk_get_request() blocks until it is unfrozen. So dev cmds are covered.

The queue is not usually frozen when the error handler runs.

> 
>> Also, there is the outstanding question of synchronization for the call to
>> ufshcd_reset_and_restore() further down.
> 
> Please clarify this comment further. I assume that you are referring to the
> ufshcd_reset_and_restore() call guarded by if (needs_reset)? It is not clear
> to me what the outstanding question is?

What is to stop it racing with BSG, sysfs, debugfs, abort, reset etc?

> 
> Thanks,
> 
> Bart.


  reply	other threads:[~2021-11-02  6:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 13:37 [PATCH RFC] scsi: ufs-core: Do not use clk_scaling_lock in ufshcd_queuecommand() Adrian Hunter
2021-10-29 16:31 ` Bart Van Assche
2021-11-01  9:16   ` Adrian Hunter
2021-11-01 18:35     ` Bart Van Assche
2021-11-02  6:11       ` Adrian Hunter [this message]
2021-11-02 20:49         ` Bart Van Assche
2021-11-03  7:46           ` Adrian Hunter
2021-11-03 17:06             ` Bart Van Assche
2021-11-04 14:23               ` Asutosh Das (asd)
2021-11-04 17:10                 ` Bart Van Assche
2021-11-08 18:06                   ` Asutosh Das (asd)
2021-11-08 18:24                     ` Bart Van Assche
2021-11-03 16:29 ` Asutosh Das (asd)

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=3f4ef5e8-38e8-2e90-6da4-abc67aac9e4d@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=daejun7.park@samsung.com \
    --cc=huobean@gmail.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lporzio@micron.com \
    --cc=martin.petersen@oracle.com \
    --cc=stanley.chu@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox