commit 74dc3d80775997b36dd05995284f3e93cdbdc3b8 Author: Pierre Willenbrock Date: Wed Oct 22 21:12:28 2008 +0200 change physical address type in agp from unsigned long to dma_addr_t There may still be some problems, when physical addresses are passed to intelfb or to mtrr. There is a problem passing physical pages to userspace through drm. Signed-off-by: Pierre Willenbrock diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 4bada0e..efa3971 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h @@ -51,7 +51,7 @@ enum aper_size_type { }; struct gatt_mask { - unsigned long mask; + dma_addr_t mask; u32 type; /* totally device specific, for integrated chipsets that * might have different types of memory masks. For other @@ -107,7 +107,7 @@ struct agp_bridge_driver { void (*agp_enable)(struct agp_bridge_data *, u32); void (*cleanup)(void); void (*tlb_flush)(struct agp_memory *); - unsigned long (*mask_memory)(struct agp_bridge_data *, unsigned long, int); + unsigned long (*mask_memory)(struct agp_bridge_data *, dma_addr_t, int); void (*cache_flush)(void); int (*create_gatt_table)(struct agp_bridge_data *); int (*free_gatt_table)(struct agp_bridge_data *); @@ -132,7 +132,7 @@ struct agp_bridge_data { u32 __iomem *gatt_table; u32 *gatt_table_real; unsigned long scratch_page; - unsigned long scratch_page_real; + dma_addr_t scratch_page_real; unsigned long gart_bus_addr; unsigned long gatt_bus_addr; u32 mode; @@ -286,7 +286,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge); void global_cache_flush(void); void get_agp_version(struct agp_bridge_data *bridge); unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, - unsigned long addr, int type); + dma_addr_t addr, int type); int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, int type); struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 118dbde..0d15058 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c @@ -121,7 +121,7 @@ EXPORT_SYMBOL(agp_free_page_array); static struct agp_memory *agp_create_user_memory(unsigned long num_agp_pages) { struct agp_memory *new; - unsigned long alloc_size = num_agp_pages*sizeof(struct page *); + unsigned long alloc_size = num_agp_pages*sizeof(dma_addr_t); new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL); if (new == NULL) @@ -202,12 +202,10 @@ void agp_free_memory(struct agp_memory *curr) } if (curr->page_count != 0) { for (i = 0; i < curr->page_count; i++) { - curr->memory[i] = (unsigned long)gart_to_virt(curr->memory[i]); - curr->bridge->driver->agp_destroy_page((void *)curr->memory[i], + void *va = gart_to_virt(curr->memory[i]); + curr->bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP); - } - for (i = 0; i < curr->page_count; i++) { - curr->bridge->driver->agp_destroy_page((void *)curr->memory[i], + curr->bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE); } } @@ -217,7 +215,7 @@ void agp_free_memory(struct agp_memory *curr) } EXPORT_SYMBOL(agp_free_memory); -#define ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) +#define ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(dma_addr_t)) /** * agp_allocate_memory - allocate a group of pages of a certain type. @@ -1280,7 +1278,7 @@ void global_cache_flush(void) EXPORT_SYMBOL(global_cache_flush); unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { /* memory type is ignored in the generic routine */ if (bridge->driver->masks) diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 81f0942..4156f6d 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c @@ -448,7 +448,7 @@ static void intel_i810_free_by_type(struct agp_memory *curr) } static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { /* Type checking must be done elsewhere */ return addr | bridge->driver->masks[type].mask; @@ -1180,7 +1180,7 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) * this conditional. */ static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { /* Shift high bits down */ addr |= (addr >> 28) & 0xf0; diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c index 803bc9e..98b2c94 100644 --- a/drivers/gpu/drm/drm_memory.c +++ b/drivers/gpu/drm/drm_memory.c @@ -82,7 +82,8 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) static void *agp_remap(unsigned long offset, unsigned long size, struct drm_device * dev) { - unsigned long *phys_addr_map, i, num_pages = + dma_addr_t *phys_addr_map; + unsigned long i, num_pages = PAGE_ALIGN(size) / PAGE_SIZE; struct drm_agp_mem *agpmem; struct page **page_map; diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index c234c6f..21f0461 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -144,13 +144,13 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) * Get the page, inc the use count, and return it */ offset = (baddr - agpmem->bound) >> PAGE_SHIFT; - page = virt_to_page(__va(agpmem->memory->memory[offset])); + page = virt_to_page(phys_to_virt(agpmem->memory->memory[offset])); get_page(page); vmf->page = page; DRM_DEBUG ("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n", - baddr, __va(agpmem->memory->memory[offset]), offset, + baddr, phys_to_virt(agpmem->memory->memory[offset]), offset, page_count(page)); return 0; } diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h index 2b8df8b..fdbd65e 100644 --- a/include/linux/agp_backend.h +++ b/include/linux/agp_backend.h @@ -70,13 +70,13 @@ struct agp_memory { struct agp_memory *next; struct agp_memory *prev; struct agp_bridge_data *bridge; - unsigned long *memory; + dma_addr_t *memory; size_t page_count; int key; int num_scratch_pages; off_t pg_start; u32 type; - u32 physical; + dma_addr_t physical; bool is_bound; bool is_flushed; bool vmalloc_flag; diff --git a/include/linux/agpgart.h b/include/linux/agpgart.h index c8fdb6e..6bd55de 100644 --- a/include/linux/agpgart.h +++ b/include/linux/agpgart.h @@ -93,6 +93,7 @@ typedef struct _agp_allocate { int key; /* tag of allocation */ size_t pg_count; /* number of pages */ __u32 type; /* 0 == normal, other devspec */ + /*this needs to be fixed if we want to use 64bit phys addresses */ __u32 physical; /* device specific (some devices * need a phys address of the * actual page behind the gatt @@ -155,7 +156,7 @@ struct agp_allocate { int key; /* tag of allocation */ size_t pg_count; /* number of pages */ u32 type; /* 0 == normal, other devspec */ - u32 physical; /* device specific (some devices + dma_addr_t physical; /* device specific (some devices * need a phys address of the * actual page behind the gatt * table) */