* [PATCH] usb: host: xhci-hub: drop redundant port register reads
@ 2022-02-11 19:05 Sergey Shtylyov
2022-02-12 7:03 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Shtylyov @ 2022-02-11 19:05 UTC (permalink / raw)
To: Mathias Nyman, linux-usb, Greg Kroah-Hartman
In xhci_hub_control(), there are many port register readbacks in several
branches of the *switch* statement which get duplicated right after that
*switch* by reading back the port register once more -- which is done to
flush the posted writes. Remove the redundant reads inside that *switch*.
Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.
drivers/usb/host/xhci-hub.c | 8 --------
1 file changed, 8 deletions(-)
Index: usb/drivers/usb/host/xhci-hub.c
===================================================================
--- usb.orig/drivers/usb/host/xhci-hub.c
+++ usb/drivers/usb/host/xhci-hub.c
@@ -1323,7 +1323,6 @@ int xhci_hub_control(struct usb_hcd *hcd
msleep(10); /* wait device to enter */
spin_lock_irqsave(&xhci->lock, flags);
- temp = readl(ports[wIndex]->addr);
bus_state->suspended_ports |= 1 << wIndex;
break;
case USB_PORT_FEAT_LINK_STATE:
@@ -1341,7 +1340,6 @@ int xhci_hub_control(struct usb_hcd *hcd
PORT_OCC | PORT_RC | PORT_PLC |
PORT_CEC;
writel(temp | PORT_PE, ports[wIndex]->addr);
- temp = readl(ports[wIndex]->addr);
break;
}
@@ -1351,7 +1349,6 @@ int xhci_hub_control(struct usb_hcd *hcd
hcd->self.busnum, wIndex + 1);
xhci_set_link_state(xhci, ports[wIndex],
link_state);
- temp = readl(ports[wIndex]->addr);
break;
}
@@ -1384,8 +1381,6 @@ int xhci_hub_control(struct usb_hcd *hcd
hcd->self.busnum, wIndex + 1);
xhci_set_link_state(xhci, ports[wIndex],
link_state);
-
- temp = readl(ports[wIndex]->addr);
break;
}
/* Port must be enabled */
@@ -1435,7 +1430,6 @@ int xhci_hub_control(struct usb_hcd *hcd
xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n",
hcd->self.busnum, wIndex + 1);
spin_lock_irqsave(&xhci->lock, flags);
- temp = readl(ports[wIndex]->addr);
break;
}
@@ -1460,7 +1454,6 @@ int xhci_hub_control(struct usb_hcd *hcd
break;
}
spin_lock_irqsave(&xhci->lock, flags);
- temp = readl(ports[wIndex]->addr);
bus_state->suspended_ports |= 1 << wIndex;
}
break;
@@ -1491,7 +1484,6 @@ int xhci_hub_control(struct usb_hcd *hcd
case USB_PORT_FEAT_BH_PORT_RESET:
temp |= PORT_WR;
writel(temp, ports[wIndex]->addr);
- temp = readl(ports[wIndex]->addr);
break;
case USB_PORT_FEAT_U1_TIMEOUT:
if (hcd->speed < HCD_USB3)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: host: xhci-hub: drop redundant port register reads
2022-02-11 19:05 [PATCH] usb: host: xhci-hub: drop redundant port register reads Sergey Shtylyov
@ 2022-02-12 7:03 ` Greg Kroah-Hartman
2022-02-14 18:44 ` Sergey Shtylyov
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-02-12 7:03 UTC (permalink / raw)
To: Sergey Shtylyov; +Cc: Mathias Nyman, linux-usb
On Fri, Feb 11, 2022 at 10:05:19PM +0300, Sergey Shtylyov wrote:
> In xhci_hub_control(), there are many port register readbacks in several
> branches of the *switch* statement which get duplicated right after that
> *switch* by reading back the port register once more -- which is done to
> flush the posted writes. Remove the redundant reads inside that *switch*.
Doing a read right after a write is good, perhaps the one after the
switch should be removed instead?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: host: xhci-hub: drop redundant port register reads
2022-02-12 7:03 ` Greg Kroah-Hartman
@ 2022-02-14 18:44 ` Sergey Shtylyov
0 siblings, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2022-02-14 18:44 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Mathias Nyman, linux-usb
On 2/12/22 10:03 AM, Greg Kroah-Hartman wrote:
>> In xhci_hub_control(), there are many port register readbacks in several
>> branches of the *switch* statement which get duplicated right after that
>> *switch* by reading back the port register once more -- which is done to
>> flush the posted writes. Remove the redundant reads inside that *switch*.
>
> Doing a read right after a write is good, perhaps the one after the
> switch should be removed instead?
OK, hoping that the PORTPMSC writes don't need the PORTSC readbacks...
Looking a the git history, the readback after *switch* was redudant from the start...
> thanks,
>
> greg k-h
MBR, Sergey
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-14 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 19:05 [PATCH] usb: host: xhci-hub: drop redundant port register reads Sergey Shtylyov
2022-02-12 7:03 ` Greg Kroah-Hartman
2022-02-14 18:44 ` Sergey Shtylyov
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).