* [PATCH net-next 1/3] stmmac: loongson: Remove surplus loop
2025-03-13 16:14 [PATCH net-next 0/3] Clean up deprecated PCI calls Philipp Stanner
@ 2025-03-13 16:14 ` Philipp Stanner
2025-03-13 22:32 ` Jacob Keller
2025-03-13 16:14 ` [PATCH net-next 2/3] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Philipp Stanner @ 2025-03-13 16:14 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Yanteng Si,
Huacai Chen, Yinggang Gu, Serge Semin, Philipp Stanner
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Philipp Stanner, Andrew Lunn, Huacai Chen, Henry Chen
loongson_dwmac_probe() contains a loop which doesn't have an effect,
because it tries to call pcim_iomap_regions() with the same parameters
several times. The break statement at the loop's end furthermore ensures
that the loop only runs once anyways.
Remove the surplus loop.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Tested-by: Henry Chen <chenx97@aosc.io>
---
.../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 73a6715a93e6..e2959ac5c1ca 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -524,7 +524,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
struct stmmac_pci_info *info;
struct stmmac_resources res;
struct loongson_data *ld;
- int ret, i;
+ int ret;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
@@ -554,14 +554,9 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
pci_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), DRIVER_NAME);
- if (ret)
- goto err_disable_device;
- break;
- }
+ ret = pcim_iomap_regions(pdev, BIT(0), DRIVER_NAME);
+ if (ret)
+ goto err_disable_device;
memset(&res, 0, sizeof(res));
res.addr = pcim_iomap_table(pdev)[0];
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next 1/3] stmmac: loongson: Remove surplus loop
2025-03-13 16:14 ` [PATCH net-next 1/3] stmmac: loongson: Remove surplus loop Philipp Stanner
@ 2025-03-13 22:32 ` Jacob Keller
0 siblings, 0 replies; 8+ messages in thread
From: Jacob Keller @ 2025-03-13 22:32 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Yanteng Si, Huacai Chen, Yinggang Gu, Serge Semin,
Philipp Stanner
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Andrew Lunn,
Huacai Chen, Henry Chen
On 3/13/2025 9:14 AM, Philipp Stanner wrote:
> loongson_dwmac_probe() contains a loop which doesn't have an effect,
> because it tries to call pcim_iomap_regions() with the same parameters
> several times. The break statement at the loop's end furthermore ensures
> that the loop only runs once anyways.
>
> Remove the surplus loop.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> Tested-by: Henry Chen <chenx97@aosc.io>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index 73a6715a93e6..e2959ac5c1ca 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -524,7 +524,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
> struct stmmac_pci_info *info;
> struct stmmac_resources res;
> struct loongson_data *ld;
> - int ret, i;
> + int ret;
>
> plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> if (!plat)
> @@ -554,14 +554,9 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
> pci_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), DRIVER_NAME);
> - if (ret)
> - goto err_disable_device;
> - break;
> - }
This nonsensical code has been here since the beginning of the Loongson
support in commit 30bba69d7db4 ("stmmac: pci: Add dwmac support for
Loongson")
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 2/3] stmmac: Remove pcim_* functions for driver detach
2025-03-13 16:14 [PATCH net-next 0/3] Clean up deprecated PCI calls Philipp Stanner
2025-03-13 16:14 ` [PATCH net-next 1/3] stmmac: loongson: Remove surplus loop Philipp Stanner
@ 2025-03-13 16:14 ` Philipp Stanner
2025-03-13 22:33 ` Jacob Keller
2025-03-13 16:14 ` [PATCH net-next 3/3] stmmac: Replace deprecated PCI functions Philipp Stanner
2025-03-18 17:50 ` [PATCH net-next 0/3] Clean up deprecated PCI calls Simon Horman
3 siblings, 1 reply; 8+ messages in thread
From: Philipp Stanner @ 2025-03-13 16:14 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Yanteng Si,
Huacai Chen, Yinggang Gu, Serge Semin, Philipp Stanner
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Philipp Stanner, Andrew Lunn, Henry Chen
Functions prefixed with "pcim_" are managed devres functions which
perform automatic cleanup once the driver unloads. It is, thus, not
necessary to call any cleanup functions in remove() callbacks.
Remove the pcim_ cleanup function calls in the remove() callbacks.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Tested-by: Henry Chen <chenx97@aosc.io>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 8 --------
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 12 +-----------
2 files changed, 1 insertion(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index e2959ac5c1ca..5d7746d787ac 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -603,7 +603,6 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)
struct net_device *ndev = dev_get_drvdata(&pdev->dev);
struct stmmac_priv *priv = netdev_priv(ndev);
struct loongson_data *ld;
- int i;
ld = priv->plat->bsp_priv;
stmmac_dvr_remove(&pdev->dev);
@@ -614,13 +613,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);
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 352b01678c22..1637c8139b9d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -226,21 +226,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: this function calls the main to free the net resources.
*/
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)
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next 2/3] stmmac: Remove pcim_* functions for driver detach
2025-03-13 16:14 ` [PATCH net-next 2/3] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
@ 2025-03-13 22:33 ` Jacob Keller
0 siblings, 0 replies; 8+ messages in thread
From: Jacob Keller @ 2025-03-13 22:33 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Yanteng Si, Huacai Chen, Yinggang Gu, Serge Semin,
Philipp Stanner
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Andrew Lunn,
Henry Chen
On 3/13/2025 9:14 AM, Philipp Stanner wrote:
> Functions prefixed with "pcim_" are managed devres functions which
> perform automatic cleanup once the driver unloads. It is, thus, not
> necessary to call any cleanup functions in remove() callbacks.
>
> Remove the pcim_ cleanup function calls in the remove() callbacks.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
> Tested-by: Henry Chen <chenx97@aosc.io>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 3/3] stmmac: Replace deprecated PCI functions
2025-03-13 16:14 [PATCH net-next 0/3] Clean up deprecated PCI calls Philipp Stanner
2025-03-13 16:14 ` [PATCH net-next 1/3] stmmac: loongson: Remove surplus loop Philipp Stanner
2025-03-13 16:14 ` [PATCH net-next 2/3] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
@ 2025-03-13 16:14 ` Philipp Stanner
2025-03-13 22:34 ` Jacob Keller
2025-03-18 17:50 ` [PATCH net-next 0/3] Clean up deprecated PCI calls Simon Horman
3 siblings, 1 reply; 8+ messages in thread
From: Philipp Stanner @ 2025-03-13 16:14 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Yanteng Si,
Huacai Chen, Yinggang Gu, Serge Semin, Philipp Stanner
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Andrew Lunn,
Huacai Chen, Henry Chen
From: Philipp Stanner <pstanner@redhat.com>
The PCI functions
- pcim_iomap_regions() and
- pcim_iomap_table()
have been deprecated.
Replace them with their successor function, pcim_iomap_region().
Make variable declaration order at closeby places comply with reverse
christmas tree order.
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Tested-by: Henry Chen <chenx97@aosc.io>
---
.../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 8 +++-----
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++--------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 5d7746d787ac..25ef7b9c5dce 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -521,8 +521,8 @@ static int loongson_dwmac_acpi_config(struct pci_dev *pdev,
static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct plat_stmmacenet_data *plat;
+ struct stmmac_resources res = {};
struct stmmac_pci_info *info;
- struct stmmac_resources res;
struct loongson_data *ld;
int ret;
@@ -554,13 +554,11 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
pci_set_master(pdev);
/* Get the base address of device */
- ret = pcim_iomap_regions(pdev, BIT(0), DRIVER_NAME);
+ res.addr = pcim_iomap_region(pdev, 0, DRIVER_NAME);
+ ret = PTR_ERR_OR_ZERO(res.addr);
if (ret)
goto err_disable_device;
- memset(&res, 0, sizeof(res));
- res.addr = pcim_iomap_table(pdev)[0];
-
plat->bsp_priv = ld;
plat->setup = loongson_dwmac_setup;
ld->dev = &pdev->dev;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 1637c8139b9d..b7adda35b7b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -155,9 +155,9 @@ 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;
- int i;
+ struct stmmac_resources res = {};
int ret;
+ int i;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
@@ -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;
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next 3/3] stmmac: Replace deprecated PCI functions
2025-03-13 16:14 ` [PATCH net-next 3/3] stmmac: Replace deprecated PCI functions Philipp Stanner
@ 2025-03-13 22:34 ` Jacob Keller
0 siblings, 0 replies; 8+ messages in thread
From: Jacob Keller @ 2025-03-13 22:34 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Yanteng Si, Huacai Chen, Yinggang Gu, Serge Semin,
Philipp Stanner
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Andrew Lunn,
Huacai Chen, Henry Chen
On 3/13/2025 9:14 AM, Philipp Stanner wrote:
> From: Philipp Stanner <pstanner@redhat.com>
>
> The PCI functions
> - pcim_iomap_regions() and
> - pcim_iomap_table()
> have been deprecated.
>
> Replace them with their successor function, pcim_iomap_region().
>
> Make variable declaration order at closeby places comply with reverse
> christmas tree order.
>
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> Tested-by: Henry Chen <chenx97@aosc.io>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/3] Clean up deprecated PCI calls
2025-03-13 16:14 [PATCH net-next 0/3] Clean up deprecated PCI calls Philipp Stanner
` (2 preceding siblings ...)
2025-03-13 16:14 ` [PATCH net-next 3/3] stmmac: Replace deprecated PCI functions Philipp Stanner
@ 2025-03-18 17:50 ` Simon Horman
3 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2025-03-18 17:50 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Yanteng Si,
Huacai Chen, Yinggang Gu, Serge Semin, Philipp Stanner, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
On Thu, Mar 13, 2025 at 05:14:20PM +0100, Philipp Stanner wrote:
> Spiritual successor of this older series, of which one patch has already
> been merged [1]
>
> P.
>
> [1] https://lore.kernel.org/netdev/20250226085208.97891-1-phasta@kernel.org/
>
> Philipp Stanner (3):
> stmmac: loongson: Remove surplus loop
> stmmac: Remove pcim_* functions for driver detach
> stmmac: Replace deprecated PCI functions
Hi Philipp,
Unfortunately this series did not apply cleanly to net-next when the CI ran.
Please rebase and repost, including Jacob's tags.
--
pw-bot: changes-requested
^ permalink raw reply [flat|nested] 8+ messages in thread