Wake on connect/disconnect is only supported while runtime suspend
for now, which is obviously necessary. Its also not inherently
desired for the system to wakeup on thunderbolt hot events.
However, we can still make user in control of waking up the system
in the events of hot plug/unplug.
This patch adds 'wakeup' attribute under 'usb4_portX/power' sysfs
attribute and only enables wakes on connect/disconnect to the
respective port when 'wakeup' is set to 'enabled'. The attribute
is set to 'disabled' by default.
Signed-off-by: Rajat Khandelwal <[email protected]>
---
drivers/thunderbolt/tb_regs.h | 2 ++
drivers/thunderbolt/usb4.c | 33 +++++++++++++++++++++++++--------
drivers/thunderbolt/usb4_port.c | 3 +++
3 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h
index 166054110388..04733fc1130c 100644
--- a/drivers/thunderbolt/tb_regs.h
+++ b/drivers/thunderbolt/tb_regs.h
@@ -358,6 +358,8 @@ struct tb_regs_port_header {
#define PORT_CS_18_BE BIT(8)
#define PORT_CS_18_TCM BIT(9)
#define PORT_CS_18_CPS BIT(10)
+#define PORT_CS_18_WOCS BIT(16)
+#define PORT_CS_18_WODS BIT(17)
#define PORT_CS_18_WOU4S BIT(18)
#define PORT_CS_19 0x13
#define PORT_CS_19_PC BIT(3)
diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index 3a2e7126db9d..0d5ff086814b 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -155,6 +155,8 @@ static inline int usb4_switch_op_data(struct tb_switch *sw, u16 opcode,
static void usb4_switch_check_wakes(struct tb_switch *sw)
{
+ bool wakeup_usb4 = false;
+ struct usb4_port *usb4;
struct tb_port *port;
bool wakeup = false;
u32 val;
@@ -173,20 +175,31 @@ static void usb4_switch_check_wakes(struct tb_switch *sw)
wakeup = val & (ROUTER_CS_6_WOPS | ROUTER_CS_6_WOUS);
}
- /* Check for any connected downstream ports for USB4 wake */
+ /*
+ * Check for any downstream ports for USB4 wake,
+ * connection wake and disconnection wake.
+ */
tb_switch_for_each_port(sw, port) {
- if (!tb_port_has_remote(port))
+ if (!port->cap_usb4)
continue;
if (tb_port_read(port, &val, TB_CFG_PORT,
port->cap_usb4 + PORT_CS_18, 1))
break;
- tb_port_dbg(port, "USB4 wake: %s\n",
- (val & PORT_CS_18_WOU4S) ? "yes" : "no");
+ tb_port_dbg(port, "USB4 wake: %s, connection wake: %s, disconnection wake: %s\n",
+ (val & PORT_CS_18_WOU4S) ? "yes" : "no",
+ (val & PORT_CS_18_WOCS) ? "yes" : "no",
+ (val & PORT_CS_18_WODS) ? "yes" : "no");
+
+ wakeup_usb4 = val & (PORT_CS_18_WOU4S | PORT_CS_18_WOCS |
+ PORT_CS_18_WODS);
+
+ usb4 = port->usb4;
+ if (device_may_wakeup(&usb4->dev) && wakeup_usb4)
+ pm_wakeup_event(&usb4->dev, 0);
- if (val & PORT_CS_18_WOU4S)
- wakeup = true;
+ wakeup |= wakeup_usb4;
}
if (wakeup)
@@ -366,6 +379,7 @@ bool usb4_switch_lane_bonding_possible(struct tb_switch *sw)
*/
int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
{
+ struct usb4_port *usb4;
struct tb_port *port;
u64 route = tb_route(sw);
u32 val;
@@ -395,10 +409,13 @@ int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
val |= PORT_CS_19_WOU4;
} else {
bool configured = val & PORT_CS_19_PC;
+ usb4 = port->usb4;
- if ((flags & TB_WAKE_ON_CONNECT) && !configured)
+ if (((flags & TB_WAKE_ON_CONNECT) |
+ device_may_wakeup(&usb4->dev)) && !configured)
val |= PORT_CS_19_WOC;
- if ((flags & TB_WAKE_ON_DISCONNECT) && configured)
+ if (((flags & TB_WAKE_ON_DISCONNECT) |
+ device_may_wakeup(&usb4->dev)) && configured)
val |= PORT_CS_19_WOD;
if ((flags & TB_WAKE_ON_USB4) && configured)
val |= PORT_CS_19_WOU4;
diff --git a/drivers/thunderbolt/usb4_port.c b/drivers/thunderbolt/usb4_port.c
index 6b02945624ee..442ed1152e59 100644
--- a/drivers/thunderbolt/usb4_port.c
+++ b/drivers/thunderbolt/usb4_port.c
@@ -282,6 +282,9 @@ struct usb4_port *usb4_port_device_add(struct tb_port *port)
}
}
+ if (!tb_is_upstream_port(port))
+ device_set_wakeup_capable(&usb4->dev, true);
+
pm_runtime_no_callbacks(&usb4->dev);
pm_runtime_set_active(&usb4->dev);
pm_runtime_enable(&usb4->dev);
--
2.34.1
On Wed, Sep 28, 2022 at 06:30:05PM +0530, Rajat Khandelwal wrote:
> Wake on connect/disconnect is only supported while runtime suspend
> for now, which is obviously necessary. Its also not inherently
> desired for the system to wakeup on thunderbolt hot events.
> However, we can still make user in control of waking up the system
> in the events of hot plug/unplug.
> This patch adds 'wakeup' attribute under 'usb4_portX/power' sysfs
> attribute and only enables wakes on connect/disconnect to the
> respective port when 'wakeup' is set to 'enabled'. The attribute
> is set to 'disabled' by default.
>
> Signed-off-by: Rajat Khandelwal <[email protected]>
Including the issue pointed out below by my bot, Intel has a "special"
requirement that you are not meeting here in order to send out patches
for review on a public mailing list in a subsystem like this (i.e. one
that I and others review patches on.)
Please meet that requirement first before sending any future kernel
patches out.
> ---
>
> drivers/thunderbolt/tb_regs.h | 2 ++
> drivers/thunderbolt/usb4.c | 33 +++++++++++++++++++++++++--------
> drivers/thunderbolt/usb4_port.c | 3 +++
> 3 files changed, 30 insertions(+), 8 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:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/SubmittingPatches for what needs to be done
here to properly describe 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
Hi Greg,
On Tue, Sep 27, 2022 at 06:48:41PM +0200, Greg KH wrote:
> On Wed, Sep 28, 2022 at 06:30:05PM +0530, Rajat Khandelwal wrote:
> > Wake on connect/disconnect is only supported while runtime suspend
> > for now, which is obviously necessary. Its also not inherently
> > desired for the system to wakeup on thunderbolt hot events.
> > However, we can still make user in control of waking up the system
> > in the events of hot plug/unplug.
> > This patch adds 'wakeup' attribute under 'usb4_portX/power' sysfs
> > attribute and only enables wakes on connect/disconnect to the
> > respective port when 'wakeup' is set to 'enabled'. The attribute
> > is set to 'disabled' by default.
> >
> > Signed-off-by: Rajat Khandelwal <[email protected]>
>
> Including the issue pointed out below by my bot, Intel has a "special"
> requirement that you are not meeting here in order to send out patches
> for review on a public mailing list in a subsystem like this (i.e. one
> that I and others review patches on.)
>
> Please meet that requirement first before sending any future kernel
> patches out.
I asked Khandelwal to send this patch upstream after we did an internal
review for it (I think I also asked him to send this out after v6.1-rc1
is released but whatever).
I think the bot noticed the v4 he sent earlier that was the same we
reviewed internally.
I was planning to pick this up after the merge window closes if there
are no objections.
On Wed, Sep 28, 2022 at 08:01:03AM +0300, Mika Westerberg wrote:
> Hi Greg,
>
> On Tue, Sep 27, 2022 at 06:48:41PM +0200, Greg KH wrote:
> > On Wed, Sep 28, 2022 at 06:30:05PM +0530, Rajat Khandelwal wrote:
> > > Wake on connect/disconnect is only supported while runtime suspend
> > > for now, which is obviously necessary. Its also not inherently
> > > desired for the system to wakeup on thunderbolt hot events.
> > > However, we can still make user in control of waking up the system
> > > in the events of hot plug/unplug.
> > > This patch adds 'wakeup' attribute under 'usb4_portX/power' sysfs
> > > attribute and only enables wakes on connect/disconnect to the
> > > respective port when 'wakeup' is set to 'enabled'. The attribute
> > > is set to 'disabled' by default.
> > >
> > > Signed-off-by: Rajat Khandelwal <[email protected]>
> >
> > Including the issue pointed out below by my bot, Intel has a "special"
> > requirement that you are not meeting here in order to send out patches
> > for review on a public mailing list in a subsystem like this (i.e. one
> > that I and others review patches on.)
> >
> > Please meet that requirement first before sending any future kernel
> > patches out.
>
> I asked Khandelwal to send this patch upstream after we did an internal
> review for it (I think I also asked him to send this out after v6.1-rc1
> is released but whatever).
So the correct rules were not followed, please fix that :(
> I think the bot noticed the v4 he sent earlier that was the same we
> reviewed internally.
Again, yes, this was sent incorrectly.
> I was planning to pick this up after the merge window closes if there
> are no objections.
I'm objecting :)
thanks,
greg k-h
On Wed, Sep 28, 2022 at 08:03:42AM +0200, Greg KH wrote:
> On Wed, Sep 28, 2022 at 08:01:03AM +0300, Mika Westerberg wrote:
> > Hi Greg,
> >
> > On Tue, Sep 27, 2022 at 06:48:41PM +0200, Greg KH wrote:
> > > On Wed, Sep 28, 2022 at 06:30:05PM +0530, Rajat Khandelwal wrote:
> > > > Wake on connect/disconnect is only supported while runtime suspend
> > > > for now, which is obviously necessary. Its also not inherently
> > > > desired for the system to wakeup on thunderbolt hot events.
> > > > However, we can still make user in control of waking up the system
> > > > in the events of hot plug/unplug.
> > > > This patch adds 'wakeup' attribute under 'usb4_portX/power' sysfs
> > > > attribute and only enables wakes on connect/disconnect to the
> > > > respective port when 'wakeup' is set to 'enabled'. The attribute
> > > > is set to 'disabled' by default.
> > > >
> > > > Signed-off-by: Rajat Khandelwal <[email protected]>
> > >
> > > Including the issue pointed out below by my bot, Intel has a "special"
> > > requirement that you are not meeting here in order to send out patches
> > > for review on a public mailing list in a subsystem like this (i.e. one
> > > that I and others review patches on.)
> > >
> > > Please meet that requirement first before sending any future kernel
> > > patches out.
> >
> > I asked Khandelwal to send this patch upstream after we did an internal
> > review for it (I think I also asked him to send this out after v6.1-rc1
> > is released but whatever).
>
> So the correct rules were not followed, please fix that :(
We will, sorry about this.