mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: badhri@google.com, heikki.krogerus@linux.intel.com,
	gregkh@linuxfoundation.org, dsimic@manjaro.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH] Revert "tcpm: allow looking for role_sw device in the main node"
Date: Fri, 27 Feb 2026 16:45:30 +0100	[thread overview]
Message-ID: <073cbeb3-04a8-4b26-a7b6-ef0b7654c34c@collabora.com> (raw)
In-Reply-To: <im3nnajzv2hdu3kv2hknxi3jaz3oam5pujdoapva4hs5rzguky@t45ryche6n5k>

Hi Xu,

Le 25/02/2026 à 03:57, Xu Yang a écrit :
> Hi Arnaud,
> 
> On Tue, Feb 24, 2026 at 12:33:33PM +0100, Arnaud Ferraris wrote:
>> Hi,
>>
>> Le 24/02/2026 à 12:01, Xu Yang a écrit :
>>> This reverts commit 1366cd228b0c67b60a2c0c26ef37fe9f7cfedb7f.
>>
>> I believe a plain revert isn't the right solution here, as we'll get to the
>> same point as we were before 1366cd228b0c, where some devices stopped
>> working properly with newer kernels.
> 
> I don't think 1366cd228b0c fix the real root problem because the description
> should be wrong in the commit message. If -EPROBE_DEFER is returned by
> fwnode_usb_role_switch_get(), the ports node should be in connector node
> instead of tcpc node. However, you get the error when ports in tcpc node.
> 
> Could you double check the issue, so we can find a proper solution and avoid
> the further regression?

Sure, I'll come up with more details asap, either tomorrow or early next 
week.

Best regards,
Arnaud

> 
>>
>>>
>>> The fwnode_usb_role_switch_get() returns NULL only if no connection is
>>> found, returns ERR_PTR(-EPROBE_DEFER) if connection is found but deferred
>>> probe is needed, or a valid pointer of usb_role_switch.
>>>
>>> When switching from NULL check to IS_ERR_OR_NULL(), usb_role_switch_get()
>>> will return NULL pointer which will override ERR_PTR(-EPROBE_DEFER) which
>>> is returned by fwnode_usb_role_switch_get(). Then usb role switch can't be
>>> obtained because the defer probe info is lost. So the unique error should
>>> not be regarded the same as NULL.
>>>
>>> Fixes: 1366cd228b0c ("tcpm: allow looking for role_sw device in the main node")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>>>
>>> ---
>>> Also correct a description in 1366cd228b0c ("tcpm: allow looking for
>>> role_sw device in the main node"), if the ports are defined in the tcpc
>>> main node, NULL pointer is returned by fwnode_usb_role_switch_get()
>>> instead of an error.
>>> ---
>>>    drivers/usb/typec/tcpm/tcpm.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
>>> index 1d2f3af034c5..8e0e14a2704e 100644
>>> --- a/drivers/usb/typec/tcpm/tcpm.c
>>> +++ b/drivers/usb/typec/tcpm/tcpm.c
>>> @@ -7890,7 +7890,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>>>    	port->partner_desc.identity = &port->partner_ident;
>>>    	port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
>>> -	if (IS_ERR_OR_NULL(port->role_sw))
>>> +	if (!port->role_sw)
>>
>> It might be worth saving the error and restoring it after the call to
>> usb_role_switch_get() instead, something like:
>>
>> 	if (IS_ERR_OR_NULL(port->role_sw)) {
>> 		err = PTR_ERR(port->role_sw);
>> 		port->role_sw = usb_role_switch_get(port->dev);
>> 		if (!port->role_sw)
>> 			port->role_sw = ERR_PTR(err);
>> 	}
> 
> It works but we'd better to get the thing clear firstly.
> 
> Thanks,
> Xu Yang


  reply	other threads:[~2026-02-27 15:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 11:01 Xu Yang
2026-02-24 11:33 ` Arnaud Ferraris
2026-02-25  2:57   ` Xu Yang
2026-02-27 15:45     ` Arnaud Ferraris [this message]
2026-03-05  9:40       ` Xu Yang
2026-03-05 16:36         ` Arnaud Ferraris
2026-03-06  9:52           ` Xu Yang
2026-03-06 16:24             ` Arnaud Ferraris
2026-03-09  7:36               ` 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=073cbeb3-04a8-4b26-a7b6-ef0b7654c34c@collabora.com \
    --to=arnaud.ferraris@collabora.com \
    --cc=badhri@google.com \
    --cc=dsimic@manjaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --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

all inboxes | Powered by JetHome®