* [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements
@ 2025-02-24 13:53 Philipp Stanner
2025-02-24 13:53 ` [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function Philipp Stanner
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Philipp Stanner @ 2025-02-24 13:53 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Philipp Stanner
Changes in v3:
- Several formatting nits (Paolo)
- Split up patch into a patch series (Yanteng)
Philipp Stanner (4):
stmmac: loongson: Pass correct arg to PCI function
stmmac: loongson: Remove surplus loop
stmmac: Remove pcim_* functions for driver detach
stmmac: Replace deprecated PCI functions
.../ethernet/stmicro/stmmac/dwmac-loongson.c | 31 ++++++-------------
.../net/ethernet/stmicro/stmmac/stmmac_pci.c | 24 ++++----------
2 files changed, 15 insertions(+), 40 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function
2025-02-24 13:53 [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Philipp Stanner
@ 2025-02-24 13:53 ` Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
2025-02-25 9:00 ` Yanteng Si
2025-02-24 13:53 ` [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop Philipp Stanner
` (3 subsequent siblings)
4 siblings, 2 replies; 20+ messages in thread
From: Philipp Stanner @ 2025-02-24 13:53 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Philipp Stanner, stable
pcim_iomap_regions() should receive the driver's name as its third
parameter, not the PCI device's name.
Define the driver name with a macro and use it at the appropriate
places, including pcim_iomap_regions().
Cc: stable@vger.kernel.org # v5.14+
Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index bfe6e2d631bd..73a6715a93e6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -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 */
@@ -555,7 +557,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
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));
+ ret = pcim_iomap_regions(pdev, BIT(0), DRIVER_NAME);
if (ret)
goto err_disable_device;
break;
@@ -673,7 +675,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,
--
2.48.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop
2025-02-24 13:53 [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Philipp Stanner
2025-02-24 13:53 ` [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function Philipp Stanner
@ 2025-02-24 13:53 ` Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
` (2 more replies)
2025-02-24 13:53 ` [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
` (2 subsequent siblings)
4 siblings, 3 replies; 20+ messages in thread
From: Philipp Stanner @ 2025-02-24 13:53 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Philipp Stanner
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>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 73a6715a93e6..e3cacd085b3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -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] 20+ messages in thread
* [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
2025-02-24 13:53 [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Philipp Stanner
2025-02-24 13:53 ` [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function Philipp Stanner
2025-02-24 13:53 ` [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop Philipp Stanner
@ 2025-02-24 13:53 ` Philipp Stanner
2025-02-24 19:56 ` Andrew Lunn
2025-02-25 9:10 ` Yanteng Si
2025-02-24 13:53 ` [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions Philipp Stanner
2025-02-25 8:42 ` [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Henry Chen
4 siblings, 2 replies; 20+ messages in thread
From: Philipp Stanner @ 2025-02-24 13:53 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Philipp Stanner
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>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 7 -------
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ----------
2 files changed, 17 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index e3cacd085b3f..f3ea6016be68 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -614,13 +614,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..91ff6c15f977 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -227,20 +227,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
*
* @pdev: platform device pointer
* Description: this function calls the main to free the net resources
- * and releases the PCI 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] 20+ messages in thread
* [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions
2025-02-24 13:53 [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Philipp Stanner
` (2 preceding siblings ...)
2025-02-24 13:53 ` [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
@ 2025-02-24 13:53 ` Philipp Stanner
2025-02-24 19:57 ` Andrew Lunn
` (2 more replies)
2025-02-25 8:42 ` [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Henry Chen
4 siblings, 3 replies; 20+ messages in thread
From: Philipp Stanner @ 2025-02-24 13:53 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
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>
---
.../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++-------
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++--------
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index f3ea6016be68..25ef7b9c5dce 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -521,10 +521,10 @@ 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, i;
+ int ret;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
@@ -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;
@@ -603,7 +601,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);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 91ff6c15f977..37fc7f55a7e4 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] 20+ messages in thread
* Re: [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function
2025-02-24 13:53 ` [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function Philipp Stanner
@ 2025-02-24 19:55 ` Andrew Lunn
2025-02-25 9:00 ` Yanteng Si
1 sibling, 0 replies; 20+ messages in thread
From: Andrew Lunn @ 2025-02-24 19:55 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, stable
On Mon, Feb 24, 2025 at 02:53:19PM +0100, Philipp Stanner wrote:
> pcim_iomap_regions() should receive the driver's name as its third
> parameter, not the PCI device's name.
>
> Define the driver name with a macro and use it at the appropriate
> places, including pcim_iomap_regions().
>
> Cc: stable@vger.kernel.org # v5.14+
> Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop
2025-02-24 13:53 ` [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop Philipp Stanner
@ 2025-02-24 19:55 ` Andrew Lunn
2025-02-25 9:06 ` Yanteng Si
2025-02-25 9:29 ` Huacai Chen
2 siblings, 0 replies; 20+ messages in thread
From: Andrew Lunn @ 2025-02-24 19:55 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang, netdev, linux-stm32, linux-arm-kernel,
linux-kernel
On Mon, Feb 24, 2025 at 02:53:20PM +0100, 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>
Andrew
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
2025-02-24 13:53 ` [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
@ 2025-02-24 19:56 ` Andrew Lunn
2025-02-25 9:10 ` Yanteng Si
1 sibling, 0 replies; 20+ messages in thread
From: Andrew Lunn @ 2025-02-24 19:56 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang, netdev, linux-stm32, linux-arm-kernel,
linux-kernel
On Mon, Feb 24, 2025 at 02:53:21PM +0100, 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>
Andrew
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions
2025-02-24 13:53 ` [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions Philipp Stanner
@ 2025-02-24 19:57 ` Andrew Lunn
2025-02-25 7:16 ` Philipp Stanner
2025-02-25 9:30 ` Huacai Chen
2 siblings, 0 replies; 20+ messages in thread
From: Andrew Lunn @ 2025-02-24 19:57 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Huacai Chen,
Yanteng Si, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang, netdev, linux-stm32, linux-arm-kernel,
linux-kernel
On Mon, Feb 24, 2025 at 02:53:22PM +0100, 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>
Andrew
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions
2025-02-24 13:53 ` [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions Philipp Stanner
2025-02-24 19:57 ` Andrew Lunn
@ 2025-02-25 7:16 ` Philipp Stanner
2025-02-25 9:14 ` Yanteng Si
2025-02-25 9:30 ` Huacai Chen
2 siblings, 1 reply; 20+ messages in thread
From: Philipp Stanner @ 2025-02-25 7:16 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Huacai Chen, Yanteng Si, Yinggang Gu, Feiyang Chen, Jiaxun Yang,
Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Mon, 2025-02-24 at 14:53 +0100, 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>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++-------
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++------
> --
> 2 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index f3ea6016be68..25ef7b9c5dce 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -521,10 +521,10 @@ 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, i;
> + int ret;
>
> plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> if (!plat)
> @@ -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;
> @@ -603,7 +601,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;
Just saw that this is a left-over that actually should be in patch 3.
Will fix.
P.
>
> ld = priv->plat->bsp_priv;
> stmmac_dvr_remove(&pdev->dev);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> index 91ff6c15f977..37fc7f55a7e4 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;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements
2025-02-24 13:53 [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Philipp Stanner
` (3 preceding siblings ...)
2025-02-24 13:53 ` [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions Philipp Stanner
@ 2025-02-25 8:42 ` Henry Chen
4 siblings, 0 replies; 20+ messages in thread
From: Henry Chen @ 2025-02-25 8:42 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Huacai Chen, Yanteng Si, Yinggang Gu, Feiyang Chen,
Philipp Stanner, Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Kexy Biscuit,
Mingcong Bai
On 2/24/25 21:53, Philipp Stanner wrote:
> Changes in v3:
> - Several formatting nits (Paolo)
> - Split up patch into a patch series (Yanteng)
>
> Philipp Stanner (4):
> stmmac: loongson: Pass correct arg to PCI function
> stmmac: loongson: Remove surplus loop
> stmmac: Remove pcim_* functions for driver detach
> stmmac: Replace deprecated PCI functions
>
> .../ethernet/stmicro/stmmac/dwmac-loongson.c | 31 ++++++-------------
> .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 24 ++++----------
> 2 files changed, 15 insertions(+), 40 deletions(-)
>
I have tested This patch series on my Loongson-3A5000-HV-7A2000-1w-V0.1-
EVB. The onboard STMMAC ethernet works as expected.
Tested-by: Henry Chen <chenx97@aosc.io>
Henry
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function
2025-02-24 13:53 ` [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
@ 2025-02-25 9:00 ` Yanteng Si
1 sibling, 0 replies; 20+ messages in thread
From: Yanteng Si @ 2025-02-25 9:00 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Huacai Chen, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, stable
在 2/24/25 9:53 PM, Philipp Stanner 写道:
> pcim_iomap_regions() should receive the driver's name as its third
> parameter, not the PCI device's name.
>
> Define the driver name with a macro and use it at the appropriate
> places, including pcim_iomap_regions().
>
> Cc: stable@vger.kernel.org # v5.14+
> Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Thanks,
Yanteng
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index bfe6e2d631bd..73a6715a93e6 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -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 */
> @@ -555,7 +557,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
> 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));
> + ret = pcim_iomap_regions(pdev, BIT(0), DRIVER_NAME);
> if (ret)
> goto err_disable_device;
> break;
> @@ -673,7 +675,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,
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop
2025-02-24 13:53 ` [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
@ 2025-02-25 9:06 ` Yanteng Si
2025-02-25 9:15 ` Philipp Stanner
2025-02-25 9:29 ` Huacai Chen
2 siblings, 1 reply; 20+ messages in thread
From: Yanteng Si @ 2025-02-25 9:06 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Huacai Chen, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
在 2/24/25 9:53 PM, Philipp Stanner 写道:
> 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>
It seems that the fix-tag has been forgotten, next two patches as well.
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Thanks,
Yanteng
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index 73a6715a93e6..e3cacd085b3f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -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];
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
2025-02-24 13:53 ` [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
2025-02-24 19:56 ` Andrew Lunn
@ 2025-02-25 9:10 ` Yanteng Si
2025-02-25 9:19 ` Huacai Chen
1 sibling, 1 reply; 20+ messages in thread
From: Yanteng Si @ 2025-02-25 9:10 UTC (permalink / raw)
To: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Huacai Chen, Yinggang Gu, Feiyang Chen, Philipp Stanner,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
在 2/24/25 9:53 PM, Philipp Stanner 写道:
> 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>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 7 -------
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ----------
> 2 files changed, 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index e3cacd085b3f..f3ea6016be68 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -614,13 +614,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..91ff6c15f977 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> @@ -227,20 +227,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
> *
> * @pdev: platform device pointer
> * Description: this function calls the main to free the net resources
There is a missing full stop. You commented on the next email,
and it seems that you are already preparing for v4. With this
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Thanks,
Yanteng
> - * and releases the PCI 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)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions
2025-02-25 7:16 ` Philipp Stanner
@ 2025-02-25 9:14 ` Yanteng Si
0 siblings, 0 replies; 20+ messages in thread
From: Yanteng Si @ 2025-02-25 9:14 UTC (permalink / raw)
To: Philipp Stanner, Philipp Stanner, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Huacai Chen, Yinggang Gu, Feiyang Chen,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
在 2/25/25 3:16 PM, Philipp Stanner 写道:
> On Mon, 2025-02-24 at 14:53 +0100, 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>
>> ---
>> .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++-------
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++------
>> --
>> 2 files changed, 10 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>> index f3ea6016be68..25ef7b9c5dce 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>> @@ -521,10 +521,10 @@ 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, i;
>> + int ret;
>>
>> plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
>> if (!plat)
>> @@ -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;
>> @@ -603,7 +601,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;
> Just saw that this is a left-over that actually should be in patch 3.
> Will fix.
>
Yeah, with this
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Thanks,
Yanteng
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop
2025-02-25 9:06 ` Yanteng Si
@ 2025-02-25 9:15 ` Philipp Stanner
2025-02-26 1:57 ` Yanteng Si
0 siblings, 1 reply; 20+ messages in thread
From: Philipp Stanner @ 2025-02-25 9:15 UTC (permalink / raw)
To: Yanteng Si, Philipp Stanner, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Huacai Chen, Yinggang Gu, Feiyang Chen,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Tue, 2025-02-25 at 17:06 +0800, Yanteng Si wrote:
>
> 在 2/24/25 9:53 PM, Philipp Stanner 写道:
> > 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>
>
> It seems that the fix-tag has been forgotten, next two patches as
> well.
Not forgotten, I just think that patches 2-4 are code improvements, not
bug fixes.
The issue in patch 1 would cause actual misbehavior (a useless debug
information print in case of a resource collision), whereas 2-4 are
just ugly code, but not actual bugs: the loop always just runs once;
and unmapping the PCI resources manually is valid, but obviously
unnecessary.
Agreed?
P.
>
>
> Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
>
> Thanks,
> Yanteng
>
> > ---
> > drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 +++----
> > ----
> > 1 file changed, 3 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > index 73a6715a93e6..e3cacd085b3f 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > @@ -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];
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
2025-02-25 9:10 ` Yanteng Si
@ 2025-02-25 9:19 ` Huacai Chen
0 siblings, 0 replies; 20+ messages in thread
From: Huacai Chen @ 2025-02-25 9:19 UTC (permalink / raw)
To: Yanteng Si
Cc: Philipp Stanner, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Yinggang Gu, Feiyang Chen, Philipp Stanner, Jiaxun Yang,
Qing Zhang, netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Tue, Feb 25, 2025 at 5:11 PM Yanteng Si <si.yanteng@linux.dev> wrote:
>
>
> 在 2/24/25 9:53 PM, Philipp Stanner 写道:
> > 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>
> > ---
> > drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 7 -------
> > drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ----------
> > 2 files changed, 17 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > index e3cacd085b3f..f3ea6016be68 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > @@ -614,13 +614,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..91ff6c15f977 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > @@ -227,20 +227,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
> > *
> > * @pdev: platform device pointer
>
> > * Description: this function calls the main to free the net resources
>
> There is a missing full stop. You commented on the next email,
>
> and it seems that you are already preparing for v4. With this
>
>
> Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>
> Thanks,
> Yanteng
>
> > - * and releases the PCI 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)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop
2025-02-24 13:53 ` [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
2025-02-25 9:06 ` Yanteng Si
@ 2025-02-25 9:29 ` Huacai Chen
2 siblings, 0 replies; 20+ messages in thread
From: Huacai Chen @ 2025-02-25 9:29 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Yanteng Si,
Yinggang Gu, Feiyang Chen, Philipp Stanner, Jiaxun Yang,
Qing Zhang, netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Mon, Feb 24, 2025 at 9:53 PM Philipp Stanner <phasta@kernel.org> 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: Huacai Chen <chenhuacai@loongson.cn>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index 73a6715a93e6..e3cacd085b3f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -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 [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions
2025-02-24 13:53 ` [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions Philipp Stanner
2025-02-24 19:57 ` Andrew Lunn
2025-02-25 7:16 ` Philipp Stanner
@ 2025-02-25 9:30 ` Huacai Chen
2 siblings, 0 replies; 20+ messages in thread
From: Huacai Chen @ 2025-02-25 9:30 UTC (permalink / raw)
To: Philipp Stanner
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Yanteng Si,
Yinggang Gu, Feiyang Chen, Philipp Stanner, Jiaxun Yang,
Qing Zhang, netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Mon, Feb 24, 2025 at 9:53 PM Philipp Stanner <phasta@kernel.org> 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: Huacai Chen <chenhuacai@loongson.cn>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++-------
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++--------
> 2 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index f3ea6016be68..25ef7b9c5dce 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -521,10 +521,10 @@ 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, i;
> + int ret;
>
> plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> if (!plat)
> @@ -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;
> @@ -603,7 +601,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);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> index 91ff6c15f977..37fc7f55a7e4 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 [flat|nested] 20+ messages in thread
* Re: [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop
2025-02-25 9:15 ` Philipp Stanner
@ 2025-02-26 1:57 ` Yanteng Si
0 siblings, 0 replies; 20+ messages in thread
From: Yanteng Si @ 2025-02-26 1:57 UTC (permalink / raw)
To: Philipp Stanner, Philipp Stanner, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Huacai Chen, Yinggang Gu, Feiyang Chen,
Jiaxun Yang, Qing Zhang
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
在 2/25/25 5:15 PM, Philipp Stanner 写道:
> On Tue, 2025-02-25 at 17:06 +0800, Yanteng Si wrote:
>> 在 2/24/25 9:53 PM, Philipp Stanner 写道:
>>> 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>
>> It seems that the fix-tag has been forgotten, next two patches as
>> well.
> Not forgotten, I just think that patches 2-4 are code improvements, not
> bug fixes.
>
> The issue in patch 1 would cause actual misbehavior (a useless debug
> information print in case of a resource collision), whereas 2-4 are
> just ugly code, but not actual bugs: the loop always just runs once;
> and unmapping the PCI resources manually is valid, but obviously
> unnecessary.
>
> Agreed?
You bet!
Thanks,
Yanteng
>
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2025-02-26 1:57 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 13:53 [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Philipp Stanner
2025-02-24 13:53 ` [PATCH net-next v3 1/4] stmmac: loongson: Pass correct arg to PCI function Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
2025-02-25 9:00 ` Yanteng Si
2025-02-24 13:53 ` [PATCH net-next v3 2/4] stmmac: loongson: Remove surplus loop Philipp Stanner
2025-02-24 19:55 ` Andrew Lunn
2025-02-25 9:06 ` Yanteng Si
2025-02-25 9:15 ` Philipp Stanner
2025-02-26 1:57 ` Yanteng Si
2025-02-25 9:29 ` Huacai Chen
2025-02-24 13:53 ` [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach Philipp Stanner
2025-02-24 19:56 ` Andrew Lunn
2025-02-25 9:10 ` Yanteng Si
2025-02-25 9:19 ` Huacai Chen
2025-02-24 13:53 ` [PATCH net-next v3 4/4] stmmac: Replace deprecated PCI functions Philipp Stanner
2025-02-24 19:57 ` Andrew Lunn
2025-02-25 7:16 ` Philipp Stanner
2025-02-25 9:14 ` Yanteng Si
2025-02-25 9:30 ` Huacai Chen
2025-02-25 8:42 ` [PATCH net-next v3 0/4] stmmac: Several PCI-related improvements Henry Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).