Skip to contentSkip to conversation

usb: xhci: add a member hci_version in xhci_ctrl struct

PATCH Superseded Chunfeng Yun 5 participants 31 messages Sep 7, 2020 – Sep 9, 2020

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Chunfeng Yun

author maintainer
#0 lore raw

PATCH v3 1/9 usb: xhci: add a member hci_version in xhci_ctrl struct

Add a member to save xHCI version, it's used some times.

---
v3: add reviewed-by Bin

v2: no changes

---
 drivers/usb/host/xhci-ring.c | 4 ++--
 drivers/usb/host/xhci.c      | 1 +
 include/usb/xhci.h           | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-ring.c +2 -2
index 092ed6e..79bfc34 100644
@@ -682,7 +682,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
 			field |= TRB_ISP;
 
 		/* Set the TRB length, TD size, and interrupter fields. */
-		if (HC_VERSION(xhci_readl(&ctrl->hccr->cr_capbase)) < 0x100)
+		if (ctrl->hci_version < 0x100)
 			remainder = xhci_td_remainder(length - running_total);
 		else
 			remainder = xhci_v1_0_td_remainder(running_total,
@@ -830,7 +830,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 		field |= 0x1;
 
 	/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-	if (HC_VERSION(xhci_readl(&ctrl->hccr->cr_capbase)) >= 0x100) {
+	if (ctrl->hci_version >= 0x100) {
 		if (length > 0) {
 			if (req->requesttype & USB_DIR_IN)
 				field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
drivers/usb/host/xhci.c +1 -0
index 126dabc..4be1411 100644
@@ -1283,6 +1283,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
 
 	reg = HC_VERSION(xhci_readl(&hccr->cr_capbase));
 	printf("USB XHCI %x.%02x\n", reg >> 8, reg & 0xff);
+	ctrl->hci_version = reg;
 
 	return 0;
 }
include/usb/xhci.h +1 -0
index 7d34103..a3e5914 100644
@@ -1227,6 +1227,7 @@ struct xhci_ctrl {
 	struct xhci_scratchpad *scratchpad;
 	struct xhci_virt_device *devs[MAX_HC_SLOTS];
 	int rootdev;
+	u16 hci_version;
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH v3 2/9 usb: xhci: create one unified function to calculate TRB TD remainder.

xhci versions 1.0 and later report the untransferred data remaining in a TD a bit differently than older hosts.

We used to have separate functions for these, and needed to check host version before calling the right function.

Now Mediatek host has an additional quirk on how it uses the TD Size field for remaining data. To prevent yet another function for calculating remainder we instead want to make one quirk friendly unified function.

Porting from the Linux:
c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.") 124c39371114("xhci: use boolean to indicate last trb in td remainder calculation")

---
v2~v3: no changes

---
 drivers/usb/host/xhci-ring.c | 105 +++++++++++++++++++++----------------------
 include/usb/xhci.h           |   2 +
 2 files changed, 52 insertions(+), 55 deletions(-)
drivers/usb/host/xhci-ring.c +50 -55
index 79bfc34..0f86b01 100644
@@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, u32 slot_id,
 	xhci_writel(&ctrl->dba->doorbell[0], DB_VALUE_HOST);
 }
 
-/**
- * The TD size is the number of bytes remaining in the TD (including this TRB),
- * right shifted by 10.
- * It must fit in bits 21:17, so it can't be bigger than 31.
+/*
+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
+ * packets remaining in the TD (*not* including this TRB).
  *
- * @param remainder	remaining packets to be sent
- * @return remainder if remainder is less than max else max
- */
-static u32 xhci_td_remainder(unsigned int remainder)
-{
-	u32 max = (1 << (21 - 17 + 1)) - 1;
-
-	if ((remainder >> 10) >= max)
-		return max << 17;
-	else
-		return (remainder >> 10) << 17;
-}
-
-/**
- * Finds out the remanining packets to be sent
+ * Total TD packet count = total_packet_count =
+ *     DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
+ *
+ * Packets transferred up to and including this TRB = packets_transferred =
+ *     rounddown(total bytes transferred including this TRB / wMaxPacketSize)
+ *
+ * TD size = total_packet_count - packets_transferred
  *
- * @param running_total	total size sent so far
+ * For xHCI 0.96 and older, TD size field should be the remaining bytes
+ * including this TRB, right shifted by 10
+ *
+ * For all hosts it must fit in bits 21:17, so it can't be bigger than 31.
+ * This is taken care of in the TRB_TD_SIZE() macro
+ *
+ * The last TRB in a TD must have the TD size set to zero.
+ *
+ * @param ctrl	host controller data structure
+ * @param transferred	total size sent so far
  * @param trb_buff_len	length of the TRB Buffer
- * @param total_packet_count	total packet count
- * @param maxpacketsize		max packet size of current pipe
- * @param num_trbs_left		number of TRBs left to be processed
- * @return 0 if running_total or trb_buff_len is 0, else remainder
+ * @param td_total_len	total packet count
+ * @param maxp	max packet size of current pipe
+ * @param more_trbs_coming	indicate last trb in TD
+ * @return remainder
  */
-static u32 xhci_v1_0_td_remainder(int running_total,
-				int trb_buff_len,
-				unsigned int total_packet_count,
-				int maxpacketsize,
-				unsigned int num_trbs_left)
+static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
+			     int trb_buff_len, unsigned int td_total_len,
+			     int maxp, bool more_trbs_coming)
 {
-	int packets_transferred;
+	u32 total_packet_count;
+
+	if (ctrl->hci_version < 0x100)
+		return ((td_total_len - transferred) >> 10);
 
 	/* One TRB with a zero-length data packet. */
-	if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
+	if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
+	    trb_buff_len == td_total_len)
 		return 0;
 
-	/*
-	 * All the TRB queueing functions don't count the current TRB in
-	 * running_total.
-	 */
-	packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
+	total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
-	if ((total_packet_count - packets_transferred) > 31)
-		return 31 << 17;
-	return (total_packet_count - packets_transferred) << 17;
+	/* Queueing functions don't count the current TRB into transferred */
+	return (total_packet_count - ((transferred + trb_buff_len) / maxp));
 }
 
 /**
@@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
 	union xhci_trb *event;
 
 	int running_total, trb_buff_len;
-	unsigned int total_packet_count;
+	bool more_trbs_coming = true;
 	int maxpacketsize;
 	u64 addr;
 	int ret;
@@ -636,8 +633,6 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
 	running_total = 0;
 	maxpacketsize = usb_maxpacket(udev, pipe);
 
-	total_packet_count = DIV_ROUND_UP(length, maxpacketsize);
-
 	/* How much data is in the first TRB? */
 	/*
 	 * How much data is (potentially) left before the 64KB boundary?
@@ -672,27 +667,24 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
 		 * Chain all the TRBs together; clear the chain bit in the last
 		 * TRB to indicate it's the last TRB in the chain.
 		 */
-		if (num_trbs > 1)
+		if (num_trbs > 1) {
 			field |= TRB_CHAIN;
-		else
+		} else {
 			field |= TRB_IOC;
+			more_trbs_coming = false;
+		}
 
 		/* Only set interrupt on short packet for IN endpoints */
 		if (usb_pipein(pipe))
 			field |= TRB_ISP;
 
 		/* Set the TRB length, TD size, and interrupter fields. */
-		if (ctrl->hci_version < 0x100)
-			remainder = xhci_td_remainder(length - running_total);
-		else
-			remainder = xhci_v1_0_td_remainder(running_total,
-							   trb_buff_len,
-							   total_packet_count,
-							   maxpacketsize,
-							   num_trbs - 1);
+		remainder = xhci_td_remainder(ctrl, running_total, trb_buff_len,
+					      length, maxpacketsize,
+					      more_trbs_coming);
 
 		length_field = ((trb_buff_len & TRB_LEN_MASK) |
-				remainder |
+				TRB_TD_SIZE(remainder) |
 				((0 & TRB_INTR_TARGET_MASK) <<
 				TRB_INTR_TARGET_SHIFT));
 
@@ -764,6 +756,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	struct xhci_virt_device *virt_dev = ctrl->devs[slot_id];
 	struct xhci_ring *ep_ring;
 	union xhci_trb *event;
+	u32 remainder;
 
 	debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
 		req->request, req->request,
@@ -866,12 +859,14 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	else
 		field = (TRB_DATA << TRB_TYPE_SHIFT);
 
-	length_field = (length & TRB_LEN_MASK) | xhci_td_remainder(length) |
+	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);
 	debug("length_field = %d, length = %d,"
 		"xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
 		length_field, (length & TRB_LEN_MASK),
-		xhci_td_remainder(length), 0);
+		TRB_TD_SIZE(remainder), 0);
 
 	if (length > 0) {
 		if (req->requesttype & USB_DIR_IN)
include/usb/xhci.h +2 -0
index a3e5914..15926eb 100644
@@ -850,6 +850,8 @@ struct xhci_event_cmd {
 /* 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@*/
 #define	TRB_INTR_TARGET_SHIFT		(22)
 #define	TRB_INTR_TARGET_MASK		(0x3ff)
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/9 usb: xhci: create one unified function to calculate TRB TD remainder.

Quoted 1 line · Chunfeng Yun

nits: please remove the ending period in the commit title

Quoted 181 lines

xhci versions 1.0 and later report the untransferred data remaining in a TD a bit differently than older hosts.

We used to have separate functions for these, and needed to check host version before calling the right function.

Now Mediatek host has an additional quirk on how it uses the TD Size field for remaining data. To prevent yet another function for calculating remainder we instead want to make one quirk friendly unified function.

Porting from the Linux:
c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.") 124c39371114("xhci: use boolean to indicate last trb in td remainder calculation")

---
v2~v3: no changes

---
 drivers/usb/host/xhci-ring.c | 105 +++++++++++++++++++++----------------------
 include/usb/xhci.h           |   2 +
 2 files changed, 52 insertions(+), 55 deletions(-)
drivers/usb/host/xhci-ring.c +46 -53
index 79bfc34..0f86b01 100644
@@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, u32 slot_id,
        xhci_writel(&ctrl->dba->doorbell[0], DB_VALUE_HOST);
 }
 
-/**
- * The TD size is the number of bytes remaining in the TD (including this TRB),
- * right shifted by 10.
- * It must fit in bits 21:17, so it can't be bigger than 31.
+/*
+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
+ * packets remaining in the TD (*not* including this TRB).
  *
- * @param remainder    remaining packets to be sent
- * @return remainder if remainder is less than max else max
- */
-static u32 xhci_td_remainder(unsigned int remainder)
-{
-       u32 max = (1 << (21 - 17 + 1)) - 1;
-
-       if ((remainder >> 10) >= max)
-               return max << 17;
-       else
-               return (remainder >> 10) << 17;
-}
-
-/**
- * Finds out the remanining packets to be sent
+ * Total TD packet count = total_packet_count =
+ *     DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
+ *
+ * Packets transferred up to and including this TRB = packets_transferred =
+ *     rounddown(total bytes transferred including this TRB / wMaxPacketSize)
+ *
+ * TD size = total_packet_count - packets_transferred
  *
- * @param running_total        total size sent so far
+ * For xHCI 0.96 and older, TD size field should be the remaining bytes
+ * including this TRB, right shifted by 10
+ *
+ * For all hosts it must fit in bits 21:17, so it can't be bigger than 31.
+ * This is taken care of in the TRB_TD_SIZE() macro
+ *
+ * The last TRB in a TD must have the TD size set to zero.
+ *
+ * @param ctrl host controller data structure
+ * @param transferred  total size sent so far
  * @param trb_buff_len length of the TRB Buffer
- * @param total_packet_count   total packet count
- * @param maxpacketsize                max packet size of current pipe
- * @param num_trbs_left                number of TRBs left to be processed
- * @return 0 if running_total or trb_buff_len is 0, else remainder
+ * @param td_total_len total packet count
+ * @param maxp max packet size of current pipe
+ * @param more_trbs_coming     indicate last trb in TD
+ * @return remainder
  */
-static u32 xhci_v1_0_td_remainder(int running_total,
-                               int trb_buff_len,
-                               unsigned int total_packet_count,
-                               int maxpacketsize,
-                               unsigned int num_trbs_left)
+static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
+                            int trb_buff_len, unsigned int td_total_len,
+                            int maxp, bool more_trbs_coming)
 {
-       int packets_transferred;
+       u32 total_packet_count;
+
+       if (ctrl->hci_version < 0x100)
+               return ((td_total_len - transferred) >> 10);
 
        /* One TRB with a zero-length data packet. */
-       if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
+       if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
+           trb_buff_len == td_total_len)
                return 0;
 
