All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification
@ 2023-01-24  9:09 Mika Westerberg
  2023-01-24  9:09 ` [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth() Mika Westerberg
  2023-01-27  6:28 ` [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Mika Westerberg
  0 siblings, 2 replies; 5+ messages in thread
From: Mika Westerberg @ 2023-01-24  9:09 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

When the graphics side enables bandwidth allocation mode the DP IN
adapter sends notification to the connection manager about this.
Currently the handler misses this and tries to allocate 0 Mb/s that then
makes the graphics side to think the request failed.

Fix this by properly handling the enablement notification.

Fixes: 6ce3563520be ("thunderbolt: Add support for DisplayPort bandwidth allocation mode")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb.c   | 10 +++++++---
 drivers/thunderbolt/usb4.c |  7 ++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 0b891d749a96..7bfbc9ca9ba4 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1756,11 +1756,15 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
 		goto unlock;
 	}
 
-	requested_bw = usb4_dp_port_requested_bw(in);
-	if (requested_bw < 0) {
-		tb_port_dbg(in, "no bandwidth request active\n");
+	ret = usb4_dp_port_requested_bw(in);
+	if (ret < 0) {
+		if (ret == -ENODATA)
+			tb_port_dbg(in, "no bandwidth request active\n");
+		else
+			tb_port_warn(in, "failed to read requested bandwidth\n");
 		goto unlock;
 	}
+	requested_bw = ret;
 
 	tb_port_dbg(in, "requested bandwidth %d Mb/s\n", requested_bw);
 
diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index 2a9266fb5c0f..1e5e9c147a31 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -2732,7 +2732,8 @@ int usb4_dp_port_allocate_bw(struct tb_port *port, int bw)
  * Reads the DPCD (graphics driver) requested bandwidth and returns it
  * in Mb/s. Takes the programmed granularity into account. In case of
  * error returns negative errno. Specifically returns %-EOPNOTSUPP if
- * the adapter does not support bandwidth allocation mode.
+ * the adapter does not support bandwidth allocation mode, and %ENODATA
+ * if there is no active bandwidth request from the graphics driver.
  */
 int usb4_dp_port_requested_bw(struct tb_port *port)
 {
@@ -2750,10 +2751,10 @@ int usb4_dp_port_requested_bw(struct tb_port *port)
 	ret = tb_port_read(port, &val, TB_CFG_PORT,
 			   port->cap_adap + ADP_DP_CS_8, 1);
 	if (ret)
-		return 0;
+		return ret;
 
 	if (!(val & ADP_DP_CS_8_DR))
-		return 0;
+		return -ENODATA;
 
 	return (val & ADP_DP_CS_8_REQUESTED_BW_MASK) * granularity;
 }
-- 
2.39.0


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

* [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth()
  2023-01-24  9:09 [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Mika Westerberg
@ 2023-01-24  9:09 ` Mika Westerberg
  2023-01-24 10:26   ` Lukas Wunner
  2023-01-27  6:28 ` [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Mika Westerberg
  1 sibling, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2023-01-24  9:09 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

These were missing from the original commit so add them now. No
functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tunnel.c | 10 ++++++++++
 drivers/thunderbolt/tunnel.h |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index c406675a8966..8af9397f272e 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -2081,6 +2081,16 @@ static bool tb_tunnel_is_active(const struct tb_tunnel *tunnel)
 	return true;
 }
 
+/**
+ * tb_tunnel_maximum_bandwidth() - Return maximum possible bandwidth
+ * @tunnel: Tunnel to check
+ * @max_up: Maximum upstream bandwidth in Mb/s
+ * @max_down: Maximum upstream bandwidth in Mb/s
+ *
+ * Returns maximum possible bandwidth this tunnel can go if not limited
+ * by other bandwidth clients. If the tunnel does not support this
+ * returns %-EOPNOTSUPP.
+ */
 int tb_tunnel_maximum_bandwidth(struct tb_tunnel *tunnel, int *max_up,
 				int *max_down)
 {
diff --git a/drivers/thunderbolt/tunnel.h b/drivers/thunderbolt/tunnel.h
index d7bbdf8c8186..bf690f7beeee 100644
--- a/drivers/thunderbolt/tunnel.h
+++ b/drivers/thunderbolt/tunnel.h
@@ -29,7 +29,7 @@ enum tb_tunnel_type {
  * @init: Optional tunnel specific initialization
  * @deinit: Optional tunnel specific de-initialization
  * @activate: Optional tunnel specific activation/deactivation
- * @maximum_bandwidth:
+ * @maximum_bandwidth: Returns maximum possible bandwidth for this tunnel
  * @allocated_bandwidth: Return how much bandwidth is allocated for the tunnel
  * @alloc_bandwidth: Change tunnel bandwidth allocation
  * @consumed_bandwidth: Return how much bandwidth the tunnel consumes
-- 
2.39.0


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

* Re: [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth()
  2023-01-24  9:09 ` [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth() Mika Westerberg
@ 2023-01-24 10:26   ` Lukas Wunner
  2023-01-24 10:33     ` Mika Westerberg
  0 siblings, 1 reply; 5+ messages in thread
From: Lukas Wunner @ 2023-01-24 10:26 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-usb, Yehezkel Bernat, Michael Jamet, Andreas Noever

On Tue, Jan 24, 2023 at 11:09:38AM +0200, Mika Westerberg wrote:
> +/**
> + * tb_tunnel_maximum_bandwidth() - Return maximum possible bandwidth
> + * @tunnel: Tunnel to check
> + * @max_up: Maximum upstream bandwidth in Mb/s
> + * @max_down: Maximum upstream bandwidth in Mb/s
                         ^^^^^^^^
			 downstream?

I'm sure you're just testing whether anyone is reading your patches ;)

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

* Re: [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth()
  2023-01-24 10:26   ` Lukas Wunner
@ 2023-01-24 10:33     ` Mika Westerberg
  0 siblings, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2023-01-24 10:33 UTC (permalink / raw)
  To: Lukas Wunner; +Cc: linux-usb, Yehezkel Bernat, Michael Jamet, Andreas Noever

On Tue, Jan 24, 2023 at 11:26:26AM +0100, Lukas Wunner wrote:
> On Tue, Jan 24, 2023 at 11:09:38AM +0200, Mika Westerberg wrote:
> > +/**
> > + * tb_tunnel_maximum_bandwidth() - Return maximum possible bandwidth
> > + * @tunnel: Tunnel to check
> > + * @max_up: Maximum upstream bandwidth in Mb/s
> > + * @max_down: Maximum upstream bandwidth in Mb/s
>                          ^^^^^^^^
> 			 downstream?
> 
> I'm sure you're just testing whether anyone is reading your patches ;)

Hehe, thanks for reading them ;-) Fixed it now.

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

* Re: [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification
  2023-01-24  9:09 [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Mika Westerberg
  2023-01-24  9:09 ` [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth() Mika Westerberg
@ 2023-01-27  6:28 ` Mika Westerberg
  1 sibling, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2023-01-27  6:28 UTC (permalink / raw)
  To: linux-usb; +Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever

On Tue, Jan 24, 2023 at 11:09:37AM +0200, Mika Westerberg wrote:
> When the graphics side enables bandwidth allocation mode the DP IN
> adapter sends notification to the connection manager about this.
> Currently the handler misses this and tries to allocate 0 Mb/s that then
> makes the graphics side to think the request failed.
> 
> Fix this by properly handling the enablement notification.
> 
> Fixes: 6ce3563520be ("thunderbolt: Add support for DisplayPort bandwidth allocation mode")
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Fixed the typo and applied both patches to thunderbolt.git/next.

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

end of thread, other threads:[~2023-01-27  6:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24  9:09 [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Mika Westerberg
2023-01-24  9:09 ` [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth() Mika Westerberg
2023-01-24 10:26   ` Lukas Wunner
2023-01-24 10:33     ` Mika Westerberg
2023-01-27  6:28 ` [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.