aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_pci.c')
-rw-r--r--drivers/gpu/drm/drm_pci.c46
1 files changed, 13 insertions, 33 deletions
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 020cfd934854..fd29f03645b8 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -27,6 +27,7 @@
27#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/export.h> 28#include <linux/export.h>
29#include <drm/drmP.h> 29#include <drm/drmP.h>
30#include "drm_legacy.h"
30 31
31/** 32/**
32 * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA. 33 * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA.
@@ -81,7 +82,7 @@ EXPORT_SYMBOL(drm_pci_alloc);
81 * 82 *
82 * This function is for internal use in the Linux-specific DRM core code. 83 * This function is for internal use in the Linux-specific DRM core code.
83 */ 84 */
84void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) 85void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
85{ 86{
86 unsigned long addr; 87 unsigned long addr;
87 size_t sz; 88 size_t sz;
@@ -105,7 +106,7 @@ void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
105 */ 106 */
106void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) 107void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
107{ 108{
108 __drm_pci_free(dev, dmah); 109 __drm_legacy_pci_free(dev, dmah);
109 kfree(dmah); 110 kfree(dmah);
110} 111}
111 112
@@ -127,34 +128,20 @@ static int drm_get_pci_domain(struct drm_device *dev)
127 return pci_domain_nr(dev->pdev->bus); 128 return pci_domain_nr(dev->pdev->bus);
128} 129}
129 130
130static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) 131int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
131{ 132{
132 int len, ret; 133 master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
133 master->unique_len = 40; 134 drm_get_pci_domain(dev),
134 master->unique_size = master->unique_len; 135 dev->pdev->bus->number,
135 master->unique = kmalloc(master->unique_size, GFP_KERNEL); 136 PCI_SLOT(dev->pdev->devfn),
136 if (master->unique == NULL) 137 PCI_FUNC(dev->pdev->devfn));
138 if (!master->unique)
137 return -ENOMEM; 139 return -ENOMEM;
138 140
139 141 master->unique_len = strlen(master->unique);
140 len = snprintf(master->unique, master->unique_len,
141 "pci:%04x:%02x:%02x.%d",
142 drm_get_pci_domain(dev),
143 dev->pdev->bus->number,
144 PCI_SLOT(dev->pdev->devfn),
145 PCI_FUNC(dev->pdev->devfn));
146
147 if (len >= master->unique_len) {
148 DRM_ERROR("buffer overflow");
149 ret = -EINVAL;
150 goto err;
151 } else
152 master->unique_len = len;
153
154 return 0; 142 return 0;
155err:
156 return ret;
157} 143}
144EXPORT_SYMBOL(drm_pci_set_busid);
158 145
159int drm_pci_set_unique(struct drm_device *dev, 146int drm_pci_set_unique(struct drm_device *dev,
160 struct drm_master *master, 147 struct drm_master *master,
@@ -163,8 +150,7 @@ int drm_pci_set_unique(struct drm_device *dev,
163 int domain, bus, slot, func, ret; 150 int domain, bus, slot, func, ret;
164 151
165 master->unique_len = u->unique_len; 152 master->unique_len = u->unique_len;
166 master->unique_size = u->unique_len + 1; 153 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
167 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
168 if (!master->unique) { 154 if (!master->unique) {
169 ret = -ENOMEM; 155 ret = -ENOMEM;
170 goto err; 156 goto err;
@@ -269,10 +255,6 @@ void drm_pci_agp_destroy(struct drm_device *dev)
269 } 255 }
270} 256}
271 257
272static struct drm_bus drm_pci_bus = {
273 .set_busid = drm_pci_set_busid,
274};
275
276/** 258/**
277 * drm_get_pci_dev - Register a PCI device with the DRM subsystem 259 * drm_get_pci_dev - Register a PCI device with the DRM subsystem
278 * @pdev: PCI device 260 * @pdev: PCI device
@@ -353,8 +335,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
353 335
354 DRM_DEBUG("\n"); 336 DRM_DEBUG("\n");
355 337
356 driver->bus = &drm_pci_bus;
357
358 if (driver->driver_features & DRIVER_MODESET) 338 if (driver->driver_features & DRIVER_MODESET)
359 return pci_register_driver(pdriver); 339 return pci_register_driver(pdriver);
360 340