Lines Matching +full:device +full:- +full:unique
1 /* drm_pci.h -- PCI DMA memory management wrappers for DRM -*- linux-c -*- */
44 "DRM device");
61 dmah->busaddr = segs[0].ds_addr; in drm_pci_busdma_callback()
73 /* Need power-of-two alignment, so fail the allocation if it isn't. */ in drm_pci_alloc()
74 if ((align & (align - 1)) != 0) { in drm_pci_alloc()
75 DRM_ERROR("drm_pci_alloc with non-power-of-two alignment %d\n", in drm_pci_alloc()
85 mtx_assert(&dev->dma_lock, MA_NOTOWNED); in drm_pci_alloc()
86 if (mtx_owned(&dev->dma_lock)) in drm_pci_alloc()
90 bus_get_dma_tag(dev->dev), /* parent */ in drm_pci_alloc()
96 &dmah->tag); in drm_pci_alloc()
102 ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, in drm_pci_alloc()
103 BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_NOCACHE, &dmah->map); in drm_pci_alloc()
105 bus_dma_tag_destroy(dmah->tag); in drm_pci_alloc()
110 ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr, size, in drm_pci_alloc()
113 bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); in drm_pci_alloc()
114 bus_dma_tag_destroy(dmah->tag); in drm_pci_alloc()
127 * This function is for internal use in the Linux-specific DRM core code.
134 bus_dmamap_unload(dmah->tag, dmah->map); in __drm_pci_free()
135 bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); in __drm_pci_free()
136 bus_dma_tag_destroy(dmah->tag); in __drm_pci_free()
152 return dev->pci_domain; in drm_get_pci_domain()
158 if (dev->irqr) in drm_pci_get_irq()
159 return (dev->irq); in drm_pci_get_irq()
161 dev->irqr = bus_alloc_resource_any(dev->dev, SYS_RES_IRQ, in drm_pci_get_irq()
162 &dev->irqrid, RF_SHAREABLE); in drm_pci_get_irq()
163 if (!dev->irqr) { in drm_pci_get_irq()
164 dev_err(dev->dev, "Failed to allocate IRQ\n"); in drm_pci_get_irq()
168 dev->irq = (int) rman_get_start(dev->irqr); in drm_pci_get_irq()
170 return (dev->irq); in drm_pci_get_irq()
175 if (dev->irqr == NULL) in drm_pci_free_irq()
178 bus_release_resource(dev->dev, SYS_RES_IRQ, in drm_pci_free_irq()
179 dev->irqrid, dev->irqr); in drm_pci_free_irq()
181 dev->irqr = NULL; in drm_pci_free_irq()
182 dev->irq = 0; in drm_pci_free_irq()
187 return dev->driver->name; in drm_pci_get_name()
193 master->unique_len = 40; in drm_pci_set_busid()
194 master->unique_size = master->unique_len; in drm_pci_set_busid()
195 master->unique = malloc(master->unique_size, DRM_MEM_DRIVER, M_NOWAIT); in drm_pci_set_busid()
196 if (master->unique == NULL) in drm_pci_set_busid()
197 return -ENOMEM; in drm_pci_set_busid()
200 len = snprintf(master->unique, master->unique_len, in drm_pci_set_busid()
202 dev->pci_domain, in drm_pci_set_busid()
203 dev->pci_bus, in drm_pci_set_busid()
204 dev->pci_slot, in drm_pci_set_busid()
205 dev->pci_func); in drm_pci_set_busid()
207 if (len >= master->unique_len) { in drm_pci_set_busid()
209 ret = -EINVAL; in drm_pci_set_busid()
212 master->unique_len = len; in drm_pci_set_busid()
225 master->unique_len = u->unique_len; in drm_pci_set_unique()
226 master->unique_size = u->unique_len + 1; in drm_pci_set_unique()
227 master->unique = malloc(master->unique_size, DRM_MEM_DRIVER, M_WAITOK); in drm_pci_set_unique()
228 if (!master->unique) { in drm_pci_set_unique()
229 ret = -ENOMEM; in drm_pci_set_unique()
233 if (copy_from_user(master->unique, u->unique, master->unique_len)) { in drm_pci_set_unique()
234 ret = -EFAULT; in drm_pci_set_unique()
238 master->unique[master->unique_len] = '\0'; in drm_pci_set_unique()
240 /* Return error if the busid submitted doesn't match the device's actual in drm_pci_set_unique()
243 ret = sscanf(master->unique, "PCI:%d:%d:%d", &bus, &slot, &func); in drm_pci_set_unique()
245 ret = -EINVAL; in drm_pci_set_unique()
252 if ((domain != dev->pci_domain) || in drm_pci_set_unique()
253 (bus != dev->pci_bus) || in drm_pci_set_unique()
254 (slot != dev->pci_slot) || in drm_pci_set_unique()
255 (func != dev->pci_func)) { in drm_pci_set_unique()
256 ret = -EINVAL; in drm_pci_set_unique()
267 if ((p->busnum >> 8) != drm_get_pci_domain(dev) || in drm_pci_irq_by_busid()
268 (p->busnum & 0xff) != dev->pci_bus || in drm_pci_irq_by_busid()
269 p->devnum != dev->pci_slot || p->funcnum != dev->pci_func) in drm_pci_irq_by_busid()
270 return -EINVAL; in drm_pci_irq_by_busid()
272 p->irq = dev->irq; in drm_pci_irq_by_busid()
274 DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum, in drm_pci_irq_by_busid()
275 p->irq); in drm_pci_irq_by_busid()
283 dev->agp = drm_agp_init(dev); in drm_pci_agp_init()
285 && (dev->agp == NULL)) { in drm_pci_agp_init()
287 return -EINVAL; in drm_pci_agp_init()
290 if (dev->agp && dev->agp->agp_info.ai_aperture_base != 0) { in drm_pci_agp_init()
291 if (drm_mtrr_add(dev->agp->agp_info.ai_aperture_base, in drm_pci_agp_init()
292 dev->agp->agp_info.ai_aperture_size, DRM_MTRR_WC) == 0) in drm_pci_agp_init()
293 dev->agp->agp_mtrr = 1; in drm_pci_agp_init()
295 dev->agp->agp_mtrr = -1; in drm_pci_agp_init()
316 * \param pdev - PCI device structure
317 * \param ent entry from the PCI ID table with device type flags
321 * then register the character device and inter module information.
331 driver->bus = &drm_pci_bus; in drm_get_pci_dev()
333 dev->dev = kdev; in drm_get_pci_dev()
335 dev->pci_domain = pci_get_domain(dev->dev); in drm_get_pci_dev()
336 dev->pci_bus = pci_get_bus(dev->dev); in drm_get_pci_dev()
337 dev->pci_slot = pci_get_slot(dev->dev); in drm_get_pci_dev()
338 dev->pci_func = pci_get_function(dev->dev); in drm_get_pci_dev()
340 dev->pci_vendor = pci_get_vendor(dev->dev); in drm_get_pci_dev()
341 dev->pci_device = pci_get_device(dev->dev); in drm_get_pci_dev()
342 dev->pci_subvendor = pci_get_subvendor(dev->dev); in drm_get_pci_dev()
343 dev->pci_subdevice = pci_get_subdevice(dev->dev); in drm_get_pci_dev()
353 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); in drm_get_pci_dev()
358 if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY))) in drm_get_pci_dev()
361 if (dev->driver->load) { in drm_get_pci_dev()
362 ret = dev->driver->load(dev, in drm_get_pci_dev()
363 dev->id_entry->driver_private); in drm_get_pci_dev()
371 &dev->primary->mode_group); in drm_get_pci_dev()
377 list_add_tail(&dev->driver_item, &driver->device_list); in drm_get_pci_dev()
381 driver->name, driver->major, driver->minor, driver->patchlevel, in drm_get_pci_dev()
382 driver->date, device_get_nameunit(dev->dev), dev->primary->index); in drm_get_pci_dev()
388 if (dev->driver->unload) in drm_get_pci_dev()
389 dev->driver->unload(dev); in drm_get_pci_dev()
391 drm_put_minor(&dev->primary); in drm_get_pci_dev()
394 drm_put_minor(&dev->control); in drm_get_pci_dev()
409 return (-ENOENT); in drm_pci_enable_msi()
411 msicount = pci_msi_count(dev->dev); in drm_pci_enable_msi()
416 ret = pci_alloc_msi(dev->dev, &msicount); in drm_pci_enable_msi()
419 dev->msi_enabled = 1; in drm_pci_enable_msi()
420 dev->irqrid = 1; in drm_pci_enable_msi()
423 return (-ret); in drm_pci_enable_msi()
430 if (!dev->msi_enabled) in drm_pci_disable_msi()
433 pci_release_msi(dev->dev); in drm_pci_disable_msi()
434 dev->msi_enabled = 0; in drm_pci_disable_msi()
435 dev->irqrid = 0; in drm_pci_disable_msi()
446 return -EINVAL; in drm_pcie_get_speed_cap_mask()
450 device_get_parent( /* `-- pci */ in drm_pcie_get_speed_cap_mask()
451 device_get_parent( /* `-- vgapci */ in drm_pcie_get_speed_cap_mask()
452 dev->dev))); /* `-- drmn */ in drm_pcie_get_speed_cap_mask()
457 return -EINVAL; in drm_pcie_get_speed_cap_mask()
462 return -EINVAL; in drm_pcie_get_speed_cap_mask()
488 …DRM_INFO("probing gen 2 caps for device %x:%x = %x/%x\n", pci_get_vendor(root), pci_get_device(roo… in drm_pcie_get_speed_cap_mask()