Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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()

+31 -15
+2 -2
drivers/ntb/core.c
··· 72 72 MODULE_AUTHOR(DRIVER_AUTHOR); 73 73 MODULE_DESCRIPTION(DRIVER_DESCRIPTION); 74 74 75 - static struct bus_type ntb_bus; 75 + static const struct bus_type ntb_bus; 76 76 static void ntb_dev_release(struct device *dev); 77 77 78 78 int __ntb_register_client(struct ntb_client *client, struct module *mod, ··· 298 298 complete(&ntb->released); 299 299 } 300 300 301 - static struct bus_type ntb_bus = { 301 + static const struct bus_type ntb_bus = { 302 302 .name = "ntb", 303 303 .probe = ntb_probe, 304 304 .remove = ntb_remove,
+1 -1
drivers/ntb/hw/epf/ntb_hw_epf.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - /** 2 + /* 3 3 * Host side endpoint driver to implement Non-Transparent Bridge functionality 4 4 * 5 5 * Copyright (C) 2020 Texas Instruments
+1 -1
drivers/ntb/hw/idt/ntb_hw_idt.c
··· 2547 2547 */ 2548 2548 2549 2549 /* 2550 - * idt_check_setup() - Check whether the IDT PCIe-swtich is properly 2550 + * idt_check_setup() - Check whether the IDT PCIe-switch is properly 2551 2551 * pre-initialized 2552 2552 * @pdev: Pointer to the PCI device descriptor 2553 2553 *
+1 -1
drivers/ntb/hw/intel/ntb_hw_gen1.c
··· 778 778 ndev->debugfs_dir = 779 779 debugfs_create_dir(pci_name(ndev->ntb.pdev), 780 780 debugfs_dir); 781 - if (!ndev->debugfs_dir) 781 + if (IS_ERR(ndev->debugfs_dir)) 782 782 ndev->debugfs_info = NULL; 783 783 else 784 784 ndev->debugfs_info =
+1
drivers/ntb/hw/mscc/ntb_hw_switchtec.c
··· 1554 1554 switchtec_ntb_deinit_db_msg_irq(sndev); 1555 1555 switchtec_ntb_deinit_shared_mw(sndev); 1556 1556 switchtec_ntb_deinit_crosslink(sndev); 1557 + cancel_work_sync(&sndev->check_link_status_work); 1557 1558 kfree(sndev); 1558 1559 dev_info(dev, "ntb device unregistered\n"); 1559 1560 }
+24 -9
drivers/ntb/ntb_transport.c
··· 314 314 put_device(dev); 315 315 } 316 316 317 - static struct bus_type ntb_transport_bus = { 317 + static const struct bus_type ntb_transport_bus = { 318 318 .name = "ntb_transport", 319 319 .match = ntb_transport_bus_match, 320 320 .probe = ntb_transport_bus_probe, ··· 377 377 * @device_name: Name of NTB client device 378 378 * 379 379 * Register an NTB client device with the NTB transport layer 380 + * 381 + * Returns: %0 on success or -errno code on error 380 382 */ 381 383 int ntb_transport_register_client_dev(char *device_name) 382 384 { ··· 809 807 } 810 808 811 809 static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw, 812 - struct device *dma_dev, size_t align) 810 + struct device *ntb_dev, size_t align) 813 811 { 814 812 dma_addr_t dma_addr; 815 813 void *alloc_addr, *virt_addr; 816 814 int rc; 817 815 818 - alloc_addr = dma_alloc_coherent(dma_dev, mw->alloc_size, 819 - &dma_addr, GFP_KERNEL); 816 + /* 817 + * The buffer here is allocated against the NTB device. The reason to 818 + * use dma_alloc_*() call is to allocate a large IOVA contiguous buffer 819 + * backing the NTB BAR for the remote host to write to. During receive 820 + * processing, the data is being copied out of the receive buffer to 821 + * the kernel skbuff. When a DMA device is being used, dma_map_page() 822 + * is called on the kvaddr of the receive buffer (from dma_alloc_*()) 823 + * and remapped against the DMA device. It appears to be a double 824 + * DMA mapping of buffers, but first is mapped to the NTB device and 825 + * second is to the DMA device. DMA_ATTR_FORCE_CONTIGUOUS is necessary 826 + * in order for the later dma_map_page() to not fail. 827 + */ 828 + alloc_addr = dma_alloc_attrs(ntb_dev, mw->alloc_size, 829 + &dma_addr, GFP_KERNEL, 830 + DMA_ATTR_FORCE_CONTIGUOUS); 820 831 if (!alloc_addr) { 821 - dev_err(dma_dev, "Unable to alloc MW buff of size %zu\n", 832 + dev_err(ntb_dev, "Unable to alloc MW buff of size %zu\n", 822 833 mw->alloc_size); 823 834 return -ENOMEM; 824 835 } ··· 860 845 return 0; 861 846 862 847 err: 863 - dma_free_coherent(dma_dev, mw->alloc_size, alloc_addr, dma_addr); 848 + dma_free_coherent(ntb_dev, mw->alloc_size, alloc_addr, dma_addr); 864 849 865 850 return rc; 866 851 } ··· 1981 1966 1982 1967 /** 1983 1968 * ntb_transport_create_queue - Create a new NTB transport layer queue 1984 - * @rx_handler: receive callback function 1985 - * @tx_handler: transmit callback function 1986 - * @event_handler: event callback function 1969 + * @data: pointer for callback data 1970 + * @client_dev: &struct device pointer 1971 + * @handlers: pointer to various ntb queue (callback) handlers 1987 1972 * 1988 1973 * Create a new NTB transport layer queue and provide the queue with a callback 1989 1974 * routine for both transmit and receive. The receive callback routine will be
+1 -1
drivers/ntb/test/ntb_perf.c
··· 1227 1227 "\tOut buffer addr 0x%pK\n", peer->outbuf); 1228 1228 1229 1229 pos += scnprintf(buf + pos, buf_size - pos, 1230 - "\tOut buff phys addr %pa[p]\n", &peer->out_phys_addr); 1230 + "\tOut buff phys addr %pap\n", &peer->out_phys_addr); 1231 1231 1232 1232 pos += scnprintf(buf + pos, buf_size - pos, 1233 1233 "\tOut buffer size %pa\n", &peer->outbuf_size);