commit 3b897af010242b5647e3077de75bc929499cf403 Author: Pierre Willenbrock Date: Thu Oct 23 12:09:46 2008 +0200 change physical address type in agp from unsigned long to dma_addr_t There still may be some problems, when physical addresses are passed to intelfb, mtrr or userspace. Signed-off-by: Pierre Willenbrock diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 46f5075..c8ca7a3 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 *); @@ -134,7 +134,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; @@ -291,7 +291,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/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c index 453543a..c7d35a8 100644 --- a/drivers/char/agp/efficeon-agp.c +++ b/drivers/char/agp/efficeon-agp.c @@ -65,7 +65,7 @@ static const struct gatt_mask efficeon_generic_masks[] = }; /* This function does the same thing as mask_memory() for this chipset... */ -static inline unsigned long efficeon_mask_memory(unsigned long addr) +static inline unsigned long efficeon_mask_memory(dma_addr_t addr) { return addr | 0x00000001; } diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 10d6cbd..97e8b41 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) @@ -206,15 +206,12 @@ void agp_free_memory(struct agp_memory *curr) } else { for (i = 0; i < curr->page_count; i++) { - curr->memory[i] = (unsigned long)gart_to_virt( - curr->memory[i]); + void *va = gart_to_virt(curr->memory[i]); curr->bridge->driver->agp_destroy_page( - (void *)curr->memory[i], + va, AGP_PAGE_DESTROY_UNMAP); - } - for (i = 0; i < curr->page_count; i++) { curr->bridge->driver->agp_destroy_page( - (void *)curr->memory[i], + va, AGP_PAGE_DESTROY_FREE); } } @@ -225,7 +222,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. @@ -1361,7 +1358,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/hp-agp.c b/drivers/char/agp/hp-agp.c index 183ac3f..778b5e7 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c @@ -397,7 +397,7 @@ hp_zx1_remove_memory (struct agp_memory *mem, off_t pg_start, int type) static unsigned long hp_zx1_mask_memory (struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { return HP_ZX1_PDIR_VALID_BIT | addr; } diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c index 10da687..45d44d1 100644 --- a/drivers/char/agp/i460-agp.c +++ b/drivers/char/agp/i460-agp.c @@ -544,7 +544,7 @@ static void i460_destroy_page (void *page, int flags) #endif /* I460_LARGE_IO_PAGES */ static unsigned long i460_mask_memory (struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { /* Make sure the returned address is a valid GATT entry */ return bridge->driver->masks[0].mask diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 1108665..dedee45 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/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c index f2492ec..7654cee 100644 --- a/drivers/char/agp/parisc-agp.c +++ b/drivers/char/agp/parisc-agp.c @@ -186,7 +186,7 @@ parisc_agp_remove_memory(struct agp_memory *mem, off_t pg_start, int type) static unsigned long parisc_agp_mask_memory(struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { return SBA_PDIR_VALID_BIT | addr; } diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c index b972d83..913ddf7 100644 --- a/drivers/char/agp/sgi-agp.c +++ b/drivers/char/agp/sgi-agp.c @@ -71,7 +71,7 @@ static void sgi_tioca_tlbflush(struct agp_memory *mem) */ static unsigned long sgi_tioca_mask_memory(struct agp_bridge_data *bridge, - unsigned long addr, int type) + dma_addr_t addr, int type) { return tioca_physpage_to_gart(addr); } 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;