• Takayoshi Kochi's avatar
    [PATCH] PCI Hotplug: add address file and fix acpiphp bugs · 272b06a8
    Takayoshi Kochi authored
    This is the pending patch that adds 'address' file to show
    PCI-address and a few other minor fixes.
    As 2.6.0 is out, I'm resending the patch.
    Would you mind taking this?
    
    > > > Thanks.  I had a little time to try your patch today.  Sorry
    > > > to report that it isn't working for me.
    > > >
    > > > I first powered off (successfully the 1st time) a populated slot
    > > > and removed and reinserted the card into the same slot.  The slot
    > > > powered back up but I was then unable to power it off.  I believe
    > > > the following instruction that still exists in power_off_slot()
    > > > may be preventing the slot from being powered off more than once.
    > > >     func->flags &= (~FUNC_EXISTS);
    > > >
    > > > I then tried to insert an adapter in an un-populated slot.  For
    > > > some reason (which I don't understand yet) there was an enabling
    > > > error which I believe caused enable_device() to exit via a path
    > > > that bypassed the instruction that sets the FUNC_EXISTS flag.
    > > > I was then unable to power off the slot which I believe was due
    > > > to the FUNC_EXISTS flag not being set.
    > > >
    > > > I didn't have time to definitely confirmed the above theories.
    > > > I'll take a closer look at this tomorrow unless you are able
    > > > to diagnose using my vague clues :)
    > >
    > > It turns out that both of the above mentioned problems happened
    > > because the call to acpiphp_configure_slot() from enable_device()
    > > failed after inserting the card.  When this happens enable_device()
    > > exits without setting the FUNC_EXISTS flag for any of the slot
    > > functions.  Subsequent attempts to power off the same slot fail
    > > when power_off_slot() is unable to locate a function with both
    > > FUNC_HAS_EJ0 and FUNC_EXISTS flags set.
    > >
    > > The patch works okay when using a card that allows
    > > acpiphp_configure_slot() to succeed but I believe it should
    > > be improved to allow the slot to be powered off following
    > > device enablement errors.
    >
    > Thanks for testing and comments.
    > I really appreciate it.
    >
    > This problem turned out to be somewhat fragile state
    > transition:
    >
    > a lifecycle of a slot is (if there's no error)
    >
    >   function             state
    > ----------------------------------------------------
    > 0                      nothing
    > 1  power_on_slot()  -> SLOT_POWERDON
    > 2  enable_device()  -> SLOT_POWEREDON + SLOT_ENABLED
    > 3  disable_device() -> SLOT_POWEREDON
    > 4  power_off_slot() -> nothing
    >
    > but if any error occur during enable_device(), slot will remain
    > SLOT_POWERDON, but some functions on the card may not have
    > FUNC_EXISTS flags, which will eventually prevents powering
    > off in power_off_slot(), state transition from 1 to 4 directly.
    > I.e, the FUNC_EXISTS flag introduced more states to
    > complicate things.
    >
    > The FUNC_EXISTS flag was introduced after some discussion
    > between me and Irene Zubarev, but it has no more meaning
    > than that the function has corresponding 'pci_dev' structure.
    > So I eliminated the usage of FUNC_EXISTS and the result is
    > the patches attached to this mail (for both 2.4 and 2.6.
    > I think Greg already applied the 2.4 'cleanup' patch to his tree,
    > but it's not in Marcelo's release so I'm re-attaching to
    > this mail for anyone interested in this topic.  It's identical
    > to the one I posted earlier).
    > These patches don't include Gary's patch in his post last week,
    > so please apply separately.
    >
    > Please note that current acpiphp driver cannot handle a
    > PCI card that has a PCI-to-PCI bridge on it (support
    > for such cards is incomplete).  But if it's treated as
    > an error, it should be recoverable anyway.
    272b06a8
acpiphp_core.c 12.7 KB