-       /*
-        * All the TRB queueing functions don't count the current TRB in
-        * running_total.
-        */
-       packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
+       total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
-       if ((total_packet_count - packets_transferred) > 31)
-               return 31 << 17;
-       return (total_packet_count - packets_transferred) << 17;
+       /* Queueing functions don't count the current TRB into transferred */
+       return (total_packet_count - ((transferred + trb_buff_len) / maxp));
 }
 
 /**
@@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
        union xhci_trb *event;
 
        int running_total, trb_buff_len;
-       unsigned int total_packet_count;
+       bool more_trbs_coming = true;
        int maxpacketsize;
        u64 addr;
        int ret;
@@ -636,8 +633,6 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
        running_total = 0;
        maxpacketsize = usb_maxpacket(udev, pipe);
 
-       total_packet_count = DIV_ROUND_UP(length, maxpacketsize);
-
        /* How much data is in the first TRB? */
        /*
         * How much data is (potentially) left before the 64KB boundary?
@@ -672,27 +667,24 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
                 * Chain all the TRBs together; clear the chain bit in the last
                 * TRB to indicate it's the last TRB in the chain.
                 */
-               if (num_trbs > 1)
+               if (num_trbs > 1) {
                        field |= TRB_CHAIN;
-               else
+               } else {
                        field |= TRB_IOC;
+                       more_trbs_coming = false;
+               }
 
                /* Only set interrupt on short packet for IN endpoints */
                if (usb_pipein(pipe))
                        field |= TRB_ISP;
 
                /* Set the TRB length, TD size, and interrupter fields. */
