| .. | .. |
|---|
| 22 | 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 23 | 23 | */ |
|---|
| 24 | 24 | |
|---|
| 25 | | -#include <linux/pci.h> |
|---|
| 26 | | -#include <linux/slab.h> |
|---|
| 27 | 25 | #include <linux/dma-mapping.h> |
|---|
| 28 | 26 | #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 | + |
|---|
| 31 | 35 | #include "drm_internal.h" |
|---|
| 32 | 36 | #include "drm_legacy.h" |
|---|
| 37 | + |
|---|
| 38 | +#ifdef CONFIG_DRM_LEGACY |
|---|
| 33 | 39 | |
|---|
| 34 | 40 | /** |
|---|
| 35 | 41 | * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA. |
|---|
| .. | .. |
|---|
| 59 | 65 | return NULL; |
|---|
| 60 | 66 | |
|---|
| 61 | 67 | 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); |
|---|
| 63 | 71 | |
|---|
| 64 | 72 | if (dmah->vaddr == NULL) { |
|---|
| 65 | 73 | kfree(dmah); |
|---|
| .. | .. |
|---|
| 68 | 76 | |
|---|
| 69 | 77 | return dmah; |
|---|
| 70 | 78 | } |
|---|
| 71 | | - |
|---|
| 72 | 79 | 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 | | -} |
|---|
| 85 | 80 | |
|---|
| 86 | 81 | /** |
|---|
| 87 | 82 | * drm_pci_free - Free a PCI consistent memory block |
|---|
| .. | .. |
|---|
| 93 | 88 | */ |
|---|
| 94 | 89 | void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) |
|---|
| 95 | 90 | { |
|---|
| 96 | | - __drm_legacy_pci_free(dev, dmah); |
|---|
| 91 | + dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr, |
|---|
| 92 | + dmah->busaddr); |
|---|
| 97 | 93 | kfree(dmah); |
|---|
| 98 | 94 | } |
|---|
| 99 | 95 | |
|---|
| 100 | 96 | EXPORT_SYMBOL(drm_pci_free); |
|---|
| 101 | | - |
|---|
| 102 | | -#ifdef CONFIG_PCI |
|---|
| 97 | +#endif |
|---|
| 103 | 98 | |
|---|
| 104 | 99 | static int drm_get_pci_domain(struct drm_device *dev) |
|---|
| 105 | 100 | { |
|---|
| .. | .. |
|---|
| 161 | 156 | struct drm_irq_busid *p = data; |
|---|
| 162 | 157 | |
|---|
| 163 | 158 | if (!drm_core_check_feature(dev, DRIVER_LEGACY)) |
|---|
| 164 | | - return -EINVAL; |
|---|
| 159 | + return -EOPNOTSUPP; |
|---|
| 165 | 160 | |
|---|
| 166 | 161 | /* UMS was only ever support on PCI devices. */ |
|---|
| 167 | 162 | if (WARN_ON(!dev->pdev)) |
|---|
| 168 | 163 | return -EINVAL; |
|---|
| 169 | 164 | |
|---|
| 170 | 165 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
|---|
| 171 | | - return -EINVAL; |
|---|
| 166 | + return -EOPNOTSUPP; |
|---|
| 172 | 167 | |
|---|
| 173 | 168 | return drm_pci_irq_by_busid(dev, p); |
|---|
| 174 | 169 | } |
|---|
| 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 |
|---|
| 175 | 182 | |
|---|
| 176 | 183 | static void drm_pci_agp_init(struct drm_device *dev) |
|---|
| 177 | 184 | { |
|---|
| .. | .. |
|---|
| 187 | 194 | } |
|---|
| 188 | 195 | } |
|---|
| 189 | 196 | |
|---|
| 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) |
|---|
| 217 | 200 | { |
|---|
| 218 | 201 | struct drm_device *dev; |
|---|
| 219 | 202 | int ret; |
|---|
| .. | .. |
|---|
| 256 | 239 | drm_dev_put(dev); |
|---|
| 257 | 240 | return ret; |
|---|
| 258 | 241 | } |
|---|
| 259 | | -EXPORT_SYMBOL(drm_get_pci_dev); |
|---|
| 260 | 242 | |
|---|
| 261 | 243 | /** |
|---|
| 262 | 244 | * drm_legacy_pci_init - shadow-attach a legacy DRM PCI driver |
|---|
| .. | .. |
|---|
| 305 | 287 | } |
|---|
| 306 | 288 | EXPORT_SYMBOL(drm_legacy_pci_init); |
|---|
| 307 | 289 | |
|---|
| 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 | | - |
|---|
| 319 | 290 | /** |
|---|
| 320 | 291 | * drm_legacy_pci_exit - unregister shadow-attach legacy DRM driver |
|---|
| 321 | 292 | * @driver: DRM device driver |
|---|
| .. | .. |
|---|
| 327 | 298 | void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) |
|---|
| 328 | 299 | { |
|---|
| 329 | 300 | struct drm_device *dev, *tmp; |
|---|
| 301 | + |
|---|
| 330 | 302 | DRM_DEBUG("\n"); |
|---|
| 331 | 303 | |
|---|
| 332 | 304 | if (!(driver->driver_features & DRIVER_LEGACY)) { |
|---|
| .. | .. |
|---|
| 341 | 313 | DRM_INFO("Module unloaded\n"); |
|---|
| 342 | 314 | } |
|---|
| 343 | 315 | EXPORT_SYMBOL(drm_legacy_pci_exit); |
|---|
| 316 | + |
|---|
| 317 | +#endif |
|---|