# FreeBSD 9.1 + HD4000 : /dev/dri & tty problem



## ohyes (Mar 15, 2013)

Hello all 

I have a mobile with a nVidia graphic card and a modern Intel one (core i7). I cannot disable one in the BIOS. I read a lot on the FreeBSD forum about 'How to' configure the new xOrg with Intel card. I start a fresh FreeBSD 9.1 install, then update the ports tree, then update the kernel. (Please, report to the end of the post to see my detailed install for xOrg/gnome). Some people say that everything is OK for them. I can login into Gnome and use it but I still get two problems.

*First problem*
I cannot switch to tty when using *Ctrl+Alt+Fx* keys. This is a big problem.

*Second problem*

```
Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
```
If I look to the filesystem, I have /dev/dri/card1 but not /dev/dri/card0.
Card0 is the intel card (associated with the good BusID in xorg.conf, see attached files).

```
# pciconf -lv | grep -B 4 VGA
vgapci1@pci0:0:2:0:	class=0x030000 card=0x905a104d chip=0x00468086 rev=0x02 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Core Processor Integrated Graphics Controller'
    class      = display
    subclass   = VGA
--
vgapci0@pci0:1:0:0:	class=0x030000 card=0x905a104d chip=0x0a2b10de rev=0xa2 hdr=0x00
    vendor     = 'nVidia Corporation'
    device     = 'GT216 [GeForce GT 330M]'
    class      = display
    subclass   = VGA
```



*Here what I've done for xOrg installation (this order) :*

```
# freebsd-update fetch
# freebsd-update install
```
/etc/make.conf

```
WITH_NEW_XORG="YES"
WITH_KMS="YES"
```
Then :

```
# cd /usr/ports/x11/gnome2
# make config-recursive
# make install
# cd /usr/ports/x11/xorg
# make config-recursive
# make install

# portinstall -P x11-drivers/xf86-video-intel
```

Then add in /boot/loader.conf

```
i915_load="YES"
```

Then generate /etc/X11/xorg.conf and modify it :

```
# Xorg -configure
```


```
[...]
Section "Device"
        Driver "intel"
[...]
Section "ServerFlags"
        Option          "DRI2"          "True"
        Option          "AIGLX"         "True"
EndSection
[...]
```

Any help will be appreciated.
Thanks.


----------



## wblock@ (Mar 15, 2013)

ohyes said:
			
		

> ```
> # cd /usr/ports/x11/gnome2
> # make config-recursive
> # make install
> ...



Installing the xorg port built the drivers.  At best, that last step does nothing.  At worst, it downloads and installs a precompiled xf86-video-intel binary package that does not have KMS support.



> Then add in /boot/loader.conf
> 
> ```
> i915_load="YES"
> ```



That is not needed any more.

When including files, please put short ones like xorg.conf inline, and put longer ones like /var/log/Xorg.0.log on a web site like pastebin.com and post a link.  That information becomes available immediately, rather than having to download, extract, read, and then respond.


----------



## ohyes (Mar 15, 2013)

Thanks @wblock@. Ok for Pastebin next time.

About the not needed anymore steps, I try first without. Problems are the same.


----------



## wblock@ (Mar 15, 2013)

Rebuild the x11-drivers/xf86-video-intel:
`# make -C /usr/ports/x11-drivers/xf86-video-intel clean deinstall install clean`


----------



## ohyes (Mar 16, 2013)

wblock@ said:
			
		

> Rebuild the x11-drivers/xf86-video-intel:
> `# make -C /usr/ports/x11-drivers/xf86-video-intel clean deinstall install clean`



I dit it, no change. Same problems


----------



## ohyes (Mar 16, 2013)

@G_Nerc said to me to add this in xorg.conf:

```
Section "DRI"
        Group 0
        Mode 0666
EndSection
```

No change. Same problems


----------



## ohyes (Mar 18, 2013)

Well, I've done a complete rebuild, no changes.

About the problem of /dev/dri/Card0 not found;
I find this thread : http://forums.freebsd.org/showthread.php?t=10690&highlight=drmOpendevice

Do you think that doing this is a good idea:
[...] appending the following statement to /etc/devd.conf

```
attach 0 {
	device-name "drm1";
	action	"ln -s /dev/dri/card1 /dev/dri/card0";
};
```

?


----------



## ORTO-DOX (Mar 18, 2013)

