Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4400776pxj; Mon, 21 Jun 2021 22:29:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOo2DdraaCKOVMmcixLePJDGT/BPkUgor2Pj10m86ZsirtBF9K9MHUJZpMM4NmpMtCZsZV X-Received: by 2002:a05:6e02:c6b:: with SMTP id f11mr1407943ilj.140.1624339750855; Mon, 21 Jun 2021 22:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624339750; cv=none; d=google.com; s=arc-20160816; b=lGJJ5YrObxxoIrrMVfcaZnLK9ds/2F/6Zq4wlTVogog5dGQZygy1YfxUqA9uAeA6A6 a0WVdEjzwckeZ0GexkgDJbBuHcRX/CJODDO2F+fVOHl1QBRkWBhaMyHxciMeycIsU0q9 QpEjYZ1u5HcGuP0+XtoH7E9dC8DnHHqnSnU1E8iKHxbNB+8hXLLeXcitIApeKhOGBaq7 g8FDDEQwxlWWVXWVRlRXKeR81ODSovzwSIWYORbpTeTyv5h0VXKbuROWJIRWgh4/nDzH yxduRuWs8ezoc2J+sv0Lf94/OSYYcvXi9IGBqFzDUvPVuFqSdess7jgYYdqlFIs1DiHr 2IAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=kX/KWqvomt6ymo0vZ4ejVIxk4DjhHljAq6y2gDsHnm0=; b=imHzBY7gQ7rzUkwSwvLZ+7gRFnOWXKmUVGP/NcnM/gHahjcorogxQvP56CDELTDED6 OZSU9Qe6dVS5dPB9bZ+lcDDkjCZQDbPDAipfi7J1RF2mKPFTyFn00efGDirlNa5EsL+c s+Gf0nNlodobU673OsmQrdLV1nQACLYit4FrXp5YwAYS69FvKu9jzv9uiJCN+4aE1y/D 9z6sPSfWFPeSWuudOaoObVb8V9Ce1r5pqBUQ0r/igMWbXAAYama7JKM5vEtYcdb/PgHi AjYtv84Rgc6SJ7s1f9C0T7jqYlle2GcPzCbx7vK5DCfYXN9pGjCO3JK+/lszOJ65vaVn km/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=EOpgb4WB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si13641644ilq.159.2021.06.21.22.28.59; Mon, 21 Jun 2021 22:29:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=EOpgb4WB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbhFVF3o (ORCPT + 99 others); Tue, 22 Jun 2021 01:29:44 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:35330 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbhFVF3n (ORCPT ); Tue, 22 Jun 2021 01:29:43 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1624339648; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=kX/KWqvomt6ymo0vZ4ejVIxk4DjhHljAq6y2gDsHnm0=; b=EOpgb4WB2stGxLxte3MUpoXNgx34QFidqozSoDB/anVc5zWIFR5JTG8lB+nXmIRgnwqpBeqn VXXLouXJ+wet6l6kqEz3z75I1z6KtkWlNd2puZpQD6/MHPgSkQNF1GCi+N4fWoL1HYwDGxK8 0iDBbSCDz62XNq8smYpA0z+WfKE= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 60d174ad2eaeb98b5ee5818f (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 22 Jun 2021 05:27:09 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 65C7AC4360C; Tue, 22 Jun 2021 05:27:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from [10.110.90.136] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wcheng) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3255DC433F1; Tue, 22 Jun 2021 05:27:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3255DC433F1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=wcheng@codeaurora.org Subject: Re: [PATCH v10 1/6] usb: gadget: udc: core: Introduce check_config to verify USB configuration To: Greg KH Cc: balbi@kernel.org, robh+dt@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, frowand.list@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, jackp@codeaurora.org, fntoth@gmail.com, heikki.krogerus@linux.intel.com, andy.shevchenko@gmail.com References: <1623923899-16759-1-git-send-email-wcheng@codeaurora.org> <1623923899-16759-2-git-send-email-wcheng@codeaurora.org> From: Wesley Cheng Message-ID: <241aeca7-3c24-29be-c9db-7e8da0b65baa@codeaurora.org> Date: Mon, 21 Jun 2021 22:27:06 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/2021 4:09 AM, Greg KH wrote: > On Thu, Jun 17, 2021 at 02:58:14AM -0700, Wesley Cheng wrote: >> Some UDCs may have constraints on how many high bandwidth endpoints it can >> support in a certain configuration. This API allows for the composite >> driver to pass down the total number of endpoints to the UDC so it can verify >> it has the required resources to support the configuration. >> >> Signed-off-by: Wesley Cheng >> --- >> drivers/usb/gadget/udc/core.c | 25 +++++++++++++++++++++++++ >> include/linux/usb/gadget.h | 5 +++++ >> 2 files changed, 30 insertions(+) >> >> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c >> index b7f0b1e..e33ae2d 100644 >> --- a/drivers/usb/gadget/udc/core.c >> +++ b/drivers/usb/gadget/udc/core.c >> @@ -1003,6 +1003,31 @@ int usb_gadget_ep_match_desc(struct usb_gadget *gadget, >> } >> EXPORT_SYMBOL_GPL(usb_gadget_ep_match_desc); >> >> +/** >> + * usb_gadget_check_config - checks if the UDC can support the number of eps >> + * @gadget: controller to check the USB configuration >> + * @ep_map: bitmap of endpoints being requested by a USB configuration Hi Greg, > > Will a u64 really hold all of the possible endpoints? > Ah, should be a u32 bitmap, and that is enough as USB spec only allows 32 EPs (IN+OUT eps) total. That hasn't changed since USB2, so I assume that will stay the same moving forward. I can fix that. > Why make it odd like this, why not just provide a list like we do in the > USB core with the structure that USB drivers use? What can a driver do > with a bitmap only? > I didn't want the ep bookeeping here to be too complicated. For example, in the TXFIFO resize situation, just knowing the number of endpoints used can help determine if we have enough internal controller memory to allocate per endpoint. (at minimum 1 FIFO per EP) If the USB configuration is going to be requesting more endpoints than FIFO memory it has (unlikely), then it will fail the config bind. Otherwise, we'd end up enumerating w/ the host w/ the interfaces that were starved of FIFO memory to be broken/non-functional. This was one of the concerns that Felipe had in our initial discussions. In addition, at the time of function driver binding, the amount of information we have is minimal per endpoint, as most of it is populated once the host places the device into the CONFIGURED state. (ie when the device knows which configuration is being enabled, hence which EPs are being used) Thanks Wesley Cheng > > thanks, > > greg k-h > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project