diff mbox

powerpc: pseries: Round up MSI-X requests

Message ID 20120604091545.03ce738b@kryten (mailing list archive)
State Superseded, archived
Delegated to: Michael Ellerman
Headers show

Commit Message

Anton Blanchard June 3, 2012, 11:15 p.m. UTC
The pseries firmware currently refuses any non power of two MSI-X
request. Unfortunately most network drivers end up asking for that
because they want a power of two for RX queues and one or two extra
for everything else.

This patch rounds up the firmware request to the next power of two
if the quota allows it.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Comments

Michael Ellerman June 4, 2012, 6:43 a.m. UTC | #1
On Mon, 2012-06-04 at 09:15 +1000, Anton Blanchard wrote:
> The pseries firmware currently refuses any non power of two MSI-X
> request. Unfortunately most network drivers end up asking for that
> because they want a power of two for RX queues and one or two extra
> for everything else.
> 
> This patch rounds up the firmware request to the next power of two
> if the quota allows it.

There is some chance this will result in breakage because the driver
asks for N - and assumes that is what was allocated - and the device is
configured for > N.

But that's a hypothetical, and we know the current approach sucks
because it will result in many drivers falling back to a single
interrupt.

I think this is the least-worst approach in light of the FW limitations,
and we can always add quirks in here if we really have to.

Paul is the pseries maintainer so he gets to ACK or NAK it, but from an
MSI point of view it gets my +1.

cheers
Benjamin Herrenschmidt June 4, 2012, 6:54 a.m. UTC | #2
On Mon, 2012-06-04 at 16:43 +1000, Michael Ellerman wrote:
> There is some chance this will result in breakage because the driver
> asks for N - and assumes that is what was allocated - and the device is
> configured for > N.

We can fix that. We can whack the configuration back with N, just know
that we have "allocated"  > N.

> But that's a hypothetical, and we know the current approach sucks
> because it will result in many drivers falling back to a single
> interrupt.
> 
> I think this is the least-worst approach in light of the FW limitations,
> and we can always add quirks in here if we really have to.
> 
> Paul is the pseries maintainer so he gets to ACK or NAK it, but from an
> MSI point of view it gets my +1.
> 

Cheers,
Ben.
diff mbox

Patch

Index: linux-build/arch/powerpc/platforms/pseries/msi.c
===================================================================
--- linux-build.orig/arch/powerpc/platforms/pseries/msi.c	2012-06-03 20:49:29.082280031 +1000
+++ linux-build/arch/powerpc/platforms/pseries/msi.c	2012-06-04 09:06:55.909732276 +1000
@@ -402,6 +402,18 @@  static int rtas_setup_msi_irqs(struct pc
 		return -EINVAL;
 
 	/*
+	 * Firmware currently refuse any non power of two allocation
+	 * so we round up if the quota will allow it.
+	 */
+	if (type == PCI_CAP_ID_MSIX) {
+		int m = roundup_pow_of_two(nvec);
+		int quota = msi_quota_for_device(pdev, m);
+
+		if (quota >= m)
+			nvec = m;
+	}
+
+	/*
 	 * Try the new more explicit firmware interface, if that fails fall
 	 * back to the old interface. The old interface is known to never
 	 * return MSI-Xs.