# [WORKAROUND] modular AGP/ disabled IOMMU in 2.6.18 on amd64

## dmpogo

I don't find a way to disable IOMMU in the new 2.6.18-r2 kernel on amd64 platform.

As I see, the old CONFIG_GART_IOMMU  option is split  into CONFIG_IOMMU and CONFIG_CALGARY_IOMMU.

menuconfig gives a handle for   CONFIG_CALGARY_IOMMU   but not for CONFIG_IOMMU  which is always set.

Is this by design or a bug ?

Since CONFIG_IOMMU is set,   kernel based AGP is forced,   and, say, nvidia AGP can't be used.

My problem is however different.  On my quad-opteron headless server I found (over a year ago) that without IOMMU=off and AGP=off

(there is no AGP bus at all on it) I expereienced some instabilities, so I'm a bit scared to have it enabled.Last edited by dmpogo on Tue Nov 21, 2006 2:04 am; edited 2 times in total

----------

## IanPo

my kernel is 2.6.18-r2, too.

I tried to set the option mentioned off manually in .config as well (was fighting with ati-drivers; according to the guide CONFIG_GART_IOMMU was to be set to "n").

Having "make" started i read something about "writing in .config" in console output.

I stopped compilation and peeped into .config - the option CONFIG_IOMMU was "y" again.

So i could've set option CALGARY_IOMMU but CONFIG_IOMMU.

My opinion: it's not a bug, it's a new feature.

In older kernels it was different: http://gentoo-wiki.com/HOWTO_ATI_on_amd64

Here's some explanations about IOMMU: http://www.linuxhq.com/kernel/v2.6/18-rc2/arch/x86_64/KconfigLast edited by IanPo on Mon Nov 20, 2006 8:56 pm; edited 1 time in total

----------

## nationdemon

Got the same prob on my girls amd64 the only one with such a god damned ati... sorry but these cards are annoying. It took me 3 days to get it running with glx and than after a month without probs the new kernel hits ground. I've found the header files of both recommended modules (agpgart and amd64-agp)... If I step back to 2.6.17-r8 Iam able to start X with real good results on glxgears and fgl_glxgears (and ati instead of mesa in glxinfo) after reinstalling ati-drivers. But with 2.6.18-r2 nothing works

I've tried to edit the .config setting the options to m and funny it is still m but neither agpgart nor amd64-agp had been installed. 

ps.: plz excuse my worse english

----------

## dmpogo

 *IanPo wrote:*   

> my kernel is 2.6.18-r2, too.
> 
> I tried to set the option mentioned off manually in .config as well (was fighting with ati-drivers; according to the guide CONFIG_GART_IOMMU was to be set to "n").
> 
> Having "make" started i read something about "writing in .config" in console output.
> ...

 

Bloody hell  :Sad:     Let see what can be done with EMBEDDED flag

I guess if you replace in  /usr/src/linux-2.6.18-gentoo-r2/arch/x86_64/Kconfig  the line

```

bool "IOMMU support" if EMBEDDED

```

by

```

bool "IOMMU support"

```

you will be able to disable IOMMU

Also, it seems that if you choose EMBEDDED flag, you will get an option to disable IOMMU (but what other side effects of that ?)Last edited by dmpogo on Mon Nov 20, 2006 9:09 pm; edited 4 times in total

----------

## dmpogo

 *IanPo wrote:*   

> my kernel is 2.6.18-r2, too.
> 
> I tried to set the option mentioned off manually in .config as well (was fighting with ati-drivers; according to the guide CONFIG_GART_IOMMU was to be set to "n").
> 
> Having "make" started i read something about "writing in .config" in console output.
> ...

 

Did you mean CONFIG_IOMMU, right ?  old CONFIG_GART_IOMMU is now CONFIG_IOMMU and CONFIG_CALGARY_IOMMU

----------

## IanPo

 *Quote:*   

> Did you mean CONFIG_IOMMU, right ?

 

Yes. Little mistake, sorry.

I'm gonna correct my previous posts.

This is how my Kernel Configuration looks:

