linux/drivers/gpu/drm
Kai-Heng Feng 8c3dd61cfa drm/amdgpu: Register VGA clients after init can no longer fail
When an amdgpu device fails to init, it makes another VGA device cause
kernel splat:
kernel: amdgpu 0000:08:00.0: amdgpu: amdgpu_device_ip_init failed
kernel: amdgpu 0000:08:00.0: amdgpu: Fatal error during GPU init
kernel: amdgpu: probe of 0000:08:00.0 failed with error -110
...
kernel: amdgpu 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
kernel: BUG: kernel NULL pointer dereference, address: 0000000000000018
kernel: #PF: supervisor read access in kernel mode
kernel: #PF: error_code(0x0000) - not-present page
kernel: PGD 0 P4D 0
kernel: Oops: 0000 [#1] SMP NOPTI
kernel: CPU: 6 PID: 1080 Comm: Xorg Tainted: G        W         5.12.0-rc8+ #12
kernel: Hardware name: HP HP EliteDesk 805 G6/872B, BIOS S09 Ver. 02.02.00 12/30/2020
kernel: RIP: 0010:amdgpu_device_vga_set_decode+0x13/0x30 [amdgpu]
kernel: Code: 06 31 c0 c3 b8 ea ff ff ff 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 0f 1f 44 00 00 55 48 8b 87 90 06 00 00 48 89 e5 53 89 f3 <48> 8b 40 18 40 0f b6 f6 e8 40 58 39 fd 80 fb 01 5b 5d 19 c0 83 e0
kernel: RSP: 0018:ffffae3c0246bd68 EFLAGS: 00010002
kernel: RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
kernel: RDX: ffff8dd1af5a8560 RSI: 0000000000000000 RDI: ffff8dce8c160000
kernel: RBP: ffffae3c0246bd70 R08: ffff8dd1af5985c0 R09: ffffae3c0246ba38
kernel: R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000246
kernel: R13: 0000000000000000 R14: 0000000000000003 R15: ffff8dce81490000
kernel: FS:  00007f9303d8fa40(0000) GS:ffff8dd1af580000(0000) knlGS:0000000000000000
kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
kernel: CR2: 0000000000000018 CR3: 0000000103cfa000 CR4: 0000000000350ee0
kernel: Call Trace:
kernel:  vga_arbiter_notify_clients.part.0+0x4a/0x80
kernel:  vga_get+0x17f/0x1c0
kernel:  vga_arb_write+0x121/0x6a0
kernel:  ? apparmor_file_permission+0x1c/0x20
kernel:  ? security_file_permission+0x30/0x180
kernel:  vfs_write+0xca/0x280
kernel:  ksys_write+0x67/0xe0
kernel:  __x64_sys_write+0x1a/0x20
kernel:  do_syscall_64+0x38/0x90
kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xae
kernel: RIP: 0033:0x7f93041e02f7
kernel: Code: 75 05 48 83 c4 58 c3 e8 f7 33 ff ff 0f 1f 80 00 00 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
kernel: RSP: 002b:00007fff60e49b28 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
kernel: RAX: ffffffffffffffda RBX: 000000000000000b RCX: 00007f93041e02f7
kernel: RDX: 000000000000000b RSI: 00007fff60e49b40 RDI: 000000000000000f
kernel: RBP: 00007fff60e49b40 R08: 00000000ffffffff R09: 00007fff60e499d0
kernel: R10: 00007f93049350b5 R11: 0000000000000246 R12: 000056111d45e808
kernel: R13: 0000000000000000 R14: 000056111d45e7f8 R15: 000056111d46c980
kernel: Modules linked in: nls_iso8859_1 snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_seq input_leds snd_seq_device snd_timer snd soundcore joydev kvm_amd serio_raw k10temp mac_hid hp_wmi ccp kvm sparse_keymap wmi_bmof ucsi_acpi efi_pstore typec_ucsi rapl typec video wmi sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx libcrc32c xor raid6_pq raid1 raid0 multipath linear dm_mirror dm_region_hash dm_log hid_generic usbhid hid amdgpu drm_ttm_helper ttm iommu_v2 gpu_sched i2c_algo_bit drm_kms_helper syscopyarea sysfillrect crct10dif_pclmul sysimgblt crc32_pclmul fb_sys_fops ghash_clmulni_intel cec rc_core aesni_intel crypto_simd psmouse cryptd r8169 i2c_piix4 drm ahci xhci_pci realtek libahci xhci_pci_renesas gpio_amdpt gpio_generic
kernel: CR2: 0000000000000018
kernel: ---[ end trace 76d04313d4214c51 ]---

Commit 4192f7b576 ("drm/amdgpu: unmap register bar on device init
failure") makes amdgpu_driver_unload_kms() skips amdgpu_device_fini(),
so the VGA clients remain registered. So when
vga_arbiter_notify_clients() iterates over registered clients, it causes
NULL pointer dereference.

Since there's no reason to register VGA clients that early, so solve
the issue by putting them after all the goto cleanups.

v2:
 - Remove redundant vga_switcheroo cleanup in failed: label.

Fixes: 4192f7b576 ("drm/amdgpu: unmap register bar on device init failure")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2021-04-29 00:03:21 -04:00
..
amd drm/amdgpu: Register VGA clients after init can no longer fail 2021-04-29 00:03:21 -04:00
arm drm/komeda: Fix bit check to import to value of proper type 2021-04-01 13:48:48 +01:00
armada drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
aspeed drm/gem: Move drm_gem_fb_prepare_fb() to GEM atomic helpers 2021-02-23 08:54:22 +01:00
ast drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
atmel-hlcdc drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
bochs drm/bochs: Remove references to struct drm_device.pdev 2021-01-06 15:42:55 +01:00
bridge A few fixes for the next merge window, with some build fixes for anx7625 2021-04-23 13:53:07 +10:00
etnaviv Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
exynos Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
fsl-dcu drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
gma500 gma500: Use DEFINE_SPINLOCK() for spinlock 2021-04-08 13:19:56 +02:00
gud drm/gud: Remove unneeded semicolon 2021-03-23 10:32:14 +01:00
hisilicon drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
i2c
i810 drm/i810: make i810_flush_queue() return void 2020-09-11 10:54:17 +02:00
i915 Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
imx Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
ingenic drm/ingenic: Register devm action to cleanup encoders 2021-03-29 16:47:12 +01:00
kmb drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
lib
lima Revert "drm/scheduler: Job timeout handler returns status (v3)" 2021-02-10 15:26:00 +01:00
mcde drm/mcde/panel: Inverse misunderstood flag 2021-03-04 14:31:06 +01:00
mediatek Mediatek DRM Next for Linux 5.13 2021-04-08 12:42:14 +10:00
meson drm/meson: Fix few typo 2021-03-19 10:40:54 +01:00
mga drm/mga/mga_ioc32: Fix some formatting issues in 'mga_compat_ioctl's header 2021-01-18 15:41:12 +01:00
mgag200 drm/mgag200: Move vmap out of commit tail 2021-02-08 13:00:26 +01:00
msm Merge tag 'drm-msm-next-2021-04-11' of https://gitlab.freedesktop.org/drm/msm into drm-next 2021-04-13 23:35:54 +02:00
mxsfb drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
nouveau Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
omapdrm Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
panel Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
panfrost drm/panfrost: Stay in the threaded MMU IRQ handler until we've handled all IRQs 2021-02-15 09:43:33 +01:00
pl111 drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
qxl drm/ttm: switch to per device LRU lock 2021-03-24 17:05:25 +01:00
r128 drm/r128/r128_ioc32: Fix formatting issues in 'r128_compat_ioctl()'s header 2021-01-18 15:41:04 +01:00
radeon drm/radeon: Fix a missing check bug in radeon_dp_mst_detect() 2021-04-09 16:58:23 -04:00
rcar-du Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
rockchip drm/rockchip: Remove unused variable 2021-03-24 09:31:22 +01:00
savage drm/savage/savage_bci: Remove set but never used 'aper_rsrc' and 'fb_rsrc' 2020-11-12 20:31:01 +01:00
scheduler drm/amd/amdgpu implement tdr advanced mode 2021-04-09 16:45:45 -04:00
selftests drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap 2020-11-17 20:08:29 +01:00
shmobile drm/<drivers>: Constify struct drm_driver 2020-11-06 10:31:26 +01:00
sis
sti drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
stm drm/stm: dsi: Avoid printing errors for -EPROBE_DEFER 2021-03-08 15:06:56 +01:00
sun4i drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
tdfx drm: Constify drm_driver in drivers that don't modify it 2021-01-05 07:20:36 +02:00
tegra Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
tidss drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
tilcdc drm/tilcdc: fix pixel clock setting warning message 2021-03-24 12:05:28 +02:00
tiny drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
ttm A few fixes for the next merge window, with some build fixes for anx7625 2021-04-23 13:53:07 +10:00
tve200 drm/gem: Move drm_gem_fb_prepare_fb() to GEM atomic helpers 2021-02-23 08:54:22 +01:00
udl drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
v3d Revert "drm/scheduler: Job timeout handler returns status (v3)" 2021-02-10 15:26:00 +01:00
vboxvideo drm/vboxvideo: Use managed VRAM-helper initialization 2021-03-11 14:19:43 +01:00
vc4 Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
vgem drm/prime: split array import functions v4 2020-11-30 15:00:45 +01:00
via via/via_irq: use __func__ to replace string function name 2020-11-27 16:14:02 +01:00
virtio drm/virtio: fix possible leak/unlock virtio_gpu_object_array 2021-03-09 12:06:18 +01:00
vkms drm/vkms: fix misuse of WARN_ON 2021-03-25 08:23:28 -03:00
vmwgfx drm/ttm: remove swap LRU v3 2021-03-24 17:05:14 +01:00
xen Merge drm/drm-fixes into drm-next 2021-04-13 23:15:09 +02:00
xlnx drm: xlnx: zynqmp: fix a memset in zynqmp_dp_train() 2021-04-08 12:52:10 +02:00
zte drm: Use state helper instead of the plane state pointer 2021-02-25 08:05:28 +01:00
drm_agpsupport.c drm: Upcast struct drm_device.dev to struct pci_device; replace pdev 2021-01-19 09:06:38 +01:00
drm_atomic_helper.c drm: Fix 3 typos in the inline doc 2021-03-26 11:46:33 +01:00
drm_atomic_state_helper.c drm: fix some kernel-doc markups 2020-11-16 20:48:20 +01:00
drm_atomic_uapi.c drm: fix oops in drm_atomic_set_crtc_for_connector 2020-11-16 09:56:55 +01:00
drm_atomic.c drm/atomic: Couple of typo fixes 2021-04-09 16:42:09 -04:00
drm_auth.c
drm_blend.c drm/doc: introduce new section for standard plane properties 2020-12-17 16:56:40 +01:00
drm_bridge_connector.c gpu/drm: delete same check in if condition 2020-11-02 14:04:53 +01:00
drm_bridge.c
drm_bufs.c drm: Upcast struct drm_device.dev to struct pci_device; replace pdev 2021-01-19 09:06:38 +01:00
drm_cache.c drm: Include <linux/mem_encrypt.h> in drm_cache.c 2021-01-14 09:42:31 +01:00
drm_client_modeset.c drm: replace drm_modeset_lock_all() in drm_client_modeset_dpms_legacy() 2021-02-09 17:16:57 +01:00
drm_client.c drm/client: Depend on GEM object kmap ref-counting 2020-11-24 09:27:54 +01:00
drm_color_mgmt.c drm: add legacy support for using degamma for gamma 2020-12-15 15:46:03 +02:00
drm_connector.c drm/uapi: Add USB connector type 2021-03-16 12:45:28 +01:00
drm_context.c
drm_crtc_helper_internal.h drm: remove drm_fb_helper_modinit 2021-02-08 12:20:38 +01:00
drm_crtc_helper.c
drm_crtc_internal.h drm: Introduce plane and CRTC scaling filter properties 2020-10-21 12:19:54 +03:00
drm_crtc.c drm: Switch to %p4cc format modifier 2021-02-17 12:52:59 +01:00
drm_damage_helper.c
drm_debugfs_crc.c
drm_debugfs.c
drm_displayid.c drm/displayid: rename displayid_hdr to displayid_header 2021-03-31 15:42:39 +03:00
drm_dma.c
drm_dp_aux_dev.c drm/dp_aux_dev: check aux_dev before use in drm_dp_aux_dev_get_by_minor() 2020-10-15 13:58:54 -04:00
drm_dp_cec.c
drm_dp_dual_mode_helper.c
drm_dp_helper.c drm/dp_helper: Define options for FRL training for HDMI2.1 PCON 2021-03-31 12:21:06 +03:00
drm_dp_mst_topology_internal.h
drm_dp_mst_topology.c drm/dp_mst: Drop DRM_ERROR() on kzalloc() fail in drm_dp_mst_handle_up_req() 2021-04-08 17:47:26 -04:00
drm_drv.c drm/drv: Remove initialization of static variables 2021-02-21 19:49:17 -05:00
drm_dsc.c drm/dsc: add helper for calculating rc buffer size from DPCD 2020-12-10 10:49:47 +02:00
drm_dumb_buffers.c drm: Don't export the drm_gem_dumb_destroy() function 2021-01-05 07:20:25 +02:00
drm_edid_load.c
drm_edid.c drm/edid: use the new displayid iterator for tile info 2021-03-31 15:42:02 +03:00
drm_encoder_slave.c
drm_encoder.c drm: add drmm_encoder_alloc() 2021-01-04 12:59:33 +01:00
drm_fb_cma_helper.c
drm_fb_helper.c drm/fb-helper: only unmap if buffer not null 2021-03-11 11:08:14 +01:00
drm_file.c drm/drm_vblank: set the dma-fence timestamp during send_vblank_event 2021-02-24 21:05:54 +05:30
drm_flip_work.c
drm_format_helper.c
drm_fourcc.c drm/fourcc: Add AXBXGXRX106106106106 format 2020-10-20 20:51:42 +01:00
drm_framebuffer.c drm: Switch to %p4cc format modifier 2021-02-17 12:52:59 +01:00
drm_gem_atomic_helper.c drm/gem: Move drm_gem_fb_prepare_fb() to GEM atomic helpers 2021-02-23 08:54:22 +01:00
drm_gem_cma_helper.c drm/cma-helper: Implement mmap as GEM CMA object functions 2020-11-30 13:38:27 +01:00
drm_gem_framebuffer_helper.c drm/gem: Move drm_gem_fb_prepare_fb() to GEM atomic helpers 2021-02-23 08:54:22 +01:00
drm_gem_shmem_helper.c drm/shmem-helpers: vunmap: Don't put pages for dma-buf 2021-03-11 11:11:33 +01:00
drm_gem_ttm_helper.c drm/ttm: Add vmap/vunmap to TTM and TTM GEM helpers 2020-11-09 09:17:36 +01:00
drm_gem_vram_helper.c drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
drm_gem.c drm/gem: Export drm_gem_vmap() and drm_gem_vunmap() 2021-02-08 13:00:06 +01:00
drm_hashtab.c
drm_hdcp.c
drm_internal.h drm/drm_internal.h: Remove repeated struct declaration 2021-04-08 13:05:38 +02:00
drm_ioc32.c drm/compat: Clear bounce structures 2021-03-11 11:11:33 +01:00
drm_ioctl.c drm: Give irq_by_busid drm_legacy_ prefix 2020-10-21 18:05:11 +02:00
drm_irq.c drm: Upcast struct drm_device.dev to struct pci_device; replace pdev 2021-01-19 09:06:38 +01:00
drm_kms_helper_common.c drm: remove drm_fb_helper_modinit 2021-02-08 12:20:38 +01:00
drm_lease.c
drm_legacy_misc.c
drm_legacy.h drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY 2021-01-13 14:22:37 +01:00
drm_lock.c
drm_managed.c drm/dev: Remove drm_dev_init 2020-09-21 10:45:08 +02:00
drm_memory.c drm: Implement drm_need_swiotlb() in drm_cache.c 2021-01-13 14:22:29 +01:00
drm_mipi_dbi.c drm: Switch to %p4cc format modifier 2021-02-17 12:52:59 +01:00
drm_mipi_dsi.c
drm_mm.c
drm_mode_config.c drm-misc-next for v5.12: 2021-01-07 13:40:20 +01:00
drm_mode_object.c drm: fix some kernel-doc markups 2020-11-16 20:48:20 +01:00
drm_modes.c drm: Refuse to create zero width/height cmdline modes 2021-04-01 20:29:16 +03:00
drm_modeset_helper.c
drm_modeset_lock.c
drm_of.c
drm_panel_orientation_quirks.c drm: Added orientation quirk for OneGX1 Pro 2021-01-20 22:33:01 +01:00
drm_panel.c
drm_pci.c drm: Upcast struct drm_device.dev to struct pci_device; replace pdev 2021-01-19 09:06:38 +01:00
drm_plane_helper.c
drm_plane.c drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
drm_prime.c drm: Set vm_ops to GEM object's values during mmap 2021-01-18 10:37:26 +01:00
drm_print.c
drm_probe_helper.c drm/probe-helper: Check epoch counter in output_poll_execute() 2021-03-16 12:45:52 +01:00
drm_property.c drm: Few typo fixes 2021-03-18 14:22:50 +01:00
drm_rect.c
drm_scatter.c
drm_scdc_helper.c drm: fix some kernel-doc markups 2020-11-16 20:48:20 +01:00
drm_self_refresh_helper.c
drm_simple_kms_helper.c drm/atomic: Pass the full state to planes atomic disable and update 2021-02-25 08:05:28 +01:00
drm_syncobj.c drm/syncobj: use newly allocated stub fences 2021-04-08 12:21:13 +02:00
drm_sysfs.c drm/sysfs: Convert sysfs sprintf/snprintf family to sysfs_emit 2021-03-23 07:41:39 -04:00
drm_trace_points.c
drm_trace.h
drm_vblank_work.c
drm_vblank.c drm/vblank: Do not store a new vblank timestamp in drm_vblank_restore() 2021-04-01 20:29:17 +03:00
drm_vm.c drm: Upcast struct drm_device.dev to struct pci_device; replace pdev 2021-01-19 09:06:38 +01:00
drm_vma_manager.c
drm_writeback.c
Kconfig drm/radeon: fix AGP dependency 2021-03-23 23:25:21 -04:00
Makefile drm/displayid: add separate drm_displayid.c 2021-03-31 15:41:35 +03:00