From: Yanteng Si <si.yanteng@linux.dev>
To: Philipp Stanner <phasta@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Huacai Chen <chenhuacai@kernel.org>,
Yinggang Gu <guyinggang@loongson.cn>,
Feiyang Chen <chenfeiyang@loongson.cn>,
Qunqin Zhao <zhaoqunqin@loongson.cn>,
Huacai Chen <chenhuacai@loongson.cn>
Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Philipp Stanner <pstanner@redhat.com>
Subject: Re: [PATCH v2] stmmac: Replace deprecated PCI functions
Date: Fri, 21 Feb 2025 10:01:50 +0800 [thread overview]
Message-ID: <a4e790d1-b849-415f-b2f9-66cf162204e2@linux.dev> (raw)
In-Reply-To: <20250218132120.124038-2-phasta@kernel.org>
在 2/18/25 9:21 PM, Philipp Stanner 写道:
> From: Philipp Stanner <pstanner@redhat.com>
>
> 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.
>
> Furthermore, loongson_dwmac_probe() contains a surplus loop. That loop
> does not use index i in pcim_iomap_regions(), but costantly attempts to
> request and ioremap BAR 0. This would actually fail (since you cannot
> request the same BAR more than once), but presumably never fails because
> the preceding length check detects that all BARs except for 0 do not
> exist.
> Replace them with pcim_iomap_region(). Remove the surplus loop.
So, two things are done in one patch. How about splitting it into two
patches?
>
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>
> ---
> Changes in v2:
> - Fix build errors because of missing ';'
> - Address in the commit message why the patch removes a loop. (Andrew)
> ---
> .../ethernet/stmicro/stmmac/dwmac-loongson.c | 31 ++++++-------------
> .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 24 ++++----------
> 2 files changed, 15 insertions(+), 40 deletions(-)
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index bfe6e2d631bd..6f7c479c1a51 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"
This appears to have nothing to do with the commit message.
I believe it would be better if it were split off and made into
an independent patch.
> +
> /* Normal Loongson Tx Summary */
> #define DMA_INTR_ENA_NIE_TX_LOONGSON 0x00040000
> /* Normal Loongson Rx Summary */
> @@ -520,9 +522,9 @@ 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;
> + int ret;
>
> plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
> if (!plat)
> @@ -552,17 +554,10 @@ 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), 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;
According to the description in the commit message, the reason for
remove the surplus loop here is to fix the problem of requesting
the same BAR multiple times, that's good.
> @@ -606,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);
> @@ -617,13 +611,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);
> }
According to the commit message, the reason for removing the surplus
loop here is that there's no need to use the pcim_* cleanup functions in
the `remove()` function. This is different from the modifications in the
`probe()` function. I think it can be split out and made into a separate
patch.
How about splitting it like this?
Patch 1/3: Use the `DRIVER_NAME` macro.
Patch 2/3: remove the surplus loop to fix the problem of requesting the
same BAR multiple times
Patch 3/3: remove the surplus pcim_* cleanup functions in the `remove()`
function
Huacai, Qunqin, Would you mind helping to test it?
Thanks,
Yanteng
prev parent reply other threads:[~2025-02-21 2:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 13:21 [PATCH v2] stmmac: Replace deprecated PCI functions Philipp Stanner
2025-02-18 16:13 ` Andrew Lunn
2025-02-20 8:59 ` Paolo Abeni
2025-02-21 2:01 ` Yanteng Si [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4e790d1-b849-415f-b2f9-66cf162204e2@linux.dev \
--to=si.yanteng@linux.dev \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=chenfeiyang@loongson.cn \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=guyinggang@loongson.cn \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=phasta@kernel.org \
--cc=pstanner@redhat.com \
--cc=zhaoqunqin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.