From: Frank Li <Frank.li@oss.nxp.com>
To: Koichiro Den <den@valinux.co.jp>
Cc: Jon Mason <jdmason@kudzu.us>, Dave Jiang <dave.jiang@intel.com>,
Allen Hubbe <allenbh@gmail.com>, Frank Li <Frank.Li@kernel.org>,
Logan Gunthorpe <logang@deltatee.com>,
fuyuanli <fuyuanli0722@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nicholas Bellinger <nab@linux-iscsi.org>,
Joey Zhang <joey.zhang@microchip.com>,
ntb@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 04/14] NTB: ntb_transport: Publish link state after QP setup
Date: Fri, 11 Sep 2026 11:39:25 -0500 [thread overview]
Message-ID: <aqQuvWacR6FSaMvn@SMW015318> (raw)
In-Reply-To: <20260910040836.3792333-5-den@valinux.co.jp>
On Thu, Sep 10, 2026 at 01:08:26PM +0900, Koichiro Den wrote:
> ntb_transport_link_work() marks the transport link up before setting
> up the QPs' MW and peer MSI state. A concurrent ntb_transport_link_up()
> can then queue QP link work, which may enable RX and notify the client
> before setup finishes.
>
> Publish link_is_up with a release store after setting up all QPs,
> and use acquire loads before queuing QP link work.
>
> Fixes: fce8a7bb5b4b ("PCI-Express Non-Transparent Bridge Support")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/anyKbq3mpLG4y7rb@SMW015318
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Changes in v2:
> - No changes.
>
> drivers/ntb/ntb_transport.c | 40 +++++++++++++++++++++++--------------
> 1 file changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index c77b173dca01..75d4a2e021f4 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -922,6 +922,16 @@ static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
> qp->remote_rx_info->entry = qp->rx_max_entry - 1;
> }
>
> +static void ntb_transport_schedule_qp_link(struct ntb_transport_qp *qp,
> + unsigned long delay)
> +{
> + struct ntb_transport_ctx *nt = qp->transport;
> +
> + /* Pair with the link publication in ntb_transport_link_work(). */
> + if (smp_load_acquire(&nt->link_is_up))
> + schedule_delayed_work(&qp->link_work, delay);
> +}
> +
> static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
> {
> struct ntb_transport_ctx *nt = qp->transport;
> @@ -941,13 +951,10 @@ static void ntb_qp_link_cleanup_work(struct work_struct *work)
> struct ntb_transport_qp *qp = container_of(work,
> struct ntb_transport_qp,
> link_cleanup);
> - struct ntb_transport_ctx *nt = qp->transport;
>
> ntb_qp_link_cleanup(qp);
> -
> - if (nt->link_is_up)
> - schedule_delayed_work(&qp->link_work,
> - msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
> + ntb_transport_schedule_qp_link(qp,
> + msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
> }
>
> static void ntb_qp_link_down(struct ntb_transport_qp *qp)
> @@ -1089,16 +1096,19 @@ static void ntb_transport_link_work(struct work_struct *work)
> goto out1;
> }
>
> - nt->link_is_up = true;
> -
> for (i = 0; i < nt->qp_count; i++) {
> - struct ntb_transport_qp *qp = &nt->qp_vec[i];
> -
> ntb_transport_setup_qp_mw(nt, i);
> ntb_transport_setup_qp_peer_msi(nt, i);
> + }
> +
> + /* Publish the link only after every QP has been set up. */
> + smp_store_release(&nt->link_is_up, true);
> +
> + for (i = 0; i < nt->qp_count; i++) {
> + struct ntb_transport_qp *qp = &nt->qp_vec[i];
>
> if (qp->client_ready)
> - schedule_delayed_work(&qp->link_work, 0);
> + ntb_transport_schedule_qp_link(qp, 0);
> }
>
> return;
> @@ -1146,9 +1156,10 @@ static void ntb_qp_link_work(struct work_struct *work)
>
> if (qp->active)
> tasklet_schedule(&qp->rxc_db_work);
> - } else if (nt->link_is_up)
> - schedule_delayed_work(&qp->link_work,
> - msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
> + } else {
> + ntb_transport_schedule_qp_link(qp,
> + msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
> + }
> }
>
> static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
> @@ -2392,8 +2403,7 @@ void ntb_transport_link_up(struct ntb_transport_qp *qp)
>
> qp->client_ready = true;
>
> - if (qp->transport->link_is_up)
> - schedule_delayed_work(&qp->link_work, 0);
> + ntb_transport_schedule_qp_link(qp, 0);
> }
> EXPORT_SYMBOL_GPL(ntb_transport_link_up);
>
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-09-11 16:39 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 4:08 [PATCH v2 00/14] NTB: ntb_transport: Miscellaneous fixes Koichiro Den
2026-09-10 4:08 ` [PATCH v2 01/14] NTB: ntb_transport: Remove the device debugfs directory Koichiro Den
2026-09-10 4:20 ` sashiko-bot
2026-09-10 18:41 ` Frank Li
2026-09-10 4:08 ` [PATCH v2 02/14] NTB: ntb_transport: Start TX offload thread after queue setup Koichiro Den
2026-09-11 16:13 ` Frank Li
2026-09-10 4:08 ` [PATCH v2 03/14] NTB: ntb_transport: Avoid deadlock when cancelling link work Koichiro Den
2026-09-10 4:23 ` sashiko-bot
2026-09-11 16:21 ` Frank Li
2026-09-11 17:41 ` Koichiro Den
2026-09-10 4:08 ` [PATCH v2 04/14] NTB: ntb_transport: Publish link state after QP setup Koichiro Den
2026-09-11 16:39 ` Frank Li [this message]
2026-09-10 4:08 ` [PATCH v2 05/14] NTB: ntb_transport: Avoid losing QP link-up requests Koichiro Den
2026-09-10 4:26 ` sashiko-bot
2026-09-11 16:53 ` Frank Li
2026-09-11 18:04 ` Koichiro Den
2026-09-11 18:21 ` Koichiro Den
2026-09-12 3:20 ` Frank Li
2026-09-12 14:52 ` Koichiro Den
2026-09-10 4:08 ` [PATCH v2 06/14] NTB: ntb_transport: Clear link state before QP cleanup Koichiro Den
2026-09-10 4:27 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 07/14] NTB: ntb_transport: Stop QP work before freeing a queue Koichiro Den
2026-09-10 4:23 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 08/14] NTB: ntb_transport: Stop RX tasklet scheduling " Koichiro Den
2026-09-10 4:08 ` [PATCH v2 09/14] NTB: ntb_transport: Drain RX tasklets during link cleanup Koichiro Den
2026-09-10 4:23 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 10/14] NTB: ntb_transport: Wait for RX completions before resetting a QP Koichiro Den
2026-09-10 4:24 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 11/14] NTB: ntb_transport: Prepare remote RX info accesses for MW teardown Koichiro Den
2026-09-10 4:31 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 12/14] NTB: ntb_transport: Clear QP pointers when freeing an MW Koichiro Den
2026-09-10 4:32 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 13/14] NTB: ntb_transport: Abort link setup on QP MW allocation failure Koichiro Den
2026-09-10 4:40 ` sashiko-bot
2026-09-10 4:08 ` [PATCH v2 14/14] NTB: ntb_transport: Remove clients before freeing transport resources Koichiro Den
2026-09-10 4:36 ` sashiko-bot
2026-09-10 8:48 ` Koichiro Den
2026-09-11 15:49 ` Dave Jiang
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=aqQuvWacR6FSaMvn@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=allenbh@gmail.com \
--cc=dave.jiang@intel.com \
--cc=den@valinux.co.jp \
--cc=fuyuanli0722@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdmason@kudzu.us \
--cc=joey.zhang@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=nab@linux-iscsi.org \
--cc=ntb@lists.linux.dev \
/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.