• Maciej W. Rozycki's avatar
    FDDI: defxx: Bail out gracefully with unassigned PCI resource for CSR · f626ca68
    Maciej W. Rozycki authored
    Recent versions of the PCI Express specification have deprecated support
    for I/O transactions and actually some PCIe host bridges, such as Power
    Systems Host Bridge 4 (PHB4), do not implement them.
    
    For those systems the PCI BARs that request a mapping in the I/O space
    have the length recorded in the corresponding PCI resource set to zero,
    which makes it unassigned:
    
    # lspci -s 0031:02:04.0 -v
    0031:02:04.0 FDDI network controller: Digital Equipment Corporation PCI-to-PDQ Interface Chip [PFI] FDDI (DEFPA) (rev 02)
    	Subsystem: Digital Equipment Corporation FDDIcontroller/PCI (DEFPA)
    	Flags: bus master, medium devsel, latency 136, IRQ 57, NUMA node 8
    	Memory at 620c080020000 (32-bit, non-prefetchable) [size=128]
    	I/O ports at <unassigned> [disabled]
    	Memory at 620c080030000 (32-bit, non-prefetchable) [size=64K]
    	Capabilities: [50] Power Management version 2
    	Kernel driver in use: defxx
    	Kernel modules: defxx
    
    #
    
    Regardless the driver goes ahead and requests it (here observed with a
    Raptor Talos II POWER9 system), resulting in an odd /proc/ioport entry:
    
    # cat /proc/ioports
    00000000-ffffffffffffffff : 0031:02:04.0
    #
    
    Furthermore, the system gets confused as the driver actually continues
    and pokes at those locations, causing a flood of messages being output
    to the system console by the underlying system firmware, like:
    
    defxx: v1.11 2014/07/01  Lawrence V. Stefani and others
    defxx 0031:02:04.0: enabling device (0140 -> 0142)
    LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010000
    IPMI: dropping non severe PEL event
    LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010014
    IPMI: dropping non severe PEL event
    LPC[000]: Got SYNC no-response error. Error address reg: 0xd0010014
    IPMI: dropping non severe PEL event
    
    and so on and so on (possibly intermixed actually, as there's no locking
    between the kernel and the firmware in console port access with this
    particular system, but cleaned up above for clarity), and once some 10k
    of such pairs of the latter two messages have been produced an interace
    eventually shows up in a useless state:
    
    0031:02:04.0: DEFPA at I/O addr = 0x0, IRQ = 57, Hardware addr = 00-00-00-00-00-00
    
    This was not expected to happen as resource handling was added to the
    driver a while ago, because it was not known at that time that a PCI
    system would be possible that cannot assign port I/O resources, and
    oddly enough `request_region' does not fail, which would have caught it.
    
    Correct the problem then by checking for the length of zero for the CSR
    resource and bail out gracefully refusing to register an interface if
    that turns out to be the case, producing messages like:
    
    defxx: v1.11 2014/07/01  Lawrence V. Stefani and others
    0031:02:04.0: Cannot use I/O, no address set, aborting
    0031:02:04.0: Recompile driver with "CONFIG_DEFXX_MMIO=y"
    
    Keep the original check for the EISA MMIO resource as implemented,
    because in that case the length is hardwired to 0x400 as a consequence
    of how the compare/mask address decoding works in the ESIC chip and it
    is only the base address that is set to zero if MMIO has been disabled
    for the adapter in EISA configuration, which in turn could be a valid
    bus address in a legacy-free system implementing PCI, especially for
    port I/O.
    
    Where the EISA MMIO resource has been disabled for the adapter in EISA
    configuration this arrangement keeps producing messages like:
    
    eisa 00:05: EISA: slot 5: DEC3002 detected
    defxx: v1.11 2014/07/01  Lawrence V. Stefani and others
    00:05: Cannot use MMIO, no address set, aborting
    00:05: Recompile driver with "CONFIG_DEFXX_MMIO=n"
    00:05: Or run ECU and set adapter's MMIO location
    
    with the last two lines now swapped for easier handling in the driver.
    
    There is no need to check for and catch the case of a port I/O resource
    not having been assigned for EISA as the adapter uses the slot-specific
    I/O space, which gets assigned by how EISA has been specified and maps
    directly to the particular slot an option card has been placed in.  And
    the EISA variant of the adapter has additional registers that are only
    accessible via the port I/O space anyway.
    
    While at it factor out the error message calls into helpers and fix an
    argument order bug with the `pr_err' call now in `dfx_register_res_err'.
    Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
    Fixes: 4d0438e5 ("defxx: Clean up DEFEA resource management")
    Cc: stable@vger.kernel.org # v3.19+
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f626ca68
defxx.c 116 KB