• Alex Williamson's avatar
    PCI: pciehp: Wait for hotplug command completion where necessary · bea3f198
    Alex Williamson authored
    [ Upstream commit a5dd4b4b ]
    
    The commit referenced below deferred waiting for command completion until
    the start of the next command, allowing hardware to do the latching
    asynchronously.  Unfortunately, being ready to accept a new command is the
    only indication we have that the previous command is completed.  In cases
    where we need that state change to be enabled, we must still wait for
    completion.  For instance, pciehp_reset_slot() attempts to disable anything
    that might generate a surprise hotplug on slots that support presence
    detection.  If we don't wait for those settings to latch before the
    secondary bus reset, we negate any value in attempting to prevent the
    spurious hotplug.
    
    Create a base function with optional wait and helper functions so that
    pcie_write_cmd() turns back into the "safe" interface which waits before
    and after issuing a command and add pcie_write_cmd_nowait(), which
    eliminates the trailing wait for asynchronous completion.  The following
    functions are returned to their previous behavior:
    
      pciehp_power_on_slot
      pciehp_power_off_slot
      pcie_disable_notification
      pciehp_reset_slot
    
    The rationale is that pciehp_power_on_slot() enables the link and therefore
    relies on completion of power-on.  pciehp_power_off_slot() and
    pcie_disable_notification() need a wait because data structures may be
    freed after these calls and continued signaling from the device would be
    unexpected.  And, of course, pciehp_reset_slot() needs to wait for the
    scenario outlined above.
    
    Fixes: 3461a068 ("PCI: pciehp: Wait for hotplug command completion lazily")
    Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    CC: stable@vger.kernel.org	# v3.17+
    Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
    bea3f198
pciehp_hpc.c 23 KB