All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Koichiro Den <den@valinux.co.jp>, Jon Mason <jdmason@kudzu.us>,
	Allen Hubbe <allenbh@gmail.com>, Frank Li <Frank.Li@kernel.org>,
	Logan Gunthorpe <logang@deltatee.com>
Cc: 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,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 03/15] NTB: ntb_transport: Make link setup flags atomic
Date: Fri, 9 Oct 2026 16:08:17 -0700	[thread overview]
Message-ID: <3b225456-30e9-4da6-bb1c-96cd17f65b17@intel.com> (raw)
In-Reply-To: <20260928152550.3354675-4-den@valinux.co.jp>



On 9/28/26 8:25 AM, Koichiro Den wrote:
> Convert nt->link_is_up and qp->client_ready to atomic_t and use atomic
> accessors throughout. This prepares for the unlocked cleanup check and
> the link-up ordering fixes that follow.
> 
> Leave control flow and locking unchanged.
> 
> Cc: stable@vger.kernel.org
> Suggested-by: Frank Li <Frank.Li@kernel.org>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
> Changes in v3:
>   - New patch. (Frank)
>     https://lore.kernel.org/r/i3b4kyeuwyjssav2kne5uhxmltwl2bmug2weyfaujxtrwlkuox@ms6ozb55tmz5/
> 
>  drivers/ntb/ntb_transport.c | 31 ++++++++++++++++---------------
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index 55a20ae9a85e..5d2ec484c3df 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -47,6 +47,7 @@
>   * Contact Information:
>   * Jon Mason <jon.mason@intel.com>
>   */
> +#include <linux/atomic.h>
>  #include <linux/debugfs.h>
>  #include <linux/delay.h>
>  #include <linux/dmaengine.h>
> @@ -142,7 +143,7 @@ struct ntb_transport_qp {
>  	struct dma_chan *tx_dma_chan;
>  	struct dma_chan *rx_dma_chan;
>  
> -	bool client_ready;
> +	atomic_t client_ready;
>  	bool link_is_up;
>  	bool active;
>  
> @@ -249,7 +250,7 @@ struct ntb_transport_ctx {
>  	unsigned int msi_spad_offset;
>  	u64 msi_db_mask;
>  
> -	bool link_is_up;
> +	atomic_t link_is_up;
>  	struct delayed_work link_work;
>  	struct work_struct link_cleanup;
>  
> @@ -945,7 +946,7 @@ static void ntb_qp_link_cleanup_work(struct work_struct *work)
>  
>  	ntb_qp_link_cleanup(qp);
>  
> -	if (nt->link_is_up)
> +	if (atomic_read(&nt->link_is_up))
>  		schedule_delayed_work(&qp->link_work,
>  				      msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
>  }
> @@ -972,7 +973,7 @@ static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
>  			cancel_delayed_work_sync(&qp->link_work);
>  		}
>  
> -	if (!nt->link_is_up)
> +	if (!atomic_read(&nt->link_is_up))
>  		cancel_delayed_work_sync(&nt->link_work);
>  
>  	for (i = 0; i < nt->mw_count; i++)
> @@ -1084,7 +1085,7 @@ static void ntb_transport_link_work(struct work_struct *work)
>  			goto out1;
>  	}
>  
> -	nt->link_is_up = true;
> +	atomic_set(&nt->link_is_up, true);
>  
>  	for (i = 0; i < nt->qp_count; i++) {
>  		struct ntb_transport_qp *qp = &nt->qp_vec[i];
> @@ -1092,7 +1093,7 @@ static void ntb_transport_link_work(struct work_struct *work)
>  		ntb_transport_setup_qp_mw(nt, i);
>  		ntb_transport_setup_qp_peer_msi(nt, i);
>  
> -		if (qp->client_ready)
> +		if (atomic_read(&qp->client_ready))
>  			schedule_delayed_work(&qp->link_work, 0);
>  	}
>  
> @@ -1121,7 +1122,7 @@ static void ntb_qp_link_work(struct work_struct *work)
>  	struct ntb_transport_ctx *nt = qp->transport;
>  	int val;
>  
> -	WARN_ON(!nt->link_is_up);
> +	WARN_ON(!atomic_read(&nt->link_is_up));
>  
>  	val = ntb_spad_read(nt->ndev, QP_LINKS);
>  
> @@ -1141,7 +1142,7 @@ 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)
> +	} else if (atomic_read(&nt->link_is_up))
>  		schedule_delayed_work(&qp->link_work,
>  				      msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
>  }
> @@ -1165,7 +1166,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
>  	qp->qp_num = qp_num;
>  	qp->transport = nt;
>  	qp->ndev = nt->ndev;
> -	qp->client_ready = false;
> +	atomic_set(&qp->client_ready, false);
>  	qp->event_handler = NULL;
>  	ntb_qp_link_context_reset(qp);
>  
> @@ -1373,7 +1374,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
>  	if (rc)
>  		goto err3;
>  
> -	nt->link_is_up = false;
> +	atomic_set(&nt->link_is_up, false);
>  	ntb_link_enable(ndev, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
>  	ntb_link_event(ndev);
>  
> @@ -1457,7 +1458,7 @@ static void ntb_complete_rxc(struct ntb_transport_qp *qp)
>  
>  		spin_unlock_irqrestore(&qp->ntb_rx_q_lock, irqflags);
>  
> -		if (qp->rx_handler && qp->client_ready)
> +		if (qp->rx_handler && atomic_read(&qp->client_ready))
>  			qp->rx_handler(qp, qp->cb_data, cb_data, len);
>  
>  		spin_lock_irqsave(&qp->ntb_rx_q_lock, irqflags);
> @@ -2268,7 +2269,7 @@ void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len)
>  	struct ntb_queue_entry *entry;
>  	void *buf;
>  
> -	if (!qp || qp->client_ready)
> +	if (!qp || atomic_read(&qp->client_ready))
>  		return NULL;
>  
>  	entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_pend_q);
> @@ -2385,9 +2386,9 @@ void ntb_transport_link_up(struct ntb_transport_qp *qp)
>  	if (!qp)
>  		return;
>  
> -	qp->client_ready = true;
> +	atomic_set(&qp->client_ready, true);
>  
> -	if (qp->transport->link_is_up)
> +	if (atomic_read(&qp->transport->link_is_up))
>  		schedule_delayed_work(&qp->link_work, 0);
>  }
>  EXPORT_SYMBOL_GPL(ntb_transport_link_up);
> @@ -2407,7 +2408,7 @@ void ntb_transport_link_down(struct ntb_transport_qp *qp)
>  	if (!qp)
>  		return;
>  
> -	qp->client_ready = false;
> +	atomic_set(&qp->client_ready, false);
>  
>  	val = ntb_spad_read(qp->ndev, QP_LINKS);
>  


  parent reply	other threads:[~2026-10-09 23:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 15:25 [PATCH v3 00/15] NTB: ntb_transport: Miscellaneous fixes Koichiro Den
2026-09-28 15:25 ` [PATCH v3 01/15] NTB: ntb_transport: Remove the device debugfs directory Koichiro Den
2026-09-28 15:25 ` [PATCH v3 02/15] NTB: ntb_transport: Start TX offload thread after queue setup Koichiro Den
2026-09-28 15:25 ` [PATCH v3 03/15] NTB: ntb_transport: Make link setup flags atomic Koichiro Den
2026-09-28 15:53   ` Logan Gunthorpe
2026-10-09 23:08   ` Dave Jiang [this message]
2026-09-28 15:25 ` [PATCH v3 04/15] NTB: ntb_transport: Avoid deadlock when cancelling link work Koichiro Den
2026-09-28 15:43   ` sashiko-bot
2026-09-29  1:19     ` Koichiro Den
2026-10-09 23:09   ` Dave Jiang
2026-09-28 15:25 ` [PATCH v3 05/15] NTB: ntb_transport: Publish link state after QP setup Koichiro Den
2026-09-28 15:25 ` [PATCH v3 06/15] NTB: ntb_transport: Avoid losing QP link-up requests Koichiro Den
2026-09-28 16:57   ` Logan Gunthorpe
2026-09-29  1:43     ` Koichiro Den
2026-10-09 23:11   ` Dave Jiang
2026-09-28 15:25 ` [PATCH v3 07/15] NTB: ntb_transport: Clear link state before QP cleanup Koichiro Den
2026-09-28 15:25 ` [PATCH v3 08/15] NTB: ntb_transport: Stop QP work before freeing a queue Koichiro Den
2026-10-09 23:11   ` Dave Jiang
2026-09-28 15:25 ` [PATCH v3 09/15] NTB: ntb_transport: Stop RX tasklet scheduling " Koichiro Den
2026-09-28 15:25 ` [PATCH v3 10/15] NTB: ntb_transport: Drain RX tasklets during link cleanup Koichiro Den
2026-09-28 15:25 ` [PATCH v3 11/15] NTB: ntb_transport: Wait for RX completions before resetting a QP Koichiro Den
2026-09-28 15:54   ` sashiko-bot
2026-09-29  1:27     ` Koichiro Den
2026-09-28 15:25 ` [PATCH v3 12/15] NTB: ntb_transport: Prepare remote RX info accesses for MW teardown Koichiro Den
2026-09-28 15:25 ` [PATCH v3 13/15] NTB: ntb_transport: Clear QP pointers when freeing an MW Koichiro Den
2026-09-28 15:25 ` [PATCH v3 14/15] NTB: ntb_transport: Abort link setup on QP MW allocation failure Koichiro Den
2026-09-28 15:25 ` [PATCH v3 15/15] NTB: ntb_transport: Remove clients before freeing transport resources Koichiro Den
2026-09-28 16:04   ` sashiko-bot
2026-09-29  1:31     ` Koichiro Den

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=3b225456-30e9-4da6-bb1c-96cd17f65b17@intel.com \
    --to=dave.jiang@intel.com \
    --cc=Frank.Li@kernel.org \
    --cc=allenbh@gmail.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 \
    --cc=stable@vger.kernel.org \
    /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.