From: "Neronin, Niklas" <niklas.neronin@linux.intel.com>
To: "Michał Pecio" <michal.pecio@gmail.com>
Cc: mathias.nyman@linux.intel.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] usb: xhci: improve TR Dequeue Pointer mask
Date: Tue, 2 Sep 2025 15:26:13 +0300 [thread overview]
Message-ID: <5d2fbba0-63f3-444a-adfc-b0773bf20774@linux.intel.com> (raw)
In-Reply-To: <20250828101207.49aea3b5.michal.pecio@gmail.com>
On 28/08/2025 11.12, Michał Pecio wrote:
> On Tue, 26 Aug 2025 15:06:56 +0200, Niklas Neronin wrote:
>> Address the naming and usage of the TR Dequeue Pointer mask in the xhci
>> driver. The Endpoint Context Field at offset 0x08 is defined as follows:
>> Bit 0 Dequeue Cycle State (DCS)
>> Bits 3:1 RsvdZ (Reserved and Zero)
>> Bits 63:4 TR Dequeue Pointer
>>
>> When extracting the TR Dequeue Pointer for an Endpoint without Streams,
>> in xhci_handle_cmd_set_deq(), the inverted Dequeue Cycle State mask
>> (~EP_CTX_CYCLE_MASK) is used, inadvertently including the Reserved bits.
>> Although bits 3:1 are typically zero, using the incorrect mask could cause
>> issues.
>>
>> The existing mask, named "SCTX_DEQ_MASK," is misleading because "SCTX"
>> implies exclusivity to Stream Contexts, whereas the TR Dequeue Pointer is
>> applicable to both Stream and non-Stream Contexts.
>>
>> Rename the mask to "TR_DEQ_PTR_MASK", utilize GENMASK_ULL() macro and use
>> the mask when handling the TR Dequeue Pointer field.
>>
>> Function xhci_get_hw_deq() returns the Endpoint Context Field 0x08, either
>> directly from the Endpoint context or a Stream.
>>
>> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
>> ---
...
>
>> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
>> index a20f4e7cd43a..59ff84ba2d4a 100644
>> --- a/drivers/usb/host/xhci.h
>> +++ b/drivers/usb/host/xhci.h
>> @@ -500,7 +500,8 @@ struct xhci_ep_ctx {
>>
>> /* deq bitmasks */
>> #define EP_CTX_CYCLE_MASK (1 << 0)
>> -#define SCTX_DEQ_MASK (~0xfL)
>> +/* bits 63:4 - TR Dequeue Pointer */
>> +#define TR_DEQ_PTR_MASK GENMASK_ULL(63, 4)
>
> I don't care much about this rename, but I can't help but notice that
> naming is not consistent with the related EP_CTX_CYCLE_MASK above and
> that it too applies to both types of contexts.
>
> If I wanted to fix this, I would just drop the 'EP_' and 'S' prefixes.
I have an Endpoint Context patch series in progress that will address all
Endpoint Context macro naming, comments, and related issues.
Because, this patch set is quite old, v1 sent in February this year, all
my current patches are built and tested on top of it, so this is why I
am sending it first.
Best Regards,
Niklas
prev parent reply other threads:[~2025-09-02 12:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 13:06 [PATCH v2] usb: xhci: improve TR Dequeue Pointer mask Niklas Neronin
2025-08-28 8:12 ` Michał Pecio
2025-09-02 12:26 ` Neronin, Niklas [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=5d2fbba0-63f3-444a-adfc-b0773bf20774@linux.intel.com \
--to=niklas.neronin@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=michal.pecio@gmail.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;
as well as URLs for NNTP newsgroup(s).