diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-02-15 20:00:12 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-02-15 20:00:12 +0000 |
commit | d89a715085865454fa49dd0fde0f0078228514e0 (patch) | |
tree | 6ce1498d14296ab1de9e26785a53d7221ad40340 | |
parent | 31270a9e42f09724e0cc58b02814464d38ff6877 (diff) |
convert the pcigart case where the gart table is in system memory over
to use the new api.
More cleanup to this file coming soon.
-rw-r--r-- | sys/dev/pci/drm/ati_pcigart.c | 85 | ||||
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 15 |
2 files changed, 36 insertions, 64 deletions
diff --git a/sys/dev/pci/drm/ati_pcigart.c b/sys/dev/pci/drm/ati_pcigart.c index 0bcf23b1bd2..0d849848e90 100644 --- a/sys/dev/pci/drm/ati_pcigart.c +++ b/sys/dev/pci/drm/ati_pcigart.c @@ -39,31 +39,6 @@ #define ATI_PCIE_WRITE 0x4 #define ATI_PCIE_READ 0x8 -int drm_ati_alloc_pcigart_table(struct drm_device *, - struct drm_ati_pcigart_info *); -void drm_ati_free_pcigart_table(struct drm_device *, - struct drm_ati_pcigart_info *); - -int -drm_ati_alloc_pcigart_table(struct drm_device *dev, - struct drm_ati_pcigart_info *gart_info) -{ - dev->sg->dmah = drm_pci_alloc(dev->dmat, gart_info->table_size, - PAGE_SIZE, gart_info->table_mask); - if (dev->sg->dmah == NULL) - return ENOMEM; - - return 0; -} - -void -drm_ati_free_pcigart_table(struct drm_device *dev, - struct drm_ati_pcigart_info *gart_info) -{ - drm_pci_free(dev->dmat, dev->sg->dmah); - dev->sg->dmah = NULL; -} - int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) @@ -76,9 +51,12 @@ drm_ati_pcigart_cleanup(struct drm_device *dev, if (gart_info->bus_addr) { gart_info->bus_addr = 0; + gart_info->addr = 0; if (gart_info->gart_table_location == DRM_ATI_GART_MAIN && - dev->sg->dmah != NULL) - drm_ati_free_pcigart_table(dev, gart_info); + gart_info->mem != NULL) { + drm_dmamem_free(dev->dmat, gart_info->mem); + gart_info->mem = NULL; + } } return 1; @@ -89,56 +67,49 @@ drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) { - void *address = NULL; - unsigned long pages; - u32 *pci_gart, page_base; - dma_addr_t bus_address = 0; - int i, j, ret = 0; - int max_pages; - dma_addr_t entry_addr; + u_int32_t *pci_gart, page_base; + bus_addr_t entry_addr; + u_long pages, max_pages; + int i, j, ret = 0; /* we need to support large memory configurations */ if (dev->sg == NULL) { DRM_ERROR("no scatter/gather memory!\n"); - goto done; + goto error; } if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n"); - ret = drm_ati_alloc_pcigart_table(dev, gart_info); - if (ret) { + gart_info->mem = drm_dmamem_alloc(dev->dmat, + gart_info->table_size, PAGE_SIZE, 1, + gart_info->table_size, 0, 0); + if (gart_info->mem == NULL) { DRM_ERROR("cannot allocate PCI GART page!\n"); - goto done; + goto error; } - address = (void *)dev->sg->dmah->vaddr; - bus_address = dev->sg->dmah->busaddr; + gart_info->addr = gart_info->mem->kva; + gart_info->bus_addr = gart_info->mem->map->dm_segs[0].ds_addr; } else { - address = gart_info->addr; - bus_address = gart_info->bus_addr; DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", (unsigned int)bus_address, (unsigned long)address); } - pci_gart = (u32 *) address; + pci_gart = (u_int32_t *) gart_info->addr; - max_pages = (gart_info->table_size / sizeof(u32)); - pages = (dev->sg->pages <= max_pages) - ? dev->sg->pages : max_pages; + max_pages = (gart_info->table_size / sizeof(u_int32_t)); + pages = (dev->sg->pages <= max_pages) ? dev->sg->pages : max_pages; memset(pci_gart, 0, max_pages * sizeof(u32)); -#ifdef __FreeBSD__ - KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE, ("page size too small")); -#else KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE); -#endif for (i = 0; i < pages; i++) { entry_addr = dev->sg->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { - page_base = (u32) entry_addr & ATI_PCIGART_PAGE_MASK; + page_base = (u_int32_t)entry_addr & + ATI_PCIGART_PAGE_MASK; switch(gart_info->gart_reg_if) { case DRM_ATI_GART_IGP: page_base |= (upper_32_bits(entry_addr) & 0xff) << 4; @@ -153,7 +124,7 @@ drm_ati_pcigart_init(struct drm_device *dev, case DRM_ATI_GART_PCI: break; } - *pci_gart = cpu_to_le32(page_base); + *pci_gart = htole32(page_base); pci_gart++; entry_addr += ATI_PCIGART_PAGE_SIZE; } @@ -161,10 +132,10 @@ drm_ati_pcigart_init(struct drm_device *dev, DRM_MEMORYBARRIER(); - ret = 1; + return (1); - done: - gart_info->addr = address; - gart_info->bus_addr = bus_address; - return ret; + error: + gart_info->addr = NULL; + gart_info->bus_addr = 0; + return (ret); } diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index a40373e66f1..432bbab3149 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -447,13 +447,14 @@ struct drm_mem { #define upper_32_bits(_val) ((u_int32_t)(((_val) >> 16) >> 16)) struct drm_ati_pcigart_info { - int gart_table_location; - int gart_reg_if; - void *addr; - dma_addr_t bus_addr; - dma_addr_t table_mask; - drm_local_map_t mapping; - int table_size; + drm_local_map_t mapping; + struct drm_dmamem *mem; + void *addr; + bus_addr_t bus_addr; + bus_addr_t table_mask; + int gart_table_location; + int gart_reg_if; + int table_size; }; struct drm_driver_info { |