[PATCH] agp: use scratch page on memory remove and at GATT creation V2

Michel Dänzer michel at daenzer.net
Tue Apr 20 07:57:11 PDT 2010


On Die, 2010-04-20 at 14:31 +0200, glisse at freedesktop.org wrote: 
> From: Jerome Glisse <jglisse at redhat.com>
> 
> Convert most AGP chipset to use scratch page as default entries.
> This help avoiding GPU querying 0 address and trigger computer
> fault. With KMS and memory manager we bind/unbind AGP memory
> constantly and it seems that some GPU are still doing AGP
> traffic even after GPU report being idle with the memory segment.
> 
> Tested (radeon GPU KMS + Xorg + compiz + glxgears + quake3) on :
> - SIS 1039:0001 & 1039:0003
> - Intel 865 8086:2571
> 
> Compile tested for other bridges
> 
> V2 enable scratch page on uninorth
> 
> Signed-off-by: Jerome Glisse <jglisse at redhat.com>
> Cc: stable <stable at kernel.org>

[...]

> diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
> index d89da4a..f01a8df 100644
> --- a/drivers/char/agp/uninorth-agp.c
> +++ b/drivers/char/agp/uninorth-agp.c
> @@ -27,6 +27,7 @@
>   */
>  static int uninorth_rev;
>  static int is_u3;
> +static u32 scratch_value;
>  
>  #define DEFAULT_APERTURE_SIZE 256
>  #define DEFAULT_APERTURE_STRING "256"
> @@ -213,8 +214,9 @@ int uninorth_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
>  		return 0;
>  
>  	gp = (u32 *) &agp_bridge->gatt_table[pg_start];
> -	for (i = 0; i < mem->page_count; ++i)
> -		gp[i] = 0;
> +	for (i = 0; i < mem->page_count; ++i) {
> +		gp[i] = scratch_value;
> +	}
>  	mb();
>  	uninorth_tlbflush(mem);
>  
> @@ -420,8 +422,13 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
>  
>  	bridge->gatt_bus_addr = virt_to_phys(table);
>  
> +	if (is_u3)
> +		scratch_value = (page_to_phys(agp_bridge->scratch_page_page) >> PAGE_SHIFT) | 0x80000000UL;
> +	else
> +		scratch_value =	cpu_to_le32((page_to_phys(agp_bridge->scratch_page_page) & 0xFFFFF000UL) |
> +				0x1UL);
>  	for (i = 0; i < num_entries; i++)
> -		bridge->gatt_table[i] = 0;
> +		bridge->gatt_table[i] = scratch_value;
>  
>  	return 0;
>  
> @@ -518,6 +525,7 @@ const struct agp_bridge_driver uninorth_agp_driver = {
>  	.agp_destroy_pages	= agp_generic_destroy_pages,
>  	.agp_type_to_mask_type  = agp_generic_type_to_mask_type,
>  	.cant_use_aperture	= true,
> +	.needs_scratch_page	= true,
>  };
>  
>  const struct agp_bridge_driver u3_agp_driver = {

The uninorth driver also needs the change below, or no memory can be
bound anymore. With that, it's working on my PowerBook.


diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index f01a8df..9b26341 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -172,7 +172,7 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, int ty
 
 	gp = (u32 *) &agp_bridge->gatt_table[pg_start];
 	for (i = 0; i < mem->page_count; ++i) {
-		if (gp[i]) {
+		if (gp[i] != scratch_value) {
 			dev_info(&agp_bridge->dev->dev,
 				 "uninorth_insert_memory: entry 0x%x occupied (%x)\n",
 				 i, gp[i]);


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer



More information about the dri-devel mailing list