-               if (ctrl->hci_version < 0x100)
-                       remainder = xhci_td_remainder(length - running_total);
-               else
-                       remainder = xhci_v1_0_td_remainder(running_total,
-                                                          trb_buff_len,
-                                                          total_packet_count,
-                                                          maxpacketsize,
-                                                          num_trbs - 1);
+               remainder = xhci_td_remainder(ctrl, running_total, trb_buff_len,
+                                             length, maxpacketsize,
+                                             more_trbs_coming);
 
                length_field = ((trb_buff_len & TRB_LEN_MASK) |
-                               remainder |
+                               TRB_TD_SIZE(remainder) |
                                ((0 & TRB_INTR_TARGET_MASK) <<
                                TRB_INTR_TARGET_SHIFT));
 
@@ -764,6 +756,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
        struct xhci_virt_device *virt_dev = ctrl->devs[slot_id];
        struct xhci_ring *ep_ring;
        union xhci_trb *event;
+       u32 remainder;
 
        debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
                req->request, req->request,

drivers/usb/host/xhci-ring.c int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, · line 863

Quoted 6 lines
drivers/usb/host/xhci-ring.c +2 -1
@@ -866,12 +859,14 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
        else
                field = (TRB_DATA << TRB_TYPE_SHIFT);
 
-       length_field = (length & TRB_LEN_MASK) | xhci_td_remainder(length) |
+       remainder = xhci_td_remainder(ctrl, 0, length, length,
+                                     usb_maxpacket(udev, pipe), 1);

1 should be true

