Custom KMS driver + X

Jose Abreu Jose.Abreu at synopsys.com
Tue Jul 5 14:28:14 UTC 2016


Hi All,

I developed a very simple KMS driver which uses an HDMI TX phy
present in an external FPGA which is connected though PCIe to a
X86_64 platform. I implemented all the necessary logic and it is
working using mpv. Right now I would like to integrate this
driver into X as an offload engine. I looked at
https://nouveau.freedesktop.org/wiki/Optimus/ (section: "Using
outputs on discrete GPU") but I am facing two difficulties:
     - First: My driver only supports 24 bpp (I mean real 24
bits, not 24 packed in 32 bits). Is there a way to specify to X
(or specify in the driver itself) to use 24bpp **only** in the
new driver that I created?
    - Second (and most important one): If I start my workstation
and modprobe the driver the X server seems to recognize and add
the new DRM device (I can't be sure because right now no output
is shown due to the 24/32 bpp problem). But if I then do a
"startx" from terminal the server will crash with a segmentation
fault, outputting this log:

[snip...]
(II) xfree86: Adding drm device (/dev/dri/card1)
(EE)
(EE) Backtrace:
(EE) 0: /usr/bin/X (xorg_backtrace+0x48) [0x7f7e3c6f5fc8]
(EE) 1: /usr/bin/X (0x7f7e3c555000+0x1a4ff9) [0x7f7e3c6f9ff9]
(EE) 2: /lib/x86_64-linux-gnu/libc.so.6 (0x7f7e3a6d5000+0x36cb0)
[0x7f7e3a70bcb0]
(EE) 3: /usr/bin/X (0x7f7e3c555000+0xb3539) [0x7f7e3c608539]
(EE) 4: /usr/bin/X (xf86BusProbe+0x9) [0x7f7e3c5dc1e9]
(EE) 5: /usr/bin/X (InitOutput+0x728) [0x7f7e3c5ea668]
(EE) 6: /usr/bin/X (0x7f7e3c555000+0x57dab) [0x7f7e3c5acdab]
(EE) 7: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0xf5)
[0x7f7e3a6f6f45]
(EE) 8: /usr/bin/X (0x7f7e3c555000+0x4352e) [0x7f7e3c59852e]
(EE)
(EE) Segmentation fault at address 0x0
(EE)
Fatal server error:
(EE) Caught signal 11 (Segmentation fault). Server aborting
(EE)

Doing a strace to startx I get this info:
[snip ...]
pid  3700] write(0, "(II) xfree86: Adding drm device "..., 49) = 49
[pid  3700] open("/dev/dri/card1", O_RDWR) = 6
[pid  3700] ioctl(6, 0xc0406400, 0x7fee48bd3690) = 0
[pid  3700] ioctl(6, 0xc0406400, 0x7fee48bd3690) = 0
[pid  3700] close(6)                    = 0
[pid  3700]
readlink("/sys/devices/platform/hdmi-drm/drm/card1/card1-HDMI-A-2",
0x7ffcdbe49410, 1024) = -1 EINVAL (Invalid argument)
[pid  3700]
stat("/sys/devices/platform/hdmi-drm/drm/card1/card1-HDMI-A-2/uevent",
{st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
[pid  3700]
open("/sys/devices/platform/hdmi-drm/drm/card1/card1-HDMI-A-2/uevent",
O_RDONLY|O_CLOEXEC) = 6
[pid  3700] fstat(6, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
[pid  3700] mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fee473a4000
[pid  3700] read(6, "", 4096)           = 0
[pid  3700] close(6)                    = 0
[pid  3700] munmap(0x7fee473a4000, 4096) = 0
[pid  3700] stat("/sys/bus/pci/devices", {st_mode=S_IFDIR|0755,
st_size=0, ...}) = 0
[pid  3700] open("/proc/mtrr", O_WRONLY|O_CLOEXEC) = 6
[pid  3700] openat(AT_FDCWD, "/sys/bus/pci/devices",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 7
[pid  3700] getdents(7, /* 20 entries */, 32768) = 624
[pid  3700] getdents(7, /* 0 entries */, 32768) = 0
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:00.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7, "\206\200\0\f\6\0\220
\6\0\0\6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:01.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\1\f\7\4\20\0\6\0\4\6\20\0\201\0\0\0\0\0\0\0\0\0\0\1\1\0\360\0\0
"..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:02.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\2\4\7\4\220\0\6\0\0\3\0\0\0\0\4\0\200\367\0\0\0\0\f\0\0\340\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:03.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\f\f\6\4\20\0\6\0\3\4\20\0\0\0\4@\321\367\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:14.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\2001\214\6\4\220\2\0050\3\f\0\0\0\0\4\0\320\367\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:16.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200:\214\6\0\20\0\4\0\200\7\0\0\200\0\4\340\321\367\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1a.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7, "\206\200-\214\6\0\220\2\5
\3\f\0\0\0\0\0\300\321\367\0\0\0\0\0\0\0\0\0\0\0\0"..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1b.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7, "\206\200
\214\6\4\20\0\5\0\3\4\20\0\0\0\4\0\321\367\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1c.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\20\214\7\0\20\0\325\0\4\6\20\0\201\0\0\0\0\0\0\0\0\0\0\2\2\0 
\0 "..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1c.2/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\24\214\7\0\20\0\325\0\4\6\20\0\201\0\0\0\0\0\0\0\0\0\0\3\3\0\340\340\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1c.5/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200N$\7\0\20\0\325\1\4\6\20\0\201\0\0\0\0\0\0\0\0\0\0\4\5\0\360\0\0
"..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1d.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7, "\206\200&\214\6\0\220\2\5
\3\f\0\0\0\0\0\260\321\367\0\0\0\0\0\0\0\0\0\0\0\0"..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1f.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\\\214\7\0\20\2\5\0\1\6\0\0\200\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1f.2/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\2\214\7\4\260\2\5\1\6\1\0\0\0\0\261\360\0\0\241\360\0\0\221\360\0\0\201\360\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:1f.3/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\"\214\3\0\200\2\5\0\5\f\0\0\0\0\4\220\321\367\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:01:00.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\303\26\20\201\7\0\20\0\0\0\200\4\20\0\0\0\0\0\0\367\0\0\0\0\0\0\0\0\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:03:00.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\354\20h\201\7\4\20\0\21\0\0\2\20\0\0\0\1\340\0\0\0\0\0\0\4\0\300\367\0\0\0\0"...,
48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:04:00.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"!\33\200\20\7\0\20\0\4\1\4\6\20\0\1\0\0\0\0\0\0\0\0\0\4\5\5
\361\1  "..., 48, 0) = 48
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:02.0/config",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] pread(7,
"\206\200\2\4\7\4\220\0\6\0\0\3\0\0\0\0\4\0\200\367\0\0\0\0\f\0\0\340\0\0\0\0"...,
256, 0) = 256
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:02.0/resource",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] read(7, "0x00000000f7800000 0x00000000f7b"..., 512) = 399
[pid  3700] close(7)                    = 0
[pid  3700] open("/sys/bus/pci/devices/0000:00:02.0/boot_vga",
O_RDONLY|O_CLOEXEC) = 7
[pid  3700] read(7, "1", 1)             = 1
[pid  3700] close(7)                    = 0
[pid  3700] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR,
si_addr=0} ---
[snip...]


Can you give me any comments regarding these two problems?

Thank you in advance for your patience.

Best regards,
Jose Miguel Abreu


More information about the xorg-devel mailing list