linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim <maximlevitsky@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	Jeff Chua <jeff.chua.linux@gmail.com>,
	Adrian Bunk <bunk@stusta.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	pavel@suse.cz, linux-pm@lists.osdl.org, gregkh@suse.de,
	linux-pci@atrey.karlin.mff.cuni.cz,
	Jens Axboe <jens.axboe@oracle.com>, Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, jgarzik@pobox.com,
	linux-ide@vger.kernel.org,
	"Michael S. Tsirkin" <mst@mellanox.co.il>
Subject: Re: [ PATCH] Add suspend/resume for HPET was: Re: [3/6] 2.6.21-rc4: known regressions
Date: Thu, 29 Mar 2007 07:47:28 +0200	[thread overview]
Message-ID: <200703290747.28929.maximlevitsky@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0703282203550.6730@woody.linux-foundation.org>

On Thursday 29 March 2007 07:08:58 Linus Torvalds wrote:
> 
> On Thu, 29 Mar 2007, Maxim wrote:
> >
> > 	I am sending here a patch that as was discussed here adds hpet to list of system devices
> > 	and adds suspend/resume hooks this way.
> > 	I tested it and it works fine.
> 
> Ok, it certainly looks better, but it *also* looks like it just assumes 
> the HPET is there. Which would work in testing _with_ a HPET, but would 
> likely break on hardware without one, no?
> 
> Shouldn't there be at least something like a
> 
> 	if (!is_hpet_capable())
> 		return 0;
> 
> at the top of that init routine? I'd also expect that you'd need to check 
> that "hpet_virt_address" is valid or something?
> 
> (Or, better yet, shouldn't we set "boot_hpet_disable" when we decide not 
> to use the HPET, and set hpet_virt_address to NULL?)

This is done here

out_nohpet:
	iounmap(hpet_virt_address);
	hpet_virt_address = NULL;
> 
> 		Linus
> 

Hi, 
	Of course, I forgot.

	I was planning to put sysdev code in hpet_enable()
	but it is not possible because this function is called too early.

	Thus I put sysdev initialization  in separate function but forgot to test for HPET

	Thanks a lot.

	Best regards
		Maxim Levitsky

---
This adds support of suspend/resume on i386 for HPET
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>

---
 arch/i386/kernel/hpet.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/arch/i386/kernel/hpet.c b/arch/i386/kernel/hpet.c
index 0fd9fba..7c67780 100644
--- a/arch/i386/kernel/hpet.c
+++ b/arch/i386/kernel/hpet.c
@@ -3,6 +3,8 @@
 #include <linux/errno.h>
 #include <linux/hpet.h>
 #include <linux/init.h>
+#include <linux/sysdev.h>
+#include <linux/pm.h>
 
 #include <asm/hpet.h>
 #include <asm/io.h>
@@ -310,6 +312,7 @@ int __init hpet_enable(void)
 out_nohpet:
 	iounmap(hpet_virt_address);
 	hpet_virt_address = NULL;
+	boot_hpet_disable = 1;
 	return 0;
 }
 
