public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shérab <Sebastien.Hinderer@ens-lyon.org>
To: Valdis.Kletnieks@vt.edu
Cc: Samuel Thibault <Samuel.Thibault@ens-lyon.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Len Brown <lenb@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Andres Salomon <dilinger@queued.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: EuroBraille/Iris power off
Date: Sat, 13 Nov 2010 20:22:56 +0100	[thread overview]
Message-ID: <20101113192256.GB5030@pema> (raw)
In-Reply-To: <20101010162236.GA3320@pema>

[-- Attachment #1: Type: text/plain, Size: 7395 bytes --]

Dear all,

I am resending this patch which got no criticisms and has stillnot been
integrated so far.

Many thanks in advance for examining it.

Cheers,

Shérab.

Shérab (2010/10/10 18:22 +0200):
> Hi,
> 
> I'm resending and would appreciate it very much if someone good have a
> lookto it.
> Thanks,
> Shérab.
> 
> Shérab (2010/09/26 19:54 +0200):
> > Hello,
> > 
> > Shérab (2010/09/20 10:22 +0200):
> > > Dear all,
> > > 
> > > Valdis.Kletnieks@vt.edu (2010/09/13 21:45 -0400):
> > > > On Mon, 13 Sep 2010 17:22:49 +0200, Samuel Thibault said:
> > > > 
> > > > > Again, I'm not sure we really should try hard to make it automatically
> > > > > detected (and thus always enabled).  Having to pass a kernel parameter
> > > > > to enable the functionality is completely fine, since installing Linux
> > > > > on this device requires quite some tinkering already.
> > > > 
> > > > I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
> > > > on the command line or as a module parameter, and bailed immediately if it
> > > > wasn't passed, then doing the inb() and testing it should be safe
> > > > enough. [...]
> > > 
> > > Please find below a revised version of the module that does what has
> > > been asked.
> > 
> > The previous patch had a few style problem and the moduleparam.h header
> > was not included whereas it should have been.
> > The version below passes ./script/checkpatch and the missing header has
> > been included, so the patch should be correct now.
> > Moreover the patch has been updated to apply on top of current master.
> > 
> > Shérab.
> > 
> > From 2af50581bb591cd25ac59a7cf16902ea50f766db Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
> > Date: Sat, 25 Sep 2010 06:06:57 +0200
> > Subject: [PATCH] Eurobraille/Iris power off.
> > MIME-Version: 1.0
> > Content-Type: text/plain; charset=UTF-8
> > Content-Transfer-Encoding: 8bit
> > Content-Type: text/plain; charset="utf-8"
> > 
> > The Iris machines from Eurobraille do not have APM or ACPI support
> > to shut themselves down properly.  A special I/O sequence is
> > needed to do so.  This modle runs this I/O sequence at
> > kernel shutdown when its force parameter is set to 1.
> > Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
> > ---
> >  arch/x86/Kconfig         |   13 +++++++
> >  arch/x86/kernel/Makefile |    1 +
> >  arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 104 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/x86/kernel/iris.c
> > 
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index cea0cd9..7c8e261 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -493,6 +493,19 @@ config X86_ES7000
> >  	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
> >  	  supposed to run on an IA32-based Unisys ES7000 system.
> >  
> > +config X86_32_IRIS
> > +	tristate "Eurobraille/Iris poweroff module"
> > +	depends on X86_32
> > +	---help---
> > +	  The Iris machines from EuroBraille do not have APM or ACPI support
> > +	  to shut themselves down properly.  A special I/O sequence is
> > +	  needed to do so, which is what this module does at
> > +	  kernel shutdown.
> > +
> > +	  This is only for Iris machines from EuroBraille.
> > +
> > +	  If unused, say N.
> > +
> >  config SCHED_OMIT_FRAME_POINTER
> >  	def_bool y
> >  	prompt "Single-depth WCHAN output"
> > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
> > index 0925676..98dd1c8 100644
> > --- a/arch/x86/kernel/Makefile
> > +++ b/arch/x86/kernel/Makefile
> > @@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
> >  obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
> >  
> >  obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
> > +obj-$(CONFIG_X86_32_IRIS)		+= iris.o
> >  
> >  ###
> >  # 64 bit specific files
> > diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
> > new file mode 100644
> > index 0000000..c6d8137
> > --- /dev/null
> > +++ b/arch/x86/kernel/iris.c
> > @@ -0,0 +1,90 @@
> > +/*
> > + * Eurobraille/Iris power off support.
> > + *
> > + * Eurobraille's Iris machine is a PC with no APM or ACPI support.
> > + * It is shutdown by a special I/O sequence which this module provides.
> > + *
> > + *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
> > + *
> > + * This program is free software ; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation ; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY ; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with the program ; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + */
> > +
> > +#include <linux/module.h>
> > +#include <linux/moduleparam.h>
> > +#include <linux/kernel.h>
> > +#include <linux/errno.h>
> > +#include <linux/init.h>
> > +#include <linux/pm.h>
> > +#include <linux/delay.h>
> > +#include <asm/io.h>
> > +
> > +#define IRIS_GIO_BASE 0x340
> > +#define IRIS_GIO_INPUT IRIS_GIO_BASE
> > +#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
> > +#define IRIS_GIO_PULSE 0x80 /* First byte to send */
> > +#define IRIS_GIO_REST 0x0 /* Second byte to send */
> > +#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
> > +
> > +MODULE_LICENSE("GPL");
> > +MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
> > +MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
> > +MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
> > +
> > +static int force;
> > +module_param(force, bool, 0);
> > +MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
> > +
> > +static void (*old_pm_power_off)(void);
> > +
> > +static void iris_power_off(void)
> > +{
> > +	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
> > +	msleep(850);
> > +	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
> > +}
> > +
> > +/*
> > + * Before installing the power_off handler, try to make sure the OS is
> > + * running on an Iris.  Since Iris does not support DMI, this is done
> > + * by reading its input port and seeing whether the read value is
> > + * meaningful.
> > + */
> > +static int iris_init(void)
> > +{
> > +	unsigned char status;
> > +	if (force != 1) {
> > +		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
> > +		return -ENODEV;
> > +	}
> > +	status = inb(IRIS_GIO_INPUT);
> > +	if (status == IRIS_GIO_NODEV) {
> > +		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
> > +		return -ENODEV;
> > +	}
> > +	old_pm_power_off = pm_power_off;
> > +	pm_power_off = &iris_power_off;
> > +	printk(KERN_INFO "Iris power_off handler installed.\n");
> > +	return 0;
> > +}
> > +
> > +static void iris_exit(void)
> > +{
> > +	pm_power_off = old_pm_power_off;
> > +	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
> > +}
> > +
> > +module_init(iris_init);
> > +module_exit(iris_exit);
> > +

[-- Attachment #2: 0001-Eurobraille-Iris-power-off.patch --]
[-- Type: text/x-diff, Size: 5197 bytes --]

>From 2af50581bb591cd25ac59a7cf16902ea50f766db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
Date: Sat, 25 Sep 2010 06:06:57 +0200
Subject: [PATCH] Eurobraille/Iris power off.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

The Iris machines from Eurobraille do not have APM or ACPI support
to shut themselves down properly.  A special I/O sequence is
needed to do so.  This modle runs this I/O sequence at
kernel shutdown when its force parameter is set to 1.
Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
---
 arch/x86/Kconfig         |   13 +++++++
 arch/x86/kernel/Makefile |    1 +
 arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/kernel/iris.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cea0cd9..7c8e261 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..c6d8137
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,90 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * This program is free software ; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation ; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY ; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_INPUT IRIS_GIO_BASE
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static int force;
+module_param(force, bool, 0);
+MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+/*
+ * Before installing the power_off handler, try to make sure the OS is
+ * running on an Iris.  Since Iris does not support DMI, this is done
+ * by reading its input port and seeing whether the read value is
+ * meaningful.
+ */
+static int iris_init(void)
+{
+	unsigned char status;
+	if (force != 1) {
+		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
+		return -ENODEV;
+	}
+	status = inb(IRIS_GIO_INPUT);
+	if (status == IRIS_GIO_NODEV) {
+		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+		return -ENODEV;
+	}
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+
-- 
1.7.1


  reply	other threads:[~2010-11-13 19:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-25  9:49 [PATCH] x86: EuroBraille/Iris power off Shérab
2010-08-25 16:12 ` Andreas Mohr
2010-08-25 21:12   ` Sebastien Hinderer
2010-08-25 21:19     ` H. Peter Anvin
2010-08-25 22:50       ` Samuel Thibault
2010-08-26  0:06         ` H. Peter Anvin
2010-08-26  0:19           ` Samuel Thibault
2010-08-26  6:45           ` Sebastien Hinderer
2010-08-26  6:55             ` H. Peter Anvin
2010-08-26  7:09               ` Andreas Mohr
2010-08-26  9:29               ` Sebastien Hinderer
2010-08-26 18:11 ` Len Brown
2010-08-26 21:08   ` Shérab
2010-08-26 21:16     ` H. Peter Anvin
2010-08-27 17:35       ` Shérab
2010-08-27 18:49         ` H. Peter Anvin
2010-08-27 22:27       ` Shérab
2010-08-29 20:59       ` Shérab
2010-09-13 10:07         ` Shérab
2010-09-13 15:10           ` Valdis.Kletnieks
2010-09-13 15:22             ` Samuel Thibault
2010-09-13 16:06               ` H. Peter Anvin
2010-09-13 16:12                 ` Samuel Thibault
2010-09-14  1:45               ` Valdis.Kletnieks
2010-09-14  5:16                 ` Shérab
2010-09-20  8:22                 ` Shérab
2010-09-26 17:54                   ` Shérab
2010-10-10 16:22                     ` Shérab
2010-11-13 19:22                       ` Shérab [this message]
2010-09-13 15:25             ` Shérab
2010-09-13 15:48               ` H. Peter Anvin

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=20101113192256.GB5030@pema \
    --to=sebastien.hinderer@ens-lyon.org \
    --cc=Samuel.Thibault@ens-lyon.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=dilinger@queued.net \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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