public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* mtrr/state.c unused?
@ 2010-02-03 20:24 Borislav Petkov
  2010-02-04  8:24 ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2010-02-03 20:24 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner; +Cc: linux-kernel, x86

It looks like <arch/x86/kernel/cpu/mtrr/state.c> is not used by
anything in the kernel.

Besides cleanups, the only relevant patch in the git history is:

commit 2ec1df4130c60d1eb49dc0fa0ed15858fede6b05
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Oct 11 11:16:28 2007 +0200

    i386: move kernel/cpu/mtrr


which adds it. Hmm...

A

git log -i --pickaxe-all -Sset_mtrr_prepare_save

for example, shows that

commit 9a6b344ea967efa0bb5ca4cb5405f840652b66c4
Author: Harvey Harrison <harvey.harrison@gmail.com>
Date:   Mon Feb 4 16:48:01 2008 +0100

    x86: remove long dead cyrix mtrr code

has removed the last callers of those helpers and they're now unused.
They should go if we don't need them anymore.

-- 
Regards/Gruss,
Boris.

--
Advanced Micro Devices, Inc.
Operating Systems Research Center

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

* Re: mtrr/state.c unused?
  2010-02-03 20:24 mtrr/state.c unused? Borislav Petkov
@ 2010-02-04  8:24 ` Ingo Molnar
  2010-02-04  8:51   ` Borislav Petkov
  2010-02-04 17:29   ` mtrr/state.c unused? Harvey Harrison
  0 siblings, 2 replies; 6+ messages in thread
From: Ingo Molnar @ 2010-02-04  8:24 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: H. Peter Anvin, Thomas Gleixner, linux-kernel, x86


* Borislav Petkov <bp@amd64.org> wrote:

> It looks like <arch/x86/kernel/cpu/mtrr/state.c> is not used by
> anything in the kernel.

Good catch - i dont see it used either. Mind sending a patch?

> 
> Besides cleanups, the only relevant patch in the git history is:
> 
> commit 2ec1df4130c60d1eb49dc0fa0ed15858fede6b05
> Author: Thomas Gleixner <tglx@linutronix.de>
> Date:   Thu Oct 11 11:16:28 2007 +0200
> 
>     i386: move kernel/cpu/mtrr
> 
> 
> which adds it. Hmm...

Might be a dead code artifact from the original unification.

Thanks,

	Ingo

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

* Re: mtrr/state.c unused?
  2010-02-04  8:24 ` Ingo Molnar
