uninorth: Use same sizes array everywhere
PATCH 1/2 uninorth: Use same sizes array everywhere
In reply to a message not in the archiveUntil we have evidence of the opposite, we'll just assume for the sake of simplicity that all revisions of UniNorth support the same aperture sizes.
Also derive the number of supported sizes from the array definition.
--- drivers/char/agp/uninorth-agp.c | 27 ++++++--------------------- 1 files changed, 6 insertions(+), 21 deletions(-)
drivers/char/agp/uninorth-agp.c +6 -21
@@ -450,24 +450,7 @@ void null_cache_flush(void)/* Setup function */ -static struct aper_size_info_32 uninorth_sizes[7 ] = -{ -#if 0 /* Not sure uninorth supports that high aperture sizes */ - {256 ,65536 ,6 ,64 }, - {128 ,32768 ,5 ,32 }, - {64 ,16384 ,4 ,16 }, -#endif - {32 ,8192 ,3 ,8 }, - {16 ,4096 ,2 ,4 }, - {8 ,2048 ,1 ,2 }, - {4 ,1024 ,0 ,1 } -}; - -/* -* Not sure that u3 supports that high aperture sizes but it -* would strange if it did not :) -*/ -static struct aper_size_info_32 u3_sizes[8 ] = +static struct aper_size_info_32 uninorth_sizes[8 ] = { {512 ,131072 ,7 ,128 }, {256 ,65536 ,6 ,64 },
@@ -483,7 +466,8 @@ struct agp_bridge_driver uninorth_agp_dr .owner = THIS_MODULE, .aperture_sizes = (void *)uninorth_sizes, .size_type = U32_APER_SIZE, - .num_aperture_sizes = 4, + .num_aperture_sizes =sizeof (uninorth_sizes) + / sizeof(struct aper_size_info_32), .configure = uninorth_configure, .fetch_size = uninorth_fetch_size, .cleanup = uninorth_cleanup,
@@ -505,9 +489,10 @@ struct agp_bridge_driver uninorth_agp_drstruct agp_bridge_driver u3_agp_driver = { .owner =THIS_MODULE , - .aperture_sizes = (void *)u3_sizes, + .aperture_sizes = (void *)uninorth_sizes, .size_type =U32_APER_SIZE , - .num_aperture_sizes =8 , + .num_aperture_sizes =sizeof (uninorth_sizes) + /sizeof (struct aper_size_info_32 ), .configure = uninorth_configure, .fetch_size = uninorth_fetch_size, .cleanup = uninorth_cleanup,
Signature · 2 lines
Earthling Michel Dänzer | http://tungstengraphics.com Libre software enthusiast | Debian, X and DRI developer
PATCH 2/2 uninorth: Add module param 'aperture' for aperture size
In reply to a message not in the archiveIn contrast to most if not all PC BIOSes, OpenFirmware (OF) on PowerMacs with UniNorth bridges does not allow changing the aperture size. The size set up by OF is usually 16 MB, which is too low for graphics intensive environments. Hence, add a module parameter that allows changing the aperture size at driver initialization time. When the parameter is not specified, the default is still to leave the size unchanged, usually as set up by OF.
--- drivers/char/agp/uninorth-agp.c | 59 ++++++++++++++++++++++++++------------- 1 files changed, 40 insertions(+), 19 deletions(-)
drivers/char/agp/uninorth-agp.c +40 -19
@@ -27,32 +27,48 @@ #include "agp.h"static int uninorth_rev;static int is_u3; +static char __devinitdata *aperture =NULL ;static int uninorth_fetch_size (void ) { -int i; -u32 temp; -struct aper_size_info_32 *values; - -pci_read_config_dword (agp_bridge->dev,UNI_N_CFG_GART_BASE , &temp); - temp &= ~(0xfffff000 ); - values =A_SIZE_32 (agp_bridge->driver->aperture_sizes); - -for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) { -if (temp == values[i].size_value) { - agp_bridge->previous_size = - agp_bridge->current_size = (void *) (values + i); - agp_bridge->aperture_size_idx = i; -return values[i].size; +int i =0 , size =0 ; +struct aper_size_info_32 *values = +A_SIZE_32 (agp_bridge->driver->aperture_sizes); + +if (aperture) { +char *save = aperture; + + size =memparse (aperture, &aperture) >>20 ; + aperture = save; + +for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) +if (size == values[i].size) +break ; + +if (i == agp_bridge->driver->num_aperture_sizes) { + printk(KERN_ERR PFX "Invalid aperture size, using" + " default\n"); + size =0 ; + aperture =NULL ; } } - agp_bridge->previous_size = - agp_bridge->current_size = (void *) (values +1 ); - agp_bridge->aperture_size_idx =1 ; -return values[1 ].size; +if (!size) { +u32 temp; -return 0 ; +pci_read_config_dword (agp_bridge->dev,UNI_N_CFG_GART_BASE , + &temp); + temp &= ~(0xfffff000 ); + +for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) +if (temp == values[i].size_value) +break ; + } + + agp_bridge->previous_size = + agp_bridge->current_size = (void *)(values + i); + agp_bridge->aperture_size_idx = i; +return values[i].size; }static void uninorth_tlbflush (struct agp_memory *mem)
@@ -668,5 +684,10 @@ static void __exit agp_uninorth_cleanup(module_init (agp_uninorth_init);module_exit (agp_uninorth_cleanup); +module_param (aperture, charp,0 ); +MODULE_PARM_DESC (aperture, +"Aperture size, must be power of two between 4MB and 512MB.\n" +"Default: Leave unchanged, e.g. as set up by firmware" ); +MODULE_AUTHOR ("Ben Herrenschmidt & Paul Mackerras" );MODULE_LICENSE ("GPL" );
Signature · 2 lines
Earthling Michel Dänzer | http://tungstengraphics.com Libre software enthusiast | Debian, X and DRI developer
Re: [PATCH 2/2] uninorth: Add module param 'aperture' for aperture size
Quoted 6 lines · Michel Dänzer
In contrast to most if not all PC BIOSes, OpenFirmware (OF) on PowerMacs with UniNorth bridges does not allow changing the aperture size. The size set up by OF is usually 16 MB, which is too low for graphics intensive environments. Hence, add a module parameter that allows changing the aperture size at driver initialization time. When the parameter is not specified, the default is still to leave the size unchanged, usually as set up by OF.
The right fix is to allow changing it by the driver ... can't we do it such that AGPSize will work & change it ? The firmware doesn't actually configure it at all I suspect... those 16M are basically what the HW comes up with as a default setting (unless the firmware runs some diagnostics and sets it as a result of these). It's basically expected that we set it ourselves and a module option doesn't seem like a terribly good idea to me...
Maybe we should just have the driver default to something more sensible in addition to what AGPSize comes from userland ? like 64M ?
Ben.
Re: [PATCH 2/2] uninorth: Add module param 'aperture' for aperture size
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 6 lines · Michel Dänzer
In contrast to most if not all PC BIOSes, OpenFirmware (OF) on PowerMacs with UniNorth bridges does not allow changing the aperture size. The size set up by OF is usually 16 MB, which is too low for graphics intensive environments. Hence, add a module parameter that allows changing the aperture size at driver initialization time. When the parameter is not specified, the default is still to leave the size unchanged, usually as set up by OF.
The right fix is to allow changing it by the driver ... can't we do it such that AGPSize will work & change it ?
Not sure, but it seems like the aperture size is fixed at backend initialization time, i.e. in the driver's probe hook.
Quoted 2 lines
It's basically expected that we set it ourselves and a module option doesn't seem like a terribly good idea to me...
Well, wasn't it you who suggested this? :)
Quoted 2 lines
Maybe we should just have the driver default to something more sensible in addition to what AGPSize comes from userland ? like 64M ?
Might be a good idea.
Signature · 2 lines
Earthling Michel Dänzer | http://tungstengraphics.com Libre software enthusiast | Debian, X and DRI developer
Re: [PATCH 2/2] uninorth: Add module param 'aperture' for aperture size
Quoted 4 lines
Quoted 2 lines
It's basically expected that we set it ourselves and a module option doesn't seem like a terribly good idea to me...
Well, wasn't it you who suggested this? :)
Possibly, I don't always have good ideas :) I would rather have that size be configured by the client driver... oh well, let's workaround that for now by using a better default _and_ the module option.
Quoted 6 lines
Quoted 2 lines
Maybe we should just have the driver default to something more sensible in addition to what AGPSize comes from userland ? like 64M ?
Might be a good idea.
Re: [PATCH 2/2] uninorth: Add module param 'aperture' for aperture size
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 4 lines
Quoted 2 lines
It's basically expected that we set it ourselves and a module option doesn't seem like a terribly good idea to me...
Well, wasn't it you who suggested this? :)
Possibly, I don't always have good ideas :) I would rather have that size be configured by the client driver...
That would certainly be ideal. Digging into the code a little deeper, it seems like the backend's insert_memory hook should be able to adjust the GATT table size on the fly. Not sure __get_free_pages() is expected to succeed for dozens of pages at any given time though.
Quoted 2 lines
oh well, let's workaround that for now by using a better default _and_ the module option.
Agreed, I'll re-send the patch with the default changed to 64M.
Signature · 2 lines
Earthling Michel Dänzer | http://tungstengraphics.com Libre software enthusiast | Debian, X and DRI developer
PATCH 1/1 uninorth: Add module param 'aperture' for aperture size
In reply to Benjamin HerrenschmidtIn contrast to most if not all PC BIOSes, OpenFirmware (OF) on PowerMacs with UniNorth bridges does not allow changing the aperture size. The size set up by OF is usually 16 MB, which is too low for graphics intensive environments. Hence, add a module parameter that allows changing the aperture size at driver initialization time. When the parameter is not specified, the default is 32 MB.
---
Note that I made the default size 32 MB (instead of 64 MB as discussed on the linuxppc-dev list) to make this patch independent of the other uninorth patch I sent out.
drivers/char/agp/uninorth-agp.c | 54 +++++++++++++++++++++++++-------------- 1 files changed, 35 insertions(+), 19 deletions(-)
drivers/char/agp/uninorth-agp.c +35 -19
@@ -27,32 +27,42 @@ #include "agp.h"static int uninorth_rev;static int is_u3; +static char __devinitdata *aperture =NULL ;static int uninorth_fetch_size (void ) { -int i; -u32 temp; -struct aper_size_info_32 *values; - -pci_read_config_dword (agp_bridge->dev,UNI_N_CFG_GART_BASE , &temp); - temp &= ~(0xfffff000 ); - values =A_SIZE_32 (agp_bridge->driver->aperture_sizes); - -for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) { -if (temp == values[i].size_value) { - agp_bridge->previous_size = - agp_bridge->current_size = (void *) (values + i); - agp_bridge->aperture_size_idx = i; -return values[i].size; +int i, size =0 ; +struct aper_size_info_32 *values = +A_SIZE_32 (agp_bridge->driver->aperture_sizes); + +if (aperture) { +char *save = aperture; + + size =memparse (aperture, &aperture) >>20 ; + aperture = save; + +for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) +if (size == values[i].size) +break ; + +if (i == agp_bridge->driver->num_aperture_sizes) { + printk(KERN_ERR PFX "Invalid aperture size, using" + " default\n"); + size =0 ; + aperture =NULL ; } } - agp_bridge->previous_size = - agp_bridge->current_size = (void *) (values +1 ); - agp_bridge->aperture_size_idx =1 ; -return values[1 ].size; +if (!size) { +for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) +if (32 == values[i].size) +break ; + } -return 0 ; + agp_bridge->previous_size = + agp_bridge->current_size = (void *)(values + i); + agp_bridge->aperture_size_idx = i; +return values[i].size; }static void uninorth_tlbflush (struct agp_memory *mem)
@@ -668,5 +678,11 @@ static void __exit agp_uninorth_cleanup(module_init (agp_uninorth_init);module_exit (agp_uninorth_cleanup); +module_param (aperture, charp,0 ); +MODULE_PARM_DESC (aperture, +"Aperture size, must be power of two between 4MB and an\n" +"\t\tupper limit specific to the UniNorth revision.\n" +"\t\tDefault: 32M" ); +MODULE_AUTHOR ("Ben Herrenschmidt & Paul Mackerras" );MODULE_LICENSE ("GPL" );
Signature · 7 lines
1.4.1.1 -- Earthling Michel Dänzer | http://tungstengraphics.com Libre software enthusiast | Debian, X and DRI developer
PATCH 1/1 uninorth: Add module param 'aperture' for aperture size
In reply to Benjamin HerrenschmidtIn contrast to most if not all PC BIOSes, OpenFirmware (OF) on PowerMacs with UniNorth bridges does not allow changing the aperture size. The size set up by OF is usually 16 MB, which is too low for graphics intensive environments. Hence, add a module parameter that allows changing the aperture size at driver initialization time. When the parameter is not specified, the default is 32 MB.
---
Any (N)ACKs on this would be much appreciated.
Note that I made the default size 32 MB (instead of 64 MB as discussed on the linuxppc-dev list) to make this patch independent of the other uninorth patch I sent out.
drivers/char/agp/uninorth-agp.c | 54 +++++++++++++++++++++++++-------------- 1 files changed, 35 insertions(+), 19 deletions(-)
drivers/char/agp/uninorth-agp.c +35 -19
@@ -27,32 +27,42 @@ #include "agp.h"static int uninorth_rev;static int is_u3; +static char __devinitdata *aperture =NULL ;static int uninorth_fetch_size (void ) { -int i; -u32 temp; -struct aper_size_info_32 *values; - -pci_read_config_dword (agp_bridge->dev,UNI_N_CFG_GART_BASE , &temp); - temp &= ~(0xfffff000 ); - values =A_SIZE_32 (agp_bridge->driver->aperture_sizes); - -for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) { -if (temp == values[i].size_value) { - agp_bridge->previous_size = - agp_bridge->current_size = (void *) (values + i); - agp_bridge->aperture_size_idx = i; -return values[i].size; +int i, size =0 ; +struct aper_size_info_32 *values = +A_SIZE_32 (agp_bridge->driver->aperture_sizes); + +if (aperture) { +char *save = aperture; + + size =memparse (aperture, &aperture) >>20 ; + aperture = save; + +for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) +if (size == values[i].size) +break ; + +if (i == agp_bridge->driver->num_aperture_sizes) { + printk(KERN_ERR PFX "Invalid aperture size, using" + " default\n"); + size =0 ; + aperture =NULL ; } } - agp_bridge->previous_size = - agp_bridge->current_size = (void *) (values +1 ); - agp_bridge->aperture_size_idx =1 ; -return values[1 ].size; +if (!size) { +for (i =0 ; i < agp_bridge->driver->num_aperture_sizes; i++) +if (32 == values[i].size) +break ; + } -return 0 ; + agp_bridge->previous_size = + agp_bridge->current_size = (void *)(values + i); + agp_bridge->aperture_size_idx = i; +return values[i].size; }static void uninorth_tlbflush (struct agp_memory *mem)
@@ -668,5 +678,11 @@ static void __exit agp_uninorth_cleanup(module_init (agp_uninorth_init);module_exit (agp_uninorth_cleanup); +module_param (aperture, charp,0 ); +MODULE_PARM_DESC (aperture, +"Aperture size, must be power of two between 4MB and an\n" +"\t\tupper limit specific to the UniNorth revision.\n" +"\t\tDefault: 32M" ); +MODULE_AUTHOR ("Ben Herrenschmidt & Paul Mackerras" );MODULE_LICENSE ("GPL" );
Signature · 7 lines
1.4.1.1 -- Earthling Michel Dänzer | http://tungstengraphics.com Libre software enthusiast | Debian, X and DRI developer
Re: [PATCH] uninorth: Add module param 'aperture' for aperture size
drivers/char/agp/uninorth-agp.c #include "agp.h" · line 58
Quoted 1 line · Michel Dänzer
drivers/char/agp/uninorth-agp.c +1
-0+if (32 == values[i].size)
variable == value, please.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."