pci_alloc_msi is always called, is this bad? [never mind]
Sean Bruno
sean_bruno at yahoo.com
Fri Oct 4 17:01:22 UTC 2013
On Fri, 2013-10-04 at 08:56 -0700, Sean Bruno wrote:
> I was looking at the recent thread on -stable about mfi(4) and I noted
> that it appears, if I'm not mistaken, mfi_pci.c::pci_alloc_msi() is
> *always* invoked regardless of the mfi_msi tuneable. We just ignore the
> allocated MSI by not setting sc->mfi_irq_rid. Is that harmful?
>
> ------------------------------------------------------------------------
> 240 /* Allocate IRQ resource. */
> 241 sc->mfi_irq_rid = 0;
> 242 count = 1;
> 243 if (mfi_msi && pci_alloc_msi(sc->mfi_dev, &count) == 0) {
> 244 device_printf(sc->mfi_dev, "Using MSI\n");
> 245 sc->mfi_irq_rid = 1;
> 246 }
>
>
> ------------------------------------------------------------------------
> I would have thought that this would be more correct, avoid calling
> pci_alloc_msi() if mfi_msi isn't set in the first place.
> ------------------------------------------------------------------------
> sc->mfi_irq_ird = 0;
> count = 1;
> ret = 0
> if(mfi_msi)
> ret = pci_alloc_msi(sc->mfi_dev, &count);
>
> if (!ret) {
> device_printf(sc->mfi_dev, "Using MSI\n");
> sc->mfi_irq_rid = 1;
> }
> ------------------------------------------------------------------------
>
> Sean
Ah, ok. so, no, this is just me not understanding C. Wrote a small
test to see what kib and scott were chatting about and the conditional
&& does indeed short circuit if the first condition is false. Good to
know. Carry on!
#include <stdio.h>
#include <stdlib.h>
int test()
{
int j = 1;
printf ("test is running\n");
return j;
}
int main (int argc, char **argv)
{
int i = atoi(argv[1]);
printf ("i %d\n", i);
if ( i && test() )
printf ("both are true\n");
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freebsd.org/pipermail/freebsd-scsi/attachments/20131004/e63741d5/attachment.sig>
More information about the freebsd-scsi
mailing list