Re: [PATCH] usb: xhci: save hcd_priv memory of shared_hcd

From: Mathias Nyman
Date: Thu May 19 2022 - 03:46:28 EST


On 19.5.2022 5.17, Tao Wang wrote:
The shared_hcd->hcd_priv is not used in xhci, so not
need to malloc hcd priv memory for shared_hcd.

Signed-off-by: Tao Wang <quic_wat@xxxxxxxxxxx>
---
drivers/usb/host/xhci-plat.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 01dcfd7..a27dd3a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -336,6 +336,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
device_set_wakeup_capable(&pdev->dev, true);
xhci->main_hcd = hcd;
+ /*
+ * The shared_hcd->hcd_priv is not used in xhci,
+ * so not need to malloc hcd priv memory for shared_hcd.
+ */
+ driver->hcd_priv_size = 0;

A change like this will probably come back and bite us later.
We already allocated the additional hcd_priv_size bytes for primary hcd.
Future code can no longer rely on driver->hcd_priv_size being valid after this.

If saving this amount of memory is important then maybe look into
__usb_create_hcd() and avoid allocating the extra bytes if the hcd is not
the primary hcd.

Thanks
-Mathias