Commit 8877f6e2 authored by Rik van Riel's avatar Rik van Riel Committed by Linus Torvalds

- janitor: clean up i810_dma.c and agpgart_be.c to use the macros

  from mm.h instead of set_bit/clear_bit
- access page->count only through the atomic macros, remove the
  broken init_page_count thing  (DaveM)
parent c39e9205
...@@ -622,7 +622,7 @@ static int agp_generic_create_gatt_table(void) ...@@ -622,7 +622,7 @@ static int agp_generic_create_gatt_table(void)
table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1); table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
set_bit(PG_reserved, &page->flags); SetPageReserved(page);
agp_bridge.gatt_table_real = (unsigned long *) table; agp_bridge.gatt_table_real = (unsigned long *) table;
CACHE_FLUSH(); CACHE_FLUSH();
...@@ -632,7 +632,7 @@ static int agp_generic_create_gatt_table(void) ...@@ -632,7 +632,7 @@ static int agp_generic_create_gatt_table(void)
if (agp_bridge.gatt_table == NULL) { if (agp_bridge.gatt_table == NULL) {
for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
clear_bit(PG_reserved, &page->flags); ClearPageReserved(page);
free_pages((unsigned long) table, page_order); free_pages((unsigned long) table, page_order);
...@@ -699,7 +699,7 @@ static int agp_generic_free_gatt_table(void) ...@@ -699,7 +699,7 @@ static int agp_generic_free_gatt_table(void)
table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1); table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
clear_bit(PG_reserved, &page->flags); ClearPageReserved(page);
free_pages((unsigned long) agp_bridge.gatt_table_real, page_order); free_pages((unsigned long) agp_bridge.gatt_table_real, page_order);
return 0; return 0;
...@@ -812,8 +812,8 @@ static unsigned long agp_generic_alloc_page(void) ...@@ -812,8 +812,8 @@ static unsigned long agp_generic_alloc_page(void)
if (page == NULL) { if (page == NULL) {
return 0; return 0;
} }
atomic_inc(&page->count); get_page(page);
set_bit(PG_locked, &page->flags); LockPage(page);
atomic_inc(&agp_bridge.current_memory_agp); atomic_inc(&agp_bridge.current_memory_agp);
return (unsigned long)page_address(page); return (unsigned long)page_address(page);
} }
...@@ -828,9 +828,8 @@ static void agp_generic_destroy_page(unsigned long addr) ...@@ -828,9 +828,8 @@ static void agp_generic_destroy_page(unsigned long addr)
} }
page = virt_to_page(pt); page = virt_to_page(pt);
atomic_dec(&page->count); put_page(page);
clear_bit(PG_locked, &page->flags); UnlockPage(page);
wake_up_page(page);
free_page((unsigned long) pt); free_page((unsigned long) pt);
atomic_dec(&agp_bridge.current_memory_agp); atomic_dec(&agp_bridge.current_memory_agp);
} }
...@@ -2278,13 +2277,12 @@ static int amd_create_page_map(amd_page_map *page_map) ...@@ -2278,13 +2277,12 @@ static int amd_create_page_map(amd_page_map *page_map)
if (page_map->real == NULL) { if (page_map->real == NULL) {
return -ENOMEM; return -ENOMEM;
} }
set_bit(PG_reserved, &virt_to_page(page_map->real)->flags); SetPageReserved(virt_to_page(page_map->real));
CACHE_FLUSH(); CACHE_FLUSH();
page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
PAGE_SIZE); PAGE_SIZE);
if (page_map->remapped == NULL) { if (page_map->remapped == NULL) {
clear_bit(PG_reserved, ClearPageReserved(virt_to_page(page_map->real));
&virt_to_page(page_map->real)->flags);
free_page((unsigned long) page_map->real); free_page((unsigned long) page_map->real);
page_map->real = NULL; page_map->real = NULL;
return -ENOMEM; return -ENOMEM;
...@@ -2301,8 +2299,7 @@ static int amd_create_page_map(amd_page_map *page_map) ...@@ -2301,8 +2299,7 @@ static int amd_create_page_map(amd_page_map *page_map)
static void amd_free_page_map(amd_page_map *page_map) static void amd_free_page_map(amd_page_map *page_map)
{ {
iounmap(page_map->remapped); iounmap(page_map->remapped);
clear_bit(PG_reserved, ClearPageReserved(virt_to_page(page_map->real));
&virt_to_page(page_map->real)->flags);
free_page((unsigned long) page_map->real); free_page((unsigned long) page_map->real);
} }
...@@ -2790,8 +2787,8 @@ static unsigned long ali_alloc_page(void) ...@@ -2790,8 +2787,8 @@ static unsigned long ali_alloc_page(void)
if (page == NULL) if (page == NULL)
return 0; return 0;
atomic_inc(&page->count); get_page(page);
set_bit(PG_locked, &page->flags); LockPage(page);
atomic_inc(&agp_bridge.current_memory_agp); atomic_inc(&agp_bridge.current_memory_agp);
global_cache_flush(); global_cache_flush();
...@@ -2826,9 +2823,8 @@ static void ali_destroy_page(unsigned long addr) ...@@ -2826,9 +2823,8 @@ static void ali_destroy_page(unsigned long addr)
} }
page = virt_to_page(pt); page = virt_to_page(pt);
atomic_dec(&page->count); put_page(page);
clear_bit(PG_locked, &page->flags); UnlockPage(page);
wake_up_page(page);
free_page((unsigned long) pt); free_page((unsigned long) pt);
atomic_dec(&agp_bridge.current_memory_agp); atomic_dec(&agp_bridge.current_memory_agp);
} }
...@@ -2910,13 +2906,12 @@ static int serverworks_create_page_map(serverworks_page_map *page_map) ...@@ -2910,13 +2906,12 @@ static int serverworks_create_page_map(serverworks_page_map *page_map)
if (page_map->real == NULL) { if (page_map->real == NULL) {
return -ENOMEM; return -ENOMEM;
} }
set_bit(PG_reserved, &virt_to_page(page_map->real)->flags); SetPageReserved(virt_to_page(page_map->real));
CACHE_FLUSH(); CACHE_FLUSH();
page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
PAGE_SIZE); PAGE_SIZE);
if (page_map->remapped == NULL) { if (page_map->remapped == NULL) {
clear_bit(PG_reserved, ClearPageReserved(virt_to_page(page_map->real));
&virt_to_page(page_map->real)->flags);
free_page((unsigned long) page_map->real); free_page((unsigned long) page_map->real);
page_map->real = NULL; page_map->real = NULL;
return -ENOMEM; return -ENOMEM;
...@@ -2933,8 +2928,7 @@ static int serverworks_create_page_map(serverworks_page_map *page_map) ...@@ -2933,8 +2928,7 @@ static int serverworks_create_page_map(serverworks_page_map *page_map)
static void serverworks_free_page_map(serverworks_page_map *page_map) static void serverworks_free_page_map(serverworks_page_map *page_map)
{ {
iounmap(page_map->remapped); iounmap(page_map->remapped);
clear_bit(PG_reserved, ClearPageReserved(virt_to_page(page_map->real));
&virt_to_page(page_map->real)->flags);
free_page((unsigned long) page_map->real); free_page((unsigned long) page_map->real);
} }
......
...@@ -286,8 +286,8 @@ static unsigned long i810_alloc_page(drm_device_t *dev) ...@@ -286,8 +286,8 @@ static unsigned long i810_alloc_page(drm_device_t *dev)
if(address == 0UL) if(address == 0UL)
return 0; return 0;
atomic_inc(&virt_to_page(address)->count); get_page(virt_to_page(address));
set_bit(PG_locked, &virt_to_page(address)->flags); LockPage(virt_to_page(address));
return address; return address;
} }
...@@ -296,9 +296,8 @@ static void i810_free_page(drm_device_t *dev, unsigned long page) ...@@ -296,9 +296,8 @@ static void i810_free_page(drm_device_t *dev, unsigned long page)
{ {
if (page) { if (page) {
struct page *p = virt_to_page(page); struct page *p = virt_to_page(page);
atomic_dec(p); put_page(p);
clear_bit(PG_locked, &p->flags); UnlockPage(p);
wake_up_page(p);
free_page(page); free_page(page);
} }
} }
......
...@@ -193,11 +193,6 @@ typedef struct page { ...@@ -193,11 +193,6 @@ typedef struct page {
#define page_count(p) atomic_read(&(p)->count) #define page_count(p) atomic_read(&(p)->count)
#define set_page_count(p,v) atomic_set(&(p)->count, v) #define set_page_count(p,v) atomic_set(&(p)->count, v)
static inline void init_page_count(struct page *page)
{
page->count.counter = 0;
}
/* /*
* Various page->flags bits: * Various page->flags bits:
* *
......
...@@ -811,7 +811,7 @@ void __init free_area_init_core(int nid, pg_data_t *pgdat, struct page **gmap, ...@@ -811,7 +811,7 @@ void __init free_area_init_core(int nid, pg_data_t *pgdat, struct page **gmap,
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
struct page *page = mem_map + offset + i; struct page *page = mem_map + offset + i;
set_page_zone(page, nid * MAX_NR_ZONES + j); set_page_zone(page, nid * MAX_NR_ZONES + j);
init_page_count(page); set_page_count(page, 0);
__SetPageReserved(page); __SetPageReserved(page);
memlist_init(&page->list); memlist_init(&page->list);
if (j != ZONE_HIGHMEM) if (j != ZONE_HIGHMEM)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment