Skip to content

Make it compile on Linux 6.16 and improve performance#32

Open
tiirwaa wants to merge 39 commits intorhgndf:mainfrom
tiirwaa:main
Open

Make it compile on Linux 6.16 and improve performance#32
tiirwaa wants to merge 39 commits intorhgndf:mainfrom
tiirwaa:main

Conversation

@tiirwaa
Copy link
Copy Markdown

@tiirwaa tiirwaa commented Jul 19, 2025

uname -r
6.15.6-1-liquorix-amd64

lsmod | grep ms912x
ms912x 24576 1
drm_shmem_helper 40960 1 ms912x
drm_ttm_helper 16384 3 ms912x,nvidia_drm,xe
drm_client_lib 20480 4 ms912x,nvidia_drm,xe,i915
drm_kms_helper 241664 8 ms912x,drm_shmem_helper,drm_display_helper,drm_ttm_helper,nvidia_drm,drm_client_lib,xe,i915
drm 815104 33 gpu_sched,i2c_hid,ms912x,drm_kms_helper,drm_exec,drm_gpuvm,drm_suballoc_helper,drm_shmem_helper,drm_display_helper,nvidia,drm_buddy,drm_ttm_helper,nvidia_drm,drm_client_lib,xe,i915,ttm

dmesg | grep ms912x
[ 1357.389889] usbcore: registered new interface driver ms912x
[ 1362.995188] [drm] Initialized ms912x 0.0.1 for 3-4.3:1.3 on minor 2
[ 3077.155772] Modules linked in: ms912x(O) snd_usb_audio snd_usbmidi_lib snd_ump drm_shmem_helper xt_set ip_set xfrm_user xfrm_algo af_packet rfcomm cmac algif_hash algif_skcipher af_alg snd_hrtimer nvidia_uvm(O) xt_CHECKSUM xt_MASQUERADE nft_chain_nat nf_nat bridge stp llc vboxnetadp(O) vboxnetflt(O) snd_ctl_led snd_soc_skl_hda_dsp snd_soc_intel_sof_board_helpers snd_soc_intel_hda_dsp_common snd_sof_probes overlay vboxdrv(O) ip6t_REJECT nf_reject_ipv6 xt_hl ip6t_rt ipt_REJECT nf_reject_ipv4 xt_LOG nf_log_syslog nft_limit snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_soc_dmic snd_sof_pci_intel_tgl snd_sof_pci_intel_cnl snd_sof_intel_hda_generic soundwire_intel snd_sof_intel_hda_sdw_bpt snd_sof_intel_hda_common snd_soc_hdac_hda snd_sof_intel_hda_mlink snd_sof_intel_hda soundwire_cadence snd_sof_pci snd_sof_xtensa_dsp snd_sof snd_sof_utils snd_soc_acpi_intel_match snd_soc_acpi_intel_sdca_quirks soundwire_generic_allocation snd_soc_acpi soundwire_bus snd_soc_sdca crc8 xt_limit snd_soc_avs bnep
[ 3077.155864] ghash_clmulni_intel sha512_ssse3 cec sha256_ssse3 rc_core sha1_ssse3 aesni_intel crypto_simd ucsi_acpi cryptd intel_lpss_pci drm_kms_helper i2c_i801 r8169 i2c_hid_acpi spi_intel_pci i2c_hid typec_ucsi i2c_smbus intel_lpss intel_gtt spi_intel i2c_mux realtek usbhid rtsx_pci idma64 agpgart typec drm video wmi pinctrl_tigerlake [last unloaded: ms912x(O)]
[ 3104.005031] usbcore: deregistering interface driver ms912x
[ 3115.118857] usbcore: registered new interface driver ms912x
[ 3121.459230] [drm] Initialized ms912x 0.0.1 for 3-4.3:1.3 on minor 2
[ 3121.878262] ms912x 3-4.3:1.3: [drm] fb2: ms912xdrmfb frame buffer device

Andrey added 8 commits July 19, 2025 12:29
@tiirwaa tiirwaa changed the title Make it compile on 6.15 Make it compile on Linux 6.15 and improve performance Jul 20, 2025
Andrey added 4 commits July 20, 2025 15:22
…aximum 1920x1080 resolution

- Allocate temp_buffer once per request with size 1920 * 4 bytes (max line width * bytes per pixel)
- Avoid repeated dynamic allocations in ms912x_fb_xrgb8888_to_yuv422()
- Improve performance and reduce memory fragmentation
…in ms912x_fb_send_rect

- Removed wait_for_completion_timeout to avoid stalling workqueue and improve frame throughput.
- Resulted in smoother video playback, especially noticeable with multi-monitor setups.
- Ensured driver stability while reducing latency in USB requests.
Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of Andrey’s last 3 commits:

Optimize temp_buffer allocation (7077109):
Improved temp_buffer allocation by pre-allocating a fixed buffer size to avoid repeated dynamic allocations, enhancing performance and reducing memory fragmentation.

Fix on ms912x_free_request (6c2a59c):
Fixed resource freeing function to properly clean up buffers, preventing potential memory leaks and misuse.

Improve performance by removing blocking wait_for_completion_timeout (37f09d6):
Removed blocking wait_for_completion_timeout in ms912x_fb_send_rect, significantly improving performance and video smoothness, especially on setups with multiple monitors. The driver remains stable after this change.

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using wait_for_completion_timeout together with the 60 FPS frame limiting logic results in good performance and effective vertical synchronization (vsync). This helps reduce tearing and ensures smoother display output.

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improved performance

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get more fps on the usb screen, lowering timeout is allowing thank to the fps limit

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Fixed timeout in fps limiter to 16ms = 60fps]
get more mps on usb hdmi screen
reduce mouse flickering

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optimizations

Copy link
Copy Markdown
Author

@tiirwaa tiirwaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restored modes deleted by error

@rhgndf
Copy link
Copy Markdown
Owner

rhgndf commented Jul 27, 2025

Can you format with clang-format? The diffs are very difficult to read at the moment

@rhgndf
Copy link
Copy Markdown
Owner

rhgndf commented Jul 27, 2025

Also please clean up the comments, there are a lot of random comments left in the code

@rhgndf
Copy link
Copy Markdown
Owner

rhgndf commented Jul 27, 2025

Thanks for the contribution @tiirwaa! I need you to answer to some of the comments on this PR.

Repository owner deleted a comment from Copilot AI Jul 27, 2025
Repository owner deleted a comment from Copilot AI Jul 27, 2025
Repository owner deleted a comment from Copilot AI Jul 27, 2025
Repository owner deleted a comment from Copilot AI Jul 27, 2025
Repository owner deleted a comment from Copilot AI Jul 27, 2025
Repository owner deleted a comment from Copilot AI Jul 27, 2025
tiirwaa and others added 19 commits July 27, 2025 12:22
Missing space in comment. Should be '/* Same data reused here */'.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Enable runtime configuration of ms912x_mode_list[0].mode via module parameter
Enable runtime override of ms912x_mode_list[0].mode via module parameter

This change removes the const qualifier from ms912x_mode_list and adds a write-only module parameter (mode_set) that allows setting the mode field of the first entry in the mode list at runtime.
The feature is intended for debugging and testing purposes, enabling developers to quickly force a specific HDMI output mode without recompiling the driver.

Notes:

Only ms912x_mode_list[0].mode is affected.

No validation or hardware reconfiguration is performed after changing the value; the updated mode will take effect only if/when the driver reads it again (e.g., during re-initialization).

Parameter is restricted to root or members of the root group (S_IWUSR | S_IWGRP).
I am using Arch Linux with Kernel 6.16.4-arch1-1. This patch allows the driver to be compiled. "from_timer" was renamed to "timer_container_of" in the Linux Kernel. There seems to be some graphical problems. Idk how to fix that, so good luck.
"from_timer" was renamed to "timer_container_of"
@rapgro
Copy link
Copy Markdown

rapgro commented Sep 12, 2025

$ LANG=C make -j4 KERNELRELEASE=6.15.8-100.fc41.x86_64 all


make CHECK="/usr/bin/sparse" -C /lib/modules/6.15.8-100.fc41.x86_64/build M=/home/raphael/build/ms912x-k615 modules
make[1]: Entering directory '/usr/src/kernels/6.15.8-100.fc41.x86_64'
make[2]: Entering directory '/home/raphael/build/ms912x-k615'
  CC [M]  ms912x_transfer.o
ms912x_transfer.c: In function 'ms912x_request_timeout':
ms912x_transfer.c:15:46: error: implicit declaration of function 'timer_container_of'; did you mean 'container_of'? [-Wimplicit-function-declaration]
   15 |         struct ms912x_usb_request *request = timer_container_of(request, t, timer);
      |                                              ^~~~~~~~~~~~~~~~~~
      |                                              container_of
ms912x_transfer.c:15:77: error: 'timer' undeclared (first use in this function); did you mean 'ktimerd'?
   15 |         struct ms912x_usb_request *request = timer_container_of(request, t, timer);
      |                                                                             ^~~~~
      |                                                                             ktimerd
ms912x_transfer.c:15:77: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [/usr/src/kernels/6.15.8-100.fc41.x86_64/scripts/Makefile.build:203: ms912x_transfer.o] Error 1
make[3]: *** [/usr/src/kernels/6.15.8-100.fc41.x86_64/Makefile:2043: .] Error 2
make[2]: *** [/usr/src/kernels/6.15.8-100.fc41.x86_64/Makefile:260: __sub-make] Error 2
make[2]: Leaving directory '/home/raphael/build/ms912x-k615'
make[1]: *** [Makefile:260: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/kernels/6.15.8-100.fc41.x86_64'
make: *** [Makefile:24: modules] Error 2

@tiirwaa tiirwaa changed the title Make it compile on Linux 6.15 and improve performance Make it compile on Linux 6.16 and improve performance Sep 12, 2025
@tiirwaa
Copy link
Copy Markdown
Author

tiirwaa commented Sep 12, 2025

$ LANG=C make -j4 KERNELRELEASE=6.15.8-100.fc41.x86_64 all


make CHECK="/usr/bin/sparse" -C /lib/modules/6.15.8-100.fc41.x86_64/build M=/home/raphael/build/ms912x-k615 modules
make[1]: Entering directory '/usr/src/kernels/6.15.8-100.fc41.x86_64'
make[2]: Entering directory '/home/raphael/build/ms912x-k615'
  CC [M]  ms912x_transfer.o
ms912x_transfer.c: In function 'ms912x_request_timeout':
ms912x_transfer.c:15:46: error: implicit declaration of function 'timer_container_of'; did you mean 'container_of'? [-Wimplicit-function-declaration]
   15 |         struct ms912x_usb_request *request = timer_container_of(request, t, timer);
      |                                              ^~~~~~~~~~~~~~~~~~
      |                                              container_of
ms912x_transfer.c:15:77: error: 'timer' undeclared (first use in this function); did you mean 'ktimerd'?
   15 |         struct ms912x_usb_request *request = timer_container_of(request, t, timer);
      |                                                                             ^~~~~
      |                                                                             ktimerd
ms912x_transfer.c:15:77: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [/usr/src/kernels/6.15.8-100.fc41.x86_64/scripts/Makefile.build:203: ms912x_transfer.o] Error 1
make[3]: *** [/usr/src/kernels/6.15.8-100.fc41.x86_64/Makefile:2043: .] Error 2
make[2]: *** [/usr/src/kernels/6.15.8-100.fc41.x86_64/Makefile:260: __sub-make] Error 2
make[2]: Leaving directory '/home/raphael/build/ms912x-k615'
make[1]: *** [Makefile:260: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/kernels/6.15.8-100.fc41.x86_64'
make: *** [Makefile:24: modules] Error 2

Hi,

The errors you’re seeing happen because the main branch now targets kernel 6.16, so it’s not compatible with 6.15. To compile for kernel 6.15, please use the branch kernel-6.15
instead.

This branch includes all necessary fixes for kernel 6.15, including timer_container_of. Compiling main for 6.15 will fail with errors like the ones you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants