linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-22 14:41 Thomas Schlichter
  0 siblings, 0 replies; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-22 14:41 UTC (permalink / raw)
  To: Suresh Siddha
  Cc: Jan Beulich, Arjan van de Ven, dri-devel@lists.sourceforge.net,
	Robert Hancock, Henrique de Moraes Holschuh, H. Peter Anvin,
	jbarnes@virtuousgeek.org, Jeremy Fitzhardinge,
	linux-kernel@vger.kernel.org, Ingo Molnar, Ingo Molnar,
	Thomas Gleixner, Thomas Hellstrom, Tejun Heo,
	Pallipadi, Venkatesh, x86@kernel.org, Yinghai Lu

Suresh Siddha wrote:
> > > There is no need to go through num_var_ranges etc.
> > 
> > Well I have to remember wich file added which MTRR entries. Because I have
> > to remove them if the file is being closed. Therefore I need an array of size
> > "num_var_ranges" (or MTRR_MAX_VAR_RANGES which is the uper bound).
> 
> No. the private data  for example can keep track of a struct containing
> mtrr number and ref count etc. Exporting var_ranges and going through
> var ranges elements in an array is not clean, especially when you are
> populating only one element.

OK, I should have written that num_var_ranges is neccessary if I do copy a
algorithm for exactly the same purpose from an other place. And I don't see
anything better in having a dynamically growing list that makes the operation
of incrementing MTRR entries an O(n) operation where it now is a O(1) operation.

Additionally, the worst case memory requirement would be
2*sizeof(int)*num_var_ranges, where it is now 1*sizeof(int)*num_var_ranges.

So for me, this would be a step back, but if you want this, you should additionally
change arch/x86/kernel/cpu/mtrr/if.c from where I reused the algorithm.

Regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-22 14:27 Thomas Schlichter
  0 siblings, 0 replies; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-22 14:27 UTC (permalink / raw)
  To: H. Peter Anvin, Suresh Siddha
  Cc: JBeulich, arjan, dri-devel, hancockrwd, hmh, jbarnes,
	jeremy.fitzhardinge, linux-kernel, mingo, mingo, tglx, thellstrom,
	tj, venkatesh.pallipadi, x86, yinghai

Suresh Siddha wrote:
> On Thu, 2009-10-22 at 05:14 -0700, H. Peter Anvin wrote:
> > On 10/22/2009 09:08 PM, Thomas Schlichter wrote:
> > > And in that case (shared "struct file", one single release() call in the end) this
> > > implementation should be completely safe...
> > 
> > struct file is shared between forked processes.
> 
> That is correct. But I am referring to the ref-count getting incremented
> in Thomas's patch only in the pci_mmap_page_range() which will be called
> only during first mmap.
> 
> We need to keep track of the counts of later forks too.

When forked processes do mmap() PCI additional memory,
pci_mmap_page_range() will be called again and the corresponding (shared)
mtrr_usage_count wil be incremented. So we do keep track of later forks...

Yes, the MTRR reference count has nothing to do with the processes using this
memory, but if you want this, arch/x86/kernel/cpu/mtrr/if.c must be changed, too.

Regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-22 12:08 Thomas Schlichter
  2009-10-22 12:14 ` H. Peter Anvin
  2009-10-22 13:35 ` Suresh Siddha
  0 siblings, 2 replies; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-22 12:08 UTC (permalink / raw)
  To: Suresh Siddha
  Cc: Jan Beulich, Arjan van de Ven, dri-devel@lists.sourceforge.net,
	Robert Hancock, Henrique de Moraes Holschuh, H. Peter Anvin,
	jbarnes@virtuousgeek.org, Jeremy Fitzhardinge,
	linux-kernel@vger.kernel.org, Ingo Molnar, Ingo Molnar,
	Thomas Gleixner, Thomas Hellstrom, Tejun Heo,
	Pallipadi, Venkatesh, x86@kernel.org, Yinghai Lu

Suresh Siddha wrote:
> On Wed, 2009-10-21 at 13:01 -0700, Thomas Schlichter wrote:
> > OK, so I think the attached patches should do it. Hopefully I have addressed 
> > all your comments.
> 
> Thomas,
> 
> I have couple of issues with this patchset still. pci_mmap_page_range()
> doesn't get called for each fork(). So, we won't be ref counting the
> mtrr usage properly.

When forking, what happens with the "struct file"? If it is being copied, then the
processes share the same private data which would be freed during the first
release(). I think this would be a problem whereever file-private data are used.

So I think it must be shared between the forked processes and some reference
counting must exist. This reference counting must ensure that release() is only
called when all processes did close() their file.

And in that case (shared "struct file", one single release() call in the end) this
implementation should be completely safe...

> I need to think a bit more carefully on this. Can I get back to you
> early next week on this, as I am traveling and need to think through
> this?

Of course you can. But as I do this just in my spare time, I can only work on this
in the evenings...

> We already keep track of some of the PAT ref counting using
> track_pfn_vma_copy(). And we need to extend/use something similar here.
> 
> Even if we need to extend sysfs or pci vma ops, we need to increment and
> decrement the ref count of the mtrr register that gets used.

The MTRR register ref count is already incremented with each mtrr_add() or
mtrr_add_page() that has the "increment" parameter set to true. Which is the
case in my implementation.

> There is no need to go through num_var_ranges etc.

Well I have to remember wich file added which MTRR entries. Because I have
to remove them if the file is being closed. Therefore I need an array of size
"num_var_ranges" (or MTRR_MAX_VAR_RANGES which is the uper bound).

Btw. if there really is a problem in my reference counting code, it also exists in
the current code in:
  arch/x86/kernel/cpu/mtrr/if.c

My patch borrows its ref-counting parts from there...

Kind regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not  available
@ 2009-10-21 14:38 Thomas Schlichter
  2009-10-21 15:14 ` Jan Beulich
  0 siblings, 1 reply; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-21 14:38 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Arjan van de Ven, dri-devel, Robert Hancock,
	Henrique de Moraes Holschuh, H. Peter Anvin, jbarnes,
	Jeremy Fitzhardinge, linux-kernel, Ingo Molnar, Ingo Molnar,
	Suresh Siddha, Thomas Gleixner, Thomas Hellstrom, Tejun Heo,
	Venkatesh Pallipadi, x86, Yinghai Lu

Jan Beulich wrote:
> >Yes, I had that in the first place, but Jan suggested to extend it to also
> >handle non-aligned, non-power-of-two cases:
> >  http://marc.info/?l=linux-kernel&m=125541951529918&w=2 
> 
> I merely pointed out it wouldn't work for unaligned addresses or sizes
> passed in.

Oh, I'm sorry, I must have misinterpreted it...

> >So if it's OK for Jan, I'll reduce the functionality again and use mtrr_add()
> >instead. Btw. this simply means to drop mtrr_add_unaligned(), all the other
> >parts are still required for reference counting and a proper mtrr_del() on file
> >close.
> 
> I'm perfectly fine with just handling the aligned case, as long as the code
> checks that the alignment constraints are met.

Hmm, as far as I see mtrr_add() and mtrr_add_page() already check these
constraints. Do you want me to check them additionally? Or do you want to
completely fail the mmap() if these constraints are violated?

I'd let mmap() succeed even if the mtrr_add() fails...

Regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-21 13:45 Thomas Schlichter
  2009-10-21 14:11 ` Jan Beulich
  0 siblings, 1 reply; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-21 13:45 UTC (permalink / raw)
  To: Ingo Molnar, Suresh Siddha
  Cc: Jan Beulich, Arjan van de Ven, dri-devel, Robert Hancock,
	Henrique de Moraes Holschuh, H. Peter Anvin, jbarnes,
	Jeremy Fitzhardinge, linux-kernel, Ingo Molnar, Thomas Gleixner,
	Thomas Hellstrom, Tejun Heo, Venkatesh Pallipadi, x86, Yinghai Lu

Suresh Siddha wrote:
> I think we can simplify this  by just using mtrr_add_page() and avoid
> all the complexity that comes with mtrr_add_unaligned().
> 
> pci_mmap_range() should call one mtrr_add_page() if the base and size
> are nicely aligned. Almost all the cases, this is the usage sequence
> here anyway.

Ingo Molnar wrote:
> Can we eliminate mtrr_add_unaligned() as Suresh suggested, and still 
> make it work on your testbox?

Yes, I had that in the first place, but Jan suggested to extend it to also
handle non-aligned, non-power-of-two cases:
  http://marc.info/?l=linux-kernel&m=125541951529918&w=2

So if it's OK for Jan, I'll reduce the functionality again and use mtrr_add()
instead. Btw. this simply means to drop mtrr_add_unaligned(), all the other
parts are still required for reference counting and a proper mtrr_del() on file
close.

