From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Ingo Molnar <mingo@elte.hu>
Cc: Pavel Machek <pavel@suse.cz>,
the arch/x86 maintainers <x86@kernel.org>,
pm list <linux-pm@lists.linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86 GART: Add resume handling (was: Re: >3G => iommu => suspend problems -- was Re: SB600 AHCI: Hard Disk Corruption)
Date: Tue, 10 Jun 2008 00:10:48 +0200 [thread overview]
Message-ID: <200806100010.49194.rjw@sisk.pl> (raw)
In-Reply-To: <20080609124630.GA28799@elte.hu>
On Monday, 9 of June 2008, Ingo Molnar wrote:
>
> * Rafael J. Wysocki <rjw@sisk.pl> wrote:
>
> > > Looks ok to me.
> >
> > Still, it may be improved. :-)
> >
> > First, we shouldn't mix the "early PCI config access" thing with the
> > "normal" method. Second, we don't have to check for the K8 north
> > bridges on resume, because we already know where they are in the
> > configuration space and we can use this information.
> >
> > Updated patch follows. It has been tested a little on my new 4 GB
> > test box on which 2.6.26-rc4 failed miserably with severe
> > consequences. More testing welcome, but please be careful.
>
> Rafael, could we try this against the tip/x86/gart tree perhaps? It
> already has a couple of fixes from Pavel and your patch collides with
> them in a non-obvious way.
>
> http://people.redhat.com/mingo/tip.git/README
Okay, appended is the patch rebased on tip/x86/gart with (mainline) commit
cd76374e9de4501acc74f833dc6cb5e7a5dca115 "suspend-vs-iommu: prevent suspend if
we could not resume" (which appears to be missing from tip/x86/gart) applied.
This version of the patch doesn't break compilation, but it hasn't been really
tested yet.
Thanks,
Rafael
---
Add resume handling to GART IOMMU.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
arch/x86/kernel/aperture_64.c | 2 +
arch/x86/kernel/pci-gart_64.c | 57 ++++++++++++++++++++++++++++++++++++++----
include/asm-x86/gart.h | 1
3 files changed, 55 insertions(+), 5 deletions(-)
Index: tip.git/arch/x86/kernel/aperture_64.c
===================================================================
--- tip.git.orig/arch/x86/kernel/aperture_64.c
+++ tip.git/arch/x86/kernel/aperture_64.c
@@ -496,4 +496,6 @@ out:
write_pci_config(bus, slot, 3, AMD64_GARTAPERTUREBASE, aper_alloc >> 25);
}
}
+
+ set_up_gart_resume(aper_order, aper_alloc);
}
Index: tip.git/arch/x86/kernel/pci-gart_64.c
===================================================================
--- tip.git.orig/arch/x86/kernel/pci-gart_64.c
+++ tip.git/arch/x86/kernel/pci-gart_64.c
@@ -549,14 +549,63 @@ static __init unsigned read_aperture(str
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];
+
+ enable_gart_translation(dev, __pa(agp_gatt_table));
+ }
+}
+
+/*
+ * 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, AMD64_GARTAPERTURECTL,
+ aperture_order << 1);
+ pci_write_config_dword(dev, AMD64_GARTAPERTUREBASE,
+ 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 = {
@@ -614,16 +663,14 @@ static __init int init_k8_gatt(struct ag
memset(gatt, 0, gatt_size);
agp_gatt_table = gatt;
- for (i = 0; i < num_k8_northbridges; i++) {
- dev = k8_northbridges[i];
- enable_gart_translation(dev, __pa(gatt));
- }
+ enable_gart_translations();
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",
Index: tip.git/include/asm-x86/gart.h
===================================================================
--- tip.git.orig/include/asm-x86/gart.h
+++ tip.git/include/asm-x86/gart.h
@@ -14,6 +14,7 @@ extern void gart_iommu_shutdown(void);
extern void __init gart_parse_options(char *);
extern void early_gart_iommu_check(void);
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;
next prev parent reply other threads:[~2008-06-09 22:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-25 12:10 SB600 AHCI: Hard Disk Corruption Patrick
2008-05-25 12:16 ` Patrick
2008-05-25 17:38 ` Pavel Machek
2008-05-25 20:08 ` Patrick
2008-05-25 20:39 ` >3G => iommu => suspend problems -- was " Pavel Machek
2008-05-25 21:10 ` Pavel Machek
2008-05-26 15:31 ` Patrick
2008-05-27 11:22 ` Pavel Machek
2008-05-29 18:44 ` Patrick
2008-05-29 18:51 ` Patrick
2008-05-29 21:05 ` Patrick
2008-06-03 22:33 ` Rafael J. Wysocki
2008-06-06 13:20 ` Pavel Machek
2008-06-08 22:36 ` Rafael J. Wysocki
[not found] ` <20080609124630.GA28799@elte.hu>
2008-06-09 22:10 ` Rafael J. Wysocki [this message]
2008-06-10 10:03 ` [PATCH] x86 GART: Add resume handling (was: Re: >3G => iommu => suspend problems -- was Re: SB600 AHCI: Hard Disk Corruption) Rafael J. Wysocki
2008-06-12 9:34 ` Ingo Molnar
2008-06-11 11:43 ` >3G => iommu => suspend problems -- was Re: SB600 AHCI: Hard Disk Corruption Patrick
2008-06-11 14:38 ` Rafael J. Wysocki
2008-06-11 15:04 ` Andi Kleen
2008-07-03 17:35 ` Patrick
2008-08-07 8:17 ` Pavel Machek
2008-08-08 22:40 ` Patrick
2008-09-02 8:05 ` Pavel Machek
2008-05-27 10:23 ` Pavel Machek
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=200806100010.49194.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mingo@elte.hu \
--cc=pavel@suse.cz \
--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