mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tao Wang <quic_wat@quicinc.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	"open list:USB SUBSYSTEM" <linux-usb@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: <quic_wat@quicinc.com>, <quic_linyyuan@quicinc.com>
Subject: [PATCH] usb: hcd: add a flag for whether using shared_hcd priv
Date: Thu, 7 Apr 2022 10:45:14 +0800	[thread overview]
Message-ID: <1649299514-64014-1-git-send-email-quic_wat@quicinc.com> (raw)

The shared_hcd->hcd_priv is not used in xhci, so not
need to malloc hcd priv memory for shared_hcd.

This change add a shared_hcd_no_priv flag to indicate
if shared_hcd use priv, and set the flag of xhci to 1.

Signed-off-by: Tao Wang <quic_wat@quicinc.com>
---
 drivers/usb/core/hcd.c       | 6 +++++-
 drivers/usb/host/xhci-plat.c | 1 +
 include/linux/usb/hcd.h      | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 99908d8..f339c3e 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2419,7 +2419,11 @@ struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
 {
 	struct usb_hcd *hcd;
 
-	hcd = kzalloc(sizeof(*hcd) + driver->hcd_priv_size, GFP_KERNEL);
+	if (primary_hcd && driver->shared_hcd_no_priv)
+		hcd = kzalloc(sizeof(*hcd), GFP_KERNEL);
+	else
+		hcd = kzalloc(sizeof(*hcd) + driver->hcd_priv_size, GFP_KERNEL);
+
 	if (!hcd)
 		return NULL;
 	if (primary_hcd == NULL) {
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 21280a6..223e508 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -236,6 +236,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 		return -ENODEV;
 
 	driver = &xhci_plat_hc_driver;
+	driver->shared_hcd_no_priv = 1;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 2ffafbd..03ac312 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -256,6 +256,7 @@ struct hc_driver {
 	const char	*description;	/* "ehci-hcd" etc */
 	const char	*product_desc;	/* product/vendor string */
 	size_t		hcd_priv_size;	/* size of private data */
+	bool		shared_hcd_no_priv;	/* 0 use priv, 1 not use priv*/
 
 	/* irq handler */
 	irqreturn_t	(*irq) (struct usb_hcd *hcd);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


             reply	other threads:[~2022-04-07  2:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07  2:45 Tao Wang [this message]
2022-04-21 16:48 ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1649299514-64014-1-git-send-email-quic_wat@quicinc.com \
    --to=quic_wat@quicinc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=quic_linyyuan@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®