mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* suspend vs. iommu: prevent suspend if we could not resume
@ 2008-05-27  9:51 Pavel Machek
  2008-06-02 11:03 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2008-05-27  9:51 UTC (permalink / raw)
  To: kernel list, Ingo Molnar, davej, Andi Kleen, H. Peter Anvin,
	Rafael J. Wysocki


iommu/gart support misses suspend/resume code, which can do bad stuff,
including memory corruption on resume. Prevent system suspend in case
we would be unable to resume.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Tested-by: Patrick <ragamuffin@datacomm.ch>

---
commit 7724af033ea084f0b037ae8a2032da5e40255088
tree 06de661a106ba83a96cab2ee0e76e3f3c44823ab
parent e9f4353b46ec2b05f73e1a84085c305de211bd3e
author Pavel <pavel@amd.ucw.cz> Sun, 25 May 2008 23:08:17 +0200
committer Pavel <pavel@amd.ucw.cz> Sun, 25 May 2008 23:08:17 +0200

 arch/x86/kernel/pci-gart_64.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 620ec3a..926af9c 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -26,6 +26,7 @@ #include <linux/bitops.h>
 #include <linux/kdebug.h>
 #include <linux/scatterlist.h>
 #include <linux/iommu-helper.h>
+#include <linux/sysdev.h>
 #include <asm/atomic.h>
 #include <asm/io.h>
 #include <asm/mtrr.h>
@@ -548,6 +549,28 @@ static __init unsigned read_aperture(str
 	return aper_base;
 }
 
+static int gart_resume(struct sys_device *dev)
+{
+	return 0;
+}
+
+static int gart_suspend(struct sys_device *dev, pm_message_t state)
+{
+	return -EINVAL;
+}
+
+static struct sysdev_class gart_sysdev_class = {
+	.name = "gart",
+	.suspend = gart_suspend,
+	.resume = gart_resume,
+
+};
+
+static struct sys_device device_gart = {
+	.id	= 0,
+	.cls	= &gart_sysdev_class,
+};
+
 /*
  * Private Northbridge GATT initialization in case we cannot use the
  * AGP driver for some reason.
@@ -558,7 +581,7 @@ static __init int init_k8_gatt(struct ag
 	unsigned aper_base, new_aper_base;
 	struct pci_dev *dev;
 	void *gatt;
-	int i;
+	int i, error;
 
 	printk(KERN_INFO "PCI-DMA: Disabling AGP.\n");
 	aper_size = aper_base = info->aper_size = 0;
@@ -595,6 +618,12 @@ static __init int init_k8_gatt(struct ag
 		dev = k8_northbridges[i];
 		enable_gart_translation(dev, __pa(gatt));
 	}
+	
+	error = sysdev_class_register(&gart_sysdev_class);
+	if (!error)
+		error = sysdev_register(&device_gart);
+	if (error)
+		panic("Could not register gart_sysdev -- would corrupt data on next suspend");
 	flush_gart();
 
 	printk(KERN_INFO "PCI-DMA: aperture base @ %x size %u KB\n",


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: suspend vs. iommu: prevent suspend if we could not resume
  2008-05-27  9:51 suspend vs. iommu: prevent suspend if we could not resume Pavel Machek
@ 2008-06-02 11:03 ` Ingo Molnar
  2008-06-02 19:13   ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2008-06-02 11:03 UTC (permalink / raw)
  To: Pavel Machek
  Cc: kernel list, davej, Andi Kleen, H. Peter Anvin, Rafael J. Wysocki


* Pavel Machek <pavel@suse.cz> wrote:

> iommu/gart support misses suspend/resume code, which can do bad stuff, 
> including memory corruption on resume. Prevent system suspend in case 
> we would be unable to resume.

applied to tip/x86/urgent and to tip/pci-for-jesse. Thanks Pavel,

	Ingo

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

* Re: suspend vs. iommu: prevent suspend if we could not resume
  2008-06-02 11:03 ` Ingo Molnar
@ 2008-06-02 19:13   ` Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2008-06-02 19:13 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: kernel list, davej, Andi Kleen, H. Peter Anvin, Rafael J. Wysocki

On Mon 2008-06-02 13:03:10, Ingo Molnar wrote:
> 
> * Pavel Machek <pavel@suse.cz> wrote:
> 
> > iommu/gart support misses suspend/resume code, which can do bad stuff, 
> > including memory corruption on resume. Prevent system suspend in case 
> > we would be unable to resume.
> 
> applied to tip/x86/urgent and to tip/pci-for-jesse. Thanks Pavel,

Thanks!

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

end of thread, other threads:[~2008-06-02 19:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-27  9:51 suspend vs. iommu: prevent suspend if we could not resume Pavel Machek
2008-06-02 11:03 ` Ingo Molnar
2008-06-02 19:13   ` Pavel Machek

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

all inboxes | Powered by JetHome®