mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Fenghua Yu" <fenghua.yu@intel.com>
To: "Ingo Molnar" <mingo@elte.hu>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"H Peter Anvin" <hpa@zytor.com>,
	"Tony Luck" <tony.luck@intel.com>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
	"Fenghua Yu" <fenghua.yu@intel.com>
Subject: [PATCH 1/2] x86/kernel/cpu/mcheck/mce-inject.c: Add mce inject driver exit
Date: Tue,  3 May 2011 15:34:39 -0700	[thread overview]
Message-ID: <1304462080-3358-2-git-send-email-fenghua.yu@intel.com> (raw)
In-Reply-To: <1304462080-3358-1-git-send-email-fenghua.yu@intel.com>

From: Fenghua Yu <fenghua.yu@intel.com>

Gracefully remove mce_inject driver. This avoids rebooting machine if one wants
to release the driver. It makes the driver more useful for debugging mce issues
or debugging the driver itself. And the mce code is more clean and reasonable.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Tony Luck <tony.luck@intel.com>
---
 arch/x86/kernel/cpu/mcheck/mce-inject.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c
index 0ed633c..9966a61 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
@@ -179,7 +179,7 @@ static void raise_mce(struct mce *m)
 }
 
 /* Error injection interface */
-static ssize_t mce_write(struct file *filp, const char __user *ubuf,
+static ssize_t mce_write_inject(struct file *filp, const char __user *ubuf,
 			 size_t usize, loff_t *off)
 {
 	struct mce m;
@@ -210,17 +210,25 @@ static ssize_t mce_write(struct file *filp, const char __user *ubuf,
 	return usize;
 }
 
-static int inject_init(void)
+static int __init inject_init(void)
 {
 	if (!alloc_cpumask_var(&mce_inject_cpumask, GFP_KERNEL))
 		return -ENOMEM;
 	printk(KERN_INFO "Machine check injector initialized\n");
-	mce_chrdev_ops.write = mce_write;
+	mce_write_register(mce_write_inject);
 	register_die_notifier(&mce_raise_nb);
 	return 0;
 }
 
+static void __exit inject_exit(void)
+{
+	mce_write_unregister();
+	unregister_die_notifier(&mce_raise_nb);
+	free_cpumask_var(mce_inject_cpumask);
+}
+
 module_init(inject_init);
+module_exit(inject_exit);
 /*
  * Cannot tolerate unloading currently because we cannot
  * guarantee all openers of mce_chrdev will get a reference to us.
-- 
1.7.2


  reply	other threads:[~2011-05-03 22:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-03 22:34 [PATCH 0/2] Enable " Fenghua Yu
2011-05-03 22:34 ` Fenghua Yu [this message]
2011-05-03 22:34 ` [PATCH 2/2] x86/kernel/cpu/mcheck/mce.c: Interfaces for " Fenghua Yu

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=1304462080-3358-2-git-send-email-fenghua.yu@intel.com \
    --to=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    /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

Powered by JetHome