Difference between revisions of "Swap on video ram"

From ArchWiki
Jump to: navigation, search
(clarified the intro)
(describe how to limit VideoRam taken by X)
Line 2: Line 2:
 
[[Category:Other hardware]]
 
[[Category:Other hardware]]
 
{{stub}}
 
{{stub}}
Warning: the stuff in here is not tested that much, and it is possible that you will run out of video ram/have a conflict and your xserver will crash.
+
Warning: the stuff in here is not tested that much, and it is possible that you may have a conflict and your xserver will crash.
To be absolutely sure of stability, you can use the vga xorg driver, where you can set a specific amount of videoram, (unlike other foss or binary drivers, which seem to ignore attempts to set videoram = 16 or whatever).
+
To be absolutely sure of stability, use an xorg driver that allows you to override videoram. At least the vga and radeon (xf86-video-ati) listen to an overide.
  
 
The fast memory on your graphics card (if you have one) can be used as general ram (actually swap) by using the MTD subsystem of the kernel. MTD is now included in kernel26.
 
The fast memory on your graphics card (if you have one) can be used as general ram (actually swap) by using the MTD subsystem of the kernel. MTD is now included in kernel26.
Line 16: Line 16:
 
<pre>lspci -vvv</pre>
 
<pre>lspci -vvv</pre>
  
you then look for the sections that name your video card as an example mine is here:
+
Then you look for the sections that name your video card as an example mine is here:
  
 
<pre>
 
<pre>
Line 43: Line 43:
 
</pre>
 
</pre>
  
So what's important is the Region 0, or the biggest one (it seems possible to use the addresses of either the primary or secondary)
+
What's important is Region 0, (the biggest one)  
  
The video card needs some ram to function as a video card, and this space you leave at the start of the address range. Choose how much space you can spare; maybe it is 16MiB which is 0x01000000. or maybe some more.
+
The video card needs some ram to serve its normal purpose, so you need to do some calculations. The offsets are easy to calculate as powers of 2. The card uses the begining of the address range as framebuffer, textures etc. when it is limited (pretty sure about this, but maybe your driver could be different).  
  
Your start of the range is then the sum of that offset and the initial address range: I would have added 0x01000000 to 0xe00000000 to get the start
+
Example: total 2^28 bytes (256M) videoram, leaving 2^24 (32M) for the normal function (less will work fine)
 +
The start range, is 2^24 bytes more than the start of the pci address range shown by lspci -vvv.
 +
 
 +
The end is your total minus the amount you left for the card.
  
 
<pre>
 
<pre>
 
# for using vram as swap
 
# for using vram as swap
modprobe slram map=VRAM,0xSTART RANGE HERE,0xEND
+
modprobe mtdblock slram map=VRAM,0xSTART RANGE,+0xWHAT IS USED
modprobe mtdchar #probably unnecessary
+
modprobe mtdblock
+
 
mkswap /dev/mtdblock0
 
mkswap /dev/mtdblock0
swapon /dev/mtdblock0 -p 10 #higher priority gets used before disk
+
swapon /dev/mtdblock0 -p 10 #higher priority to be swapped to before disk
 +
</pre>
 +
 
 +
=Xorg Driver Config=
 +
To keep X stable, you have to tell your video driver to take a small part of the videoram. In the Device section of your /etc/X11/xorg.conf the declaration
 +
<pre>
 +
Section "Device"
 +
    Driver "radeon"
 +
    VideoRam 32768
 +
EndSection
 
</pre>
 
</pre>
 +
specifies that you use 32 MiB of ram. Other drivers might take the number for videoram as being in MiB (I think vga does), check manpages.
  
 
==External Links==
 
==External Links==
 
[http://www.linux-mtd.infradead.org MTD website]
 
[http://www.linux-mtd.infradead.org MTD website]
 
[http://gentoo-wiki.com/TIP_Use_memory_on_video_card_as_swap Gentoo Wiki]
 
[http://gentoo-wiki.com/TIP_Use_memory_on_video_card_as_swap Gentoo Wiki]

Revision as of 02:01, 8 December 2007

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Swap on video ram#)

Warning: the stuff in here is not tested that much, and it is possible that you may have a conflict and your xserver will crash. To be absolutely sure of stability, use an xorg driver that allows you to override videoram. At least the vga and radeon (xf86-video-ati) listen to an overide.

The fast memory on your graphics card (if you have one) can be used as general ram (actually swap) by using the MTD subsystem of the kernel. MTD is now included in kernel26.

How To

Kernel Stuff

Get a kernel version >= 2.6.23.1-6

Post-Kernel Stuff

When you are running a kernel with MTD modules, you have to load the modules specifying the pci address ranges that correspond to the ram on your video card.

check the ranges with

lspci -vvv

Then you look for the sections that name your video card as an example mine is here:

01:00.0 VGA compatible controller: ATI Technologies Inc RV350 AR [Radeon 9600] (prog-if 00 [VGA])
ubsystem: PC Partner Limited Unknown device 0830

ntrol: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
tatus: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
ency: 64 (2000ns min), Cache Line Size: 32 byteserrupt: pin A routed to IRQ 11
egion 0: Memory at e0000000 (32-bit, prefetchable) [size=256M]
egion 1: I/O ports at c800 [size=256]
egion 2: Memory at ff8f0000 (32-bit, non-prefetchable) [size=64K]
ion ROM at ff8c0000 [disabled] [size=128K]

ies: <access denied>

01:00.1 Display controller: ATI Technologies Inc RV350 AR [Radeon 9600] (Secondary)
ubsystem: PC Partner Limited Unknown device 0831

ntrol: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
tatus: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
ency: 64 (2000ns min), Cache Line Size: 32 bytes
egion 0: Memory at d0000000 (32-bit, prefetchable) [size=256M]
egion 1: Memory at ff8e0000 (32-bit, non-prefetchable) [size=64K]
ies: <access denied>

What's important is Region 0, (the biggest one)

The video card needs some ram to serve its normal purpose, so you need to do some calculations. The offsets are easy to calculate as powers of 2. The card uses the begining of the address range as framebuffer, textures etc. when it is limited (pretty sure about this, but maybe your driver could be different).

Example: total 2^28 bytes (256M) videoram, leaving 2^24 (32M) for the normal function (less will work fine) The start range, is 2^24 bytes more than the start of the pci address range shown by lspci -vvv.

The end is your total minus the amount you left for the card.

# for using vram as swap
modprobe mtdblock slram map=VRAM,0xSTART RANGE,+0xWHAT IS USED
mkswap /dev/mtdblock0
swapon /dev/mtdblock0 -p 10 #higher priority to be swapped to before disk

Xorg Driver Config

To keep X stable, you have to tell your video driver to take a small part of the videoram. In the Device section of your /etc/X11/xorg.conf the declaration

Section "Device"
    Driver "radeon"
    VideoRam 32768
EndSection

specifies that you use 32 MiB of ram. Other drivers might take the number for videoram as being in MiB (I think vga does), check manpages.

External Links

MTD website Gentoo Wiki