Message ID | 20221031164547.1886851-1-m.chetan.kumar@linux.intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,1/3] net: wwan: iosm: fix memory leak in ipc_pcie_read_bios_cfg | expand |
Hi, I love your patch! Yet something to improve: [auto build test ERROR on net/master] url: https://github.com/intel-lab-lkp/linux/commits/m-chetan-kumar-linux-intel-com/net-wwan-iosm-fix-memory-leak-in-ipc_pcie_read_bios_cfg/20221101-004705 patch link: https://lore.kernel.org/r/20221031164547.1886851-1-m.chetan.kumar%40linux.intel.com patch subject: [PATCH net 2/3] net: wwan: iosm: fix driver not working with INTEL_IOMMU disabled config: s390-allmodconfig compiler: s390-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/411347d4a4da7b0b70bc1018fe97263bd76073bf git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review m-chetan-kumar-linux-intel-com/net-wwan-iosm-fix-memory-leak-in-ipc_pcie_read_bios_cfg/20221101-004705 git checkout 411347d4a4da7b0b70bc1018fe97263bd76073bf # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash drivers/net/wwan/iosm/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All error/warnings (new ones prefixed by >>): drivers/net/wwan/iosm/iosm_ipc_pcie.c: In function 'ipc_pcie_resources_request': >> drivers/net/wwan/iosm/iosm_ipc_pcie.c:122:9: error: implicit declaration of function 'pcie_capability_read_dword' [-Werror=implicit-function-declaration] 122 | pcie_capability_read_dword(ipc_pcie->pci, PCI_EXP_DEVCAP2, &cap); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/net/wwan/iosm/iosm_ipc_pcie.c:124:17: error: implicit declaration of function 'pcie_capability_set_word' [-Werror=implicit-function-declaration] 124 | pcie_capability_set_word(ipc_pcie->pci, PCI_EXP_DEVCTL2, | ^~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/wwan/iosm/iosm_ipc_pcie.c: In function 'ipc_pcie_check_aspm_enabled': >> drivers/net/wwan/iosm/iosm_ipc_pcie.c:153:9: error: implicit declaration of function 'pcie_capability_read_word' [-Werror=implicit-function-declaration] 153 | pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &value); | ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/wwan/iosm/iosm_ipc_pcie.c: At top level: >> drivers/net/wwan/iosm/iosm_ipc_pcie.c:450:1: warning: data definition has no type or storage class 450 | module_pci_driver(iosm_ipc_driver); | ^~~~~~~~~~~~~~~~~ >> drivers/net/wwan/iosm/iosm_ipc_pcie.c:450:1: error: type defaults to 'int' in declaration of 'module_pci_driver' [-Werror=implicit-int] >> drivers/net/wwan/iosm/iosm_ipc_pcie.c:450:1: warning: parameter names (without types) in function declaration drivers/net/wwan/iosm/iosm_ipc_pcie.c:441:26: warning: 'iosm_ipc_driver' defined but not used [-Wunused-variable] 441 | static struct pci_driver iosm_ipc_driver = { | ^~~~~~~~~~~~~~~ cc1: some warnings being treated as errors -- drivers/net/wwan/iosm/iosm_ipc_irq.c: In function 'ipc_release_irq': >> drivers/net/wwan/iosm/iosm_ipc_irq.c:57:9: error: implicit declaration of function 'pci_free_irq_vectors'; did you mean 'pci_alloc_irq_vectors'? [-Werror=implicit-function-declaration] 57 | pci_free_irq_vectors(pdev); | ^~~~~~~~~~~~~~~~~~~~ | pci_alloc_irq_vectors cc1: some warnings being treated as errors vim +/pcie_capability_read_dword +122 drivers/net/wwan/iosm/iosm_ipc_pcie.c 7e98d785ae6184 M Chetan Kumar 2021-06-13 65 7e98d785ae6184 M Chetan Kumar 2021-06-13 66 static int ipc_pcie_resources_request(struct iosm_pcie *ipc_pcie) 7e98d785ae6184 M Chetan Kumar 2021-06-13 67 { 7e98d785ae6184 M Chetan Kumar 2021-06-13 68 struct pci_dev *pci = ipc_pcie->pci; 7e98d785ae6184 M Chetan Kumar 2021-06-13 69 u32 cap = 0; 7e98d785ae6184 M Chetan Kumar 2021-06-13 70 u32 ret; 7e98d785ae6184 M Chetan Kumar 2021-06-13 71 7e98d785ae6184 M Chetan Kumar 2021-06-13 72 /* Reserved PCI I/O and memory resources. 7e98d785ae6184 M Chetan Kumar 2021-06-13 73 * Mark all PCI regions associated with PCI device pci as 7e98d785ae6184 M Chetan Kumar 2021-06-13 74 * being reserved by owner IOSM_IPC. 7e98d785ae6184 M Chetan Kumar 2021-06-13 75 */ 7e98d785ae6184 M Chetan Kumar 2021-06-13 76 ret = pci_request_regions(pci, "IOSM_IPC"); 7e98d785ae6184 M Chetan Kumar 2021-06-13 77 if (ret) { 7e98d785ae6184 M Chetan Kumar 2021-06-13 78 dev_err(ipc_pcie->dev, "failed pci request regions"); 7e98d785ae6184 M Chetan Kumar 2021-06-13 79 goto pci_request_region_fail; 7e98d785ae6184 M Chetan Kumar 2021-06-13 80 } 7e98d785ae6184 M Chetan Kumar 2021-06-13 81 7e98d785ae6184 M Chetan Kumar 2021-06-13 82 /* Reserve the doorbell IPC REGS memory resources. 7e98d785ae6184 M Chetan Kumar 2021-06-13 83 * Remap the memory into CPU space. Arrange for the physical address 7e98d785ae6184 M Chetan Kumar 2021-06-13 84 * (BAR) to be visible from this driver. 7e98d785ae6184 M Chetan Kumar 2021-06-13 85 * pci_ioremap_bar() ensures that the memory is marked uncachable. 7e98d785ae6184 M Chetan Kumar 2021-06-13 86 */ 7e98d785ae6184 M Chetan Kumar 2021-06-13 87 ipc_pcie->ipc_regs = pci_ioremap_bar(pci, ipc_pcie->ipc_regs_bar_nr); 7e98d785ae6184 M Chetan Kumar 2021-06-13 88 7e98d785ae6184 M Chetan Kumar 2021-06-13 89 if (!ipc_pcie->ipc_regs) { 7e98d785ae6184 M Chetan Kumar 2021-06-13 90 dev_err(ipc_pcie->dev, "IPC REGS ioremap error"); 7e98d785ae6184 M Chetan Kumar 2021-06-13 91 ret = -EBUSY; 7e98d785ae6184 M Chetan Kumar 2021-06-13 92 goto ipc_regs_remap_fail; 7e98d785ae6184 M Chetan Kumar 2021-06-13 93 } 7e98d785ae6184 M Chetan Kumar 2021-06-13 94 7e98d785ae6184 M Chetan Kumar 2021-06-13 95 /* Reserve the MMIO scratchpad memory resources. 7e98d785ae6184 M Chetan Kumar 2021-06-13 96 * Remap the memory into CPU space. Arrange for the physical address 7e98d785ae6184 M Chetan Kumar 2021-06-13 97 * (BAR) to be visible from this driver. 7e98d785ae6184 M Chetan Kumar 2021-06-13 98 * pci_ioremap_bar() ensures that the memory is marked uncachable. 7e98d785ae6184 M Chetan Kumar 2021-06-13 99 */ 7e98d785ae6184 M Chetan Kumar 2021-06-13 100 ipc_pcie->scratchpad = 7e98d785ae6184 M Chetan Kumar 2021-06-13 101 pci_ioremap_bar(pci, ipc_pcie->scratchpad_bar_nr); 7e98d785ae6184 M Chetan Kumar 2021-06-13 102 7e98d785ae6184 M Chetan Kumar 2021-06-13 103 if (!ipc_pcie->scratchpad) { 7e98d785ae6184 M Chetan Kumar 2021-06-13 104 dev_err(ipc_pcie->dev, "doorbell scratchpad ioremap error"); 7e98d785ae6184 M Chetan Kumar 2021-06-13 105 ret = -EBUSY; 7e98d785ae6184 M Chetan Kumar 2021-06-13 106 goto scratch_remap_fail; 7e98d785ae6184 M Chetan Kumar 2021-06-13 107 } 7e98d785ae6184 M Chetan Kumar 2021-06-13 108 7e98d785ae6184 M Chetan Kumar 2021-06-13 109 /* Install the irq handler triggered by CP. */ 7e98d785ae6184 M Chetan Kumar 2021-06-13 110 ret = ipc_acquire_irq(ipc_pcie); 7e98d785ae6184 M Chetan Kumar 2021-06-13 111 if (ret) { 7e98d785ae6184 M Chetan Kumar 2021-06-13 112 dev_err(ipc_pcie->dev, "acquiring MSI irq failed!"); 7e98d785ae6184 M Chetan Kumar 2021-06-13 113 goto irq_acquire_fail; 7e98d785ae6184 M Chetan Kumar 2021-06-13 114 } 7e98d785ae6184 M Chetan Kumar 2021-06-13 115 7e98d785ae6184 M Chetan Kumar 2021-06-13 116 /* Enable bus-mastering for the IOSM IPC device. */ 7e98d785ae6184 M Chetan Kumar 2021-06-13 117 pci_set_master(pci); 7e98d785ae6184 M Chetan Kumar 2021-06-13 118 7e98d785ae6184 M Chetan Kumar 2021-06-13 119 /* Enable LTR if possible 7e98d785ae6184 M Chetan Kumar 2021-06-13 120 * This is needed for L1.2! 7e98d785ae6184 M Chetan Kumar 2021-06-13 121 */ 7e98d785ae6184 M Chetan Kumar 2021-06-13 @122 pcie_capability_read_dword(ipc_pcie->pci, PCI_EXP_DEVCAP2, &cap); 7e98d785ae6184 M Chetan Kumar 2021-06-13 123 if (cap & PCI_EXP_DEVCAP2_LTR) 7e98d785ae6184 M Chetan Kumar 2021-06-13 @124 pcie_capability_set_word(ipc_pcie->pci, PCI_EXP_DEVCTL2, 7e98d785ae6184 M Chetan Kumar 2021-06-13 125 PCI_EXP_DEVCTL2_LTR_EN); 7e98d785ae6184 M Chetan Kumar 2021-06-13 126 7e98d785ae6184 M Chetan Kumar 2021-06-13 127 dev_dbg(ipc_pcie->dev, "link between AP and CP is fully on"); 7e98d785ae6184 M Chetan Kumar 2021-06-13 128 7e98d785ae6184 M Chetan Kumar 2021-06-13 129 return ret; 7e98d785ae6184 M Chetan Kumar 2021-06-13 130 7e98d785ae6184 M Chetan Kumar 2021-06-13 131 irq_acquire_fail: 7e98d785ae6184 M Chetan Kumar 2021-06-13 132 iounmap(ipc_pcie->scratchpad); 7e98d785ae6184 M Chetan Kumar 2021-06-13 133 scratch_remap_fail: 7e98d785ae6184 M Chetan Kumar 2021-06-13 134 iounmap(ipc_pcie->ipc_regs); 7e98d785ae6184 M Chetan Kumar 2021-06-13 135 ipc_regs_remap_fail: 7e98d785ae6184 M Chetan Kumar 2021-06-13 136 pci_release_regions(pci); 7e98d785ae6184 M Chetan Kumar 2021-06-13 137 pci_request_region_fail: 7e98d785ae6184 M Chetan Kumar 2021-06-13 138 return ret; 7e98d785ae6184 M Chetan Kumar 2021-06-13 139 } 7e98d785ae6184 M Chetan Kumar 2021-06-13 140 7e98d785ae6184 M Chetan Kumar 2021-06-13 141 bool ipc_pcie_check_aspm_enabled(struct iosm_pcie *ipc_pcie, 7e98d785ae6184 M Chetan Kumar 2021-06-13 142 bool parent) 7e98d785ae6184 M Chetan Kumar 2021-06-13 143 { 7e98d785ae6184 M Chetan Kumar 2021-06-13 144 struct pci_dev *pdev; 7e98d785ae6184 M Chetan Kumar 2021-06-13 145 u16 value = 0; 7e98d785ae6184 M Chetan Kumar 2021-06-13 146 u32 enabled; 7e98d785ae6184 M Chetan Kumar 2021-06-13 147 7e98d785ae6184 M Chetan Kumar 2021-06-13 148 if (parent) 7e98d785ae6184 M Chetan Kumar 2021-06-13 149 pdev = ipc_pcie->pci->bus->self; 7e98d785ae6184 M Chetan Kumar 2021-06-13 150 else 7e98d785ae6184 M Chetan Kumar 2021-06-13 151 pdev = ipc_pcie->pci; 7e98d785ae6184 M Chetan Kumar 2021-06-13 152 7e98d785ae6184 M Chetan Kumar 2021-06-13 @153 pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &value); 7e98d785ae6184 M Chetan Kumar 2021-06-13 154 enabled = value & PCI_EXP_LNKCTL_ASPMC; 7e98d785ae6184 M Chetan Kumar 2021-06-13 155 dev_dbg(ipc_pcie->dev, "ASPM L1: 0x%04X 0x%03X", pdev->device, value); 7e98d785ae6184 M Chetan Kumar 2021-06-13 156 7e98d785ae6184 M Chetan Kumar 2021-06-13 157 return (enabled == PCI_EXP_LNKCTL_ASPM_L1 || 7e98d785ae6184 M Chetan Kumar 2021-06-13 158 enabled == PCI_EXP_LNKCTL_ASPMC); 7e98d785ae6184 M Chetan Kumar 2021-06-13 159 } 7e98d785ae6184 M Chetan Kumar 2021-06-13 160
diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig index 3486ffe94ac4..58e1eb4cf45c 100644 --- a/drivers/net/wwan/Kconfig +++ b/drivers/net/wwan/Kconfig @@ -94,7 +94,6 @@ config RPMSG_WWAN_CTRL config IOSM tristate "IOSM Driver for Intel M.2 WWAN Device" - depends on INTEL_IOMMU select NET_DEVLINK select RELAY if WWAN_DEBUGFS help diff --git a/drivers/net/wwan/iosm/iosm_ipc_pcie.c b/drivers/net/wwan/iosm/iosm_ipc_pcie.c index 97cb6846c6ae..d3d34d1c4704 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_pcie.c +++ b/drivers/net/wwan/iosm/iosm_ipc_pcie.c @@ -259,6 +259,7 @@ static int ipc_pcie_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { struct iosm_pcie *ipc_pcie = kzalloc(sizeof(*ipc_pcie), GFP_KERNEL); + int ret; pr_debug("Probing device 0x%X from the vendor 0x%X", pci_id->device, pci_id->vendor); @@ -291,6 +292,12 @@ static int ipc_pcie_probe(struct pci_dev *pci, goto pci_enable_fail; } + ret = dma_set_mask(ipc_pcie->dev, DMA_BIT_MASK(64)); + if (ret) { + dev_err(ipc_pcie->dev, "Could not set PCI DMA mask: %d", ret); + return ret; + } + ipc_pcie_config_aspm(ipc_pcie); dev_dbg(ipc_pcie->dev, "PCIe device enabled.");