mbox series

[v7,0/7] ufs: core: mcq: Add ufshcd_abort() and error handler support in MCQ mode

Message ID cover.1685396241.git.quic_nguyenb@quicinc.com (mailing list archive)
Headers show
Series ufs: core: mcq: Add ufshcd_abort() and error handler support in MCQ mode | expand

Message

Bao D. Nguyen May 29, 2023, 10:12 p.m. UTC
This patch series enable support for ufshcd_abort() and error handler in MCQ mode.

Bao D. Nguyen (7):
  ufs: core: Combine 32-bit command_desc_base_addr_lo/hi
  ufs: core: Update the ufshcd_clear_cmds() functionality
  ufs: mcq: Add supporting functions for mcq abort
  ufs: mcq: Add support for clean up mcq resources
  ufs: mcq: Added ufshcd_mcq_abort()
  ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode
  ufs: core: Add error handling for MCQ mode

 drivers/ufs/core/ufs-mcq.c     | 259 ++++++++++++++++++++++++++++++++++++++++-
 drivers/ufs/core/ufshcd-priv.h |  18 ++-
 drivers/ufs/core/ufshcd.c      | 256 ++++++++++++++++++++++++++++++++--------
 drivers/ufs/host/ufs-qcom.c    |   2 +-
 include/ufs/ufshcd.h           |   5 +-
 include/ufs/ufshci.h           |  23 +++-
 6 files changed, 501 insertions(+), 62 deletions(-)
---
Changes compared to v6:
patch #7: Added a new argument force_compl to function ufshcd_mcq_compl_pending_transfer().
          Added a new function ufshcd_mcq_compl_all_cqes_lock().
	  This change is to handle the case where the ufs host controller has been reset by
	  the ufshcd_hba_stop() in ufshcd_host_reset_and_restore() prior to calling
	  ufshcd_complete_requests(). The new logic is added to correctly complete all the
	  commands that have been completed in the Completion Queue, or inform the scsi layer
	  about those commands that are still stuck/pending in the hardware.
---
v5->v6: Addressed Stanley's comments
patch #1,2,3,4,6: unchanged.
patch #5: fixed extra erroneous if() statement introduced in version v5
patch #7: Change ufshcd_complete_requests() to call a new mcq function
          ufshcd_mcq_compl_pending_transfer(), leaving ufshcd_transfer_req_compl()
          to be used in SDB mode only.

          Reset the hwq's head and tail slot variables to default values
          when the ufs host controller hw has been reset.
---
v4->v5:
patch #4: fixed uninitialized variable access introduced in patch v3.
---
v3->v4: Mainly addressed Bart's comments
patch #1: updated the commit message
patch #2: renamed ufshcd_clear_cmds() into ufshcd_clear_cmd()
patch #3: removed result arg in ufshcd_mcq_sq_cleanup()
patch #4: removed check for "!rq" in ufshcd_cmd_inflight()
          avoided access to door bell register in mcq mode 
patch #5, 6: unchanged
patch #7: ufshcd_clear_cmds() to ufshcd_clear_cmd()
--- 
v2->v3:
patch #1:
  New patch per Bart's comment. Helps process utp cmd
  descriptor addr easier.
patch #2:
  New patch to address Bart's comment regarding potentialoverflow 
  when mcq queue depth becomes greater than 64.
patch #3:
  Address Bart's comments
  . Replaced ufshcd_mcq_poll_register() with read_poll_timeout()
  . Replace spin_lock(sq_lock) with mutex(sq_mutex)
  . Updated ufshcd_mcq_nullify_cmd() and renamed to ufshcd_mcq_nullify_sqe()
  . Minor cosmetic changes
patch #4:
  Adress Bart's comments. Added new function ufshcd_cmd_inflight()
  to replace the usage of lrbp->cmd
patch #5:
  Continue replacing lrbp->cmd with ufshcd_cmd_inflight()
patch #6:
  No change
patch #7:
  Address Stanley Chu's comment about clearing hba->dev_cmd.complete
  in clear ufshcd_wait_for_dev_cmd()
  Address Bart's comment.
---
v1->v2:
patch #1: Addressed Powen's comment. Replaced read_poll_timeout()
with ufshcd_mcq_poll_register(). The function read_poll_timeout()
may sleep while the caller is holding a spin_lock(). Poll the registers
in a tight loop instead.

Comments

Stanley Jhu May 30, 2023, 12:23 a.m. UTC | #1
Hi Bao,