Quoted 15 lines
drivers/usb/host/xhci-ring.c +2 -1
+       length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
                        ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
        debug("length_field = %d, length = %d,"
                "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
                length_field, (length & TRB_LEN_MASK),
-               xhci_td_remainder(length), 0);
+               TRB_TD_SIZE(remainder), 0);
 
        if (length > 0) {
                if (req->requesttype & USB_DIR_IN)
include/usb/xhci.h +0 -0
index a3e5914..15926eb 100644

include/usb/xhci.h struct xhci_event_cmd { · line 857

Quoted 8 lines
include/usb/xhci.h +2 -0
@@ -850,6 +850,8 @@ struct xhci_event_cmd {
 /* 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)

Otherwise,

author maintainer
#3 lore raw

PATCH v3 2/9 usb: xhci: create one unified function to calculate TRB TD remainder.

Quoted 4 lines · Bin Meng
Quoted 1 line · Chunfeng Yun

nits: please remove the ending period in the commit title

Ok, will fix it

Quoted 185 lines
Quoted 185 lines

xhci versions 1.0 and later report the untransferred data remaining in a TD a bit differently than older hosts.

We used to have separate functions for these, and needed to check host version before calling the right function.

Now Mediatek host has an additional quirk on how it uses the TD Size field for remaining data. To prevent yet another function for calculating remainder we instead want to make one quirk friendly unified function.

Porting from the Linux:
c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.") 124c39371114("xhci: use boolean to indicate last trb in td remainder calculation")

---
v2~v3: no changes

---
 drivers/usb/host/xhci-ring.c | 105 +++++++++++++++++++++----------------------
 include/usb/xhci.h           |   2 +
 2 files changed, 52 insertions(+), 55 deletions(-)
drivers/usb/host/xhci-ring.c +46 -53
index 79bfc34..0f86b01 100644
@@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, u32 slot_id,
        xhci_writel(&ctrl->dba->doorbell[0], DB_VALUE_HOST);
 }
 
-/**
- * The TD size is the number of bytes remaining in the TD (including this TRB),
- * right shifted by 10.
- * It must fit in bits 21:17, so it can't be bigger than 31.
+/*
+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
+ * packets remaining in the TD (*not* including this TRB).
  *
- * @param remainder    remaining packets to be sent
- * @return remainder if remainder is less than max else max
- */
-static u32 xhci_td_remainder(unsigned int remainder)
-{
-       u32 max = (1 << (21 - 17 + 1)) - 1;
-
-       if ((remainder >> 10) >= max)
-               return max << 17;
-       else
-               return (remainder >> 10) << 17;
-}
-
-/**
- * Finds out the remanining packets to be sent
+ * Total TD packet count = total_packet_count =
+ *     DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
+ *
+ * Packets transferred up to and including this TRB = packets_transferred =
+ *     rounddown(total bytes transferred including this TRB / wMaxPacketSize)
+ *
+ * TD size = total_packet_count - packets_transferred
  *
- * @param running_total        total size sent so far
+ * For xHCI 0.96 and older, TD size field should be the remaining bytes
+ * including this TRB, right shifted by 10
+ *
+ * For all hosts it must fit in bits 21:17, so it can't be bigger than 31.
+ * This is taken care of in the TRB_TD_SIZE() macro
+ *
+ * The last TRB in a TD must have the TD size set to zero.
+ *
+ * @param ctrl host controller data structure
+ * @param transferred  total size sent so far
  * @param trb_buff_len length of the TRB Buffer
- * @param total_packet_count   total packet count
- * @param maxpacketsize                max packet size of current pipe
- * @param num_trbs_left                number of TRBs left to be processed
- * @return 0 if running_total or trb_buff_len is 0, else remainder
+ * @param td_total_len total packet count
+ * @param maxp max packet size of current pipe
+ * @param more_trbs_coming     indicate last trb in TD
+ * @return remainder
  */
-static u32 xhci_v1_0_td_remainder(int running_total,
-                               int trb_buff_len,
-                               unsigned int total_packet_count,
-                               int maxpacketsize,
-                               unsigned int num_trbs_left)
+static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
+                            int trb_buff_len, unsigned int td_total_len,
+                            int maxp, bool more_trbs_coming)
 {
-       int packets_transferred;
+       u32 total_packet_count;
+
+       if (ctrl->hci_version < 0x100)
+               return ((td_total_len - transferred) >> 10);
 
        /* One TRB with a zero-length data packet. */
-       if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
+       if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
+           trb_buff_len == td_total_len)
                return 0;
 
-       /*
-        * All the TRB queueing functions don't count the current TRB in
-        * running_total.
-        */
-       packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
+       total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
-       if ((total_packet_count - packets_transferred) > 31)
-               return 31 << 17;
-       return (total_packet_count - packets_transferred) << 17;
+       /* Queueing functions don't count the current TRB into transferred */
+       return (total_packet_count - ((transferred + trb_buff_len) / maxp));
 }
 
 /**
@@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
        union xhci_trb *event;
 
        int running_total, trb_buff_len;
-       unsigned int total_packet_count;
+       bool more_trbs_coming = true;
        int maxpacketsize;
        u64 addr;
        int ret;
@@ -636,8 +633,6 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
        running_total = 0;
        maxpacketsize = usb_maxpacket(udev, pipe);
 
-       total_packet_count = DIV_ROUND_UP(length, maxpacketsize);
-
        /* How much data is in the first TRB? */
        /*
         * How much data is (potentially) left before the 64KB boundary?
@@ -672,27 +667,24 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
                 * Chain all the TRBs together; clear the chain bit in the last
                 * TRB to indicate it's the last TRB in the chain.
                 */
-               if (num_trbs > 1)
+               if (num_trbs > 1) {
                        field |= TRB_CHAIN;
-               else
+               } else {
                        field |= TRB_IOC;
+                       more_trbs_coming = false;
+               }
 
                /* Only set interrupt on short packet for IN endpoints */
                if (usb_pipein(pipe))
                        field |= TRB_ISP;
 
                /* Set the TRB length, TD size, and interrupter fields. */
-               if (ctrl->hci_version < 0x100)
-                       remainder = xhci_td_remainder(length - running_total);
-               else
-                       remainder = xhci_v1_0_td_remainder(running_total,
-                                                          trb_buff_len,
-                                                          total_packet_count,
-                                                          maxpacketsize,
-                                                          num_trbs - 1);
+               remainder = xhci_td_remainder(ctrl, running_total, trb_buff_len,
+                                             length, maxpacketsize,
+                                             more_trbs_coming);
 
                length_field = ((trb_buff_len & TRB_LEN_MASK) |
-                               remainder |
+                               TRB_TD_SIZE(remainder) |
                                ((0 & TRB_INTR_TARGET_MASK) <<
                                TRB_INTR_TARGET_SHIFT));
 
@@ -764,6 +756,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
        struct xhci_virt_device *virt_dev = ctrl->devs[slot_id];
        struct xhci_ring *ep_ring;
        union xhci_trb *event;
+       u32 remainder;
 
        debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
                req->request, req->request,
@@ -866,12 +859,14 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
        else
                field = (TRB_DATA << TRB_TYPE_SHIFT);
 
Quoted 5 lines

drivers/usb/host/xhci-ring.c int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, · line 863

Quoted 3 lines
drivers/usb/host/xhci-ring.c +2 -1
-       length_field = (length & TRB_LEN_MASK) | xhci_td_remainder(length) |
+       remainder = xhci_td_remainder(ctrl, 0, length, length,
+                                     usb_maxpacket(udev, pipe), 1);

1 should be true

Ok, it's better, will modify it

Quoted 26 lines
Quoted 16 lines
drivers/usb/host/xhci-ring.c +2 -1
+       length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
                        ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
        debug("length_field = %d, length = %d,"
                "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
                length_field, (length & TRB_LEN_MASK),
-               xhci_td_remainder(length), 0);
+               TRB_TD_SIZE(remainder), 0);
 
        if (length > 0) {
                if (req->requesttype & USB_DIR_IN)
include/usb/xhci.h +0 -0
index a3e5914..15926eb 100644

include/usb/xhci.h struct xhci_event_cmd { · line 857

Quoted 8 lines
include/usb/xhci.h +2 -0
@@ -850,6 +850,8 @@ struct xhci_event_cmd {
 /* 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)

Otherwise,

Quoted 1 line

Thanks a lot

author maintainer
#4 lore raw

PATCH v3 3/9 usb: xhci: add quirks flag to support MediaTek xHCI 0.96

In reply to Chunfeng Yun

There some vendor quirks for MTK xHCI 0.96 host controller:
1. It defines some extra SW scheduling parameters for HW to minimize the scheduling effort for synchronous and interrupt endpoints. The parameters are put into reserved DWs of slot context and endpoint context.
2. Its TDS in Normal TRB defines a number of packets that remains to be transferred for a TD after processing all Max packets in all previous TRBs.

---
v3: fix typo, and add reviewed-by Bin

v2: add Tested-by Frank

---
 drivers/usb/host/xhci-mtk.c  | 1 +
 drivers/usb/host/xhci-ring.c | 9 +++++++--
 drivers/usb/host/xhci.c      | 2 +-
 include/usb/xhci.h           | 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-mtk.c +1 -0
index 8ff7185..f3f181d 100644
@@ -258,6 +258,7 @@ static int xhci_mtk_probe(struct udevice *dev)
 	if (ret)
 		goto ssusb_init_err;
 
+	mtk->ctrl.quirks = XHCI_MTK_HOST;
 	hcor = (struct xhci_hcor *)((uintptr_t)mtk->hcd +
 			HC_LENGTH(xhci_readl(&mtk->hcd->cr_capbase)));
 
drivers/usb/host/xhci-ring.c +7 -2
index 0f86b01..cf8b9d2 100644
@@ -332,7 +332,8 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
 {
 	u32 total_packet_count;
 
-	if (ctrl->hci_version < 0x100)
+	/* MTK xHCI 0.96 contains some features from 1.0 */
+	if (ctrl->hci_version < 0x100 && !(ctrl->quirks & XHCI_MTK_HOST))
 		return ((td_total_len - transferred) >> 10);
 
 	/* One TRB with a zero-length data packet. */
@@ -340,6 +341,10 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
 	    trb_buff_len == td_total_len)
 		return 0;
 
+	/* for MTK xHCI 0.96, TD size include this TRB, but not in 1.x */
+	if ((ctrl->quirks & XHCI_MTK_HOST) && (ctrl->hci_version < 0x100))
+		trb_buff_len = 0;
+
 	total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
 	/* Queueing functions don't count the current TRB into transferred */
@@ -823,7 +828,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 		field |= 0x1;
 
 	/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-	if (ctrl->hci_version >= 0x100) {
+	if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
 		if (length > 0) {
 			if (req->requesttype & USB_DIR_IN)
 				field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
drivers/usb/host/xhci.c +1 -1
index 4be1411..51edeb2 100644
@@ -650,7 +650,7 @@ static int xhci_set_configuration(struct usb_device *udev)
 		 * are put into reserved DWs in Slot and Endpoint Contexts
 		 * for synchronous endpoints.
 		 */
-		if (IS_ENABLED(CONFIG_USB_XHCI_MTK)) {
+		if (ctrl->quirks & XHCI_MTK_HOST) {
 			ep_ctx[ep_index]->reserved[0] =
 				cpu_to_le32(EP_BPKTS(1) | EP_BBM(1));
 		}
include/usb/xhci.h +2 -0
index 15926eb..3de46cd 100644
@@ -1230,6 +1230,8 @@ struct xhci_ctrl {
 	struct xhci_virt_device *devs[MAX_HC_SLOTS];
 	int rootdev;
 	u16 hci_version;
+	u32 quirks;
+#define XHCI_MTK_HOST		BIT(0)
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
Signature · 1 line
1.9.1
author maintainer
#5 lore raw

PATCH v3 4/9 usb: xhci: convert to HCS_MAX_PORTS()

In reply to Chunfeng Yun

Use HCS_MAX_PORTS(p) instead of
((p & HCS_MAX_PORTS_MASK) >> HCS_MAX_PORTS_SHIFT)

---
v3: add reviewed-by Bin

v2: no changes

---
 drivers/usb/host/xhci.c | 3 +--
 include/usb/xhci.h      | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/usb/host/xhci.c +1 -2
index 51edeb2..5f3a0fb 100644
@@ -1257,8 +1257,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
 		return -ENOMEM;
 
 	reg = xhci_readl(&hccr->cr_hcsparams1);
-	descriptor.hub.bNbrPorts = ((reg & HCS_MAX_PORTS_MASK) >>
-						HCS_MAX_PORTS_SHIFT);
+	descriptor.hub.bNbrPorts = HCS_MAX_PORTS(reg);
 	printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts);
 
 	/* Port Indicators */
include/usb/xhci.h +0 -2
index 3de46cd..cf4c020 100644
@@ -101,8 +101,6 @@ struct xhci_hccr {
 /* bits 8:18, Max Interrupters */
 #define HCS_MAX_INTRS(p)	(((p) >> 8) & 0x7ff)
 /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
-#define HCS_MAX_PORTS_SHIFT	24
-#define HCS_MAX_PORTS_MASK	(0xff << HCS_MAX_PORTS_SHIFT)
 #define HCS_MAX_PORTS(p)	(((p) >> 24) & 0xff)
 
 /* HCSPARAMS2 - hcs_params2 - bitmasks */
Signature · 1 line
1.9.1
author maintainer
#6 lore raw

PATCH v3 5/9 usb: xhci: convert to TRB_TYPE()

In reply to Chunfeng Yun

Use TRB_TYPE(p) instead of ((p) << TRB_TYPE_SHIFT)

---
v3: add reviewed-by Bin

v2: no changes

---
 drivers/usb/host/xhci-mem.c  |  3 +--
 drivers/usb/host/xhci-ring.c | 11 +++++------
 include/usb/xhci.h           |  1 -
 3 files changed, 6 insertions(+), 9 deletions(-)
drivers/usb/host/xhci-mem.c +1 -2
index 1da0524..d627aa5 100644
@@ -236,8 +236,7 @@ static void xhci_link_segments(struct xhci_segment *prev,
 		 */
 		val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control);
 		val &= ~TRB_TYPE_BITMASK;
-		val |= (TRB_LINK << TRB_TYPE_SHIFT);
-
+		val |= TRB_TYPE(TRB_LINK);
 		prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val);
 	}
 }
drivers/usb/host/xhci-ring.c +5 -6
index cf8b9d2..87891fd 100644
@@ -696,7 +696,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
 		trb_fields[0] = lower_32_bits(addr);
 		trb_fields[1] = upper_32_bits(addr);
 		trb_fields[2] = length_field;
-		trb_fields[3] = field | (TRB_NORMAL << TRB_TYPE_SHIFT);
+		trb_fields[3] = field | TRB_TYPE(TRB_NORMAL);
 
 		queue_trb(ctrl, ring, (num_trbs > 1), trb_fields);
 
@@ -823,7 +823,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	/* Queue setup TRB - see section 6.4.1.2.1 */
 	/* FIXME better way to translate setup_packet into two u32 fields? */
 	field = 0;
-	field |= TRB_IDT | (TRB_SETUP << TRB_TYPE_SHIFT);
+	field |= TRB_IDT | TRB_TYPE(TRB_SETUP);
 	if (start_cycle == 0)
 		field |= 0x1;
 
@@ -860,9 +860,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	/* If there's data, queue data TRBs */
 	/* Only set interrupt on short packet for IN endpoints */
 	if (usb_pipein(pipe))
-		field = TRB_ISP | (TRB_DATA << TRB_TYPE_SHIFT);
+		field = TRB_ISP | TRB_TYPE(TRB_DATA);
 	else
-		field = (TRB_DATA << TRB_TYPE_SHIFT);
+		field = TRB_TYPE(TRB_DATA);
 
 	remainder = xhci_td_remainder(ctrl, 0, length, length,
 				      usb_maxpacket(udev, pipe), 1);
@@ -904,8 +904,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
 		/* Event on completion */
 	trb_fields[3] = field | TRB_IOC |
-			(TRB_STATUS << TRB_TYPE_SHIFT) |
-			ep_ring->cycle_state;
+			TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
 
 	queue_trb(ctrl, ep_ring, false, trb_fields);
 
include/usb/xhci.h +0 -1
index cf4c020..bdba51d 100644
@@ -903,7 +903,6 @@ union xhci_trb {
 /* TRB bit mask */
 #define	TRB_TYPE_BITMASK	(0xfc00)
 #define TRB_TYPE(p)		((p) << 10)
-#define TRB_TYPE_SHIFT		(10)
 #define TRB_FIELD_TO_TYPE(p)	(((p) & TRB_TYPE_BITMASK) >> 10)
 
 /* TRB type IDs */
Signature · 1 line
1.9.1
author maintainer
#7 lore raw

PATCH v3 6/9 usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET()

In reply to Chunfeng Yun

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)

---
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(-)
drivers/usb/host/xhci-ring.c +7 -9
index 87891fd..99c84f9 100644
@@ -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));
 
 		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;
include/usb/xhci.h +0 -3
index bdba51d..35c6604 100644
@@ -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@*/
-#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)
Signature · 1 line
1.9.1
#8 lore raw

PATCH v3 6/9 usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET()

Quoted 21 lines · Chunfeng Yun

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)