```
                                                     [ ] Support for hot-pluggable CPUs (EXPERIMENTAL)                                                                        

                                                     [*] Provide RTC interrupt                                                                                                

                                                     [ ] IBM Calgary IOMMU support                                                                                            

                                                     --- Machine check support                                                                                                

                                                     [ ]   Intel MCE features                                                                                                 

                                                     [*]   AMD MCE features                                                                                                   
```

And now a piece of my .config:

```
CONFIG_HPET_EMULATE_RTC=y

CONFIG_IOMMU=y         <--------------------------------------- yeah, i meant this

# CONFIG_CALGARY_IOMMU is not set

CONFIG_SWIOTLB=y
```

Thanks for the hint about EMBEDDED flag. I'll try it.

----------

## nationdemon

@ dmpogo THX, it works again... Such an easy solution   :Embarassed:   :Embarassed: 

----------

## dmpogo

To summarize the workaround for those who wants/needs  the ability for in-kernel AGP to be disabled or compiled as a module and/or IOMMU disabled   on AMD64 under 2.6.18 kernels

In /usr/src/linux-2.6.18-gentoo-r2/arch/x86_64/Kconfig  replace the line 406

```

        bool "IOMMU support" if EMBEDDED

```

by

```

         bool "IOMMU support"

```

The IOMMU option will appear in kernel configuration and if disabled, AGP will not be forced.

It is up to you to decide whether you should disable IOMMU on your system.

I have filed a bug https://bugs.gentoo.org/show_bug.cgi?id=155805   but was sent upstream.Last edited by dmpogo on Tue Nov 21, 2006 4:07 pm; edited 1 time in total

----------

## IanPo

Blimey, i was doing it wrong! Value "n" is illegal in .config, should've used "is not set" instead. Those "y"s and "m"s led me the wrong way.   :Embarassed: 

No matter if you deleting "if EMBEDDED" as written above, just for the record.

----------

## IanPo

Now testing.

Before:

.config

```

CONFIG_HPET_EMULATE_RTC=y

CONFIG_IOMMU is not set <----------------- set it manually in editor

# CONFIG_CALGARY_IOMMU is not set
```

console:

```

sniffer linux # make

  HOSTCC  scripts/basic/fixdep

  HOSTCC  scripts/basic/docproc

  HOSTCC  scripts/kconfig/conf.o

  HOSTCC  scripts/kconfig/kxgettext.o

  HOSTCC  scripts/kconfig/mconf.o

  HOSTCC  scripts/kconfig/zconf.tab.o

  HOSTLD  scripts/kconfig/conf

scripts/kconfig/conf -s arch/x86_64/Kconfig

#

# configuration written to .config

#

  CHK     include/linux/version.h

  CHK     include/linux/utsrelease.h

  CC      arch/x86_64/kernel/asm-offsets.s

make[1]: *** õÄÁÌÑÅÔÓÑ ÆÁÊÌ `arch/x86_64/kernel/asm-offsets.s'  <-------------------------------- interrupting make

make[1]: *** [arch/x86_64/kernel/asm-offsets.s] ðÒÅÒÙ×ÁÎÉÅ

make: *** [prepare0] ðÒÅÒÙ×ÁÎÉÅ

```

.config after make:

```

CONFIG_HPET_EMULATE_RTC=y

CONFIG_IOMMU=y <---------------------- is set to default by script as it's defined in Kconfig

# CONFIG_CALGARY_IOMMU is not set

```

Deleting "if EMBEDDED":

```

# Mark as embedded because too many people got it wrong.

# The code disables itself when not needed.

config IOMMU

   bool "IOMMU support"

#if EMBEDDED

   default y

   select SWIOTLB

   select AGP

   depends on PCI

   help

     Support for full DMA access of devices with 32bit memory access only

     on systems with more than 3GB. This is usually needed for USB,

     sound, many IDE/SATA chipsets and some other devices.

     Provides a driver for the AMD Athlon64/Opteron/Turion/Sempron GART

     based IOMMU and a software bounce buffer based IOMMU used on Intel

     systems and as fallback.

     The code is only active when needed (enough memory and limited

     device) unless CONFIG_IOMMU_DEBUG or iommu=force is specified

     too.

```

Well, there's only 2 Gb of memory installed on my PC, so i don't need it anyway.

Now we do:

make clean

make menuconfig

and see what's happened to Kernel Configuration:

```

(2) Maximum number of CPUs (2-256)                                                                                       

                                                     [ ] Support for hot-pluggable CPUs (EXPERIMENTAL)                                                                        

                                                     [*] Provide RTC interrupt                                                                                                

                                                     [ ] IOMMU support                                                                                                        

                                                     [ ] IBM Calgary IOMMU support 

```

Now we can disable it   :Cool: 

```

< > Siemens R3964 line discipline                                                                                        

                                                     < > Applicom intelligent fieldbus card support                                                                           

                                                         Ftape, the floppy tape device driver  --->                                                                           

                                                     <*> /dev/agpgart (AGP Support)                                                                                           

                                                     <M>   AMD Opteron/Athlon64 on-CPU GART support                                                                           

                                                     < >   Intel 440LX/BX/GX, I8xx and E7x05 chipset support                                                                  

                                                     < >   SiS chipset support                                                                                                

                                                     < >   VIA chipset support

```

AGPGART as well  :Cool:  (the option AMD Opteron/Athlon64 on-CPU GART support  was hidden before and  /dev/agpgart (AGP Support) one was always enabled)

----------

## dmpogo

IanPo,

There is one fine point. I don't know if it makes sense (or even can cause problems) to have CALGARY_IOMMU enabled while IOMMU disabled.

Kconfig does not condition CONFIG_CALGARY_IOMMU to be dependent on CONFIG_IOMMU, but this may be because they thought that IOMMU is forced anyway !

So I would be disabling CALGARY every time I disable IOMMU just in case. As you did, of course

----------

## IanPo

I agree. For we're tweaking the option manually we also have to set all the dependent ones in accordance.

----------

## dmpogo

 *IanPo wrote:*   

> I agree. For we're tweaking the option manually we also have to set all the dependent ones in accordance.

 

I was told on Linux kernel that CONFIG_CALGARY_IOMMU is completely independent from CONFIG_IOMMU,

despite that the name makes us believe it is a subset

----------

## Aitikin

I've tried this fix myself and I can't get it to work.  My make menuconfig still does not have the IOMMU option available or the agpgart option available.  I wish I knew what was goingg wrong.  I'm going to try putting the default to N and see what that does.

----------

## dmpogo

 *Aitikin wrote:*   

> I've tried this fix myself and I can't get it to work.  My make menuconfig still does not have the IOMMU option available or the agpgart option available.  I wish I knew what was goingg wrong.  I'm going to try putting the default to N and see what that does.

 

You are doing something wrong, perhaps you need to run something like make mrproper before you see the changes

----------

## IanPo

 *dmpogo wrote:*   

>  *IanPo wrote:*   I agree. For we're tweaking the option manually we also have to set all the dependent ones in accordance. 
> 
> I was told on Linux kernel that CONFIG_CALGARY_IOMMU is completely independent from CONFIG_IOMMU,
> 
> despite that the name makes us believe it is a subset

 

 :Embarassed:  my bad.

Support for hardware IOMMUs in IBM's xSeries x366 and x460 systems - IOMMU Calgary. Dunno what those systems are. At least, my PC's neither of them  :Wink: 

2 Aitikin

If you're still interested in solution, could you post what you did step-by-step here (like i did)?

----------

## eNTi

sorry to ask a little offtopic here, but isn't there a reason, why it's forced into the kernel? can one really use NvAGP on amd64? if yes, that would solve my suspend2 issues, i think.

----------

## dmpogo

 *eNTi wrote:*   

> sorry to ask a little offtopic here, but isn't there a reason, why it's forced into the kernel? can one really use NvAGP on amd64? if yes, that would solve my suspend2 issues, i think.

 

The reason as stated in Kconfig is "many people get it wrong", so that is a precaution against misconfiguration.  I don't know whether it is warranted or not.  This is regarding IOMMU, not AGP, AGP is just a byproduct of forcing IOMMU (GART IOMMU to be exact which is just called IOMMU now, CALGARY stuff is completely independent).

What I do know

1) IOMMU is probably safe to disable if you have < 4Gb RAM. It has some uses even for small RAM, but not critical. With > 4Gb some PCI devices may not work properly without IOMMU.

2) I have used my nvidia with both NvAGP=1 and NvAGP=2 (and, surely 3) so I can live with kernel-based agpgart. However, I never push my card to compare performances. But it can be used.

3) Several people with ATI cards seems remarked that some ATI configurations require you to disable kernel-based agpgart driver and that they don't have an option to choose as nvidia people are.

4) In my case my interest to the problem came from other direction.  I have a practically headless server with some small video but no AGP bridge at all. Two years ago I experienced some memory related instabilities and I found a stable configuration with AGP off.  It is most probably red herring, but I don't want to play  these games again with a production server so I have standard config with IOMMU=off and AGP=off. So upgrading to new kernel I was surprised that I don't have this option anymore.Last edited by dmpogo on Tue Dec 19, 2006 11:22 pm; edited 3 times in total

----------

## Stolz

Thanks for the workaround, dmpogo.
I have an AMD64 with nVidia proprietary drivers. Since 2.6.18, as soon as  I start X, the system starts randomly stalling/freezing, the hard disk light stays lit, and X performance becomes crappy. Disabling IOMMU with the workaround enables again Nvidia's AGP and solves the problem   :Smile: 

----------

## eNTi

yeah it's good, to know, that there is something you can do, to use nvagp after all, but i wouldn't recommend it to any gamers out there. it's very slow on my machine.

----------

## jonnevers

thanks!

I tried everything to get my system to use a kernel > 2.6.17. removing 'if embedded' and then disabling IOMMU and the kernel's AGPART in 'make menuconfig' worked like a charm.

AMD64 xorg-x11 7.1, nvidia-drivers 9742, and beyond-sources 2.6.19-beyond2, fully working!

----------

## Decibels

Yes, thanks. I have always had to disable IOMMU on my amd64 to get video to work with nvidia driver. I really dislike the fact they made it embedded and not allow us the option to disable it. 

I had some trouble with grub and splashutils on 2.6.18-gentoo-r2 kernel so couldn't boot. Ends up that was grub, didn't like some command always had in there for others, but just get black screen when kernel loading. So thought that had to do with the IOMMU thing. Tried the 'nv' driver to get past it, but since figured out it was grub haven't retried with IOMMU enabled and 'nv' driver since removed the embedded.

Once I got past the grub problem, would boot up fine until starting X. Then nothing. That is when removed the embedded on the IOMMU and just incase agpgart was screwed up made it modular so could use the nvagp if needed to try. BUT NO, once disabled IOMMU everything worked fine. Left agpgart as a module and didn't have to try the nvagp. IOMMU is what screwed up the whole process and it appears the kernel maintainers are not going to change it because people were choosing Y when meant N,...

----------

## Decibels

I went back and left IOMMU enabled (embedded) and tried variouse iommu kernel options. It still appears that disabling by changing Kconfig is the best option.

passing:

iommu=off doesn't work. Still no X with nvidia binary.

Also tried size, allowed, noforce, noagp, iommu=memaper=1 & 2 couldn't get X with nvidia binary.

Only one that works is iommu=noaperture. 

Then checked dmesg to see and still get aperture:

```
agpgart: Detected AGP bridge 0

agpgart: Setting up Nforce3 AGP.

agpgart: AGP aperture is 32M @ 0xf0000000

PCI-DMA: Disabling IOMMU

Linux agpgart interface v0.101 (c) Dave Jones

[agpgart: Found an AGP 3.0 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
```

*Later: Upon further checking figure out another option. So here are the options as I see it.

1) You can pass the iommu=noaperture and it works. Saw on nvnews forums that iommu=off may not work and noaperture does in disabling iommu. That appears to be the case with mine also. It must let the bios choose or something. But as you can see I do get aperture of 32Mb.

2) But I don't want to pass iommu=noaperture to kernel. Found out that if I change the bios agp aperture to 64Mb

it will work without having to pass the kernel iommu param. Don't know why yet, but by changing the aperture to

64Mb in bios and leaving Kconfig alone (ie iommu enabled and agpgart compiled in) works. Leaving bios aperture at 32Mb doesn't (have to pass iommu=noaperture).

3) Or each time you recompile new kernel you will have to edit Kconfig to remove the embedded on iommu.

4) Use the 'nv' open-source driver. Most stuff seems to work you will have to resize some of your fonts and opengl stuff probably won't work. But otherwise seems ok.

----------

## Decibels

Found out that if you have bios agp aperture set to 32Mb that the kernel will:

```
If the system's default IOMMU is smaller than 64 MB, the Linux kernel automatically replaces it with a 64 MB IOMMU.
```

http://us.download.nvidia.com/XFree86/Linux-x86_64/1.0-9746/README/appendix-aa.html

One way I found to get around it was to change the bios agp aperture to 64Mb. With that, the binary Nvidia driver will work and don't get black screen X lockup. Also if disabled agp in xorg.conf Nvidia driver will work, but that isn't what I want. 

I tried to get help with this on nvnews, but can't get any nvidia-bug-reports from the system. Tried while logged on via ssh, open another console, nothing, ssh locks up and can't get to the other console after startx. The lockup is hard and have to hit the reset button. 

So with IOMMU embedded, if you don't want to have to edit Kconfig for each new kernel now. You might want to see if increasing your bios agp aperture will help. Works on mine. The kernel is going to take 64Mb anyway for aperture.

----------

## Shiznitz

Would this be the only workaround you guys can find? It seems as if my Motherboard's BIOS does not let me edit the AGP aperture.

Shiznitz

----------

## Decibels

Have you tried entering bios and hiting the 'ctrl F1' keys. That might enable the advanced chipset features on some bioses. Does on mine.

If you can't change it to 64Mb, then you will probably have to do like mentioned above and edit Kconfig in the kernel to make IOMMU choice

show up so you can disable it.

If you still can't get into bios and change aperture, tells use what your motherboard or system model is and maybe someone will know.

----------

## Shiznitz

My motherboard is a Gigabyte GA-K8NS Pro.

EDIT: I did as you suggested and it enabled an advanced mode that let me select the Aperture size. I selected 182MB because I am running a GeForce 6800 GT with 129MB on it. I was able to run WoW but it was very sketchy.. I'm goign to have to do a bit more research. Thanks for the help.

Shiznitz

----------

## IanPo

I found a hint how to disable IOMMU without editing the file manually:

https://forums.gentoo.org/viewtopic-p-3831394.html#3831394

1.

In General Setup set "y" at:

```
  

[*] Configure standard kernel features (for small systems)  ---> 

```

2. In Processor type and features  ---> see what happens:

```

[*] Provide RTC interrupt 

[*] IOMMU support (NEW)              <----------------he-he, i can disable it now !!!

[ ] IBM Calgary IOMMU support

```

Not sure about any side effects of that option ("for small systems" one) enabled, though.

----------

## Decibels

I guess keep an eye on your dmesg for possible problems. What about the other options under that? Just enabling it by itself with the

options under it might not mean a hill of beans, but allowing you to do exactly what you did. So might work.

Didn't get much from the help except:  *Quote:*   

> Only use this if you really know what you are doing.

 

Notice 'really' isn't capitalized so probably ok.   :Laughing: 

Just kidding. Thanks for the info, let us know if you run into any problems from it. I found it easier to just do what the kernel wanted and change agp aperture to 64Mb

in bios.

----------

## dmpogo

 *IanPo wrote:*   

> I found a hint how to disable IOMMU without editing the file manually:
> https://forums.gentoo.org/viewtopic-p-3831394.html#3831394
> 
> 1.
> In General Setup set "y" at:
> ...

 


Obviously, since IOMMU is forced by adding "if EMBEDDED" clause. If you set EMBEDDED flag, you get it.

----------

## jonnevers

I still have to manually modify all new kernels by removing the 'if embedded' section for the arch/x86_64/Kconfig file.

```
host linux # cat /usr/src/linux/.config | grep -i embedded

# CONFIG_EMBEDDED is not set
```

is there something else that triggers this? it's a pain to have to manually modify this file everytime I want to use a new kernel.

----------

