Difference between revisions of "Swap on video ram"

From ArchWiki
Jump to: navigation, search
m (cleanup)
(update for inclusion of MTD to kernel26)
Line 2: Line 2:
 
[[Category:Other hardware]]
 
[[Category:Other hardware]]
 
{{stub}}
 
{{stub}}
This is a work in progress
+
This is a work in progress: 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.
  
 
The fast memory on your graphics card (if you have one) can be used as general ram by using the MTD subsystem of the kernel. At the moment that part is not included in the stock arch kernel, so you have to build your own kernel. Using [[ABS]] is probably the easiest way.
 
The fast memory on your graphics card (if you have one) can be used as general ram by using the MTD subsystem of the kernel. At the moment that part is not included in the stock arch kernel, so you have to build your own kernel. Using [[ABS]] is probably the easiest way.
Line 8: Line 8:
 
==How To==
 
==How To==
 
===Kernel Stuff===
 
===Kernel Stuff===
You can rebuild the whole kernel as shown here. The modules can probably be built separately though (perhaps with a pkgbuild)
+
Get a kernel version >= 2.6.23.1-6
# Get the [[ABS]] tree
+
===Post-Kernel Stuff===
# copy the /var/abs/kernels/kernel26 to /var/abs/local/kernel26-mtd, that will be your working directory
+
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.
# change the name of the package to something else ie. from kernel26 to kernel26-mtd or something like that
+
 
# get and extract the sources with <pre>makepkg -o</pre>
+
check the ranges with  
# modify the configuration of the kernel, adding
+
<pre>lspci -vvv</pre>
## mtd_block (maybe mtd_char)
+
 
## mtd_slram
+
you then look for the sections that name your video card as an example mine is here:
## mtd_phram (alternative and successor to slram)
+
## mtd_ram probably too.
+
## other settings that go with those choices:
+
<pre>CONFIG_MTD_MAP_BANK_WIDTH_1=y
+
CONFIG_MTD_MAP_BANK_WIDTH_2=y
+
CONFIG_MTD_MAP_BANK_WIDTH_4=y
+
# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+
# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+
# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+
CONFIG_MTD_CFI_I1=y
+
CONFIG_MTD_CFI_I2=y</pre>
+
  
That's what the mtd section of my config ends up looking like. You can add this (almost?) anywhere in the config; just search for MTD, and replace the '#CONFIG_MTD= # is not set' with something else:
 
 
<pre>
 
<pre>
# Memory Technology Devices (MTD)
+
01:00.0 VGA compatible controller: ATI Technologies Inc RV350 AR [Radeon 9600] (prog-if 00 [VGA])
#
+
ubsystem: PC Partner Limited Unknown device 0830
CONFIG_MTD=m
+
# CONFIG_MTD_DEBUG is not set
+
# CONFIG_MTD_CONCAT is not set
+
CONFIG_MTD_PARTITIONS=y
+
# CONFIG_MTD_REDBOOT_PARTS is not set
+
  
#
+
ntrol: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
# User Modules And Translation Layers
+
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
CONFIG_MTD_CHAR=m
+
egion 0: Memory at e0000000 (32-bit, prefetchable) [size=256M]
# CONFIG_MTD_BLKDEVS is not set
+
egion 1: I/O ports at c800 [size=256]
CONFIG_MTD_BLOCK=m # is not set
+
egion 2: Memory at ff8f0000 (32-bit, non-prefetchable) [size=64K]
# CONFIG_MTD_BLOCK_RO is not set
+
ion ROM at ff8c0000 [disabled] [size=128K]
# CONFIG_FTL is not set
+
# CONFIG_NFTL is not set
+
# CONFIG_INFTL is not set
+
# CONFIG_RFD_FTL is not set
+
# CONFIG_SSFDC is not set
+
  
#
+
ies: <access denied>
# RAM/ROM/Flash chip drivers
+
#
+
# CONFIG_MTD_CFI is not set
+
# CONFIG_MTD_JEDECPROBE is not set
+
CONFIG_MTD_MAP_BANK_WIDTH_1=y
+
CONFIG_MTD_MAP_BANK_WIDTH_2=y
+
CONFIG_MTD_MAP_BANK_WIDTH_4=y
+
# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+
# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+
# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+
CONFIG_MTD_CFI_I1=y
+
CONFIG_MTD_CFI_I2=y
+
# CONFIG_MTD_CFI_I4 is not set
+
# CONFIG_MTD_CFI_I8 is not set
+
CONFIG_MTD_RAM=m
+
# CONFIG_MTD_ROM is not set
+
# CONFIG_MTD_ABSENT is not set
+
# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
  
#
+
01:00.1 Display controller: ATI Technologies Inc RV350 AR [Radeon 9600] (Secondary)
# Mapping drivers for chip access
+
ubsystem: PC Partner Limited Unknown device 0831
#
+
# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+
# CONFIG_MTD_TS5500 is not set
+
CONFIG_MTD_PLATRAM=m
+
  
