hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/drm_pci.c
....@@ -22,14 +22,20 @@
2222 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323 */
2424
25
-#include <linux/pci.h>
26
-#include <linux/slab.h>
2725 #include <linux/dma-mapping.h>
2826 #include <linux/export.h>
29
-#include <drm/drm_pci.h>
30
-#include <drm/drmP.h>
27
+#include <linux/pci.h>
28
+#include <linux/slab.h>
29
+
30
+#include <drm/drm.h>
31
+#include <drm/drm_agpsupport.h>
32
+#include <drm/drm_drv.h>
33
+#include <drm/drm_print.h>
34
+
3135 #include "drm_internal.h"
3236 #include "drm_legacy.h"
37
+
38
+#ifdef CONFIG_DRM_LEGACY
3339
3440 /**
3541 * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA.
....@@ -59,7 +65,9 @@
5965 return NULL;
6066
6167 dmah->size = size;
62
- dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL);
68
+ dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size,
69
+ &dmah->busaddr,
70
+ GFP_KERNEL);
6371
6472 if (dmah->vaddr == NULL) {
6573 kfree(dmah);
....@@ -68,20 +76,7 @@
6876
6977 return dmah;
7078 }
71
-
7279 EXPORT_SYMBOL(drm_pci_alloc);
73
-
74
-/*
75
- * Free a PCI consistent memory block without freeing its descriptor.
76
- *
77
- * This function is for internal use in the Linux-specific DRM core code.
78
- */
79
-void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
80
-{
81
- if (dmah->vaddr)
82
- dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
83
- dmah->busaddr);
84
-}
8580
8681 /**
8782 * drm_pci_free - Free a PCI consistent memory block
....@@ -93,13 +88,13 @@
9388 */
9489 void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
9590 {
96
- __drm_legacy_pci_free(dev, dmah);
91
+ dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
92
+ dmah->busaddr);
9793 kfree(dmah);
9894 }
9995
10096 EXPORT_SYMBOL(drm_pci_free);
101
-
102
-#ifdef CONFIG_PCI
97
+#endif
10398
10499 static int drm_get_pci_domain(struct drm_device *dev)
105100 {
....@@ -161,17 +156,29 @@
161156 struct drm_irq_busid *p = data;
162157
163158 if (!drm_core_check_feature(dev, DRIVER_LEGACY))
164
- return -EINVAL;
159
+ return -EOPNOTSUPP;
165160
166161 /* UMS was only ever support on PCI devices. */
167162 if (WARN_ON(!dev->pdev))
168163 return -EINVAL;
169164
170165 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
171
- return -EINVAL;
166
+ return -EOPNOTSUPP;
172167
173168 return drm_pci_irq_by_busid(dev, p);
174169 }
170
+
171
+void drm_pci_agp_destroy(struct drm_device *dev)
172
+{
173
+ if (dev->agp) {
174
+ arch_phys_wc_del(dev->agp->agp_mtrr);
175
+ drm_legacy_agp_clear(dev);
176
+ kfree(dev->agp);
177
+ dev->agp = NULL;
178
+ }
179
+}
180
+
181
+#ifdef CONFIG_DRM_LEGACY
175182
176183 static void drm_pci_agp_init(struct drm_device *dev)
177184 {
....@@ -187,33 +194,9 @@
187194 }
188195 }
189196
190
-void drm_pci_agp_destroy(struct drm_device *dev)
191
-{
192
- if (dev->agp) {
193
- arch_phys_wc_del(dev->agp->agp_mtrr);
194
- drm_legacy_agp_clear(dev);
195
- kfree(dev->agp);
196
- dev->agp = NULL;
197
- }
198
-}
199
-
200
-/**
201
- * drm_get_pci_dev - Register a PCI device with the DRM subsystem
202
- * @pdev: PCI device
203
- * @ent: entry from the PCI ID table that matches @pdev
204
- * @driver: DRM device driver
205
- *
206
- * Attempt to gets inter module "drm" information. If we are first
207
- * then register the character device and inter module information.
208
- * Try and register, if we fail to register, backout previous work.
209
- *
210
- * NOTE: This function is deprecated, please use drm_dev_alloc() and
211
- * drm_dev_register() instead and remove your &drm_driver.load callback.
212
- *
213
- * Return: 0 on success or a negative error code on failure.
214
- */
215
-int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
216
- struct drm_driver *driver)
197
+static int drm_get_pci_dev(struct pci_dev *pdev,
198
+ const struct pci_device_id *ent,
199
+ struct drm_driver *driver)
217200 {
218201 struct drm_device *dev;
219202 int ret;
....@@ -256,7 +239,6 @@
256239 drm_dev_put(dev);
257240 return ret;
258241 }
259
-EXPORT_SYMBOL(drm_get_pci_dev);
260242
261243 /**
262244 * drm_legacy_pci_init - shadow-attach a legacy DRM PCI driver
....@@ -305,17 +287,6 @@
305287 }
306288 EXPORT_SYMBOL(drm_legacy_pci_init);
307289
308
-#else
309
-
310
-void drm_pci_agp_destroy(struct drm_device *dev) {}
311
-
312
-int drm_irq_by_busid(struct drm_device *dev, void *data,
313
- struct drm_file *file_priv)
314
-{
315
- return -EINVAL;
316
-}
317
-#endif
318
-
319290 /**
320291 * drm_legacy_pci_exit - unregister shadow-attach legacy DRM driver
321292 * @driver: DRM device driver
....@@ -327,6 +298,7 @@
327298 void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
328299 {
329300 struct drm_device *dev, *tmp;
301
+
330302 DRM_DEBUG("\n");
331303
332304 if (!(driver->driver_features & DRIVER_LEGACY)) {
....@@ -341,3 +313,5 @@
341313 DRM_INFO("Module unloaded\n");
342314 }
343315 EXPORT_SYMBOL(drm_legacy_pci_exit);
316
+
317
+#endif