All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Charalampos Mitrodimas <charmitro@posteo.net>
Cc: zhangjianrong <zhangjianrong5@huawei.com>,
	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: Fri, 27 Jun 2025 07:46:15 +0300	[thread overview]
Message-ID: <20250627044615.GM2824380@black.fi.intel.com> (raw)
In-Reply-To: <877c0ylo2f.fsf@posteo.net>

Hi,

On Thu, Jun 26, 2025 at 11:50:00AM +0000, Charalampos Mitrodimas wrote:
> Mika Westerberg <mika.westerberg@linux.intel.com> writes:
> 
> > 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?
> 
> I suppose this can happen when reducing bandwidth while total upstream
> bandwidth usage on the link exceeds TB_ASYM_MIN (36 Gbps). The
> allocation fails at the asymmetric limit check before checking whether
> the downstream request actually needs asymmetric mode.

Right, but I would like to see here in the changelog explanation of the
situation and preferably parts of the dmesg showing the error as well.

@zhangjianrong, can you do that and resend?

Note, I will be on vacation after today so expect delay from my side.

> >> 
> >> 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-27  4:46 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
2025-06-26 11:50   ` Charalampos Mitrodimas
2025-06-27  4:46     ` Mika Westerberg [this message]
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=20250627044615.GM2824380@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=caiyadong@huawei.com \
    --cc=charmitro@posteo.net \
    --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.