summaryrefslogtreecommitdiffstats
path: root/drivers/char/agp
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-07-29 09:28:45 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-08-03 09:04:57 +0100
commitf692775d7e0a22477143cd884e45c955448ac7d2 (patch)
tree8a801ec8cede89e694a9f4feaf8050642609ad27 /drivers/char/agp
parent91b8e3056bf9107b688eb076c9b804171364db71 (diff)
intel-agp: fix sglist allocation to avoid vmalloc()
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/char/agp')
-rw-r--r--drivers/char/agp/intel-agp.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index b9d9886ff3c..d8c80d8be5e 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -198,39 +198,30 @@ static void intel_agp_unmap_page(struct page *page, dma_addr_t dma)
static void intel_agp_free_sglist(struct agp_memory *mem)
{
+ struct sg_table st;
+
+ st.sgl = mem->sg_list;
+ st.orig_nents = st.nents = mem->page_count;
+
+ sg_free_table(&st);
- if (mem->sg_vmalloc_flag)
- vfree(mem->sg_list);
- else
- kfree(mem->sg_list);
- mem->sg_vmalloc_flag = 0;
mem->sg_list = NULL;
mem->num_sg = 0;
}
static int intel_agp_map_memory(struct agp_memory *mem)
{
+ struct sg_table st;
struct scatterlist *sg;
int i;
DBG("try mapping %lu pages\n", (unsigned long)mem->page_count);
- if ((mem->page_count * sizeof(*mem->sg_list)) < 2*PAGE_SIZE)
- mem->sg_list = kcalloc(mem->page_count, sizeof(*mem->sg_list),
- GFP_KERNEL);
-
- if (mem->sg_list == NULL) {
- mem->sg_list = vmalloc(mem->page_count * sizeof(*mem->sg_list));
- mem->sg_vmalloc_flag = 1;
- }
-
- if (!mem->sg_list) {
- mem->sg_vmalloc_flag = 0;
+ if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL))
return -ENOMEM;
- }
- sg_init_table(mem->sg_list, mem->page_count);
- sg = mem->sg_list;
+ mem->sg_list = sg = st.sgl;
+
for (i = 0 ; i < mem->page_count; i++, sg = sg_next(sg))
sg_set_page(sg, mem->pages[i], PAGE_SIZE, 0);