On Tue, May 30, 2023 at 6:14 AM Bao D. Nguyen <quic_nguyenb@quicinc.com> wrote:
>
> This patch series enable support for ufshcd_abort() and error handler in MCQ mode.
>
> Bao D. Nguyen (7):
>   ufs: core: Combine 32-bit command_desc_base_addr_lo/hi
>   ufs: core: Update the ufshcd_clear_cmds() functionality
>   ufs: mcq: Add supporting functions for mcq abort
>   ufs: mcq: Add support for clean up mcq resources
>   ufs: mcq: Added ufshcd_mcq_abort()
>   ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode
>   ufs: core: Add error handling for MCQ mode
>
>  drivers/ufs/core/ufs-mcq.c     | 259 ++++++++++++++++++++++++++++++++++++++++-
>  drivers/ufs/core/ufshcd-priv.h |  18 ++-
>  drivers/ufs/core/ufshcd.c      | 256 ++++++++++++++++++++++++++++++++--------
>  drivers/ufs/host/ufs-qcom.c    |   2 +-
>  include/ufs/ufshcd.h           |   5 +-
>  include/ufs/ufshci.h           |  23 +++-
>  6 files changed, 501 insertions(+), 62 deletions(-)
> ---
> Changes compared to v6:
> patch #7: Added a new argument force_compl to function ufshcd_mcq_compl_pending_transfer().
>           Added a new function ufshcd_mcq_compl_all_cqes_lock().
>           This change is to handle the case where the ufs host controller has been reset by
>           the ufshcd_hba_stop() in ufshcd_host_reset_and_restore() prior to calling
>           ufshcd_complete_requests(). The new logic is added to correctly complete all the
>           commands that have been completed in the Completion Queue, or inform the scsi layer
>           about those commands that are still stuck/pending in the hardware.
> ---
> v5->v6: Addressed Stanley's comments
> patch #1,2,3,4,6: unchanged.
> patch #5: fixed extra erroneous if() statement introduced in version v5
> patch #7: Change ufshcd_complete_requests() to call a new mcq function
>           ufshcd_mcq_compl_pending_transfer(), leaving ufshcd_transfer_req_compl()
>           to be used in SDB mode only.
>
>           Reset the hwq's head and tail slot variables to default values
>           when the ufs host controller hw has been reset.
> ---
> v4->v5:
> patch #4: fixed uninitialized variable access introduced in patch v3.
> ---
> v3->v4: Mainly addressed Bart's comments
> patch #1: updated the commit message
> patch #2: renamed ufshcd_clear_cmds() into ufshcd_clear_cmd()
> patch #3: removed result arg in ufshcd_mcq_sq_cleanup()
> patch #4: removed check for "!rq" in ufshcd_cmd_inflight()
>           avoided access to door bell register in mcq mode
> patch #5, 6: unchanged
> patch #7: ufshcd_clear_cmds() to ufshcd_clear_cmd()
> ---
> v2->v3:
> patch #1:
>   New patch per Bart's comment. Helps process utp cmd
>   descriptor addr easier.
> patch #2:
>   New patch to address Bart's comment regarding potentialoverflow
>   when mcq queue depth becomes greater than 64.
> patch #3:
>   Address Bart's comments
>   . Replaced ufshcd_mcq_poll_register() with read_poll_timeout()
>   . Replace spin_lock(sq_lock) with mutex(sq_mutex)
>   . Updated ufshcd_mcq_nullify_cmd() and renamed to ufshcd_mcq_nullify_sqe()
>   . Minor cosmetic changes
> patch #4:
>   Adress Bart's comments. Added new function ufshcd_cmd_inflight()
>   to replace the usage of lrbp->cmd
> patch #5:
>   Continue replacing lrbp->cmd with ufshcd_cmd_inflight()
> patch #6:
>   No change
> patch #7:
>   Address Stanley Chu's comment about clearing hba->dev_cmd.complete
>   in clear ufshcd_wait_for_dev_cmd()
>   Address Bart's comment.
> ---
> v1->v2:
> patch #1: Addressed Powen's comment. Replaced read_poll_timeout()
> with ufshcd_mcq_poll_register(). The function read_poll_timeout()
> may sleep while the caller is holding a spin_lock(). Poll the registers
> in a tight loop instead.
> --
> 2.7.4
>

