public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Krishna Kurapati PSSNV <quic_kriskura@quicinc.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Rob Herring <robh@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Wesley Cheng <quic_wcheng@quicinc.com>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Felipe Balbi <balbi@kernel.org>, Johan Hovold <johan@kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"quic_ppratap@quicinc.com" <quic_ppratap@quicinc.com>,
	"quic_jackp@quicinc.com" <quic_jackp@quicinc.com>,
	Johan Hovold <johan+linaro@kernel.org>
Subject: Re: [PATCH v20 4/9] usb: dwc3: core: Refactor PHY logic to support Multiport Controller
Date: Wed, 10 Apr 2024 10:10:54 +0530	[thread overview]
Message-ID: <60e569d7-0d63-4b62-b666-1dd7919c8af2@quicinc.com> (raw)
In-Reply-To: <20240409181342.wmjvi6rwtxphnv3z@synopsys.com>



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 <quic_kriskura@quicinc.com>
>>>> Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
>>>> ---
>>>>    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(-)
>>>>
>>>
>>> <snip>
>>>
>>>> @@ -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;
>>>>    }
>>>
>>> <snip>
>>>
>>>> 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 <linux/power_supply.h>
>>>> +/*
>>>> + * 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.

Regards,
Krishna,

  reply	other threads:[~2024-04-10  4:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 13:29 [PATCH v20 0/9] Add multiport support for DWC3 controllers Krishna Kurapati
2024-04-08 13:29 ` [PATCH v20 1/9] dt-bindings: usb: Add bindings for multiport properties on DWC3 controller Krishna Kurapati
2024-04-08 13:29 ` [PATCH v20 2/9] usb: dwc3: core: Access XHCI address space temporarily to read port info Krishna Kurapati
2024-04-09  0:28   ` Thinh Nguyen
2024-04-08 13:29 ` [PATCH v20 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Krishna Kurapati
2024-04-08 13:29 ` [PATCH v20 4/9] usb: dwc3: core: Refactor PHY logic to support Multiport Controller Krishna Kurapati
2024-04-09  1:11   ` Thinh Nguyen
2024-04-09 17:42     ` Krishna Kurapati PSSNV
2024-04-09 18:13       ` Thinh Nguyen
2024-04-10  4:40         ` Krishna Kurapati PSSNV [this message]
2024-04-11 12:19           ` Greg Kroah-Hartman
2024-04-08 13:29 ` [PATCH v20 5/9] dt-bindings: usb: qcom,dwc3: Add bindings for SC8280 Multiport Krishna Kurapati
2024-04-08 13:29 ` [PATCH v20 6/9] usb: dwc3: qcom: Add helper function to request wakeup interrupts Krishna Kurapati
2024-04-09  1:12   ` Thinh Nguyen
2024-04-08 13:29 ` [PATCH v20 7/9] usb: dwc3: qcom: Refactor IRQ handling in glue driver Krishna Kurapati
2024-04-09  1:14   ` Thinh Nguyen
2024-04-08 13:29 ` [PATCH v20 8/9] usb: dwc3: qcom: Enable wakeup for applicable ports of multiport Krishna Kurapati
2024-04-09  1:16   ` Thinh Nguyen
2024-04-08 13:29 ` [PATCH v20 9/9] usb: dwc3: qcom: Add multiport suspend/resume support for wrapper Krishna Kurapati
2024-04-09  1:20   ` Thinh Nguyen

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=60e569d7-0d63-4b62-b666-1dd7919c8af2@quicinc.com \
    --to=quic_kriskura@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=andersson@kernel.org \
    --cc=balbi@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan+linaro@kernel.org \
    --cc=johan@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_jackp@quicinc.com \
    --cc=quic_ppratap@quicinc.com \
    --cc=quic_wcheng@quicinc.com \
    --cc=robh@kernel.org \
    /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