dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Andy Lavr <andy.lavr@gmail.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Arnd Bergmann <arnd@arndb.de>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [BUG] DRM kernel NULL pointer dereference (linux-next 20210115)
Date: Mon, 18 Jan 2021 09:25:53 +0100	[thread overview]
Message-ID: <7851c78c-8c57-3c84-cd49-a72703095a5d@suse.de> (raw)
In-Reply-To: <9f067539-07b1-7aa6-3112-0eb25b1b606f@gmail.com>


[-- Attachment #1.1.1.1: Type: text/plain, Size: 11323 bytes --]

(cc'ing dri-devel)

Hi

thanks for reporting the bug.

Am 17.01.21 um 12:12 schrieb Andy Lavr:
> Hey,
> 
> 
> You forgot to add these commits to linux-next:
> 
> 
>   drm: Move struct drm_device.pdev to legacy
> 
> https://patchwork.kernel.org/project/intel-gfx/cover/20210107080748.4768-1-tzimmermann@suse.de/
> 
> 
> I committed these patches to my local tree and that solved my problem.
> 
> 
>   * v3,4/8] drm/i915: Remove references to struct drm_device.pdev
>     <https://patchwork.kernel.org/project/intel-gfx/patch/20210107080748.4768-5-tzimmermann@suse.de/>
>   * [v3,5/8] drm/i915/gt: Remove references to struct drm_device.pdev
>     <https://patchwork.kernel.org/project/intel-gfx/patch/20210107080748.4768-6-tzimmermann@suse.de/>
>   * [v3,6/8] drm/i915/gvt: Remove references to struct drm_device.pdev
>     <https://patchwork.kernel.org/project/intel-gfx/patch/20210107080748.4768-7-tzimmermann@suse.de/>
>   * [v3,8/8] drm: Upcast struct drm_device.dev to struct pci_device;
>     replace pdev
>     <https://patchwork.kernel.org/project/intel-gfx/patch/20210107080748.4768-9-tzimmermann@suse.de/>

These patches have not been merged yet as they have to wait for some 
preparation in the i915 driver.

I reduced the final patch, so it should change the buggy code. Could you 
please apply only the attached patchfile and report if it fixes the issue?

Best regards
Thomas

> 
> 
> 
> Thanks to all!
> 
> 
> 16.01.2021 15:17, Andy Lavr:
>>
>> Hey,
>>
>>
>> *linux-next 20210114 work fine.*
>>
>>
>> *linux-next 20210115:*
>>
>> Jan 15 17:34:30 wip kernel: [   35.185982] *BUG: kernel NULL pointer 
>> dereference, address: 0000000000000010*
>> Jan 15 17:34:30 wip kernel: [   35.186988] #PF: supervisor read access 
>> in kernel mode
>> Jan 15 17:34:30 wip kernel: [   35.187984] #PF: error_code(0x0000) - 
>> not-present page
>> Jan 15 17:34:30 wip kernel: [   35.189016] PGD 0 P4D 0
>> Jan 15 17:34:30 wip kernel: [   35.190508] Oops: 0000 [#1] SMP PTI
>> Jan 15 17:34:30 wip kernel: [   35.191814] CPU: 6 PID: 1319 Comm: Xorg 
>> Not tainted 5.11.13-dragon-sandybridge #202101150001
>> Jan 15 17:34:30 wip kernel: [   35.192847] Hardware name: Dell Inc. 
>> Precision M6600/04YY4M, BIOS A18 09/14/2018
>> Jan 15 17:34:30 wip kernel: [   35.193877] *RIP: 
>> 0010:drm_pci_set_busid+0x1a/0x80 [drm]*
>> Jan 15 17:34:30 wip kernel: [   35.194950] Code: fc 06 f8 c8 00 00 00 
>> 00 00 00 00 00 00 00 00 00 0f 1f 44 00 00 55 53 50 48 89 f3 31 d2 81 
>> 3f 04 00 01 00 48 8b 87 78 01 00 00 <48> 8b 48 10 7c 09 48 8b 91 d0 01 
>> 00 00 8b 12 0f b6 89 e0 01 00 00
>> Jan 15 17:34:30 wip kernel: [   35.196094] RSP: 0018:ffffaacf485afd38 
>> EFLAGS: 00010246
>> Jan 15 17:34:30 wip kernel: [   35.197695] RAX: 0000000000000000 RBX: 
>> ffff95f1684e5000 RCX: ffffffff8b06f380
>> Jan 15 17:34:30 wip kernel: [   35.198872] RDX: 0000000000000000 RSI: 
>> ffff95f1684e5000 RDI: ffff95f175240010
>> Jan 15 17:34:30 wip kernel: [   35.200037] RBP: 00000000ffffffea R08: 
>> 000000000000e200 R09: 0000000000000001
>> Jan 15 17:34:30 wip kernel: [   35.201205] R10: ffff95f16de88b00 R11: 
>> ffffffffc03e1990 R12: ffff95f1684e5000
>> Jan 15 17:34:30 wip kernel: [   35.202383] R13: 00007fff8865e240 R14: 
>> ffff95f1752400a8 R15: ffff95f175240010
>> Jan 15 17:34:30 wip kernel: [   35.203554] FS: 000070bcd696da40(0000) 
>> GS:ffff95f41db80000(0000) knlGS:0000000000000000
>> Jan 15 17:34:30 wip kernel: [   35.204742] CS:  0010 DS: 0000 ES: 0000 
>> CR0: 0000000080050033
>> Jan 15 17:34:30 wip kernel: [   35.205936] CR2: 0000000000000010 CR3: 
>> 0000000186c28006 CR4: 00000000000606e0
>> Jan 15 17:34:30 wip kernel: [   35.207144] Call Trace:
>> Jan 15 17:34:30 wip kernel: [   35.208370] drm_setversion+0x13e/0x170 
>> [drm]
>> Jan 15 17:34:30 wip kernel: [   35.209596]  ? drm_getstats+0x20/0x20 [drm]
>> Jan 15 17:34:30 wip kernel: [   35.210799] drm_ioctl_kernel+0xe2/0x150 
>> [drm]
>> Jan 15 17:34:30 wip kernel: [   35.211989] drm_ioctl+0x30b/0x440 [drm]
>> Jan 15 17:34:30 wip kernel: [   35.213170]  ? drm_getstats+0x20/0x20 [drm]
>> Jan 15 17:34:30 wip kernel: [   35.214351] amdgpu_drm_ioctl+0x44/0x80 
>> [amdgpu]
>> Jan 15 17:34:30 wip kernel: [   35.215696] __se_sys_ioctl+0x78/0xc0
>> Jan 15 17:34:30 wip kernel: [   35.216848] do_syscall_64+0x33/0x70
>> Jan 15 17:34:30 wip kernel: [   35.218002] 
>> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>> Jan 15 17:34:30 wip kernel: [   35.219177] RIP: 0033:0x70bcd6dd931b
>> Jan 15 17:34:30 wip kernel: [   35.220654] Code: 89 d8 49 8d 3c 1c 48 
>> f7 d8 49 39 c4 72 b5 e8 1c ff ff ff 85 c0 78 ba 4c 89 e0 5b 5d 41 5c 
>> c3 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 
>> 0d 1d 3b 0d 00 f7 d8 64 89 01 48
>> Jan 15 17:34:30 wip kernel: [   35.222211] RSP: 002b:00007fff8865e208 
>> EFLAGS: 00000202 ORIG_RAX: 0000000000000010
>> Jan 15 17:34:30 wip kernel: [   35.223778] RAX: ffffffffffffffda RBX: 
>> 00007fff8865e240 RCX: 000070bcd6dd931b
>> Jan 15 17:34:30 wip kernel: [   35.225145] RDX: 00007fff8865e240 RSI: 
>> 00000000c0106407 RDI: 000000000000000c
>> Jan 15 17:34:30 wip kernel: [   35.226420] RBP: 00000000c0106407 R08: 
>> 0000000000000031 R09: 0000000000000000
>> Jan 15 17:34:30 wip kernel: [   35.227691] R10: 000070bcd7850ec0 R11: 
>> 0000000000000202 R12: 00005b60f67cbb50
>> Jan 15 17:34:30 wip kernel: [   35.228954] R13: 000000000000000c R14: 
>> 00005b60f67cbb90 R15: 0000000000000000
>> Jan 15 17:34:30 wip kernel: [   35.229231] iwlwifi 0000:03:00.0: Radio 
>> type=0x0-0x3-0x1
>> Jan 15 17:34:30 wip kernel: [   35.230218] Modules linked in: vfat fat 
>> intel_rapl_msr hid_generic mei_hdcp at24 dell_rbtn iwldvm dell_laptop 
>> dell_smm_hwmon mac80211 intel_rapl_common libarc4 snd_hda_codec_idt 
>> snd_hda_codec_generic x86_pkg_temp_thermal ledtrig_audio 
>> intel_powerclamp snd_hda_codec_hdmi crct10dif_pclmul iwlwifi 
>> crc32_pclmul ghash_clmulni_intel snd_hda_intel rapl snd_intel_dspcfg 
>> usbhid intel_cstate firewire_ohci dell_wmi sdhci_pci hid snd_hda_codec 
>> firewire_core dell_smbios crc_itu_t mei_me dcdbas cfg80211 
>> sparse_keymap cqhci i2c_i801 sdhci snd_hda_core joydev e1000e 
>> snd_hwdep wmi_bmof dell_wmi_descriptor i2c_smbus mei tpm_tis 
>> tpm_tis_core tpm dell_smo8800 xt_hl ip6_tables ip6t_rt nf_log_ipv4 
>> nf_log_common ipt_REJECT nf_reject_ipv4 xt_LOG nft_limit xt_limit 
>> xt_addrtype xt_tcpudp sch_cake tcp_yeah tcp_vegas xt_conntrack 
>> nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nft_compat nft_counter 
>> coretemp nf_tables nfnetlink parport_pc ppdev lp parport binfmt_misc 
>> ip_tables x_tables xfs raid10 raid456
>> Jan 15 17:34:30 wip kernel: [   35.232152]  async_raid6_recov async_pq 
>> async_xor async_memcpy async_tx raid1 raid0 multipath linear amdgpu 
>> iommu_v2 gpu_sched drm_ttm_helper ttm i2c_algo_bit drm_kms_helper cec 
>> aesni_intel sysimgblt syscopyarea sysfillrect fb_sys_fops crypto_simd 
>> cryptd psmouse input_leds drm ahci serio_raw libahci wmi video mac_hid
>> Jan 15 17:34:30 wip kernel: [   35.242819] CR2: 0000000000000010
>> Jan 15 17:34:30 wip kernel: [   35.244502] ---[ end trace 
>> 47eef7912dfa1ae6 ]---
>> Jan 15 17:34:30 wip kernel: [   35.494899] *RIP: 
>> 0010:drm_pci_set_busid+0x1a/0x80 [drm]*
>> Jan 15 17:34:30 wip kernel: [   35.496577] Code: fc 06 f8 c8 00 00 00 
>> 00 00 00 00 00 00 00 00 00 0f 1f 44 00 00 55 53 50 48 89 f3 31 d2 81 
>> 3f 04 00 01 00 48 8b 87 78 01 00 00 <48> 8b 48 10 7c 09 48 8b 91 d0 01 
>> 00 00 8b 12 0f b6 89 e0 01 00 00
>> Jan 15 17:34:30 wip kernel: [   35.498313] RSP: 0018:ffffaacf485afd38 
>> EFLAGS: 00010246
>> Jan 15 17:34:30 wip kernel: [   35.500089] RAX: 0000000000000000 RBX: 
>> ffff95f1684e5000 RCX: ffffffff8b06f380
>> Jan 15 17:34:30 wip kernel: [   35.501919] RDX: 0000000000000000 RSI: 
>> ffff95f1684e5000 RDI: ffff95f175240010
>> Jan 15 17:34:30 wip kernel: [   35.503708] RBP: 00000000ffffffea R08: 
>> 000000000000e200 R09: 0000000000000001
>> Jan 15 17:34:30 wip kernel: [   35.505483] R10: ffff95f16de88b00 R11: 
>> ffffffffc03e1990 R12: ffff95f1684e5000
>> Jan 15 17:34:30 wip kernel: [   35.507276] R13: 00007fff8865e240 R14: 
>> ffff95f1752400a8 R15: ffff95f175240010
>> Jan 15 17:34:30 wip kernel: [   35.509058] FS: 000070bcd696da40(0000) 
>> GS:ffff95f41db80000(0000) knlGS:0000000000000000
>> Jan 15 17:34:30 wip kernel: [   35.510866] CS:  0010 DS: 0000 ES: 0000 
>> CR0: 0000000080050033
>> Jan 15 17:34:30 wip kernel: [   35.512647] CR2: 0000000000000010 CR3: 
>> 0000000186c28006 CR4: 00000000000606e0
>>
>>
>>
>> -- 
>> Best regards, Andy Lavr.
>>
>>   CONFIDENTIAL NOTE
>>
>>   This email (including any attachments) is intended only for the person or entity to which it is addressed
>>   and may contain confidential and/or privileged material.  Any review, retransmission, dissemination or other
>>   use of, or taking of any action in reliance upon, this information by persons or entities other than the
>>   intended recipient is prohibited. If you received this in error, please notify the sender immediately and
>>   delete the material completely from your system. E-mail communication cannot be guaranteed to be reliable,
>>   secure, error-free or virus-free. Accordingly, we cannot accept liability for any damage sustained as a
>>   result of any virus, error or incompleteness of this e-mail or any failure to deliver promptly or at all
>>   information exchanged between you and us by this means. If you suspect that this e-mail may have been
>>   intercepted or amended, please contact the sender. Any views or opinions expressed in this email are solely
>>   those of the author and do not necessarily represent those of our entity or related/associated entities.
> 
> -- 
> Best regards, Andy Lavr.
> 
>   CONFIDENTIAL NOTE
> 
>   This email (including any attachments) is intended only for the person or entity to which it is addressed
>   and may contain confidential and/or privileged material.  Any review, retransmission, dissemination or other
>   use of, or taking of any action in reliance upon, this information by persons or entities other than the
>   intended recipient is prohibited. If you received this in error, please notify the sender immediately and
>   delete the material completely from your system. E-mail communication cannot be guaranteed to be reliable,
>   secure, error-free or virus-free. Accordingly, we cannot accept liability for any damage sustained as a
>   result of any virus, error or incompleteness of this e-mail or any failure to deliver promptly or at all
>   information exchanged between you and us by this means. If you suspect that this e-mail may have been
>   intercepted or amended, please contact the sender. Any views or opinions expressed in this email are solely
>   those of the author and do not necessarily represent those of our entity or related/associated entities.
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

[-- Attachment #1.1.1.2: 0001-drm-Upcast-struct-drm_device.dev-to-struct-pci_devic.patch --]
[-- Type: text/x-patch, Size: 9515 bytes --]

From 26be85bf5d99c8e2a4e682af4dbff825b417ec02 Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <tzimmermann@suse.de>
Date: Sat, 7 Nov 2020 21:05:28 +0100
Subject: [PATCH] drm: Upcast struct drm_device.dev to struct pci_device;
 replace pdev

We have DRM drivers based on USB, SPI and platform devices. All of them
are fine with storing their device reference in struct drm_device.dev.
PCI devices should be no exception. Therefore struct drm_device.pdev is
deprecated.

Instead upcast from struct drm_device.dev with to_pci_dev(). PCI-specific
code can use dev_is_pci() to test for a PCI device. This patch changes
the DRM core code and documentation accordingly.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/drm/drm_agpsupport.c |  9 ++++++---
 drivers/gpu/drm/drm_bufs.c       |  4 ++--
 drivers/gpu/drm/drm_edid.c       |  7 ++++++-
 drivers/gpu/drm/drm_irq.c        | 12 +++++++-----
 drivers/gpu/drm/drm_pci.c        | 26 +++++++++++++++-----------
 drivers/gpu/drm/drm_vm.c         |  2 +-
 6 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 8b690ef306de..7e765cb0efee 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -103,11 +103,13 @@ int drm_agp_info_ioctl(struct drm_device *dev, void *data,
  */
 int drm_agp_acquire(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+
 	if (!dev->agp)
 		return -ENODEV;
 	if (dev->agp->acquired)
 		return -EBUSY;
-	dev->agp->bridge = agp_backend_acquire(dev->pdev);
+	dev->agp->bridge = agp_backend_acquire(pdev);
 	if (!dev->agp->bridge)
 		return -ENODEV;
 	dev->agp->acquired = 1;
@@ -402,14 +404,15 @@ int drm_agp_free_ioctl(struct drm_device *dev, void *data,
  */
 struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct drm_agp_head *head = NULL;
 
 	head = kzalloc(sizeof(*head), GFP_KERNEL);
 	if (!head)
 		return NULL;
-	head->bridge = agp_find_bridge(dev->pdev);
+	head->bridge = agp_find_bridge(pdev);
 	if (!head->bridge) {
-		head->bridge = agp_backend_acquire(dev->pdev);
+		head->bridge = agp_backend_acquire(pdev);
 		if (!head->bridge) {
 			kfree(head);
 			return NULL;
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index aeb1327e3077..e3d77dfefb0a 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -326,7 +326,7 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
 		 * As we're limiting the address to 2^32-1 (or less),
 		 * casting it down to 32 bits is no problem, but we
 		 * need to point to a 64bit variable first. */
-		map->handle = dma_alloc_coherent(&dev->pdev->dev,
+		map->handle = dma_alloc_coherent(dev->dev,
 						 map->size,
 						 &map->offset,
 						 GFP_KERNEL);
@@ -556,7 +556,7 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
 	case _DRM_SCATTER_GATHER:
 		break;
 	case _DRM_CONSISTENT:
-		dma_free_coherent(&dev->pdev->dev,
+		dma_free_coherent(dev->dev,
 				  map->size,
 				  map->handle,
 				  map->offset);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 394cc55b3214..c2bbe7bee7b6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -32,6 +32,7 @@
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/vga_switcheroo.h>
 
@@ -2075,9 +2076,13 @@ EXPORT_SYMBOL(drm_get_edid);
 struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
 				     struct i2c_adapter *adapter)
 {
-	struct pci_dev *pdev = connector->dev->pdev;
+	struct drm_device *dev = connector->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct edid *edid;
 
+	if (drm_WARN_ON_ONCE(dev, !dev_is_pci(dev->dev)))
+		return NULL;
+
 	vga_switcheroo_lock_ddc(pdev);
 	edid = drm_get_edid(connector, adapter);
 	vga_switcheroo_unlock_ddc(pdev);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 803af4bbd214..c3bd664ea733 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -122,7 +122,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
 		dev->driver->irq_preinstall(dev);
 
 	/* PCI devices require shared interrupts. */
-	if (dev->pdev)
+	if (dev_is_pci(dev->dev))
 		sh_flags = IRQF_SHARED;
 
 	ret = request_irq(irq, dev->driver->irq_handler,
@@ -140,7 +140,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
 	if (ret < 0) {
 		dev->irq_enabled = false;
 		if (drm_core_check_feature(dev, DRIVER_LEGACY))
-			vga_client_register(dev->pdev, NULL, NULL, NULL);
+			vga_client_register(to_pci_dev(dev->dev), NULL, NULL, NULL);
 		free_irq(irq, dev);
 	} else {
 		dev->irq = irq;
@@ -203,7 +203,7 @@ int drm_irq_uninstall(struct drm_device *dev)
 	DRM_DEBUG("irq=%d\n", dev->irq);
 
 	if (drm_core_check_feature(dev, DRIVER_LEGACY))
-		vga_client_register(dev->pdev, NULL, NULL, NULL);
+		vga_client_register(to_pci_dev(dev->dev), NULL, NULL, NULL);
 
 	if (dev->driver->irq_uninstall)
 		dev->driver->irq_uninstall(dev);
@@ -252,6 +252,7 @@ int drm_legacy_irq_control(struct drm_device *dev, void *data,
 {
 	struct drm_control *ctl = data;
 	int ret = 0, irq;
+	struct pci_dev *pdev;
 
 	/* if we haven't irq we fallback for compatibility reasons -
 	 * this used to be a separate function in drm_dma.h
@@ -262,12 +263,13 @@ int drm_legacy_irq_control(struct drm_device *dev, void *data,
 	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
 		return 0;
 	/* UMS was only ever supported on pci devices. */
-	if (WARN_ON(!dev->pdev))
+	if (WARN_ON(!dev_is_pci(dev->dev)))
 		return -EINVAL;
 
 	switch (ctl->func) {
 	case DRM_INST_HANDLER:
-		irq = dev->pdev->irq;
+		pdev = to_pci_dev(dev->dev);
+		irq = pdev->irq;
 
 		if (dev->if_version < DRM_IF_VERSION(1, 2) &&
 		    ctl->irq != irq)
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 5370e6b492fd..2294a1580d35 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -70,7 +70,7 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
 		return NULL;
 
 	dmah->size = size;
-	dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size,
+	dmah->vaddr = dma_alloc_coherent(dev->dev, size,
 					 &dmah->busaddr,
 					 GFP_KERNEL);
 
@@ -93,7 +93,7 @@ EXPORT_SYMBOL(drm_pci_alloc);
  */
 void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
 {
-	dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
+	dma_free_coherent(dev->dev, dmah->size, dmah->vaddr,
 			  dmah->busaddr);
 	kfree(dmah);
 }
@@ -112,16 +112,18 @@ static int drm_get_pci_domain(struct drm_device *dev)
 		return 0;
 #endif /* __alpha__ */
 
-	return pci_domain_nr(dev->pdev->bus);
+	return pci_domain_nr(to_pci_dev(dev->dev)->bus);
 }
 
 int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+
 	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
 					drm_get_pci_domain(dev),
-					dev->pdev->bus->number,
-					PCI_SLOT(dev->pdev->devfn),
-					PCI_FUNC(dev->pdev->devfn));
+					pdev->bus->number,
+					PCI_SLOT(pdev->devfn),
+					PCI_FUNC(pdev->devfn));
 	if (!master->unique)
 		return -ENOMEM;
 
@@ -131,12 +133,14 @@ int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 
 static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+
 	if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
-	    (p->busnum & 0xff) != dev->pdev->bus->number ||
-	    p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn))
+	    (p->busnum & 0xff) != pdev->bus->number ||
+	    p->devnum != PCI_SLOT(pdev->devfn) || p->funcnum != PCI_FUNC(pdev->devfn))
 		return -EINVAL;
 
-	p->irq = dev->pdev->irq;
+	p->irq = pdev->irq;
 
 	DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum,
 		  p->irq);
@@ -164,7 +168,7 @@ int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
 		return -EOPNOTSUPP;
 
 	/* UMS was only ever support on PCI devices. */
-	if (WARN_ON(!dev->pdev))
+	if (WARN_ON(!dev_is_pci(dev->dev)))
 		return -EINVAL;
 
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
@@ -188,7 +192,7 @@ void drm_pci_agp_destroy(struct drm_device *dev)
 static void drm_pci_agp_init(struct drm_device *dev)
 {
 	if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
-		if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
+		if (pci_find_capability(to_pci_dev(dev->dev), PCI_CAP_ID_AGP))
 			dev->agp = drm_agp_init(dev);
 		if (dev->agp) {
 			dev->agp->agp_mtrr = arch_phys_wc_add(
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 6d5a03b32238..9b3b989d7cad 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -278,7 +278,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
 			case _DRM_SCATTER_GATHER:
 				break;
 			case _DRM_CONSISTENT:
-				dma_free_coherent(&dev->pdev->dev,
+				dma_free_coherent(dev->dev,
 						  map->size,
 						  map->handle,
 						  map->offset);
-- 
2.29.2


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

       reply	other threads:[~2021-01-18  8:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8304b313-9610-08bb-589c-0daa8ff7bd6c@gmail.com>
     [not found] ` <9f067539-07b1-7aa6-3112-0eb25b1b606f@gmail.com>
2021-01-18  8:25   ` Thomas Zimmermann [this message]
2021-01-18  9:14     ` [BUG] DRM kernel NULL pointer dereference (linux-next 20210115) Andy Lavr
2021-01-18  9:22       ` Thomas Zimmermann
2021-01-18 11:09         ` Andy Lavr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7851c78c-8c57-3c84-cd49-a72703095a5d@suse.de \
    --to=tzimmermann@suse.de \
    --cc=alexander.deucher@amd.com \
    --cc=andy.lavr@gmail.com \
    --cc=arnd@arndb.de \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).