Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Aug 2010 11:13:04 +0400
From:      Oleg Sharoyko <osharoiko@gmail.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: PCI config space is not restored upon resume (macbook pro)
Message-ID:  <AANLkTika4sUaEh67bpyjJLSALKwhOYHzaAm-eWoE%2BqNW@mail.gmail.com>
In-Reply-To: <AANLkTinUvptZ9vrGq0Y8d3jUu0JzGsLCy5%2Brc3Rd=_rQ@mail.gmail.com>
References:  <AANLkTikMFhG1QLDf4raf%2BrxOKhobjoA-dRbUew2-8KeF@mail.gmail.com> <201008030944.01011.jhb@freebsd.org> <AANLkTinUvptZ9vrGq0Y8d3jUu0JzGsLCy5%2Brc3Rd=_rQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 3 August 2010 20:25, Oleg Sharoyko <osharoiko@gmail.com> wrote:

>> I wonder if the bus numbers for PCI-PCI bridges need to be restored on r=
esume?
>> If they aren't then config transactions won't be routed properly. =C2=A0=
You could
>> add a pcib_resume() method that prints out the various bus register valu=
es
>> after resume to see if they match what we print out during boot.

Indeed this was the problem of PCI-PIC bridges' registers not being
restored upon resume.
Thanks for your advise! I'm including the patch, which uses exiting
methods from dev/pic/pic_pci.c
to save/restore bridges' registers on suspend/resume. With it my
macbook pro no longer
looses devices after resume.

Unfortunately it doesn't help with videocard problem. Though I no
longer see 'failed to reload state'
message, display still stays blank and dark after resume. Would
freebsd-acpi be the right list
to ask for help or can you recommend anything else I can do to solve
this problem?

Index: dev/acpica/acpi_pcib_pci.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/dev/acpica/acpi_pcib_pci.c,v
retrieving revision 1.18
diff -u -r1.18 acpi_pcib_pci.c
--- dev/acpica/acpi_pcib_pci.c	5 Jun 2009 18:44:36 -0000	1.18
+++ dev/acpica/acpi_pcib_pci.c	4 Aug 2010 06:54:36 -0000
@@ -65,6 +65,7 @@

 static int		acpi_pcib_pci_probe(device_t bus);
 static int		acpi_pcib_pci_attach(device_t bus);
+static int		acpi_pcib_pci_suspend(device_t bus);
 static int		acpi_pcib_pci_resume(device_t bus);
 static int		acpi_pcib_read_ivar(device_t dev, device_t child,
 			    int which, uintptr_t *result);
@@ -76,7 +77,7 @@
     DEVMETHOD(device_probe,		acpi_pcib_pci_probe),
     DEVMETHOD(device_attach,		acpi_pcib_pci_attach),
     DEVMETHOD(device_shutdown,		bus_generic_shutdown),
-    DEVMETHOD(device_suspend,		bus_generic_suspend),
+    DEVMETHOD(device_suspend,		acpi_pcib_pci_suspend),
     DEVMETHOD(device_resume,		acpi_pcib_pci_resume),

     /* Bus interface */
@@ -142,9 +143,20 @@
 }

 static int
-acpi_pcib_pci_resume(device_t dev)
+acpi_pcib_pci_suspend(device_t dev)
 {
+    struct acpi_pcib_softc *sc;
+    sc =3D device_get_softc(dev);
+    pcib_cfg_save(&sc->ap_pcibsc);
+    return (bus_generic_suspend(dev));
+}

+static int
+acpi_pcib_pci_resume(device_t dev)
+{
+    struct acpi_pcib_softc *sc;
+    sc =3D device_get_softc(dev);
+    pcib_cfg_restore(&sc->ap_pcibsc);
     return (acpi_pcib_resume(dev));
 }

Index: dev/pci/pci_pci.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/dev/pci/pci_pci.c,v
retrieving revision 1.61
diff -u -r1.61 pci_pci.c
--- dev/pci/pci_pci.c	10 Dec 2009 01:01:53 -0000	1.61
+++ dev/pci/pci_pci.c	4 Aug 2010 06:54:36 -0000
@@ -238,7 +238,7 @@
 /*
  * Get current bridge configuration.
  */
-static void
+void
 pcib_cfg_save(struct pcib_softc *sc)
 {
 	device_t	dev;
@@ -260,7 +260,7 @@
 /*
  * Restore previous bridge configuration.
  */
-static void
+void
 pcib_cfg_restore(struct pcib_softc *sc)
 {
 	device_t	dev;
Index: dev/pci/pcib_private.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/dev/pci/pcib_private.h,v
retrieving revision 1.15
diff -u -r1.15 pcib_private.h
--- dev/pci/pcib_private.h	14 Mar 2009 14:08:53 -0000	1.15
+++ dev/pci/pcib_private.h	4 Aug 2010 06:54:36 -0000
@@ -82,5 +82,7 @@
 int		pcib_alloc_msix(device_t pcib, device_t dev, int *irq);
 int		pcib_release_msix(device_t pcib, device_t dev, int irq);
 int		pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t
*addr, uint32_t *data);
+void		pcib_cfg_save(struct pcib_softc *sc);
+void		pcib_cfg_restore(struct pcib_softc *sc);

 #endif

--=20
Oleg Sharoyko



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTika4sUaEh67bpyjJLSALKwhOYHzaAm-eWoE%2BqNW>