[PATCH v1] rtl_pci: add support for Realtek management device

javen posted 1 patch 1 month, 1 week ago
There is a newer version of this series
drivers/misc/Kconfig   | 12 +++++++
drivers/misc/Makefile  |  1 +
drivers/misc/rtl_pci.c | 78 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+)
create mode 100644 drivers/misc/rtl_pci.c
[PATCH v1] rtl_pci: add support for Realtek management device
Posted by javen 1 month, 1 week ago
From: Javen Xu <javen_xu@realsil.com.cn>

This is not the standard ethernet driver. It specially handles the
management function.

I tried to submitted to linux/net-next before, but they said these class
didn't belong there. So I came here, and I'm wondering if these unknown
classes used for management functions should be submitted here.

Thanks,
Javen Xu

Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
---
 drivers/misc/Kconfig   | 12 +++++++
 drivers/misc/Makefile  |  1 +
 drivers/misc/rtl_pci.c | 78 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 drivers/misc/rtl_pci.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 5cc79d1517af..e3c572bd1e34 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -643,6 +643,18 @@ config MCHP_LAN966X_PCI
 	    - lan966x-miim (MDIO_MSCC_MIIM)
 	    - lan966x-switch (LAN966X_SWITCH)
 
+config RTL_PCI
+	tristate "Realtek Management Interface Support"
+	depends on PCI
+	help
+	  This enables support for the Realtek nic PCIe Management device.
+
+	  Please note that this is NOT the standard Ethernet driver for network
+	  traffic. It specifically handles the management function.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called rtl_pci.o.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b32a2597d246..b937a25707c8 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -75,3 +75,4 @@ obj-$(CONFIG_MCHP_LAN966X_PCI)	+= lan966x-pci.o
 obj-y				+= keba/
 obj-y				+= amd-sbi/
 obj-$(CONFIG_MISC_RP1)		+= rp1/
+obj-$(CONFIG_RTL_PCI)		+= rtl_pci.o
diff --git a/drivers/misc/rtl_pci.c b/drivers/misc/rtl_pci.c
new file mode 100644
index 000000000000..148acb192b33
--- /dev/null
+++ b/drivers/misc/rtl_pci.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  This module handles PCI endpoint functions exposed by Realtek
+ *  management controllers (e.g. RTL8111x series). It manages device
+ *  probing for virtual devices.
+ *
+ *  Copyright(c) 2026 Realtek Semiconductor Corp.
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+#define PCI_DEVICE_ID_REALTEK_PTOU      0x8164
+#define PCI_DEVICE_ID_REALTEK_COM1      0x816a
+#define PCI_DEVICE_ID_REALTEK_COM2      0x816b
+#define PCI_DEVICE_ID_REALTEK_IPMI      0x816c
+#define PCI_DEVICE_ID_REALTEK_BMC       0x816e
+#define PCI_DEVICE_ID_REALTEK_PCIBR     0x9151
+
+static struct pci_device_id rtl_pci_tbl[] = {
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_PTOU), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_COM1), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_COM2), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_IPMI), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_BMC), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_PCIBR), .class_mask = 0xff00 },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(pci, rtl_pci_tbl);
+
+static int rtl_probe(struct pci_dev *pdev,
+			 const struct pci_device_id *ent)
+{
+	int rc;
+
+	/* enable device (incl. PCI PM wakeup and hotplug setup) */
+	rc = pcim_enable_device(pdev);
+	if (rc < 0)
+		return dev_err_probe(&pdev->dev, rc, "enable failure\n");
+
+	dev_info(&pdev->dev, "enable device\n");
+
+	return rc;
+}
+
+static void rtl_remove(struct pci_dev *pdev) {}
+
+static int rtl_pm_suspend(struct device *device)
+{
+	return 0;
+}
+
+static int rtl_pm_resume(struct device *device)
+{
+	return 0;
+}
+
+static const struct dev_pm_ops rtl_pm_ops = {
+	SYSTEM_SLEEP_PM_OPS(rtl_pm_suspend, rtl_pm_resume)
+};
+
+static struct pci_driver rtl_pci_driver = {
+	.name		= "rtl_pci",
+	.id_table	= rtl_pci_tbl,
+	.probe		= rtl_probe,
+	.remove		= rtl_remove,
+#ifdef CONFIG_PM
+	.driver.pm  = pm_ptr(&rtl_pm_ops),
+#endif
+};
+
+module_pci_driver(rtl_pci_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RealTek pci driver");
-- 
2.43.0
Re: [PATCH v1] rtl_pci: add support for Realtek management device
Posted by kernel test robot 1 month, 1 week ago
Hi javen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus soc/for-next linus/master v7.0-rc2 next-20260302]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/javen/rtl_pci-add-support-for-Realtek-management-device/20260303-110319
base:   char-misc/char-misc-testing
patch link:    https://lore.kernel.org/r/20260303030106.1335-1-javen_xu%40realsil.com.cn
patch subject: [PATCH v1] rtl_pci: add support for Realtek management device
reproduce: (https://download.01.org/0day-ci/archive/20260303/202603030549.R78qeiGD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603030549.R78qeiGD-lkp@intel.com/

versioncheck warnings: (new ones prefixed by >>)
   INFO PATH=/opt/cross/rustc-1.88.0-bindgen-0.72.1/cargo/bin:/opt/cross/clang-20/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
   /usr/bin/timeout -k 100 3h /usr/bin/make KCFLAGS=\ -fno-crash-diagnostics\ -Wno-error=return-type\ -Wreturn-type\ -funsigned-char\ -Wundef\ -falign-functions=64 W=1 --keep-going LLVM=1 -j32 ARCH=x86_64 versioncheck 
   find ./* \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o \
   	-name '*.[hcS]' -type f -print | sort \
   	| xargs perl -w ./scripts/checkversion.pl
>> ./drivers/misc/rtl_pci.c: 11 linux/version.h not needed.
   ./samples/bpf/spintest.bpf.c: 8 linux/version.h not needed.
   ./tools/lib/bpf/bpf_helpers.h: 446: need linux/version.h
   ./tools/testing/selftests/bpf/progs/dev_cgroup.c: 9 linux/version.h not needed.
   ./tools/testing/selftests/bpf/progs/netcnt_prog.c: 3 linux/version.h not needed.
   ./tools/testing/selftests/bpf/progs/test_map_lock.c: 4 linux/version.h not needed.
   ./tools/testing/selftests/bpf/progs/test_send_signal_kern.c: 4 linux/version.h not needed.
   ./tools/testing/selftests/bpf/progs/test_spin_lock.c: 4 linux/version.h not needed.
   ./tools/testing/selftests/bpf/progs/test_tcp_estats.c: 37 linux/version.h not needed.
   ./tools/testing/selftests/wireguard/qemu/init.c: 27 linux/version.h not needed.

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki