]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: libwx: fix VF illegal register access
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 29 Apr 2026 08:37:42 +0000 (16:37 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 1 May 2026 01:07:21 +0000 (18:07 -0700)
Register WX_CFG_PORT_ST is a PF restricted register. When a VF is
initialized, attempting to read this register triggers an illegal
register access, which lead to a system hang.

When the device is VF, the bus function ID can be obtained directly from
the PCI_FUNC(pdev->devfn).

Fixes: a04ea57aae37 ("net: libwx: fix device bus LAN ID")
Cc: stable@vger.kernel.org
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Link: https://patch.msgid.link/4D1F4452D21DE107+20260429083743.88961-1-jiawenwu@trustnetic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/wangxun/libwx/wx_hw.c

index d3772d01e00bc8de21e18c79acd85ef41e42d234..2451f6b20b111594b87c5ca56df7a01a7ba3a8b3 100644 (file)
@@ -2480,8 +2480,11 @@ int wx_sw_init(struct wx *wx)
        wx->oem_svid = pdev->subsystem_vendor;
        wx->oem_ssid = pdev->subsystem_device;
        wx->bus.device = PCI_SLOT(pdev->devfn);
-       wx->bus.func = FIELD_GET(WX_CFG_PORT_ST_LANID,
-                                rd32(wx, WX_CFG_PORT_ST));
+       if (pdev->is_virtfn)
+               wx->bus.func = PCI_FUNC(pdev->devfn);
+       else
+               wx->bus.func = FIELD_GET(WX_CFG_PORT_ST_LANID,
+                                        rd32(wx, WX_CFG_PORT_ST));
 
        if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN ||
            pdev->is_virtfn) {