Created attachment 30844 [details] [review] Patch for libpciaccess 0.10.9 I have a laptop with SIS video card, Xorg 7.5, Linux kernel 2.6.31.3. When I play video with XVideo output in any media player, X server uses up to 50% CPU depending on video resolution. I'm attaching a patch for libpciaccess 0.10.9 that solves this problem for me. I'm not sure that it won't introduce problems on other hardware, but at least it demonstrates the reason. pci_device_linux_sysfs_map_range (linux_sysfs.c) performs MTRRIOC_ADD_ENTRY ioctl only when PCI_DEV_MAP_FLAG_WRITE_COMBINE flag is not set. After making it perform that ioctl when the flag is set, everything becomes fine. I'm also attaching Xorg.0.log before and after applying the patch. These logs are from older version of xorg-server (1.6.5) but it does not matter – both problem and solution are just the same.
Created attachment 30845 [details] [review] Original Xorg.0.log (when video is slow)
Created attachment 30846 [details] Xorg.0.log with patched libpciaccess Before applying the patch: (II) SIS(0): Benchmarking system RAM to video RAM memory transfer methods: (--) SIS(0): Checked libc memcpy()... 20.0 MiB/s (--) SIS(0): Checked built-in-1 memcpy()... 20.0 MiB/s (--) SIS(0): Checked built-in-2 memcpy()... 16.6 MiB/s (--) SIS(0): Checked MMX memcpy()... 39.7 MiB/s (--) SIS(0): Checked MMX2 memcpy()... 39.9 MiB/s After applying the patch: (II) SIS(0): Benchmarking system RAM to video RAM memory transfer methods: (--) SIS(0): Checked libc memcpy()... 120.2 MiB/s (--) SIS(0): Checked built-in-1 memcpy()... 118.5 MiB/s (--) SIS(0): Checked built-in-2 memcpy()... 27.2 MiB/s (--) SIS(0): Checked MMX memcpy()... 123.3 MiB/s (--) SIS(0): Checked MMX2 memcpy()... 152.8 MiB/s
This appears to be a regression since ... commit 7282b53c47c2435c1ea23948272c9ccf1798178a Author: Jesse Barnes <jbarnes@hobbes.(none)> Date: Mon Jun 23 11:24:04 2008 -0700 Support write combine resource files in Linux sysfs Starting with version 2.6.26, Linux will support resourceN_wc files which export write combining mappings of PCI resource ranges, so support them if present in libpciaccess.
Turned out to be a kernel issue. http://lkml.indiana.edu/hypermail/linux/kernel/0910.1/00895.html Those resourceN_wc files in the kernel are broken. Write combining won't work on a CPU without PAT support (which is my case, Intel Centrino 1.7 GHz – hope it will serve me another 10 years). So there are two alternatives: revert commit 7282b53c47c2435c1ea23948272c9ccf1798178a mentioned above or do nothing hope that it will get fixed in the kernel.
Created attachment 31352 [details] [review] always set up mtrrs I had a similar patch awhile back actually, can you confirm that it also works for you? If so, I'll go ahead and push it. I think the kernel is fixed now but old kernels will still fail here.
Created attachment 31353 [details] [review] fixed patch Had a typo in the last one.
(In reply to comment #6) Yes, it's basically similar to my version, and works for me.
Recent kernels should fix this. If not please re-open.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.