@@ -524,3 +527,68 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 #endif
+
+
+/*
+ * Suspend/resume part
+ */
+
+#ifdef CONFIG_PM
+
+static int hpet_suspend(struct sys_device *sys_device, pm_message_t state)
+{
+	unsigned long cfg = hpet_readl(HPET_CFG);
+
+	cfg &= ~(HPET_CFG_ENABLE|HPET_CFG_LEGACY);
+	hpet_writel(cfg, HPET_CFG);
+
+	return 0;
+}
+
+static int hpet_resume(struct sys_device *sys_device)
+{
+	unsigned int id;
+
+	hpet_start_counter();
+
+	id = hpet_readl(HPET_ID);
+
+	if (id & HPET_ID_LEGSUP)
+		hpet_enable_int();
+
+	return 0;
+}
+
+static struct sysdev_class hpet_class = {
+	set_kset_name("hpet"),
+	.suspend	= hpet_suspend,
+	.resume		= hpet_resume,
+};
+
+static struct sys_device hpet_device = {
+	.id		= 0,
+	.cls		= &hpet_class,
+};
+
+
+static __init int hpet_register_sysfs(void)
+{
+	int err;
+
+	if (!is_hpet_capable())
+		return 0;
+
+	err = sysdev_class_register(&hpet_class);
+
+	if (!err) {
+		sysdev_register(&hpet_device);
+		if (err)
+			sysdev_class_unregister(&hpet_class);
+	}
+
+	return err;
+}
+
+device_initcall(hpet_register_sysfs);
+
+#endif
-- 
1.4.4.2


  reply	other threads:[~2007-03-29  5:47 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.64.0703160925270.26106@woody.linux-foundation.org>
2007-03-18 18:49 ` [2/6] 2.6.21-rc4: known regressions Adrian Bunk
2007-03-18 18:49 ` [3/6] " Adrian Bunk
2007-03-26  1:25   ` Jeff Chua
2007-03-26  4:05     ` Adrian Bunk
2007-03-26  5:37       ` Jeff Chua
2007-03-26 16:26         ` Thomas Gleixner
2007-03-26 17:46           ` Jeff Chua
2007-03-28  7:04             ` Thomas Gleixner
2007-03-28 13:43               ` Maxim
2007-03-28 14:41                 ` Ingo Molnar
2007-03-28 15:01                   ` Maxim
2007-03-28 16:38                     ` Linus Torvalds
2007-03-28 19:38                       ` David Brownell
2007-03-28 20:19                         ` [linux-pm] " Maxim
2007-03-28 20:59                           ` David Brownell
2007-03-28 21:27                             ` Maxim
2007-03-29 22:33                               ` David Brownell
2007-03-29 23:29                                 ` Maxim Levitsky
2007-03-30  0:09                                   ` [linux-pm] " David Brownell
2007-03-30  0:48                                     ` Maxim Levitsky
2007-03-28 20:42                         ` Linus Torvalds
2007-03-28 21:17                           ` [linux-pm] " David Brownell
2007-03-28 22:26                           ` Maxim
2007-03-29  4:41                       ` [ PATCH] Add suspend/resume for HPET was: " Maxim
2007-03-29  5:08                         ` Linus Torvalds
2007-03-29  5:47                           ` Maxim [this message]
2007-03-29 13:20                             ` Sergei Shtylyov
2007-03-29 13:31                               ` Maxim
2007-03-29 13:46                                 ` [PATCH v2] Add suspend/resume for HPET Maxim Levitsky
2007-03-29 16:53                                   ` Linus Torvalds
2007-03-29 17:28                                     ` Maxim Levitsky
2007-03-29 17:51                                     ` Ingo Molnar
2007-03-29 20:46                                       ` Andi Kleen
2007-03-29 18:11                                   ` Jeff Chua
2007-03-31 15:51                                   ` Thomas Gleixner
2007-03-31 16:01                                     ` Jeff Chua
2007-03-31 16:09                                       ` Thomas Gleixner
2007-03-31 16:09                                     ` Linus Torvalds
2007-03-31 16:33                                       ` Thomas Gleixner
2007-03-31 16:41                                         ` Greg KH
2007-03-31 16:53                                         ` Linus Torvalds
2007-03-31 17:02                                           ` Ingo Molnar
2007-03-31 18:18                                             ` [linux-pm] " David Brownell
2007-03-31 19:32                                               ` David Brownell
2007-04-01  3:13                                                 ` Jeff Chua
2007-04-01  4:13                                                   ` David Brownell
2007-03-31 17:08                                           ` Greg KH
2007-03-31 17:55                                           ` [linux-pm] " David Brownell
2007-03-31 16:56                                     ` Maxim Levitsky
2007-03-31 17:09                                       ` Linus Torvalds
2007-03-31 17:17                                         ` Ingo Molnar
2007-03-31 17:58                                           ` Daniel Walker
2007-03-29 16:35                             ` [ PATCH] Add suspend/resume for HPET was: Re: [3/6] 2.6.21-rc4: known regressions Linus Torvalds
2007-03-29 16:51                               ` Maxim Levitsky
2007-03-29 17:22                                 ` Linus Torvalds
2007-03-29 17:47                                   ` [patch, v2] add suspend/resume for HPET Ingo Molnar
2007-03-28 18:04                 ` [3/6] 2.6.21-rc4: known regressions Michael S. Tsirkin
2007-03-28 18:32                   ` Ingo Molnar
2007-03-28 18:35                   ` Randy Dunlap
2007-03-29 14:24                   ` Jeff Chua
2007-03-23 18:48 ` [2/5] 2.6.21-rc4: known regressions (v2) Adrian Bunk
2007-03-26 10:01   ` Tejun Heo
2007-03-23 18:50 ` [3/5] " Adrian Bunk
2007-03-23 19:07   ` Maxim
2007-03-24 17:04   ` Thomas Meyer
2007-03-24 18:02     ` Eric W. Biederman
2007-03-23 18:50 ` [4/5] " Adrian Bunk
2007-03-24 11:25 ` 2.6.21-rc4: known regressions with patches (v2) Adrian Bunk
2007-03-26 12:37   ` Bob Tracy

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=200703290747.28929.maximlevitsky@gmail.com \
    --to=maximlevitsky@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bunk@stusta.de \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@suse.de \
    --cc=jeff.chua.linux@gmail.com \
    --cc=jens.axboe@oracle.com \
    --cc=jgarzik@pobox.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=linux-pm@lists.osdl.org \
    --cc=mingo@elte.hu \
    --cc=mst@mellanox.co.il \
    --cc=pavel@suse.cz \
    --cc=rjw@sisk.pl \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).