Kind regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-19 15:10 Thomas Schlichter
  2009-10-19 15:28 ` Ingo Molnar
  0 siblings, 1 reply; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-19 15:10 UTC (permalink / raw)
  To: Ingo Molnar, Suresh Siddha
  Cc: JBeulich, arjan, dri-devel, hancockrwd, hmh, hpa, jbarnes,
	jeremy.fitzhardinge, linux-kernel, mingo, tglx, thellstrom, tj,
	venkatesh.pallipadi, x86, yinghai

Ingo Molnar wrote:
> * Suresh Siddha <suresh.b.siddha@intel.com> wrote:
> > Can't we just force PAT option always and we probably don't care about 
> > ioremap_wc() on processors were PAT doesn't get enabled because of 
> > known errata.
> 
> We can make PAT configurability dependent on EMBEDDED-y - mind sending a 
> patch for that?

I think there already is such a patch in -tip:
http://git.kernel.org/?p=linux/kernel/git/tip/linux-2.6-tip.git;a=commitdiff;h=c03cb3149daed3e411657e3212d05ae27cf1a874

Kind regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-19 15:07 Thomas Schlichter
  0 siblings, 0 replies; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-19 15:07 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Jan Beulich, Arjan van de Ven, dri-devel, Robert Hancock,
	Henrique de Moraes Holschuh, H. Peter Anvin, jbarnes,
	Jeremy Fitzhardinge, linux-kernel, Ingo Molnar, Suresh Siddha,
	Thomas Gleixner, Thomas Hellstrom, Tejun Heo, Venkatesh Pallipadi,
	x86, Yinghai Lu

Konrad Rzeszutek Wilk wrote:
> I am not familiar with libpciaccess, but I was wondering why that library
> cannot realize it failed in its endeavour and use other means to accomplish
> its goals?

The thing is that the mmap() will succeed! Only the memory region will not be
set up as write combining when PAT is disabled. So userspace would have to
find out it PAT is enabled in kernel and accordingly set up MTRR entries. And
currently I don't know of a kernel interface that would tell userspace if PAT is
enabled.

Kind regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-19 14:59 Thomas Schlichter
  2009-10-19 15:31 ` Ingo Molnar
  0 siblings, 1 reply; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-19 14:59 UTC (permalink / raw)
  To: Jan Beulich, Suresh Siddha
  Cc: arjan, dri-devel, hancockrwd, hmh, hpa, jbarnes,
	jeremy.fitzhardinge, linux-kernel, mingo, tglx, thellstrom, tj,
	venkatesh.pallipadi, x86, yinghai

Suresh Siddha wrote:
> If we are going to make ioremap() and set_memory_wc() add mtrr's in
> non-pat case, then we need to delete the added mtrr(s) in the
> corresponding iounmap() and set_memory_wb() aswell.
> 
> hmm, this is becoming too complex. The way i915 and other graphics
> drivers are using set_memory_wc(), it is def a bad idea to start adding
> mtrr's behind the back for non-pat case.

Yes, maybe it's better to drop it for ioremap() and set_memory_wc(). But I'd like
to keep it for mmapping the PCI region. It should help all the people with
PAT-incapable CPUs and graphics chips without DRM support (for them there
simply is no driver that should set up the MTRR entries...).

> Can't we just force PAT option always and we probably don't care about
> ioremap_wc() on processors were PAT doesn't get enabled because of known
> errata.

I don't think this is a good idea, Robert Hancock wrote there may be millions of
such Laptops (Core Solo/Duo erratum AE7, Pentium M erratum Y31) :
  http://marc.info/?l=linux-kernel&m=125537136105246&w=2

> or Perhaps just try to add mtrr only for the pci mmap case like the 4th
> patch in this series..

I'd prefer this! ;-)

Kind regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not  available
@ 2009-10-19 14:47 Thomas Schlichter
  2009-10-20 19:54 ` Thomas Schlichter
  0 siblings, 1 reply; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-19 14:47 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Arjan van de Ven, dri-devel, Robert Hancock,
	Henrique de Moraes Holschuh, H. Peter Anvin, jbarnes,
	Jeremy Fitzhardinge, linux-kernel, Ingo Molnar, Suresh Siddha,
	Thomas Gleixner, Thomas Hellstrom, Tejun Heo, Venkatesh Pallipadi,
	x86, Yinghai Lu

Jan Beulich wrote:
> >>> Thomas Schlichter <thomas.schlichter@web.de> 17.10.09 21:48 >>>
> >What do you think about these patches?
> 
> Functionality-wise this looks fine to me; whether the core sysfs changes
> are acceptable I can't judge, though.

OK, who can? Or shall I simply ask get_maintainer.pl again?

> However, I would recommend folding the last two arguments of
> mtrr_add_unaligned(), i.e. use mtrr_usage != NULL as the increment
> argument passed to mtrr_add().

Good idea, I will do so this evening...

> And patches 5 and 6 would apparently not build right now, as they're
> failing to pass the new 5th argument to mtrr_add_unaligned().

*Grml* you are of course right. But I am not sure if these both patches
are a goot idea at all.

> Also, why do you add x86-specific code to drivers/pci-sysfs.c when the
> function called there (pci_mmap_page_range()) already is arch-specific?
> Moving your addition there would also allow covering the related
> (legacy?) procfs based functionality... pci_release() could also become
> arch-specific, with a fall-back definition to NULL.

You are right, I should do that...

> Additionally, I would suggest making those code portions depend on
> CONFIG_X86_MTRR rather than CONFIG_X86, so that you don't
> needlessly (try to) allocate the mtrr_usage vector.

Good idea, I will do so.

Thank you very much for your feedback, I'll hopefully come up with an
even better version tonight...

Kind regards,
  Thomas

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-13  7:34 Jan Beulich
  2009-10-13 21:29 ` Thomas Schlichter
  0 siblings, 1 reply; 60+ messages in thread
From: Jan Beulich @ 2009-10-13  7:34 UTC (permalink / raw)
  To: Thomas Schlichter
  Cc: Jeremy Fitzhardinge, Robert Hancock, Henrique de Moraes Holschuh,
	Suresh Siddha, Venkatesh Pallipadi, Tejun Heo, x86, Yinghai Lu,
	Thomas Gleixner, Arjan van de Ven, dri-devel, Ingo Molnar,
	linux-kernel, jbarnes, Thomas Hellstrom, H. Peter Anvin

>>> Thomas Schlichter <thomas.schlichter@web.de> 12.10.09 20:32 >>>
>@@ -268,11 +269,14 @@ EXPORT_SYMBOL(ioremap_nocache);
>  */
> void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
> {
>-	if (pat_enabled)
>-		return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
>-					__builtin_return_address(0));
>-	else
>-		return ioremap_nocache(phys_addr, size);
>+	if (!pat_enabled) {
>+		void __iomem *ret = ioremap_nocache(phys_addr, size);
>+		if (ret)
>+			mtrr_add(phys_addr, size, MTRR_TYPE_WRCOMB, false);

This won't work if phys_addr or size aren't page aligned, or if size isn't
a power of two.

>+		return ret;
>+	}
>+	return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
>+				__builtin_return_address(0));
> }
> EXPORT_SYMBOL(ioremap_wc);
> 
>@@ -1010,8 +1011,13 @@ int set_memory_wc(unsigned long addr, int numpages)
> {
> 	int ret;
> 
>-	if (!pat_enabled)
>-		return set_memory_uc(addr, numpages);
>+	if (!pat_enabled) {
>+		ret = set_memory_uc(addr, numpages);
>+		if (!ret)
>+			mtrr_add(__pa(addr), numpages * PAGE_SIZE,
>+				 MTRR_TYPE_WRCOMB, false);

Similarly, this requires numpages to be a power of two.

>+		return ret;
>+	}
> 
> 	ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE,
> 		_PAGE_CACHE_WC, NULL);

I think user mode code handles this by splitting the request and trying to
establish as many entries as possible (and those as big as possible).

Also, in all cases you pass 'false' for the 'increment' parameter, in order
to avoid having to tear down the established entries. While this may be
reasonable for kernel initiated mappings, I don't think that's acceptable
for such originating from user mode.

Jan


^ permalink raw reply	[flat|nested] 60+ messages in thread
* [RFC Patch] use MTRR for write combining if PAT is not available
@ 2009-10-10  1:22 Thomas Schlichter
  2009-10-10  4:24 ` Arjan van de Ven
  0 siblings, 1 reply; 60+ messages in thread
From: Thomas Schlichter @ 2009-10-10  1:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Hellstrom, Arjan van de Ven

[-- Attachment #1: Type: Text/Plain, Size: 1494 bytes --]

Hi,

I've found a problem with X.org not setting up MTRR for the framebuffer 
memory. After I investigated I think this is not a X.org problem, but a kernel 
issue.

X.org uses libpciaccess to map the framebuffer memory. This library opens 
/sys/bus/pci/devices/*/resource0_wc and mmaps the memory. Unfortunately, the 
kernel only enables write combining if PAT is enabled, if it is not, the 
memory is mmapped uncached. But Xorg (respectively libpciaccess) thinks it was 
successfully mapped with write combining enabled and thus does not 
additionally set up MTRR entries.

The corresponding libpciaccess code can be found here:
  http://cgit.freedesktop.org/xorg/lib/libpciaccess/tree/src/linux_sysfs.c#n501

If the kernel behavior is intentional and X.org should always set up MTRR 
entries, why should it use /sys/.../resource0_wc at all? I think there are 2 
possibilities to make the kernel behavior consistent:

 1. The mmap_wc should fail if PAT is not enabled.
    (libpciaccess will then map the framebuffer uncached and set up
     MTRR entries)
 2. Use MTRR to enable write combining if PAT is not available.

In an earlier thread about ioremap_wc, Arjan van de Ven wrote that option 2 is 
preferred over option 1:

    http://lkml.indiana.edu/hypermail/linux/kernel/0805.3/2925.html

So, I've created the attached patch implementing option 2. For me this solves 
the problem with the slow Video playback due to not correctly set up MTRR 
entries.

Kind regards,
Thomas Schlichter

[-- Attachment #2: 0001-Use-MTRR-for-write-combining-mmap-ioremap-if-PAT-is-.patch --]
[-- Type: text/x-patch, Size: 3346 bytes --]

From 19fb39061825a0110d1a4feb3f83dfa3f09fb738 Mon Sep 17 00:00:00 2001
From: Thomas Schlichter <thomas.schlichter@web.de>
Date: Thu, 8 Oct 2009 21:24:07 +0200
Subject: [PATCH] Use MTRR for write combining mmap/ioremap if PAT is not available

X.org uses libpciaccess which tries to mmap with write combining enabled via
/sys/bus/pci/devices/*/resource0_wc. Currently, when PAT is not enabled, we
fall back to uncached mmap. Then libpciaccess thinks it succeeded mapping
with write combining anabled and does not set up suited MTRR entries. ;-(

So when falling back to uncached mapping, we better try to set up MTRR
entries automatically. To match this modified PCI mmap behavior, also
ioremap_wc and set_memory_wc are adjusted.

Signed-off-by: Thomas Schlichter <thomas.schlichter@web.de>
---
 arch/x86/mm/ioremap.c  |   14 +++++++++-----
 arch/x86/mm/pageattr.c |   10 ++++++++--
 arch/x86/pci/i386.c    |    6 ++++++
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 334e63c..1a73bbc 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -21,6 +21,7 @@
 #include <asm/tlbflush.h>
 #include <asm/pgalloc.h>
 #include <asm/pat.h>
+#include <asm/mtrr.h>
 
 #include "physaddr.h"
 
@@ -268,11 +269,14 @@ EXPORT_SYMBOL(ioremap_nocache);
  */
 void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
 {
-	if (pat_enabled)
-		return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
-					__builtin_return_address(0));
-	else
-		return ioremap_nocache(phys_addr, size);
+	if (!pat_enabled) {
+		void __iomem *ret = ioremap_nocache(phys_addr, size);
+		if (ret)
+			mtrr_add(phys_addr, size, MTRR_TYPE_WRCOMB, false);
+		return ret;
+	}
+	return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
+				__builtin_return_address(0));
 }
 EXPORT_SYMBOL(ioremap_wc);
 
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index dd38bfb..7f3a85b 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -23,6 +23,7 @@
 #include <asm/pgalloc.h>
 #include <asm/proto.h>
 #include <asm/pat.h>
+#include <asm/mtrr.h>
 
 /*
  * The current flushing context - we pass it instead of 5 arguments:
@@ -1010,8 +1011,13 @@ int set_memory_wc(unsigned long addr, int numpages)
 {
 	int ret;
 
-	if (!pat_enabled)
-		return set_memory_uc(addr, numpages);
+	if (!pat_enabled) {
+		ret = set_memory_uc(addr, numpages);
+		if (!ret)
+			mtrr_add(__pa(addr), numpages * PAGE_SIZE,
+				 MTRR_TYPE_WRCOMB, false);
+		return ret;
+	}
 
 	ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE,
 		_PAGE_CACHE_WC, NULL);
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index b22d13b..06cf678 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -33,6 +33,7 @@
 #include <linux/bootmem.h>
 
 #include <asm/pat.h>
+#include <asm/mtrr.h>
 #include <asm/e820.h>
 #include <asm/pci_x86.h>
 #include <asm/io_apic.h>
@@ -301,5 +302,10 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 
 	vma->vm_ops = &pci_mmap_ops;
 
+	if (!pat_enabled && write_combine)
+		mtrr_add_page(vma->vm_pgoff,
+			     (vma->vm_end - vma->vm_start) >> PAGE_SHIFT,
+			      MTRR_TYPE_WRCOMB, false);
+
 	return 0;
 }
-- 
1.6.4.4


^ permalink raw reply related	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2009-10-23 14:38 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200910122032.52168.thomas.schlichter@web.de>
2009-10-12 19:16 ` [RFC Patch] use MTRR for write combining if PAT is not available Thomas Hellstrom
2009-10-12 19:45   ` Thomas Schlichter
     [not found]     ` <1255378684.2063.5.camel@gaiman.anholt.net>
