From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 4 07:13:06 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 C080E106566B; Wed, 4 Aug 2010 07:13:06 +0000 (UTC) (envelope-from osharoiko@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 77EA78FC08; Wed, 4 Aug 2010 07:13:06 +0000 (UTC) Received: by iwn35 with SMTP id 35so1886597iwn.13 for ; Wed, 04 Aug 2010 00:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Rnf8JLxVYc23mClQjnk4t8EDouZA2pDqif8RBUbWFPA=; b=FvOG4UoLQQK2TiVVT52fu+Aj0Ez8EtnXtvdU8x2zDaLgJpY970VkjCXW5DK65WyT5r VlRV0PHmxwCKSD4B/ZeUjcz3H4adZnQ1HJ+v9r0XnBgXMDUwbJzba7Rno+w9dBdEY0ly m1X69rzfa/Cc2CK4/iXG12I1/BOSw8GgI3O+U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=QZ8U9WsEeO4XfHmcBYhT5SkOfqCdUL2qo/UScQN+MTYsLBP5zAe/L6LxBHoGSJ2WM/ oiGUCozj8uh/HSUk3HKXRJ/KYqLQ1+o8VfUsEfqSHYWMm5abDt5ilX9IHU5A0dDKh1v5 wJ7o7Y4zaMcFlFyPr+jKpz98e54IADEuVqdaE= MIME-Version: 1.0 Received: by 10.231.30.130 with SMTP id u2mr9978772ibc.111.1280905985411; Wed, 04 Aug 2010 00:13:05 -0700 (PDT) Received: by 10.231.168.20 with HTTP; Wed, 4 Aug 2010 00:13:04 -0700 (PDT) In-Reply-To: References: <201008030944.01011.jhb@freebsd.org> Date: Wed, 4 Aug 2010 11:13:04 +0400 Message-ID: From: Oleg Sharoyko To: John Baldwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 07:13:06 -0000 On 3 August 2010 20:25, Oleg Sharoyko 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