From 278f87e0ced1902d266537c4c7f6617d534fee8b Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Fri, 19 May 2023 17:39:01 +0530 Subject: [PATCH] gpu: nvgpu: unregister reboot notifier for pci driver Below oops is encountered as reboot notifier was not unregistered on nvgpu unload. On registering new reboot notifier on reload of the nvgpu module, kernel is not able to access prior freed notifier buffer. Reboot notifier unregistration was not present in nvgpu_pci_remove. Add it. Unable to handle kernel paging request at virtual address Internal error: Oops: 96000004 [#1] PREEMPT SMP^M CPU: 0 PID: 997 Comm: modprobe Tainted: G W 5.10.152-tegra #2^M pstate: a2400009 (NzCv daif +PAN -UAO +TCO BTYPE=--)^M pc : blocking_notifier_chain_register+0x50/0xf0^M lr : blocking_notifier_chain_register+0x3c/0xf0^M blocking_notifier_chain_register+0x50/0xf0^M register_reboot_notifier+0x2c/0x40^M nvgpu_pci_shutdown+0xaac/0x1b00 [nvgpu]^M pci_device_probe+0xf8/0x1f0^M really_probe+0x104/0x510^M driver_probe_device+0x108/0x190^M device_driver_attach+0x80/0x90^M __driver_attach+0xfc/0x1e0^M bus_for_each_dev+0x84/0x100^M driver_attach+0x34/0x50^M bus_add_driver+0x15c/0x260^M driver_register+0x68/0x130^M __pci_register_driver+0x78/0x90^M nvgpu_pci_init+0x3c/0x74 [nvgpu]^M init_module+0x18/0xe9c [nvgpu]^M do_one_initcall+0x50/0x310^M do_init_module+0x50/0x200^M load_module+0x22dc/0x2800^M Bug 3495440 Change-Id: I4367352c57d4858ee0b8dda7d1181c9d01632791 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2907442 Reviewed-by: Rajesh Devaraj Reviewed-by: Ramalingam C Reviewed-by: Ankur Kishore GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c index 171d4b7b8..6fed5b28c 100644 --- a/drivers/gpu/nvgpu/os/linux/pci.c +++ b/drivers/gpu/nvgpu/os/linux/pci.c @@ -860,6 +860,8 @@ static void nvgpu_pci_remove(struct pci_dev *pdev) nvgpu_remove(dev); + unregister_reboot_notifier(&l->nvgpu_reboot_nb); + #if defined(CONFIG_PCI_MSI) if (g->msi_enabled) pci_disable_msi(pdev);