2009-10-13 21:05       ` Thomas Schlichter
2009-10-22 14:41 Thomas Schlichter
  -- strict thread matches above, loose matches on Subject: below --
2009-10-22 14:27 Thomas Schlichter
2009-10-22 12:08 Thomas Schlichter
2009-10-22 12:14 ` H. Peter Anvin
2009-10-22 13:26   ` Suresh Siddha
2009-10-22 13:35 ` Suresh Siddha
2009-10-21 14:38 Thomas Schlichter
2009-10-21 15:14 ` Jan Beulich
2009-10-21 13:45 Thomas Schlichter
2009-10-21 14:11 ` Jan Beulich
2009-10-21 17:35   ` Ingo Molnar
2009-10-21 20:01     ` Thomas Schlichter
2009-10-22  9:53       ` Suresh Siddha
2009-10-22 15:34         ` Eric Anholt
2009-10-22 21:47           ` Suresh Siddha
2009-10-22 23:10             ` Jesse Barnes
2009-10-23  0:11               ` Suresh Siddha
2009-10-23  1:53                 ` Eric Anholt
2009-10-23  4:31                   ` Jesse Barnes
2009-10-23  4:58                     ` Suresh Siddha
2009-10-23  7:24                       ` Thomas Schlichter
2009-10-23 14:24                         ` Suresh Siddha
2009-10-23 14:37                           ` Ingo Molnar
2009-10-23  4:33                   ` Suresh Siddha
2009-10-19 15:10 Thomas Schlichter
2009-10-19 15:28 ` Ingo Molnar
2009-10-19 15:07 Thomas Schlichter
2009-10-19 14:59 Thomas Schlichter
2009-10-19 15:31 ` Ingo Molnar
2009-10-19 21:49   ` Suresh Siddha
2009-10-20 20:35   ` Thomas Schlichter
2009-10-20 21:59     ` Suresh Siddha
2009-10-21 11:52       ` Ingo Molnar
2009-10-19 14:47 Thomas Schlichter
2009-10-20 19:54 ` Thomas Schlichter
2009-10-21 11:57   ` Ingo Molnar
2009-10-13  7:34 Jan Beulich
2009-10-13 21:29 ` Thomas Schlichter
2009-10-14  8:13   ` Jan Beulich
2009-10-14 19:14     ` Thomas Schlichter
2009-10-15  7:48       ` Jan Beulich
2009-10-17 19:48         ` Thomas Schlichter
2009-10-19  9:16           ` Jan Beulich
2009-10-19 13:44             ` Suresh Siddha
2009-10-19 13:54               ` Ingo Molnar
2009-10-19 13:36           ` Konrad Rzeszutek Wilk
2009-10-10  1:22 Thomas Schlichter
2009-10-10  4:24 ` Arjan van de Ven
2009-10-10  8:31   ` Thomas Schlichter
2009-10-10 15:45     ` Arjan van de Ven
2009-10-10 17:50       ` Roland Dreier
2009-10-11  7:40       ` Ingo Molnar
2009-10-11  9:56       ` Thomas Schlichter
2009-10-11 18:51   ` Henrique de Moraes Holschuh
2009-10-11 18:54     ` Arjan van de Ven
2009-10-11 20:19       ` Henrique de Moraes Holschuh
2009-10-12 18:09         ` Robert Hancock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).