Skip to content

Commit

Permalink
Merge tag 'ntb-6.5' of https://github.com/jonmason/ntb
Browse files Browse the repository at this point in the history
Pull NTB updates from Jon Mason:
 "Fixes for pci_clean_master, error handling in driver inits, and
  various other issues/bugs"

* tag 'ntb-6.5' of https://github.com/jonmason/ntb:
  ntb: hw: amd: Fix debugfs_create_dir error checking
  ntb.rst: Fix copy and paste error
  ntb_netdev: Fix module_init problem
  ntb: intel: Remove redundant pci_clear_master
  ntb: epf: Remove redundant pci_clear_master
  ntb_hw_amd: Remove redundant pci_clear_master
  ntb: idt: drop redundant pci_enable_pcie_error_reporting()
  MAINTAINERS: git://github -> https://github.com for jonmason
  NTB: EPF: fix possible memory leak in pci_vntb_probe()
  NTB: ntb_tool: Add check for devm_kcalloc
  NTB: ntb_transport: fix possible memory leak while device_register() fails
  ntb: intel: Fix error handling in intel_ntb_pci_driver_init()
  NTB: amd: Fix error handling in amd_ntb_pci_driver_init()
  ntb: idt: Fix error handling in idt_pci_driver_init()
  • Loading branch information
torvalds committed Jul 9, 2023
2 parents 1c7873e + bff6efc commit cff0687
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Documentation/driver-api/ntb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ The MSI test client serves to test and debug the MSI library which
allows for passing MSI interrupts across NTB memory windows. The
test client is interacted with through the debugfs filesystem:

* *debugfs*/ntb\_tool/*hw*/
* *debugfs*/ntb\_msi\_test/*hw*/
A directory in debugfs will be created for each
NTB device probed by the tool. This directory is shortened to *hw*
NTB device probed by the msi test. This directory is shortened to *hw*
below.
* *hw*/port
This file describes the local port number
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -15010,7 +15010,7 @@ M: Allen Hubbe <[email protected]>
L: [email protected]
S: Supported
W: https://github.com/jonmason/ntb/wiki
T: git git://github.com/jonmason/ntb.git
T: git https://github.com/jonmason/ntb.git
F: drivers/net/ntb_netdev.c
F: drivers/ntb/
F: drivers/pci/endpoint/functions/pci-epf-*ntb.c
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ntb_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ static int __init ntb_netdev_init_module(void)

return 0;
}
module_init(ntb_netdev_init_module);
late_initcall(ntb_netdev_init_module);

