public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: venkatesh.pallipadi@intel.com
To: mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, suresh.b.siddha@intel.com,
	kjwinchester@gmail.com,
	Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Subject: [patch 2/6] x86 PAT: consolidate old memtype new memtype check into a function
Date: Fri, 09 Jan 2009 16:13:10 -0800	[thread overview]
Message-ID: <20090110001404.585698000@intel.com> (raw)
In-Reply-To: 20090110001308.403550000@intel.com

[-- Attachment #1: cleanup_allowed_memtype_change.patch --]
[-- Type: text/plain, Size: 2448 bytes --]

Move the new memtype old memtype allowed check to header so that is can be
shared by other users. Subsequent patch uses this in pat.c in remap_pfn_range()
code path. No functionality change in this patch.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>

---
 arch/x86/include/asm/pgtable.h |   19 +++++++++++++++++++
 arch/x86/pci/i386.c            |   12 +-----------
 2 files changed, 20 insertions(+), 11 deletions(-)

Index: linux-2.6/arch/x86/include/asm/pgtable.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/pgtable.h	2009-01-07 15:00:34.000000000 -0800
+++ linux-2.6/arch/x86/include/asm/pgtable.h	2009-01-07 16:03:25.000000000 -0800
@@ -341,6 +341,25 @@ static inline pgprot_t pgprot_modify(pgp
 
 #define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
 
+static inline int is_new_memtype_allowed(unsigned long flags,
+						unsigned long new_flags)
+{
+	/*
+	 * Certain new memtypes are not allowed with certain
+	 * requested memtype:
+	 * - request is uncached, return cannot be write-back
+	 * - request is write-combine, return cannot be write-back
+	 */
+	if ((flags == _PAGE_CACHE_UC_MINUS &&
+	     new_flags == _PAGE_CACHE_WB) ||
+	    (flags == _PAGE_CACHE_WC &&
+	     new_flags == _PAGE_CACHE_WB)) {
+		return 0;
+	}
+
+	return 1;
+}
+
 #ifndef __ASSEMBLY__
 /* Indicate that x86 has its own track and untrack pfn vma functions */
 #define __HAVE_PFNMAP_TRACKING
Index: linux-2.6/arch/x86/pci/i386.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/i386.c	2009-01-07 15:00:34.000000000 -0800
+++ linux-2.6/arch/x86/pci/i386.c	2009-01-07 16:03:20.000000000 -0800
@@ -314,17 +314,7 @@ int pci_mmap_page_range(struct pci_dev *
 		return retval;
 
 	if (flags != new_flags) {
-		/*
-		 * Do not fallback to certain memory types with certain
-		 * requested type:
-		 * - request is uncached, return cannot be write-back
-		 * - request is uncached, return cannot be write-combine
-		 * - request is write-combine, return cannot be write-back
-		 */
-		if ((flags == _PAGE_CACHE_UC_MINUS &&
-		     (new_flags == _PAGE_CACHE_WB)) ||
-		    (flags == _PAGE_CACHE_WC &&
-		     new_flags == _PAGE_CACHE_WB)) {
+		if (!is_new_memtype_allowed(flags, new_flags)) {
 			free_memtype(addr, addr+len);
 			return -EINVAL;
 		}

-- 


  parent reply	other threads:[~2009-01-10  0:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-10  0:13 [patch 0/6] PAT fixes/cleanup following the pfnmap changes venkatesh.pallipadi
2009-01-10  0:13 ` [patch 1/6] x86 PAT: remove PFNMAP type on track_pfn_vma_new() error venkatesh.pallipadi
2009-01-10  0:13 ` venkatesh.pallipadi [this message]
2009-01-10  0:13 ` [patch 3/6] x86 PAT: change track_pfn_vma_new to take pgprot_t pointer param venkatesh.pallipadi
2009-01-10  0:13 ` [patch 4/6] x86 PAT: return compatible mapping to remap_pfn_range callers venkatesh.pallipadi
2009-01-10  0:13 ` [patch 5/6] x86 PAT: ioremap_wc should take resource_size_t parameter venkatesh.pallipadi
2009-01-10  0:13 ` [patch 6/6] x86 PAT: Remove CPA WARN_ON for zero pte venkatesh.pallipadi
2009-01-10 13:02 ` [patch 0/6] PAT fixes/cleanup following the pfnmap changes Kevin Winchester
2009-01-11  2:05   ` Ingo Molnar
2009-01-11 16:59     ` Kevin Winchester
2009-01-15  0:02     ` Kevin Winchester

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090110001404.585698000@intel.com \
    --to=venkatesh.pallipadi@intel.com \
    --cc=hpa@zytor.com \
    --cc=kjwinchester@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox