Re: [Penance PATCH] PCI: clean up the MSI code a bit

From: Stefan Smietanowski
Date: Thu Jun 09 2005 - 18:47:22 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

> Also see the proposals from Jeff/Stefan et.al. for simpler interfaces
> for this. No need to actually make it messy if we have nice helpers.

Could even be simplified one step closer.

My helper could simply be incorporated into pci_enable_msix().

pci_enable_msix(dev)
{
if (is_dev_msi(dev)) {
cur_status=MSI;
pci_disable_msi(dev);
}
else if (is_dev_msix(dev))
return(ALREADY_MSIX);
else
cur_status=OLD_FASHIONED;
if (!__pci_enable_msix(dev))
if (cur_status==MSI)
pci_enable_msi(dev);
}

Add error-checking, etc, etc, etc.

Naturally pci_enable_msix() is renamed to __pci_enable_msix() in my
example. You can also just put it inside here, or whatever.

That way, if you want to enable msix and it fails, it will return
to whatever it was using before pci_enable_msix() was called.

Why this ALSO will work is that msi will already be enabled for devices
that handle it (I'm thinking of this together with making msi default).

That's why we cache the current status, so that we can return the device
to the previous state, be it normal or be it msi mode.

Hm. Can a device that fails MSI (due to any reason - NB not supporting
it or some other reason) go to MSIX mode at all?

If it can't, then it's even shorter.

pci_enable_msix(dev)
{
if (is_dev_msi(dev))
pci_disable_msi(dev);
else if (is_dev_msix(dev))
return(ALREADY_MSIX);
else
return(MSIX_NOT_AVAILABLE);
if (!__pci_enable_msix(dev))
pci_enable_msi(dev);
}

That way noone needs to explicitly turn off msi as it's done
automatically instead and the device will after this call
always be in either MSIX, MSI or NORMAL IRQ mode, and
always in the "best" mode the device, motherboard, bios, NB,
whatever combination is available.

// Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)

iD8DBQFCqNWGBrn2kJu9P78RAjvUAJsFS2yj15j34CWKyh3CJ9iSDMydpACfc2a5
MA7LncSpbj6tQHigOFmFmrQ=
=4bMK
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/