[Hardy] SRU request for LP#257293

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Hardy] SRU request for LP#257293

Stefan Bader-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

https://bugs.launchpad.net/ubuntu/hardy/+source/linux/+bug/257293

Note: The fix to this went into v2.6.27-rc1 upstream, so Intrepid should get it
automatically.

SRU Justification:

Impact: The GART code is missing suspend resume support which means, certain
setup steps will not be performed after resume which can cause memory
corruption in the worst case.

Fix: The fix is done in two steps (following upstream): first this add suspend
and resume callbacks and then it adds the necessary code to set up the
registers after a suspend.

Testcase: See bug report.
- --

When all other means of communication fail, try words!


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIrXQfP+TjRTJVqvQRAsfqAKCNlLommCE4Tpm9SJscfBJFXsjjiwCfS/fN
yeGsriwd9l9Ej2dMwuYuFUA=
=EscD
-----END PGP SIGNATURE-----

From 0066865ca8746df4934effe245c8e89b4c2d0b03 Mon Sep 17 00:00:00 2001
From: Stefan Bader <[hidden email]>
Date: Mon, 18 Aug 2008 12:49:47 -0400
Subject: [PATCH] suspend-vs-iommu: prevent suspend if we could not resume

Bug: #257293

commit cd76374e9de4501acc74f833dc6cb5e7a5dca115
Author: Pavel Machek <[hidden email]>
Date:   Thu May 29 00:30:21 2008 -0700

    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 <[hidden email]>
    Tested-by: Patrick <[hidden email]>
    Signed-off-by: Andrew Morton <[hidden email]>
    Signed-off-by: Ingo Molnar <[hidden email]>

Signed-off-by: Stefan Bader <[hidden email]>
---
 arch/x86/kernel/pci-gart_64.c |   30 ++++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 06bcba5..c5e46d2 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -25,6 +25,7 @@
 #include <linux/bitops.h>
 #include <linux/kdebug.h>
 #include <linux/scatterlist.h>
+#include <linux/sysdev.h>
 #include <asm/atomic.h>
 #include <asm/io.h>
 #include <asm/mtrr.h>
@@ -492,6 +493,26 @@ static __init unsigned read_aperture(struct pci_dev *dev, u32 *size)
  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 = {
+ .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.  
@@ -502,7 +524,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
  void *gatt;
  unsigned aper_base, new_aper_base;
  unsigned aper_size, gatt_size, new_aper_size;
- int i;
+ int i, error;
 
  printk(KERN_INFO "PCI-DMA: Disabling AGP.\n");
  aper_size = aper_base = info->aper_size = 0;
@@ -551,6 +573,13 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
 
  pci_write_config_dword(dev, 0x90, ctl);
  }
+
+ 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("PCI-DMA: aperture base @ %x size %u KB\n",aper_base, aper_size>>10);
--
1.5.4.3


From 7b1e91930a1866ecd6d2176e5622fc74b25fbe3c Mon Sep 17 00:00:00 2001
From: Stefan Bader <[hidden email]>
Date: Mon, 18 Aug 2008 13:29:41 -0400
Subject: [PATCH] x86, gart: add resume handling

Bug: #257293
Author: Rafael J. Wysocki <[hidden email]>
Date:   Tue Jun 10 00:10:48 2008 +0200

Picked from upstream 6703f6d10dcd3316e03641a5ecaa6c8a04374d98

If GART IOMMU is used on an AMD64 system, the northbridge registers
related to it should be restored during resume so that memory is not
corrupted.  Make gart_resume() handle that as appropriate.

Ref. http://lkml.org/lkml/2008/5/25/96 and the following thread.

Signed-off-by: Rafael J. Wysocki <[hidden email]>
Signed-off-by: Ingo Molnar <[hidden email]>
Signed-off-by: Stefan Bader <[hidden email]>
---
 arch/x86/kernel/aperture_64.c |    2 +
 arch/x86/kernel/pci-gart_64.c |   75 +++++++++++++++++++++++++++++++---------
 include/asm-x86/gart.h        |    1 +
 3 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index e469a1d..c23333f 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -299,4 +299,6 @@ void __init gart_iommu_hole_init(void)
  write_pci_config(0, num, 3, 0x90, aper_order<<1);
  write_pci_config(0, num, 3, 0x94, aper_alloc>>25);
  }
+
+ set_up_gart_resume(aper_order, aper_alloc);
 }
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index c5e46d2..9d7ed16 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -493,14 +493,71 @@ static __init unsigned read_aperture(struct pci_dev *dev, u32 *size)
  return aper_base;
 }
 
+static void enable_gart_translations(void)
+{
+ int i;
+
+ for (i = 0; i < num_k8_northbridges; i++) {
+ struct pci_dev *dev = k8_northbridges[i];
+ u32 ctl;
+ u32 gatt_reg;
+
+ gatt_reg = __pa(agp_gatt_table) >> 12;
+ gatt_reg <<= 4;
+ pci_write_config_dword(dev, 0x98, gatt_reg);
+ pci_read_config_dword(dev, 0x90, &ctl);
+
+ ctl |= 1;
+ ctl &= ~((1<<4) | (1<<5));
+
+ pci_write_config_dword(dev, 0x90, ctl);
+ }
+}
+
+/*
+ * If fix_up_north_bridges is set, the north bridges have to be fixed up on
+ * resume in the same way as they are handled in gart_iommu_hole_init().
+ */
+static bool fix_up_north_bridges;
+static u32 aperture_order;
+static u32 aperture_alloc;
+
+void set_up_gart_resume(u32 aper_order, u32 aper_alloc)
+{
+ fix_up_north_bridges = true;
+ aperture_order = aper_order;
+ aperture_alloc = aper_alloc;
+}
+
 static int gart_resume(struct sys_device *dev)
 {
+ printk(KERN_INFO "PCI-DMA: Resuming GART IOMMU\n");
+
+ if (fix_up_north_bridges) {
+ int i;
+
+ printk(KERN_INFO "PCI-DMA: Restoring GART aperture settings\n");
+
+ for (i = 0; i < num_k8_northbridges; i++) {
+ struct pci_dev *dev = k8_northbridges[i];
+
+ /*
+ * Don't enable translations just yet.  That is the next
+ * step.  Restore the pre-suspend aperture settings.
+ */
+ pci_write_config_dword(dev, 0x90, aperture_order << 1);
+ pci_write_config_dword(dev, 0x94, aperture_alloc >> 25);
+ }
+ }
+
+ enable_gart_translations();
+
  return 0;
 }
 
 static int gart_suspend(struct sys_device *dev, pm_message_t state)
 {
- return -EINVAL;
+ return 0;
 }
 
 static struct sysdev_class gart_sysdev_class = {
@@ -557,21 +613,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
  memset(gatt, 0, gatt_size);
  agp_gatt_table = gatt;
 
- for (i = 0; i < num_k8_northbridges; i++) {
- u32 ctl;
- u32 gatt_reg;
-
- dev = k8_northbridges[i];
- gatt_reg = __pa(gatt) >> 12;
- gatt_reg <<= 4;
- pci_write_config_dword(dev, 0x98, gatt_reg);
- pci_read_config_dword(dev, 0x90, &ctl);
-
- ctl |= 1;
- ctl &= ~((1<<4) | (1<<5));
-
- pci_write_config_dword(dev, 0x90, ctl);
- }
+ enable_gart_translations();
 
  error = sysdev_class_register(&gart_sysdev_class);
  if (!error)
diff --git a/include/asm-x86/gart.h b/include/asm-x86/gart.h
index f704c50..1cf5986 100644
--- a/include/asm-x86/gart.h
+++ b/include/asm-x86/gart.h
@@ -10,6 +10,7 @@ extern void gart_iommu_init(void);
 extern void gart_iommu_shutdown(void);
 extern void __init gart_parse_options(char *);
 extern void gart_iommu_hole_init(void);
+extern void set_up_gart_resume(u32, u32);
 extern int fallback_aper_order;
 extern int fallback_aper_force;
 extern int gart_iommu_aperture;
--
1.5.4.3


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [Hardy] SRU request for LP#257293

Tim Gardner-2
Stefan Bader wrote:

> https://bugs.launchpad.net/ubuntu/hardy/+source/linux/+bug/257293
>
> Note: The fix to this went into v2.6.27-rc1 upstream, so Intrepid should get it
> automatically.
>
> SRU Justification:
>
> Impact: The GART code is missing suspend resume support which means, certain
> setup steps will not be performed after resume which can cause memory
> corruption in the worst case.
>
> Fix: The fix is done in two steps (following upstream): first this add suspend
> and resume callbacks and then it adds the necessary code to set up the
> registers after a suspend.
>
> Testcase: See bug report.

ACK
--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team