static void __exit ntb_netdev_exit_module(void)
{
Expand Down
11 changes: 7 additions & 4 deletions drivers/ntb/hw/amd/ntb_hw_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ static void ndev_init_debugfs(struct amd_ntb_dev *ndev)
ndev->debugfs_dir =
debugfs_create_dir(pci_name(ndev->ntb.pdev),
debugfs_dir);
if (!ndev->debugfs_dir)
if (IS_ERR(ndev->debugfs_dir))
ndev->debugfs_info = NULL;
else
ndev->debugfs_info =
Expand Down Expand Up @@ -1194,7 +1194,6 @@ static int amd_ntb_init_pci(struct amd_ntb_dev *ndev,
return 0;

err_dma_mask:
pci_clear_master(pdev);
pci_release_regions(pdev);
err_pci_regions:
pci_disable_device(pdev);
Expand All @@ -1209,7 +1208,6 @@ static void amd_ntb_deinit_pci(struct amd_ntb_dev *ndev)

pci_iounmap(pdev, ndev->self_mmio);

pci_clear_master(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
Expand Down Expand Up @@ -1338,12 +1336,17 @@ static struct pci_driver amd_ntb_pci_driver = {

static int __init amd_ntb_pci_driver_init(void)
{
int ret;
pr_info("%s %s\n", NTB_DESC, NTB_VER);

if (debugfs_initialized())
debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);

return pci_register_driver(&amd_ntb_pci_driver);
ret = pci_register_driver(&amd_ntb_pci_driver);
if (ret)
debugfs_remove_recursive(debugfs_dir);

return ret;
}
module_init(amd_ntb_pci_driver_init);

Expand Down
12 changes: 4 additions & 8 deletions drivers/ntb/hw/epf/ntb_hw_epf.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,22 +591,22 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(dev, "Cannot set DMA mask\n");
goto err_dma_mask;
goto err_pci_regions;
}
dev_warn(&pdev->dev, "Cannot DMA highmem\n");
}

ndev->ctrl_reg = pci_iomap(pdev, ndev->ctrl_reg_bar, 0);
if (!ndev->ctrl_reg) {
ret = -EIO;
goto err_dma_mask;
goto err_pci_regions;
}

if (ndev->peer_spad_reg_bar) {
ndev->peer_spad_reg = pci_iomap(pdev, ndev->peer_spad_reg_bar, 0);
if (!ndev->peer_spad_reg) {
ret = -EIO;
goto err_dma_mask;
goto err_pci_regions;
}
} else {
spad_sz = 4 * readl(ndev->ctrl_reg + NTB_EPF_SPAD_COUNT);
Expand All @@ -617,14 +617,11 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
ndev->db_reg = pci_iomap(pdev, ndev->db_reg_bar, 0);
if (!ndev->db_reg) {
ret = -EIO;
goto err_dma_mask;
goto err_pci_regions;
}

return 0;

err_dma_mask:
pci_clear_master(pdev);

err_pci_regions:
pci_disable_device(pdev);

Expand All @@ -642,7 +639,6 @@ static void ntb_epf_deinit_pci(struct ntb_epf_dev *ndev)
pci_iounmap(pdev, ndev->peer_spad_reg);
pci_iounmap(pdev, ndev->db_reg);

pci_clear_master(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
Expand Down
24 changes: 11 additions & 13 deletions drivers/ntb/hw/idt/ntb_hw_idt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2651,20 +2651,18 @@ static int idt_init_pci(struct idt_ntb_dev *ndev)
}

/*
* Enable the device advanced error reporting. It's not critical to
* The PCI core enables device error reporting. It's not critical to
* have AER disabled in the kernel.
*
* Cleanup nonfatal error status before getting to init.
*/
ret = pci_enable_pcie_error_reporting(pdev);
if (ret != 0)
dev_warn(&pdev->dev, "PCIe AER capability disabled\n");
else /* Cleanup nonfatal error status before getting to init */
pci_aer_clear_nonfatal_status(pdev);
pci_aer_clear_nonfatal_status(pdev);

/* First enable the PCI device */
ret = pcim_enable_device(pdev);
if (ret != 0) {
dev_err(&pdev->dev, "Failed to enable PCIe device\n");
goto err_disable_aer;
return ret;
}

/*
Expand Down Expand Up @@ -2692,8 +2690,6 @@ static int idt_init_pci(struct idt_ntb_dev *ndev)

err_clear_master:
pci_clear_master(pdev);
err_disable_aer:
(void)pci_disable_pcie_error_reporting(pdev);

return ret;
}
Expand All @@ -2714,9 +2710,6 @@ static void idt_deinit_pci(struct idt_ntb_dev *ndev)
/* Clear the bus master disabling the Request TLPs translation */
pci_clear_master(pdev);

/* Disable the AER capability */
(void)pci_disable_pcie_error_reporting(pdev);

dev_dbg(&pdev->dev, "NT-function PCIe interface cleared");
}

Expand Down Expand Up @@ -2891,14 +2884,19 @@ static struct pci_driver idt_pci_driver = {

static int __init idt_pci_driver_init(void)
{
int ret;
pr_info("%s %s\n", NTB_DESC, NTB_VER);

/* Create the top DebugFS directory if the FS is initialized */
if (debugfs_initialized())
dbgfs_topdir = debugfs_create_dir(KBUILD_MODNAME, NULL);

/* Register the NTB hardware driver to handle the PCI device */
return pci_register_driver(&idt_pci_driver);
ret = pci_register_driver(&idt_pci_driver);
if (ret)
debugfs_remove_recursive(dbgfs_topdir);

return ret;
}
module_init(idt_pci_driver_init);

Expand Down
9 changes: 6 additions & 3 deletions drivers/ntb/hw/intel/ntb_hw_gen1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,6 @@ static int intel_ntb_init_pci(struct intel_ntb_dev *ndev, struct pci_dev *pdev)

err_mmio:
err_dma_mask:
pci_clear_master(pdev);
pci_release_regions(pdev);
err_pci_regions:
pci_disable_device(pdev);
Expand All @@ -1808,7 +1807,6 @@ static void intel_ntb_deinit_pci(struct intel_ntb_dev *ndev)
pci_iounmap(pdev, ndev->peer_mmio);
pci_iounmap(pdev, ndev->self_mmio);

pci_clear_master(pdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
Expand Down Expand Up @@ -2064,12 +2062,17 @@ static struct pci_driver intel_ntb_pci_driver = {

static int __init intel_ntb_pci_driver_init(void)
{
int ret;
pr_info("%s %s\n", NTB_DESC, NTB_VER);

if (debugfs_initialized())
debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);

return pci_register_driver(&intel_ntb_pci_driver);
ret = pci_register_driver(&intel_ntb_pci_driver);
if (ret)
debugfs_remove_recursive(debugfs_dir);

return ret;
}
module_init(intel_ntb_pci_driver_init);

Expand Down
2 changes: 1 addition & 1 deletion drivers/ntb/ntb_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ int ntb_transport_register_client_dev(char *device_name)

rc = device_register(dev);
if (rc) {
kfree(client_dev);
put_device(dev);
goto err;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/ntb/test/ntb_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc)
tc->peers[pidx].outmws =
devm_kcalloc(&tc->ntb->dev, tc->peers[pidx].outmw_cnt,
sizeof(*tc->peers[pidx].outmws), GFP_KERNEL);
if (tc->peers[pidx].outmws == NULL)
return -ENOMEM;

for (widx = 0; widx < tc->peers[pidx].outmw_cnt; widx++) {
tc->peers[pidx].outmws[widx].pidx = pidx;
Expand Down
1 change: 1 addition & 0 deletions drivers/pci/endpoint/functions/pci-epf-vntb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ static int pci_vntb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return 0;

err_register_dev:
put_device(&ndev->ntb.dev);
return -EINVAL;
}

Expand Down

0 comments on commit cff0687

Please sign in to comment.