Commit fa9d4bf5 authored by Linus Torvalds's avatar Linus Torvalds

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
...@@ -941,13 +941,10 @@ static void ndev_init_debugfs(struct amd_ntb_dev *ndev) ...@@ -941,13 +941,10 @@ static void ndev_init_debugfs(struct amd_ntb_dev *ndev)
ndev->debugfs_dir = ndev->debugfs_dir =
debugfs_create_dir(pci_name(ndev->ntb.pdev), debugfs_create_dir(pci_name(ndev->ntb.pdev),
debugfs_dir); debugfs_dir);
if (IS_ERR(ndev->debugfs_dir)) ndev->debugfs_info =
ndev->debugfs_info = NULL; debugfs_create_file("info", S_IRUSR,
else ndev->debugfs_dir, ndev,
ndev->debugfs_info = &amd_ntb_debugfs_info);
debugfs_create_file("info", S_IRUSR,
ndev->debugfs_dir, ndev,
&amd_ntb_debugfs_info);
} }
} }
......
...@@ -909,7 +909,7 @@ static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, ...@@ -909,7 +909,7 @@ static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw,
return 0; 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->link_is_up = false;
qp->active = false; qp->active = false;
...@@ -932,6 +932,13 @@ static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp) ...@@ -932,6 +932,13 @@ static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
qp->tx_async = 0; 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) static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
{ {
struct ntb_transport_ctx *nt = qp->transport; struct ntb_transport_ctx *nt = qp->transport;
...@@ -1174,7 +1181,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, ...@@ -1174,7 +1181,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
qp->ndev = nt->ndev; qp->ndev = nt->ndev;
qp->client_ready = false; qp->client_ready = false;
qp->event_handler = NULL; qp->event_handler = NULL;
ntb_qp_link_down_reset(qp); ntb_qp_link_context_reset(qp);
if (mw_num < qp_count % mw_count) if (mw_num < qp_count % mw_count)
num_qps_mw = qp_count / mw_count + 1; num_qps_mw = qp_count / mw_count + 1;
...@@ -1894,7 +1901,7 @@ static void ntb_async_tx(struct ntb_transport_qp *qp, ...@@ -1894,7 +1901,7 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,
static int ntb_process_tx(struct ntb_transport_qp *qp, static int ntb_process_tx(struct ntb_transport_qp *qp,
struct ntb_queue_entry *entry) 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++; qp->tx_ring_full++;
return -EAGAIN; return -EAGAIN;
} }
...@@ -2276,9 +2283,13 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, ...@@ -2276,9 +2283,13 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
struct ntb_queue_entry *entry; struct ntb_queue_entry *entry;
int rc; int rc;
if (!qp || !qp->link_is_up || !len) if (!qp || !len)
return -EINVAL; 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); entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
if (!entry) { if (!entry) {
qp->tx_err_no_buf++; qp->tx_err_no_buf++;
...@@ -2418,7 +2429,7 @@ unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp) ...@@ -2418,7 +2429,7 @@ unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp)
unsigned int head = qp->tx_index; unsigned int head = qp->tx_index;
unsigned int tail = qp->remote_rx_info->entry; 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); EXPORT_SYMBOL_GPL(ntb_transport_tx_free_entry);
......
...@@ -1355,7 +1355,7 @@ static void perf_setup_dbgfs(struct perf_ctx *perf) ...@@ -1355,7 +1355,7 @@ static void perf_setup_dbgfs(struct perf_ctx *perf)
struct pci_dev *pdev = perf->ntb->pdev; struct pci_dev *pdev = perf->ntb->pdev;
perf->dbgfs_dir = debugfs_create_dir(pci_name(pdev), perf_dbgfs_topdir); 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"); dev_warn(&perf->ntb->dev, "DebugFS unsupported\n");
return; return;
} }
......
...@@ -370,16 +370,9 @@ static ssize_t tool_fn_write(struct tool_ctx *tc, ...@@ -370,16 +370,9 @@ static ssize_t tool_fn_write(struct tool_ctx *tc,
if (*offp) if (*offp)
return 0; return 0;
buf = kmalloc(size + 1, GFP_KERNEL); buf = memdup_user_nul(ubuf, size);
if (!buf) if (IS_ERR(buf))
return -ENOMEM; return PTR_ERR(buf);
if (copy_from_user(buf, ubuf, size)) {
kfree(buf);
return -EFAULT;
}
buf[size] = 0;
n = sscanf(buf, "%c %lli", &cmd, &bits); n = sscanf(buf, "%c %lli", &cmd, &bits);
...@@ -1495,8 +1488,6 @@ static void tool_setup_dbgfs(struct tool_ctx *tc) ...@@ -1495,8 +1488,6 @@ static void tool_setup_dbgfs(struct tool_ctx *tc)
tc->dbgfs_dir = debugfs_create_dir(dev_name(&tc->ntb->dev), tc->dbgfs_dir = debugfs_create_dir(dev_name(&tc->ntb->dev),
tool_dbgfs_topdir); tool_dbgfs_topdir);
if (!tc->dbgfs_dir)
return;
debugfs_create_file("port", 0600, tc->dbgfs_dir, debugfs_create_file("port", 0600, tc->dbgfs_dir,
tc, &tool_port_fops); tc, &tool_port_fops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment