Bug 97941

Summary: [cht dsi] DRM i915 on surface 3 fail
Product: Drivers Reporter: Benoit Gschwind (gschwind)
Component: Video(DRI - Intel)Assignee: intel-gfx-bugs (intel-gfx-bugs)
Status: RESOLVED CODE_FIX    
Severity: normal CC: andrea, bugzilla, c, deyin, eduncan911+kernel, intel-gfx-bugs, jamie.c.breeze, joshmyzie2, kernel, orychalk, scramble, stephenjust, tramtrist, ville.syrjala
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: 4.1.0-rc2+(drm-intel commit 1f6cfc3654f57cca7314eaa1e06e3c0d727cedd5) Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg
dmesg 20150519
dmesg with drm.debug=0xff
OpRegion dump
4.2.0 log
4.2.0 log with drm.debug=14
kernel-4.3-pre drm debug log
kernel 4.1.6 dmesg with patchset
kernel-4.3-pre drm debug log (third build)
kernel-4.2.0-rc8+ drm debug log (fourth build)
drm-debug-log
Dmesg after Comment #31
Dmesg w/ External Monitor, GNOME
dmesg drm-intel-nightly-20160116

Description Benoit Gschwind 2015-05-08 16:04:10 UTC
Created attachment 176221 [details]
dmesg

Hello,

I built a kernel for Surface 3 (non-Pro version).

i915 fail on all tested kernel between 3.16 (from ubuntu) to last known drm-intel.

I attached dmesg, the Surface 3 does not hang, but I get a black screen. I get the dmseg from ssh.

If you need I can test proposed patches.

Best regard
Comment 1 Benoit Gschwind 2015-05-20 08:56:42 UTC
Created attachment 177431 [details]
dmesg 20150519


attach dmesg of drm-intel-nightly
Comment 2 Benoit Gschwind 2015-05-28 22:43:55 UTC
Created attachment 178211 [details]
dmesg with drm.debug=0xff


update dmesg with drm.debug=0xff option
Comment 3 Benoit Gschwind 2015-06-05 09:30:28 UTC
dmesg seems to point out that there is unexpected entry in VBIOS, thus I tried to dump VBIOS folowing :

https://01.org/linuxgraphics/documentation/development/how-dump-video-bios

But I get an I/O error.

Best regards
Comment 4 Ville Syrjala 2015-06-05 11:59:02 UTC
(In reply to Benoit Gschwind from comment #3)
> dmesg seems to point out that there is unexpected entry in VBIOS, thus I
> tried to dump VBIOS folowing :
> 
> https://01.org/linuxgraphics/documentation/development/how-dump-video-bios
> 
> But I get an I/O error.
> 
> Best regards

Just
cat /sys/kernel/debug/dri/0/i915_opregion > file
is enough
Comment 5 Benoit Gschwind 2015-06-05 14:27:32 UTC
Created attachment 178901 [details]
OpRegion dump

Hello,

I attached the OpRegion dump of Surface 3

Best regards
Comment 6 Bastien Nocera 2015-08-17 20:34:18 UTC
I'm hitting this on a Surface 3 as well, using kernel 4.2-rc3.

As the fallback LLVM mesa support is also broken:
https://bugzilla.redhat.com/show_bug.cgi?id=1178347
No graphical mode at all for me.

Let me know if you need any more information.
Comment 7 Jamie 2015-08-17 23:38:41 UTC
I'm having the same problems, my dumps are all the same as the attached ones in kernel 4.1.5, I only disabled extra AMD hardware support and NVIDIA support for my specific build to disable 'bloat' that isn't needed as well as the Surface Type Cover fix.

I can also confirm this has been the same problem since kernel 3.16, and was an issue in 3.19

After looking through the relevant code, the device ID 22b0 is listed in the kernel driver PCI IDs, yet isn't loading i915, so if we don't sent nomodeset, the kernel just loads to a black screen.
Comment 8 Jani Nikula 2015-09-01 13:17:05 UTC
Please try the patches in the thread starting at

http://mid.gmane.org/1438077670-12953-1-git-send-email-m.deepak@intel.com
Comment 9 Bastien Nocera 2015-09-02 10:52:23 UTC
Created attachment 186501 [details]
4.2.0 log

Tested the patches on top of 4.2.0 (after small rebasing).

Sep 01 20:43:03 localhost kernel: [drm:vlv_enable_dsi_pll [i915]] *ERROR* DSI PLL lock failed
Sep 01 20:43:03 localhost kernel: [drm:dpi_send_cmd.constprop.8 [i915]] *ERROR* Video mode command 0x00000042 send failed.
Comment 10 Bastien Nocera 2015-09-02 14:17:12 UTC
Created attachment 186511 [details]
4.2.0 log with drm.debug=14
Comment 11 Jani Nikula 2015-09-02 14:34:58 UTC
Sep 02 10:13:31 localhost kernel: [drm:vlv_update_cdclk] Current CD clock rate: 266667 kHz
Sep 02 10:13:31 localhost kernel: [drm:intel_dsi_pre_pll_enable] 
Sep 02 10:13:31 localhost kernel: [drm:intel_dsi_prepare] pipe B
Sep 02 10:13:31 localhost kernel: [drm:vlv_enable_dsi_pll] 
Sep 02 10:13:31 localhost kernel: [drm:vlv_configure_dsi_pll] dsi pll div 000001ab, ctrl 00020080
Sep 02 10:13:31 localhost kernel: [drm:vlv_enable_dsi_pll [i915]] *ERROR* DSI PLL lock failed
Comment 12 Bastien Nocera 2015-09-02 21:49:42 UTC
Created attachment 186521 [details]
kernel-4.3-pre drm debug log

With the patch in http://article.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/66645 added to the original patch series.
Comment 13 Benoit Gschwind 2015-09-03 21:59:45 UTC
Created attachment 186681 [details]
kernel 4.1.6 dmesg with patchset

The path set of comment 8 was aplyed without any modification to the vanilla kernel 4.1.6

Best regards.
Comment 14 Jani Nikula 2015-09-04 07:06:33 UTC
Another one that might help 
http://mid.gmane.org/1441306216-6581-4-git-send-email-ville.syrjala@linux.intel.com
Comment 15 Bastien Nocera 2015-09-04 13:39:06 UTC
Created attachment 186711 [details]
kernel-4.3-pre drm debug log (third build)
Comment 16 Bastien Nocera 2015-09-04 13:40:42 UTC
(In reply to Jani Nikula from comment #14)
> Another one that might help 
> http://mid.gmane.org/1441306216-6581-4-git-send-email-ville.syrjala@linux.
> intel.com

Still failing with that patch added to the ones mentioned in comment 8 and comment 12.
Comment 17 Ville Syrjala 2015-09-04 14:30:57 UTC
(In reply to Bastien Nocera from comment #16)
> (In reply to Jani Nikula from comment #14)
> > Another one that might help 
> > http://mid.gmane.org/1441306216-6581-4-git-send-email-ville.syrjala@linux.
> > intel.com
> 
> Still failing with that patch added to the ones mentioned in comment 8 and
> comment 12.

It says gen=8 in the dmesg so this is CHT not BYT. You should definitely try my entire branch (which already includes that earlier patch of mine):
git://github.com/vsyrjala/linux.git vlv_chv_dsi_dpll

It should at least fix all of that DPIO spew, and if we're lucky it might also fix something else.

Though you will need to merge that with the other stuff you've already picked up. Not sure how bad it'll conflict.

I couldn't figure out how to s/byt/cht/ in the bug title, so someone else should do it.
Comment 18 Bastien Nocera 2015-09-04 14:36:21 UTC
(In reply to Ville Syrjala from comment #17)
> (In reply to Bastien Nocera from comment #16)
> > (In reply to Jani Nikula from comment #14)
> > > Another one that might help 
> > >
> http://mid.gmane.org/1441306216-6581-4-git-send-email-ville.syrjala@linux.
> > > intel.com
> > 
> > Still failing with that patch added to the ones mentioned in comment 8 and
> > comment 12.
> 
> It says gen=8 in the dmesg so this is CHT not BYT.

I didn't even notice. Jani changed it, likely in error, when he first commented:
https://bugzilla.kernel.org/show_activity.cgi?id=97941

The Surface 3 is indeed CherryTrail:
https://en.wikipedia.org/wiki/Surface_3

> You should definitely try
> my entire branch (which already includes that earlier patch of mine):
> git://github.com/vsyrjala/linux.git vlv_chv_dsi_dpll

From 38090edf0488bc28313f75f177072f1b4f233713 (excluded) up to the tip of the branch?

> It should at least fix all of that DPIO spew, and if we're lucky it might
> also fix something else.
> 
> Though you will need to merge that with the other stuff you've already
> picked up. Not sure how bad it'll conflict.

I'll try this out then.

> I couldn't figure out how to s/byt/cht/ in the bug title, so someone else
> should do it.

No bugzilla rights to do that either.
Comment 19 Ville Syrjala 2015-09-04 14:38:55 UTC
(In reply to Bastien Nocera from comment #18)
> (In reply to Ville Syrjala from comment #17)
> > You should definitely try
> > my entire branch (which already includes that earlier patch of mine):
> > git://github.com/vsyrjala/linux.git vlv_chv_dsi_dpll
> 
> From 38090edf0488bc28313f75f177072f1b4f233713 (excluded) up to the tip of
> the branch?

Yep.
Comment 20 Bastien Nocera 2015-09-05 10:24:52 UTC
Either I did something wrong rebasing or there's a bug in that branch.

I rebased all the patches mentioned in comment 16 (the patch series, plus the 2 independent patches on top) on top of the vlv_chv_dsi_dpll branch. But the machine must be crashing in the middle of setting up the display.

For the record, this is what the patch on top of the branch looks like:
http://paste.fedoraproject.org/263933/44849914

Is there a way to load force the i915 driver to do modesetting *after* the machine has been booted with nomodeset? This would allow me to connect to the machine through ssh and capture at least the early parts of the modesetting setup.
Comment 21 Benoit Gschwind 2015-09-05 10:34:20 UTC
(In reply to Bastien Nocera from comment #20)
> Either I did something wrong rebasing or there's a bug in that branch.
> 
> I rebased all the patches mentioned in comment 16 (the patch series, plus
> the 2 independent patches on top) on top of the vlv_chv_dsi_dpll branch. But
> the machine must be crashing in the middle of setting up the display.
> 
> For the record, this is what the patch on top of the branch looks like:
> http://paste.fedoraproject.org/263933/44849914
> 
> Is there a way to load force the i915 driver to do modesetting *after* the
> machine has been booted with nomodeset? This would allow me to connect to
> the machine through ssh and capture at least the early parts of the
> modesetting setup.

Hello Bastien,

You have to compile i915 and drm as module and black list them in 

/etc/modprobe.d/blacklist.conf

by adding :

blacklist drm
blacklist i915

then load modules manually

# modprobe drm debug=0xff
# modprobe i915

that's it
Comment 22 Ville Syrjala 2015-09-05 14:58:03 UTC
No real need to blacklist drm, i915 is enough. It can also be done from the kernel command line with "modprobe.blacklist=i915".

Also make sure you disable plymouth, X etc. from automatically starting as they will load the module behind your back despite the blacklisting.
Comment 23 Bastien Nocera 2015-09-05 18:16:49 UTC
(In reply to Ville Syrjala from comment #22)
> No real need to blacklist drm, i915 is enough. It can also be done from the
> kernel command line with "modprobe.blacklist=i915".
> 
> Also make sure you disable plymouth, X etc. from automatically starting as
> they will load the module behind your back despite the blacklisting.

I forgot to disable starting X in my test, but the postponing meant that it errored after the Wi-Fi had been brought up. Log attached (it can detect the display correctly this time!).
Comment 24 Bastien Nocera 2015-09-05 18:17:26 UTC
Created attachment 186831 [details]
kernel-4.2.0-rc8+ drm debug log (fourth build)
Comment 25 Jani Nikula 2015-09-07 08:40:30 UTC
(In reply to Bastien Nocera from comment #18)
> (In reply to Ville Syrjala from comment #17)
> > It says gen=8 in the dmesg so this is CHT not BYT.
> 
> I didn't even notice. Jani changed it, likely in error, when he first
> commented:
> https://bugzilla.kernel.org/show_activity.cgi?id=97941

Bah, is_valleyview in dmesg keeps throwing me off.
Comment 26 Bastien Nocera 2015-09-17 14:31:03 UTC
So I have the vlv_chv_dsi_dpll branch, plus the patchset at:
http://mid.gmane.org/1441841070-11532-1-git-send-email-m.deepak@intel.com
and http://article.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/66645

http://article.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/68903
is already in the vlv_chv_dsi_dpll branch.

Building now.
Comment 27 Bastien Nocera 2015-09-17 16:22:53 UTC
Created attachment 187861 [details]
drm-debug-log
Comment 28 joshmyzie2 2015-11-24 22:02:29 UTC
Any progress on this?  I have a Surface 3 and would be willing to help test any patches or debug settings.  Really want to see Linux running smoothly on this thing!
Comment 29 Jani Nikula 2015-12-02 13:40:29 UTC
We'll probably get a Surface 3 to play with sometime soon, maybe that'll help...
Comment 30 Josh Klar 2015-12-15 19:44:38 UTC
Echoing the hope that this gets sorted - I'm quite interested in picking up a Surface but would need to have graphics support on the thing for it to be of any use to me at all.
Comment 31 Jani Nikula 2015-12-21 14:56:20 UTC
Hi all, please try drm-intel-nightly branch of http://cgit.freedesktop.org/drm-intel *and* the 15-patch series from http://patchwork.freedesktop.org/series/1998/ on top.

No, don't get your hopes up just yet, I don't think it will work. But I'd appreciate the dmesg resulting from running that with drm.debug=14 module parameter set.
Comment 32 Stephen Just 2015-12-22 06:44:45 UTC
Created attachment 197981 [details]
Dmesg after Comment #31

I've attached the dmesg after using the instructions from Comment #31. The system was booted with i915 blacklisted, and right before the dmesg was generated, I ran modprobe i915. Note that the screen resolution switch actually worked and the screen is no longer blank.

It still looks like there's some errors in the logs.

Weston runs now as well as the weston demo programs. GDM is running too. I'll have to do more playing around. I guess this means that functionally everything works?
Comment 33 Josh Klar 2015-12-22 16:50:37 UTC
Very nice. I recently grabbed a Surface and have been running W10 on it until this bug was resolved... looks like I'll have to build a Arch ISO remix tonight :)
Comment 34 Stephen Just 2015-12-22 19:05:53 UTC
If someone has an external monitor they could try, that would be good to test.

Obviously there's probably still some bugs here and there, but in just super excited to finally be able to run a decent desktop on this thing.
Comment 35 Jani Nikula 2015-12-23 10:11:45 UTC
Whoa, I never even dreamed that my patchset would make it work; I just thought it was a necessary intermediate step. A happy surprise for once. :)
Comment 36 John 2015-12-27 21:06:33 UTC
If anyone has a working image file and can share, that would be much appreciated!  It's been a little while since I've compiled a kernel..
Comment 37 Andrea Gottardo 2015-12-27 22:02:14 UTC
I would really appreciate that as well. I'm happy that I'll be finally able to use Linux on my Surface.
Comment 38 Steve 2015-12-28 01:20:22 UTC
Yes this would make many people happy.  Hopefully this change can make it into a distribution soon.
Comment 39 Stephen Just 2015-12-29 23:23:26 UTC
Created attachment 198471 [details]
Dmesg w/ External Monitor, GNOME

I've spent a little bit more time testing this patch, and it looks like external displays are working (I acquired a mini-DP to DVI adapter to test with).

The display brightness control does not appear to be working at this point.

I'm attaching another dmesg, because there are some unusual looking logs towards the end which weren't in the previous dmesg. They showed up after launching Gnome.
Comment 40 Bastien Nocera 2016-01-06 10:26:28 UTC
I didn't have much time to test this, but it's working well enough for me. The EDID of the panel isn't propagated properly (xrandr claims 0mm x 0mm) but at least the interface shows up in the native resolution.
Comment 41 Jani Nikula 2016-01-07 12:11:10 UTC
(In reply to Bastien Nocera from comment #40)
> The EDID of the panel isn't propagated properly (xrandr claims 0mm x 0mm)

FYI, DSI has no EDID.
Comment 42 Bastien Nocera 2016-01-07 12:44:59 UTC
(In reply to Jani Nikula from comment #41)
> (In reply to Bastien Nocera from comment #40)
> > The EDID of the panel isn't propagated properly (xrandr claims 0mm x 0mm)
> 
> FYI, DSI has no EDID.

Is the data about the physical size of the panel available somewhere else? If not, do we have a place somewhere in the driver code base to put it?

The Surface 3 uses a 10.9 inch 1920 x 1280 panel, which, if my maths[1] are right would be 8.99" × 5.99", or 22.82cm × 15.22cm.

[1]: OK, https://www.sven.de/dpi/
Comment 43 Jani Nikula 2016-01-07 13:22:11 UTC
We get the supported mode of the display from the VBT (video bios table), because DSI has no auto-discovery to get that info out of the display itself.

Unfortunately the VBT does not seem to have information about the physical dimensions.
Comment 44 Bastien Nocera 2016-01-07 14:34:13 UTC
(In reply to Jani Nikula from comment #43)
> We get the supported mode of the display from the VBT (video bios table),
> because DSI has no auto-discovery to get that info out of the display itself.
> 
> Unfortunately the VBT does not seem to have information about the physical
> dimensions.

Can we fill that in based on the DMI information, somewhere in the driver? The DPI should be detected as > 200 DPI, and kick GNOME into hi-dpi mode.
Comment 45 Jani Nikula 2016-01-07 15:12:27 UTC
(In reply to Bastien Nocera from comment #44)
> (In reply to Jani Nikula from comment #43)
> > We get the supported mode of the display from the VBT (video bios table),
> > because DSI has no auto-discovery to get that info out of the display
> itself.
> > 
> > Unfortunately the VBT does not seem to have information about the physical
> > dimensions.
> 
> Can we fill that in based on the DMI information, somewhere in the driver?
> The DPI should be detected as > 200 DPI, and kick GNOME into hi-dpi mode.

It would eventually become one giant monster of a DMI match table. I'd rather not start on that path in the kernel.
Comment 46 Jani Nikula 2016-01-11 17:30:56 UTC
(In reply to Jani Nikula from comment #31)
> Hi all, please try drm-intel-nightly branch of
> http://cgit.freedesktop.org/drm-intel *and* the 15-patch series from
> http://patchwork.freedesktop.org/series/1998/ on top.
> 
> No, don't get your hopes up just yet, I don't think it will work. But I'd
> appreciate the dmesg resulting from running that with drm.debug=14 module
> parameter set.

Most of the patches have now been pushed to drm-intel-nightly with minor modifications. Please try drm-intel-nightly again, and report back.

If that does *not* work, please add the one remaining patch [1] on top, and try again.

[1] http://patchwork.freedesktop.org/patch/msgid/1452519005-17244-1-git-send-email-jani.nikula@intel.com
Comment 47 Jani Nikula 2016-01-15 13:05:27 UTC
Ping, anyone up for testing drm-intel-nightly again?

My plan is to close this bug as soon as I get confirmation that we no longer get a black screen. That's kind of the pivotal point in debugging everything else. After that I urge people to file new bugs, one bug per report for any remaining issues, at the freedesktop.org bugzilla [1], and they will be easier to manage one by one.

[1] https://bugs.freedesktop.org/enter_bug.cgi?product=DRI&component=DRM/Intel
Comment 48 Bastien Nocera 2016-01-15 17:46:10 UTC
(In reply to Jani Nikula from comment #47)
> Ping, anyone up for testing drm-intel-nightly again?

I was traveling, and now the laptop keeps shutting down when I'm compiling because it's too hot. Will let you know when I manage to get something compiled and tested...
Comment 49 Bastien Nocera 2016-01-15 23:18:11 UTC
(In reply to Jani Nikula from comment #47)
> Ping, anyone up for testing drm-intel-nightly again?
> 
> My plan is to close this bug as soon as I get confirmation that we no longer
> get a black screen.

After this:
https://twitter.com/hadessuk/status/688070076906520576/photo/1

I managed to compile and run the drm-intel-nightly. It works well enough to show a couple of Tuxes at boot, and a GNOME desktop afterwards. I didn't need to apply any more patches.
Comment 50 Benoit Gschwind 2016-01-16 15:22:32 UTC
Created attachment 199831 [details]
dmesg drm-intel-nightly-20160116

Hello,

The drm-intel-nightly work for me with warning as attached dmesg show.

Best regards.
Comment 51 Jani Nikula 2016-01-17 09:51:25 UTC
Awesome, thanks for testing. As promised, I'm closing this one as fixed. Please file new bugs at the freedesktop.org bugzilla for the remaining graphics issues (like the warnings), one bug per issue:

https://bugs.freedesktop.org/enter_bug.cgi?product=DRI&component=DRM/Intel
Comment 52 Bastien Nocera 2016-01-29 15:04:42 UTC
Filed https://bugs.freedesktop.org/show_bug.cgi?id=93929