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]
Date:   Mon, 29 Jun 2020 07:26:41 +0000
From:   Peter Chen <peter.chen@....com>
To:     Philippe Schenker <philippe.schenker@...adex.com>
CC:     "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        Stefan Agner <stefan.agner@...adex.com>,
        Marcel Ziswiler <marcel.ziswiler@...adex.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: chipidea: fix ci_irq for role-switching use-case

On 20-06-26 13:03:11, Philippe Schenker wrote:
> If the hardware is in low-power-mode and one plugs in device or host
> it did not switch the mode due to the early exit out of the interrupt.

Do you mean there is no coming call for role-switch? Could you please share
your dts changes? Try below patch:


diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index e8ce300ad490..9e10dcfeb98f 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -1313,6 +1313,29 @@ static void ci_controller_suspend(struct ci_hdrc *ci)
 	enable_irq(ci->irq);
 }
 
+/*
+ * Handle the wakeup interrupt triggered by extcon connector
+ * We need to call ci_irq again for extcon since the first
+ * interrupt (wakeup int) only let the controller be out of
+ * low power mode, but not handle any interrupts.
+ */
+static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
+{
+	struct ci_hdrc_cable *cable_id, *cable_vbus;
+	u32 otgsc = hw_read_otgsc(ci, ~0);
+
+	cable_id = &ci->platdata->id_extcon;
+	cable_vbus = &ci->platdata->vbus_extcon;
+
+	if (!IS_ERR(cable_id->edev) && ci->is_otg &&
+		(otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS))
+		ci_irq(ci->irq, ci);
+
+	if (!IS_ERR(cable_vbus->edev) && ci->is_otg &&
+		(otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS))
+		ci_irq(ci->irq, ci);
+}
+
 static int ci_controller_resume(struct device *dev)
 {
 	struct ci_hdrc *ci = dev_get_drvdata(dev);
@@ -1343,6 +1366,7 @@ static int ci_controller_resume(struct device *dev)
 		enable_irq(ci->irq);
 		if (ci_otg_is_fsm_mode(ci))
 			ci_otg_fsm_wakeup_by_srp(ci);
+		ci_extcon_wakeup_int(ci);
 	}
 
 	return 0;

> 
> This patch fixes that behaviour and lets the rest of the code check if
> something has to be done. If nothing has to be done the same return
> value gets returned as before.

Before the controller leaving low power mode, otgsc value may not
correct since the controller/PHY is still in low power mode.

> 
> Fixes: 1f874edcb731 ("usb: chipidea: add runtime power management support")
> Signed-off-by: Philippe Schenker <philippe.schenker@...adex.com>
> 
> ---
> 
> Hi Peter
> 
> During my investigation I found a bug in ci_irq. I would appreciate
> if you could review this. From what I see this patch should be save to apply.
> 
> This patch does not solve all of our issues. When I have RUNTIME_PM
> enabled on imx6ull or imx7. RNDIS still does not come up. So there
> has to be another bug hiding somewhere in the Runtime PM code to prevent
> RNDIS from working properly. I quickly looked through your patches
> that added this stuff back in 2015 but couldn't spot anything related to
> usb gadget-mode.
> 
> If you right away know where the problem could be hiding itself,
> I would appreciate a hint.
> 

I need information for call trace for further suggestion.

Peter

> 
> ---
> 
>  drivers/usb/chipidea/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 9a7c53d09ab4..5159420a23a4 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -518,7 +518,7 @@ static irqreturn_t ci_irq(int irq, void *data)
>  		disable_irq_nosync(irq);
>  		ci->wakeup_int = true;
>  		pm_runtime_get(ci->dev);
> -		return IRQ_HANDLED;
> +		ret = IRQ_HANDLED;
>  	}
>  
>  	if (ci->is_otg) {
> -- 
> 2.27.0
> 

-- 

Thanks,
Peter Chen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