Feel free to add below tags to this series,

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Bao D. Nguyen May 30, 2023, 2:14 a.m. UTC | #2
On 5/29/2023 5:23 PM, Stanley Chu wrote:
> Hi Bao,
> 
> On Tue, May 30, 2023 at 6:14 AM Bao D. Nguyen <quic_nguyenb@quicinc.com> wrote:
>>
>> This patch series enable support for ufshcd_abort() and error handler in MCQ mode.
>>
>> Bao D. Nguyen (7):
>>    ufs: core: Combine 32-bit command_desc_base_addr_lo/hi
>>    ufs: core: Update the ufshcd_clear_cmds() functionality
>>    ufs: mcq: Add supporting functions for mcq abort
>>    ufs: mcq: Add support for clean up mcq resources
>>    ufs: mcq: Added ufshcd_mcq_abort()
>>    ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode
>>    ufs: core: Add error handling for MCQ mode
>>
>>   drivers/ufs/core/ufs-mcq.c     | 259 ++++++++++++++++++++++++++++++++++++++++-
>>   drivers/ufs/core/ufshcd-priv.h |  18 ++-
>>   drivers/ufs/core/ufshcd.c      | 256 ++++++++++++++++++++++++++++++++--------
>>   drivers/ufs/host/ufs-qcom.c    |   2 +-
>>   include/ufs/ufshcd.h           |   5 +-
>>   include/ufs/ufshci.h           |  23 +++-
>>   6 files changed, 501 insertions(+), 62 deletions(-)
>> ---
>> Changes compared to v6:
>> patch #7: Added a new argument force_compl to function ufshcd_mcq_compl_pending_transfer().
>>            Added a new function ufshcd_mcq_compl_all_cqes_lock().
>>            This change is to handle the case where the ufs host controller has been reset by
>>            the ufshcd_hba_stop() in ufshcd_host_reset_and_restore() prior to calling
>>            ufshcd_complete_requests(). The new logic is added to correctly complete all the
>>            commands that have been completed in the Completion Queue, or inform the scsi layer
>>            about those commands that are still stuck/pending in the hardware.
>> ---
>> v5->v6: Addressed Stanley's comments
>> patch #1,2,3,4,6: unchanged.
>> patch #5: fixed extra erroneous if() statement introduced in version v5
>> patch #7: Change ufshcd_complete_requests() to call a new mcq function
>>            ufshcd_mcq_compl_pending_transfer(), leaving ufshcd_transfer_req_compl()
>>            to be used in SDB mode only.
>>
>>            Reset the hwq's head and tail slot variables to default values
>>            when the ufs host controller hw has been reset.
>> ---
>> v4->v5:
>> patch #4: fixed uninitialized variable access introduced in patch v3.
>> ---
>> v3->v4: Mainly addressed Bart's comments
>> patch #1: updated the commit message
>> patch #2: renamed ufshcd_clear_cmds() into ufshcd_clear_cmd()
>> patch #3: removed result arg in ufshcd_mcq_sq_cleanup()
>> patch #4: removed check for "!rq" in ufshcd_cmd_inflight()
>>            avoided access to door bell register in mcq mode
>> patch #5, 6: unchanged
>> patch #7: ufshcd_clear_cmds() to ufshcd_clear_cmd()
>> ---
>> v2->v3:
>> patch #1:
>>    New patch per Bart's comment. Helps process utp cmd
>>    descriptor addr easier.
>> patch #2:
>>    New patch to address Bart's comment regarding potentialoverflow
>>    when mcq queue depth becomes greater than 64.
>> patch #3:
>>    Address Bart's comments
>>    . Replaced ufshcd_mcq_poll_register() with read_poll_timeout()
>>    . Replace spin_lock(sq_lock) with mutex(sq_mutex)
>>    . Updated ufshcd_mcq_nullify_cmd() and renamed to ufshcd_mcq_nullify_sqe()
>>    . Minor cosmetic changes
>> patch #4:
>>    Adress Bart's comments. Added new function ufshcd_cmd_inflight()
>>    to replace the usage of lrbp->cmd
>> patch #5:
>>    Continue replacing lrbp->cmd with ufshcd_cmd_inflight()
>> patch #6:
>>    No change
>> patch #7:
>>    Address Stanley Chu's comment about clearing hba->dev_cmd.complete
>>    in clear ufshcd_wait_for_dev_cmd()
>>    Address Bart's comment.
>> ---
>> v1->v2:
>> patch #1: Addressed Powen's comment. Replaced read_poll_timeout()
>> with ufshcd_mcq_poll_register(). The function read_poll_timeout()
>> may sleep while the caller is holding a spin_lock(). Poll the registers
>> in a tight loop instead.
>> --
>> 2.7.4
>>
> 
> Feel free to add below tags to this series,
> 
> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
> Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Thank you very much, Stanley.
I will add these tags if a new rev is needed.

