Commit 5f153b63 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull PCIe non-transparent bridge updates from Jon Mason:
 "Bug fixes for intel ntb driver debugfs, use after free in switchtec
  driver, ntb transport rx ring buffers. Also, cleanups in printks,
  kernel-docs, and idt driver comment"

* tag 'ntb-6.12' of https://github.com/jonmason/ntb:
  ntb: Force physically contiguous allocation of rx ring buffers
  ntb: ntb_hw_switchtec: Fix use after free vulnerability in switchtec_ntb_remove due to race condition
  ntb: idt: Fix the cacography in ntb_hw_idt.c
  NTB: epf: don't misuse kernel-doc marker
  NTB: ntb_transport: fix all kernel-doc warnings
  ntb: Constify struct bus_type
  ntb_perf: Fix printk format
  ntb: intel: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()
parents d7dfb07d 061a785a
...@@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION); ...@@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION);
MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESCRIPTION); MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
static struct bus_type ntb_bus; static const struct bus_type ntb_bus;
static void ntb_dev_release(struct device *dev); static void ntb_dev_release(struct device *dev);
int __ntb_register_client(struct ntb_client *client, struct module *mod, int __ntb_register_client(struct ntb_client *client, struct module *mod,
...@@ -298,7 +298,7 @@ static void ntb_dev_release(struct device *dev) ...@@ -298,7 +298,7 @@ static void ntb_dev_release(struct device *dev)
complete(&ntb->released); complete(&ntb->released);
} }
static struct bus_type ntb_bus = { static const struct bus_type ntb_bus = {
.name = "ntb", .name = "ntb",
.probe = ntb_probe, .probe = ntb_probe,
.remove = ntb_remove, .remove = ntb_remove,
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
/** /*
* Host side endpoint driver to implement Non-Transparent Bridge functionality * Host side endpoint driver to implement Non-Transparent Bridge functionality
* *
* Copyright (C) 2020 Texas Instruments * Copyright (C) 2020 Texas Instruments
......
...@@ -2547,7 +2547,7 @@ static void idt_deinit_dbgfs(struct idt_ntb_dev *ndev) ...@@ -2547,7 +2547,7 @@ static void idt_deinit_dbgfs(struct idt_ntb_dev *ndev)
*/ */
/* /*
* idt_check_setup() - Check whether the IDT PCIe-swtich is properly * idt_check_setup() - Check whether the IDT PCIe-switch is properly
* pre-initialized * pre-initialized
* @pdev: Pointer to the PCI device descriptor * @pdev: Pointer to the PCI device descriptor
* *
......
...@@ -778,7 +778,7 @@ static void ndev_init_debugfs(struct intel_ntb_dev *ndev) ...@@ -778,7 +778,7 @@ static void ndev_init_debugfs(struct intel_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 (!ndev->debugfs_dir) if (IS_ERR(ndev->debugfs_dir))
ndev->debugfs_info = NULL; ndev->debugfs_info = NULL;
else else
ndev->debugfs_info = ndev->debugfs_info =
......
...@@ -1554,6 +1554,7 @@ static void switchtec_ntb_remove(struct device *dev) ...@@ -1554,6 +1554,7 @@ static void switchtec_ntb_remove(struct device *dev)
switchtec_ntb_deinit_db_msg_irq(sndev); switchtec_ntb_deinit_db_msg_irq(sndev);
switchtec_ntb_deinit_shared_mw(sndev); switchtec_ntb_deinit_shared_mw(sndev);
switchtec_ntb_deinit_crosslink(sndev); switchtec_ntb_deinit_crosslink(sndev);
cancel_work_sync(&sndev->check_link_status_work);
kfree(sndev); kfree(sndev);
dev_info(dev, "ntb device unregistered\n"); dev_info(dev, "ntb device unregistered\n");
} }
......
...@@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev) ...@@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev)
put_device(dev); put_device(dev);
} }
static struct bus_type ntb_transport_bus = { static const struct bus_type ntb_transport_bus = {
.name = "ntb_transport", .name = "ntb_transport",
.match = ntb_transport_bus_match, .match = ntb_transport_bus_match,
.probe = ntb_transport_bus_probe, .probe = ntb_transport_bus_probe,
...@@ -377,6 +377,8 @@ EXPORT_SYMBOL_GPL(ntb_transport_unregister_client_dev); ...@@ -377,6 +377,8 @@ EXPORT_SYMBOL_GPL(ntb_transport_unregister_client_dev);
* @device_name: Name of NTB client device * @device_name: Name of NTB client device
* *
* Register an NTB client device with the NTB transport layer * Register an NTB client device with the NTB transport layer
*
* Returns: %0 on success or -errno code on error
*/ */
int ntb_transport_register_client_dev(char *device_name) int ntb_transport_register_client_dev(char *device_name)
{ {
...@@ -807,16 +809,29 @@ static void ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw) ...@@ -807,16 +809,29 @@ static void ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw)
} }
static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw, static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw,
struct device *dma_dev, size_t align) struct device *ntb_dev, size_t align)
{ {
dma_addr_t dma_addr; dma_addr_t dma_addr;
void *alloc_addr, *virt_addr; void *alloc_addr, *virt_addr;
int rc; int rc;
alloc_addr = dma_alloc_coherent(dma_dev, mw->alloc_size, /*
&dma_addr, GFP_KERNEL); * The buffer here is allocated against the NTB device. The reason to
* use dma_alloc_*() call is to allocate a large IOVA contiguous buffer
* backing the NTB BAR for the remote host to write to. During receive
* processing, the data is being copied out of the receive buffer to
* the kernel skbuff. When a DMA device is being used, dma_map_page()
* is called on the kvaddr of the receive buffer (from dma_alloc_*())
* and remapped against the DMA device. It appears to be a double
* DMA mapping of buffers, but first is mapped to the NTB device and
* second is to the DMA device. DMA_ATTR_FORCE_CONTIGUOUS is necessary
* in order for the later dma_map_page() to not fail.
*/
alloc_addr = dma_alloc_attrs(ntb_dev, mw->alloc_size,
&dma_addr, GFP_KERNEL,
DMA_ATTR_FORCE_CONTIGUOUS);
if (!alloc_addr) { if (!alloc_addr) {
dev_err(dma_dev, "Unable to alloc MW buff of size %zu\n", dev_err(ntb_dev, "Unable to alloc MW buff of size %zu\n",
mw->alloc_size); mw->alloc_size);
return -ENOMEM; return -ENOMEM;
} }
...@@ -845,7 +860,7 @@ static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw, ...@@ -845,7 +860,7 @@ static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw,
return 0; return 0;
err: err:
dma_free_coherent(dma_dev, mw->alloc_size, alloc_addr, dma_addr); dma_free_coherent(ntb_dev, mw->alloc_size, alloc_addr, dma_addr);
return rc; return rc;
} }
...@@ -1966,9 +1981,9 @@ static bool ntb_dma_filter_fn(struct dma_chan *chan, void *node) ...@@ -1966,9 +1981,9 @@ static bool ntb_dma_filter_fn(struct dma_chan *chan, void *node)
/** /**
* ntb_transport_create_queue - Create a new NTB transport layer queue * ntb_transport_create_queue - Create a new NTB transport layer queue
* @rx_handler: receive callback function * @data: pointer for callback data
* @tx_handler: transmit callback function * @client_dev: &struct device pointer
* @event_handler: event callback function * @handlers: pointer to various ntb queue (callback) handlers
* *
* Create a new NTB transport layer queue and provide the queue with a callback * Create a new NTB transport layer queue and provide the queue with a callback
* routine for both transmit and receive. The receive callback routine will be * routine for both transmit and receive. The receive callback routine will be
......
...@@ -1227,7 +1227,7 @@ static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf, ...@@ -1227,7 +1227,7 @@ static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf,
"\tOut buffer addr 0x%pK\n", peer->outbuf); "\tOut buffer addr 0x%pK\n", peer->outbuf);
pos += scnprintf(buf + pos, buf_size - pos, pos += scnprintf(buf + pos, buf_size - pos,
"\tOut buff phys addr %pa[p]\n", &peer->out_phys_addr); "\tOut buff phys addr %pap\n", &peer->out_phys_addr);
pos += scnprintf(buf + pos, buf_size - pos, pos += scnprintf(buf + pos, buf_size - pos,
"\tOut buffer size %pa\n", &peer->outbuf_size); "\tOut buffer size %pa\n", &peer->outbuf_size);
......
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