Hy @ohyes, I have such card and on 10-CURRENT my configuration working:

```
Section "ServerFlags"
	Option		"AIGLX"		"true"
	Option		"DRI2"		"true"
EndSection

Section "ServerLayout"
	Identifier	"X.org Configured"
	Screen		0	"Screen0"	0 0
	Option		"AllowEmptyInput"	"false"
	Option		"AutoAddDevices"	"true"
	InputDevice	"Keyboard"
EndSection

Section	"InputDevice"
	Identifier	"Keyboard"
	Driver		"kbd"
	Option		"AutoRepeat"	"500 30"
	Option		"XkbRules"	"xorg"
	Option		"XkbLayout"	"us,ru"
	Option		"XkbVariant"	"basic,winkeys"
	Option		"XkbOptions"	"grp:ctrl_shift_toggle,grp_led:scroll"
EndSection

Section "Files"
	ModulePath   "/usr/local/lib/xorg/modules"
	FontPath	"/usr/local/lib/X11/fonts/cyrillic/"
	FontPath	"/usr/local/lib/X11/fonts/misc/"
	FontPath	"/usr/local/lib/X11/fonts/TTF/"
	FontPath	"/usr/local/lib/X11/fonts/OTF"
	FontPath	"/usr/local/lib/X11/fonts/Type1/"
	FontPath	"/usr/local/lib/X11/fonts/100dpi/"
	FontPath	"/usr/local/lib/X11/fonts/75dpi/"
	FontPath	"/usr/local/lib/X11/fonts/msttf/"
	FontPath	"/usr/local/lib/X11/fonts/terminus-font/"
	FontPath	"/usr/local/lib/X11/fonts/conkyforecast/"
EndSection

Section "Module"
	Load	"extmod"
	Load	"record"
	Load	"dbe"
	Load	"glx"
	Load	"dri"
	Load	"dri2"
	Load	"GLcore"
	Load	"drm"
	Load	"vbe"
	Load	"ddc"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
	Identifier		"Card0"
	Driver			"intel"
	VendorName		"Intel"
	BoardName		"Intel HD4000"
	BusID			"PCI:0:2:0"
	Option	"DRI"		"true"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection

Section "DRI"
	Group 0
	Mode 0666
EndSection

Section "Extensions"
	Option	"Composite"	"Enable"
	Option	"RENDER"	"Enable"
	Option	"DAMAGE"	"Enable"
EndSection
```


----------



## ohyes (Mar 18, 2013)

ORTO-DOX said:
			
		

> Hy @ohyes, I have such card and on 10-CURRENT my configuration working:



Thanks. Do you have two video card*s* in this computer?


----------



## ORTO-DOX (Mar 18, 2013)

Yes. I have Nvidia card with optimus technology.

```
00:02.0 VGA compatible controller: Intel Corporation Ivy Bridge Graphics Controller (rev 09) (prog-if 00 [VGA controller])
        Subsystem: CLEVO/KAPOK Computer Device 2702
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Memory at f7400000 (64-bit, non-prefetchable)
        Memory at d0000000 (64-bit, prefetchable)
        I/O ports at f000
        Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [d0] Power Management version 2
        Capabilities: [a4] PCI Advanced Features
01:00.0 VGA compatible controller: nVidia Corporation Device 0de9 (rev a1) (prog-if 00 [VGA controller])
        Subsystem: CLEVO/KAPOK Computer Device 2702
        Flags: fast devsel, IRQ 16
        Memory at f6000000 (32-bit, non-prefetchable)
        Memory at e0000000 (64-bit, prefetchable)
        Memory at f0000000 (64-bit, prefetchable)
        I/O ports at e000
        Expansion ROM at f7000000 [disabled]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Endpoint, MSI 00
        Capabilities: [b4] Vendor Specific Information: Len=14 <?>
```


----------



## ohyes (Mar 18, 2013)

ORTO-DOX said:
			
		

> Yes. I have Nvidia card with optimus technology.



Well, I still have errors after adding 'quite the same' xorg.conf as you.
My system is a 9.1 version.

In /dev/dri directory you have Card0 and Card1?


----------



## ORTO-DOX (Mar 18, 2013)

```
ls -la /dev/dri/card1
crw-rw-rw-  1 root  wheel  0x92 18 Ð¼Ð°Ñ€ 19:11 /dev/dri/card1
```
Can you paste which error you have?


----------



## ohyes (Mar 18, 2013)

Maybe you have the same in your /var/log/Xorg.0.log, because you don't have /dev/dri/card0 :

From /var/log/Xorg.0.log (extract) :

```
[    19.980] drmOpenByBusid: Searching for BusID pci:0000:00:02.0
[    19.980] drmOpenDevice: node name is /dev/dri/card0
[    19.980] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    19.980] drmOpenDevice: open result is -1, (No such file or directory)
[    19.980] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    19.980] drmOpenDevice: open result is -1, (No such file or directory)
```


----------



## ORTO-DOX (Mar 18, 2013)

Yes, I have similar messages in /var/log/Xorg.0.log

```
cat /var/log/Xorg.0.log | grep -i -A 10 -B 10 searching

[    26.782] (II) Loading /usr/local/lib/xorg/modules/drivers/intel_drv.so
[    26.782] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[    26.783] drmOpenDevice: node name is /dev/dri/card0
[    26.783] Failed to change owner or group for file /dev/dri! 2: No such file or directory
[    26.783] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    26.783] drmOpenDevice: open result is -1, (No such file or directory)
[    26.783] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    26.783] drmOpenDevice: open result is -1, (No such file or directory)
[    26.783] drmOpenDevice: Open failed
[    28.059] drmOpenByBusid: Searching for BusID pci:0000:00:02.0
[    28.059] drmOpenDevice: node name is /dev/dri/card0
[    28.059] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    28.059] drmOpenDevice: open result is -1, (No such file or directory)
[    28.059] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    28.059] drmOpenDevice: open result is -1, (No such file or directory)
[    28.059] drmOpenDevice: Open failed
[    28.059] drmOpenByBusid: drmOpenMinor returns -2
[    28.059] drmOpenDevice: node name is /dev/dri/card1
[    28.063] drmOpenDevice: open result is 10, (OK)
[    28.063] drmOpenByBusid: drmOpenMinor returns 10
```
Can you paste more lines from log file? And also can you give output of `# kldstat`?


----------



## ohyes (Mar 18, 2013)

*Y*ou can get the complete log in the first post.

So you have the same problem as I. Can you use the Ctrl+Alt+Fx keys to switch to a console?


```
# kldstat 
Id Refs Address            Size     Name
 1  126 0xffffffff80200000 1323388  kernel
 3    1 0xffffffff81549000 3c00     snd_driver.ko
 4    2 0xffffffff8154d000 55d8     snd_ad1816.ko
 5    2 0xffffffff81553000 5e38     snd_als4000.ko
 6    2 0xffffffff81559000 7958     snd_atiixp.ko
 7    2 0xffffffff81561000 5d40     snd_cs4281.ko
 8    2 0xffffffff81567000 d268     snd_ds1.ko
 9    2 0xffffffff81575000 adc0     snd_envy24.ko
10    4 0xffffffff81580000 1e58     snd_spicds.ko
11    2 0xffffffff81582000 a3a0     snd_envy24ht.ko
12    2 0xffffffff8158d000 6a60     snd_ess.ko
13    5 0xffffffff81594000 51f8     snd_sbc.ko
14    2 0xffffffff8159a000 4ca8     snd_fm801.ko
15    3 0xffffffff8159f000 10d88    snd_mss.ko
16    2 0xffffffff815b0000 ac28     snd_maestro.ko
17    2 0xffffffff815bb000 c410     snd_maestro3.ko
18    2 0xffffffff815c8000 11bd0    snd_neomagic.ko
19    2 0xffffffff815da000 5860     snd_sb16.ko
20    2 0xffffffff815e0000 5218     snd_sb8.ko
21    2 0xffffffff815e6000 6708     snd_solo.ko
22    2 0xffffffff815ed000 6008     snd_t4dwave.ko
23    2 0xffffffff815f4000 5248     snd_via82c686.ko
24    2 0xffffffff815fa000 6240     snd_vibes.ko
25    1 0xffffffff81601000 f4d8     aio.ko
26    1 0xffffffff81611000 29e0     coretemp.ko
27    3 0xffffffff81614000 8ac0     libiconv.ko
28    1 0xffffffff8161d000 24c8     libmchain.ko
29    1 0xffffffff81620000 11c8     cd9660_iconv.ko
30    1 0xffffffff81622000 11e0     msdosfs_iconv.ko
31    1 0xffffffff81624000 6fe80    iwn6000fw.ko
32    1 0xffffffff81812000 15c2     fdescfs.ko
33    1 0xffffffff81814000 60003    i915kms.ko
34    1 0xffffffff81875000 123b     iicbb.ko
35    4 0xffffffff81877000 1307     iicbus.ko
36    1 0xffffffff81879000 dc9      iic.ko
37    1 0xffffffff8187a000 2c26d    drm2.ko
```


