freebsd / drm-kmod

drm driver for FreeBSD
148 stars 68 forks source link

Update to Linux 5.17 drivers #236

Closed dumbbell closed 7 months ago

dumbbell commented 1 year ago

This is the backport of the DRM drivers from Linux 5.17.

Progress:

Changes in Linux 5.17

You can read this Phoronix article to learn about the changes in the DRM drivers in Linux 5.17: https://www.phoronix.com/news/Linux-5.17-DRM-Submitted

Patches to linuxkpi

This update depends on the following patches to linuxkpi in FreeBSD:

These patches are maintained in the following repository and branch: https://github.com/dumbbell/freebsd-src/tree/linuxkpi-updates-for-drm

How to test

You need to run a recent FreeBSD 14-CURRENT to test it.

Here are some instructions:

  1. You need to checkout the FreeBSD src branch I mentionned, linuxkpi-updates-for-drm, and compile a kernel from that branch:

    git clone -b linuxkpi-updates-for-drm https://github.com/dumbbell/freebsd-src.git
    cd freebsd-src
    make -j8 buildkernel DEBUG_FLAGS=-g
    
    # This installs the kernel under another name, `kernel.drm`. Thus, you keep the default kernel
    # in case of trouble.
    sudo make installkernel DEBUG_FLAGS=-g INSTKERNNAME=kernel.drm
  2. You need to checkout the branch referenced in this pull request and compile it:

    git clone -b update-to-v5.17 https://github.com/dumbbell/drm-kmod.git
    cd drm-kmod
    make -j8 DEBUG_FLAGS=-g
    sudo make install DEBUG_FLAGS=-g KMODDIR=/boot/kernel.drm

    This will need access to the FreeBSD src tree cloned above. I don't remember the name of the variable to point the build to it. You can link /usr/src to your clone and it will be enough.

  3. You will need GPU firmwares in the kernel.drm directory as well. To compile and install them:

    git clone https://github.com/freebsd/drm-kmod-firmware.git
    cd drm-kmod-firmware
    make -j8 DEBUG_FLAGS=-g OSVERSION=1400000
    sudo make install DEBUG_FLAGS=-g KMODDIR=/boot/kernel.drm OSVERSION=1400000
  4. Load the relevant driver(s) as you usually do.

mekanix commented 1 year ago

Tried to compile and run it and I get

# kldload drm
iic0: <I2C generic I/O> on iicbus0
link_elf_obj: symbol drm_sysfs_connector_status_event undefined
iic0: detached
iicbus0: <unknown card> at addr 0
Warning: memory type debugfsint leaked memory on destroy (2 allocations, 80 bytes leaked).
linker_load_file: /boot/kernel.drm/drm.ko - unsupported file type
kldload: an error occurred while loading module drm. Please check dmesg(8) for more details.

If it's too early for testing, just ignore me :o)

dumbbell commented 1 year ago

The backport is finished, but polishing it will take a significant amount of work: I need to work on/revisit the framebuffer/vt(4) integration code. The amdgpu driver dropped its specific framebuffer code to use the generic code in drm_fb_helper which is commentted out on FreeBSD.

mekanix commented 1 year ago

Driver loads and works fine with Xorg and resume/suspend is without glitches on amdgpu laptop that I have.

orbitz commented 1 year ago

@mekanix I'm getting the error you did. What did you do to address it?

mekanix commented 1 year ago

I had to check again, and I was on a wrong branch, so same error as before.

rhelmot commented 1 year ago

I ran into the same issue as above, so I tried to fix it. I added the following shot-in-the-dark patch to fix the linking error:

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 036aaf7a28..312d538231 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -31,6 +31,7 @@
 #include <drm/drm_device.h>
 #include <drm/drm_print.h>
 #include <drm/drm_sysfs.h>
+#include <drm/drm_property.h>

 #include "drm_internal.h"

@@ -97,6 +98,23 @@ void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)
        sbuf_delete(sb);
 }

+void drm_sysfs_connector_status_event(
+       struct drm_connector *connector, struct drm_property *property)
+{
+       struct drm_device *dev = connector->dev;
+       struct sbuf *sb = sbuf_new_auto();
+
+       DRM_DEBUG("generating status event\n");
+
+       sbuf_printf(sb, "cdev=dri/%s connector_id=%u connector_name=\"%s\""
+           "property_name=\"%s\"",
+           dev_name(dev->primary->kdev), connector->base.id, connector->name,
+           property->name);
+       sbuf_finish(sb);
+       devctl_notify("DRM", "CONNECTOR", "STATUS", sbuf_data(sb));
+       sbuf_delete(sb);
+}
+
 static void drm_sysfs_release(struct device *dev)
 {
        kfree(dev);

Then, drm loaded without issue but attempting to load i915kms seems to crash my entire system (alder lake-p). The screen goes black or freezes, nothing appears in the logs, remote sessions immediately hang, no crash dump is produced, and (to my eye) nothing shows up in the syslogs (booted verbose, logged over the network):

Mar  3 23:32:22 daisy kernel: iic0: <I2C generic I/O> on iicbus0
Mar  3 23:32:22 daisy kernel: lindebugfs registered
Mar  3 23:32:22 daisy kernel: drmn0: <drmn> on vgapci0
Mar  3 23:32:22 daisy kernel: vgapci0: child drmn0 requested pci_enable_io
Mar  3 23:32:22 daisy syslogd: last message repeated 1 times
Mar  3 23:32:22 daisy kernel: [drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19).
Mar  3 23:32:22 daisy kernel: [drm] Got stolen memory base 0x0, size 0x0
Mar  3 23:32:22 daisy kernel: vgapci0: attempting to allocate 1 MSI vectors (1 supported)
Mar  3 23:32:22 daisy kernel: msi: routing MSI IRQ 170 to local APIC 16 vector 50
Mar  3 23:32:22 daisy kernel: vgapci0: using IRQ 170 for MSI
Mar  3 23:32:22 daisy kernel: adlp_dmc_ver2_12.bin: could not load firmware image, error 2
Mar  3 23:32:22 daisy kernel: i915/adlp_dmc_ver2_12.bin: could not load firmware image, error 2
Mar  3 23:32:22 daisy kernel: i915_adlp_dmc_ver2_12.bin: could not load firmware image, error 2
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus dpa
Mar  3 23:32:22 daisy kernel: lkpi_iic0: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus1: <Philips I2C bus> on lkpi_iic0
Mar  3 23:32:22 daisy kernel: iic1: <I2C generic I/O>
Mar  3 23:32:22 daisy kernel:  on iicbus1
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus dpb
Mar  3 23:32:22 daisy kernel: lkpi_iic1: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus2: <Philips I2C bus> on lkpi_iic1
Mar  3 23:32:22 daisy kernel: iic2: <I2C generic I/O> on iicbus2
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus dpc
Mar  3 23:32:22 daisy kernel: lkpi_iic2: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus3: <Philips I2C bus> on lkpi_iic2
Mar  3 23:32:22 daisy kernel: iic3: <I2C generic I/O> on iicbus3
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus tc1
Mar  3 23:32:22 daisy kernel: lkpi_iic3: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus4: <Philips I2C bus> on lkpi_iic3
Mar  3 23:32:22 daisy kernel: iic4: <I2C generic I/O> on iicbus4
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus tc2
Mar  3 23:32:22 daisy kernel: lkpi_iic4: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus5: <Philips I2C bus> on lkpi_iic4
Mar  3 23:32:22 daisy kernel: iic5: <I2C generic I/O> on iicbus5
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus tc3
Mar  3 23:32:22 daisy kernel: lkpi_iic5: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus6: <Philips I2C bus> on lkpi_iic5
Mar  3 23:32:22 daisy kernel: iic6: <I2C generic I/O> on iicbus6
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus tc4
Mar  3 23:32:22 daisy kernel: lkpi_iic6: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus7: <Philips I2C bus> on lkpi_iic6
Mar  3 23:32:22 daisy kernel: iic7: <I2C generic I/O> on iicbus7
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus tc5
Mar  3 23:32:22 daisy kernel: lkpi_iic7: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus8: <Philips I2C bus> on lkpi_iic7
Mar  3 23:32:22 daisy kernel: iic8: <I2C generic I/O> on iicbus8
Mar  3 23:32:22 daisy kernel: drmn0: Adding i2c adapter i915 gmbus tc6
Mar  3 23:32:22 daisy kernel: lkpi_iic8: <LinuxKPI I2C> on drmn0
Mar  3 23:32:22 daisy kernel: iicbus9: <Philips I2C bus> on lkpi_iic8
Mar  3 23:32:22 daisy kernel: iic9: <I2C generic I/O> on iicbus9
Mar  3 23:32:22 daisy kernel: [drm] Connector eDP-1: get mode from tunables:
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.modes.eDP-1
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.default_mode
Mar  3 23:32:22 daisy kernel: firmware: 'i915_adlp_dmc_ver2_12_bin' version 0: 72104 bytes loaded at 0xffffffff85571000
Mar  3 23:32:22 daisy kernel: drmn0: successfully loaded firmware image 'i915/adlp_dmc_ver2_12.bin'
Mar  3 23:32:22 daisy kernel: drmn0: [drm] Finished loading DMC firmware i915/adlp_dmc_ver2_12.bin (v2.12)
Mar  3 23:32:22 daisy kernel: [drm] Connector HDMI-A-1: get mode from tunables:
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.modes.HDMI-A-1
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.default_mode
Mar  3 23:32:22 daisy kernel: [drm] Connector DP-1: get mode from tunables:
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.modes.DP-1
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.default_mode
Mar  3 23:32:22 daisy kernel: [drm] Connector DP-2: get mode from tunables:
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.modes.DP-2
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.default_mode
Mar  3 23:32:22 daisy kernel: [drm] Connector DP-3: get mode from tunables:
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.modes.DP-3
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.default_mode
Mar  3 23:32:22 daisy kernel: [drm] Connector DP-4: get mode from tunables:
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.modes.DP-4
Mar  3 23:32:22 daisy kernel: [drm]  - kern.vt.fb.default_mode

I would like to be useful on this project! Please let me know how I can help or how I can begin debugging this issue.

rhelmot commented 1 year ago

Immediately after I sent this, I figured out that after the system hangs, I can trigger the break-to-debugger keystroke and type in the dump command even though the display isn't working. I now have a core dump from after the driver is loaded. I see a bunch of i915 threads and I will look into what they're doing, but help would still be appreciated :)

rhelmot commented 1 year ago

Discovered the DRM_DEBUG_LOG_ALL flag. Here's the logs from that:

/var/log/messages exerpt ``` Mar 5 00:59:02 daisy kernel: iic0: on iicbus0 Mar 5 00:59:02 daisy kernel: [drm] Initialized Mar 5 00:59:02 daisy kernel: drmn0: on vgapci0 Mar 5 00:59:02 daisy kernel: vgapci0: child drmn0 requested pci_enable_io Mar 5 00:59:02 daisy syslogd: last message repeated 1 times Mar 5 00:59:02 daisy kernel: drmn0: intel_wopcm_init_early: WOPCM: 2048K Mar 5 00:59:02 daisy kernel: drmn0: __confirm_options: enable_guc=3 (guc:yes submission:yes huc:yes slpc:yes) Mar 5 00:59:02 daisy kernel: drmn0: intel_pch_type: Found Alder Lake PCH Mar 5 00:59:02 daisy kernel: drmn0: get_allowed_dc_mask: Allowed DC state mask 08 Mar 5 00:59:02 daisy kernel: drmn0: intel_uncore_init_mmio: unclaimed mmio detected on uncore init, clearing Mar 5 00:59:02 daisy kernel: drmn0: intel_device_info_runtime_init: rawclk rate: 19200 kHz Mar 5 00:59:02 daisy kernel: drmn0: init_engine_mask: vdbox enable: 0005, instances: 0005 Mar 5 00:59:02 daisy kernel: drmn0: init_engine_mask: vebox enable: 0001, instances: 0001 Mar 5 00:59:02 daisy kernel: drmn0: ggtt_probe_hw: GGTT size = 4096M Mar 5 00:59:02 daisy kernel: drmn0: ggtt_probe_hw: GMADR size = 256M Mar 5 00:59:02 daisy kernel: drmn0: ggtt_probe_hw: DSM size = 0M Mar 5 00:59:02 daisy kernel: [drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19). Mar 5 00:59:02 daisy kernel: [drm] Got stolen memory base 0x0, size 0x0 Mar 5 00:59:02 daisy kernel: drmn0: intel_opregion_setup: graphic opregion physical addr: 0x8d64e018 Mar 5 00:59:02 daisy kernel: drmn0: intel_opregion_setup: ACPI OpRegion version 2.1.0 Mar 5 00:59:02 daisy kernel: drmn0: intel_opregion_setup: Public ACPI methods supported Mar 5 00:59:02 daisy kernel: drmn0: intel_opregion_setup: ASLE supported Mar 5 00:59:02 daisy kernel: drmn0: intel_opregion_setup: ASLE extension supported Mar 5 00:59:02 daisy kernel: drmn0: intel_opregion_setup: Found valid VBT in ACPI OpRegion (RVDA) Mar 5 00:59:02 daisy kernel: drmn0: intel_dram_detect: DRAM channels: 4 Mar 5 00:59:02 daisy kernel: drmn0: intel_dram_detect: Watermark level 0 adjustment needed: no Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: QGV 0: DCLK=2401 tRP=24 tRDPRE=20 tRAS=52 tRCD=24 tRC=76 Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: QGV 1: DCLK=4801 tRP=44 tRDPRE=28 tRAS=104 tRCD=44 tRC=148 Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: QGV 2: DCLK=5201 tRP=48 tRDPRE=28 tRAS=112 tRCD=48 tRC=160 Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: QGV 3: DCLK=5201 tRP=48 tRDPRE=28 tRAS=112 tRCD=48 tRC=160 Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: PSF GV 0: CLK=32 Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: PSF GV 1: CLK=48 Mar 5 00:59:02 daisy kernel: drmn0: icl_get_qgv_points: PSF GV 2: CLK=48 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / QGV 0: num_planes=0 deratedbw=16956 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / QGV 1: num_planes=0 deratedbw=23981 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / QGV 2: num_planes=0 deratedbw=24772 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / QGV 3: num_planes=0 deratedbw=24772 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / PSF GV 0: num_planes=0 bw=34133 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / PSF GV 1: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW0 / PSF GV 2: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / QGV 0: num_planes=4 deratedbw=21855 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / QGV 1: num_planes=4 deratedbw=34500 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / QGV 2: num_planes=4 deratedbw=36108 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / QGV 3: num_planes=4 deratedbw=36108 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / PSF GV 0: num_planes=4 bw=34133 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / PSF GV 1: num_planes=4 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW1 / PSF GV 2: num_planes=4 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / QGV 0: num_planes=0 deratedbw=25544 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / QGV 1: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / QGV 2: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / QGV 3: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / PSF GV 0: num_planes=0 bw=34133 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / PSF GV 1: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW2 / PSF GV 2: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / QGV 0: num_planes=0 deratedbw=27900 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / QGV 1: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / QGV 2: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / QGV 3: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / PSF GV 0: num_planes=0 bw=34133 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / PSF GV 1: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW3 / PSF GV 2: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / QGV 0: num_planes=0 deratedbw=29248 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / QGV 1: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / QGV 2: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / QGV 3: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / PSF GV 0: num_planes=0 bw=34133 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / PSF GV 1: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW4 / PSF GV 2: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / QGV 0: num_planes=0 deratedbw=29972 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / QGV 1: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / QGV 2: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / QGV 3: num_planes=0 deratedbw=38000 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / PSF GV 0: num_planes=0 bw=34133 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / PSF GV 1: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: tgl_get_bw_info: BW5 / PSF GV 2: num_planes=0 bw=51200 Mar 5 00:59:02 daisy kernel: drmn0: init_vbt_defaults: Set default to SSC at 120000 kHz Mar 5 00:59:02 daisy kernel: drmn0: intel_bios_init: VBT signature "$VBT ALDERLAKE-P ", BDB version 249 Mar 5 00:59:02 daisy kernel: drmn0: parse_general_features: BDB_GENERAL_FEATURES int_tv_support 0 int_crt_support 0 lvds_use_ssc 0 lvds_ssc_freq 120000 display_clock_mode 1 fdi_rx_polarity_inverted 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_general_definitions: crt_ddc_bus_pin: 2 Mar 5 00:59:02 daisy kernel: drmn0: parse_general_definitions: Expected child device config size for VBT version 249 not known; assuming 39 Mar 5 00:59:02 daisy kernel: drmn0: parse_general_definitions: Found VBT child device with type 0x1806 Mar 5 00:59:02 daisy kernel: drmn0: parse_general_definitions: Found VBT child device with type 0x60d2 Mar 5 00:59:02 daisy kernel: drmn0: parse_general_definitions: Found VBT child device with type 0x68c6 Mar 5 00:59:02 daisy syslogd: last message repeated 3 times Mar 5 00:59:02 daisy kernel: drmn0: parse_panel_options: Invalid VBT panel type 0xff Mar 5 00:59:02 daisy kernel: drmn0: parse_lfp_backlight: VBT backlight PWM modulation frequency 990 Hz, active high, min brightness 3, level 21845, controller 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_sdvo_device_mapping: Skipping SDVO device mapping Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port A VBT info: CRT:0 DVI:0 HDMI:0 DP:1 eDP:1 LSPCON:0 USB-Type-C:0 TBT:0 DSC:0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port A VBT HDMI level shift: 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port B VBT info: CRT:0 DVI:1 HDMI:1 DP:0 eDP:0 LSPCON:0 USB-Type-C:0 TBT:0 DSC:0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port B VBT HDMI level shift: 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port D VBT info: CRT:0 DVI:0 HDMI:0 DP:1 eDP:0 LSPCON:0 USB-Type-C:1 TBT:1 DSC:0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port D VBT HDMI level shift: 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port E VBT info: CRT:0 DVI:0 HDMI:0 DP:1 eDP:0 LSPCON:0 USB-Type-C:1 TBT:1 DSC:0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port E VBT HDMI level shift: 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port F VBT info: CRT:0 DVI:0 HDMI:0 DP:1 eDP:0 LSPCON:0 USB-Type-C:1 TBT:1 DSC:0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port F VBT HDMI level shift: 0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port G VBT info: CRT:0 DVI:0 HDMI:0 DP:1 eDP:0 LSPCON:0 USB-Type-C:1 TBT:1 DSC:0 Mar 5 00:59:02 daisy kernel: drmn0: parse_ddi_port: Port G VBT HDMI level shift: 0 Mar 5 00:59:02 daisy kernel: drmn0: gen9_set_dc_state: Setting DC state from 00 to 00 Mar 5 00:59:02 daisy kernel: drmn0: check_phy_reg: Combo PHY A reg 001628a0 state mismatch: current 90033bbc mask e0000000 expected a0000000 Mar 5 00:59:02 daisy kernel: drmn0: check_phy_reg: Combo PHY A reg 00162804 state mismatch: current 1c000004 mask 00300000 expected 00300000 Mar 5 00:59:02 daisy kernel: drmn0: check_phy_reg: Combo PHY B reg 0006c8a0 state mismatch: current 9003501c mask e0000000 expected a0000000 Mar 5 00:59:02 daisy kernel: drmn0: check_phy_reg: Combo PHY B reg 0006c804 state mismatch: current 1c000004 mask 00300000 expected 00300000 Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling power well 1 Mar 5 00:59:02 daisy kernel: [drm] Current CDCLK 307200 kHz, VCO 614400 kHz, ref 38400 kHz, bypass 19200 kHz, voltage level 0 Mar 5 00:59:02 daisy kernel: drmn0: gen9_dbuf_slices_update: Updating dbuf slices to 0xf Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling always-on Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling DC off Mar 5 00:59:02 daisy kernel: drmn0: gen9_set_dc_state: Setting DC state from 00 to 00 Mar 5 00:59:02 daisy kernel: drmn0: icl_combo_phys_init: Combo PHY A already enabled, won't reprogram it. Mar 5 00:59:02 daisy kernel: drmn0: icl_combo_phys_init: Combo PHY B already enabled, won't reprogram it. Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling power well 2 Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling power well A Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling power well B Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling power well C Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling power well D Mar 5 00:59:02 daisy kernel: drmn0: intel_dmc_ucode_init: Loading i915/adlp_dmc_ver2_12.bin Mar 5 00:59:02 daisy kernel: drmn0: intel_fbc_init: Sanitized enable_fbc value: 0 Mar 5 00:59:02 daisy kernel: drmn0: intel_print_wm_latency: Gen9 Plane WM0 latency 3 (3.0 usec) Mar 5 00:59:02 daisy kernel: drmn0: intel_print_wm_latency: Gen9 Plane WM1 latency 54 (54.0 usec) Mar 5 00:59:02 daisy kernel: drmn0: intel_print_wm_latency: Gen9 Plane WM2 latency 83 (83.0 usec) Mar 5 00:59:02 daisy kernel: drmn0: intel_print_wm_latency: Gen9 Plane WM3 latency 102 (102.0 usec) Mar 5 00:59:02 daisy kernel: drmn0: intel_print_wm_latency: Gen9 Plane WM4 latency 147 (147.0 usec) Mar 5 00:59:02 daisy kernel: drmn0: intel_print_wm_latency: Gen9 Plane WM5 latency 147 (147.0 usec) Mar 5 00:59:02 daisy kernel: lkpi_iic0: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus1: on lkpi_iic0 Mar 5 00:59:02 daisy kernel: iic1: on iicbus1 Mar 5 00:59:02 daisy kernel: lkpi_iic1: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus2: on lkpi_iic1 Mar 5 00:59:02 daisy kernel: iic2: on iicbus2 Mar 5 00:59:02 daisy kernel: lkpi_iic2: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus3: on lkpi_iic2 Mar 5 00:59:02 daisy kernel: iic3: on iicbus3 Mar 5 00:59:02 daisy kernel: lkpi_iic3: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus4: on lkpi_iic3 Mar 5 00:59:02 daisy kernel: iic4: on iicbus4 Mar 5 00:59:02 daisy kernel: lkpi_iic4: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus5: on lkpi_iic4 Mar 5 00:59:02 daisy kernel: iic5: on iicbus5 Mar 5 00:59:02 daisy kernel: lkpi_iic5: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus6: on lkpi_iic5 Mar 5 00:59:02 daisy kernel: iic6: on iicbus6 Mar 5 00:59:02 daisy kernel: lkpi_iic6: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus7: on lkpi_iic6 Mar 5 00:59:02 daisy kernel: iic7: on iicbus7 Mar 5 00:59:02 daisy kernel: lkpi_iic7: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus8: on lkpi_iic7 Mar 5 00:59:02 daisy kernel: iic8: on iicbus8 Mar 5 00:59:02 daisy kernel: lkpi_iic8: on drmn0 Mar 5 00:59:02 daisy kernel: iicbus9: on lkpi_iic8 Mar 5 00:59:02 daisy kernel: iic9: on iicbus9 Mar 5 00:59:02 daisy kernel: drmn0: intel_modeset_init_nogem: 4 display pipes available. Mar 5 00:59:02 daisy kernel: [drm] Current CDCLK 307200 kHz, VCO 614400 kHz, ref 38400 kHz, bypass 19200 kHz, voltage level 0 Mar 5 00:59:02 daisy kernel: drmn0: intel_update_max_cdclk: Max CD clock rate: 652800 kHz Mar 5 00:59:02 daisy kernel: drmn0: intel_update_max_cdclk: Max dotclock rate: 1305600 kHz Mar 5 00:59:02 daisy kernel: drmn0: intel_bios_port_aux_ch: using AUX A for port A (VBT) Mar 5 00:59:02 daisy kernel: drmn0: intel_dp_init_connector: Adding eDP connector on [ENCODER:235:DDI A/PHY A] Mar 5 00:59:02 daisy kernel: [drm] cur t1_t3 1 t8 1 t9 1 t10 500 t11_t12 6000 Mar 5 00:59:02 daisy kernel: [drm] vbt t1_t3 2000 t8 10 t9 2600 t10 500 t11_t12 6000 Mar 5 00:59:02 daisy kernel: drmn0: pps_init_delays: panel power up delay 200, power down delay 50, power cycle delay 600 Mar 5 00:59:02 daisy kernel: drmn0: pps_init_delays: backlight on delay 1, off delay 260 Mar 5 00:59:02 daisy kernel: drmn0: pps_init_registers: panel power sequencer register settings: PP_ON 0x7d00001, PP_OFF 0x1f40001, PP_DIV 0x60 Mar 5 00:59:02 daisy kernel: drmn0: intel_power_well_enable: enabling AUX A Mar 5 00:59:02 daisy kernel: drmn0: intel_pps_vdd_on_unlocked: Turning [ENCODER:235:DDI A/PHY A] VDD on Mar 5 00:59:02 daisy kernel: drmn0: intel_pps_vdd_on_unlocked: PP_STATUS: 0x80000008 PP_CONTROL: 0x0000006f Mar 5 00:59:02 daisy kernel: drmn0: successfully loaded firmware image 'i915/adlp_dmc_ver2_12.bin' Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00000 AUX -> (ret= 15) fffff802de397183h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x02200 AUX -> (ret= 15) fffffe014a2ea5f1h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_read_dpcd_caps: AUX A/DDI A/PHY A: DPCD: fffff802de397183h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00400 AUX -> (ret= 12) fffff802de397250h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_read_desc: AUX A/DDI A/PHY A: DP sink: OUI fffff802de397250hD dev-ID 0xfffff802de397253E HW-rev 0.0 SW-rev 1.253 quirks 0x0000 Mar 5 00:59:02 daisy kernel: drmn0: [drm] Finished loading DMC firmware i915/adlp_dmc_ver2_12.bin (v2.12) Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00700 AUX -> (ret= 3) fffff802de3971a4h Mar 5 00:59:02 daisy kernel: drmn0: intel_edp_init_dpcd: eDP DPCD: fffff802de3971a4h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00070 AUX -> (ret= 2) fffff802de397192h Mar 5 00:59:02 daisy kernel: drmn0: intel_psr_init_dpcd: eDP panel supports PSR version 3 Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x02009 AUX -> (ret= 1) fffffe014a2ea5f7h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x0002e AUX -> (ret= 1) fffffe014a2ea5f6h Mar 5 00:59:02 daisy kernel: drmn0: intel_psr_init_dpcd: PSR2 supported Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x02210 AUX -> (ret= 1) fffffe014a2ea5dfh Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00072 AUX -> (ret= 2) fffffe014a2ea5f4h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00074 AUX -> (ret= 1) fffffe014a2ea5f3h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00010 AUX -> (ret= 16) fffffe014a2ea670h Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00060 AUX -> (ret= 15) fffff802de3971a7h Mar 5 00:59:02 daisy kernel: drmn0: intel_dp_get_dsc_sink_cap: DSC DPCD: fffff802de3971a7h Mar 5 00:59:02 daisy kernel: drmn0: intel_dp_get_dsc_sink_cap: FEC CAPABILITY: 0 Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x00300 AUX -> (ret= 3) fffffe014a2ea68ch Mar 5 00:59:02 daisy kernel: [drm] Supported Monitor Refresh rate range is 40 Hz - 60 Hz Mar 5 00:59:02 daisy kernel: [drm] non_desktop set to 0 Mar 5 00:59:02 daisy kernel: [drm] eDP-1: Assigning EDID-1.4 digital sink color depth as 10 bpc. Mar 5 00:59:02 daisy kernel: [drm] ELD monitor Mar 5 00:59:02 daisy kernel: [drm] ELD size 20, SAD count 0 Mar 5 00:59:02 daisy kernel: [drm] Supported Monitor Refresh rate range is 40 Hz - 60 Hz Mar 5 00:59:02 daisy kernel: [drm] non_desktop set to 0 Mar 5 00:59:02 daisy kernel: [drm] eDP-1: Assigning EDID-1.4 digital sink color depth as 10 bpc. Mar 5 00:59:02 daisy kernel: [drm] Supported Monitor Refresh rate range is 40 Hz - 60 Hz Mar 5 00:59:02 daisy kernel: [drm] non_desktop set to 0 Mar 5 00:59:02 daisy kernel: [drm] eDP-1: Assigning EDID-1.4 digital sink color depth as 10 bpc. Mar 5 00:59:02 daisy kernel: [drm] OBJ ID: 237 (1) Mar 5 00:59:02 daisy kernel: drmn0: intel_panel_edid_fixed_mode: [CONNECTOR:236:eDP-1] using preferred mode from EDID: [drm] Modeline "3840x2400": 60 596200 3840 3888 3920 4000 2400 2403 2408 2484 0x48 0xa Mar 5 00:59:02 daisy kernel: drmn0: intel_drrs_init: VBT doesn't support DRRS Mar 5 00:59:02 daisy kernel: drmn0: drm_dp_dump_access: AUX A/DDI A/PHY A: 0x007a4 AUX -> (ret= 1) fffffe014a2ea670h Mar 5 00:59:02 daisy kernel: drmn0: intel_dp_wait_source_oui: Performing OUI wait Mar 5 00:59:05 daisy kernel: drmn0: intel_pps_vdd_off_sync_unlocked: Turning [ENCODER:235:DDI A/PHY A] VDD off Mar 5 00:59:05 daisy kernel: drmn0: intel_pps_vdd_off_sync_unlocked: PP_STATUS: 0x80000008 PP_CONTROL: 0x00000067 Mar 5 00:59:05 daisy kernel: drmn0: intel_power_well_disable: disabling AUX A ```
dumbbell commented 1 year ago

