Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp390633pxb; Fri, 22 Apr 2022 03:18:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGM/80k0L+MdGzcN9tOnFZ5T20/mlMBGp2OxLKiH58nl7VDfF4ibq1fEHM8dBp+9nd/Cfn X-Received: by 2002:a05:6402:1813:b0:425:adb9:4abd with SMTP id g19-20020a056402181300b00425adb94abdmr4099646edy.278.1650622728700; Fri, 22 Apr 2022 03:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650622728; cv=none; d=google.com; s=arc-20160816; b=JSi/oLAaUuwLE2EgJfVTL2keNzVLEdXIc0wGw/C99W43nT7aVGEgcpb5r89U77N3XQ GmZHIwmRAVMc+Q4jYXH8QMOrZCt0Wh4MCpotICGi00Nn26IipLR0k4RUj9kK6nj0WbHO qc4aedWvDcWu3hSqJy6a+VnwRY5iCxStWeuweqP/CuDdrOWZJ0/neeqbhfBvjZ2KjoEh gN6OXsX+5OmEm6uJ5BYERVaYk7MJoS8mefzeMvR6+IaX/mbb6yBQIi4fiGm5r2sc1xbo libEFVwJN8vlMWG2Im/JXt5yERmbeUXbRGZMOuL4Ms/sb5aa3i9jxqus+kkzQeJy3RyR RNlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mnGXZMYBAxnOYchPk3NLSBEpeJ44DP/kpcNNRLrTySg=; b=tk2L8W0PfklE5/MHKHgUMf8xXO2bPGER9LMzflALzEVt6ijkc9r547vWYoMEJT1KWR pybMiWY4Ootiuctb443VMM/6+j+kkjWjLcFzZyncTm91uxwsnuxvWWlDEFHurWsOOWfc o3YNZ4KbUlXjxUQT2zqttTrlyFXH1B3q/5Af/v4dqD+/NekT0jna8MJimjh4Hs2kGWIs m3UlEz9b2JU0eQKi2bhb5tWL/VzMkXGHPu+TjpKdc2ffRE40ke6zwAFoxOnOPIiGVAef ZQTqi5iYLWLr0ny1Gn0lfQVor7aRjSwQYszrQBEo6kDt+vSySY254K6PFwbVgSD01nch 4ZZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BfT+bMpA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a50cdd7000000b0041d8802d293si5713958edj.401.2022.04.22.03.18.24; Fri, 22 Apr 2022 03:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BfT+bMpA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232455AbiDUQvg (ORCPT + 99 others); Thu, 21 Apr 2022 12:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbiDUQve (ORCPT ); Thu, 21 Apr 2022 12:51:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA2CA49690; Thu, 21 Apr 2022 09:48:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 74AE861CD9; Thu, 21 Apr 2022 16:48:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 623E5C385A1; Thu, 21 Apr 2022 16:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650559723; bh=yP8brE5xLFSZ4V+019DWeeykSrtQQtHPVTTnvr0EayY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BfT+bMpAmzLMFlJadFbYxAXzctEsG9vI5g3xuKM28TFO9Zb45KHhP/bpb+r2GV6kk LnIH/COSCtqnDsqgMBC7oSwBwVAFvtETfczvM8uWEUBYdKpmqT0hqmscKFDUL4I2tZ uh+tezDqfQH242oZ8+joIgEc5xHBumdbD5JQ71dE= Date: Thu, 21 Apr 2022 18:48:40 +0200 From: Greg Kroah-Hartman To: Tao Wang Cc: Mathias Nyman , "open list:USB SUBSYSTEM" , open list , quic_linyyuan@quicinc.com Subject: Re: [PATCH] usb: hcd: add a flag for whether using shared_hcd priv Message-ID: References: <1649299514-64014-1-git-send-email-quic_wat@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1649299514-64014-1-git-send-email-quic_wat@quicinc.com> X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 07, 2022 at 10:45:14AM +0800, Tao Wang wrote: > The shared_hcd->hcd_priv is not used in xhci, so not > need to malloc hcd priv memory for shared_hcd. What is the problem with allocating that memory? Do you have systems with thousands of USB host controllers where this memory is wasted? > This change add a shared_hcd_no_priv flag to indicate > if shared_hcd use priv, and set the flag of xhci to 1. 1 is not a boolean :( > > Signed-off-by: Tao Wang > --- > 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; true? > > 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*/ Did you check to see how much extra padding you just added to the structure? When writing a change to try to save memory, do not cause extra memory to be wasted for everyone. thanks, greg k-h