All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeuk Kim <jeuk20.kim@gmail.com>
To: Stanley Jhu <stanleyjhu@google.com>, Jeuk Kim <jeuk20.kim@samsung.com>
Cc: qemu-devel@nongnu.org, Jinyoung Choi <j-young.choi@samsung.com>
Subject: Re: [PATCH v3] hw/ufs: Reset controller and MCQ state on HCE transition to 0
Date: Thu, 3 Sep 2026 15:06:42 +0900	[thread overview]
Message-ID: <21bbbab6-192b-4243-980e-4167b450c478@gmail.com> (raw)
In-Reply-To: <20260902081610.2290123-1-stanleyjhu@google.com>


On 9/2/2026 5:16 PM, Stanley Jhu wrote:
> According to the JEDEC Universal Flash Storage Host Controller Interface
> (UFSHCI) specification (Section 5.2.1 "Host Controller Enable"):
> when Host Controller Enable (HCE) transitions from 1 to 0, a host
> controller reset is initiated. The host controller shall abort all
> active transfers, return internal state machines to idle, and de-assert
> all interrupts.
>
> Currently, QEMU's UFS emulator only clears HCS and HCE registers upon
> HCE=0, leaving internal state active. Specifically:
> - Outstanding SCSI requests in the block layer are not purged.
> - Active bottom halves (doorbell_bh, complete_bh, and MCQ sq/cq BHs)
>    remain scheduled.
> - Allocated MCQ Submission and Completion Queues (sq and cq) are
>    not freed.
> - Dynamic MCQ queue registers, legacy UTRL request states, and status
>    registers (UTRLCNR, UTRLRSR) remain stale.
>
> Implement ufs_hce_reset() to:
> 1. Implement .cancel callback in ufs_scsi_info to properly unref
>     scsi_req and prevent reference leaks when SCSI requests are purged.
> 2. Cancel active bottom halves (doorbell_bh, complete_bh, and MCQ sq/cq
>     BHs) and guard them with a resetting flag before purging requests,
>     ensuring blk_drain() cannot run or reschedule request-producing BHs.
> 3. Purge outstanding SCSI requests for all logical units via
>     scsi_device_purge_requests().
> 4. Clear standard request list slots and release SGLs via
>     ufs_clear_req(), and clear doorbells and status registers (UTRLCNR,
>     UTRLRSR).
> 5. Free allocated MCQ queues and clear dynamic queue registers while
>     preserving static capability offsets.
> 6. De-assert interrupts via ufs_irq_check().
> 7. Add a trace_ufs_hce_reset() trace event.
>
> Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
> ---


Thank you for your contribution.

Reviewed-by: Jeuk Kim <jeuk20.kim@samsung.com>




  reply	other threads:[~2026-09-03  6:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  8:16 [PATCH v3] hw/ufs: Reset controller and MCQ state on HCE transition to 0 Stanley Jhu
2026-09-03  6:06 ` Jeuk Kim [this message]
2026-09-17 12:22   ` Stanley Jhu
2026-09-17 14:41     ` Stefan Hajnoczi
2026-09-21 13:58       ` Jeuk Kim
2026-09-18  0:12     ` Jeuk Kim

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=21bbbab6-192b-4243-980e-4167b450c478@gmail.com \
    --to=jeuk20.kim@gmail.com \
    --cc=j-young.choi@samsung.com \
    --cc=jeuk20.kim@samsung.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stanleyjhu@google.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.