@ 2010-02-04  8:51   ` Borislav Petkov
  2010-02-04  9:57     ` [tip:x86/cleanups] x86, mtrr: Remove unused mtrr/state.c tip-bot for Borislav Petkov
  2010-02-04 17:29   ` mtrr/state.c unused? Harvey Harrison
  1 sibling, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2010-02-04  8:51 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Borislav Petkov, H. Peter Anvin, Thomas Gleixner, linux-kernel,
	x86

On Thu, Feb 04, 2010 at 09:24:28AM +0100, Ingo Molnar wrote:
> 
> * Borislav Petkov <bp@amd64.org> wrote:
> 
> > It looks like <arch/x86/kernel/cpu/mtrr/state.c> is not used by
> > anything in the kernel.
> 
> Good catch - i dont see it used either. Mind sending a patch?

Yep, here we go:

--
>From 059e59699f15c824c35a85774c377ffcae6bffdf Mon Sep 17 00:00:00 2001
From: Borislav Petkov <borislav.petkov@amd.com>
Date: Thu, 4 Feb 2010 09:36:03 +0100
Subject: [PATCH] x86, mtrr: Remove unused mtrr/state.c

The last reference to the helpers in <arch/x86/kernel/cpu/mtrr/state.c>
went away with 9a6b344ea967efa0bb5ca4cb5405f840652b66c4 leaving unused
code. Remove it.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 arch/x86/kernel/cpu/mtrr/Makefile |    2 +-
 arch/x86/kernel/cpu/mtrr/state.c  |   94 -------------------------------------
 2 files changed, 1 insertions(+), 95 deletions(-)
 delete mode 100644 arch/x86/kernel/cpu/mtrr/state.c

diff --git a/arch/x86/kernel/cpu/mtrr/Makefile b/arch/x86/kernel/cpu/mtrr/Makefile
index f4361b5..ad9e5ed 100644
--- a/arch/x86/kernel/cpu/mtrr/Makefile
+++ b/arch/x86/kernel/cpu/mtrr/Makefile
@@ -1,3 +1,3 @@
-obj-y		:= main.o if.o generic.o state.o cleanup.o
+obj-y		:= main.o if.o generic.o cleanup.o
 obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
 
diff --git a/arch/x86/kernel/cpu/mtrr/state.c b/arch/x86/kernel/cpu/mtrr/state.c
deleted file mode 100644
index dfc80b4..0000000
--- a/arch/x86/kernel/cpu/mtrr/state.c
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/mm.h>
-
-#include <asm/processor-cyrix.h>
-#include <asm/processor-flags.h>
-#include <asm/mtrr.h>
-#include <asm/msr.h>
-
-#include "mtrr.h"
-
-/* Put the processor into a state where MTRRs can be safely set */
-void set_mtrr_prepare_save(struct set_mtrr_context *ctxt)
-{
-	unsigned int cr0;
-
-	/* Disable interrupts locally */
-	local_irq_save(ctxt->flags);
-
-	if (use_intel() || is_cpu(CYRIX)) {
-
-		/* Save value of CR4 and clear Page Global Enable (bit 7) */
-		if (cpu_has_pge) {
-			ctxt->cr4val = read_cr4();
-			write_cr4(ctxt->cr4val & ~X86_CR4_PGE);
-		}
-
-		/*
-		 * Disable and flush caches. Note that wbinvd flushes the TLBs
-		 * as a side-effect
-		 */
-		cr0 = read_cr0() | X86_CR0_CD;
-		wbinvd();
-		write_cr0(cr0);
-		wbinvd();
-
-		if (use_intel()) {
-			/* Save MTRR state */
-			rdmsr(MSR_MTRRdefType, ctxt->deftype_lo, ctxt->deftype_hi);
-		} else {
-			/*
-			 * Cyrix ARRs -
-			 * everything else were excluded at the top
-			 */
-			ctxt->ccr3 = getCx86(CX86_CCR3);
-		}
-	}
-}
-
-void set_mtrr_cache_disable(struct set_mtrr_context *ctxt)
-{
-	if (use_intel()) {
-		/* Disable MTRRs, and set the default type to uncached */
-		mtrr_wrmsr(MSR_MTRRdefType, ctxt->deftype_lo & 0xf300UL,
-		      ctxt->deftype_hi);
-	} else {
-		if (is_cpu(CYRIX)) {
-			/* Cyrix ARRs - everything else were excluded at the top */
-			setCx86(CX86_CCR3, (ctxt->ccr3 & 0x0f) | 0x10);
-		}
-	}
-}
-
-/* Restore the processor after a set_mtrr_prepare */
-void set_mtrr_done(struct set_mtrr_context *ctxt)
-{
-	if (use_intel() || is_cpu(CYRIX)) {
-
-		/* Flush caches and TLBs */
-		wbinvd();
-
-		/* Restore MTRRdefType */
-		if (use_intel()) {
-			/* Intel (P6) standard MTRRs */
-			mtrr_wrmsr(MSR_MTRRdefType, ctxt->deftype_lo,
-				   ctxt->deftype_hi);
-		} else {
-			/*
-			 * Cyrix ARRs -
-			 * everything else was excluded at the top
-			 */
-			setCx86(CX86_CCR3, ctxt->ccr3);
-		}
-
-		/* Enable caches */
-		write_cr0(read_cr0() & 0xbfffffff);
-
-		/* Restore value of CR4 */
-		if (cpu_has_pge)
-			write_cr4(ctxt->cr4val);
-	}
-	/* Re-enable interrupts locally (if enabled previously) */
-	local_irq_restore(ctxt->flags);
-}
-- 
1.6.6

-- 
Regards/Gruss,
    Boris.

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

* [tip:x86/cleanups] x86, mtrr: Remove unused mtrr/state.c
  2010-02-04  8:51   ` Borislav Petkov
@ 2010-02-04  9:57     ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Borislav Petkov @ 2010-02-04  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, petkovbb, tglx, mingo, borislav.petkov

Commit-ID:  34d2819f20782feb60f9434470ecfb200875fd41
Gitweb:     http://git.kernel.org/tip/34d2819f20782feb60f9434470ecfb200875fd41
Author:     Borislav Petkov <petkovbb@googlemail.com>
AuthorDate: Thu, 4 Feb 2010 09:51:28 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 4 Feb 2010 10:01:38 +0100

x86, mtrr: Remove unused mtrr/state.c

The last reference to the helpers in
<arch/x86/kernel/cpu/mtrr/state.c> went away with
9a6b344ea967efa0bb5ca4cb5405f840652b66c4 leaving unused code.
Remove it.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
LKML-Reference: <20100204085128.GA513@liondog.tnic>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/cpu/mtrr/Makefile |    2 +-
 arch/x86/kernel/cpu/mtrr/state.c  |   94 -------------------------------------
 2 files changed, 1 insertions(+), 95 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/Makefile b/arch/x86/kernel/cpu/mtrr/Makefile
index f4361b5..ad9e5ed 100644
--- a/arch/x86/kernel/cpu/mtrr/Makefile
+++ b/arch/x86/kernel/cpu/mtrr/Makefile
@@ -1,3 +1,3 @@
-obj-y		:= main.o if.o generic.o state.o cleanup.o
+obj-y		:= main.o if.o generic.o cleanup.o
 obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
 
