linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Fix a logic error in wake on connect
@ 2025-04-11 15:14 Mario Limonciello
  2025-04-11 15:20 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Mario Limonciello @ 2025-04-11 15:14 UTC (permalink / raw)
  To: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal
  Cc: mika.westerberg, linux-usb

From: Mario Limonciello <mario.limonciello@amd.com>

commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
on USB4 ports") introduced a sysfs file to control wake up policy
for a given USB4 port that defaulted to disabled.

However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
on connect and disconnect over suspend") I found that it was working
even without making changes to the power/wakeup file (which defaults
to disabled). This is because of a logic error doing a bitwise or
of the wake-on-connect flag with device_may_wakeup() which should
have been a logical AND.

Adjust the logic so that policy is only applied when wakeup is
actually enabled.

Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/thunderbolt/usb4.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index e51d01671d8e7..3e96f1afd4268 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -440,10 +440,10 @@ int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
 			bool configured = val & PORT_CS_19_PC;
 			usb4 = port->usb4;
 
-			if (((flags & TB_WAKE_ON_CONNECT) |
+			if (((flags & TB_WAKE_ON_CONNECT) &&
 			      device_may_wakeup(&usb4->dev)) && !configured)
 				val |= PORT_CS_19_WOC;
-			if (((flags & TB_WAKE_ON_DISCONNECT) |
+			if (((flags & TB_WAKE_ON_DISCONNECT) &&
 			      device_may_wakeup(&usb4->dev)) && configured)
 				val |= PORT_CS_19_WOD;
 			if ((flags & TB_WAKE_ON_USB4) && configured)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] thunderbolt: Fix a logic error in wake on connect
  2025-04-11 15:14 [PATCH] thunderbolt: Fix a logic error in wake on connect Mario Limonciello
@ 2025-04-11 15:20 ` Greg KH
  2025-04-16 12:37 ` Mika Westerberg
  2025-06-29 17:52 ` [REGRESSION] " Alyssa Ross
  2 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2025-04-11 15:20 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb

On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
> 
> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
> on USB4 ports") introduced a sysfs file to control wake up policy
> for a given USB4 port that defaulted to disabled.
> 
> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
> on connect and disconnect over suspend") I found that it was working
> even without making changes to the power/wakeup file (which defaults
> to disabled). This is because of a logic error doing a bitwise or
> of the wake-on-connect flag with device_may_wakeup() which should
> have been a logical AND.
> 
> Adjust the logic so that policy is only applied when wakeup is
> actually enabled.
> 
> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/thunderbolt/usb4.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] thunderbolt: Fix a logic error in wake on connect
  2025-04-11 15:14 [PATCH] thunderbolt: Fix a logic error in wake on connect Mario Limonciello
  2025-04-11 15:20 ` Greg KH
@ 2025-04-16 12:37 ` Mika Westerberg
  2025-04-16 13:27   ` Mario Limonciello
  2025-06-29 17:52 ` [REGRESSION] " Alyssa Ross
  2 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2025-04-16 12:37 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, linux-usb

On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
> 
> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
> on USB4 ports") introduced a sysfs file to control wake up policy
> for a given USB4 port that defaulted to disabled.
> 
> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
> on connect and disconnect over suspend") I found that it was working
> even without making changes to the power/wakeup file (which defaults
> to disabled). This is because of a logic error doing a bitwise or
> of the wake-on-connect flag with device_may_wakeup() which should
> have been a logical AND.
> 
> Adjust the logic so that policy is only applied when wakeup is
> actually enabled.
> 
> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

I guess the offending commit was never even tested :(

Applied to thunderbolt.git/next thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] thunderbolt: Fix a logic error in wake on connect
  2025-04-16 12:37 ` Mika Westerberg
@ 2025-04-16 13:27   ` Mario Limonciello
  2025-04-16 16:23     ` Mika Westerberg
  0 siblings, 1 reply; 11+ messages in thread
From: Mario Limonciello @ 2025-04-16 13:27 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, linux-usb

On 4/16/2025 7:37 AM, Mika Westerberg wrote:
> On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
>> on USB4 ports") introduced a sysfs file to control wake up policy
>> for a given USB4 port that defaulted to disabled.
>>
>> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
>> on connect and disconnect over suspend") I found that it was working
>> even without making changes to the power/wakeup file (which defaults
>> to disabled). This is because of a logic error doing a bitwise or
>> of the wake-on-connect flag with device_may_wakeup() which should
>> have been a logical AND.
>>
>> Adjust the logic so that policy is only applied when wakeup is
>> actually enabled.
>>
>> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> 
> I guess the offending commit was never even tested :(
> 

Yeah that is my only explanation too.  So now this begs the question do 
we do the 3rd step that we set all the ports to 'enabled' by default?

> Applied to thunderbolt.git/next thanks!

Thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] thunderbolt: Fix a logic error in wake on connect
  2025-04-16 13:27   ` Mario Limonciello
@ 2025-04-16 16:23     ` Mika Westerberg
  0 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2025-04-16 16:23 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, linux-usb

On Wed, Apr 16, 2025 at 08:27:10AM -0500, Mario Limonciello wrote:
> On 4/16/2025 7:37 AM, Mika Westerberg wrote:
> > On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
> > > From: Mario Limonciello <mario.limonciello@amd.com>
> > > 
> > > commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
> > > on USB4 ports") introduced a sysfs file to control wake up policy
> > > for a given USB4 port that defaulted to disabled.
> > > 
> > > However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
> > > on connect and disconnect over suspend") I found that it was working
> > > even without making changes to the power/wakeup file (which defaults
> > > to disabled). This is because of a logic error doing a bitwise or
> > > of the wake-on-connect flag with device_may_wakeup() which should
> > > have been a logical AND.
> > > 
> > > Adjust the logic so that policy is only applied when wakeup is
> > > actually enabled.
> > > 
> > > Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
> > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> > 
> > I guess the offending commit was never even tested :(
> > 
> 
> Yeah that is my only explanation too.  So now this begs the question do we
> do the 3rd step that we set all the ports to 'enabled' by default?

No we don't. That needs the userspace that can do dark resume and we cannot
assume it by default.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [REGRESSION] thunderbolt: Fix a logic error in wake on connect
  2025-04-11 15:14 [PATCH] thunderbolt: Fix a logic error in wake on connect Mario Limonciello
  2025-04-11 15:20 ` Greg KH
  2025-04-16 12:37 ` Mika Westerberg
@ 2025-06-29 17:52 ` Alyssa Ross
  2025-06-30 11:32   ` Alyssa Ross
  2 siblings, 1 reply; 11+ messages in thread
From: Alyssa Ross @ 2025-06-29 17:52 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb,
	regressions, kim.lindberger, linux, Sasha Levin, stable,
	Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 2282 bytes --]

On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
> on USB4 ports") introduced a sysfs file to control wake up policy
> for a given USB4 port that defaulted to disabled.
>
> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
> on connect and disconnect over suspend") I found that it was working
> even without making changes to the power/wakeup file (which defaults
> to disabled). This is because of a logic error doing a bitwise or
> of the wake-on-connect flag with device_may_wakeup() which should
> have been a logical AND.
>
> Adjust the logic so that policy is only applied when wakeup is
> actually enabled.
>
> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Hi! There have been a couple of reports of a Thunderbolt regression in
recent stable kernels, and one reporter has now bisected it to this
change:

 • https://bugzilla.kernel.org/show_bug.cgi?id=220284https://github.com/NixOS/nixpkgs/issues/420730

Both reporters are CCed, and say it starts working after the module is
reloaded.

Link: https://lore.kernel.org/r/bug-220284-208809@https.bugzilla.kernel.org%2F/
(for regzbot)

> ---
>  drivers/thunderbolt/usb4.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
> index e51d01671d8e7..3e96f1afd4268 100644
> --- a/drivers/thunderbolt/usb4.c
> +++ b/drivers/thunderbolt/usb4.c
> @@ -440,10 +440,10 @@ int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
>  			bool configured = val & PORT_CS_19_PC;
>  			usb4 = port->usb4;
>
> -			if (((flags & TB_WAKE_ON_CONNECT) |
> +			if (((flags & TB_WAKE_ON_CONNECT) &&
>  			      device_may_wakeup(&usb4->dev)) && !configured)
>  				val |= PORT_CS_19_WOC;
> -			if (((flags & TB_WAKE_ON_DISCONNECT) |
> +			if (((flags & TB_WAKE_ON_DISCONNECT) &&
>  			      device_may_wakeup(&usb4->dev)) && configured)
>  				val |= PORT_CS_19_WOD;
>  			if ((flags & TB_WAKE_ON_USB4) && configured)
> --
> 2.43.0
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [REGRESSION] thunderbolt: Fix a logic error in wake on connect
  2025-06-29 17:52 ` [REGRESSION] " Alyssa Ross
@ 2025-06-30 11:32   ` Alyssa Ross
  2025-07-06 14:46     ` Mario Limonciello
  0 siblings, 1 reply; 11+ messages in thread
From: Alyssa Ross @ 2025-06-30 11:32 UTC (permalink / raw)
  To: regressions
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb,
	kim.lindberger, linux, Sasha Levin, stable, Greg Kroah-Hartman,
	Mario Limonciello

[-- Attachment #1: Type: text/plain, Size: 1887 bytes --]

Alyssa Ross <hi@alyssa.is> writes:

> On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
>> on USB4 ports") introduced a sysfs file to control wake up policy
>> for a given USB4 port that defaulted to disabled.
>>
>> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
>> on connect and disconnect over suspend") I found that it was working
>> even without making changes to the power/wakeup file (which defaults
>> to disabled). This is because of a logic error doing a bitwise or
>> of the wake-on-connect flag with device_may_wakeup() which should
>> have been a logical AND.
>>
>> Adjust the logic so that policy is only applied when wakeup is
>> actually enabled.
>>
>> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>
> Hi! There have been a couple of reports of a Thunderbolt regression in
> recent stable kernels, and one reporter has now bisected it to this
> change:
>
>  • https://bugzilla.kernel.org/show_bug.cgi?id=220284
>  • https://github.com/NixOS/nixpkgs/issues/420730
>
> Both reporters are CCed, and say it starts working after the module is
> reloaded.
>
> Link: https://lore.kernel.org/r/bug-220284-208809@https.bugzilla.kernel.org%2F/
> (for regzbot)

Apparently[1] fixed by the first linked patch below, which is currently in
the Thunderbolt tree waiting to be pulled into the USB tree.

#regzbot monitor: https://lore.kernel.org/linux-usb/20250619213840.2388646-1-superm1@kernel.org/
#regzbot monitor: https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/

[1]: https://github.com/NixOS/nixpkgs/issues/420730#issuecomment-3018563631

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [REGRESSION] thunderbolt: Fix a logic error in wake on connect
  2025-06-30 11:32   ` Alyssa Ross
@ 2025-07-06 14:46     ` Mario Limonciello
  2025-07-07  7:57       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Mario Limonciello @ 2025-07-06 14:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb,
	kim.lindberger, linux, Sasha Levin, stable, Alyssa Ross,
	regressions

On 6/30/25 07:32, Alyssa Ross wrote:
> Alyssa Ross <hi@alyssa.is> writes:
> 
>> On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>
>>> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
>>> on USB4 ports") introduced a sysfs file to control wake up policy
>>> for a given USB4 port that defaulted to disabled.
>>>
>>> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
>>> on connect and disconnect over suspend") I found that it was working
>>> even without making changes to the power/wakeup file (which defaults
>>> to disabled). This is because of a logic error doing a bitwise or
>>> of the wake-on-connect flag with device_may_wakeup() which should
>>> have been a logical AND.
>>>
>>> Adjust the logic so that policy is only applied when wakeup is
>>> actually enabled.
>>>
>>> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>
>> Hi! There have been a couple of reports of a Thunderbolt regression in
>> recent stable kernels, and one reporter has now bisected it to this
>> change:
>>
>>   • https://bugzilla.kernel.org/show_bug.cgi?id=220284
>>   • https://github.com/NixOS/nixpkgs/issues/420730
>>
>> Both reporters are CCed, and say it starts working after the module is
>> reloaded.
>>
>> Link: https://lore.kernel.org/r/bug-220284-208809@https.bugzilla.kernel.org%2F/
>> (for regzbot)
> 
> Apparently[1] fixed by the first linked patch below, which is currently in
> the Thunderbolt tree waiting to be pulled into the USB tree.
> 
> #regzbot monitor: https://lore.kernel.org/linux-usb/20250619213840.2388646-1-superm1@kernel.org/
> #regzbot monitor: https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/
> 
> [1]: https://github.com/NixOS/nixpkgs/issues/420730#issuecomment-3018563631

Hey Greg,

Can you pick up the pull request from Mika from a week and a half ago 
with this fix for the next 6.16-rc?

https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/

Thanks,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [REGRESSION] thunderbolt: Fix a logic error in wake on connect
  2025-07-06 14:46     ` Mario Limonciello
@ 2025-07-07  7:57       ` Greg Kroah-Hartman
  2025-07-14 16:35         ` Mario Limonciello
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-07  7:57 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb,
	kim.lindberger, linux, Sasha Levin, stable, Alyssa Ross,
	regressions

On Sun, Jul 06, 2025 at 10:46:53AM -0400, Mario Limonciello wrote:
> On 6/30/25 07:32, Alyssa Ross wrote:
> > Alyssa Ross <hi@alyssa.is> writes:
> > 
> > > On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
> > > > From: Mario Limonciello <mario.limonciello@amd.com>
> > > > 
> > > > commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
> > > > on USB4 ports") introduced a sysfs file to control wake up policy
> > > > for a given USB4 port that defaulted to disabled.
> > > > 
> > > > However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
> > > > on connect and disconnect over suspend") I found that it was working
> > > > even without making changes to the power/wakeup file (which defaults
> > > > to disabled). This is because of a logic error doing a bitwise or
> > > > of the wake-on-connect flag with device_may_wakeup() which should
> > > > have been a logical AND.
> > > > 
> > > > Adjust the logic so that policy is only applied when wakeup is
> > > > actually enabled.
> > > > 
> > > > Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
> > > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> > > 
> > > Hi! There have been a couple of reports of a Thunderbolt regression in
> > > recent stable kernels, and one reporter has now bisected it to this
> > > change:
> > > 
> > >   • https://bugzilla.kernel.org/show_bug.cgi?id=220284
> > >   • https://github.com/NixOS/nixpkgs/issues/420730
> > > 
> > > Both reporters are CCed, and say it starts working after the module is
> > > reloaded.
> > > 
> > > Link: https://lore.kernel.org/r/bug-220284-208809@https.bugzilla.kernel.org%2F/
> > > (for regzbot)
> > 
> > Apparently[1] fixed by the first linked patch below, which is currently in
> > the Thunderbolt tree waiting to be pulled into the USB tree.
> > 
> > #regzbot monitor: https://lore.kernel.org/linux-usb/20250619213840.2388646-1-superm1@kernel.org/
> > #regzbot monitor: https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/
> > 
> > [1]: https://github.com/NixOS/nixpkgs/issues/420730#issuecomment-3018563631
> 
> Hey Greg,
> 
> Can you pick up the pull request from Mika from a week and a half ago with
> this fix for the next 6.16-rc?
> 
> https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/

Yes, I was waiting for this last round to go to Linus as the pull
request was made against a newer version of Linus's tree than I
currently had in my "for linus" branch.  I'll go get to that later
today.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [REGRESSION] thunderbolt: Fix a logic error in wake on connect
  2025-07-07  7:57       ` Greg Kroah-Hartman
@ 2025-07-14 16:35         ` Mario Limonciello
  2025-07-15  5:56           ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Mario Limonciello @ 2025-07-14 16:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb,
	kim.lindberger, linux, Sasha Levin, stable, Alyssa Ross,
	regressions

On 7/7/25 2:57 AM, Greg Kroah-Hartman wrote:
> On Sun, Jul 06, 2025 at 10:46:53AM -0400, Mario Limonciello wrote:
>> On 6/30/25 07:32, Alyssa Ross wrote:
>>> Alyssa Ross <hi@alyssa.is> writes:
>>>
>>>> On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
>>>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>>>
>>>>> commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
>>>>> on USB4 ports") introduced a sysfs file to control wake up policy
>>>>> for a given USB4 port that defaulted to disabled.
>>>>>
>>>>> However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
>>>>> on connect and disconnect over suspend") I found that it was working
>>>>> even without making changes to the power/wakeup file (which defaults
>>>>> to disabled). This is because of a logic error doing a bitwise or
>>>>> of the wake-on-connect flag with device_may_wakeup() which should
>>>>> have been a logical AND.
>>>>>
>>>>> Adjust the logic so that policy is only applied when wakeup is
>>>>> actually enabled.
>>>>>
>>>>> Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>
>>>> Hi! There have been a couple of reports of a Thunderbolt regression in
>>>> recent stable kernels, and one reporter has now bisected it to this
>>>> change:
>>>>
>>>>    • https://bugzilla.kernel.org/show_bug.cgi?id=220284
>>>>    • https://github.com/NixOS/nixpkgs/issues/420730
>>>>
>>>> Both reporters are CCed, and say it starts working after the module is
>>>> reloaded.
>>>>
>>>> Link: https://lore.kernel.org/r/bug-220284-208809@https.bugzilla.kernel.org%2F/
>>>> (for regzbot)
>>>
>>> Apparently[1] fixed by the first linked patch below, which is currently in
>>> the Thunderbolt tree waiting to be pulled into the USB tree.
>>>
>>> #regzbot monitor: https://lore.kernel.org/linux-usb/20250619213840.2388646-1-superm1@kernel.org/
>>> #regzbot monitor: https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/
>>>
>>> [1]: https://github.com/NixOS/nixpkgs/issues/420730#issuecomment-3018563631
>>
>> Hey Greg,
>>
>> Can you pick up the pull request from Mika from a week and a half ago with
>> this fix for the next 6.16-rc?
>>
>> https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/
> 
> Yes, I was waiting for this last round to go to Linus as the pull
> request was made against a newer version of Linus's tree than I
> currently had in my "for linus" branch.  I'll go get to that later
> today.
> 
> thanks,
> 
> greg k-h
> 

Greg,

Sorry to be a bugger, but I was surprised I didn't see this come in -rc6 
this week, and I went and double checked your "usb-linus" branch [1] and 
didn't see it there.

Thanks,

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/log/?h=usb-linus

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [REGRESSION] thunderbolt: Fix a logic error in wake on connect
  2025-07-14 16:35         ` Mario Limonciello
@ 2025-07-15  5:56           ` Greg Kroah-Hartman
  0 siblings, 0 replies; 11+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-15  5:56 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, andreas.noever, michael.jamet, westeri,
	YehezkelShB, rajat.khandelwal, mika.westerberg, linux-usb,
	kim.lindberger, linux, Sasha Levin, stable, Alyssa Ross,
	regressions

On Mon, Jul 14, 2025 at 11:35:39AM -0500, Mario Limonciello wrote:
> On 7/7/25 2:57 AM, Greg Kroah-Hartman wrote:
> > On Sun, Jul 06, 2025 at 10:46:53AM -0400, Mario Limonciello wrote:
> > > On 6/30/25 07:32, Alyssa Ross wrote:
> > > > Alyssa Ross <hi@alyssa.is> writes:
> > > > 
> > > > > On Fri, Apr 11, 2025 at 10:14:44AM -0500, Mario Limonciello wrote:
> > > > > > From: Mario Limonciello <mario.limonciello@amd.com>
> > > > > > 
> > > > > > commit a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect
> > > > > > on USB4 ports") introduced a sysfs file to control wake up policy
> > > > > > for a given USB4 port that defaulted to disabled.
> > > > > > 
> > > > > > However when testing commit 4bfeea6ec1c02 ("thunderbolt: Use wake
> > > > > > on connect and disconnect over suspend") I found that it was working
> > > > > > even without making changes to the power/wakeup file (which defaults
> > > > > > to disabled). This is because of a logic error doing a bitwise or
> > > > > > of the wake-on-connect flag with device_may_wakeup() which should
> > > > > > have been a logical AND.
> > > > > > 
> > > > > > Adjust the logic so that policy is only applied when wakeup is
> > > > > > actually enabled.
> > > > > > 
> > > > > > Fixes: a5cfc9d65879c ("thunderbolt: Add wake on connect/disconnect on USB4 ports")
> > > > > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> > > > > 
> > > > > Hi! There have been a couple of reports of a Thunderbolt regression in
> > > > > recent stable kernels, and one reporter has now bisected it to this
> > > > > change:
> > > > > 
> > > > >    • https://bugzilla.kernel.org/show_bug.cgi?id=220284
> > > > >    • https://github.com/NixOS/nixpkgs/issues/420730
> > > > > 
> > > > > Both reporters are CCed, and say it starts working after the module is
> > > > > reloaded.
> > > > > 
> > > > > Link: https://lore.kernel.org/r/bug-220284-208809@https.bugzilla.kernel.org%2F/
> > > > > (for regzbot)
> > > > 
> > > > Apparently[1] fixed by the first linked patch below, which is currently in
> > > > the Thunderbolt tree waiting to be pulled into the USB tree.
> > > > 
> > > > #regzbot monitor: https://lore.kernel.org/linux-usb/20250619213840.2388646-1-superm1@kernel.org/
> > > > #regzbot monitor: https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/
> > > > 
> > > > [1]: https://github.com/NixOS/nixpkgs/issues/420730#issuecomment-3018563631
> > > 
> > > Hey Greg,
> > > 
> > > Can you pick up the pull request from Mika from a week and a half ago with
> > > this fix for the next 6.16-rc?
> > > 
> > > https://lore.kernel.org/linux-usb/20250626154009.GK2824380@black.fi.intel.com/
> > 
> > Yes, I was waiting for this last round to go to Linus as the pull
> > request was made against a newer version of Linus's tree than I
> > currently had in my "for linus" branch.  I'll go get to that later
> > today.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Greg,
> 
> Sorry to be a bugger, but I was surprised I didn't see this come in -rc6
> this week, and I went and double checked your "usb-linus" branch [1] and
> didn't see it there.
> 
> Thanks,
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/log/?h=usb-linus

It's in there:

$ git lg main..usb-linus
*   cd0f8649d0e1 - (HEAD -> usb-linus, origin/usb-linus, kroah.org/usb-linus, work-linus) Merge tag 'usb-serial-6.16-rc6' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-linus (6 days ago) <Greg Kroah-Hartman>
|\  
| * 08f49cdb71f3 - USB: serial: option: add Foxconn T99W640 (3 weeks ago) <Slark Xiao>
* 3014168731b7 - usb: gadget: configfs: Fix OOB read on empty string write (6 days ago) <Xinyu Liu>
* 67a59f82196c - usb: musb: fix gadget state on disconnect (8 days ago) <Drew Hamilton>
* 9fccced2d25b - Merge tag 'thunderbolt-for-v6.16-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus (8 days ago) <Greg Kroah-Hartman>
* 2cdde91c14ec - thunderbolt: Fix bit masking in tb_dp_port_set_hops() (3 weeks ago) <Alok Tiwari>
* 58d71d4242ce - thunderbolt: Fix wake on connect at runtime (3 weeks ago) <Mario Limonciello>

I'll get this to Linus for the next -rc.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-07-15  5:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 15:14 [PATCH] thunderbolt: Fix a logic error in wake on connect Mario Limonciello
2025-04-11 15:20 ` Greg KH
2025-04-16 12:37 ` Mika Westerberg
2025-04-16 13:27   ` Mario Limonciello
2025-04-16 16:23     ` Mika Westerberg
2025-06-29 17:52 ` [REGRESSION] " Alyssa Ross
2025-06-30 11:32   ` Alyssa Ross
2025-07-06 14:46     ` Mario Limonciello
2025-07-07  7:57       ` Greg Kroah-Hartman
2025-07-14 16:35         ` Mario Limonciello
2025-07-15  5:56           ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).