lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240424011810.4gs3vs4f2qbjxbea@synopsys.com>
Date: Wed, 24 Apr 2024 01:18:13 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Krishna Kurapati <quic_kriskura@...cinc.com>
CC: Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Rob Herring <robh@...nel.org>, Bjorn Andersson <andersson@...nel.org>,
        Wesley Cheng <quic_wcheng@...cinc.com>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Conor Dooley <conor+dt@...nel.org>,
        Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
        Felipe Balbi <balbi@...nel.org>, Johan Hovold <johan@...nel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-arm-msm@...r.kernel.org" <linux-arm-msm@...r.kernel.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "quic_ppratap@...cinc.com" <quic_ppratap@...cinc.com>,
        "quic_jackp@...cinc.com" <quic_jackp@...cinc.com>,
        Johan Hovold <johan+linaro@...nel.org>,
        Bjorn Andersson <quic_bjorande@...cinc.com>
Subject: Re: [PATCH v21 8/9] usb: dwc3: qcom: Enable wakeup for applicable
 ports of multiport

On Sat, Apr 20, 2024, Krishna Kurapati wrote:
> DWC3 Qcom wrapper currently supports only wakeup configuration
> for single port controllers. Read speed of each port connected
> to the controller and enable wakeup for each of them accordingly.
> 
> Signed-off-by: Krishna Kurapati <quic_kriskura@...cinc.com>
> Reviewed-by: Johan Hovold <johan+linaro@...nel.org>
> Reviewed-by: Bjorn Andersson <quic_bjorande@...cinc.com>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 71 +++++++++++++++++++++---------------
>  1 file changed, 41 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 5ddb694dd8e7..b6f13bb14e2c 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -60,6 +60,7 @@ struct dwc3_qcom_port {
>  	int			dp_hs_phy_irq;
>  	int			dm_hs_phy_irq;
>  	int			ss_phy_irq;
> +	enum usb_device_speed	usb2_speed;
>  };
>  
>  struct dwc3_qcom {
> @@ -71,7 +72,6 @@ struct dwc3_qcom {
>  	struct reset_control	*resets;
>  	struct dwc3_qcom_port	ports[DWC3_QCOM_MAX_PORTS];
>  	u8			num_ports;
> -	enum usb_device_speed	usb2_speed;
>  
>  	struct extcon_dev	*edev;
>  	struct extcon_dev	*host_edev;
> @@ -310,7 +310,7 @@ static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom)
>  	return dwc->xhci;
>  }
>  
> -static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
> +static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, int port_index)
>  {
>  	struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
>  	struct usb_device *udev;
> @@ -321,14 +321,8 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
>  	 */
>  	hcd = platform_get_drvdata(dwc->xhci);
>  
> -	/*
> -	 * It is possible to query the speed of all children of
> -	 * USB2.0 root hub via usb_hub_for_each_child(). DWC3 code
> -	 * currently supports only 1 port per controller. So
> -	 * this is sufficient.
> -	 */
>  #ifdef CONFIG_USB
> -	udev = usb_hub_find_child(hcd->self.root_hub, 1);
> +	udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
>  #else
>  	udev = NULL;
>  #endif
> @@ -359,26 +353,26 @@ static void dwc3_qcom_disable_wakeup_irq(int irq)
>  	disable_irq_nosync(irq);
>  }
>  
> -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
> +static void dwc3_qcom_disable_port_interrupts(struct dwc3_qcom_port *port)
>  {
> -	dwc3_qcom_disable_wakeup_irq(qcom->ports[0].qusb2_phy_irq);
> +	dwc3_qcom_disable_wakeup_irq(port->qusb2_phy_irq);
>  
> -	if (qcom->usb2_speed == USB_SPEED_LOW) {
> -		dwc3_qcom_disable_wakeup_irq(qcom->ports[0].dm_hs_phy_irq);
> -	} else if ((qcom->usb2_speed == USB_SPEED_HIGH) ||
> -			(qcom->usb2_speed == USB_SPEED_FULL)) {
> -		dwc3_qcom_disable_wakeup_irq(qcom->ports[0].dp_hs_phy_irq);
> +	if (port->usb2_speed == USB_SPEED_LOW) {
> +		dwc3_qcom_disable_wakeup_irq(port->dm_hs_phy_irq);
> +	} else if ((port->usb2_speed == USB_SPEED_HIGH) ||
> +			(port->usb2_speed == USB_SPEED_FULL)) {
> +		dwc3_qcom_disable_wakeup_irq(port->dp_hs_phy_irq);
>  	} else {
> -		dwc3_qcom_disable_wakeup_irq(qcom->ports[0].dp_hs_phy_irq);
> -		dwc3_qcom_disable_wakeup_irq(qcom->ports[0].dm_hs_phy_irq);
> +		dwc3_qcom_disable_wakeup_irq(port->dp_hs_phy_irq);
> +		dwc3_qcom_disable_wakeup_irq(port->dm_hs_phy_irq);
>  	}
>  
> -	dwc3_qcom_disable_wakeup_irq(qcom->ports[0].ss_phy_irq);
> +	dwc3_qcom_disable_wakeup_irq(port->ss_phy_irq);
>  }
>  
> -static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> +static void dwc3_qcom_enable_port_interrupts(struct dwc3_qcom_port *port)
>  {
> -	dwc3_qcom_enable_wakeup_irq(qcom->ports[0].qusb2_phy_irq, 0);
> +	dwc3_qcom_enable_wakeup_irq(port->qusb2_phy_irq, 0);
>  
>  	/*
>  	 * Configure DP/DM line interrupts based on the USB2 device attached to
> @@ -389,21 +383,37 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
>  	 * DP and DM lines as rising edge to detect HS/HS/LS device connect scenario.
>  	 */
>  
> -	if (qcom->usb2_speed == USB_SPEED_LOW) {
> -		dwc3_qcom_enable_wakeup_irq(qcom->ports[0].dm_hs_phy_irq,
> +	if (port->usb2_speed == USB_SPEED_LOW) {
> +		dwc3_qcom_enable_wakeup_irq(port->dm_hs_phy_irq,
>  					    IRQ_TYPE_EDGE_FALLING);
> -	} else if ((qcom->usb2_speed == USB_SPEED_HIGH) ||
> -			(qcom->usb2_speed == USB_SPEED_FULL)) {
> -		dwc3_qcom_enable_wakeup_irq(qcom->ports[0].dp_hs_phy_irq,
> +	} else if ((port->usb2_speed == USB_SPEED_HIGH) ||
> +			(port->usb2_speed == USB_SPEED_FULL)) {
> +		dwc3_qcom_enable_wakeup_irq(port->dp_hs_phy_irq,
>  					    IRQ_TYPE_EDGE_FALLING);
>  	} else {
> -		dwc3_qcom_enable_wakeup_irq(qcom->ports[0].dp_hs_phy_irq,
> +		dwc3_qcom_enable_wakeup_irq(port->dp_hs_phy_irq,
>  					    IRQ_TYPE_EDGE_RISING);
> -		dwc3_qcom_enable_wakeup_irq(qcom->ports[0].dm_hs_phy_irq,
> +		dwc3_qcom_enable_wakeup_irq(port->dm_hs_phy_irq,
>  					    IRQ_TYPE_EDGE_RISING);
>  	}
>  
> -	dwc3_qcom_enable_wakeup_irq(qcom->ports[0].ss_phy_irq, 0);
> +	dwc3_qcom_enable_wakeup_irq(port->ss_phy_irq, 0);
> +}
> +
> +static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
> +{
> +	int i;
> +
> +	for (i = 0; i < qcom->num_ports; i++)
> +		dwc3_qcom_disable_port_interrupts(&qcom->ports[i]);
> +}
> +
> +static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> +{
> +	int i;
> +
> +	for (i = 0; i < qcom->num_ports; i++)
> +		dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
>  }
>  
>  static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
> @@ -430,7 +440,8 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
>  	 * freezable workqueue.
>  	 */
>  	if (dwc3_qcom_is_host(qcom) && wakeup) {
> -		qcom->usb2_speed = dwc3_qcom_read_usb2_speed(qcom);
> +		for (i = 0; i < qcom->num_ports; i++)
> +			qcom->ports[i].usb2_speed = dwc3_qcom_read_usb2_speed(qcom, i);
>  		dwc3_qcom_enable_interrupts(qcom);
>  	}
>  
> -- 
> 2.34.1
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@...opsys.com>

Thanks,
Thinh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