add agp_generic_destroy_pages()
PATCH 3/4 add agp_generic_destroy_pages()
Add agp_generic_destroy_pages(), it uses new pageattr array interface API.
--- drivers/char/agp/agp.h | 2 + drivers/char/agp/generic.c | 55 ++++++++++++++++++++++++++++++++++++------- drivers/char/agp/intel-agp.c | 14 ++++++++++ 3 files changed, 63 insertions(+), 8 deletions(-)
drivers/char/agp/agp.h +2 -0
@@ -118,6 +118,7 @@ struct agp_bridge_driver {void *(*agp_alloc_page)(struct agp_bridge_data *);int (*agp_alloc_pages)(struct agp_bridge_data *,struct agp_memory *,size_t );void (*agp_destroy_page)(void *,int flags); +void (*agp_destroy_pages)(struct agp_memory *);int (*agp_type_to_mask_type) (struct agp_bridge_data *,int );void (*chipset_flush)(struct agp_bridge_data *); };
@@ -281,6 +282,7 @@ void *agp_generic_alloc_page(struct agp_int agp_generic_alloc_pages (struct agp_bridge_data *agp_bridge,struct agp_memory *memory,size_t page_count);void agp_generic_destroy_page (void *addr,int flags); +void agp_generic_destroy_pages (struct agp_memory *memory);void agp_free_key (int key);int agp_num_entries (void );u32 agp_collect_device_status (struct agp_bridge_data *bridge,u32 mode,u32 command);
drivers/char/agp/generic.c +47 -8
67 lines not on this page · raw message
drivers/char/agp/intel-agp.c +14 -0
@@ -1713,6 +1713,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1739,6 +1740,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1764,6 +1766,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1790,6 +1793,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = intel_i830_type_to_mask_type, .chipset_flush = intel_i830_chipset_flush, };
@@ -1816,6 +1820,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1841,6 +1846,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1866,6 +1872,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1891,6 +1898,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, .chipset_flush = intel_i830_chipset_flush, };
@@ -1917,6 +1925,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1942,6 +1951,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -1968,6 +1978,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = intel_i830_type_to_mask_type, .chipset_flush = intel_i915_chipset_flush, };
@@ -1995,6 +2006,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = intel_i830_type_to_mask_type, .chipset_flush = intel_i915_chipset_flush, };
@@ -2021,6 +2033,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = agp_generic_type_to_mask_type, };
@@ -2047,6 +2060,7 @@ static const struct agp_bridge_driver in .agp_alloc_page = agp_generic_alloc_page, .agp_alloc_pages = agp_generic_alloc_pages, .agp_destroy_page = agp_generic_destroy_page, + .agp_destroy_pages = agp_generic_destroy_pages, .agp_type_to_mask_type = intel_i830_type_to_mask_type, .chipset_flush = intel_i915_chipset_flush, };
Quoted 7 lines · On Thu, 21 Aug 2008 10:46:17 +0800 Shaohua Li <[email protected]> wrote:
drivers/char/agp/generic.c +0
-1@@ -201,14 +201,22 @@ void agp_free_memory(struct agp_memory *return ; }if (curr->page_count !=0 ) { -for (i =0 ; i < curr->page_count; i++) {
drivers/char/agp/generic.c void agp_free_memory(struct agp_memory * · line 206
Quoted 10 lines
drivers/char/agp/generic.c +3
-7- curr->memory[i] = (unsigned long )gart_to_virt (curr->memory[i]); - curr->bridge->driver->agp_destroy_page ((void *)curr->memory[i], -AGP_PAGE_DESTROY_UNMAP ); - } -for (i =0 ; i < curr->page_count; i++) { - curr->bridge->driver->agp_destroy_page ((void *)curr->memory[i], -AGP_PAGE_DESTROY_FREE ); +if (curr->bridge->driver->agp_destroy_pages) { + curr->bridge->driver->agp_destroy_pages (curr); + }else {
stylistic nit:
drivers/char/agp/generic.c void agp_free_memory(struct agp_memory * · line 219
Quoted 13 lines
drivers/char/agp/generic.c +13
-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], +AGP_PAGE_DESTROY_UNMAP ); + } +for (i =0 ; i < curr->page_count; i++) { + curr->bridge->driver->agp_destroy_page ( + (void *)curr->memory[i], +AGP_PAGE_DESTROY_FREE ); + }
Make the above code a standalone function and call it here.
Then convert all drivers over so their .agp_destroy_pages points at that new function.
Then remove the `if'.
Quoted 18 lines · Andrew Morton
stylistic nit:
drivers/char/agp/generic.c void agp_free_memory(struct agp_memory * · line 219
Quoted 13 lines
drivers/char/agp/generic.c +13
-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], +AGP_PAGE_DESTROY_UNMAP ); + } +for (i =0 ; i < curr->page_count; i++) { + curr->bridge->driver->agp_destroy_page ( + (void *)curr->memory[i], +AGP_PAGE_DESTROY_FREE ); + }Make the above code a standalone function and call it here.
Quoted 4 lines
Then convert all drivers over so their .agp_destroy_pages points at that new function.
Then remove the `if'.
good point.
[ Shaohua, when you fix this, please do it as a delta patch against your
current patchset (or against tip/master). Thanks. ]
Ingo