#
+
ntrol: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
# Self-contained MTD device drivers
+
tatus: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
#
+
ency: 64 (2000ns min), Cache Line Size: 32 bytes
# CONFIG_MTD_PMC551 is not set
+
egion 0: Memory at d0000000 (32-bit, prefetchable) [size=256M]
# CONFIG_MTD_DATAFLASH is not set
+
egion 1: Memory at ff8e0000 (32-bit, non-prefetchable) [size=64K]
# CONFIG_MTD_M25P80 is not set
+
ies: <access denied>
CONFIG_MTD_SLRAM=m
+
</pre>
CONFIG_MTD_PHRAM=m
+
# CONFIG_MTD_MTDRAM is not set
+
# CONFIG_MTD_BLOCK2MTD is not set
+
  
#
+
So what's important is the Region 0 (it seems possible to use the addresses of either the primary or secondary)
# Disk-On-Chip Device Drivers
+
#
+
# CONFIG_MTD_DOC2000 is not set
+
# CONFIG_MTD_DOC2001 is not set
+
# CONFIG_MTD_DOC2001PLUS is not set
+
  
#
+
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.
# NAND Flash Device Drivers
+
 
#
+
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
# CONFIG_MTD_NAND is not set
+
  
#
 
# OneNAND Flash Device Drivers
 
#
 
# CONFIG_MTD_ONENAND is not set
 
</pre>
 
===Post-Kernel Stuff===
 
When you are running the new kernel with those modules built, you choose the pci address ranges where the device goes and then add something like the following to your rc.local:
 
 
<pre>
 
<pre>
 
# for using vram as swap
 
# for using vram as swap
modprobe slram map=VRAM,0xSTART RANGE HERE,+0xGOING THIS MUCH FARTHER
+
modprobe slram map=VRAM,0xSTART RANGE HERE,0xEND
 
modprobe mtdchar #probably unnecessary
 
modprobe mtdchar #probably unnecessary
 
modprobe mtdblock
 
modprobe mtdblock
Line 116: Line 56:
 
swapon /dev/mtdblock0 -p 10 #higher priority gets used before disk
 
swapon /dev/mtdblock0 -p 10 #higher priority gets used before disk
 
</pre>
 
</pre>
you get the whole range you can take from lspci -vvv, looking for something that names your video card.
 
 
Learn hex arithmetic, or use a calculator (qalculate). You leave a certain space at the beginning of the address range, so that you graphics card can still function which is at least 4MiB if you decide to use the vga driver (at up to 1280x1024).
 
====Example====
 
<pre>
 
lspci -vvv
 
01:00.0 VGA compatible controller: ATI Technologies Inc RV350 AR [Radeon 9600] (prog-if 00 [VGA])
 
Subsystem: PC Partner Limited Unknown device 0830
 
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
 
Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
 
Latency: 64 (2000ns min), Cache Line Size: 32 bytes
 
Interrupt: pin A routed to IRQ 11
 
'' Region 0: Memory at e0000000 (32-bit, prefetchable) [size=256M]''
 
Region 1: I/O ports at c800 [size=256]
 
Region 2: Memory at ff8f0000 (32-bit, non-prefetchable) [size=64K]
 
Expansion ROM at ff8c0000 [disabled] [size=128K]
 
Capabilities: [58] AGP version 2.0
 
Status: RQ=80 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64- HTrans- 64bit- FW+ AGP3- Rate=x1,x2,x4
 
Command: RQ=32 ArqSz=0 Cal=0 SBA+ AGP+ GART64- 64bit- FW- Rate=x4
 
Capabilities: [50] Power Management version 2
 
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
 
Status: D0 PME-Enable- DSel=0 DScale=0 PME-
 
</pre>
 
So here I have an address range starting at 0xe0000000, with a size of 256MiB, aka +0x10000000.
 
 
So choose how much space you can spare; maybe it is 16MiB which is 0x01000000.
 
 
That space has to be at the start of the address range: add 0x01000000 to 0xe00000000 to get the start, and then subtract that from the end to make sure that you are using the whole space.
 
  
 
==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 20:57, 27 October 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#)

This is a work in progress: 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.

The fast memory on your graphics card (if you have one) can be used as general ram by using the MTD subsystem of the kernel. At the moment that part is not included in the stock arch kernel, so you have to build your own kernel. Using ABS is probably the easiest way.

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

you then 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>

So what's important is the Region 0 (it seems possible to use the addresses of either the primary or secondary)

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.

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

# for using vram as swap
modprobe slram map=VRAM,0xSTART RANGE HERE,0xEND
modprobe mtdchar #probably unnecessary
modprobe mtdblock
mkswap /dev/mtdblock0
swapon /dev/mtdblock0 -p 10 #higher priority gets used before disk

External Links

MTD website Gentoo Wiki