summaryrefslogtreecommitdiff
path: root/linux-core/drmP.h
AgeCommit message (Expand)Author
2001-02-16- Clean up the way customization of the templates is done.Gareth Hughes
2001-02-15Merge mga-1-0-0-branch into trunk.Gareth Hughes
2001-01-24- Misc cleanups.Gareth Hughes
2000-11-15Sync with Linux 2.4.0-test11-pre5 Provide backward compatibility testedRik Faith
2000-11-08merge with 4.0.1dDavid Dawes
2000-09-29More changes for sync with Linux 2.4.0-test9-pre7Rik Faith
2000-09-29Audit calls to schedule() Remove tags from files shared with Linux kernelRik Faith
2000-09-27Merged the mga-lock-debug-0-2-0-branch with the trunk. This includesJeff Hartmann
2000-09-24commit xfree86 4.0.1d-pre updateAlan Hourihane
2000-09-07Merged tdfx-2-1-branchAlan Hourihane
2000-08-28Add compatibility header file to make Linux 2.4.0 kernel patches cleaner.Rik Faith
2000-08-26Sync with Linux 2.4.0-test7 Add signal blocking support to all driversRik Faith
2000-08-18Fix ABA problem in drm_freelist_{put,try}Rik Faith
2000-08-18Sync with Linux 2.4.0-test7/pre4Rik Faith
2000-08-08Sync with Linux 2.4.0-test6-pre8Rik Faith
2000-08-07Fix for multiple sarea bug + agp built into kernel segfaultJeff Hartmann
2000-08-04Sync with Linux 2.4.0-test6-pre2Rik Faith
2000-07-21Revert some changes and try alternative way to clean up AGP handling.Rik Faith
2000-07-21Changes to make AGP optional for in-kernel buildsRik Faith
2000-07-20More fixups for kernel build: EXPORT_SYMTAB warning removalRik Faith
2000-07-20Fixes for building in the kernel treeRik Faith
2000-07-20Fixed for monolithic kernel buildRik Faith
2000-07-20Added support for building as modules or as part of monolithic kernelRik Faith
2000-06-13Unify code with kernel: Change some spacing in comments Add #includeRik Faith
2000-06-08Merged glxmisc-3-0-0Brian Paul
2000-05-18Merged ati-4-0-1Kevin E Martin
2000-04-04Merged mga branch with trunkJeff Hartmann
2000-03-16Merge with 4.0Jeff Hartmann
2000-02-223.9.18 mergeKevin E Martin
2000-01-12Add a drm_poll function to the tdfx driver. This fixes the problem withDaryll Strauss
2000-01-06Import of XFree86 3.9.17Rik Faith
1999-12-07Move Mesa to xc/extras Update to the latest Mesa 3.2 code Fix the Q3DemoDaryll Strauss
1999-12-05First DRI release of 3dfx driver.Daryll Strauss
e <linux/pci.h> #include <linux/dma-mapping.h> #include "drmP.h" /**********************************************************************/ /** \name PCI memory */ /*@{*/ /** * \brief Allocate a PCI consistent memory block, for DMA. */ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t align, dma_addr_t maxaddr) { drm_dma_handle_t *dmah; unsigned long addr; size_t sz; #ifdef DRM_DEBUG_MEMORY int area = DRM_MEM_DMA; spin_lock(&drm_mem_lock); if ((drm_ram_used >> PAGE_SHIFT) > (DRM_RAM_PERCENT * drm_ram_available) / 100) { spin_unlock(&drm_mem_lock); return 0; } spin_unlock(&drm_mem_lock); #endif /* pci_alloc_consistent only guarantees alignment to the smallest * PAGE_SIZE order which is greater than or equal to the requested size. * Return NULL here for now to make sure nobody tries for larger alignment */ if (align > size) return NULL; if (pci_set_dma_mask(dev->pdev, maxaddr) != 0) { DRM_ERROR("Setting pci dma mask failed\n"); return NULL; } dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL); if (!dmah) return NULL; dmah->size = size; dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP); #ifdef DRM_DEBUG_MEMORY if (dmah->vaddr == NULL) { spin_lock(&drm_mem_lock); ++drm_mem_stats[area].fail_count; spin_unlock(&drm_mem_lock); kfree(dmah); return NULL; } spin_lock(&drm_mem_lock); ++drm_mem_stats[area].succeed_count; drm_mem_stats[area].bytes_allocated += size; drm_ram_used += size; spin_unlock(&drm_mem_lock); #else if (dmah->vaddr == NULL) { kfree(dmah); return NULL; } #endif memset(dmah->vaddr, 0, size); /* XXX - Is virt_to_page() legal for consistent mem? */ /* Reserve */ for (addr = (unsigned long)dmah->vaddr, sz = size; sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { SetPageReserved(virt_to_page(addr)); } return dmah; } EXPORT_SYMBOL(drm_pci_alloc); /** * \brief Free a PCI consistent memory block without freeing its descriptor. * * This function is for internal use in the Linux-specific DRM core code. */ void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah) { unsigned long addr; size_t sz; #ifdef DRM_DEBUG_MEMORY int area = DRM_MEM_DMA; int alloc_count; int free_count; #endif if (!dmah->vaddr) { #ifdef DRM_DEBUG_MEMORY DRM_MEM_ERROR(area, "Attempt to free address 0\n"); #endif } else { /* XXX - Is virt_to_page() legal for consistent mem? */ /* Unreserve */ for (addr = (unsigned long)dmah->vaddr, sz = dmah->size; sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { ClearPageReserved(virt_to_page(addr)); } dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr, dmah->busaddr); } #ifdef DRM_DEBUG_MEMORY spin_lock(&drm_mem_lock); free_count = ++drm_mem_stats[area].free_count; alloc_count = drm_mem_stats[area].succeed_count; drm_mem_stats[area].bytes_freed += size; drm_ram_used -= size; spin_unlock(&drm_mem_lock); if (free_count > alloc_count) { DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n", free_count, alloc_count); } #endif } /** * \brief Free a PCI consistent memory block */ void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah) { __drm_pci_free(dev, dmah); kfree(dmah); } EXPORT_SYMBOL(drm_pci_free); /*@}*/