stmmac: Replace deprecated PCI functions
Subsystems (4)
PATCH 1/1 stmmac: Replace deprecated PCI functions
From: Philipp Stanner <[email protected]>
The PCI functions
- pcim_iomap_regions()
- pcim_iomap_table() and
- pcim_iounmap_regions()
have been deprecated.
The usage of pcim_* cleanup functions in the driver detach path (remove callback) is actually not necessary, since they perform that cleanup automatically.
Replace them with pcim_iomap_region().
--- .../ethernet/stmicro/stmmac/dwmac-loongson.c | 28 ++++++------------- .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 24 ++++------------ 2 files changed, 14 insertions(+), 38 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +8 -20
@@ -11,6 +11,8 @@#include "dwmac_dma.h" #include "dwmac1000.h" +#define DRIVER_NAME "dwmac-loongson-pci" +/* Normal Loongson Tx Summary */ #define DMA_INTR_ENA_NIE_TX_LOONGSON 0x00040000/* Normal Loongson Rx Summary */
@@ -520,7 +522,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id {struct plat_stmmacenet_data *plat;struct stmmac_pci_info *info; -struct stmmac_resources res; +struct stmmac_resources res = {};struct loongson_data *ld;int ret, i;
@@ -552,17 +554,10 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idpci_set_master (pdev);/* Get the base address of device */ -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; - ret =pcim_iomap_regions (pdev,BIT (0 ),pci_name (pdev)); -if (ret) - goto err_disable_device; -break ; - } - -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[0 ]; + res.addr =pcim_iomap_region (pdev,0 ,DRIVER_NAME ); + ret =PTR_ERR_OR_ZERO (res.addr); +if (ret) + goto err_disable_device; plat->bsp_priv = ld; plat->setup = loongson_dwmac_setup;
@@ -617,13 +612,6 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)if (ld->loongson_id ==DWMAC_CORE_LS_MULTICHAN )loongson_dwmac_msi_clear (pdev); -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; -pcim_iounmap_regions (pdev,BIT (i)); -break ; - } -pci_disable_device (pdev); }
@@ -673,7 +661,7 @@ static const struct pci_device_id loongson_dwmac_id_table[] = {MODULE_DEVICE_TABLE (pci, loongson_dwmac_id_table);static struct pci_driver loongson_dwmac_driver = { - .name ="dwmac-loongson-pci" , + .name =DRIVER_NAME , .id_table = loongson_dwmac_id_table, .probe = loongson_dwmac_probe, .remove = loongson_dwmac_remove,
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +6 -18
@@ -155,7 +155,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev, {struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;struct plat_stmmacenet_data *plat; -struct stmmac_resources res; +struct stmmac_resources res = {};int i;int ret;
@@ -188,13 +188,13 @@ static int stmmac_pci_probe(struct pci_dev *pdev,return ret; } -/* Get the base address of device */ +/* The first BAR > 0 is the base IO addr of our device. */ for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {if (pci_resource_len (pdev, i) ==0 )continue ; - ret =pcim_iomap_regions (pdev,BIT (i),pci_name (pdev)); -if (ret) -return ret; + res.addr =pcim_iomap_region (pdev, i,STMMAC_RESOURCE_NAME ); +if (IS_ERR (res.addr)) +return PTR_ERR (res.addr) break; }
@@ -204,8 +204,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev,if (ret)return ret; -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[i]; res.wol_irq = pdev->irq; res.irq = pdev->irq;
@@ -226,21 +224,11 @@ static int stmmac_pci_probe(struct pci_dev *pdev,* stmmac_pci_remove * * @pdev: platform device pointer -* Description: this function calls the main to free the net resources -* and releases the PCI resources. +* Description: Main driver resource release function */ static void stmmac_pci_remove (struct pci_dev *pdev) { -int i; -stmmac_dvr_remove (&pdev->dev); - -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; -pcim_iounmap_regions (pdev,BIT (i)); -break ; - } }static int __maybe_unused stmmac_pci_suspend (struct device *dev)
Signature · 1 line
2.47.1
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id · line 557
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1
-11/* Get the base address of device */ -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; - ret =pcim_iomap_regions (pdev,BIT (0 ),pci_name (pdev)); -if (ret) - goto err_disable_device; -break ; - } - -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[0 ]; + res.addr =pcim_iomap_region (pdev,0 ,DRIVER_NAME );
I don't know too much about PCI, but this change does not look obviously correct to me. Maybe the commit message needs expanding to explain why the loop can be thrown away? Also, is that BIT(0) actually wrong, it should of been BIT(i)? Is that why the loop is pointless and can be removed? If so, we should be asking the developer of this code what are the implications of the bug. Should the loop be kept?
Andrew
Quoted 15 lines · Andrew Lunn
Quoted 6 lines
/* Get the base address of device */
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0
-4-for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; - ret = pcim_iomap_regions(pdev, BIT(0),
pci_name(pdev));drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id · line 557
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1
-7-if (ret) - goto err_disable_device; -break ; - } - -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[0 ]; + res.addr =pcim_iomap_region (pdev,0 ,DRIVER_NAME );
Quoted 8 lines
I don't know too much about PCI, but this change does not look obviously correct to me. Maybe the commit message needs expanding to explain why the loop can be thrown away? Also, is that BIT(0) actually
wrong, it should of been BIT(i)? Is that why the loop is pointless and
can be removed? If so, we should be asking the developer of this code what are the implications of the bug. Should the loop be kept?
Yes, the reason why the loop is pointless is that it calls BIT(0) for all runs, instead of BIT(i). This would have caused an error btw if it weren't for pci_resource_len(…) == 0, which I assume prevents trying to request BAR0 more than once, which s hould fail.
The commit message should mention this, agreed.
I assume this is not a bug, but the code was just copied from the other part (also touched in this patch) where a loop was necessary. Argument being that if the above were a bug, it would definitely have been noticed because the BARs other than 0 are not being mapped, so trying to access them should result in faults.
Although a confirmation by the respective developer would indeed be nice.
P.
Quoted 2 lines
Andrew
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Philipp,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.14-rc2 next-20250212]
[cannot apply to horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/stmmac-Replace-deprecated-PCI-functions/20250212-230254 base: linus/master patch link: https://lore.kernel.org/r/20250212145831.101719-2-phasta%40kernel.org patch subject: [PATCH] stmmac: Replace deprecated PCI functions config: sparc64-randconfig-001-20250213 (https://download.01.org/0day-ci/archive/20250213/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250213/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c: In function 'stmmac_pci_probe':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:197:49: error: expected ';' before 'break'
197 | return PTR_ERR(res.addr)
| ^
| ;
198 | break;
| ~~~~~ vim +197 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
140
141 /**
142 * stmmac_pci_probe
143 *
144 * @pdev: pci device pointer
145 * @id: pointer to table of device id/id's.
146 *
147 * Description: This probing function gets called for all PCI devices which
148 * match the ID table and are not "owned" by other driver yet. This function
149 * gets passed a "struct pci_dev *" for each device whose entry in the ID table
150 * matches the device. The probe functions returns zero when the driver choose
151 * to take "ownership" of the device or an error code(-ve no) otherwise.
152 */
153 static int stmmac_pci_probe(struct pci_dev *pdev,
154 const struct pci_device_id *id)
155 {
156 struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
157 struct plat_stmmacenet_data *plat;
158 struct stmmac_resources res = {};
159 int i;
160 int ret;
161
162 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
163 if (!plat)
164 return -ENOMEM;
165
166 plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
167 sizeof(*plat->mdio_bus_data),
168 GFP_KERNEL);
169 if (!plat->mdio_bus_data)
170 return -ENOMEM;
171
172 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
173 GFP_KERNEL);
174 if (!plat->dma_cfg)
175 return -ENOMEM;
176
177 plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
178 sizeof(*plat->safety_feat_cfg),
179 GFP_KERNEL);
180 if (!plat->safety_feat_cfg)
181 return -ENOMEM;
182
183 /* Enable pci device */
184 ret = pcim_enable_device(pdev);
185 if (ret) {
186 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
187 __func__);
188 return ret;
189 }
190
191 /* The first BAR > 0 is the base IO addr of our device. */
192 for (i = 0; i < PCI_STD_NUM_BARS; i++) {
193 if (pci_resource_len(pdev, i) == 0)
194 continue;
195 res.addr = pcim_iomap_region(pdev, i, STMMAC_RESOURCE_NAME);
196 if (IS_ERR(res.addr))
> 197 return PTR_ERR(res.addr)
198 break;
199 }
200
201 pci_set_master(pdev);
202
203 ret = info->setup(pdev, plat);
204 if (ret)
205 return ret;
206
207 res.wol_irq = pdev->irq;
208 res.irq = pdev->irq;
209
210 plat->safety_feat_cfg->tsoee = 1;
211 plat->safety_feat_cfg->mrxpee = 1;
212 plat->safety_feat_cfg->mestee = 1;
213 plat->safety_feat_cfg->mrxee = 1;
214 plat->safety_feat_cfg->mtxee = 1;
215 plat->safety_feat_cfg->epsi = 1;
216 plat->safety_feat_cfg->edpp = 1;
217 plat->safety_feat_cfg->prtyen = 1;
218 plat->safety_feat_cfg->tmouten = 1;
219
220 return stmmac_dvr_probe(&pdev->dev, plat, &res);
221 }
222
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Philipp,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.14-rc2 next-20250213]
[cannot apply to horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/stmmac-Replace-deprecated-PCI-functions/20250212-230254 base: linus/master patch link: https://lore.kernel.org/r/20250212145831.101719-2-phasta%40kernel.org patch subject: [PATCH] stmmac: Replace deprecated PCI functions config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250213/[email protected]/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250213/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:13:
In file included from include/linux/pci.h:37:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:197:28: error: expected ';' after return statement
197 | return PTR_ERR(res.addr)
| ^
| ;3 warnings and 1 error generated.
vim +197 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
140
141 /**
142 * stmmac_pci_probe
143 *
144 * @pdev: pci device pointer
145 * @id: pointer to table of device id/id's.
146 *
147 * Description: This probing function gets called for all PCI devices which
148 * match the ID table and are not "owned" by other driver yet. This function
149 * gets passed a "struct pci_dev *" for each device whose entry in the ID table
150 * matches the device. The probe functions returns zero when the driver choose
151 * to take "ownership" of the device or an error code(-ve no) otherwise.
152 */
153 static int stmmac_pci_probe(struct pci_dev *pdev,
154 const struct pci_device_id *id)
155 {
156 struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
157 struct plat_stmmacenet_data *plat;
158 struct stmmac_resources res = {};
159 int i;
160 int ret;
161
162 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
163 if (!plat)
164 return -ENOMEM;
165
166 plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
167 sizeof(*plat->mdio_bus_data),
168 GFP_KERNEL);
169 if (!plat->mdio_bus_data)
170 return -ENOMEM;
171
172 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
173 GFP_KERNEL);
174 if (!plat->dma_cfg)
175 return -ENOMEM;
176
177 plat->safety_feat_cfg = devm_kzalloc(&pdev->dev,
178 sizeof(*plat->safety_feat_cfg),
179 GFP_KERNEL);
180 if (!plat->safety_feat_cfg)
181 return -ENOMEM;
182
183 /* Enable pci device */
184 ret = pcim_enable_device(pdev);
185 if (ret) {
186 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
187 __func__);
188 return ret;
189 }
190
191 /* The first BAR > 0 is the base IO addr of our device. */
192 for (i = 0; i < PCI_STD_NUM_BARS; i++) {
193 if (pci_resource_len(pdev, i) == 0)
194 continue;
195 res.addr = pcim_iomap_region(pdev, i, STMMAC_RESOURCE_NAME);
196 if (IS_ERR(res.addr))
> 197 return PTR_ERR(res.addr)
198 break;
199 }
200
201 pci_set_master(pdev);
202
203 ret = info->setup(pdev, plat);
204 if (ret)
205 return ret;
206
207 res.wol_irq = pdev->irq;
208 res.irq = pdev->irq;
209
210 plat->safety_feat_cfg->tsoee = 1;
211 plat->safety_feat_cfg->mrxpee = 1;
212 plat->safety_feat_cfg->mestee = 1;
213 plat->safety_feat_cfg->mrxee = 1;
214 plat->safety_feat_cfg->mtxee = 1;
215 plat->safety_feat_cfg->epsi = 1;
216 plat->safety_feat_cfg->edpp = 1;
217 plat->safety_feat_cfg->prtyen = 1;
218 plat->safety_feat_cfg->tmouten = 1;
219
220 return stmmac_dvr_probe(&pdev->dev, plat, &res);
221 }
222
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 3 lines · kernel test robot
Hi Philipp,
kernel test robot noticed the following build errors:
sorry about those explosions. Normally I always test build. I think I accidentally used an old branch. Too many branches…
Will fix all that in v2.
P.
Quoted 174 lines
[auto build test ERROR on linus/master]
[also build test ERROR on v6.14-rc2 next-20250213] [cannot apply to horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url:
https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/stmmac-Replace-deprecated-PCI-functions/20250212-230254
base: linus/master
patch link:
https://lore.kernel.org/r/20250212145831.101719-2-phasta%40kernel.org
patch subject: [PATCH] stmmac: Replace deprecated PCI functions
config: s390-allmodconfig
(https://download.01.org/0day-ci/archive/20250213/202502131623.bMnlG9
[email protected]/config)
compiler: clang version 19.1.3
(https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20250213/202502131623.bMnlG9
[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tagsQuoted 3 lines
Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:13:
In file included frominclude/linux/pci.h:37:
In file included frominclude/linux/device.h:32:
In file included frominclude/linux/device/driver.h:21:
In file included frominclude/linux/module.h:19:
In file included frominclude/linux/elf.h:6:
In file included fromarch/s390/include/asm/elf.h:181:
In file included fromarch/s390/include/asm/mmu_context.h:11:
In file included fromarch/s390/include/asm/pgalloc.h:18:
In file included frominclude/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS + | ~~~~~~~~~~~~~~~~~~~~~ ^ 505 | item];
| ~~~~include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS + | ~~~~~~~~~~~~~~~~~~~~~ ^ 512 |NR_VM_NUMA_EVENT_ITEMS+ | ~~~~~~~~~~~~~~~~~~~~~~include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enumzone_stat_item' and 'enumnuma_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS + | ~~~~~~~~~~~~~~~~~~~~~ ^ 525 |NR_VM_NUMA_EVENT_ITEMS+ | ~~~~~~~~~~~~~~~~~~~~~~Quoted 2 lines
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:197:28: error:
expected ';' after return statement197 | return
PTR_ERR(res.addr)| ^ | ; 3 warnings and 1 error generated.vim +197
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c140
141 /**
142 *stmmac_pci_probe
143 *
144 * @pdev: pci device pointer
145 * @id: pointer to table of device id/id's.
146 *
147 * Description: This probing function gets called for all
PCI devices which
148 * match the ID table and are not "owned" by other driver
yet. This function
149 * gets passed a "structpci_dev*" for each device whose
entry in the ID table
150 * matches the device. The probe functions returns zero when
the driver choose
151 * to take "ownership" of the device or an error code(-ve
no) otherwise.
152 */
153 static int stmmac_pci_probe(structpci_dev*pdev,
154 const structpci_device_id*id)
155 {
156 structstmmac_pci_info*info = (structstmmac_pci_info*)id->driver_data;
157 structplat_stmmacenet_data*plat;
158 structstmmac_resourcesres = {};
159 int i;
160 int ret;
161
162 plat = devm_kzalloc(&pdev->dev,sizeof(*plat),GFP_KERNEL);
163 if (!plat)
164 return-ENOMEM;
165
166plat->mdio_bus_data= devm_kzalloc(&pdev->dev,
167 sizeof(*plat-Quoted 1 line
mdio_bus_data),168
GFP_KERNEL);
169 if (!plat->mdio_bus_data)
170 return-ENOMEM;
171
172plat->dma_cfg= devm_kzalloc(&pdev->dev,sizeof(*plat->dma_cfg),
173GFP_KERNEL);
174 if (!plat->dma_cfg)
175 return-ENOMEM;
176
177plat->safety_feat_cfg= devm_kzalloc(&pdev->dev,
178 sizeof(*plat-Quoted 1 line
safety_feat_cfg),179
GFP_KERNEL);
180 if (!plat->safety_feat_cfg)
181 return-ENOMEM;
182
183 /* Enable pci device */
184 ret =pcim_enable_device(pdev);
185 if (ret) {
186 dev_err(&pdev->dev, "%s: ERROR: failed to
enable device\n",
187__func__);
188 return ret;
189 }
190
191 /* The first BAR > 0 is the base IO addr of our
device. */
192 for (i = 0; i <PCI_STD_NUM_BARS; i++) {
193 if (pci_resource_len(pdev, i)== 0)
194 continue;
195 res.addr = pcim_iomap_region(pdev, i,STMMAC_RESOURCE_NAME);
196 if (IS_ERR(res.addr))
> 197 returnPTR_ERR(res.addr)
198 break;
199 }
200
201pci_set_master(pdev);
202
203 ret =info->setup(pdev, plat);
204 if (ret)
205 return ret;
206
207 res.wol_irq =pdev->irq;
208 res.irq =pdev->irq;
209
210plat->safety_feat_cfg->tsoee= 1;
211plat->safety_feat_cfg->mrxpee= 1;
212plat->safety_feat_cfg->mestee= 1;
213plat->safety_feat_cfg->mrxee= 1;
214plat->safety_feat_cfg->mtxee= 1;
215plat->safety_feat_cfg->epsi= 1;
216plat->safety_feat_cfg->edpp= 1;
217plat->safety_feat_cfg->prtyen= 1;
218plat->safety_feat_cfg->tmouten= 1;
219
220 returnstmmac_dvr_probe(&pdev->dev, plat, &res);
221 }
222
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Philipp,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.14-rc2 next-20250213]
[cannot apply to horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/stmmac-Replace-deprecated-PCI-functions/20250212-230254 base: linus/master patch link: https://lore.kernel.org/r/20250212145831.101719-2-phasta%40kernel.org patch subject: [PATCH] stmmac: Replace deprecated PCI functions config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20250213/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250213/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c: In function 'loongson_dwmac_probe':
>> drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:527:18: warning: unused variable 'i' [-Wunused-variable]
527 | int ret, i;
| ^
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c: In function 'loongson_dwmac_remove':
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c:604:13: warning: unused variable 'i' [-Wunused-variable]
604 | int i;
| ^vim +/i +527 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
126f4f96c41d2e Yanteng Si 2024-08-07 520
30bba69d7db40e Qing Zhang 2021-06-18 521 static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
30bba69d7db40e Qing Zhang 2021-06-18 522 {
30bba69d7db40e Qing Zhang 2021-06-18 523 struct plat_stmmacenet_data *plat;
0ec04d32b5e7f0 Yanteng Si 2024-08-07 524 struct stmmac_pci_info *info;
bd83fd598ba34f Philipp Stanner 2025-02-12 525 struct stmmac_resources res = {};
803fc61df261de Yanteng Si 2024-08-07 526 struct loongson_data *ld;
126f4f96c41d2e Yanteng Si 2024-08-07 @527 int ret, i;
30bba69d7db40e Qing Zhang 2021-06-18 528
30bba69d7db40e Qing Zhang 2021-06-18 529 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
30bba69d7db40e Qing Zhang 2021-06-18 530 if (!plat)
30bba69d7db40e Qing Zhang 2021-06-18 531 return -ENOMEM;
30bba69d7db40e Qing Zhang 2021-06-18 532
30bba69d7db40e Qing Zhang 2021-06-18 533 plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
30bba69d7db40e Qing Zhang 2021-06-18 534 sizeof(*plat->mdio_bus_data),
30bba69d7db40e Qing Zhang 2021-06-18 535 GFP_KERNEL);
e87d3a1370ce9f Yanteng Si 2023-12-11 536 if (!plat->mdio_bus_data)
e87d3a1370ce9f Yanteng Si 2023-12-11 537 return -ENOMEM;
e87d3a1370ce9f Yanteng Si 2023-12-11 538
30bba69d7db40e Qing Zhang 2021-06-18 539 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
126f4f96c41d2e Yanteng Si 2024-08-07 540 if (!plat->dma_cfg)
126f4f96c41d2e Yanteng Si 2024-08-07 541 return -ENOMEM;
30bba69d7db40e Qing Zhang 2021-06-18 542
803fc61df261de Yanteng Si 2024-08-07 543 ld = devm_kzalloc(&pdev->dev, sizeof(*ld), GFP_KERNEL);
803fc61df261de Yanteng Si 2024-08-07 544 if (!ld)
803fc61df261de Yanteng Si 2024-08-07 545 return -ENOMEM;
803fc61df261de Yanteng Si 2024-08-07 546
30bba69d7db40e Qing Zhang 2021-06-18 547 /* Enable pci device */
30bba69d7db40e Qing Zhang 2021-06-18 548 ret = pci_enable_device(pdev);
30bba69d7db40e Qing Zhang 2021-06-18 549 if (ret) {
30bba69d7db40e Qing Zhang 2021-06-18 550 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
126f4f96c41d2e Yanteng Si 2024-08-07 551 return ret;
30bba69d7db40e Qing Zhang 2021-06-18 552 }
30bba69d7db40e Qing Zhang 2021-06-18 553
126f4f96c41d2e Yanteng Si 2024-08-07 554 pci_set_master(pdev);
126f4f96c41d2e Yanteng Si 2024-08-07 555
30bba69d7db40e Qing Zhang 2021-06-18 556 /* Get the base address of device */
bd83fd598ba34f Philipp Stanner 2025-02-12 557 res.addr = pcim_iomap_region(pdev, 0, DRIVER_NAME);
bd83fd598ba34f Philipp Stanner 2025-02-12 558 ret = PTR_ERR_OR_ZERO(res.addr);
30bba69d7db40e Qing Zhang 2021-06-18 559 if (ret)
fe5b3ce8b4377e Yang Yingliang 2022-11-08 560 goto err_disable_device;
30bba69d7db40e Qing Zhang 2021-06-18 561
803fc61df261de Yanteng Si 2024-08-07 562 plat->bsp_priv = ld;
803fc61df261de Yanteng Si 2024-08-07 563 plat->setup = loongson_dwmac_setup;
56dbe2c290bc58 Yanteng Si 2024-08-07 564 ld->dev = &pdev->dev;
803fc61df261de Yanteng Si 2024-08-07 565 ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff;
803fc61df261de Yanteng Si 2024-08-07 566
0ec04d32b5e7f0 Yanteng Si 2024-08-07 567 info = (struct stmmac_pci_info *)id->driver_data;
126f4f96c41d2e Yanteng Si 2024-08-07 568 ret = info->setup(pdev, plat);
0ec04d32b5e7f0 Yanteng Si 2024-08-07 569 if (ret)
0ec04d32b5e7f0 Yanteng Si 2024-08-07 570 goto err_disable_device;
0ec04d32b5e7f0 Yanteng Si 2024-08-07 571
126f4f96c41d2e Yanteng Si 2024-08-07 572 if (dev_of_node(&pdev->dev))
126f4f96c41d2e Yanteng Si 2024-08-07 573 ret = loongson_dwmac_dt_config(pdev, plat, &res);
126f4f96c41d2e Yanteng Si 2024-08-07 574 else
126f4f96c41d2e Yanteng Si 2024-08-07 575 ret = loongson_dwmac_acpi_config(pdev, plat, &res);
126f4f96c41d2e Yanteng Si 2024-08-07 576 if (ret)
0c979e6b55f99f Yanteng Si 2024-08-07 577 goto err_disable_device;
30bba69d7db40e Qing Zhang 2021-06-18 578
803fc61df261de Yanteng Si 2024-08-07 579 /* Use the common MAC IRQ if per-channel MSIs allocation failed */
803fc61df261de Yanteng Si 2024-08-07 580 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
803fc61df261de Yanteng Si 2024-08-07 581 loongson_dwmac_msi_config(pdev, plat, &res);
803fc61df261de Yanteng Si 2024-08-07 582
f2d45fdf9a0ed2 Yang Yingliang 2022-11-08 583 ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
f2d45fdf9a0ed2 Yang Yingliang 2022-11-08 584 if (ret)
126f4f96c41d2e Yanteng Si 2024-08-07 585 goto err_plat_clear;
f2d45fdf9a0ed2 Yang Yingliang 2022-11-08 586
126f4f96c41d2e Yanteng Si 2024-08-07 587 return 0;
f2d45fdf9a0ed2 Yang Yingliang 2022-11-08 588
126f4f96c41d2e Yanteng Si 2024-08-07 589 err_plat_clear:
126f4f96c41d2e Yanteng Si 2024-08-07 590 if (dev_of_node(&pdev->dev))
126f4f96c41d2e Yanteng Si 2024-08-07 591 loongson_dwmac_dt_clear(pdev, plat);
803fc61df261de Yanteng Si 2024-08-07 592 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
803fc61df261de Yanteng Si 2024-08-07 593 loongson_dwmac_msi_clear(pdev);
fe5b3ce8b4377e Yang Yingliang 2022-11-08 594 err_disable_device:
fe5b3ce8b4377e Yang Yingliang 2022-11-08 595 pci_disable_device(pdev);
f2d45fdf9a0ed2 Yang Yingliang 2022-11-08 596 return ret;
30bba69d7db40e Qing Zhang 2021-06-18 597 }
30bba69d7db40e Qing Zhang 2021-06-18 598 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki