Subject: Re: Possible fix for kern/10586: wake up from power state D3
To: Matthias Scheler <tron@zhadum.de>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-kern
Date: 07/16/2000 10:28:38
On Sun, Jul 16, 2000 at 01:13:03PM +0200, Matthias Scheler wrote:

 > Index: if_epic_pci.c
 > ===================================================================
 > RCS file: /cvsroot/syssrc/sys/dev/pci/if_epic_pci.c,v
 > retrieving revision 1.11
 > diff -u -r1.11 if_epic_pci.c
 > --- if_epic_pci.c	2000/07/15 20:57:24	1.11
 > +++ if_epic_pci.c	2000/07/16 11:06:09
 > @@ -167,18 +167,21 @@
 >  
 >  	if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
 >  		reg = pci_conf_read(pc, pa->pa_tag, pmreg + 4) & 0x3;
 > -		if (reg == 3) {
 > -			/*
 > -			 * The card has lost all configuration data in
 > -			 * this state, so punt.
 > -			 */
 > -			printf(": unable to wake up from power state D3\n");
 > -			return;
 > -		}
 >  		if (reg != 0) {
 >  			printf(": waking up from power state D%d\n%s",
 >  			    reg, sc->sc_dev.dv_xname);
 >  			pci_conf_write(pc, pa->pa_tag, pmreg + 4, 0);
 > +		}
 > +		if (reg == 3) {
 > +			reg = pci_conf_read(pc, pa->pa_tag,
 > +					    PCI_COMMAND_STATUS_REG);
 > +			reg |= PCI_COMMAND_IO_ENABLE |
 > +			       PCI_COMMAND_MEM_ENABLE |
 > +			       PCI_COMMAND_MASTER_ENABLE;

This is not correct.  MASTER should be enabled, but each of IO and MEM
should be enabled iff its corresponding BAR has a valid value programmed
into it, and if pa->pa_flags has the corresponding flag set.

 > +			pci_conf_write(pc, pa->pa_tag,
 > +				       PCI_COMMAND_STATUS_REG, reg);
 > +			pa->pa_flags |= PCI_FLAGS_IO_ENABLED |
 > +					PCI_FLAGS_MEM_ENABLED;

You should *never* modify pa->pa_flags;

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>