public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Peter Chen (CIX)" <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, jun.li@nxp.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev
Subject: Re: [PATCH 1/2] usb: chipidea: core: fix device mode not work in non-lpm
Date: Wed, 25 Mar 2026 15:08:49 +0800	[thread overview]
Message-ID: <acOKAeNKWT86veM+@nchen-desktop> (raw)
In-Reply-To: <20260319095716.634568-1-xu.yang_2@nxp.com>

On 26-03-19 17:57:15, Xu Yang wrote:
> In current design, we expect 2 ci_irq() to handle ID and VBUS events in
> usb role switch, like what ci_extcon_wakeup_int() does. Now we only call
> ci_irq() once. However, this won't bring any issues in low power mode,
> because ci_irq() just take the device out of low power mode, and then
> ci_extcon_wakeup_int() will call ci_irq() twice. If the device is not in
> suspend state, the device mode will not work properly because VBUS event
> won'tbe handled (ID event has higher priority) at all.

%s/won'tbe/won't be

Is it possible change ci_irq_handler and handle both events?

> 
> Although 2 consecutive ci_irq() can work around the issue, do not do it
> because ci_usb_role_switch_set() may or not be in low power context which
> make the ci_irq() purpose not unique here. Because the final processing
> is in ci_otg_work(), just directly queue an otg work. This also refine
> the logic for more clarity and not set changed flag.
> 
> Fixes: e1b5d2bed67c ("usb: chipidea: core: handle usb role switch in a common way")
> Cc: stable@vger.kernel.org
> Reviewed-by: Jun Li <jun.li@nxp.com>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
>  drivers/usb/chipidea/core.c | 30 +++++++++++-------------------
>  1 file changed, 11 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index fac11f20cf0a..1bd231a852a1 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -618,30 +618,22 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw,
>  	struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw);
>  	struct ci_hdrc_cable *cable;
>  
> -	if (role == USB_ROLE_HOST) {
> -		cable = &ci->platdata->id_extcon;
> -		cable->changed = true;
> +	cable = &ci->platdata->id_extcon;
> +	if (role == USB_ROLE_HOST)
>  		cable->connected = true;
> -		cable = &ci->platdata->vbus_extcon;
> -		cable->changed = true;
> -		cable->connected = false;
> -	} else if (role == USB_ROLE_DEVICE) {
> -		cable = &ci->platdata->id_extcon;
> -		cable->changed = true;
> +	else
>  		cable->connected = false;
> -		cable = &ci->platdata->vbus_extcon;
> -		cable->changed = true;
> +
> +	cable = &ci->platdata->vbus_extcon;
> +	if (role == USB_ROLE_DEVICE)
>  		cable->connected = true;
> -	} else {
> -		cable = &ci->platdata->id_extcon;
> -		cable->changed = true;
> -		cable->connected = false;
> -		cable = &ci->platdata->vbus_extcon;
> -		cable->changed = true;
> +	else
>  		cable->connected = false;
> -	}
>  
> -	ci_irq(ci);
> +	ci->id_event = true;
> +	ci->b_sess_valid_event = true;

Why both ID and VBUS event are set as true unconditionally?

-- 

Best regards,
Peter

  parent reply	other threads:[~2026-03-25  7:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19  9:57 [PATCH 1/2] usb: chipidea: core: fix device mode not work in non-lpm Xu Yang
2026-03-19  9:57 ` [PATCH 2/2] usb: chipidea: otg: not wait vbus drop if use role_switch Xu Yang
2026-03-25  7:12   ` Peter Chen (CIX)
2026-03-25  7:08 ` Peter Chen (CIX) [this message]
2026-03-27 10:54   ` [PATCH 1/2] usb: chipidea: core: fix device mode not work in non-lpm Xu Yang

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=acOKAeNKWT86veM+@nchen-desktop \
    --to=peter.chen@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@nxp.com \
    /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