Bug 24819 - [PATCH] Slow XVideo output on SIS660
Summary: [PATCH] Slow XVideo output on SIS660
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/pciaccess (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Jesse Barnes
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-30 11:30 UTC by Arseniy Lartsev
Modified: 2010-02-05 14:55 UTC (History)
6 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch for libpciaccess 0.10.9 (893 bytes, patch)
2009-10-30 11:30 UTC, Arseniy Lartsev
no flags Details | Splinter Review
Original Xorg.0.log (when video is slow) (26.05 KB, patch)
2009-10-30 11:32 UTC, Arseniy Lartsev
no flags Details | Splinter Review
Xorg.0.log with patched libpciaccess (26.87 KB, text/x-log)
2009-10-30 11:34 UTC, Arseniy Lartsev
no flags Details
always set up mtrrs (817 bytes, patch)
2009-11-20 13:24 UTC, Jesse Barnes
no flags Details | Splinter Review
fixed patch (748 bytes, patch)
2009-11-20 13:25 UTC, Jesse Barnes
no flags Details | Splinter Review

Description Arseniy Lartsev 2009-10-30 11:30:45 UTC
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.
Comment 1 Arseniy Lartsev 2009-10-30 11:32:16 UTC
Created attachment 30845 [details] [review]
Original Xorg.0.log (when video is slow)
Comment 2 Arseniy Lartsev 2009-10-30 11:34:28 UTC
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
Comment 3 Stefan Dirsch 2009-10-30 12:52:52 UTC
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.
Comment 4 Arseniy Lartsev 2009-10-31 12:30:44 UTC
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.
Comment 5 Jesse Barnes 2009-11-20 13:24:03 UTC
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.
Comment 6 Jesse Barnes 2009-11-20 13:25:10 UTC
Created attachment 31353 [details] [review]
fixed patch

Had a typo in the last one.
Comment 7 Arseniy Lartsev 2009-12-28 09:43:10 UTC
(In reply to comment #6)
Yes, it's basically similar to my version, and works for me.
Comment 8 Jesse Barnes 2010-02-05 14:55:31 UTC
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.