diff options
Diffstat (limited to 'drivers/char/agp/generic.c')
| -rw-r--r-- | drivers/char/agp/generic.c | 63 | 
1 files changed, 22 insertions, 41 deletions
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 4956f1c8f9d..0fbccce1cee 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c @@ -29,7 +29,6 @@   */  #include <linux/module.h>  #include <linux/pci.h> -#include <linux/init.h>  #include <linux/pagemap.h>  #include <linux/miscdevice.h>  #include <linux/pm.h> @@ -81,13 +80,6 @@ static int agp_get_key(void)  	return -1;  } -void agp_flush_chipset(struct agp_bridge_data *bridge) -{ -	if (bridge->driver->chipset_flush) -		bridge->driver->chipset_flush(bridge); -} -EXPORT_SYMBOL(agp_flush_chipset); -  /*   * Use kmalloc if possible for the page list. Otherwise fall back to   * vmalloc. This speeds things up and also saves memory for small AGP @@ -122,6 +114,9 @@ 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 *); +	if (INT_MAX/sizeof(struct page *) < num_agp_pages) +		return NULL; +  	new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL);  	if (new == NULL)  		return NULL; @@ -241,11 +236,14 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,  	int scratch_pages;  	struct agp_memory *new;  	size_t i; +	int cur_memory;  	if (!bridge)  		return NULL; -	if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp) +	cur_memory = atomic_read(&bridge->current_memory_agp); +	if ((cur_memory + page_count > bridge->max_memory_agp) || +	    (cur_memory + page_count < page_count))  		return NULL;  	if (type >= AGP_USER_TYPES) { @@ -487,26 +485,6 @@ int agp_unbind_memory(struct agp_memory *curr)  }  EXPORT_SYMBOL(agp_unbind_memory); -/** - *	agp_rebind_emmory  -  Rewrite the entire GATT, useful on resume - */ -int agp_rebind_memory(void) -{ -	struct agp_memory *curr; -	int ret_val = 0; - -	spin_lock(&agp_bridge->mapped_lock); -	list_for_each_entry(curr, &agp_bridge->mapped_list, mapped_list) { -		ret_val = curr->bridge->driver->insert_memory(curr, -							      curr->pg_start, -							      curr->type); -		if (ret_val != 0) -			break; -	} -	spin_unlock(&agp_bridge->mapped_lock); -	return ret_val; -} -EXPORT_SYMBOL(agp_rebind_memory);  /* End - Routines for handling swapping of agp_memory into the GATT */ @@ -535,12 +513,12 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_  	switch (*bridge_agpstat & 7) {  	case 4:  		*bridge_agpstat |= (AGPSTAT2_2X | AGPSTAT2_1X); -		printk(KERN_INFO PFX "BIOS bug. AGP bridge claims to only support x4 rate" +		printk(KERN_INFO PFX "BIOS bug. AGP bridge claims to only support x4 rate. "  			"Fixing up support for x2 & x1\n");  		break;  	case 2:  		*bridge_agpstat |= AGPSTAT2_1X; -		printk(KERN_INFO PFX "BIOS bug. AGP bridge claims to only support x2 rate" +		printk(KERN_INFO PFX "BIOS bug. AGP bridge claims to only support x2 rate. "  			"Fixing up support for x1\n");  		break;  	default: @@ -714,7 +692,7 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_  			*bridge_agpstat &= ~(AGPSTAT3_4X | AGPSTAT3_RSVD);  			*vga_agpstat &= ~(AGPSTAT3_4X | AGPSTAT3_RSVD);  		} else { -			printk(KERN_INFO PFX "Fell back to AGPx4 mode because"); +			printk(KERN_INFO PFX "Fell back to AGPx4 mode because ");  			if (!(*bridge_agpstat & AGPSTAT3_8X)) {  				printk(KERN_INFO PFX "bridge couldn't do x8. bridge_agpstat:%x (orig=%x)\n",  					*bridge_agpstat, origbridge); @@ -977,9 +955,9 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)  	bridge->driver->cache_flush();  #ifdef CONFIG_X86  	if (set_memory_uc((unsigned long)table, 1 << page_order)) -		printk(KERN_WARNING "Could not set GATT table memory to UC!"); +		printk(KERN_WARNING "Could not set GATT table memory to UC!\n"); -	bridge->gatt_table = (void *)table; +	bridge->gatt_table = (u32 __iomem *)table;  #else  	bridge->gatt_table = ioremap_nocache(virt_to_phys(table),  					(PAGE_SIZE * (1 << page_order))); @@ -1031,7 +1009,6 @@ int agp_generic_free_gatt_table(struct agp_bridge_data *bridge)  	case LVL2_APER_SIZE:  		/* The generic routines can't deal with 2 level gatt's */  		return -EINVAL; -		break;  	default:  		page_order = 0;  		break; @@ -1098,7 +1075,6 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)  	case LVL2_APER_SIZE:  		/* The generic routines can't deal with 2 level gatt's */  		return -EINVAL; -		break;  	default:  		num_entries = 0;  		break; @@ -1116,8 +1092,8 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)  		return -EINVAL;  	} -	/* AK: could wrap */ -	if ((pg_start + mem->page_count) > num_entries) +	if (((pg_start + mem->page_count) > num_entries) || +	    ((pg_start + mem->page_count) < pg_start))  		return -EINVAL;  	j = pg_start; @@ -1151,7 +1127,7 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)  {  	size_t i;  	struct agp_bridge_data *bridge; -	int mask_type; +	int mask_type, num_entries;  	bridge = mem->bridge;  	if (!bridge) @@ -1163,6 +1139,11 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)  	if (type != mem->type)  		return -EINVAL; +	num_entries = agp_num_entries(); +	if (((pg_start + mem->page_count) > num_entries) || +	    ((pg_start + mem->page_count) < pg_start)) +		return -EINVAL; +  	mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);  	if (mask_type != 0) {  		/* The generic routines know nothing of memory types */ @@ -1414,8 +1395,8 @@ int agp3_generic_configure(void)  	current_size = A_SIZE_16(agp_bridge->current_size); -	pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); -	agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); +	agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev, +						    AGP_APERTURE_BAR);  	/* set aperture size */  	pci_write_config_word(agp_bridge->dev, agp_bridge->capndx+AGPAPSIZE, current_size->size_value);  | 
