diff mbox series

[RESEND,v2,01/11] usb: xhci: add a member hci_version in xhci_ctrl struct

Message ID 20200902061343.3185-1-linux@fw-web.de
State Superseded
Delegated to: Marek Vasut
Headers show
Series [RESEND,v2,01/11] usb: xhci: add a member hci_version in xhci_ctrl struct | expand

Commit Message

Frank Wunderlich Sept. 2, 2020, 6:13 a.m. UTC
From: Chunfeng Yun <chunfeng.yun@mediatek.com>

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

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 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(-)

Comments

Marek Vasut Sept. 2, 2020, 10:38 a.m. UTC | #1
On 9/2/20 8:13 AM, Frank Wunderlich wrote:
> From: Chunfeng Yun <chunfeng.yun@mediatek.com>
> 
> Add a member to save xHCI version, it's used some times.
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  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(-)
> 
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 092ed6eaf1..79bfc349f4 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -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);
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 126dabc11b..4be1411243 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -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;
>  }
> diff --git a/include/usb/xhci.h b/include/usb/xhci.h
> index 7d34103fd5..a3e5914b10 100644
> --- a/include/usb/xhci.h
> +++ b/include/usb/xhci.h
> @@ -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);
> 
+CC Bin
Bin Meng Sept. 2, 2020, 1:21 p.m. UTC | #2
On Wed, Sep 2, 2020 at 6:38 PM Marek Vasut <marex@denx.de> wrote:
>
> On 9/2/20 8:13 AM, Frank Wunderlich wrote:
> > From: Chunfeng Yun <chunfeng.yun@mediatek.com>
> >
> > Add a member to save xHCI version, it's used some times.
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >  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(-)
> >
> > diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> > index 092ed6eaf1..79bfc349f4 100644
> > --- a/drivers/usb/host/xhci-ring.c
> > +++ b/drivers/usb/host/xhci-ring.c
> > @@ -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);
> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> > index 126dabc11b..4be1411243 100644
> > --- a/drivers/usb/host/xhci.c
> > +++ b/drivers/usb/host/xhci.c
> > @@ -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;
> >  }
> > diff --git a/include/usb/xhci.h b/include/usb/xhci.h
> > index 7d34103fd5..a3e5914b10 100644
> > --- a/include/usb/xhci.h
> > +++ b/include/usb/xhci.h
> > @@ -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);
> >
> +CC Bin

Thanks Marek. Will take a look at this series soon.

Regards,
Bin
Bin Meng Sept. 4, 2020, 12:59 a.m. UTC | #3
On Wed, Sep 2, 2020 at 2:14 PM Frank Wunderlich <linux@fw-web.de> wrote:
>
> From: Chunfeng Yun <chunfeng.yun@mediatek.com>
>
> Add a member to save xHCI version, it's used some times.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  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(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 092ed6eaf1..79bfc349f4 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -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);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 126dabc11b..4be1411243 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -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;
 }
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 7d34103fd5..a3e5914b10 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -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);