linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Lukas Wunner <lukas@wunner.de>,
	Andreas Noever <andreas.noever@gmail.com>,
	Gil Fine <gil.fine@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH 02/10] thunderbolt: Use weight constants in tb_usb3_consumed_bandwidth()
Date: Thu,  5 Oct 2023 12:27:21 +0300	[thread overview]
Message-ID: <20231005092729.3595447-3-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20231005092729.3595447-1-mika.westerberg@linux.intel.com>

Instead of magic numbers use the constants we introduced in the previous
commit to make the code more readable. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tunnel.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index c53df06dd5df..b77acda284d0 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -1747,14 +1747,17 @@ static int tb_usb3_activate(struct tb_tunnel *tunnel, bool activate)
 static int tb_usb3_consumed_bandwidth(struct tb_tunnel *tunnel,
 		int *consumed_up, int *consumed_down)
 {
-	int pcie_enabled = tb_acpi_may_tunnel_pcie();
+	int pcie_weight = tb_acpi_may_tunnel_pcie() ? TB_PCI_WEIGHT : 0;
 
 	/*
 	 * PCIe tunneling, if enabled, affects the USB3 bandwidth so
 	 * take that it into account here.
 	 */
-	*consumed_up = tunnel->allocated_up * (3 + pcie_enabled) / 3;
-	*consumed_down = tunnel->allocated_down * (3 + pcie_enabled) / 3;
+	*consumed_up = tunnel->allocated_up *
+		(TB_USB3_WEIGHT + pcie_weight) / TB_USB3_WEIGHT;
+	*consumed_down = tunnel->allocated_down *
+		(TB_USB3_WEIGHT + pcie_weight) / TB_USB3_WEIGHT;
+
 	return 0;
 }
 
-- 
2.40.1


  parent reply	other threads:[~2023-10-05 13:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05  9:27 [PATCH 00/10] thunderbolt: USB4 v2 asymmetric switching and more Mika Westerberg
2023-10-05  9:27 ` [PATCH 01/10] thunderbolt: Use constants for path weight and priority Mika Westerberg
2023-10-05  9:27 ` Mika Westerberg [this message]
2023-10-05  9:27 ` [PATCH 03/10] thunderbolt: Make is_gen4_link() available to the rest of the driver Mika Westerberg
2023-10-05  9:27 ` [PATCH 04/10] thunderbolt: Change bandwidth reservations to comply USB4 v2 Mika Westerberg
2023-10-05  9:27 ` [PATCH 05/10] thunderbolt: Set path power management packet support bit for USB4 v2 routers Mika Westerberg
2023-10-05  9:27 ` [PATCH 06/10] thunderbolt: Introduce tb_port_path_direction_downstream() Mika Westerberg
2023-10-05  9:27 ` [PATCH 07/10] thunderbolt: Introduce tb_for_each_upstream_port_on_path() Mika Westerberg
2023-10-05  9:27 ` [PATCH 08/10] thunderbolt: Introduce tb_switch_depth() Mika Westerberg
2023-10-05  9:27 ` [PATCH 09/10] thunderbolt: Add support for asymmetric link Mika Westerberg
2023-10-05  9:27 ` [PATCH 10/10] thunderbolt: Configure asymmetric link if needed and bandwidth allows Mika Westerberg

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=20231005092729.3595447-3-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=gil.fine@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.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;
as well as URLs for NNTP newsgroup(s).