From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 4 15:39:49 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81E621065672 for ; Wed, 4 Aug 2010 15:39:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4EC018FC13 for ; Wed, 4 Aug 2010 15:39:49 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id E9CC746B96; Wed, 4 Aug 2010 11:39:48 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id B2B2A8A03C; Wed, 4 Aug 2010 11:39:47 -0400 (EDT) From: John Baldwin To: Oleg Sharoyko Date: Wed, 4 Aug 2010 11:12:28 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100217; KDE/4.4.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201008041112.28704.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Wed, 04 Aug 2010 11:39:47 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: freebsd-hackers@freebsd.org Subject: Re: PCI config space is not restored upon resume (macbook pro) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2010 15:39:49 -0000 On Wednesday, August 04, 2010 3:13:04 am Oleg Sharoyko wrote: > On 3 August 2010 20:25, Oleg Sharoyko wrote: > > >> I wonder if the bus numbers for PCI-PCI bridges need to be restored on resume? > >> If they aren't then config transactions won't be routed properly. You could > >> add a pcib_resume() method that prints out the various bus register values > >> 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. Cool, I actually think that the ACPI PCI-PCI driver can just use the stock PCI-PCI bridge driver's suspend and resume methods. Can you try out this alternate patch instead? > 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? This sounds like the display just needs to be powered on via DPMS. You might be able to make this work via acpi_video and toggling the LCD status that way. You could also try dpms.ko. Index: dev/acpica/acpi_pcib.c =================================================================== --- dev/acpica/acpi_pcib.c (revision 210796) +++ dev/acpica/acpi_pcib.c (working copy) @@ -171,13 +171,6 @@ return_VALUE (bus_generic_attach(dev)); } -int -acpi_pcib_resume(device_t dev) -{ - - return (bus_generic_resume(dev)); -} - static void prt_lookup_device(ACPI_PCI_ROUTING_TABLE *entry, void *arg) { Index: dev/acpica/acpi_pcib_pci.c =================================================================== --- dev/acpica/acpi_pcib_pci.c (revision 210796) +++ dev/acpica/acpi_pcib_pci.c (working copy) @@ -65,7 +65,6 @@ static int acpi_pcib_pci_probe(device_t bus); static int acpi_pcib_pci_attach(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); static int acpi_pcib_pci_route_interrupt(device_t pcib, @@ -75,39 +74,20 @@ /* Device interface */ 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_resume, acpi_pcib_pci_resume), /* Bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), - DEVMETHOD(bus_write_ivar, pcib_write_ivar), - DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), /* pcib interface */ - DEVMETHOD(pcib_maxslots, pcib_maxslots), - DEVMETHOD(pcib_read_config, pcib_read_config), - DEVMETHOD(pcib_write_config, pcib_write_config), DEVMETHOD(pcib_route_interrupt, acpi_pcib_pci_route_interrupt), - DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), - DEVMETHOD(pcib_release_msi, pcib_release_msi), - DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), - DEVMETHOD(pcib_release_msix, pcib_release_msix), - DEVMETHOD(pcib_map_msi, pcib_map_msi), {0, 0} }; static devclass_t pcib_devclass; -DEFINE_CLASS_0(pcib, acpi_pcib_pci_driver, acpi_pcib_pci_methods, - sizeof(struct acpi_pcib_softc)); +DEFINE_CLASS_1(pcib, acpi_pcib_pci_driver, acpi_pcib_pci_methods, + sizeof(struct acpi_pcib_softc), pcib_driver); DRIVER_MODULE(acpi_pcib, pci, acpi_pcib_pci_driver, pcib_devclass, 0, 0); MODULE_DEPEND(acpi_pcib, acpi, 1, 1, 1); @@ -142,13 +123,6 @@ } static int -acpi_pcib_pci_resume(device_t dev) -{ - - return (acpi_pcib_resume(dev)); -} - -static int acpi_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) { struct acpi_pcib_softc *sc = device_get_softc(dev); Index: dev/acpica/acpi_pcib_acpi.c =================================================================== --- dev/acpica/acpi_pcib_acpi.c (revision 210796) +++ dev/acpica/acpi_pcib_acpi.c (working copy) @@ -65,7 +65,6 @@ static int acpi_pcib_acpi_probe(device_t bus); static int acpi_pcib_acpi_attach(device_t bus); -static int acpi_pcib_acpi_resume(device_t bus); static int acpi_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); static int acpi_pcib_write_ivar(device_t dev, device_t child, @@ -94,7 +93,7 @@ DEVMETHOD(device_attach, acpi_pcib_acpi_attach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, acpi_pcib_acpi_resume), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), @@ -257,13 +257,6 @@ return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_bus)); } -static int -acpi_pcib_acpi_resume(device_t dev) -{ - - return (acpi_pcib_resume(dev)); -} - /* * Support for standard PCI bridge ivars. */ Index: dev/acpica/acpi_pcibvar.h =================================================================== --- dev/acpica/acpi_pcibvar.h (revision 210796) +++ dev/acpica/acpi_pcibvar.h (working copy) @@ -31,13 +31,14 @@ #define _ACPI_PCIBVAR_H_ #ifdef _KERNEL + void acpi_pci_link_add_reference(device_t dev, int index, device_t pcib, int slot, int pin); int acpi_pci_link_route_interrupt(device_t dev, int index); int acpi_pcib_attach(device_t bus, ACPI_BUFFER *prt, int busno); int acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin, ACPI_BUFFER *prtbuf); -int acpi_pcib_resume(device_t dev); + #endif /* _KERNEL */ #endif /* !_ACPI_PCIBVAR_H_ */ Index: dev/pci/pcib_private.h =================================================================== --- dev/pci/pcib_private.h (revision 210796) +++ dev/pci/pcib_private.h (working copy) @@ -37,6 +37,7 @@ * Export portions of generic PCI:PCI bridge support so that it can be * used by subclasses. */ +DECLARE_CLASS(pcib_driver); /* * Bridge-specific data. -- John Baldwin