diff --git a/arch/x86/kernel/cpu/mtrr/state.c b/arch/x86/kernel/cpu/mtrr/state.c
deleted file mode 100644
index dfc80b4..0000000
--- a/arch/x86/kernel/cpu/mtrr/state.c
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/mm.h>
-
-#include <asm/processor-cyrix.h>
-#include <asm/processor-flags.h>
-#include <asm/mtrr.h>
-#include <asm/msr.h>
-
-#include "mtrr.h"
-
-/* Put the processor into a state where MTRRs can be safely set */
-void set_mtrr_prepare_save(struct set_mtrr_context *ctxt)
-{
-	unsigned int cr0;
-
-	/* Disable interrupts locally */
-	local_irq_save(ctxt->flags);
-
-	if (use_intel() || is_cpu(CYRIX)) {
-
-		/* Save value of CR4 and clear Page Global Enable (bit 7) */
-		if (cpu_has_pge) {
-			ctxt->cr4val = read_cr4();
-			write_cr4(ctxt->cr4val & ~X86_CR4_PGE);
-		}
-
-		/*
-		 * Disable and flush caches. Note that wbinvd flushes the TLBs
-		 * as a side-effect
-		 */
-		cr0 = read_cr0() | X86_CR0_CD;
-		wbinvd();
-		write_cr0(cr0);
-		wbinvd();
-
-		if (use_intel()) {
-			/* Save MTRR state */
-			rdmsr(MSR_MTRRdefType, ctxt->deftype_lo, ctxt->deftype_hi);
-		} else {
-			/*
-			 * Cyrix ARRs -
-			 * everything else were excluded at the top
-			 */
-			ctxt->ccr3 = getCx86(CX86_CCR3);
-		}
-	}
-}
-
-void set_mtrr_cache_disable(struct set_mtrr_context *ctxt)
-{
-	if (use_intel()) {
-		/* Disable MTRRs, and set the default type to uncached */
-		mtrr_wrmsr(MSR_MTRRdefType, ctxt->deftype_lo & 0xf300UL,
-		      ctxt->deftype_hi);
-	} else {
-		if (is_cpu(CYRIX)) {
-			/* Cyrix ARRs - everything else were excluded at the top */
-			setCx86(CX86_CCR3, (ctxt->ccr3 & 0x0f) | 0x10);
-		}
-	}
-}
-
-/* Restore the processor after a set_mtrr_prepare */
-void set_mtrr_done(struct set_mtrr_context *ctxt)
-{
-	if (use_intel() || is_cpu(CYRIX)) {
-
-		/* Flush caches and TLBs */
-		wbinvd();
-
-		/* Restore MTRRdefType */
-		if (use_intel()) {
-			/* Intel (P6) standard MTRRs */
-			mtrr_wrmsr(MSR_MTRRdefType, ctxt->deftype_lo,
-				   ctxt->deftype_hi);
-		} else {
-			/*
-			 * Cyrix ARRs -
-			 * everything else was excluded at the top
-			 */
-			setCx86(CX86_CCR3, ctxt->ccr3);
-		}
-
-		/* Enable caches */
-		write_cr0(read_cr0() & 0xbfffffff);
-
-		/* Restore value of CR4 */
-		if (cpu_has_pge)
-			write_cr4(ctxt->cr4val);
-	}
-	/* Re-enable interrupts locally (if enabled previously) */
-	local_irq_restore(ctxt->flags);
-}

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

* Re: mtrr/state.c unused?
  2010-02-04  8:24 ` Ingo Molnar
  2010-02-04  8:51   ` Borislav Petkov
@ 2010-02-04 17:29   ` Harvey Harrison
  2010-02-04 17:41     ` H. Peter Anvin
  1 sibling, 1 reply; 6+ messages in thread
From: Harvey Harrison @ 2010-02-04 17:29 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Borislav Petkov, H. Peter Anvin, Thomas Gleixner, linux-kernel,
	x86

On Thu, Feb 4, 2010 at 12:24 AM, Ingo Molnar <mingo@elte.hu> wrote:
>
> Might be a dead code artifact from the original unification.
>
> Thanks,
>
>        Ingo

I dimly recall there was another user at the time, not that I've
actually gone back and looked
however.

Cheers,

Harvey

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

* Re: mtrr/state.c unused?
  2010-02-04 17:29   ` mtrr/state.c unused? Harvey Harrison
@ 2010-02-04 17:41     ` H. Peter Anvin
  0 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2010-02-04 17:41 UTC (permalink / raw)
  To: Harvey Harrison
  Cc: Ingo Molnar, Borislav Petkov, Thomas Gleixner, linux-kernel, x86

On 02/04/2010 09:29 AM, Harvey Harrison wrote:
> 
> I dimly recall there was another user at the time, not that I've
> actually gone back and looked
> however.
> 

Doesn't really matter, there isn't one now.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

end of thread, other threads:[~2010-02-04 17:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03 20:24 mtrr/state.c unused? Borislav Petkov
2010-02-04  8:24 ` Ingo Molnar
2010-02-04  8:51   ` Borislav Petkov
2010-02-04  9:57     ` [tip:x86/cleanups] x86, mtrr: Remove unused mtrr/state.c tip-bot for Borislav Petkov
2010-02-04 17:29   ` mtrr/state.c unused? Harvey Harrison
2010-02-04 17:41     ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox