need some help with PRIME 'output' mode

I am trying to set this up for 3rd time - spent one more day today, without much success. Have an impression that I am missing something small, could someone please advise.

I have Lenovo P50 with intel and NVidia M1000M cards.

Internal P50 display is connected to intel ‘card’. I created xorg.conf with active nvidia, inactive intel like in README, started X server on :1, it starts fine, but display does not turn on (i see backlight is off). I can switch vts between :0 or text consoles but once I am arriving to vt there :1 should be I see black screen.

In xrandr --listproviders I see:
Provider 0: id: 0x2af cap: 0x1, Source Output crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-0
Provider 1: id: 0x43 cap: 0x2, Sink Output crtcs: 3 outputs: 1 associated providers: 0 name:modesetting

I can xrandr --setprovidersource modesetting NVIDIA-0, but xrandr --auto doesn’t work afterwards (invalid parameter attributes)

xrandr returns:
Screen 0: minimum 8 x 8, current 640 x 480, maximum 16384 x 16384
eDP-1-1 connected (normal left inverted right x axis y axis)
3840x2160 60.00 + 59.98 59.97

And list of the modes. None having ‘*’, so mode seems not set.

I am using latest 5.2 kernel, latest (435.21) nvidia drivers and fairly recent fully up-to-date debian testing with xorg (1.20.4) and intel drivers (2.99.917+git20190815).

Nothing suspicios in /var/log/Xorg.1.log, no errors. Both modesetting and nvidia drivers load well. Modesetting sees my eDP-1-1, query EDID and sees all modes from internal display.

What could this be? Any idea how to debug it?

Thanks in advance

xtrace -n xrandr --output eDP-1-1 --mode 1920x1080

says:

000:<:0019: 20: RANDR-Request(140,7): SetScreenSize window=0x000002b4 width=1920 height=1080 width[mm]=652 height[mm]=366

000:>:0019:Error 8=Match: major=140, minor=7, bad=0x000002b4, seq=0019

Hoe do you run the xrandr commands, using an .xinitrc or from another vt? If from vt, you’ll have to set DISPLAY=:1

yes, I run from another vt, I did export DISPLAY=:1

Does it work if you put it into ~/xinitrc ?
Maybe also check the workaround
xrandr --output eDP-1-1 --off
xrandr --output eDP-1-1 --auto

Edit: fixed some typos

Not tried xinitrc yet, but --off has same effect:

xtrace -n xrandr --output eDP-1-1 --off

has same effect as any other command:

000:<:0019: 20: RANDR-Request(140,7): SetScreenSize window=0x000002b4 width=8 height=8 width[mm]=2

000:>:0019:Error 8=Match: major=140, minor=7, bad=0x000002b4, seq=0019

seems like xrandr --output … --off trying to setscreensize in all cases which is non-obvious to me from sources. I’ll try to look into sources and figure out what is happening. Also I noticed that after manually loading nvidia-drm modeset=1 which is somehow required to get ‘Source output’ capability there is kernel error:
[ 97.078464] nv_drm_atomic_helper_disable_all+0xa7/0x250 [nvidia_drm]
[ 97.082363] nv_drm_master_drop+0x22/0x60 [nvidia_drm]
[ 97.086283] drm_drop_master+0x1e/0x30 [drm]
[ 97.090187] drm_master_release+0x91/0xb0 [drm]
[ 97.094064] drm_file_free.part.5+0x2e2/0x2f0 [drm]
[ 97.097911] drm_release+0x4b/0x80 [drm]
[ 97.101771] __fput+0xb6/0x220
[ 97.105619] task_work_run+0x8a/0xb0
[ 97.109390] exit_to_usermode_loop+0xeb/0xf0
[ 97.113189] do_syscall_64+0x128/0x130
[ 97.117058] entry_SYSCALL_64_after_hwframe+0x44/0xa9

All this seems way to complex to solve at forum…

Looks like the only place it could fail at xorg side is here:

Which distribution are you running?
Please run nvidia-bug-report.sh as root and attach the resulting .gz file to your post. Hovering the mouse over an existing post of yours will reveal a paperclip icon.
https://devtalk.nvidia.com/default/topic/1043347/announcements/attaching-files-to-forum-topics-posts/