---
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(-)
drivers/usb/host/xhci-ring.c +0 -0
index 87891fd..99c84f9 100644

drivers/usb/host/xhci-ring.c int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, · line 693

Quoted 9 lines
drivers/usb/host/xhci-ring.c +2 -3
@@ -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)

Quoted 45 lines
drivers/usb/host/xhci-ring.c +5 -6
                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;
include/usb/xhci.h +0 -0
index bdba51d..35c6604 100644
@@ -847,12 +847,9 @@ struct xhci_event_cmd {
 /* Normal TRB fields */
 /* transfer_len bitmasks - bits 0:16 */
 #define        TRB_LEN(p)                      ((p) & 0x1ffff)

include/usb/xhci.h struct xhci_event_cmd {

Quoted 10 lines
include/usb/xhci.h +0 -4
-#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)
--
author maintainer
#9 lore raw

PATCH v3 6/9 usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET()

Quoted 25 lines · Bin Meng
Quoted 24 lines · Chunfeng Yun

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)

---
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(-)
drivers/usb/host/xhci-ring.c +0 -0
index 87891fd..99c84f9 100644
@@ -688,10 +688,9 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
                                              length, maxpacketsize,
                                              more_trbs_coming);
 
Quoted 8 lines

drivers/usb/host/xhci-ring.c int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, · line 693

