# total AGP memory

## vap0rtranz

Hey Penguins!

How does one convince agpgart/fglrx to recognize more (or the correct amount of) memory on a graphics card?

I reverted from ATI 3.9.x drivers to 3.2.8.  Everything works (X, *glxgears -- good fps), but a new message troubles me:

```

/var/log/kern.log:Jun  7 17:04:54 localhost kernel: [fglrx:firegl_agp_lock_pages] *ERROR* agp_allocate_memory_phys_list failed
```

So I checked to see how much memory the kernel allocated AGP and found only 16M of my 64M Radeon card  :Sad:   Snipit from kern.log:

```

Jun  7 17:03:34 localhost kernel: fglrx: module license 'Proprietary. (C) 2002 - ATI Technologies, Starnberg, GERMANY' taints kernel.

Jun  7 17:03:34 localhost kernel: [fglrx] Maximum main memory to use for locked dma buffers: 431 MBytes.

Jun  7 17:03:34 localhost kernel: [fglrx] module loaded - fglrx 3.2.8 [Sep 21 2003] on minor 0

Jun  7 17:03:34 localhost kernel: [fglrx] AGP detected, AgpState   = 0x1f000217 (hardware caps of chipset)

Jun  7 17:03:34 localhost kernel: agpgart: Found an AGP 2.0 compliant device at 0000:00:00.0.

Jun  7 17:03:34 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:00.0 into 4x mode

Jun  7 17:03:34 localhost kernel: agpgart: Putting AGP V2 device at 0000:01:00.0 into 4x mode

Jun  7 17:03:34 localhost kernel: [fglrx] AGP enabled,  AgpCommand = 0x1f000314 (selected caps)

Jun  7 17:03:34 localhost kernel: [fglrx] free  AGP = 54800384

Jun  7 17:03:34 localhost kernel: [fglrx] max   AGP = 54800384

Jun  7 17:03:34 localhost kernel: [fglrx] free  LFB = 40951808

Jun  7 17:03:34 localhost kernel: [fglrx] max   LFB = 40951808

Jun  7 17:03:34 localhost kernel: [fglrx] free  Inv = 0

Jun  7 17:03:34 localhost kernel: [fglrx] max   Inv = 0

Jun  7 17:03:34 localhost kernel: [fglrx] total Inv = 0

Jun  7 17:03:34 localhost kernel: [fglrx] total TIM = 0

Jun  7 17:03:34 localhost kernel: [fglrx] total FB  = 0

Jun  7 17:03:34 localhost kernel: [fglrx] total AGP = 16384 <--
```

A few days ago, I fixed the known MTTR allocation failure:

```

Jun  5 07:30:30 localhost kernel: mtrr: 0xe8000000,0x4000000 overlaps existing 0xe8000000,0x1000000

Jun  5 07:30:30 localhost kernel: [fglrx:firegl_addmap] *ERROR* mtrr allocation failed (-22)
```

with a simple script posted on https://forums.gentoo.org/viewtopic.php?t=120178&highlight=fglrx+freeze.  I assiged 64M to the graphics card and nothing complained.  Is there some similar fix for the total AGP memory? like a module parameter to agpgart? I will the VideoRam XF86Config option, but this appears to be something X is given, not something it can configure. :Idea:   I recall, in the dark ages of 2.2.x, a value one passed to the kernel  :Question: 

vap0rtranz

BTW, here is opengl correctly identifying the card:

```

patrick root # fglrxinfo

display: :0.0  screen: 0

OpenGL vendor string: ATI Technologies Inc.

OpenGL renderer string: MOBILITY FIRE GL 9000 DDR Pentium 4 (SSE2)

OpenGL version string: 1.3 (X4.3.0-3.2.8)
```

----------

## b0fh_

Somewehere in your bios setup (assuming you are using a PC) is a setting called "AGP aperture size". What does it read? Set it to the amount of video ram in your card.

peace

----------

## vap0rtranz

b0fh_