Thanks,
Bao
Can Guo May 30, 2023, 5:23 a.m. UTC | #3
Hi Bao,

On 5/30/2023 6:12 AM, Bao D. Nguyen wrote:
> This patch series enable support for ufshcd_abort() and error handler in MCQ mode.
>
> Bao D. Nguyen (7):
>    ufs: core: Combine 32-bit command_desc_base_addr_lo/hi
>    ufs: core: Update the ufshcd_clear_cmds() functionality
>    ufs: mcq: Add supporting functions for mcq abort
>    ufs: mcq: Add support for clean up mcq resources
>    ufs: mcq: Added ufshcd_mcq_abort()
>    ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode
>    ufs: core: Add error handling for MCQ mode
>
>   drivers/ufs/core/ufs-mcq.c     | 259 ++++++++++++++++++++++++++++++++++++++++-
>   drivers/ufs/core/ufshcd-priv.h |  18 ++-
>   drivers/ufs/core/ufshcd.c      | 256 ++++++++++++++++++++++++++++++++--------
>   drivers/ufs/host/ufs-qcom.c    |   2 +-
>   include/ufs/ufshcd.h           |   5 +-
>   include/ufs/ufshci.h           |  23 +++-
>   6 files changed, 501 insertions(+), 62 deletions(-)
> ---
> Changes compared to v6:
> patch #7: Added a new argument force_compl to function ufshcd_mcq_compl_pending_transfer().
>            Added a new function ufshcd_mcq_compl_all_cqes_lock().
> 	  This change is to handle the case where the ufs host controller has been reset by
> 	  the ufshcd_hba_stop() in ufshcd_host_reset_and_restore() prior to calling
> 	  ufshcd_complete_requests(). The new logic is added to correctly complete all the
> 	  commands that have been completed in the Completion Queue, or inform the scsi layer
> 	  about those commands that are still stuck/pending in the hardware.
> ---

Feel free to my Reviewed-by tag to this series,

Reviewed-by: Can Guo<quic_cang@quicinc.com>


Thanks.
Regards,
Can Guo.
Martin K. Petersen June 1, 2023, 12:23 a.m. UTC | #4
Bao,

> This patch series enable support for ufshcd_abort() and error handler
> in MCQ mode.

Applied to 6.5/scsi-staging, thanks!
Martin K. Petersen June 8, 2023, 1:42 a.m. UTC | #5
On Mon, 29 May 2023 15:12:19 -0700, Bao D. Nguyen wrote:

> This patch series enable support for ufshcd_abort() and error handler in MCQ mode.
> 
> Bao D. Nguyen (7):
>   ufs: core: Combine 32-bit command_desc_base_addr_lo/hi
>   ufs: core: Update the ufshcd_clear_cmds() functionality
>   ufs: mcq: Add supporting functions for mcq abort
>   ufs: mcq: Add support for clean up mcq resources
>   ufs: mcq: Added ufshcd_mcq_abort()
>   ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode
>   ufs: core: Add error handling for MCQ mode
> 
> [...]

Applied to 6.5/scsi-queue, thanks!

[1/7] ufs: core: Combine 32-bit command_desc_base_addr_lo/hi
      https://git.kernel.org/mkp/scsi/c/a8f9a36e4634
[2/7] ufs: core: Update the ufshcd_clear_cmds() functionality
      https://git.kernel.org/mkp/scsi/c/7aa12d2fe89d
[3/7] ufs: mcq: Add supporting functions for mcq abort
      https://git.kernel.org/mkp/scsi/c/8d7290348992
[4/7] ufs: mcq: Add support for clean up mcq resources
      https://git.kernel.org/mkp/scsi/c/adf452611677
[5/7] ufs: mcq: Added ufshcd_mcq_abort()
      https://git.kernel.org/mkp/scsi/c/f1304d442077
[6/7] ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode
      https://git.kernel.org/mkp/scsi/c/57d6ef4601c0
[7/7] ufs: core: Add error handling for MCQ mode
      https://git.kernel.org/mkp/scsi/c/ab248643d3d6