Quoted 6 lines
drivers/usb/host/xhci-ring.c +2 -3
-               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

Quoted 50 lines
Quoted 50 lines
drivers/usb/host/xhci-ring.c +5 -6
                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;
include/usb/xhci.h +0 -1
index bdba51d..35c6604 100644
@@ -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 */
Quoted 8 lines

include/usb/xhci.h struct xhci_event_cmd {

Quoted 6 lines
include/usb/xhci.h +0 -3
-#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)
--

Thanks

author maintainer
#10 lore raw

PATCH v3 7/9 usb: xhci: convert to TRB_TX_TYPE()

In reply to Chunfeng Yun

Use TRB_TX_TYPE() instead of (TRB_DATA_OUT/IN << TRB_TX_TYPE_SHIFT)

---
v2: no changes

---
 drivers/usb/host/xhci-ring.c | 4 ++--
 include/usb/xhci.h           | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-ring.c +2 -2
index 99c84f9..ccf2a35 100644
@@ -830,9 +830,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
 		if (length > 0) {
 			if (req->requesttype & USB_DIR_IN)
-				field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
+				field |= TRB_TX_TYPE(TRB_DATA_IN);
 			else
-				field |= (TRB_DATA_OUT << TRB_TX_TYPE_SHIFT);
+				field |= TRB_TX_TYPE(TRB_DATA_OUT);
 		}
 	}
 
include/usb/xhci.h +0 -1
index 35c6604..07b1aeb 100644
@@ -879,7 +879,6 @@ struct xhci_event_cmd {
 /* Control transfer TRB specific fields */
 #define TRB_DIR_IN		(1<<16)
 #define	TRB_TX_TYPE(p)		((p) << 16)
-#define	TRB_TX_TYPE_SHIFT	(16)
 #define	TRB_DATA_OUT		2
 #define	TRB_DATA_IN		3
 
Signature · 1 line
1.9.1
#11 lore raw

PATCH v3 7/9 usb: xhci: convert to TRB_TX_TYPE()

Quoted 11 lines · Chunfeng Yun

Use TRB_TX_TYPE() instead of (TRB_DATA_OUT/IN << TRB_TX_TYPE_SHIFT)

---
v2: no changes

---
 drivers/usb/host/xhci-ring.c | 4 ++--
 include/usb/xhci.h           | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
author maintainer
#12 lore raw

PATCH v3 8/9 usb: xhci: use macros with parameter to fill ep_info2

In reply to Chunfeng Yun

Use macros with parameter to fill ep_info2, then some macros for MASK and SHIFT can be removed

---
v3: merge patch [v2 9/11] and [v2 10/11] into one, both for ep_info2

v2: no changes

---
 drivers/usb/host/xhci-mem.c | 15 +++++----------
 drivers/usb/host/xhci.c     |  6 ++----
 include/usb/xhci.h          |  6 ------
 3 files changed, 7 insertions(+), 20 deletions(-)
drivers/usb/host/xhci-mem.c +5 -10
index d627aa5..0b49614 100644
@@ -825,25 +825,22 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
 
 	/* Step 4 - ring already allocated */
 	/* Step 5 */
-	ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT);
+	ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
 	debug("SPEED = %d\n", speed);
 
 	switch (speed) {
 	case USB_SPEED_SUPER:
-		ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) <<
-					MAX_PACKET_SHIFT));
+		ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512));
 		debug("Setting Packet size = 512bytes\n");
 		break;
 	case USB_SPEED_HIGH:
 	/* USB core guesses at a 64-byte max packet first for FS devices */
 	case USB_SPEED_FULL:
-		ep0_ctx->ep_info2 |= cpu_to_le32(((64 & MAX_PACKET_MASK) <<
-					MAX_PACKET_SHIFT));
+		ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64));
 		debug("Setting Packet size = 64bytes\n");
 		break;
 	case USB_SPEED_LOW:
-		ep0_ctx->ep_info2 |= cpu_to_le32(((8 & MAX_PACKET_MASK) <<
-					MAX_PACKET_SHIFT));
+		ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8));
 		debug("Setting Packet size = 8bytes\n");
 		break;
 	default:
@@ -852,9 +849,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
 	}
 
 	/* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
-	ep0_ctx->ep_info2 |=
-			cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) |
-			((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
+	ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3));
 
 	trb_64 = virt_to_phys(virt_dev->eps[0].ring->first_seg->trbs);
 	ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
drivers/usb/host/xhci.c +2 -4
index 5f3a0fb..fe30101 100644
@@ -618,8 +618,7 @@ static int xhci_set_configuration(struct usb_device *udev)
 			cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) |
 			EP_INTERVAL(interval) | EP_MULT(mult));
 
-		ep_ctx[ep_index]->ep_info2 =
-			cpu_to_le32(ep_type << EP_TYPE_SHIFT);
+		ep_ctx[ep_index]->ep_info2 = cpu_to_le32(EP_TYPE(ep_type));
 		ep_ctx[ep_index]->ep_info2 |=
 			cpu_to_le32(MAX_PACKET
 			(get_unaligned(&endpt_desc->wMaxPacketSize)));
@@ -832,8 +831,7 @@ int xhci_check_maxpacket(struct usb_device *udev)
 				ctrl->devs[slot_id]->out_ctx, ep_index);
 		in_ctx = ctrl->devs[slot_id]->in_ctx;
 		ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
-		ep_ctx->ep_info2 &= cpu_to_le32(~((0xffff & MAX_PACKET_MASK)
-						<< MAX_PACKET_SHIFT));
+		ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET(MAX_PACKET_MASK));
 		ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
 		/*
include/usb/xhci.h +0 -6
index 07b1aeb..e1d3823 100644
@@ -632,11 +632,8 @@ struct xhci_ep_ctx {
  */
 #define	FORCE_EVENT		(0x1)
 #define ERROR_COUNT(p)		(((p) & 0x3) << 1)
-#define ERROR_COUNT_SHIFT	(1)
-#define ERROR_COUNT_MASK	(0x3)
 #define CTX_TO_EP_TYPE(p)	(((p) >> 3) & 0x7)
 #define EP_TYPE(p)		((p) << 3)
-#define EP_TYPE_SHIFT		(3)
 #define ISOC_OUT_EP		1
 #define BULK_OUT_EP		2
 #define INT_OUT_EP		3
@@ -647,13 +644,10 @@ struct xhci_ep_ctx {
 /* bit 6 reserved */
 /* bit 7 is Host Initiate Disable - for disabling stream selection */
 #define MAX_BURST(p)		(((p)&0xff) << 8)
-#define MAX_BURST_MASK		(0xff)
-#define MAX_BURST_SHIFT		(8)
 #define CTX_TO_MAX_BURST(p)	(((p) >> 8) & 0xff)
 #define MAX_PACKET(p)		(((p)&0xffff) << 16)
 #define MAX_PACKET_MASK		(0xffff)
 #define MAX_PACKET_DECODED(p)	(((p) >> 16) & 0xffff)
-#define MAX_PACKET_SHIFT	(16)
 
 /* Get max packet size from ep desc. Bit 10..0 specify the max packet size.
  * USB2.0 spec 9.6.6.
Signature · 1 line
1.9.1
#13 lore raw

PATCH v3 8/9 usb: xhci: use macros with parameter to fill ep_info2

Quoted 8 lines · Chunfeng Yun

Use macros with parameter to fill ep_info2, then some macros for MASK and SHIFT can be removed

---
v3: merge patch [v2 9/11] and [v2 10/11] into one, both for ep_info2

Quoted 7 lines

v2: no changes

---
 drivers/usb/host/xhci-mem.c | 15 +++++----------
 drivers/usb/host/xhci.c     |  6 ++----
 include/usb/xhci.h          |  6 ------
 3 files changed, 7 insertions(+), 20 deletions(-)
author maintainer
#14 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

In reply to Chunfeng Yun

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/usb/host/xhci.c +11 -14
index fe30101..3547a9b 100644
@@ -33,6 +33,7 @@
 #include <linux/bug.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
+#include <linux/iopoll.h>
 #include <usb/xhci.h>
 
 #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
@@ -143,23 +144,19 @@ struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev)
  * @param usec	time to wait till
  * @return 0 if handshake is success else < 0 on failure
  */
-static int handshake(uint32_t volatile *ptr, uint32_t mask,
-					uint32_t done, int usec)
+static int
+handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec)
 {
 	uint32_t result;
+	int ret;
+
+	ret = readx_poll_sleep_timeout(xhci_readl, ptr, result,
+				 (result & mask) == done || result == U32_MAX,
+				 1, usec);
+	if (result == U32_MAX)		/* card removed */
+		return -ENODEV;
 
-	do {
-		result = xhci_readl(ptr);
-		if (result == ~(uint32_t)0)
-			return -ENODEV;
-		result &= mask;
-		if (result == done)
-			return 0;
-		usec--;
-		udelay(1);
-	} while (usec > 0);
-
-	return -ETIMEDOUT;
+	return ret;
 }
 
 /**
Signature · 1 line
1.9.1
#15 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 12 lines · Chunfeng Yun

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
#16 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 8 lines · Bin Meng
Quoted 7 lines · Chunfeng Yun

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

Quoted 7 lines
Quoted 5 lines

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

Thank you

author maintainer
#17 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Hi Marek,

I've sent out v4;

Hi Frank,

Please forward this email to Marek, thanks a lot

Quoted 23 lines · Marek Vasut
Quoted 8 lines · Bin Meng
Quoted 7 lines · Chunfeng Yun

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

Quoted 7 lines
Quoted 5 lines

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

Thank you

#18 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

In reply to Marek Vasut

Hi Marek,

Quoted 16 lines · Marek Vasut
Quoted 14 lines · Bin Meng
Quoted 12 lines · Chunfeng Yun

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
Quoted 7 lines
Quoted 1 line

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

I believe the latest version has all the RB tags.

Regards,
Bin

#19 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Quoted 15 lines · Chunfeng Yun
Quoted 12 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
Quoted 7 lines
Quoted 5 lines

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

#20 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Am 8. September 2020 18:15:05 MESZ schrieb Marek Vasut <[email protected]>:

Quoted 3 lines

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox,
because the original patches are just not there.

Should i resend v4? Or could you apply from Patchwork (series link in upper right of Patch)? Thats the way i use :)

https://patchwork.ozlabs.org/project/uboot/list/?series=200140
regards Frank

#21 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 10 lines · Frank Wunderlich

Am 8. September 2020 18:15:05 MESZ schrieb Marek Vasut <[email protected]>:

Quoted 3 lines

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox,
because the original patches are just not there.

Should i resend v4? Or could you apply from Patchwork (series link in upper right of Patch)? Thats the way i use :)

https://patchwork.ozlabs.org/project/uboot/list/?series=200140

Resend please, if I wanted to comment on any of those patches, I won't be able.

#22 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Am 8. September 2020 18:47:47 MESZ schrieb Marek Vasut <[email protected]>:

Quoted 2 lines

Resend please, if I wanted to comment on any of those patches, I won't be able.

Have resend with bit reduced recipients (afair ryder and weijie are in GSS mailinglist),because this floods others mailbox. It's only a workaround.

Have you found problem or any idea why you not able to receive from chunfeng directly? regards Frank

#23 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 10 lines · Frank Wunderlich

Am 8. September 2020 18:47:47 MESZ schrieb Marek Vasut <[email protected]>:

Quoted 2 lines

Resend please, if I wanted to comment on any of those patches, I won't be able.

Have resend with bit reduced recipients (afair ryder and weijie are in GSS mailinglist),because this floods others mailbox. It's only a workaround.

Have you found problem or any idea why you not able to receive from chunfeng directly?

No, however I have no problems receiving emails from others.

#24 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

In reply to Marek Vasut

Hi Marek,

Quoted 31 lines · Marek Vasut
Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 25 lines · Marek Vasut
Quoted 23 lines · Bin Meng
Quoted 8 lines · Chunfeng Yun
Quoted 7 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

Quoted 7 lines
Quoted 5 lines

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

Quoted 4 lines
Quoted 1 line

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Regards,
Bin

#25 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 32 lines · Marek Vasut
Quoted 31 lines · Bin Meng
Quoted 1 line

Hi Marek,

Hi,

Quoted 25 lines · Marek Vasut
Quoted 23 lines · Bin Meng
Quoted 8 lines · Chunfeng Yun
Quoted 7 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

Quoted 7 lines
Quoted 5 lines

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Can you also comment on patches via patchwork ?

I mean, really, can we please just stick to the usual workflow ? That's all I am asking for , nothing else, nothing new.

#26 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 43 lines · Marek Vasut
Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 37 lines · Marek Vasut
Quoted 35 lines · Bin Meng
Quoted 1 line

Hi Marek,

Hi,

Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Quoted 15 lines · Chunfeng Yun
Quoted 12 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
Quoted 7 lines
Quoted 5 lines

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

Quoted 7 lines
Quoted 2 lines

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Can you also comment on patches via patchwork ?

I mean, really, can we please just stick to the usual workflow ? That's all I am asking for , nothing else, nothing new.

I don't understand the question about "usual workflow". You asked "I cannot apply a patchset which only has "Re:" in my mailbox" and I recommended patchwork which will satisfy the requirement of what you asked.

Regards,
Bin

#27 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 49 lines · Bin Meng
Quoted 48 lines · Marek Vasut
Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 32 lines · Marek Vasut
Quoted 31 lines · Bin Meng
Quoted 1 line

Hi Marek,

Hi,

Quoted 25 lines · Marek Vasut
Quoted 23 lines · Bin Meng
Quoted 8 lines · Chunfeng Yun
Quoted 7 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

Quoted 7 lines
Quoted 5 lines

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Can you also comment on patches via patchwork ?

Quoted 7 lines
Quoted 2 lines

I mean, really, can we please just stick to the usual workflow ? That's all I am asking for , nothing else, nothing new.

I don't understand the question about "usual workflow". You asked "I cannot apply a patchset which only has "Re:" in my mailbox" and I recommended patchwork which will satisfy the requirement of what you asked.

Right, I can, but if there is more I want to say about the patch, I cannot do it with patchwork. Then I need the patch, which I don't have. Hence my remark about the usual email-based workflow.

#28 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 54 lines · Marek Vasut
Quoted 52 lines · Bin Meng
Quoted 50 lines · Marek Vasut
Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 32 lines · Marek Vasut
Quoted 31 lines · Bin Meng
Quoted 1 line

Hi Marek,

Hi,

Quoted 25 lines · Marek Vasut
Quoted 23 lines · Bin Meng
Quoted 8 lines · Chunfeng Yun
Quoted 7 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

Quoted 7 lines
Quoted 5 lines

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Can you also comment on patches via patchwork ?

I mean, really, can we please just stick to the usual workflow ? That's all I am asking for , nothing else, nothing new.

Quoted 8 lines
Quoted 4 lines

I don't understand the question about "usual workflow". You asked "I cannot apply a patchset which only has "Re:" in my mailbox" and I recommended patchwork which will satisfy the requirement of what you asked.

Right, I can, but if there is more I want to say about the patch, I cannot do it with patchwork. Then I need the patch, which I don't have. Hence my remark about the usual email-based workflow.

Yes, that's true. If we need to post comments about patches, we will have to use email.

Regards,
Bin

#29 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

Quoted 60 lines · Bin Meng
Quoted 59 lines · Marek Vasut
Quoted 56 lines · Bin Meng
Quoted 43 lines · Marek Vasut
Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 37 lines · Marek Vasut
Quoted 35 lines · Bin Meng
Quoted 1 line

Hi Marek,

Hi,

Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Quoted 15 lines · Chunfeng Yun
Quoted 12 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
Quoted 7 lines
Quoted 5 lines

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

Quoted 7 lines
Quoted 2 lines

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Can you also comment on patches via patchwork ?

I mean, really, can we please just stick to the usual workflow ? That's all I am asking for , nothing else, nothing new.

I don't understand the question about "usual workflow". You asked "I cannot apply a patchset which only has "Re:" in my mailbox" and I recommended patchwork which will satisfy the requirement of what you asked.

Quoted 6 lines
Quoted 3 lines

Right, I can, but if there is more I want to say about the patch, I cannot do it with patchwork. Then I need the patch, which I don't have. Hence my remark about the usual email-based workflow.

Yes, that's true. If we need to post comments about patches, we will have to use email.

Which, to close the loop, is trivial with patchwork, if you're making a new comment, and hard if you are trying to join an ongoing conversation.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200909/dc079d0c/attachment.sig>
#30 lore raw

PATCH v3 9/9 usb: xhci: convert to readx_poll_sleep_timeout()

In reply to Bin Meng
Quoted 60 lines · Bin Meng
Quoted 59 lines · Marek Vasut
Quoted 56 lines · Bin Meng
Quoted 43 lines · Marek Vasut
Quoted 1 line · Bin Meng

Hi Marek,

Hi,

Quoted 37 lines · Marek Vasut
Quoted 35 lines · Bin Meng
Quoted 1 line

Hi Marek,

Hi,

Quoted 19 lines · Marek Vasut
Quoted 18 lines · Bin Meng
Quoted 15 lines · Chunfeng Yun
Quoted 12 lines

Use readx_poll_sleep_timeout() to poll the register status

---
v3: no changes

v2: fix typo of title suggested by Frank

---
 drivers/usb/host/xhci.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
Quoted 7 lines
Quoted 5 lines

Thanks. So now I have half of a RESEND patchset with RB tags, and another half of just RB tags without patchset. Can someone of you please collect the tags and resend the patchset once more with the collected tags, so it's all in one place ?

I believe the latest version has all the RB tags.

Thank you, I cannot apply a patchset which only has "Re:" in my mailbox, because the original patches are just not there.

Quoted 7 lines
Quoted 2 lines

You can use patchwork to help the custodian work. I found it very helpful to download the patches from patchwork and apply.

Can you also comment on patches via patchwork ?

I mean, really, can we please just stick to the usual workflow ? That's all I am asking for , nothing else, nothing new.

I don't understand the question about "usual workflow". You asked "I cannot apply a patchset which only has "Re:" in my mailbox" and I recommended patchwork which will satisfy the requirement of what you asked.

Quoted 6 lines
Quoted 3 lines

Right, I can, but if there is more I want to say about the patch, I cannot do it with patchwork. Then I need the patch, which I don't have. Hence my remark about the usual email-based workflow.

Yes, that's true. If we need to post comments about patches, we will have to use email.

The problem here is that for whatever reason, I didn't receive the original patches, Frank had to resend them, then I got RBs on some of each and it was a mess. I'd just like to get back to the usual. I think we agree, don't we ?

Anyway, thanks for the RBs, that really helped.