Re: [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver
From: Xin Tian
Date: Sat Dec 05 2026 - 21:57:08 EST
On 11/27/2026 11:57 PM, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 3
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] In xsc_pci_init(), BAR0 is mapped with pci_ioremap_bar(),
> which is a plain ioremap() of pdev->resource[0], but it is unmapped…
> - [Low] The subject line is cut short.
> - [Low] The new MAINTAINERS entry 'YUNSILICON XSC DRIVERS' has only 'F:
> drivers/net/ethernet/yunsilicon/xsc'.
> - [Low] xsc_pci_driver.name is "xsc-pci".
>
> --
>
> net/xsc: add Yunsilicon XSC ethernet PCI driver
>
> This commit adds the Yunsilicon vendor Kconfig/Makefile glue and a
> skeleton PCI driver for XSC ethernet devices. The PCI core enables the
> device, requests and maps BAR0, and sets the DMA masks. The doorbell,
> command queue and netdev layers come in later patches.
>
>> net/xsc: add Yunsilicon XSC ethernet PCI driver
>>
>> skeleton
> [Severity: Low]
> This isn't a bug, but the subject line seems to have been split. The word
> "skeleton" is now the first line of the body.
>
> As a result the shortlog reads "net/xsc: add Yunsilicon XSC ethernet PCI
> driver". The commit only adds a PCI skeleton with no netdev. Could
> "skeleton" go back into the subject line?
The subject is a single line in git, our SMTP relay folded it on the way
out. Fixed on that side.
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index bde216003f428..1cd2a0a6477c7 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -30909,6 +30909,13 @@ S: Maintained
>> F: Documentation/input/devices/yealink.rst
>> F: drivers/input/misc/yealink.*
>>
>> +YUNSILICON XSC DRIVERS
>> +M: Honggang Wei <weihg@xxxxxxxxxxxxxx>
>> +M: Xin Tian <tianx@xxxxxxxxxxxxxx>
>> +L: netdev@xxxxxxxxxxxxxxx
>> +S: Maintained
>> +F: drivers/net/ethernet/yunsilicon/xsc
> [Severity: Low]
> This isn't a bug, but should this F: entry be
> drivers/net/ethernet/yunsilicon/ with a trailing slash?
>
> As written it does not cover the vendor-level files this patch adds,
> drivers/net/ethernet/yunsilicon/Kconfig and
> drivers/net/ethernet/yunsilicon/Makefile. Changes to those files would not
> be sent to the listed maintainers.
>
> The new line in drivers/net/ethernet/Makefile is also out of order:
>
> obj-$(CONFIG_NET_VENDOR_XILINX) += xilinx/
> obj-$(CONFIG_NET_VENDOR_YUNSILICON) += yunsilicon/
> obj-$(CONFIG_NET_VENDOR_XIRCOM) += xircom/
>
> In drivers/net/ethernet/Kconfig the matching source line comes after
> xircom. Both issues are still present at the end of the series.
>
>> +
>> ZD1211RW WIRELESS DRIVER
>> L: linux-wireless@xxxxxxxxxxxxxxx
>> S: Orphan
Fixed both. F: now points at drivers/net/ethernet/yunsilicon/ so the
vendor Kconfig/Makefile are covered, and the obj- line moved to match the
Kconfig order.
> [ ... ]
>
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/main.c b/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
>> new file mode 100644
>> index 0000000000000..c926507a74b04
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
> [ ... ]
>
>> + bar_base = pci_ioremap_bar(pdev, bar_num);
>> + if (!bar_base) {
>> + pci_err(pdev, "failed to ioremap %s bar%d\n", KBUILD_MODNAME,
>> + bar_num);
>> + err = -ENOMEM;
>> + goto err_clr_master;
>> + }
>> +
>> + err = pci_save_state(pdev);
>> + if (err) {
>> + pci_err(pdev, "pci_save_state failed: err=%d\n", err);
>> + goto err_io_unmap;
>> + }
>> +
>> + xdev->bar_num = bar_num;
>> + xdev->bar = bar_base;
>> +
>> + return 0;
>> +
>> +err_io_unmap:
>> + pci_iounmap(pdev, bar_base);
> [Severity: Medium]
> Is pci_iounmap() the right call to undo pci_ioremap_bar()? It pairs with
> pci_iomap(), while pci_ioremap_bar() is a plain ioremap(). xsc_pci_fini()
> uses the same pairing on remove.
>
> On s390 zPCI without MIO, the two calls are not symmetric.
> zpci_map_resources() stores a cookie from pci_iomap_range_fh() in
> resource[0].start, and that call takes the only reference.
> pci_ioremap_bar() returns that cookie without taking a reference:
>
> arch/s390/pci/pci.c:ioremap_prot() {
> ...
> if (!static_branch_unlikely(&have_mio))
> return (void __iomem *)phys_addr;
> ...
> }
>
> pci_iounmap() then calls pci_iounmap_fh(), which drops the reference that
> zpci_map_resources() holds:
>
> arch/s390/pci/pci.c:pci_iounmap_fh() {
> ...
> WARN_ON(!zpci_iomap_start[idx].count);
> if (!--zpci_iomap_start[idx].count) {
> zpci_iomap_start[idx].fh = 0;
> zpci_iomap_start[idx].bar = 0;
> }
> ...
> }
>
> After one unbind, or one probe failure that reaches err_io_unmap, would
> the next probe get a cookie whose fh is 0? Then every BAR0 readl()/writel()
> would go to the wrong function handle.
>
> When the device is finally removed, zpci_unmap_resources() calls
> pci_iounmap_fh() again. That would trigger WARN_ON(!count) and underflow
> the counter.
>
> Later patches in the series add more ways to reach err_io_unmap, such as
> xsc_cmd_init() failing.
>
> Could this pair pci_ioremap_bar() with iounmap() instead? Another option is
> to use pci_iomap()/pci_iounmap() or pcim_iomap_region().
>
>> +err_clr_master:
>> + pci_clear_master(pdev);
>> + pci_release_region(pdev, bar_num);
>> +err_disable:
>> + pci_disable_device(pdev);
>> +err_out:
>> + return err;
>> +}
>> +
>> +static void xsc_pci_fini(struct xsc_core_device *xdev)
>> +{
>> + struct pci_dev *pdev = xdev->pdev;
>> +
>> + pci_iounmap(pdev, xdev->bar);
>> + pci_clear_master(pdev);
>> + pci_release_region(pdev, xdev->bar_num);
>> + pci_disable_device(pdev);
>> +}
Fixed, wrong pairing. Both the init error path and fini now use iounmap()
to match the pci_ioremap_bar().
> [ ... ]
>
>> +static struct pci_driver xsc_pci_driver = {
>> + .name = "xsc-pci",
> [Severity: Low]
> This isn't a bug, but the driver name here is "xsc-pci". The module is
> called xsc_pci per the Kconfig help and the Makefile, and
> pci_request_region() in xsc_pci_init() claims BAR0 under KBUILD_MODNAME
> ("xsc_pci").
>
> So /sys/bus/pci/drivers/xsc-pci and the owner shown in /proc/iomem would
> have different names. Later in the series xsc_core.h defines
> XSC_PCI_DRV_NAME as "xsc_pci", but .name still uses the hyphenated string.
>
> Would .name = KBUILD_MODNAME be more consistent?
>
>> + .id_table = xsc_pci_id_table,
>> + .probe = xsc_pci_probe,
>> + .remove = xsc_pci_remove,
>> +};
Changed to KBUILD_MODNAME so the driver name, module name and the
request_region owner all match. Auxiliary matching is unaffected: the
device name comes from the auxiliary_device_add() macro, which builds it
from the module name (KBUILD_MODNAME, fixed by the Makefile object name)
plus the adev name ("eth"); struct pci_driver.name is never consulted.
pw-bot: cr