How to remove r8169 linux kernel module


We are testing network for orin nx.
And we tried to remove r8169 for some test but if failed

How to resolve it?

Hi, we recently checked with Realtek about r8169 (maintained by Linux kernel team) / r8168 (maintained by Realtek), and they recommended us use the r8168 one. So if your intention is also to switch to r8168, then try our step and see if it helps:

Rename upstream driver and reboot. So that the downstream driver will be probed.

root @tegra-ubuntu:/lib/modules/5.10.104-tegra# find . -iname r8169.ko
root @tegra-ubuntu:/lib/modules/5.10.104-tegra# mv ./kernel/drivers/net/ethernet/realtek/r8169.ko ./kernel/drivers/net/ethernet/realtek/r8169_temp.ko
root @tegra-ubuntu:/lib/modules/5.10.104-tegra# reboot -f

After reboot check dmesg logs to confirm if downstream driver is loaded and probed.

root@tegra-ubuntu:/home/nvidia# dmesg | grep r8168
[ 12.506993] r8168 0008:01:00.0: Adding to iommu group 11
[ 12.507360] r8168 0008:01:00.0: enabling device (0000 → 0003)
[ 12.507502] r8168 Gigabit Ethernet driver 8.045.08-NAPI loaded
[ 12.539601] r8168: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[ 12.539659] r8168 Copyright (C) 2017 Realtek NIC software team
[ 18.319419] r8168: eth0: link up

You probably also want to consider the output of this command:
zcat /proc/config.gz | grep -i '8169'

If it is “=y”, then the driver is not a module, but is instead integrated. In that case you’ll need to rebuild the kernel and the modules. I suppose it would be possible to blacklist, but I think that only works with modules.

Driver is changed to r8168, but it failed to remove kernel module as same before.

r8169 is ‘=m’.
So, it looks a kernel module.

Hi, we may need to check with our internal team to identify the cause. Does dmesg show anything related after waiting for eth0 to become free.?
But I wan to know that if you just need to switch to another driver, what’s the purpose of having to explicitly remove the corresponding kernel module?

What happens if you add this file to “/etc/modprobe.d/” (I’d name it “blacklist-r8169.conf”) with this content:

blacklist r8169

please try this WAR and see if this can bypass the error.

In pcie driver (kernel/kernel-5.10/drivers/pci/controller/dwc/pcie-tegra194.c), comment out below and rebuild the kernel driver.

.shutdown = tegra_pcie_dw_shutdown,

It has to unload before writing MAC address to OTP.
Because the other module has to load instead of it.

If i try it ‘blacklist r8169’.
Then r8168 is loaded from boot.

I tried it.

And then it has error.

So, I remove function code and then build is success.

I flash the new image but the error is same.
‘rmmod r8169’ is not working same as before.

Could you share me the dmesg?

Here it is
dmesg.log (66.9 KB)

Hi @sumin.lee1

Could you also try this patch?

diff --git a/drivers/platform/tegra/ptp-notifier.c b/drivers/platform/tegra/ptp-notifier.c
index 9da644b13..edfebe9e1 100644
--- a/drivers/platform/tegra/ptp-notifier.c
+++ b/drivers/platform/tegra/ptp-notifier.c
@@ -107,19 +107,31 @@ int tegra_get_hwtime(const char *intf_name, void *ts, int ts_type)
                raw_spin_unlock_irqrestore(&ptp_notifier_lock, flags);
                return -1;
+       /* dev_get_by_name increments the dev reference and requires dev_put */
        dev = dev_get_by_name(&init_net, intf_name);

-       if (!dev || !(dev->flags & IFF_UP)) {
-               pr_debug("dev is NULL or intf is not up for %s\n", intf_name);
+       if (!dev) {
+               pr_debug("No device found for %s\n", intf_name);
+               raw_spin_unlock_irqrestore(&ptp_notifier_lock, flags);
+               return -EINVAL;
+       }
+       if (!(dev->flags & IFF_UP)) {
+               pr_debug("interface is not up for %s\n", intf_name);
+               dev_put(dev);
                raw_spin_unlock_irqrestore(&ptp_notifier_lock, flags);
                return -EINVAL;
        for (index = 0; index < MAX_MAC_INSTANCES; index++) {
                if (dev == registered_ndev[index])
        if (index == MAX_MAC_INSTANCES) {
                pr_debug("Interface: %s is not registered to get HW time", intf_name);
+               dev_put(dev);
                raw_spin_unlock_irqrestore(&ptp_notifier_lock, flags);
                return -EINVAL;
@@ -128,6 +140,8 @@ int tegra_get_hwtime(const char *intf_name, void *ts, int ts_type)
                ret = (get_systime[index])(dev, ts, ts_type);
                ret = -EINVAL;
+       dev_put(dev);
        raw_spin_unlock_irqrestore(&ptp_notifier_lock, flags);

        return ret;
1 Like


There is no “ptp-notifier.c” in the source code directory.

Search kernel/nvidia.


Oh, now I see it. I will try it.

It works
The kernel module is unloaded.
Thank you !!!

1 Like

Is it the 8168 driver you want? If not, in a similar fashion from what was used for the 8169, what do you see from:
zcat /proc/config.gz | grep 8168

Sorry, looks like you already have the result you want.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.