----------



## ohyes (Mar 18, 2013)

*F*inally errors in Xorg.0.log are probably nothing because in the log file we can also see:

```
[    20.319] Failed to change owner or group for file /dev/dri/card0! 2: No such file or directory
[    20.319] drmOpenDevice: open result is -1, (No such file or directory)
[    20.319] drmOpenDevice: Open failed
[    20.319] drmOpenByBusid: drmOpenMinor returns -2
[    20.319] [B]drmOpenDevice: node name is /dev/dri/card1[/B]
[    20.323] [B]drmOpenDevice: open result is 8, (OK)[/B]
```

My real problem is that I cannot switch to console by using *Ctrl+Alt+Fx* keys. When I try to do it this error occurs in /Xorg.0.log:

```
[  2185.859] (II) AIGLX: Suspending AIGLX clients for VT switch
[  2185.859] (WW) intel(0): drmDropMaster failed: Unknown error: -22
```


----------



## wblock@ (Mar 18, 2013)

Expectation bug: the Intel KMS code does not support switching back to a text console.  Or rather, it allows it, but the graphics mode is not switched back to text, so the console is not visible.


----------



## ohyes (Mar 18, 2013)

wblock@ said:
			
		

> Expectation bug: the Intel KMS code does not support switching back to a text console.  Or rather, it allows it, but the graphics mode is not switched back to text, so the console is not visible.



Thanks for the info @wblock@.
It's bad  (Also we cannot see shu*t*ting down the log process).

And without disabling Intel Video Card in the BIOS it is not possible to use the nVidia card?


----------



## wblock@ (Mar 18, 2013)

ohyes said:
			
		

> And without disabling Intel Video Card in the Bios it is not possible to use the nVidia card ?



Maybe it will work, but unlikely.  In xorg.conf, there would only be an nvidia Device entry, no intel.


----------



## ohyes (Mar 18, 2013)

@@DutchDaemon :_ I'm sorry, i did not see your edit cause it was quick post/reply.
My repeated error was not a so bad error but it was._

About the thread, I mark it as [SOLVED] cause there is no solution for the moment -2013/03/18- (for switching to tty with an Intel graphic card like on Irondale).


			
				wblock@ said:
			
		

> Expectation bug: the Intel KMS code does not support switching back to a text console.  Or rather, it allows it, but the graphics mode is not switched back to text, so the console is not visible.



If I try to use the nVidia card onboard I know that I have a problem of 'no screens found', and specify EDID file in xorg.conf does nothing for me.

Maybe someone have information about sysutils/acpi_call port? And then, how we can disable INTEL GPU?


----------



## vermaden (Mar 18, 2013)

ohyes said:
			
		

> If I try to use the nVidia card onboard I know that I have a problem of 'no screens found', and specify EDID file in xorg.conf does nothing for me.


Check that mate:
http://romain.blogreen.org/blog/2013/02/patching-screens-edid-information/


----------



## ohyes (Mar 18, 2013)

*M*any thanks @vermaden. I will retry the nVidia install (without disabling the Intel GPU in the BIOS because I can't).

I'm not a specialist of FreeBSD kernel and hardware configuration. I think one of my last chances could be:

Rebuild the 9.1 kernel without detecting the Intel GPU _- not possible I think - _
Use apci_call to prevent loading of the Intel GPU _- don't know how -_
force Xorg to load my EDID file with the nVidia Card _- next try - _


----------



## Anjar Wmk (Oct 16, 2015)

wblock@ said:


> Rebuild the x11-drivers/xf86-video-intel:
> `# make -C /usr/ports/x11-drivers/xf86-video-intel clean deinstall install clean`



I have optimus nvidia GT540 M and installed CentOS 7 it use i915kms driver without problem.

I searched for almost two weeks to find how to make X11 work in FreeBSD 10.2-RELEASE. Finally after two weeks, this method works for me.


----------



## free-and-bsd (Nov 11, 2015)

BTW, switching back to console mode is working now. Though it will rather look like fb console.


----------