Thank you @rhelmot for testing! Sorry I didn't push everything to both my freebsd-src and drm-kmod forks as it's really not working at all currently :-) I made several temporary/testing commits that are not made to be pushed to GitHub...

Once I have something closer to a testable version, I will push again and ask for more help :-)

rhelmot commented 1 year ago

Thanks for the update. Is there anything I can do to facilitate development?

Also, what revision of 5.17 are you targeting? I tried debugging this by comparing the boot logs to my linux 5.17 install on this laptop (ubuntu) and the thing that popped out at me was that linux is using dmc firmware v2.14 and this port seems to want to use v2.12. When I ran the diff tool myself, I found a huge number of unported changes, many of which look like correctness fixes. I attempted to port all the changes I could find which seemed relevant to alder lake, and upgraded the firmware version, but haven't gotten any different results.

dumbbell commented 1 year ago

Patches come from Linux v5.17 tag. Bug fixes backported later are therefore not included.

I selfishly admit I would like to find the problem myself for the challenge and "adrenaline". I'm working on the backport since Linux 5.11 patches and this has been uneventful so far. I kind of need/want to go through this and find the issue.

dumbbell commented 1 year ago

Quick update on the backport of 5.17.

  1. Console is broken for both amdgpu and i915kms, not only the former. I'm working on our vt(4) integration layer to make it behave like Linux' fbdev.
  2. The GuC code in i915kms does not work on FreeBSD. This is enabled by default for Intel Gen12+ but can be disabled. For now, it's the only way to successfully load the driver on these iGPUs. This is equally broken in the 5.15-lts branch by the way.
dumbbell commented 1 year ago

The rewrite of the vt(4) integration layer is almost finished, but it's already working for me; see #243.

The Linux 5.17 backport branch was rebased on top of it. It will be required anyway.

timp87 commented 1 year ago

@dumbbell thank you so much for your hard work! I have a question with 14 CURRENT becoming STABLE soon. What is your general plan for now? Are you going to stop porting linux drm for some time once 5.17 is done? Or you plan to keep doing that until some point, for example, prepare Linux 6.1 port for FreeBSD 14 as that one is LTS?

dumbbell commented 1 year ago

For now, I still need to work on 5.17 which is a lot harder to port compared to all previous versions.

Once this is done, I'm not sure. Probably, I'll continue with 5.18, 5.19 and so on. That would be really cool to be in sync with Linux!

I'm glad that it was easier than expected to fix the vt(4) integration, though there are still a few things left.

mekanix commented 1 year ago

After loading amdgpu, my laptop seams frozen. SSH works, so I can do stuff to figure out what's going on. Relevant pciconf -lv portion:

vgapci0@pci0:7:0:0: class=0x030000 rev=0xd1 hdr=0x00 vendor=0x1002 device=0x1638 subvendor=0x17aa subdevice=0x509c
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Cezanne [Radeon Vega Series / Radeon Vega Mobile Series]'
    class      = display
    subclass   = VGA
dumbbell commented 1 year ago

I pushed a commit to disable GuC by default as it's clearly causing the computer to freeze when i915kms is loaded. With GuC disabled on the vt(4) integration rewritten in #243 (which this branch is based on), it looks to work with Intel 12th gen GPUs (I tested that very lightly for now).

I also noticed that a function returns an error during amdgpu init. It always did but the error was ignored so far. I will investigate.

dumbbell commented 1 year ago

Sway works fine on 5.15-lts on my Intel 12th gen GPU (i7-1260p), but not on 5.17 where I get a black screen with a working mouse cursor (and lots of errors in /var/log/messages).

JustAnotherHumanBeing commented 1 year ago

Under a GENERIC kernel, I experience this crash:

panic: acquiring blockable sleep lock with spinlock or critical section held (sleep mutex) linux_wq_exec @ /root/freebsd-src/sys/compat/linuxkpi/common/src/linux_work.c:105

GNU gdb (GDB) 13.1 [GDB v13.1 for FreeBSD]
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd14.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /boot/kernel/kernel...
Reading symbols from /usr/lib/debug//boot/kernel/kernel.debug...

Unread portion of the kernel message buffer:
panic: acquiring blockable sleep lock with spinlock or critical section held (sleep mutex) linux_wq_exec @ /root/freebsd-src/sys/compat/linuxkpi/common/src/linux_work.c:105
cpuid = 0
time = 1679351346
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe015c42ca60
vpanic() at vpanic+0x152/frame 0xfffffe015c42cab0
panic() at panic+0x43/frame 0xfffffe015c42cb10
witness_checkorder() at witness_checkorder+0xc5c/frame 0xfffffe015c42ccd0
__mtx_lock_flags() at __mtx_lock_flags+0x94/frame 0xfffffe015c42cd20
linux_queue_work_on() at linux_queue_work_on+0x9e/frame 0xfffffe015c42cd60
vt_drmfb_drawrect() at vt_drmfb_drawrect+0x5b/frame 0xfffffe015c42cd90
vt_flush() at vt_flush+0x2c4/frame 0xfffffe015c42cdf0
vt_timer() at vt_timer+0xe/frame 0xfffffe015c42ce10
softclock_call_cc() at softclock_call_cc+0x14b/frame 0xfffffe015c42cec0
softclock_thread() at softclock_thread+0xc6/frame 0xfffffe015c42cef0
fork_exit() at fork_exit+0x80/frame 0xfffffe015c42cf30
fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe015c42cf30
--- trap 0xff000000, rip = 0xff000000ff000000, rsp = 0xff000000ff000000, rbp = 0xff000000ff000000 ---
Uptime: 4m50s
Dumping 2503 out of 65301 MB:..1%..11%..21%..31%..41%..51%..61%..71%..81%..91%

warning: Could not load shared library symbols for i915kms.ko.
Do you need "set solib-search-path" or "set sysroot"?
__curthread () at /root/freebsd-src/sys/amd64/include/pcpu_aux.h:59
59      __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu,
(kgdb) #0  __curthread () at /root/freebsd-src/sys/amd64/include/pcpu_aux.h:59
#1  doadump (textdump=textdump@entry=1)
    at /root/freebsd-src/sys/kern/kern_shutdown.c:407
#2  0xffffffff80bedc7c in kern_reboot (howto=260)
    at /root/freebsd-src/sys/kern/kern_shutdown.c:528
#3  0xffffffff80bee19f in vpanic (fmt=<optimized out>, 
    ap=ap@entry=0xfffffe015c42caf0)
    at /root/freebsd-src/sys/kern/kern_shutdown.c:972
#4  0xffffffff80bedf23 in panic (fmt=<unavailable>)
    at /root/freebsd-src/sys/kern/kern_shutdown.c:896
#5  0xffffffff80c5fbcc in witness_checkorder (lock=<optimized out>, flags=9, 
    file=file@entry=0xffffffff811c4cfa "/root/freebsd-src/sys/compat/linuxkpi/common/src/linux_work.c", line=line@entry=105, interlock=interlock@entry=0x0)
    at /root/freebsd-src/sys/kern/subr_witness.c:1141
#6  0xffffffff80bc8784 in __mtx_lock_flags (c=0xfffff80001e1e5e0, opts=0, 
    file=0xffffffff811c4cfa "/root/freebsd-src/sys/compat/linuxkpi/common/src/linux_work.c", line=105) at /root/freebsd-src/sys/kern/kern_mutex.c:278
#7  0xffffffff80e8650e in linux_work_exec_unblock (work=0xfffff8019c5162f0)
    at /root/freebsd-src/sys/compat/linuxkpi/common/src/linux_work.c:105
#8  linux_queue_work_on (cpu=<optimized out>, wq=0xfffff80001e1e5c0, 
    work=0xfffff8019c5162f0)
    at /root/freebsd-src/sys/compat/linuxkpi/common/src/linux_work.c:150
#9  0xffffffff836f60ab in vt_drmfb_drawrect () from /boot/modules/drm.ko
#10 0xffffffff80a38044 in vt_set_border (vd=0xffffffff81aec518 <vt_consdev>, 
    area=0xfffff80002aeee00, c=<optimized out>)
    at /root/freebsd-src/sys/dev/vt/vt_core.c:1320
#11 vt_flush (vd=0xffffffff81aec518 <vt_consdev>)
    at /root/freebsd-src/sys/dev/vt/vt_core.c:1409
#12 0xffffffff80a3562e in vt_timer (arg=<unavailable>)
    at /root/freebsd-src/sys/dev/vt/vt_core.c:1435
#13 0xffffffff80c0c88b in softclock_call_cc (
    c=0xffffffff81aec628 <vt_consdev+272>, 
    cc=cc@entry=0xffffffff81ea3e80 <cc_cpu>, direct=direct@entry=0)
    at /root/freebsd-src/sys/kern/kern_timeout.c:721
#14 0xffffffff80c0e0b6 in softclock_thread (
    arg=arg@entry=0xffffffff81ea3e80 <cc_cpu>)
    at /root/freebsd-src/sys/kern/kern_timeout.c:860
#15 0xffffffff80ba45d0 in fork_exit (
    callout=0xffffffff80c0dff0 <softclock_thread>, 
    arg=0xffffffff81ea3e80 <cc_cpu>, frame=0xfffffe015c42cf40)
    at /root/freebsd-src/sys/kern/kern_fork.c:1102
#16 <signal handler called>
#17 0xff000000ff000000 in ?? ()
Backtrace stopped: Cannot access memory at address 0xff000000ff000000
(kgdb) 

I assume you tested i915kms under a GENERIC-NODEBUG kernel.

dumbbell commented 1 year ago

Indeed, because that's my daily driver. I will try on a GENERIC kernel like you. Thanks for the bug report!

rhelmot commented 1 year ago

I can triage this - the locks being held are vt's vd->vd_curwindow->vb_lock spinlock from vt_flush and the work queue lock, a sleep lock (from drm_fb_helper_damage adding to the workqueue). I have absolutely no idea what the implications of these uses of locks are, but I'm gonna try switching the vt lock to a sleep lock and seeing what happens.

edit: as anyone could have predicted, that did not work!

rhelmot commented 1 year ago

I finally twiddled with locks to the point that the driver loads, though X refuses to start. I suspect that's a separate issue.

These patches are assuredly not commit-ready but they should at least help you skip some steps in figuring out where all the paths that are locking erroneously are, since there's more than just the one which is documented above.

kernel:

diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 267dd7bf2489..80002b9c21f9 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -1406,17 +1406,23 @@ vt_flush(struct vt_device *vd)
                vd->vd_flags &= ~VDF_INVALID;

                a = teken_get_curattr(&vw->vw_terminal->tm_emulator);
+               /*
+                * The below calls may need to run a sleep lock in order to
+                * dispatch linuxkpi work
+                */
+               vtbuf_unlock(&vw->vw_buf);
                vt_set_border(vd, &vw->vw_draw_area, a->ta_bgcolor);
                vt_termrect(vd, vf, &tarea);
                if (vd->vd_driver->vd_invalidate_text)
                        vd->vd_driver->vd_invalidate_text(vd, &tarea);
                if (vt_draw_logo_cpus)
                        vtterm_draw_cpu_logos(vd);
+               vtbuf_lock(&vw->vw_buf);
        }

        if (tarea.tr_begin.tp_col < tarea.tr_end.tp_col) {
-               vd->vd_driver->vd_bitblt_text(vd, vw, &tarea);
                vtbuf_unlock(&vw->vw_buf);
+               vd->vd_driver->vd_bitblt_text(vd, vw, &tarea);
                return (1);
        }

drm-kmod:

diff --git a/drivers/gpu/drm/vt_drmfb.c b/drivers/gpu/drm/vt_drmfb.c
index 116121e14f..62ef106d0c 100644
--- a/drivers/gpu/drm/vt_drmfb.c
+++ b/drivers/gpu/drm/vt_drmfb.c
@@ -257,6 +257,7 @@ vt_drmfb_postswitch(struct vt_device *vd)
 {
        struct fb_info *fbio;
        struct linux_fb_info *info;
+       int locked = mtx_owned(&vd->vd_lock);

        fbio = vd->vd_softc;
        info = to_linux_fb_info(fbio);
@@ -266,8 +267,14 @@ vt_drmfb_postswitch(struct vt_device *vd)
        }

        if (!kdb_active && !KERNEL_PANICKED()) {
+               if (locked) {
+                       VT_UNLOCK(vd);
+               }
                linux_set_current(curthread);
                info->fbops->fb_set_par(info);
+               if (locked) {
+                       VT_LOCK(vd);
+               }
        } else {
 #ifdef DDB
                db_trace_self_depth(10);
dumbbell commented 1 year ago

Thank you @rhelmot! That's really helpful. Would you mind sharing this again in the #243 pull request, where the vt(4) integration patch is being worked on?

gizahNL commented 1 year ago

Intel DG1:

drmn1: <drmn> on vgapci1
vgapci1: child drmn1 requested pci_enable_io
vgapci1: child drmn1 requested pci_enable_io
vgapci1: 0x1000000 bytes of rid 0x10 res 3 failed (0, 0xffffffffffffffff).
drmn1: _lkpi_pci_iomap: failed to alloc bar 0 type 3 rid 16
drmn1: [drm] *ERROR* failed to map registers
drmn1: 0xfffffe0157b6c788Vdrmn1: Please file a bug on drm/i915; see https://gitlab.freedesktop.org/drm/intel/-/wikis/How-to-file-i915-bugs for details.device_attach: drmn1 attach returned 5

It does populate /dev/dri/renderD128, which is a significant progression :) Unfortunately vainfo doesn't like it and can't open the device (my usecase & primary test case is transcoding video).

I compiled against freebsd/main, and needed the following patch on this PR:

diff --git a/linuxkpi/gplv2/include/linux/device.h b/linuxkpi/gplv2/include/linux/device.h
index 6523393d2d..81f872b722 100644
--- a/linuxkpi/gplv2/include/linux/device.h
+++ b/linuxkpi/gplv2/include/linux/device.h
@@ -3,19 +3,4 @@

 #include_next <linux/device.h>

-/* allows to add/remove a custom action to devres stack */
-int devm_add_action(struct device *dev, void (*action)(void *), void *data);
-
-static inline int devm_add_action_or_reset(struct device *dev,
-                      void (*action)(void *), void *data)
-{
-   int ret;
-
-   ret = devm_add_action(dev, action, data);
-   if (ret)
-       action(data);
-
-   return ret;
-}
-
 #endif /* _LINUX_DEVICE_H_ */
diff --git a/linuxkpi/gplv2/src/linux_devres.c b/linuxkpi/gplv2/src/linux_devres.c
index 1243242d08..0ae429605d 100644
--- a/linuxkpi/gplv2/src/linux_devres.c
+++ b/linuxkpi/gplv2/src/linux_devres.c
@@ -17,28 +17,3 @@ static void devm_action_release(struct device *dev, void *res)
    devres->action(devres->data);
 }

-/**
- * devm_add_action() - add a custom action to list of managed resources
- * @dev: Device that owns the action
- * @action: Function that should be called
- * @data: Pointer to data passed to @action implementation
- *
- * This adds a custom action to the list of managed resources so that
- * it gets executed as part of standard resource unwinding.
- */
-int devm_add_action(struct device *dev, void (*action)(void *), void *data)
-{
-   struct action_devres *devres;
-
-   devres = devres_alloc(devm_action_release,
-                 sizeof(struct action_devres), GFP_KERNEL);
-   if (!devres)
-       return -ENOMEM;
-
-   devres->data = data;
-   devres->action = action;
-
-   devres_add(dev, devres);
-   return 0;
-}
-EXPORT_SYMBOL_GPL(devm_add_action);
orbitz commented 1 year ago

Hello! I've been busy for a few months and have not been able to try the latest code. Looks like @dumbbell has been busy too. Do you have a chance to say what the latest status is? Is it worth testing?

dumbbell commented 11 months ago

Hello!

I've been away in July. I'm back home and slowly resume work on the vt(4) integration and this 5.17 port.

dumbbell commented 11 months ago

The work on the vt(4) integration is ready for wider testing as it is feature-complete.

The port of Linux 5.17 DRM drivers is also complete for some time now. Both can be tested at the same time by using the branch of this pull request.

JustAnotherHumanBeing commented 11 months ago

So far, I noticed only one problem after installing the linuxkpi-updates-for-drm kernel and the i915kms driver from the 5.17 branch. If I have the setting kern.vt.splash_cpu=1 in my loader.conf and the splash logos are still on the screen when it's time for i915kms to take over (it could be the case if kern.vt.splash_cpu_duration is set to the value that is not too small), then the logos will become invisible and the area of the screen that would otherwise have been occupied by the logos will become inaccessible by any tty-based app until the value of kern.vt.splash_cpu_duration has expired.

dumbbell commented 11 months ago

Thank you @JustAnotherHumanBeing! I copied your comment to #243 to keep the context in the appropriate pull request. I will look at this problem, probably tomorrow.

dumbbell commented 11 months ago

The branch looks to work correctly with my Intel laptop. However, it is very unstable with my AMD GPU. I'm going to look at that in more details.

The new vt(4) integration (see #243) is ready for review and testing!

huanghwh commented 11 months ago

I try to compile and run on Huawei matebook X Pro, still no drm attached:(

---<>--- Copyright (c) 1992-2023 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 14.0-CURRENT amd64 1400094 #1 linuxkpi-updates-for-drm-n264574-14824d86fb4: Sat Aug 12 23:51:47 CST 2023 hwh@umbp.szadpr.cn:/usr/obj/usr/home/hwh/git/dumbbell/freebsd-src/amd64.amd64/sys/GENERIC amd64 FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152) WARNING: WITNESS option enabled, expect reduced performance. VT(efifb): resolution 3120x2080 CPU: 13th Gen Intel(R) Core(TM) i7-1360P (2611.20-MHz K8-class CPU) Origin="GenuineIntel" Id=0xb06a2 Family=0x6 Model=0xba Stepping=2 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE

Features2=0x7ffafbff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,T SCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND> AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM> AMD Features2=0x121<LAHF,ABM,Prefetch> Structured Extended Features=0x239c27eb<FSGSBASE,TSCADJ,BMI1,AVX2,FDPEXC,SMEP,BMI2,ERMS,INVPCID,NFPUSG,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,PROCT RACE,SHA> Structured Extended Features2=0x984007bc<UMIP,PKU,OSPKE,WAITPKG,GFNI,VAES,VPCLMULQDQ,RDPID,MOVDIRI,MOVDIR64B> Structured Extended Features3=0xfc18c410<FSRM,MD_CLEAR,IBT,IBPB,STIBP,L1DFL,ARCH_CAP,CORE_CAP,SSBD> XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES> IA32_ARCH_CAPS=0x88fd6b<RDCL_NO,IBRS_ALL,SKIP_L1DFL_VME,MDS_NO,TAA_NO> VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID,VID,PostIntr TSC: P-state invariant, performance statistics real memory = 34359738368 (32768 MB) avail memory = 32983736320 (31455 MB) Event timer "LAPIC" quality 600 ACPI APIC Table: FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs FreeBSD/SMP: Non-uniform topology random: registering fast source Intel Secure Key RNG random: fast provider: "Intel Secure Key RNG" random: unblocking device. ioapic0 <Version 2.0> irqs 0-119 Launching APs: 1 4 7 3 9 11 10 5 2 12 15 14 13 6 8 random: entropy device external interface kbd1 at kbdmux0 efirtc0: efirtc0: registered as a time-of-day clock, resolution 1.000000s smbios0: at iomem 0x3fdd6000-0x3fdd601e smbios0: Version: 3.4, BCD Revision: 3.4 aesni0: <AES-CBC,AES-CCM,AES-GCM,AES-ICM,AES-XTS,SHA1,SHA256> acpi0: Firmware Error (ACPI): Failure creating named object [\134_SB.PC00.TPL1._PS0], AE_ALREADY_EXISTS (20221020/dswload2-480) ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20221020/psobject-372) Firmware Error (ACPI): Failure creating named object [\134_SB.PC00.TPL1._PS3], AE_ALREADY_EXISTS (20221020/dswload2-480) ACPI Error: AE_ALREADY_EXISTS, During name lookup/catalog (20221020/psobject-372) acpi_ec1: <Embedded Controller: GPE 0x6e, ECDT> port 0x62,0x66 on acpi0 hpet0: iomem 0xfed00000-0xfed003ff on acpi0 Timecounter "HPET" frequency 19200000 Hz quality 950 Event timer "HPET" frequency 19200000 Hz quality 350 Event timer "HPET1" frequency 19200000 Hz quality 340 Event timer "HPET2" frequency 19200000 Hz quality 340 Event timer "HPET3" frequency 19200000 Hz quality 340 Event timer "HPET4" frequency 19200000 Hz quality 340 Event timer "HPET5" frequency 19200000 Hz quality 340 Event timer "HPET6" frequency 19200000 Hz quality 340 Event timer "HPET7" frequency 19200000 Hz quality 340 atrtc0: port 0x70-0x77 irq 8 on acpi0 atrtc0: Warning: Couldn't map I/O. atrtc0: registered as a time-of-day clock, resolution 1.000000s Event timer "RTC" frequency 32768 Hz quality 0 attimer0: port 0x40-0x43,0x50-0x53 irq 0 on acpi0 Timecounter "i8254" frequency 1193182 Hz quality 0 Event timer "i8254" frequency 1193182 Hz quality 100 Timecounter "ACPI-fast" frequency 3579545 Hz quality 900 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1808-0x180b on acpi0 pcib0: port 0xcf8-0xcff on acpi0 pci0: on pcib0 vgapci0: port 0x3000-0x303f mem 0x601c000000-0x601cffffff,0x4000000000-0x400fffffff at device 2.0 on pci0 vgapci0: Boot video device pcib1: at device 6.0 on pci0 pci1: on pcib1 nvme0: mem 0x5e200000-0x5e203fff at device 0.0 on pci1 pcib2: at device 7.0 on pci0 pcib3: at device 7.2 on pci0 xhci0: <XHCI (generic) USB 3.0 controller> mem 0x601d1a0000-0x601d1affff at device 13.0 on pci0 xhci0: 32 bytes context size, 64-bit DMA usbus0 on xhci0 usbus0: 5.0Gbps Super Speed USB v3.0 pci0: <serial bus, USB> at device 13.2 (no driver attached) pci0: <serial bus, USB> at device 13.3 (no driver attached) xhci1: <Intel Alder Lake USB 3.2 controller> mem 0x5e300000-0x5e30ffff at device 20.0 on pci0 xhci1: 32 bytes context size, 64-bit DMA usbus1: waiting for BIOS to give up control usbus1 on xhci1 usbus1: 5.0Gbps Super Speed USB v3.0 pci0: <memory, RAM> at device 20.2 (no driver attached) pci0: at device 20.3 (no driver attached) pci0: at device 21.0 (no driver attached) pci0: at device 21.1 (no driver attached) pci0: at device 21.2 (no driver attached) pci0: at device 22.0 (no driver attached) pci0: at device 25.0 (no driver attached) pci0: at device 25.1 (no driver attached) pci0: at device 30.0 (no driver attached) pci0: at device 30.2 (no driver attached) isab0: at device 31.0 on pci0 isa0: on isab0 hdac0: mem 0x601d1c0000-0x601d1c3fff,0x601d000000-0x601d0fffff at device 31.3 on pci0 pci0: at device 31.5 (no driver attached) cpu0: on acpi0 acpi_acad0: on acpi0 acpi_tz0: on acpi0 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 atkbd0: irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] acpi_lid0: on acpi0 acpi_button0: on acpi0 battery0: on acpi0 acpi_syscontainer0: on acpi0 acpi_syscontainer1: on acpi0 hwpstate_intel0: on cpu0 hwpstate_intel1: on cpu1 hwpstate_intel2: on cpu2 hwpstate_intel3: on cpu3 hwpstate_intel4: on cpu4 hwpstate_intel5: on cpu5 hwpstate_intel6: on cpu6 hwpstate_intel7: on cpu7 hwpstate_intel8: on cpu8 hwpstate_intel9: on cpu9 hwpstate_intel10: on cpu10 hwpstate_intel11: on cpu11 hwpstate_intel12: on cpu12 hwpstate_intel13: on cpu13 hwpstate_intel14: on cpu14 hwpstate_intel15: on cpu15 Timecounter "TSC-low" frequency 1305601736 Hz quality 1000 Timecounters tick every 1.000 msec ZFS filesystem version: 5 ZFS storage pool version: features support (5000) ugen0.1: at usbus0 ugen1.1: at usbus1 uhub0 on usbus0 uhub0: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0 uhub1 on usbus1 uhub1: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus1 nvme0: Allocated 64MB host memory buffer hdacc0: <Conexant (0x20d0) HDA CODEC> at cad 0 on hdac0 hdaa0: <Conexant (0x20d0) Audio Function Group> at nid 1 on hdacc0 pcm0: <Conexant (0x20d0) (Analog 4.0/2.0)> at nid 38,29 and 25 on hdaa0 pcm1: <Conexant (0x20d0) (Left Analog Headphones)> at nid 22 on hdaa0 nda0 at nvme0 bus 0 scbus0 target 0 lun 1 nda0: <WD PC SN740 SDDPNQE-2T00-1027 74115000 2321BQ400687> nda0: Serial Number 2321BQ400687 nda0: nvme version 1.4 nda0: 1953514MB (4000797360 512 byte sectors) Trying to mount root from zfs:uroot/ROOT/default []... WARNING: WITNESS option enabled, expect reduced performance. uhub0: 5 ports with 5 removable, self powered ugen0.2: <Kingston DataTraveler 3.0> at usbus0 umass0 on uhub0 umass0: <Kingston DataTraveler 3.0, class 0/0, rev 3.20/1.00, addr 1> on usbus0 umass0: SCSI over Bulk-Only; quirks = 0xc000 umass0:1:0: Attached to scbus1 (probe0:umass-sim0:0:0:0): REPORT LUNS. CDB: a0 00 00 00 00 00 00 00 00 10 00 00 (probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error (probe0:umass-sim0:0:0:0): SCSI status: Check Condition (probe0:umass-sim0:0:0:0): SCSI sense: ILLEGAL REQUEST asc:20,0 (Invalid command operation code) (probe0:umass-sim0:0:0:0): Error 22, Unretryable error da0 at umass-sim0 bus 0 scbus1 target 0 lun 0 da0: <Kingston DataTraveler 3.0 PMAP> Removable Direct Access SPC-4 SCSI device da0: Serial Number E0D55EA574B9E511B94F1945 da0: 400.000MB/s transfers da0: 236581MB (484519680 512 byte sectors) da0: quirks=0x2 uhub1: 16 ports with 16 removable, self powered ugen1.2: <3730304233343731345430 USB Camera> at usbus1 ugen1.3: <vendor 0x8087 product 0x0033> at usbus1 [drm] Got Intel graphics stolen memory base 0x0, size 0x0 Intel(R) Wireless WiFi based driver for FreeBSD iwlwifi0: mem 0x601d1c4000-0x601d1c7fff at device 20.3 on pci0 iwlwifi0: successfully loaded firmware image 'iwlwifi-so-a0-gf-a0-73.ucode' iwlwifi0: api flags index 2 larger than supported by driver iwlwifi0: TLV_FW_FSEQ_VERSION: FSEQ Version: 0.0.2.36 iwlwifi0: loaded firmware version 73.35c0a2c6.0 so-a0-gf-a0-73.ucode op_mode iwlmvm iwlwifi0: Detected Intel(R) Wi-Fi 6E AX211 160MHz, REV=0x370 iwlwifi0: successfully loaded firmware image 'iwlwifi-so-a0-gf-a0.pnvm' iwlwifi0: loaded PNVM version 881c99e1 iwlwifi0: Detected RF GF, rfid=0x2010d000 iwlwifi0: base HW address: ac:19:8e:00:4f:ce ig4iic0: at device 21.0 on pci0 ig4iic0: Using MSI iicbus0: <Philips I2C bus (ACPI-hinted)> on ig4iic0 iicbus0: at addr 0x15 iicbus0: at addr 0x57 iic0: <I2C generic I/O> on iicbus0 ig4iic1: at device 21.1 on pci0 ig4iic1: Using MSI iicbus1: <Philips I2C bus (ACPI-hinted)> on ig4iic1 iicbus1: at addr 0x5d iic1: <I2C generic I/O> on iicbus1 ig4iic2: at device 21.2 on pci0 ig4iic2: Using MSI iicbus2: <Philips I2C bus (ACPI-hinted)> on ig4iic2 iicbus2: at addr 0x1b iic2: <I2C generic I/O> on iicbus2 ig4iic3: at device 25.0 on pci0 ig4iic3: Using MSI iicbus3: <Philips I2C bus (ACPI-hinted)> on ig4iic3 iic3: <I2C generic I/O> on iicbus3 ig4iic4: at device 25.1 on pci0 ig4iic4: Using MSI iicbus4: <Philips I2C bus (ACPI-hinted)> on ig4iic4 iicbus4: at addr 0x1a iic4: <I2C generic I/O> on iicbus4 ichsmb0: port 0xefa0-0xefbf mem 0x601d1cc000-0x601d1cc0ff at device 31.4 on pci0 smbus0: on ichsmb0 acpi_wmi0: on acpi0 acpi_wmi0: cannot find EC device acpi_wmi0: Embedded MOF found ACPI: \134_SB.WFDE.WQCC: 1 arguments were passed to a non-method ACPI object (Buffer) (20221020/nsarguments-361) acpi_wmi1: on acpi0 acpi_wmi1: cannot find EC device acpi_wmi1: Embedded MOF found ACPI: \134_SB.WFTE.WQCC: 1 arguments were passed to a non-method ACPI object (Buffer) (20221020/nsarguments-361) acpi_wmi2: on acpi0 acpi_wmi2: cannot find EC device acpi_wmi2: Embedded MOF found ACPI: \134_SB.WMI1.WQBA: 1 arguments were passed to a non-method ACPI object (Buffer) (20221020/nsarguments-361) wlan0: Ethernet address: ac:19:8e:00:4f:ce tap4: Ethernet address: 58:9c:fc:10:ff:93 lo0: link state changed to UP Cuse v0.1.37 @ /dev/cuse wlan0: link state changed to UP iwlwifi0: No beacon heard and the session protection is over already... wlan0: link state changed to DOWN wlan0: link state changed to UP iichid0: <GXTP7863:00 27C6:01E0 I2C HID device> at addr 0x15 on iicbus0 iichid0: Interrupt setup failed. Fallback to sampling hidbus0: on iichid0 iichid1: <GXTP738X:00 27C6:0114 I2C HID device> at addr 0x5d on iicbus1 iichid1: Interrupt setup failed. Fallback to sampling hidbus1: on iichid1 hms0: <GXTP7863:00 27C6:01E0 Mouse> on hidbus0 hms0: 2 buttons and [XYW] coordinates ID=1 hmt0: <GXTP7863:00 27C6:01E0 TouchPad> on hidbus0 hconf0: <GXTP7863:00 27C6:01E0 Configuration> on hidbus0 hmt0: Multitouch touchpad with 2 external buttons, click-pad hmt0: 5 contacts with [C] properties. Report range [0:0] - [3684:2338] hmt1: <GXTP738X:00 27C6:0114 TouchScreen> on hidbus1 hmt1: Multitouch touchscreen with 0 external buttons hmt1: 10 contacts with [] properties. Report range [0:0] - [6240:4160] Security policy loaded: MAC/ntpd (mac_ntpd)

huanghwh commented 10 months ago

After dirty hack, adding RPLP pciid into freebsd-src and drm-kmod, drm driver is load, one main problem is keyboard and mouse respond very slow.

% kldload i915kms

iic0: <I2C generic I/O> on iicbus0
iic1: <I2C generic I/O> on iicbus1
iic2: <I2C generic I/O> on iicbus2
iic3: <I2C generic I/O> on iicbus3
iic4: <I2C generic I/O> on iicbus4
[drm] Got Intel graphics stolen memory base 0x4c800000, size 0x3c00000
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).
drmn0: could not load firmware image 'i915/adlp_dmc_ver2_14.bin'
drmn0: [drm] Failed to load DMC firmware i915/adlp_dmc_ver2_14.bin. Disabling runtime power management.
drmn0: [drm] Run pkg install gpu-firmware-kmod to install it
lkpi_iic0: <LinuxKPI I2C> on drmn0
iicbus5: <Philips I2C bus> on lkpi_iic0
iic5: <I2C generic I/O> on iicbus5
lkpi_iic1: <LinuxKPI I2C> on drmn0
iicbus6: <Philips I2C bus> on lkpi_iic1
iic6: <I2C generic I/O> on iicbus6
lkpi_iic2: <LinuxKPI I2C> on drmn0
iicbus7: <Philips I2C bus> on lkpi_iic2
iic7: <I2C generic I/O> on iicbus7
lkpi_iic3: <LinuxKPI I2C> on drmn0
iicbus8: <Philips I2C bus> on lkpi_iic3
iic8: <I2C generic I/O> on iicbus8
lkpi_iic4: <LinuxKPI I2C> on drmn0
iicbus9: <Philips I2C bus> on lkpi_iic4
iic9: <I2C generic I/O> on iicbus9
lkpi_iic5: <LinuxKPI I2C> on drmn0
iicbus10: <Philips I2C bus> on lkpi_iic5
iic10: <I2C generic I/O> on iicbus10
lkpi_iic6: <LinuxKPI I2C> on drmn0
iicbus11: <Philips I2C bus> on lkpi_iic6
iic11: <I2C generic I/O> on iicbus11
lkpi_iic7: <LinuxKPI I2C> on drmn0
iicbus12: <Philips I2C bus> on lkpi_iic7
iic12: <I2C generic I/O> on iicbus12
lkpi_iic8: <LinuxKPI I2C> on drmn0
iicbus13: <Philips I2C bus> on lkpi_iic8
iic13: <I2C generic I/O> on iicbus13
sysctl_warn_reuse: can't re-use a leaf (hw.dri.debug)!
lkpi_iic9: <LinuxKPI I2C> on drm1
iicbus14: <Philips I2C bus> on lkpi_iic9
iic14: <I2C generic I/O> on iicbus14
lkpi_iic10: <LinuxKPI I2C> on drm2
iicbus15: <Philips I2C bus> on lkpi_iic10
iic15: <I2C generic I/O> on iicbus15
lkpi_iic11: <LinuxKPI I2C> on drm3
iicbus16: <Philips I2C bus> on lkpi_iic11
iic16: <I2C generic I/O> on iicbus16
lkpi_iic12: <LinuxKPI I2C> on drm4
iicbus17: <Philips I2C bus> on lkpi_iic12
iic17: <I2C generic I/O> on iicbus17
lkpi_iic13: <LinuxKPI I2C> on drm5
iicbus18: <Philips I2C bus> on lkpi_iic13
iic18: <I2C generic I/O> on iicbus18
[drm] Initialized i915 1.6.0 20201103 for drmn0 on minor 0
VT: Replacing driver "efifb" with new "drmfb".
start FB_INFO:
height=2080 width=3120 depth=32
pbase=0x4000000000 vbase=0xfffffe0184600000
name=drmn0 id=i915drmfb flags=0x0 stride=12480
end FB_INFO

% uname -a FreeBSD umbp.szadpr.cn 14.0-CURRENT FreeBSD 14.0-CURRENT amd64 1400094 #3 linuxkpi-updates-for-drm-n264574-14824d86fb4-dirty: Mon Aug 14 08:39:51 CST 2023 hwh@umbp.szadpr.cn:/usr/obj/usr/home/hwh/git/dumbbell/freebsd-src/amd64.amd64/sys/GENERIC amd64

and the patch:

diff --git a/sys/x86/pci/pci_early_quirks.c b/sys/x86/pci/pci_early_quirks.c
index ab8072b38d1..741ae22da87 100644
--- a/sys/x86/pci/pci_early_quirks.c
+++ b/sys/x86/pci/pci_early_quirks.c
@@ -263,6 +263,7 @@ static const struct pci_device_id intel_ids[] = {
        INTEL_ADLS_IDS(&intel_stolen_ops_gen11),
        INTEL_ADLP_IDS(&intel_stolen_ops_gen11),
        INTEL_RPLS_IDS(&intel_stolen_ops_gen11),
+       INTEL_RPLP_IDS(&intel_stolen_ops_gen11),
 };

 /*
diff --git a/sys/x86/pci/pci_early_quirks.h b/sys/x86/pci/pci_early_quirks.h
index 5267a5b3e30..d47600499ae 100644
--- a/sys/x86/pci/pci_early_quirks.h
+++ b/sys/x86/pci/pci_early_quirks.h
@@ -572,4 +572,13 @@
        INTEL_VGA_DEVICE(0xA788, info), \
        INTEL_VGA_DEVICE(0xA789, info)

+/* RPL-P */
+#define INTEL_RPLP_IDS(info) \
+       INTEL_VGA_DEVICE(0xA720, info), \
+       INTEL_VGA_DEVICE(0xA721, info), \
+       INTEL_VGA_DEVICE(0xA7A0, info), \
+       INTEL_VGA_DEVICE(0xA7A1, info), \
+       INTEL_VGA_DEVICE(0xA7A8, info), \
+       INTEL_VGA_DEVICE(0xA7A9, info)
+
 #endif /* _PCI_EARLY_QUIRKS_H_ */

diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 503dcd9360..213035704a 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -1133,6 +1133,7 @@ static const struct pci_device_id pciidlist[] = {
        INTEL_ADLP_IDS(&adl_p_info),
        INTEL_DG1_IDS(&dg1_info),
        INTEL_RPLS_IDS(&adl_s_info),
+       INTEL_RPLP_IDS(&adl_p_info),
        {0, 0, 0}
 };
 #ifdef __linux__
diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index 1238c19f30..c9ccd6d0f2 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -170,8 +170,9 @@ static const u16 subplatform_portf_ids[] = {
        INTEL_ICL_PORT_F_IDS(0),
 };

-static const u16 subplatform_rpls_ids[] = {
+static const u16 subplatform_rpl_ids[] = {
        INTEL_RPLS_IDS(0),
+       INTEL_RPLP_IDS(0),
 };

 static bool find_devid(u16 id, const u16 *p, unsigned int num)
@@ -210,8 +211,8 @@ void intel_device_info_subplatform_init(struct drm_i915_private *i915)
        } else if (find_devid(devid, subplatform_portf_ids,
                              ARRAY_SIZE(subplatform_portf_ids))) {
                mask = BIT(INTEL_SUBPLATFORM_PORTF);
-       } else if (find_devid(devid, subplatform_rpls_ids,
-                             ARRAY_SIZE(subplatform_rpls_ids))) {
+       } else if (find_devid(devid, subplatform_rpl_ids,
+                             ARRAY_SIZE(subplatform_rpl_ids))) {
                mask = BIT(INTEL_SUBPLATFORM_RPL_S);
        }

diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
index baf3d1d3d5..9f1f7652f7 100644
--- a/include/drm/i915_pciids.h
+++ b/include/drm/i915_pciids.h
@@ -675,4 +675,13 @@
        INTEL_VGA_DEVICE(0xA788, info), \
        INTEL_VGA_DEVICE(0xA789, info)

+/* RPL-P */
+#define INTEL_RPLP_IDS(info) \
+       INTEL_VGA_DEVICE(0xA720, info), \
+       INTEL_VGA_DEVICE(0xA721, info), \
+       INTEL_VGA_DEVICE(0xA7A0, info), \
+       INTEL_VGA_DEVICE(0xA7A1, info), \
+       INTEL_VGA_DEVICE(0xA7A8, info), \
+       INTEL_VGA_DEVICE(0xA7A9, info)
+
 #endif /* _I915_PCIIDS_H */
orbitz commented 10 months ago

I managed to start an x session with this! Wooo, great start!

gizahNL commented 10 months ago

2023-08-14_12-20 2023-08-14_12-21

After fiddling a bit with my bios settings (disabling legacy video init in CSM options) I managed to get my card to do more than nothing ;) Intel DG1, so not officially supported in 5.17 ("supported" since 5.19, but didn't crash my Linux desktop on similar pre 5.19 kernel versions)

orbitz commented 10 months ago

I installed the latest commits today. intel_backlight is not working for me, it does not adjust the light and it just reports 0% for everything.

dumbbell commented 10 months ago

I installed the latest commits today. intel_backlight is not working for me, it does not adjust the light and it just reports 0% for everything.

Did you try with the backlight(8) too provided with base?

orbitz commented 10 months ago

Did you try with the backlight(8) too provided with base?

Whoop! That worked! Thank you.

I'm compiling and testing latest commits now.

dumbbell commented 10 months ago

Cool :)

I didn't make any changes to what I pushed this morning. I simply squashed/reordered some commits.

I'm still trying to figure out what is wrong with the amdgpu driver. It loads fine and the console seems to work. However I get a kernel panic as soon as I start Sway. I think this is a memory mapping that fails or isn't made at all. I'm in the process of bisecting.

rhelmot commented 10 months ago

Hold on - is sway supposed to actually work on this branch? I haven't been able to get any wayland compositor to run on this branch (alder lake-p). Before the hiatus, it produced really badly corrupted graphics, and now it produces a black screen with just a cursor. It runs fine with the pixman backend, so it's definitely a kms problem. I assumed it was just sway not integrating correctly but if it's expected to work then there's something wrong here. Can I provide any additional debugging logs to help diagnose this?

dumbbell commented 10 months ago

The branch is supposed to work with Sway and Alder-Lake-P. I'm writing this from a Framework 13 laptop with an i7-1260P CPU.

With i915kms, there is a known issue with suspend/resume. Otherwise, it looks fine from light testing. I would like to find what's wrong with the amdgpu driver first, in case the problem is general and not AMD-specific.

Perhaps try to set hw.dri.debug=4095 in /boot/loader.conf and see if there are some hints from the log messages. I see messages from Sway that I never saw before with i915kms. I didn't push this lead further for now, but I think I saw the same with the 5.15-tls branch.

rhelmot commented 10 months ago

Alright :) feel free to ignore this until you're finished with the other thing, but here's the snippet of /var/log/messages having booted with that flag from me starting a sway session and then killing it out-of-band:

  Aug 20 11:50:16 daisy seatd[1814]: 00:13:07.799 [INFO] [seatd/server.c:146] New client connected (pid: 2069, uid: 1001, gid: 1001)                                                          
  Aug 20 11:50:16 daisy seatd[1814]: 00:13:07.800 [INFO] [seatd/seat.c:170] Added client 2 to seat0                                                                                           
  Aug 20 11:50:16 daisy seatd[1814]: 00:13:07.800 [INFO] [seatd/seat.c:480] Opened client 2 on seat0                                                                                          
  Aug 20 11:50:31 daisy kernel: 0000080                                                                                                                                                       
  Aug 20 11:50:31 daisy kernel: drmn0: [drm] *ERROR* Fault errors on pipe A: 0x00000080                                                                                                       
  Aug 20 11:50:31 daisy syslogd: last message repeated 1753 times                                                                                                                             
  Aug 20 11:50:57 daisy seatd[1814]: 00:13:48.906 [INFO] [seatd/seat.c:621] Switching from VT 2 to VT 4                                                                                       
  Aug 20 11:50:57 daisy kernel: : 0x00000080                                                                                                                                                  
  Aug 20 11:50:57 daisy kernel: drmn0: [drm] *ERROR* Fault errors on pipe A: 0x00000080                                                                                                       
  Aug 20 11:50:57 daisy syslogd: last message repeated 1751 times                                                                                                                             
  Aug 20 11:50:57 daisy seatd[1814]: 00:13:48.942 [INFO] [seatd/seat.c:560] Disabling client 2 on seat0                                                                                       
  Aug 20 11:50:57 daisy seatd[1814]: 00:13:48.963 [INFO] [seatd/seat.c:576] Disabled client 2 on seat0                                                                                        
  Aug 20 11:50:57 daisy kernel: drmn0: [drm] *ERROR* Fault errors on pipe A: 0x00000080                                                                                                       
  Aug 20 11:50:57 daisy syslogd: last message repeated 84 times                                                                                                                               
  Aug 20 11:51:16 daisy devd[1517]: check_clients:  dropping disconnected client     
dumbbell commented 10 months ago

The instabilities I see with the amdgpu driver come from my vt(4) integration patch, because master works fine, but #243 panics, even when the new vt_drmfb is not used (but the rest of the changes to drm_fb_helper.c and linux_base.c are applied.

dumbbell commented 10 months ago

The amdgpu is stable again! The problem was in the changes to register_framebuffer in #243. The commit titled "vt(4) integration: Move fictitious range (un)register out of (un)register_framebuffer()" fixes it.

I can start using this branch as my daily driver again and see how it behaves.

ambroff commented 9 months ago

Great work on this! It looks like a colossal undertaking. I'm trying to read through some of the changes to get up to speed on how all of this works.

Hold on - is sway supposed to actually work on this branch? I haven't been able to get any wayland compositor to run on this branch (alder lake-p). Before the hiatus, it produced really badly corrupted graphics, and now it produces a black screen with just a cursor. It runs fine with the pixman backend, so it's definitely a kms problem. I assumed it was just sway not integrating correctly but if it's expected to work then there's something wrong here. Can I provide any additional debugging logs to help diagnose this?

I have been testing this with de9e9ea9f and I see the same thing. I get a blank screen with a cursor when I start sway. When I start a terminal app or something I see like one row of pixels at the top of the screen that is lit with colors that I would expect to see from the window decoration but otherwise the screen is still black.

Using xorg works wonderfully though. It's nice to not have to use the scfb driver anymore.

I'm using a Framework laptop with a i5-1240P..

I have some vacation coming up soon so I plan to spend some time trying to debug this.

freebsdcross commented 7 months ago

Hello, is there any progress here? any way I can help out? (I am a software developer with FreeBSD and kernel experience -- used to have a commit bit even).

dumbbell commented 7 months ago

Hello, is there any progress here? any way I can help out? (I am a software developer with FreeBSD and kernel experience -- used to have a commit bit even).

Hi!

The 5.17 update is ready for quite some time now. The blocker is the new vt(4)/DRM integration, see #243. I believe it's ready and the more it is tested, the faster it will be approved I suppose :-)

If you have spare time, please test the vt(4) integration using either the branch for #243, or this branch, and report success/failre in #243. If you want to dig further, there is room for improvement to support vt-switching to handle kdb/ddb/panic. Thank you for offering your help!

driesmp commented 7 months ago

Hello, is there any progress here? any way I can help out? (I am a software developer with FreeBSD and kernel experience -- used to have a commit bit even).

Hi!

The 5.17 update is ready for quite some time now. The blocker is the new vt(4)/DRM integration, see #243. I believe it's ready and the more it is tested, the faster it will be approved I suppose :-)

If you have spare time, please test the vt(4) integration using either the branch for #243, or this branch, and report success/failre in #243. If you want to dig further, there is room for improvement to support vt-switching to handle kdb/ddb/panic. Thank you for offering your help!

Hello dumbbell, do you know if 5.17 also supports graphics from 14th gen intel processors? 13th gen I'm sure of :)

dumbbell commented 7 months ago

Hi @driesmp! Linux 5.17, I don't think so: this version was the first one having stable support for the 12th gen. A quick search for Intel 14th gen GPU support returns many results around Linux 6.1.

thewanderingtraderm commented 7 months ago

when is this going to be merged? I have an Intel alder lake i7-12700H with Intel Alder Lake-P - Integrated Graphics Controller and when I load the i915kms graphics driver the whole system freezes.

wulf7 commented 7 months ago

when is this going to be merged?

It is still marked as draft