FreeBSDDesktop / kms-drm

the DRM part of the linuxkpi-based KMS
63 stars 26 forks source link

Add more PCI IDs to drm-v4.16 #122

Closed jbeich closed 5 years ago

jbeich commented 5 years ago

1e44b02041f2 and b0be0dcdcfbf are safe to backport as KabyLake and CoffeeLake are already supported. I'd probably also include 5865ffb0f0ce and d24f32bf1016.

b0be0dcdcfbf should help this user.

gautamcgoel commented 5 years ago

The link above is broken; here is the correct link: https://forums.freebsd.org/threads/new-to-freebsd-startx-fails-with-cannot-run-in-framebuffer-mode-help.68882/

I am the user who is trying to run FreeBSD on a CoffeeLake chip. I'd really appreciate any help moving this issue along!

jbeich commented 5 years ago

@GautamGoel, can you confirm b0be0dcdcfbf actually helps? Apply the following patch and rebuild/reinstall drm-fbsd12.0-kmod.

Index: graphics/drm-fbsd12.0-kmod/Makefile
===================================================================
--- graphics/drm-fbsd12.0-kmod/Makefile (revision 488702)
+++ graphics/drm-fbsd12.0-kmod/Makefile (working copy)
@@ -5,6 +5,9 @@ PORTNAME=   drm-fbsd12.0-kmod
 PORTVERSION=   4.16.g20181215
 CATEGORIES=    graphics

+PATCH_SITES=   https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
+PATCHFILES=    b0be0dcdcfbf.patch:-p1
+
 MAINTAINER=    jmd@FreeBSD.org
 COMMENT=   DRM modules for the linuxkpi-based KMS components

Index: graphics/drm-fbsd12.0-kmod/distinfo
===================================================================
--- graphics/drm-fbsd12.0-kmod/distinfo (revision 488702)
+++ graphics/drm-fbsd12.0-kmod/distinfo (working copy)
@@ -1,3 +1,5 @@
 TIMESTAMP = 1544863688
 SHA256 (FreeBSDDesktop-kms-drm-4.16.g20181215-71fcc9f_GH0.tar.gz) = b969611bbdac88394e5e5be4284ceea048425b994d872651d801baf41263c0e7
 SIZE (FreeBSDDesktop-kms-drm-4.16.g20181215-71fcc9f_GH0.tar.gz) = 13088892
+SHA256 (b0be0dcdcfbf.patch) = 9ca3a60ef566750edea5fc1fb495607683bed142e805fb01ee0a785e2451f4e1
+SIZE (b0be0dcdcfbf.patch) = 1106
tadasv commented 5 years ago

I can confirm that the patch works. I have intel i7 9700k with integrated graphics after applying the patch DMR gets loaded.

tadasv commented 5 years ago

Here's some dmesg output after I load the module

drmn0: <drmn> on vgapci0
vgapci0: child drmn0 requested pci_enable_io
vgapci0: child drmn0 requested pci_enable_io
[drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19).
__pm_runtime_resume not implemented -- see your local kernel hacker
Successfully added WC MTRR for [0x90000000-0x9fffffff]: 0; 
[drm] Got stolen memory base 0x0, size 0x0
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
[drm] Connector eDP-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.eDP-1
[drm]   - kern.vt.fb.default_mode
pm_runtime_mark_last_busy not implemented -- see your local kernel hacker
__pm_runtime_suspend not implemented -- see your local kernel hacker
[drm] failed to retrieve link info, disabling eDP
[drm] Connector DP-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.DP-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector DP-2: get mode from tunables:
[drm]   - kern.vt.fb.modes.DP-2
[drm]   - kern.vt.fb.default_mode
[drm] Connector HDMI-A-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.HDMI-A-1
[drm]   - kern.vt.fb.default_mode
pm_runtime_get_if_in_use not implemented -- see your local kernel hacker
sched_setscheduler_nocheck not implemented -- see your local kernel hacker
register_oom_notifier not implemented -- see your local kernel hacker
[drm] Initialized i915 1.6.0 20171222 for drmn0 on minor 0
register_acpi_notifier not implemented -- see your local kernel hacker
async_schedule is dodgy -- see your local kernel hacker
pm_runtime_set_autosuspend_delay not implemented -- see your local kernel hacker
__pm_runtime_use_autosuspend not implemented -- see your local kernel hacker
async_synchronize_cookie not implemented -- see your local kernel hacker
VT: Replacing driver "efifb" with new "fb".
start FB_INFO:
type=11 height=1200 width=1920 depth=32
cmsize=16 size=9216000
pbase=0x90040000 vbase=0xfffff80090040000
name=drmn0 flags=0x0 stride=7680 bpp=32
cmap[0]=0 cmap[1]=7f0000 cmap[2]=7f00 cmap[3]=c4a000
end FB_INFO
drmn0: fb0: inteldrmfb frame buffer device
[drm:lspcon_wait_mode] LSPCON mode hasn't settled
drmn0: successfully loaded firmware image with name: i915/kbl_dmc_ver1_04.bin
[drm] Finished loading DMC firmware i915/kbl_dmc_ver1_04.bin (v1.4)
[drm:lspcon_wait_mode] LSPCON mode hasn't settled
[drm:lspcon_wait_mode] LSPCON mode hasn't settled

