suspend-vs-iommu: prevent suspend if we could not resume

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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Pavel Machek and committed by Thomas Gleixner cd76374e be524fb9

+30 -1
+30 -1
arch/x86/kernel/pci-gart_64.c
··· 26 26 #include <linux/kdebug.h> 27 27 #include <linux/scatterlist.h> 28 28 #include <linux/iommu-helper.h> 29 + #include <linux/sysdev.h> 29 30 #include <asm/atomic.h> 30 31 #include <asm/io.h> 31 32 #include <asm/mtrr.h> ··· 549 548 return aper_base; 550 549 } 551 550 551 + static int gart_resume(struct sys_device *dev) 552 + { 553 + return 0; 554 + } 555 + 556 + static int gart_suspend(struct sys_device *dev, pm_message_t state) 557 + { 558 + return -EINVAL; 559 + } 560 + 561 + static struct sysdev_class gart_sysdev_class = { 562 + .name = "gart", 563 + .suspend = gart_suspend, 564 + .resume = gart_resume, 565 + 566 + }; 567 + 568 + static struct sys_device device_gart = { 569 + .id = 0, 570 + .cls = &gart_sysdev_class, 571 + }; 572 + 552 573 /* 553 574 * Private Northbridge GATT initialization in case we cannot use the 554 575 * AGP driver for some reason. ··· 581 558 unsigned aper_base, new_aper_base; 582 559 struct pci_dev *dev; 583 560 void *gatt; 584 - int i; 561 + int i, error; 585 562 586 563 printk(KERN_INFO "PCI-DMA: Disabling AGP.\n"); 587 564 aper_size = aper_base = info->aper_size = 0; ··· 629 606 630 607 pci_write_config_dword(dev, 0x90, ctl); 631 608 } 609 + 610 + error = sysdev_class_register(&gart_sysdev_class); 611 + if (!error) 612 + error = sysdev_register(&device_gart); 613 + if (error) 614 + panic("Could not register gart_sysdev -- would corrupt data on next suspend"); 632 615 flush_gart(); 633 616 634 617 printk(KERN_INFO "PCI-DMA: aperture base @ %x size %u KB\n",