xhci features and fixes for usb-next
Subsystems (3)
cover xhci features and fixes for usb-next
Hi Greg
Some xhci features and fixes for usb-next.
Both fixing some possible memory leaks that are too late for usb-linus, and simple code cleanups for usb-next
Thanks
-Mathias
Jianglei Nie (1):
usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info()
Mario Limonciello (1):
xhci: Don't show warning for reinit on known broken suspend
Mathias Nyman (3):
xhci: show fault reason for a failed enable slot command
xhci: remove unused command member from struct xhci_hcd struct
xhci: remove unused lpm_failed_dev member from struct xhci_hcd
Rafael Mendonca (1):
xhci: dbc: Fix memory leak in xhci_alloc_dbc()
drivers/usb/host/xhci-dbgcap.c | 2 +- drivers/usb/host/xhci-mem.c | 7 ++++++- drivers/usb/host/xhci.c | 6 ++++-- drivers/usb/host/xhci.h | 3 --- 4 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/6 usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info()
From: Jianglei Nie <[email protected]>
xhci_alloc_stream_info() allocates stream context array for stream_info ->stream_ctx_array with xhci_alloc_stream_ctx(). When some error occurs, stream_info->stream_ctx_array is not released, which will lead to a memory leak.
We can fix it by releasing the stream_info->stream_ctx_array with xhci_free_stream_ctx() on the error path to avoid the potential memory leak.
--- drivers/usb/host/xhci-mem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-mem.c +6 -1
@@ -641,7 +641,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, num_stream_ctxs, &stream_info->ctx_array_dma, mem_flags);if (!stream_info->stream_ctx_array) - goto cleanup_ctx; + goto cleanup_ring_array;memset (stream_info->stream_ctx_array,0 ,sizeof (struct xhci_stream_ctx )*num_stream_ctxs);
@@ -702,6 +702,11 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, }xhci_free_command (xhci, stream_info->free_streams_command); cleanup_ctx: +xhci_free_stream_ctx (xhci, + stream_info->num_stream_ctxs, + stream_info->stream_ctx_array, + stream_info->ctx_array_dma); +cleanup_ring_array:kfree (stream_info->stream_rings); cleanup_info:kfree (stream_info);
Signature · 1 line
2.25.1
PATCH 2/6 xhci: dbc: Fix memory leak in xhci_alloc_dbc()
In reply to Mathias NymanFrom: Rafael Mendonca <[email protected]>
If DbC is already in use, then the allocated memory for the xhci_dbc struct doesn't get freed before returning NULL, which leads to a memleak.
--- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-dbgcap.c +1 -1
@@ -988,7 +988,7 @@ xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver * dbc->driver = driver;if (readl (&dbc->regs->control) &DBC_CTRL_DBC_ENABLE ) -return NULL ; + goto err;INIT_DELAYED_WORK (&dbc->event_work, xhci_dbc_handle_events);spin_lock_init (&dbc->lock);
Signature · 1 line
2.25.1
PATCH 3/6 xhci: Don't show warning for reinit on known broken suspend
In reply to Mathias NymanFrom: Mario Limonciello <[email protected]>
commit 8b328f8002bc ("xhci: re-initialize the HC during resume if HCE was set") introduced a new warning message when the host controller error was set and re-initializing.
This is expected behavior on some designs which already set xhci->broken_suspend so the new warning is alarming to some users.
Modify the code to only show the warning if this was a surprising behavior to the XHCI driver.
--- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +2 -1
@@ -1183,7 +1183,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)/* re-initialize the HC on Restore Error, or Host Controller Error */ if (temp & (STS_SRE |STS_HCE )) { reinit_xhc = true; -xhci_warn (xhci,"xHC error in resume, USBSTS 0x%x, Reinit\n" , temp); +if (!xhci->broken_suspend) +xhci_warn (xhci,"xHC error in resume, USBSTS 0x%x, Reinit\n" , temp); }if (reinit_xhc) {
Signature · 1 line
2.25.1
PATCH 4/6 xhci: show fault reason for a failed enable slot command
In reply to Mathias NymanShow the completion code of a unsuccessful "enable slot" command. Add it in a human readable form to the existing error message.
--- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +2 -1
@@ -4096,7 +4096,8 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev) slot_id = command->slot_id;if (!slot_id || command->status !=COMP_SUCCESS ) { -xhci_err (xhci,"Error while assigning device slot ID\n" ); +xhci_err (xhci,"Error while assigning device slot ID: %s\n" , +xhci_trb_comp_code_string (command->status));xhci_err (xhci,"Max number of devices this xHCI host supports is %u.\n" ,HCS_MAX_SLOTS (readl (&xhci->cap_regs->hcs_params1)));
Signature · 1 line
2.25.1
PATCH 5/6 xhci: remove unused command member from struct xhci_hcd struct
In reply to Mathias NymanThe u32 command was added to struct xhci_hcd over 10 years ago in commit 9777e3ce907d ("USB: xHCI: bus power management implementation")
It wasn't even used back then, so remove it.
--- drivers/usb/host/xhci.h | 1 - 1 file changed, 1 deletion(-)
drivers/usb/host/xhci.h +0 -1
@@ -1827,7 +1827,6 @@ struct xhci_hcd {/* Host controller watchdog timer structures */ unsigned int xhc_state;unsigned long run_graceperiod; -u32 command;struct s3_save s3;/* Host controller is dying - not responding to commands. "I'm not dead yet!" *
Signature · 1 line
2.25.1
PATCH 6/6 xhci: remove unused lpm_failed_dev member from struct xhci_hcd
In reply to Mathias Nymanxhci used to test if link power management (LPM) capable USB2 devices really could enter and exit L1 state link state.
Failed devices were added to a lpm_failed_dev list.
This feature was removed 9 years ago in
commit de68bab4fa96 ("usb: Don't enable USB 2.0 Link PM by default.") but lpm_failed_dev member was still left.
Remove it now.
--- drivers/usb/host/xhci.h | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/host/xhci.h +0 -2
@@ -1807,8 +1807,6 @@ struct xhci_hcd {struct xhci_erst erst;/* Scratchpad */ struct xhci_scratchpad *scratchpad; -/* Store LPM test failed devices' information */ -struct list_head lpm_failed_devs;/* slot enabling and address device helpers */ /* these are not thread safe so use mutex */
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 5 lines · Mathias Nyman
Hi Greg
Some xhci features and fixes for usb-next.
Both fixing some possible memory leaks that are too late for usb-linus, and simple code cleanups for usb-next
Did you miss this one:
https://lore.kernel.org/r/[email protected]
or was there some issue with it?
thanks,
greg k-h
Quoted 11 lines · Greg KH
Quoted 5 lines · Mathias Nyman
Hi Greg
Some xhci features and fixes for usb-next.
Both fixing some possible memory leaks that are too late for usb-linus, and simple code cleanups for usb-nextDid you miss this one:
https://lore.kernel.org/r/[email protected]or was there some issue with it?
Got distracted while looking at it.
Can be added but probably not that useful.
In a host controller error (HCE) case all host activity stops, so it would make more sense to check HCE bit in timeout cases than in interrupt handler.
-Mathias
Greg KH
maintainerQuoted 11 lines · Mathias Nyman
Quoted 10 lines · Greg KH
Quoted 5 lines · Mathias Nyman
Hi Greg
Some xhci features and fixes for usb-next.
Both fixing some possible memory leaks that are too late for usb-linus, and simple code cleanups for usb-nextDid you miss this one:
https://lore.kernel.org/r/[email protected]
Quoted 8 lines
Quoted 1 line
or was there some issue with it?
Got distracted while looking at it.
Can be added but probably not that useful.
In a host controller error (HCE) case all host activity stops, so it would make more sense to check HCE bit in timeout cases than in interrupt handler.
Ok, no worries, I'll drop it from my review queue, but you should respond to the patch submission with this information.
thanks,
greg k-h