• Niklas Schnelle's avatar
    iommu/s390: Make attach succeed even if the device is in error state · 59bbf596
    Niklas Schnelle authored
    If a zPCI device is in the error state while switching IOMMU domains
    zpci_register_ioat() will fail and we would end up with the device not
    attached to any domain. In this state since zdev->dma_table == NULL
    a reset via zpci_hot_reset_device() would wrongfully re-initialize the
    device for DMA API usage using zpci_dma_init_device(). As automatic
    recovery is currently disabled while attached to an IOMMU domain this
    only affects slot resets triggered through other means but will affect
    automatic recovery once we switch to using dma-iommu.
    
    Additionally with that switch common code expects attaching to the
    default domain to always work so zpci_register_ioat() should only fail
    if there is no chance to recover anyway, e.g. if the device has been
    unplugged.
    
    Improve the robustness of attach by specifically looking at the status
    returned by zpci_mod_fc() to determine if the device is unavailable and
    in this case simply ignore the error. Once the device is reset
    zpci_hot_reset_device() will then correctly set the domain's DMA
    translation tables.
    Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
    Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
    Link: https://lore.kernel.org/r/20221109142903.4080275-2-schnelle@linux.ibm.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    59bbf596
pci.c 28.2 KB