[PATCH v1] ufs: core: decouple CQE processing from spinlock critical section
Peter Wang (王信友)
peter.wang at mediatek.com
Fri May 15 01:13:47 PDT 2026
On Thu, 2026-05-14 at 09:22 -0700, Bart Van Assche wrote:
> On 5/14/26 1:26 AM, peter.wang at mediatek.com wrote:
> > 4. In both ufshcd_mcq_compl_all_cqes_lock() and
> > ufshcd_mcq_poll_cqe_lock(), snapshot the starting CQE pointer
> > before
> > advancing the head slot under the spinlock, then process the
> > collected
> > CQEs after releasing the lock using the new helper.
>
> This can't work reliably. ufshcd_mcq_poll_cqe_lock() may be called
> concurrently from different CPU cores, e.g. from a UFS completion
> interrupt and from ufshcd_poll(). Processing CQEs without holding
> hwq->cq_lock may lead to overwriting of CQEs before these have been
> processed.
>
> Thanks,
>
> Bart.
Hi Bart,
This is not an issue because the CQ head is protected by cq_lock.
Only the CQEs from head to tail will be processed by ufshcd_poll
or the ISR. The main difference is that these CQEs will be
processed later, without holding the cq_lock.
Thanks
Peter
More information about the Linux-mediatek
mailing list