I never changed that setting, but checked it as a good 'duh' fix.  BIOS reports "Video RAM: 64M".  I did discover, however, that Dell posted an update to the Inspiron 600m BIOS last week.  Their fixes do not appear to fix video/memory problems, but will avoid flashing things until necessary.

Besides, I would expect MTRR to barf if I asked it to allocate more memory than BIOS reported.  Here was my fix:

```

patrick root # cat /etc/conf.d/mtrr

#!/bin/bash

echo "disable=2" >| /proc/mtrr

echo "base=0xe8000000 size=0x4000000 type=write-combining" > /proc/mtrr
```

with good results for register 2:

```
patrick root # cat /proc/mtrr

reg00: base=0x00000000 (   0MB), size= 512MB: write-back, count=1

reg01: base=0xfeda0000 (4077MB), size= 128KB: write-through, count=1

reg02: base=0xe8000000 (3712MB), size=  64MB: write-combining, count=2  <---

reg03: base=0xf0000000 (3840MB), size=  64MB: write-combining, count=1

```

If MTRR gave 64M, why didn't the kernel do the same for AGP?    :Confused: 

----------

## b0fh_

ouch, laptop...

laptops usually don't let you adjust the "agp aperture size" in the bios (did you check it? aperture size is not related to the video memory size) 

But I am talking about PCs with AGP slots here... they usually have this setting under the 'advanced' bios tab. The 'aperture size' aka 'agp memory' is exactly what the agpgart driver manages. It doesn't need to be the same as the display adapter's memory, but values range from 4 to 256 megs in recent mobos.

And I don't think the mtrr is related to this, as for the above reasoning... If you happen to get your hands on a modern PC, with an 'open' bios, like AMI or Award, enter the setup and see the thing for yourself  :Wink: . 

For example, when my laptop boots:

--SNIP--

Jun  5 11:58:46 cate Linux agpgart interface v0.99 (c) Jeff Hartmann

Jun  5 11:58:46 cate agpgart: Maximum main memory to use for agp memory: 439M

Jun  5 11:58:46 cate agpgart: Detected Intel i845 chipset

Jun  5 11:58:46 cate agpgart: AGP aperture is 256M @ 0x60000000

--SNIP

but my mobility radeon is only 32 megs... compaq's bios is fucked up and doesn't even let me fix this. bleh. At least they are on the upper side error, so not much of a performance hit.

On my desktop, OTOH, the bios setting matches exactly the memory on the geforce, 128 megs...

peace.

----------

## vap0rtranz

b0fh_

 *Quote:*   

> If you happen to get your hands on a modern PC, with an 'open' bios, like AMI or Award, enter the setup and see the thing for yourself . 

 

Perhaps ... but that sounds enigmatic.    :Shocked:    Your post did prompt me to double-check the AGP module.  I found agpgart detecting a 64M aperture:

```

Jun  8 14:42:30 localhost kernel: Real Time Clock Driver v1.12

Jun  8 14:42:30 localhost kernel: Linux agpgart interface v0.100 (c) Dave Jones

Jun  8 14:42:30 localhost kernel: agpgart: Detected an Intel 855PM Chipset.

Jun  8 14:42:30 localhost kernel: agpgart: Maximum main memory to use for agp memory: 439M

Jun  8 14:42:30 localhost kernel: agpgart: AGP aperture is 64M @ 0xf0000000
```

The kernel's ERROR messages (posted above) are complaining about allocating memory -- when fglrx loads.  Can one configure fglrx?

vap0rtranz

----------

## b0fh_

Then your aperture is corretly set... probably a bug/weirdness in the fgrlx thing. Sorry can't help ya with that since that driver doesn't even support my ATI card (mobility 7500). Way to go, ATI  :Wink: 

peace.

----------

## vap0rtranz

www.gentoo.it hosts something about my problem, but I cannot decipher whether I recompile the kernel or compile ati-drivers.  I asked the Italian forum if someone can help me finish tranlating:

http://www.gentoo.it/tips/ATI-Driver.html.

Moderators:  I dislike double-posting just as much as you!  :Wink:   My Italian post, https://forums.gentoo.org/viewtopic.php?p=1225725#1225725, is merely to help translate a Gentoo doc.  Let me know if there is a better way to share docs in different languages.

