Commit fa9d4bf5 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'ntb-6.6' of https://github.com/jonmason/ntb

Pull NTB updates from Jon Mason:
 "Link toggling fixes and debugfs error path fixes"

[ And for everybody like me who always have to remind themselves what
  the TLA of the day is, and what NTB stands for - it's a PCIe
  "Non-Transparent Bridge" thing    - Linus ]

* tag 'ntb-6.6' of https://github.com/jonmason/ntb:
  ntb: Check tx descriptors outstanding instead of head/tail for tx queue
  ntb: Fix calculation ntb_transport_tx_free_entry()
  ntb: Drop packets when qp link is down
  ntb: Clean up tx tail index on link down
  ntb: amd: Drop unnecessary error check for debugfs_create_dir
  NTB: ntb_tool: Switch to memdup_user_nul() helper
  dtivers: ntb: fix parameter check in perf_setup_dbgfs()
  ntb: Remove error checking for debugfs_create_dir()
parents 6099776f 64398223
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -941,9 +941,6 @@ static void ndev_init_debugfs(struct amd_ntb_dev *ndev)
		ndev->debugfs_dir =
			debugfs_create_dir(pci_name(ndev->ntb.pdev),
					   debugfs_dir);
		if (IS_ERR(ndev->debugfs_dir))
			ndev->debugfs_info = NULL;
		else
		ndev->debugfs_info =
			debugfs_create_file("info", S_IRUSR,
					    ndev->debugfs_dir, ndev,
+16 −5
Original line number Diff line number Diff line
@@ -909,7 +909,7 @@ static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw,
	return 0;
}

static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
static void ntb_qp_link_context_reset(struct ntb_transport_qp *qp)
{
	qp->link_is_up = false;
	qp->active = false;
@@ -932,6 +932,13 @@ static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
	qp->tx_async = 0;
}

static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
{
	ntb_qp_link_context_reset(qp);
	if (qp->remote_rx_info)
		qp->remote_rx_info->entry = qp->rx_max_entry - 1;
}

static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
{
	struct ntb_transport_ctx *nt = qp->transport;
@@ -1174,7 +1181,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
	qp->ndev = nt->ndev;
	qp->client_ready = false;
	qp->event_handler = NULL;
	ntb_qp_link_down_reset(qp);
	ntb_qp_link_context_reset(qp);

	if (mw_num < qp_count % mw_count)
		num_qps_mw = qp_count / mw_count + 1;
@@ -1894,7 +1901,7 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,
static int ntb_process_tx(struct ntb_transport_qp *qp,
			  struct ntb_queue_entry *entry)
{
	if (qp->tx_index == qp->remote_rx_info->entry) {
	if (!ntb_transport_tx_free_entry(qp)) {
		qp->tx_ring_full++;
		return -EAGAIN;
	}
@@ -2276,9 +2283,13 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
	struct ntb_queue_entry *entry;
	int rc;

	if (!qp || !qp->link_is_up || !len)
	if (!qp || !len)
		return -EINVAL;

	/* If the qp link is down already, just ignore. */
	if (!qp->link_is_up)
		return 0;

	entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
	if (!entry) {
		qp->tx_err_no_buf++;
@@ -2418,7 +2429,7 @@ unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp)
	unsigned int head = qp->tx_index;
	unsigned int tail = qp->remote_rx_info->entry;

	return tail > head ? tail - head : qp->tx_max_entry + tail - head;
	return tail >= head ? tail - head : qp->tx_max_entry + tail - head;
}
EXPORT_SYMBOL_GPL(ntb_transport_tx_free_entry);

+1 −1
Original line number Diff line number Diff line
@@ -1355,7 +1355,7 @@ static void perf_setup_dbgfs(struct perf_ctx *perf)
	struct pci_dev *pdev = perf->ntb->pdev;

	perf->dbgfs_dir = debugfs_create_dir(pci_name(pdev), perf_dbgfs_topdir);
	if (!perf->dbgfs_dir) {
	if (IS_ERR(perf->dbgfs_dir)) {
		dev_warn(&perf->ntb->dev, "DebugFS unsupported\n");
		return;
	}
+3 −12
Original line number Diff line number Diff line
@@ -370,16 +370,9 @@ static ssize_t tool_fn_write(struct tool_ctx *tc,
	if (*offp)
		return 0;

	buf = kmalloc(size + 1, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	if (copy_from_user(buf, ubuf, size)) {
		kfree(buf);
		return -EFAULT;
	}

	buf[size] = 0;
	buf = memdup_user_nul(ubuf, size);
	if (IS_ERR(buf))
		return PTR_ERR(buf);

	n = sscanf(buf, "%c %lli", &cmd, &bits);

@@ -1495,8 +1488,6 @@ static void tool_setup_dbgfs(struct tool_ctx *tc)

	tc->dbgfs_dir = debugfs_create_dir(dev_name(&tc->ntb->dev),
					   tool_dbgfs_topdir);
	if (!tc->dbgfs_dir)
		return;

	debugfs_create_file("port", 0600, tc->dbgfs_dir,
			    tc, &tool_port_fops);