Also, if I load the module manually, kldload /boot/modules/i915kms.ko everything works fine (console, updates and I can startx).

However, if I put i915 into kld_list in /etc/rc.conf it crashes on boot and my computer reboots. Not sure if this is related or something else completely.

zeising commented 5 years ago

What exactly do you put in kld_list?

tadasv commented 5 years ago

It's only kld_list="/boot/modules/i915kms.ko" added to /etc/rc.conf. This is pretty much fresh install of the system.

Edit: I'll see if I can get kernel crash dump. I noticed that loading the module manually does not work all the time. The screen starts flickering.

tadasv commented 5 years ago

Here's the core.txt after adding kld_list to rc.conf and booting up.

https://gist.github.com/tadasv/dc8e7fb3475afa3f5f61fd957084a5ce

Hope this is useful.

johalun commented 5 years ago

I'm not so sure about importing patches that are not there upstream. There's probably some reason why these are not enabled in Linux. Our 4.16 is up to date with Linux stable 4.16.18, which is the latest.

jbeich commented 5 years ago

Here's the core.txt after adding kld_list to rc.conf and booting up.

https://gist.github.com/tadasv/dc8e7fb3475afa3f5f61fd957084a5ce

The crash appears to be during shutdown. Did you attach the correct file?

gautamcgoel commented 5 years ago

@jbeich Noob question: How do I apply the patch? I need to use the 'patch' utility, right? Sorry if this is dumb, I'm not used to patching the software myself (I just downloaded binaries when I was on Linux...)

jbeich commented 5 years ago

@GautamGoel, does the following help?

  1. Save the inline patch from https://github.com/FreeBSDDesktop/kms-drm/issues/122#issuecomment-451611322 as drm-kmod.diff
  2. Apply as patch -Efsp0 -i /path/to/drm-kmod.diff -d /usr/ports (may require root)
  3. Check nothing is printed i.e., there were no patch conflicts
  4. Check /usr/ports/graphics/drm-fbsd12.0-kmod contains a bunch of .orig (backup) files
  5. Deinstall /usr/ports/graphics/drm-fbsd12.0-kmod then install again
gautamcgoel commented 5 years ago

@jbeich, I can confirm that the patch worked with no problems. I see that DRM is loaded in the dmesg, and during startup the system flashes and moves to integrated graphics. Thanks for your help, I really appreciate how welcoming this community is - that's why I'm not running OpenBSD ;).

Unfortunately, even though the driver seems to be loaded, none of the applications can seem to use it. For example, startx fails, complaining that the driver isn't there. I tried reinstalling Xorg, but that didn't help. Looking at kldstat, I see two distinct copies of the driver - i915kms.ko, and another like i915kms1_04bin.ko (something like that, I forgot to take a picture). Do you have any suggestions on what to troubleshoot? I'm happy to collect whatever information you need.

@tadasv, did you resolve your issue? I don't seem to be having the same problems on my system.

jbeich commented 5 years ago

during startup the system flashes and moves to integrated graphics

Changes display resolution to native? Does /dev/dri/card0 exist?

startx fails, complaining that the driver isn't there

Can you attach Xorg.log? Or look for lines containing modeset (DDX) and i965 (DRI). If you notice intel (DDX) deinstall xf86-video-intel (deprecated).

Did you add yourself to video group?

valpackett commented 5 years ago

like i915kms1_04bin.ko

Anything with 'bin' or so is just firmware, don't worry about that

gautamcgoel commented 5 years ago

@jbeich, yes, it appears to switch to native resolution. Here is the Xorg log: www.pastebin.com/U1Srxj2V. The /dev/Fri/card0 file you mentioned does exist and I am part of video. The package you mentioned is not installed.

Thanks again for all your help.

jbeich commented 5 years ago

(==) Using config directory: "/usr/local/etc/X11/xorg.conf.d" [...] (**) | |-->Device "Card0" [...] (II) LoadModule: "intel" (WW) Warning, couldn't open module intel

In xorg.conf(5) either drop Device section or replace intel with modesetting. Alternatively, start with no config then gradually add only sections that differ from default.

johalun commented 5 years ago

Closing this. We won't add PCI IDs that are not added upstream since they might be unstable. Any willing to experiment until the official drm driver is updated to a newer version are welcome to use the suggested patch.