summaryrefslogtreecommitdiff
path: root/graphics/drm-515-kmod/files/extra-patch-linuxkpi-pci
blob: 220f7c3f8e9d1c70e1a0eb18b20109e8cf0206bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
commit 20829888caf411a4ac5a4349cbb013334e0b31de
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: Thu Jul 31 07:31:38 2025 +0000
Commit:     Jean-Sébastien Pédron <jean-sebastien.pedron@dumbbell.fr>
CommitDate: Sat Aug 9 16:13:12 2025 +0200

    drm: use LinuxKPI PCI functions rather than bsd native
    
    LinuxKPI seems to provide everything needed here, which allows
    us to remove the special casing for FreeBSD.
    Switch from bsddev and FreeBSD native functions to LinuxKPI
    variables and functions/macros; this will avoid conflicts with
    upcoming additions to LinuxKPI.
    
    Sponsored by:   The FreeBSD Foundation

diff --git drivers/gpu/drm/drm_pci.c drivers/gpu/drm/drm_pci.c
index b7fcd9ea0b..2798d55a48 100644
--- drivers/gpu/drm/drm_pci.c
+++ drivers/gpu/drm/drm_pci.c
@@ -57,30 +57,18 @@ static int drm_get_pci_domain(struct drm_device *dev)
 		return 0;
 #endif /* __alpha__ */
 
-#ifdef __FreeBSD__
-	return pci_get_domain(dev->dev->bsddev);
-#else
 	return pci_domain_nr(to_pci_dev(dev->dev)->bus);
-#endif
 }
 
 int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 {
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
-#ifdef __FreeBSD__
-	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
-					drm_get_pci_domain(dev),
-					pci_get_bus(dev->dev->bsddev),
-					pci_get_slot(dev->dev->bsddev),
-					PCI_FUNC(pdev->devfn));
-#else
 	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
 					drm_get_pci_domain(dev),
 					pdev->bus->number,
 					PCI_SLOT(pdev->devfn),
 					PCI_FUNC(pdev->devfn));
-#endif
 	if (!master->unique)
 		return -ENOMEM;
 
@@ -93,16 +81,17 @@ int
 drm_getpciinfo(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
 	struct drm_pciinfo *info = data;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
-	info->domain = pci_get_domain(dev->dev->bsddev);
-	info->bus = pci_get_bus(dev->dev->bsddev);
-	info->dev = pci_get_slot(dev->dev->bsddev);
-	info->func = pci_get_function(dev->dev->bsddev);
-	info->vendor_id = pci_get_vendor(dev->dev->bsddev);
-	info->device_id = pci_get_device(dev->dev->bsddev);
-	info->subvendor_id = pci_get_subvendor(dev->dev->bsddev);
-	info->subdevice_id = pci_get_subdevice(dev->dev->bsddev);
-	info->revision_id = pci_get_revid(dev->dev->bsddev);
+	info->domain = drm_get_pci_domain(dev);
+	info->bus = pdev->bus->number;
+	info->dev = PCI_SLOT(pdev->devfn);
+	info->func = PCI_FUNC(pdev->devfn);
+	info->vendor_id = pdev->vendor;
+	info->device_id = pdev->device;
+	info->subvendor_id = pdev->subsystem_vendor;
+	info->subdevice_id = pdev->subsystem_device;
+	info->revision_id = pdev->revision;
 
 	return 0;
 }
diff --git drivers/gpu/drm/drm_sysctl_freebsd.c drivers/gpu/drm/drm_sysctl_freebsd.c
index b6dd16b5b5..b9eca7a53c 100644
--- drivers/gpu/drm/drm_sysctl_freebsd.c
+++ drivers/gpu/drm/drm_sysctl_freebsd.c
@@ -170,14 +170,13 @@ drm_add_busid_modesetting(struct drm_device *dev, struct sysctl_ctx_list *ctx,
     struct sysctl_oid *top)
 {
 	struct sysctl_oid *oid;
-	device_t bsddev;
 	int domain, bus, slot, func;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
-	bsddev = dev->dev->bsddev;
-	domain = pci_get_domain(bsddev);
-	bus    = pci_get_bus(bsddev);
-	slot   = pci_get_slot(bsddev);
-	func   = pci_get_function(bsddev);
+	domain = pci_domain_nr(pdev->bus);
+	bus    = pdev->bus->number;
+	slot   = PCI_SLOT(pdev->devfn);
+	func   = PCI_FUNC(pdev->devfn);
 
 	snprintf(dev->busid_str, sizeof(dev->busid_str),
 	    "pci:%04x:%02x:%02x.%d", domain, bus, slot, func);