Skip to content
  • Michael Ellerman's avatar
    powerpc/pseries: Implement a quota system for MSIs · 448e2ca0
    Michael Ellerman authored
    
    
    There are hardware limitations on the number of available MSIs,
    which firmware expresses using a property named "ibm,pe-total-#msi".
    This property tells us how many MSIs are available for devices below
    the point in the PCI tree where we find the property.
    
    For old firmwares which don't have the property, we assume there are
    8 MSIs available per "partitionable endpoint" (PE). The PE can be
    found using existing EEH code, which uses the methods described in
    PAPR. For our purposes we want the parent of the node that's
    identified using this method.
    
    When a driver requests n MSIs for a device, we first establish where
    the "ibm,pe-total-#msi" property above that device is, or we find the
    PE if the property is not found. In both cases we call this node
    the "pe_dn".
    
    We then count all non-bridge devices below the pe_dn, to establish
    how many devices in total may need MSIs. The quota is then simply the
    total available divided by the number of devices, if the request is
    less than or equal to the quota, the request is fine and we're done.
    
    If the request is greater than the quota, we try to determine if there
    are any "spare" MSIs which we can give to this device. Spare MSIs are
    found by looking for other devices which can never use their full
    quota, because their "req#msi(-x)" property is less than the quota.
    
    If we find any spare, we divide the spares by the number of devices
    that could request more than their quota. This ensures the spare
    MSIs are spread evenly amongst all over-quota requestors.
    
    Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
    Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
    448e2ca0