Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp353918lqg; Thu, 11 Apr 2024 05:20:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJamTqZw6VBf5isJiK2MMVBc1XbriQAbNMjo73TzoKwIeAOCBfumvkkyDASh6YZNyZUJdJjjJJ7In+G51ffHLtRyJpNUoCSx1f9GSJeQ== X-Google-Smtp-Source: AGHT+IHhxk52ab12y/tyrXYy7rYLzpkzsPgHB/VDlu3EaIoI02Zve4hXzRriI9L4tCacO1gDM4K2 X-Received: by 2002:a05:6808:b22:b0:3c5:ef39:9fd7 with SMTP id t2-20020a0568080b2200b003c5ef399fd7mr5229546oij.34.1712838034945; Thu, 11 Apr 2024 05:20:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712838034; cv=pass; d=google.com; s=arc-20160816; b=FEu90qIFNJwX4/s7tNU9Oskz58UKAHqal/s17T/VgC6MOhIBSM1BC6ElVqLGYEG6mq iXyt6X/v2KpTMN5Cue3JaAR3piodOwe3KN34CSODPW3nz8PAekilnnRD/w6FXWVrLQ1x hW9SxdVkfmRYddXjbgxIbAXYK0FtF1fcsnWEr4U7YzLwjHNIjUUaT9EfE3cKnPo2j70c DphPCUtM0JjUa42tJCNvaRk9WBXjsqf0rhgQCUVNqiYwkFUHla33IwmLBidPicDVqpkO NEwJ9T4HKqm84t4SSFR3tgAZ98wOcrcl/pAS++8WemLBPpGLoTqyytbNC2DTlcpQcZVu 0EBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Lb7I7a/+T3d8zkbCdJQWj21DHL/AE+El6azvucUUWDE=; fh=VPDKbZTKmUggMrlecHWQHh5NaA3Gmlpzc2Dgm64dJsg=; b=fuYYj2TB+9v5leVLzgCPXWXWV2J6/n0bfqvMd/BXXcA4IIBN1ArBX34HF7cfdvPtki Pz8qcPXzE/oAlffgzcko6d1NW5fGg5qnqhSW6ZMHxtycgTF/hF+FU28HterYq0sVV2I2 L8u+HOoOXqTWTOpqTgsWumz/tEMuxywH1aPy5jpvZqPfO1n2JH9t6BPs9gbECGAD7x4W v/CZGfIMlwBstsnH+lNGuhRTmtAD1457yGH7cnoH2mYUbh9boGWm9rw+rYSjjrMn6nnc DZYJydDTYoNk+dtljyfoO22ECgO+4SVcJUw7ibhHhi3M7hO3NsWBs2T5MGIJUQ2o4iyo Gc8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qE/lgtbR"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-140430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b11-20020ac87fcb000000b00434eaa49458si1383179qtk.668.2024.04.11.05.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 05:20:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qE/lgtbR"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-140430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A717D1C2222F for ; Thu, 11 Apr 2024 12:20:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C040E14D452; Thu, 11 Apr 2024 12:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qE/lgtbR" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E8D013FD66; Thu, 11 Apr 2024 12:20:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712838002; cv=none; b=MVs+DRwowoxArj7fyrHpaGfjhI7AKh+qZsyVlQikYgYEFrutsfR19+PvlSHBob/ZBR6r5EgoUfUScW/ovZZaw9eMivwIuE5UaBgpsM1kRLawMITEk3CnOiLqsv4BjXUypg1cVyVyfs75ZrvnO49yYKUAVKXW7CWgopHpNUmpRtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712838002; c=relaxed/simple; bh=KPb2wG+19jdDcMoEVEyKILaMpDqPAMPBDpsfS3XR3AA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XqznZO67NzNpXIPx2gfd1K4RAm5NySrwvnVnPMp8FqB4AtZD2T2cT01U5hTSsYwZwrlonbqUZS2rNmxX3QyBZTQYd1jHvYQYxaRJn95I/FljDY+wf7HS9FokdqW9dZNYLn9SYIj4tyHwskF0KXkEvtmS04VgOQ4aU72RgZr9fsE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qE/lgtbR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A294C43390; Thu, 11 Apr 2024 12:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712838001; bh=KPb2wG+19jdDcMoEVEyKILaMpDqPAMPBDpsfS3XR3AA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qE/lgtbRux/KFdT/kukz10+93UuJeasYA5Ev3LDTHFK7DSy/4HzyaD3qUAJbO+C60 uA1is1M279TXMcrbQvmTegTei+2GTcD9vjbMfdt3fJvfLVHRfXRxqzSmm9JSe1nTdn Ffxo2yoICktnPsRBhgUu5iYpVj4juHxcnqz5LAAc= Date: Thu, 11 Apr 2024 14:19:59 +0200 From: Greg Kroah-Hartman To: Krishna Kurapati PSSNV Cc: Thinh Nguyen , Krzysztof Kozlowski , Rob Herring , Bjorn Andersson , Wesley Cheng , Konrad Dybcio , Conor Dooley , Felipe Balbi , Johan Hovold , "devicetree@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "quic_ppratap@quicinc.com" , "quic_jackp@quicinc.com" , Johan Hovold Subject: Re: [PATCH v20 4/9] usb: dwc3: core: Refactor PHY logic to support Multiport Controller Message-ID: <2024041138-alienate-october-030d@gregkh> References: <20240408132925.1880571-1-quic_kriskura@quicinc.com> <20240408132925.1880571-5-quic_kriskura@quicinc.com> <20240409011046.zgjqvhewldch3snu@synopsys.com> <3ab9badd-2cf6-4fe0-aaf0-d08614418968@quicinc.com> <20240409181342.wmjvi6rwtxphnv3z@synopsys.com> <60e569d7-0d63-4b62-b666-1dd7919c8af2@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60e569d7-0d63-4b62-b666-1dd7919c8af2@quicinc.com> On Wed, Apr 10, 2024 at 10:10:54AM +0530, Krishna Kurapati PSSNV wrote: > > > On 4/9/2024 11:43 PM, Thinh Nguyen wrote: > > On Tue, Apr 09, 2024, Krishna Kurapati PSSNV wrote: > > > > > > > > > On 4/9/2024 6:41 AM, Thinh Nguyen wrote: > > > > On Mon, Apr 08, 2024, Krishna Kurapati wrote: > > > > > Currently the DWC3 driver supports only single port controller > > > > > which requires at least one HS PHY and at most one SS PHY. > > > > > > > > > > But the DWC3 USB controller can be connected to multiple ports and > > > > > each port can have their own PHYs. Each port of the multiport > > > > > controller can either be HS+SS capable or HS only capable > > > > > Proper quantification of them is required to modify GUSB2PHYCFG > > > > > and GUSB3PIPECTL registers appropriately. > > > > > > > > > > Add support for detecting, obtaining and configuring PHYs supported > > > > > by a multiport controller. Limit support to multiport controllers > > > > > with up to four ports for now (e.g. as needed for SC8280XP). > > > > > > > > > > Signed-off-by: Krishna Kurapati > > > > > Reviewed-by: Johan Hovold > > > > > --- > > > > > drivers/usb/dwc3/core.c | 251 ++++++++++++++++++++++++++++------------ > > > > > drivers/usb/dwc3/core.h | 14 ++- > > > > > drivers/usb/dwc3/drd.c | 15 ++- > > > > > 3 files changed, 193 insertions(+), 87 deletions(-) > > > > > > > > > > > > > > > > > > > > > > @@ -1937,6 +2020,10 @@ static int dwc3_get_num_ports(struct dwc3 *dwc) > > > > > iounmap(base); > > > > > + if (dwc->num_usb2_ports > DWC3_MAX_PORTS || > > > > > + dwc->num_usb3_ports > DWC3_MAX_PORTS) > > > > > + return -ENOMEM; > > > > > > > > This should be -EINVAL. > > > > > > > > > + > > > > > return 0; > > > > > } > > > > > > > > > > > > > > > > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > > > > > index 341e4c73cb2e..df2e111aa848 100644 > > > > > --- a/drivers/usb/dwc3/core.h > > > > > +++ b/drivers/usb/dwc3/core.h > > > > > @@ -33,6 +33,12 @@ > > > > > #include > > > > > +/* > > > > > + * Maximum number of ports currently supported for multiport > > > > > + * controllers. > > > > > > > > This macro here is being used per USB2 vs USB3 ports rather than USB2 + > > > > USB3, unlike the xHCI MAXPORTS. You can clarify in the comment and > > > > rename the macro to avoid any confusion. You can also create 2 separate > > > > macros for number of USB2 and USB3 ports even if they share the same > > > > value. > > > > > > > > As noted[*], we support have different max number of usb2 ports vs usb3 > > > > ports. I would suggest splitting the macros. > > > > > > > > > > Hi Thinh, > > > > > > This macro was intended only to identify how many USB2 (or USB3) Phy's were > > > serviced/operated by this driver, not how many logical ports present (like > > > > That's not what you described in the comment right above the macro... > > > > > in xHCI). I don't think it would be confusing currently given that it is > > > only used to identify number of generic phy instances to allocate and not > > > used for any other purpose. Once the num_usb2_ports and num_usb3_ports are > > > read by get_num_ports(...) call, they directly indicate how many ports are > > > > Those fields are clear. But for DWC3_MAX_PORTS, based on the name and > > comment of the macro, it's not clear. > > > > > HS and SS respectively. Keeping the same in mind, I returned ENOMEM above > > > (as you mentioned) because we don't allocate more than DWC3_MAX_PORTS and if > > > the number of hs or ss ports is more than that, we simply return ENOMEM > > > saying the driver doesn't support operating those many phy's. > > > > The error code -ENOMEM indicates out of memory failure. The check > > condition dwc->num_usb2_ports > DWC3_MAX_PORTS indicates invalid config. > > There's no allocation in that check. > > > > > > > > > [*] https://urldefense.com/v3/__https://lore.kernel.org/linux-usb/20230801013031.ft3zpoatiyfegmh6@synopsys.com/__;!!A4F2R9G_pg!azHqgm92ENkFQrpv6Fhs6PCe210VGOAIrsuGFhrgmfaor8N_kWLu6rxkPpbeCBTLL4NbUpOWlQ0ufmP9DFwO9iFc0XdSEg$ > > > > > > > > > + */ > > > > > +#define DWC3_MAX_PORTS 4 > > > > > + > > > > > > > > > > > > > But it's not a big issue whether you decided to push a new version or a > > > > create a separate patch for the comments above. Here's my Ack: > > > > > > > > > > Since this is not a bug, I would prefer to make a separate patch to rename > > > the macros. (If that is fine). > > > > > > > That is fine with me. Thanks for your effort pursuing and continue > > working on this series. > > > > Thanks Thinh. If there are no other issues, I will wait till Greg picks the > series up. Thanks for the reviews throughout the series. I can't take it yet, based on the review of this patch, so I'll wait for a new version of the series. thanks, greg k-h