powerpc/pseries: Implement a quota system for MSIs
authorMichael Ellerman <michael@ellerman.id.au>
Tue, 17 Feb 2009 00:21:56 +0000 (00:21 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 23 Feb 2009 04:53:03 +0000 (15:53 +1100)
commit448e2ca0e32a5c437650d634b6032ab732662338
treea392c48604a7dfb09a6d68b9152d2a2ea205ff97
parentd523cc379da57f1c39f5db9c47bdaa94f74727ff
powerpc/pseries: Implement a quota system for MSIs

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: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/pseries/msi.c