vap0rtranz

----------

## r3pek

 *b0fh_ wrote:*   

> The 'aperture size' aka 'agp memory'

 

really BIG wrong information!!!

aperture size it's NOT agp memory!

aperture size is the amount of system memory that the video card can allocate as if is was video memory. so if you put a large amount of aperture size, very system memory will be used for the video card will it could be used for the system itself...

----------

## b0fh_

 *r3pek wrote:*   

>  *b0fh_ wrote:*   The 'aperture size' aka 'agp memory' 
> 
> really BIG wrong information!!!
> 
> aperture size it's NOT agp memory!
> ...

 

aw dude, read carefully... 'agp aperture' aka 'agp memory', not 'agp aperture' aka 'video card memory'... big difference... And no, the memory is not 'stolen' from the system's ram... it is just an amount of the video card memory 'mapped' as if it were system memory, I think. I like to set the aperture to the total video card RAM, but it can be bigger or smaller. I think using the same sizes may achieve optimal performance, but if anyone can say otherwise, feel free to share your insights  :Wink: 

peace.

----------

## vap0rtranz

 *Quote:*   

> b0fh_wrote: ... I think ...

 

Although dated, I found John Carmack's explanation of how glx uses AGP to be fairly definitive.  The original agpgart developer, Jeff Hartmann, appears to have fallen off the planet.  Hopefully I can resolve the error without 'em.   :Rolling Eyes: 

How involved is intel_agp in allocating video memory?  Although every doc tells me to compile it as a module, I cannot find intel_agp in any logfile despite loading after agpgart.

```
patrick root # modinfo intel_agp

author:         Dave Jones <davej@codemonkey.org.uk>

license:        GPL and additional rights

vermagic:       2.6.5-gentoo-r1 preempt PENTIUMM gcc-3.3

depends:        agpgart

alias:          pci:v00008086d*sv*sd*bc06sc00i00*

patrick root # lsmod 

...

fglrx                 202884  8

intel_agp              16156  1

agpgart                28392  2 intel_agp

...
```

vap0rtranz

----------

## r3pek

 *b0fh_ wrote:*   

>  *r3pek wrote:*    *b0fh_ wrote:*   The 'aperture size' aka 'agp memory' 
> 
> really BIG wrong information!!!
> 
> aperture size it's NOT agp memory!
> ...

 

take a look at this explanation:

How big should I set AGP Aperture size in my BIOS?

First of all, AGP Aperture memory will not be used until your video card's on-board memory is running low. That means it will usually not impact your gaming performance because developers are trying hard to not exceed the on-board memory limits.

The bigger your video memory, the smaller your Aperture Size could be. However with later games requiring more and more texture memory a good number seems to be 128MB Aperture Size for all cards with 64 MB to 256 MB Video RAM.

Setting the Aperture Size to HUGE values will not increase performance because this merely sets the maximum amount of physical memory that can be used. It only makes the GART Table bigger because every 4K page has its own entry, no matter if allocated or not.

Setting the Aperture Size to too small values could result in running out of available texture memory especially on a low-mem video card. It is also possible that developers make use of the GART's features by creating textures as 'non-local'.

