drm_pci.c revision 1.6 1 1.6 riastrad /* $NetBSD: drm_pci.c,v 1.6 2018/08/27 04:58:19 riastradh Exp $ */
2 1.1 riastrad
3 1.1 riastrad /*
4 1.1 riastrad * Copyright 2003 Jos Fonseca.
5 1.1 riastrad * Copyright 2003 Leif Delgass.
6 1.1 riastrad * All Rights Reserved.
7 1.1 riastrad *
8 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a
9 1.1 riastrad * copy of this software and associated documentation files (the "Software"),
10 1.1 riastrad * to deal in the Software without restriction, including without limitation
11 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the
13 1.1 riastrad * Software is furnished to do so, subject to the following conditions:
14 1.1 riastrad *
15 1.1 riastrad * The above copyright notice and this permission notice (including the next
16 1.1 riastrad * paragraph) shall be included in all copies or substantial portions of the
17 1.1 riastrad * Software.
18 1.1 riastrad *
19 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 1.1 riastrad * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 1.1 riastrad * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 1.1 riastrad * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 1.1 riastrad */
26 1.1 riastrad
27 1.6 riastrad #include <sys/cdefs.h>
28 1.6 riastrad __KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.6 2018/08/27 04:58:19 riastradh Exp $");
29 1.6 riastrad
30 1.1 riastrad #include <linux/pci.h>
31 1.1 riastrad #include <linux/slab.h>
32 1.1 riastrad #include <linux/dma-mapping.h>
33 1.1 riastrad #include <linux/export.h>
34 1.1 riastrad #include <drm/drmP.h>
35 1.6 riastrad #include "drm_internal.h"
36 1.6 riastrad #include "drm_legacy.h"
37 1.1 riastrad
38 1.1 riastrad /**
39 1.6 riastrad * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA.
40 1.6 riastrad * @dev: DRM device
41 1.6 riastrad * @size: size of block to allocate
42 1.6 riastrad * @align: alignment of block
43 1.6 riastrad *
44 1.6 riastrad * Return: A handle to the allocated memory block on success or NULL on
45 1.6 riastrad * failure.
46 1.1 riastrad */
47 1.1 riastrad drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align)
48 1.1 riastrad {
49 1.1 riastrad drm_dma_handle_t *dmah;
50 1.1 riastrad unsigned long addr;
51 1.1 riastrad size_t sz;
52 1.1 riastrad
53 1.1 riastrad /* pci_alloc_consistent only guarantees alignment to the smallest
54 1.1 riastrad * PAGE_SIZE order which is greater than or equal to the requested size.
55 1.1 riastrad * Return NULL here for now to make sure nobody tries for larger alignment
56 1.1 riastrad */
57 1.1 riastrad if (align > size)
58 1.1 riastrad return NULL;
59 1.1 riastrad
60 1.1 riastrad dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
61 1.1 riastrad if (!dmah)
62 1.1 riastrad return NULL;
63 1.1 riastrad
64 1.1 riastrad dmah->size = size;
65 1.1 riastrad dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP);
66 1.1 riastrad
67 1.1 riastrad if (dmah->vaddr == NULL) {
68 1.1 riastrad kfree(dmah);
69 1.1 riastrad return NULL;
70 1.1 riastrad }
71 1.1 riastrad
72 1.1 riastrad memset(dmah->vaddr, 0, size);
73 1.1 riastrad
74 1.1 riastrad /* XXX - Is virt_to_page() legal for consistent mem? */
75 1.1 riastrad /* Reserve */
76 1.1 riastrad for (addr = (unsigned long)dmah->vaddr, sz = size;
77 1.1 riastrad sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) {
78 1.3 riastrad SetPageReserved(virt_to_page((void *)addr));
79 1.1 riastrad }
80 1.1 riastrad
81 1.1 riastrad return dmah;
82 1.1 riastrad }
83 1.1 riastrad
84 1.1 riastrad EXPORT_SYMBOL(drm_pci_alloc);
85 1.1 riastrad
86 1.6 riastrad /*
87 1.6 riastrad * Free a PCI consistent memory block without freeing its descriptor.
88 1.1 riastrad *
89 1.1 riastrad * This function is for internal use in the Linux-specific DRM core code.
90 1.1 riastrad */
91 1.6 riastrad void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
92 1.1 riastrad {
93 1.1 riastrad unsigned long addr;
94 1.1 riastrad size_t sz;
95 1.1 riastrad
96 1.1 riastrad if (dmah->vaddr) {
97 1.1 riastrad /* XXX - Is virt_to_page() legal for consistent mem? */
98 1.1 riastrad /* Unreserve */
99 1.1 riastrad for (addr = (unsigned long)dmah->vaddr, sz = dmah->size;
100 1.1 riastrad sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) {
101 1.3 riastrad ClearPageReserved(virt_to_page((void *)addr));
102 1.1 riastrad }
103 1.1 riastrad dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
104 1.1 riastrad dmah->busaddr);
105 1.1 riastrad }
106 1.1 riastrad }
107 1.1 riastrad
108 1.1 riastrad /**
109 1.6 riastrad * drm_pci_free - Free a PCI consistent memory block
110 1.6 riastrad * @dev: DRM device
111 1.6 riastrad * @dmah: handle to memory block
112 1.1 riastrad */
113 1.1 riastrad void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
114 1.1 riastrad {
115 1.6 riastrad __drm_legacy_pci_free(dev, dmah);
116 1.1 riastrad kfree(dmah);
117 1.1 riastrad }
118 1.1 riastrad
119 1.1 riastrad EXPORT_SYMBOL(drm_pci_free);
120 1.1 riastrad
121 1.1 riastrad #ifdef CONFIG_PCI
122 1.1 riastrad
123 1.1 riastrad static int drm_get_pci_domain(struct drm_device *dev)
124 1.1 riastrad {
125 1.1 riastrad #ifndef __alpha__
126 1.1 riastrad /* For historical reasons, drm_get_pci_domain() is busticated
127 1.1 riastrad * on most archs and has to remain so for userspace interface
128 1.1 riastrad * < 1.4, except on alpha which was right from the beginning
129 1.1 riastrad */
130 1.1 riastrad if (dev->if_version < 0x10004)
131 1.1 riastrad return 0;
132 1.1 riastrad #endif /* __alpha__ */
133 1.1 riastrad
134 1.1 riastrad return pci_domain_nr(dev->pdev->bus);
135 1.1 riastrad }
136 1.1 riastrad
137 1.6 riastrad int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
138 1.1 riastrad {
139 1.6 riastrad master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
140 1.6 riastrad drm_get_pci_domain(dev),
141 1.6 riastrad dev->pdev->bus->number,
142 1.6 riastrad PCI_SLOT(dev->pdev->devfn),
143 1.6 riastrad PCI_FUNC(dev->pdev->devfn));
144 1.6 riastrad if (!master->unique)
145 1.1 riastrad return -ENOMEM;
146 1.1 riastrad
147 1.6 riastrad master->unique_len = strlen(master->unique);
148 1.1 riastrad return 0;
149 1.1 riastrad }
150 1.6 riastrad EXPORT_SYMBOL(drm_pci_set_busid);
151 1.1 riastrad
152 1.6 riastrad int drm_pci_set_unique(struct drm_device *dev,
153 1.6 riastrad struct drm_master *master,
154 1.6 riastrad struct drm_unique *u)
155 1.1 riastrad {
156 1.1 riastrad int domain, bus, slot, func, ret;
157 1.1 riastrad
158 1.1 riastrad master->unique_len = u->unique_len;
159 1.6 riastrad master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
160 1.1 riastrad if (!master->unique) {
161 1.1 riastrad ret = -ENOMEM;
162 1.1 riastrad goto err;
163 1.1 riastrad }
164 1.1 riastrad
165 1.1 riastrad if (copy_from_user(master->unique, u->unique, master->unique_len)) {
166 1.1 riastrad ret = -EFAULT;
167 1.1 riastrad goto err;
168 1.1 riastrad }
169 1.1 riastrad
170 1.1 riastrad master->unique[master->unique_len] = '\0';
171 1.1 riastrad
172 1.1 riastrad /* Return error if the busid submitted doesn't match the device's actual
173 1.1 riastrad * busid.
174 1.1 riastrad */
175 1.1 riastrad ret = sscanf(master->unique, "PCI:%d:%d:%d", &bus, &slot, &func);
176 1.1 riastrad if (ret != 3) {
177 1.1 riastrad ret = -EINVAL;
178 1.1 riastrad goto err;
179 1.1 riastrad }
180 1.1 riastrad
181 1.1 riastrad domain = bus >> 8;
182 1.1 riastrad bus &= 0xff;
183 1.1 riastrad
184 1.1 riastrad if ((domain != drm_get_pci_domain(dev)) ||
185 1.1 riastrad (bus != dev->pdev->bus->number) ||
186 1.1 riastrad (slot != PCI_SLOT(dev->pdev->devfn)) ||
187 1.1 riastrad (func != PCI_FUNC(dev->pdev->devfn))) {
188 1.1 riastrad ret = -EINVAL;
189 1.1 riastrad goto err;
190 1.1 riastrad }
191 1.1 riastrad return 0;
192 1.1 riastrad err:
193 1.1 riastrad return ret;
194 1.1 riastrad }
195 1.1 riastrad
196 1.1 riastrad static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
197 1.1 riastrad {
198 1.1 riastrad if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
199 1.1 riastrad (p->busnum & 0xff) != dev->pdev->bus->number ||
200 1.1 riastrad p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn))
201 1.1 riastrad return -EINVAL;
202 1.1 riastrad
203 1.1 riastrad p->irq = dev->pdev->irq;
204 1.1 riastrad
205 1.1 riastrad DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum,
206 1.1 riastrad p->irq);
207 1.1 riastrad return 0;
208 1.1 riastrad }
209 1.1 riastrad
210 1.6 riastrad /**
211 1.6 riastrad * drm_irq_by_busid - Get interrupt from bus ID
212 1.6 riastrad * @dev: DRM device
213 1.6 riastrad * @data: IOCTL parameter pointing to a drm_irq_busid structure
214 1.6 riastrad * @file_priv: DRM file private.
215 1.6 riastrad *
216 1.6 riastrad * Finds the PCI device with the specified bus id and gets its IRQ number.
217 1.6 riastrad * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
218 1.6 riastrad * to that of the device that this DRM instance attached to.
219 1.6 riastrad *
220 1.6 riastrad * Return: 0 on success or a negative error code on failure.
221 1.6 riastrad */
222 1.6 riastrad int drm_irq_by_busid(struct drm_device *dev, void *data,
223 1.6 riastrad struct drm_file *file_priv)
224 1.6 riastrad {
225 1.6 riastrad struct drm_irq_busid *p = data;
226 1.6 riastrad
227 1.6 riastrad if (drm_core_check_feature(dev, DRIVER_MODESET))
228 1.6 riastrad return -EINVAL;
229 1.6 riastrad
230 1.6 riastrad /* UMS was only ever support on PCI devices. */
231 1.6 riastrad if (WARN_ON(!dev->pdev))
232 1.6 riastrad return -EINVAL;
233 1.6 riastrad
234 1.6 riastrad if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
235 1.6 riastrad return -EINVAL;
236 1.6 riastrad
237 1.6 riastrad return drm_pci_irq_by_busid(dev, p);
238 1.6 riastrad }
239 1.6 riastrad
240 1.3 riastrad static void drm_pci_agp_init(struct drm_device *dev)
241 1.1 riastrad {
242 1.3 riastrad if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
243 1.1 riastrad if (drm_pci_device_is_agp(dev))
244 1.1 riastrad dev->agp = drm_agp_init(dev);
245 1.3 riastrad if (dev->agp) {
246 1.3 riastrad dev->agp->agp_mtrr = arch_phys_wc_add(
247 1.3 riastrad dev->agp->agp_info.aper_base,
248 1.3 riastrad dev->agp->agp_info.aper_size *
249 1.3 riastrad 1024 * 1024);
250 1.1 riastrad }
251 1.1 riastrad }
252 1.3 riastrad }
253 1.3 riastrad
254 1.3 riastrad void drm_pci_agp_destroy(struct drm_device *dev)
255 1.3 riastrad {
256 1.5 riastrad if (dev->agp) {
257 1.5 riastrad arch_phys_wc_del(dev->agp->agp_mtrr);
258 1.5 riastrad drm_agp_clear(dev);
259 1.5 riastrad kfree(dev->agp);
260 1.5 riastrad dev->agp = NULL;
261 1.5 riastrad }
262 1.1 riastrad }
263 1.1 riastrad
264 1.1 riastrad /**
265 1.6 riastrad * drm_get_pci_dev - Register a PCI device with the DRM subsystem
266 1.6 riastrad * @pdev: PCI device
267 1.6 riastrad * @ent: entry from the PCI ID table that matches @pdev
268 1.6 riastrad * @driver: DRM device driver
269 1.1 riastrad *
270 1.1 riastrad * Attempt to gets inter module "drm" information. If we are first
271 1.1 riastrad * then register the character device and inter module information.
272 1.1 riastrad * Try and register, if we fail to register, backout previous work.
273 1.6 riastrad *
274 1.6 riastrad * NOTE: This function is deprecated, please use drm_dev_alloc() and
275 1.6 riastrad * drm_dev_register() instead and remove your ->load() callback.
276 1.6 riastrad *
277 1.6 riastrad * Return: 0 on success or a negative error code on failure.
278 1.1 riastrad */
279 1.1 riastrad int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
280 1.1 riastrad struct drm_driver *driver)
281 1.1 riastrad {
282 1.1 riastrad struct drm_device *dev;
283 1.1 riastrad int ret;
284 1.1 riastrad
285 1.1 riastrad DRM_DEBUG("\n");
286 1.1 riastrad
287 1.3 riastrad dev = drm_dev_alloc(driver, &pdev->dev);
288 1.1 riastrad if (!dev)
289 1.1 riastrad return -ENOMEM;
290 1.1 riastrad
291 1.1 riastrad ret = pci_enable_device(pdev);
292 1.1 riastrad if (ret)
293 1.3 riastrad goto err_free;
294 1.1 riastrad
295 1.1 riastrad dev->pdev = pdev;
296 1.1 riastrad #ifdef __alpha__
297 1.1 riastrad dev->hose = pdev->sysdata;
298 1.1 riastrad #endif
299 1.1 riastrad
300 1.3 riastrad if (drm_core_check_feature(dev, DRIVER_MODESET))
301 1.1 riastrad pci_set_drvdata(pdev, dev);
302 1.1 riastrad
303 1.3 riastrad drm_pci_agp_init(dev);
304 1.1 riastrad
305 1.3 riastrad ret = drm_dev_register(dev, ent->driver_data);
306 1.3 riastrad if (ret)
307 1.3 riastrad goto err_agp;
308 1.1 riastrad
309 1.1 riastrad DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
310 1.1 riastrad driver->name, driver->major, driver->minor, driver->patchlevel,
311 1.1 riastrad driver->date, pci_name(pdev), dev->primary->index);
312 1.1 riastrad
313 1.3 riastrad /* No locking needed since shadow-attach is single-threaded since it may
314 1.3 riastrad * only be called from the per-driver module init hook. */
315 1.3 riastrad if (!drm_core_check_feature(dev, DRIVER_MODESET))
316 1.3 riastrad list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
317 1.3 riastrad
318 1.1 riastrad return 0;
319 1.1 riastrad
320 1.3 riastrad err_agp:
321 1.3 riastrad drm_pci_agp_destroy(dev);
322 1.1 riastrad pci_disable_device(pdev);
323 1.3 riastrad err_free:
324 1.3 riastrad drm_dev_unref(dev);
325 1.1 riastrad return ret;
326 1.1 riastrad }
327 1.1 riastrad EXPORT_SYMBOL(drm_get_pci_dev);
328 1.1 riastrad
329 1.1 riastrad /**
330 1.6 riastrad * drm_pci_init - Register matching PCI devices with the DRM subsystem
331 1.6 riastrad * @driver: DRM device driver
332 1.6 riastrad * @pdriver: PCI device driver
333 1.6 riastrad *
334 1.6 riastrad * Initializes a drm_device structures, registering the stubs and initializing
335 1.6 riastrad * the AGP device.
336 1.6 riastrad *
337 1.6 riastrad * NOTE: This function is deprecated. Modern modesetting drm drivers should use
338 1.6 riastrad * pci_register_driver() directly, this function only provides shadow-binding
339 1.6 riastrad * support for old legacy drivers on top of that core pci function.
340 1.1 riastrad *
341 1.6 riastrad * Return: 0 on success or a negative error code on failure.
342 1.1 riastrad */
343 1.1 riastrad int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
344 1.1 riastrad {
345 1.1 riastrad struct pci_dev *pdev = NULL;
346 1.1 riastrad const struct pci_device_id *pid;
347 1.1 riastrad int i;
348 1.1 riastrad
349 1.1 riastrad DRM_DEBUG("\n");
350 1.1 riastrad
351 1.1 riastrad if (driver->driver_features & DRIVER_MODESET)
352 1.1 riastrad return pci_register_driver(pdriver);
353 1.1 riastrad
354 1.1 riastrad /* If not using KMS, fall back to stealth mode manual scanning. */
355 1.3 riastrad INIT_LIST_HEAD(&driver->legacy_dev_list);
356 1.1 riastrad for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
357 1.1 riastrad pid = &pdriver->id_table[i];
358 1.1 riastrad
359 1.1 riastrad /* Loop around setting up a DRM device for each PCI device
360 1.1 riastrad * matching our ID and device class. If we had the internal
361 1.1 riastrad * function that pci_get_subsys and pci_get_class used, we'd
362 1.1 riastrad * be able to just pass pid in instead of doing a two-stage
363 1.1 riastrad * thing.
364 1.1 riastrad */
365 1.1 riastrad pdev = NULL;
366 1.1 riastrad while ((pdev =
367 1.1 riastrad pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
368 1.1 riastrad pid->subdevice, pdev)) != NULL) {
369 1.1 riastrad if ((pdev->class & pid->class_mask) != pid->class)
370 1.1 riastrad continue;
371 1.1 riastrad
372 1.1 riastrad /* stealth mode requires a manual probe */
373 1.1 riastrad pci_dev_get(pdev);
374 1.1 riastrad drm_get_pci_dev(pdev, pid, driver);
375 1.1 riastrad }
376 1.1 riastrad }
377 1.1 riastrad return 0;
378 1.1 riastrad }
379 1.1 riastrad
380 1.1 riastrad int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask)
381 1.1 riastrad {
382 1.1 riastrad struct pci_dev *root;
383 1.3 riastrad u32 lnkcap, lnkcap2;
384 1.1 riastrad
385 1.1 riastrad *mask = 0;
386 1.1 riastrad if (!dev->pdev)
387 1.1 riastrad return -EINVAL;
388 1.1 riastrad
389 1.1 riastrad root = dev->pdev->bus->self;
390 1.1 riastrad
391 1.1 riastrad /* we've been informed via and serverworks don't make the cut */
392 1.1 riastrad if (root->vendor == PCI_VENDOR_ID_VIA ||
393 1.1 riastrad root->vendor == PCI_VENDOR_ID_SERVERWORKS)
394 1.1 riastrad return -EINVAL;
395 1.1 riastrad
396 1.3 riastrad pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap);
397 1.3 riastrad pcie_capability_read_dword(root, PCI_EXP_LNKCAP2, &lnkcap2);
398 1.1 riastrad
399 1.3 riastrad if (lnkcap2) { /* PCIe r3.0-compliant */
400 1.1 riastrad if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_2_5GB)
401 1.1 riastrad *mask |= DRM_PCIE_SPEED_25;
402 1.1 riastrad if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_5_0GB)
403 1.1 riastrad *mask |= DRM_PCIE_SPEED_50;
404 1.1 riastrad if (lnkcap2 & PCI_EXP_LNKCAP2_SLS_8_0GB)
405 1.1 riastrad *mask |= DRM_PCIE_SPEED_80;
406 1.3 riastrad } else { /* pre-r3.0 */
407 1.3 riastrad if (lnkcap & PCI_EXP_LNKCAP_SLS_2_5GB)
408 1.1 riastrad *mask |= DRM_PCIE_SPEED_25;
409 1.3 riastrad if (lnkcap & PCI_EXP_LNKCAP_SLS_5_0GB)
410 1.3 riastrad *mask |= (DRM_PCIE_SPEED_25 | DRM_PCIE_SPEED_50);
411 1.1 riastrad }
412 1.1 riastrad
413 1.1 riastrad DRM_INFO("probing gen 2 caps for device %x:%x = %x/%x\n", root->vendor, root->device, lnkcap, lnkcap2);
414 1.1 riastrad return 0;
415 1.1 riastrad }
416 1.1 riastrad EXPORT_SYMBOL(drm_pcie_get_speed_cap_mask);
417 1.3 riastrad
418 1.3 riastrad #else
419 1.3 riastrad
420 1.3 riastrad int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
421 1.3 riastrad {
422 1.3 riastrad return -1;
423 1.3 riastrad }
424 1.3 riastrad
425 1.3 riastrad void drm_pci_agp_destroy(struct drm_device *dev) {}
426 1.6 riastrad
427 1.6 riastrad int drm_irq_by_busid(struct drm_device *dev, void *data,
428 1.6 riastrad struct drm_file *file_priv)
429 1.6 riastrad {
430 1.6 riastrad return -EINVAL;
431 1.6 riastrad }
432 1.6 riastrad
433 1.6 riastrad int drm_pci_set_unique(struct drm_device *dev,
434 1.6 riastrad struct drm_master *master,
435 1.6 riastrad struct drm_unique *u)
436 1.6 riastrad {
437 1.6 riastrad return -EINVAL;
438 1.6 riastrad }
439 1.3 riastrad #endif
440 1.3 riastrad
441 1.3 riastrad EXPORT_SYMBOL(drm_pci_init);
442 1.3 riastrad
443 1.6 riastrad /**
444 1.6 riastrad * drm_pci_exit - Unregister matching PCI devices from the DRM subsystem
445 1.6 riastrad * @driver: DRM device driver
446 1.6 riastrad * @pdriver: PCI device driver
447 1.6 riastrad *
448 1.6 riastrad * Unregisters one or more devices matched by a PCI driver from the DRM
449 1.6 riastrad * subsystem.
450 1.6 riastrad *
451 1.6 riastrad * NOTE: This function is deprecated. Modern modesetting drm drivers should use
452 1.6 riastrad * pci_unregister_driver() directly, this function only provides shadow-binding
453 1.6 riastrad * support for old legacy drivers on top of that core pci function.
454 1.6 riastrad */
455 1.3 riastrad void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
456 1.3 riastrad {
457 1.3 riastrad struct drm_device *dev, *tmp;
458 1.3 riastrad DRM_DEBUG("\n");
459 1.3 riastrad
460 1.3 riastrad if (driver->driver_features & DRIVER_MODESET) {
461 1.3 riastrad pci_unregister_driver(pdriver);
462 1.3 riastrad } else {
463 1.3 riastrad list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
464 1.3 riastrad legacy_dev_list) {
465 1.3 riastrad list_del(&dev->legacy_dev_list);
466 1.3 riastrad drm_put_dev(dev);
467 1.3 riastrad }
468 1.3 riastrad }
469 1.3 riastrad DRM_INFO("Module unloaded\n");
470 1.3 riastrad }
471 1.3 riastrad EXPORT_SYMBOL(drm_pci_exit);
472