All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: zhangjianrong <zhangjianrong5@huawei.com>
Cc: andreas.noever@gmail.com, michael.jamet@intel.com,
	YehezkelShB@gmail.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, guhengsheng@hisilicon.com,
	caiyadong@huawei.com, xuetao09@huawei.com,
	lixinghang1@huawei.com
Subject: Re: [PATCH] thunderbolt: Confirm the necessity to configure asym link first
Date: Thu, 26 Jun 2025 12:30:26 +0300	[thread overview]
Message-ID: <20250626093026.GJ2824380@black.fi.intel.com> (raw)
In-Reply-To: <20250626084107.2710306-1-zhangjianrong5@huawei.com>

Hi,

On Thu, Jun 26, 2025 at 04:41:07PM +0800, zhangjianrong wrote:
> Current implementation can cause allocation failures in
> tb_alloc_dp_bandwidth() in some cases. For example:
> allocated_down(30Gbps), allocated_up(50Gbps),
> requested_down(10Gbps).

I'm not sure I understand the above.

Can you describe in which real life situation this can happen?

> 
> Signed-off-by: zhangjianrong <zhangjianrong5@huawei.com>
> ---
>  drivers/thunderbolt/tb.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index a7c6919fbf97..558455d9716b 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
> @@ -1039,6 +1039,9 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
>  			break;
>  
>  		if (downstream) {
> +			/* Does consumed + requested exceed the threshold */
> +			if (consumed_down + requested_down < asym_threshold)
> +				continue;
>  			/*
>  			 * Downstream so make sure upstream is within the 36G
>  			 * (40G - guard band 10%), and the requested is above
> @@ -1048,20 +1051,17 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
>  				ret = -ENOBUFS;
>  				break;
>  			}
> -			/* Does consumed + requested exceed the threshold */
> -			if (consumed_down + requested_down < asym_threshold)
> -				continue;
>  
>  			width_up = TB_LINK_WIDTH_ASYM_RX;
>  			width_down = TB_LINK_WIDTH_ASYM_TX;
>  		} else {
>  			/* Upstream, the opposite of above */
> +			if (consumed_up + requested_up < asym_threshold)
> +				continue;
>  			if (consumed_down + requested_down >= TB_ASYM_MIN) {
>  				ret = -ENOBUFS;
>  				break;
>  			}
> -			if (consumed_up + requested_up < asym_threshold)
> -				continue;
>  
>  			width_up = TB_LINK_WIDTH_ASYM_TX;
>  			width_down = TB_LINK_WIDTH_ASYM_RX;
> -- 
> 2.34.1

  reply	other threads:[~2025-06-26  9:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26  8:41 [PATCH] thunderbolt: Confirm the necessity to configure asym link first zhangjianrong
2025-06-26  9:30 ` Mika Westerberg [this message]
2025-06-26 11:50   ` Charalampos Mitrodimas
2025-06-27  4:46     ` Mika Westerberg
2025-06-28 11:59       ` zhangjianrong (E)

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=20250626093026.GJ2824380@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=caiyadong@huawei.com \
    --cc=guhengsheng@hisilicon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lixinghang1@huawei.com \
    --cc=michael.jamet@intel.com \
    --cc=xuetao09@huawei.com \
    --cc=zhangjianrong5@huawei.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 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.