From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 6/9] usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET()
Date: Tue, 8 Sep 2020 15:39:00 +0800 [thread overview]
Message-ID: <1599550740.11403.49.camel@mhfsdcap03> (raw)
In-Reply-To: <CAEUhbmWTSVPHDOGMwki=X6nJ1buniLQ0Ke1HM8ZxgG-PWkMbeQ@mail.gmail.com>
On Tue, 2020-09-08 at 09:30 +0800, Bin Meng wrote:
> On Mon, Sep 7, 2020 at 3:14 PM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
> >
> > For normal TRB fields:
> > use TRB_LEN(x) instead of ((x) & TRB_LEN_MASK);
> > and use TRB_INTR_TARGET(x) instead of
> > (((x) & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT)
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> > v3: merge patch [v2 6/11] and [v2 7/11] into one, both for normal TRB fileds
> >
> > v2: no changes
> > ---
> > drivers/usb/host/xhci-ring.c | 16 +++++++---------
> > include/usb/xhci.h | 3 ---
> > 2 files changed, 7 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> > index 87891fd..99c84f9 100644
> > --- a/drivers/usb/host/xhci-ring.c
> > +++ b/drivers/usb/host/xhci-ring.c
> > @@ -688,10 +688,9 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
> > length, maxpacketsize,
> > more_trbs_coming);
> >
> > - length_field = ((trb_buff_len & TRB_LEN_MASK) |
> > + length_field = (TRB_LEN(trb_buff_len) |
> > TRB_TD_SIZE(remainder) |
> > - ((0 & TRB_INTR_TARGET_MASK) <<
> > - TRB_INTR_TARGET_SHIFT));
> > + TRB_INTR_TARGET(0));
>
> nits: should be aligned to TRB_LEN(length)
Ok, will check it again
>
> >
> > trb_fields[0] = lower_32_bits(addr);
> > trb_fields[1] = upper_32_bits(addr);
> > @@ -849,8 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
> > trb_fields[1] = le16_to_cpu(req->index) |
> > le16_to_cpu(req->length) << 16;
> > /* TRB_LEN | (TRB_INTR_TARGET) */
> > - trb_fields[2] = (8 | ((0 & TRB_INTR_TARGET_MASK) <<
> > - TRB_INTR_TARGET_SHIFT));
> > + trb_fields[2] = (TRB_LEN(8) | TRB_INTR_TARGET(0));
> > /* Immediate data in pointer */
> > trb_fields[3] = field;
> > queue_trb(ctrl, ep_ring, true, trb_fields);
> > @@ -866,11 +864,11 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
> >
> > remainder = xhci_td_remainder(ctrl, 0, length, length,
> > usb_maxpacket(udev, pipe), 1);
> > - length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
> > - ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
> > + length_field = TRB_LEN(length) | TRB_TD_SIZE(remainder) |
> > + TRB_INTR_TARGET(0);
> > debug("length_field = %d, length = %d,"
> > "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
> > - length_field, (length & TRB_LEN_MASK),
> > + length_field, TRB_LEN(length),
> > TRB_TD_SIZE(remainder), 0);
> >
> > if (length > 0) {
> > @@ -901,7 +899,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
> >
> > trb_fields[0] = 0;
> > trb_fields[1] = 0;
> > - trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
> > + trb_fields[2] = TRB_INTR_TARGET(0);
> > /* Event on completion */
> > trb_fields[3] = field | TRB_IOC |
> > TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
> > diff --git a/include/usb/xhci.h b/include/usb/xhci.h
> > index bdba51d..35c6604 100644
> > --- a/include/usb/xhci.h
> > +++ b/include/usb/xhci.h
> > @@ -847,12 +847,9 @@ struct xhci_event_cmd {
> > /* Normal TRB fields */
> > /* transfer_len bitmasks - bits 0:16 */
> > #define TRB_LEN(p) ((p) & 0x1ffff)
> > -#define TRB_LEN_MASK (0x1ffff)
> > /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
> > #define TRB_TD_SIZE(p) (min((p), (u32)31) << 17)
> > /* Interrupter Target - which MSI-X vector to target the completion event at */
> > -#define TRB_INTR_TARGET_SHIFT (22)
> > -#define TRB_INTR_TARGET_MASK (0x3ff)
> > #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
> > #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
> > #define TRB_TBC(p) (((p) & 0x3) << 7)
> > --
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Thanks
next prev parent reply other threads:[~2020-09-08 7:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 7:11 [PATCH v3 1/9] usb: xhci: add a member hci_version in xhci_ctrl struct Chunfeng Yun
2020-09-07 7:12 ` [PATCH v3 2/9] usb: xhci: create one unified function to calculate TRB TD remainder Chunfeng Yun
2020-09-08 5:41 ` Bin Meng
2020-09-08 7:40 ` Chunfeng Yun
2020-09-07 7:12 ` [PATCH v3 3/9] usb: xhci: add quirks flag to support MediaTek xHCI 0.96 Chunfeng Yun
2020-09-07 7:12 ` [PATCH v3 4/9] usb: xhci: convert to HCS_MAX_PORTS() Chunfeng Yun
2020-09-07 7:12 ` [PATCH v3 5/9] usb: xhci: convert to TRB_TYPE() Chunfeng Yun
2020-09-07 7:12 ` [PATCH v3 6/9] usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET() Chunfeng Yun
2020-09-08 1:30 ` Bin Meng
2020-09-08 7:39 ` Chunfeng Yun [this message]
2020-09-07 7:12 ` [PATCH v3 7/9] usb: xhci: convert to TRB_TX_TYPE() Chunfeng Yun
2020-09-08 1:31 ` Bin Meng
2020-09-07 7:12 ` [PATCH v3 8/9] usb: xhci: use macros with parameter to fill ep_info2 Chunfeng Yun
2020-09-08 1:35 ` Bin Meng
2020-09-07 7:12 ` [PATCH v3 9/9] usb: xhci: convert to readx_poll_sleep_timeout() Chunfeng Yun
2020-09-08 1:44 ` Bin Meng
2020-09-08 11:13 ` Marek Vasut
2020-09-08 11:24 ` Chunfeng Yun
2020-09-08 15:45 ` Bin Meng
2020-09-08 16:15 ` Marek Vasut
2020-09-08 16:34 ` Frank Wunderlich
2020-09-08 16:47 ` Marek Vasut
2020-09-08 17:14 ` Frank Wunderlich
2020-09-08 17:30 ` Marek Vasut
2020-09-09 1:55 ` Bin Meng
2020-09-09 10:00 ` Marek Vasut
2020-09-09 13:46 ` Bin Meng
2020-09-09 14:02 ` Marek Vasut
2020-09-09 14:05 ` Bin Meng
2020-09-09 14:16 ` Tom Rini
2020-09-09 14:16 ` Marek Vasut
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=1599550740.11403.49.camel@mhfsdcap03 \
--to=chunfeng.yun@mediatek.com \
--cc=u-boot@lists.denx.de \
/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