(in http://www.ocfaq.com/article.php/overclocking/vidcard/43)

----------

## vap0rtranz

 *Quote:*   

> r3pek wrote: However with later games requiring more and more texture memory a good number seems to be 128MB Aperture Size for all cards with 64 MB to 256 MB Video RAM.

 

Precisely the reason I posted.  It would be awesome to let Windoz die-hards play 3D games on my Linux laptop when we happen to bump into one another at the local wireless cafe!  :Razz:   Intense gamers notice textures, reflections on starships, and other insane things that keep them on XP.  

On your note of aperture size, it does not appear fglrx knows about the larger size the pci bus sees:

```

patrick root # lspci -v

...

00:01.0 PCI bridge: Intel Corp. 82855PM Processor to AGP Controller (rev 03) (prog-if 00 [Normal decode])

        Flags: bus master, 66Mhz, fast devsel, latency 32

        Bus: primary=00, secondary=01, subordinate=01, sec-latency=32

        I/O behind bridge: 0000c000-0000cfff

        Memory behind bridge: fc000000-fdffffff

        Prefetchable memory behind bridge: e8000000-efffffff

...

01:00.0 VGA compatible controller: ATI Technologies Inc Radeon R250 Lf [Radeon Mobility 9000 M9] (rev 01) (prog-if 00 [VGA])

        Subsystem: Dell Computer Corporation: Unknown device 011e

        Flags: bus master, VGA palette snoop, stepping, 66Mhz, medium devsel, latency 255, IRQ 11

        Memory at e8000000 (32-bit, prefetchable) [size=128M]  <---

        I/O ports at c000 [size=256]

        Memory at fcff0000 (32-bit, non-prefetchable) [size=64K]

        Expansion ROM at <unassigned> [disabled] [size=128K]

        Capabilities: [58] AGP version 2.0

        Capabilities: [50] Power Management version 2

...

```

Compare 128M to the 64M aperture size I posted above:

 *Quote:*   

> vap0rtranz_wrote: I found agpgart detecting a 64M aperture:
> 
> Code:
> 
> Jun  8 14:42:30 localhost kernel: Real Time Clock Driver v1.12
> ...

 

I do not believe it utopic to expect my video card module can access a larger aperture.  lspci is probably reporting this size as described in Intel's spec, where the i855PM's can (somehow  :Exclamation:  ) be set as high as 256M.

Where is fglrx getting is aperture information?

vap0rtranz

PS:  Much thanks to the Italian forum for reminding me to remerge ati-drivers after kernel compiles!  Doing so fixes the "*ERROR* agp_allocate_memory_phys_list failed" message.  Globalization has benefits!  :Shocked: 

VideoRam option warned me that X already knew about the 64M, and it being 64-bit DDR.  At least fglrx knows how much memory is local to my radeon card.  

```
patrick root # less /var/log/XFree86.0.log

...

(II) Loading sub module "int10"

(II) LoadModule: "int10"

(II) Loading /usr/X11R6/lib/modules/linux/libint10.a

(II) Module int10: vendor="The XFree86 Project"

        compiled for 4.3.0.1, module version = 1.0.0

        ABI class: XFree86 Video Driver, version 0.6

(II) fglrx(0): initializing int10

(II) fglrx(0): Primary V_BIOS segment is: 0xc000

(**) fglrx(0): Option "mtrr" "off"

(--) fglrx(0): Chipset: "ATI RV250 Lf (M9)" (Chipset = 0x4c66)

(--) fglrx(0): (PciSubVendor = 0x1028, PciSubDevice = 0x011e)

(--) fglrx(0): board vendor info: third party grafics adapter - NOT original ATI(--) fglrx(0): Linear framebuffer (phys) at 0xe8000000

(--) fglrx(0): MMIO registers at 0xfcff0000

(--) fglrx(0): ChipExtRevID = 0x01

(--) fglrx(0): ChipIntRevID = 0x00

(II) fglrx(0): Video RAM override, using 65536 kB instead of 65536 kB  <---

(**) fglrx(0): VideoRAM: 65536 kByte (64-bit DDR SDRAM)

(WW) fglrx(0): board is an unknown third party board, chipset is supported

...
```

----------

## b0fh_

r3pek, vap0r, 

Thanks for the links/information... I tought the videocard would not use mobo's memory, but that is wrong... according to carmack's article, it always use some, and probably can use up to the total agp aperture size, but this seems pretty unlikely with modern cards that have gobs of RAM and thus can keep tons of textures and frames in their own memory  :Wink: 

r3pek, note that the aperture will not necessarly 'eat' your mobo's memory, it is up to the GL driver to allocate it, and most drivers will prefer to use the video card's memory since it's a lot faster. Thank god, or else I would be screwed with my laptop, half of its memory would be used by agp since there seems no way to change the aperture size from 256M (maybe compile agpgart as module and use some parameter, will investigate further).

vap0r,

```
(II) fglrx(0): Primary V_BIOS segment is: 0xc000

(**) fglrx(0): Option "mtrr" "off"   <---

(--) fglrx(0): Chipset: "ATI RV250 Lf (M9)" (Chipset = 0x4c66) 

```

does that realy mean that MTRRs are turned off? If I remember correctly, memory xfers go like turtles without mtrr...

peace.

----------

## vap0rtranz

 *Quote:*   

> b0fh_ wrote:
> 
> does that realy mean that MTRRs are turned off?

 

I wondered the same thing.  According to the comment added by fglrxconfig to my XF86Config, it doesn't:

```

...

# === misc DRI settings ===

Option "mtrr" "off" # disable DRI mtrr mapper, driver has its own code for mtrr

...

```

The comment makes sense because I do not compile DRI into the kernel.  Whether the ATI developers' MTRR mapper grabs correct aperture and memory sizes -- that is my next question.

vap0rtranz

----------

## BlindSpy

This is a great topic - i've been having the same problems with my radeon 9600 pro 128mb AGP card.

My xorg error log is here: http://blindspy.homelinux.org:8080/~blindspy/xorg.log

and my xorg.conf is here: http://blindspy.homelinux.org:8080/~blindspy/xorg.conf

dmesg:

```
fglrx: module license 'Proprietary. (C) 2002 - ATI Technologies, Starnberg, GERMANY' taints kernel.

[fglrx] Maximum main memory to use for locked dma buffers: 431 MBytes.

[fglrx] module loaded - fglrx 3.9.0 [May 11 2004] on minor 0

mtrr: 0xc0000000,0x8000000 overlaps existing 0xc0000000,0x400000                <== Concern

[fglrx:firegl_addmap] *ERROR* mtrr allocation failed (-22)                        <== Concern

[fglrx] Maximum main memory to use for locked dma buffers: 431 MBytes.

[fglrx] AGP detected, AgpState   = 0x1f000a0b (hardware caps of chipset)

agpgart: Found an AGP 3.5 compliant device at 0000:00:00.0.

agpgart: Putting AGP V3 device at 0000:00:00.0 into 8x mode

agpgart: Putting AGP V3 device at 0000:01:00.0 into 8x mode

[fglrx] AGP enabled,  AgpCommand = 0x1f000302 (selected caps)

[fglrx] free  AGP = 121909248

[fglrx] max   AGP = 121909248

[fglrx] free  LFB = 116391936

[fglrx] max   LFB = 116391936

[fglrx] free  Inv = 0

[fglrx] max   Inv = 0

[fglrx] total Inv = 0

[fglrx] total TIM = 0

[fglrx] total FB  = 0

[fglrx] total AGP = 32768

```

Look at the 2 lines I marked. I have no idea what they mean but i've found something on the guide i used to set up my ATI card:

http://odin.prohosting.com/wedge01/gentoo-radeon-faq.html#4_mtrroverlap

and this tells a lot ("It's just users who've enabled vesa framebuffer who have this problem."):

http://www.rage3d.com/board/showthread.php?threadid=33736241

----------

## BlindSpy

dmesg:

```
mtrr: 0xc0000000,0x8000000 overlaps existing 0xc0000000,0x400000

[root@OptimusPrime]:~# cat /proc/mtrr

reg00: base=0x00000000 (   0MB), size= 512MB: write-back, count=1

reg01: base=0xe0000000 (3584MB), size= 128MB: write-combining, count=2

reg02: base=0xc0000000 (3072MB), size=   4MB: write-combining, count=2

reg04: base=0xc0400000 (3076MB), size=   2MB: write-combining, count=1

reg05: base=0xe0000000 (3584MB), size= 128MB: write-combining, count=1
```

script:

```
#!/bin/bash

 

echo "disable=3" >| /proc/mtrr

echo "base=0xc0000000 size=0x8000000 type=write-combining" > /proc/mtrr
```

after running the script im still getting overlap and allocation errors?

----------

## vap0rtranz

 *Quote:*   

> BlindSpy wrote:
> 
> after running the script im still getting overlap and allocation errors?

 

It appears the script allocates memory to a register that DNE (DoesNotExist)!   :Shocked:   dmesg skips register 3, so it seems abscent from your system although present in the ATI examples.  According to your xorg.log, local video memory is allocated through register 2.  (Notice the hex address listed above in #echo /proc/mtrr compared to this snippit from xorg.log)

```
(--) PCI:*(1:0:0) ATI Technologies Inc RV350 AP [Radeon 9600] rev 0, Mem @ 0xc0000000/28, 0xe8020000/16, I/O @ 0xc000/8
```

But, your script changes register 3.

```
echo "disable=3" >| /proc/mtrr 
```

Edit your script to read "disable=2" and rerun the script.

vap0rtranz

----------

## BlindSpy

Ah thanks a lot   :Very Happy: 

----------

## vap0rtranz

Just wanted to document that the April 4th drivers (8.12.10) change memory usage for FireGL cards.  Free AGP memory decreases while total AGP memory increases.   :Rolling Eyes: 

```
Apr 15 19:56:46 localhost kernel: fglrx: module license 'Proprietary. (C) 2002 -

 ATI Technologies, Starnberg, GERMANY' taints kernel.

Apr 15 19:56:46 localhost kernel: [fglrx] Maximum main memory to use for locked 

dma buffers: 431 MBytes.

Apr 15 19:56:46 localhost kernel: [fglrx] module loaded - fglrx 8.12.10 [Apr  4 

2005] on minor 0

....

Apr 15 19:57:07 localhost kernel: [fglrx] AGP detected, AgpState   = 0x1f000217 

(hardware caps of chipset)

Apr 15 19:57:07 localhost kernel: agpgart: Found an AGP 2.0 compliant device at 

0000:00:00.0.

Apr 15 19:57:07 localhost kernel: agpgart: Putting AGP V2 device at 0000:00:00.0

 into 4x mode

Apr 15 19:57:07 localhost kernel: agpgart: Putting AGP V2 device at 0000:01:00.0

 into 4x mode

Apr 15 19:57:07 localhost kernel: [fglrx] AGP enabled,  AgpCommand = 0x1f000314 

(selected caps)

Apr 15 19:57:07 localhost kernel: [fglrx] free  AGP = 121909248  <---------------+

Apr 15 19:57:07 localhost kernel: [fglrx] max   AGP = 121909248

Apr 15 19:57:07 localhost kernel: [fglrx] free  LFB = 47165440

Apr 15 19:57:07 localhost kernel: [fglrx] max   LFB = 47165440

Apr 15 19:57:07 localhost kernel: [fglrx] free  Inv = 0

Apr 15 19:57:07 localhost kernel: [fglrx] max   Inv = 0

Apr 15 19:57:07 localhost kernel: [fglrx] total Inv = 0

Apr 15 19:57:07 localhost kernel: [fglrx] total TIM = 0

Apr 15 19:57:07 localhost kernel: [fglrx] total FB  = 0

Apr 15 19:57:07 localhost kernel: [fglrx] total AGP = 32768  <---------------+

```

----------

## vap0rtranz

Oh!  And my mtrr registers changed.  reg03 increased by 64M, explaining the AGP aperture increase in my previous post.  Odd!

```
patrick linux # cat /proc/mtrr 

reg00: base=0x00000000 (   0MB), size= 512MB: write-back, count=1

reg01: base=0xfeda0000 (4077MB), size= 128KB: write-through, count=1

reg02: base=0xe8000000 (3712MB), size=  64MB: write-combining, count=2

reg03: base=0xe0000000 (3584MB), size= 128MB: write-combining, count=1  <------------------+

```

----------

## Lucky B

btw for laptops with IGP Radeons what the BIOS thing does is change how much system memory gets reserved for the video card, in this case it IS stolen from your system. It usually has nada to do with AGP apperture.

----------

## vap0rtranz

Well, that doesn't matter for my Dell laptop.  Even after updating to the most recent BIOS (A14), users cannot change the AGP size.

----------

