Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 04 Oct 2013 10:01:12 -0700
From:      Sean Bruno <sean_bruno@yahoo.com>
To:        sbruno@freebsd.org
Cc:        "FreeBSD-scsi@freebsd.org" <FreeBSD-scsi@freebsd.org>
Subject:   Re: pci_alloc_msi is always called, is this bad? [never mind]
Message-ID:  <1380906072.2915.2.camel@localhost>
In-Reply-To: <1380902209.2621.11.camel@localhost>
References:  <CAFMmRNzWwxe=YVJcC7Lkjqru5eugciwzEQHjgE-Bh-ctOykVNQ@mail.gmail.com> <20131003194704.GG41229@kib.kiev.ua>  <1380902209.2621.11.camel@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-PoqG66kFQ3mtexPQW068
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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?
>=20
> ------------------------------------------------------------------------
> 240         /* Allocate IRQ resource. */
> 241         sc->mfi_irq_rid =3D 0;
> 242         count =3D 1;
> 243         if (mfi_msi && pci_alloc_msi(sc->mfi_dev, &count) =3D=3D 0) {
> 244                 device_printf(sc->mfi_dev, "Using MSI\n");
> 245                 sc->mfi_irq_rid =3D 1;
> 246         }
>=20
>=20
> ------------------------------------------------------------------------
> 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 =3D 0;
> 	count =3D 1;
> 	ret =3D 0
> 	if(mfi_msi)
> 		ret =3D pci_alloc_msi(sc->mfi_dev, &count);
>=20
> 	if (!ret) {
> 		device_printf(sc->mfi_dev, "Using MSI\n");
> 		sc->mfi_irq_rid =3D 1;
> 	}
> ------------------------------------------------------------------------
>=20
> 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 =3D 1;
        printf ("test is running\n");
        return j;
}

int main (int argc, char **argv)
{
        int i =3D atoi(argv[1]);

        printf ("i %d\n", i);
        if ( i && test() )
                printf ("both are true\n");
        return 0;
}


--=-PoqG66kFQ3mtexPQW068
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (FreeBSD)

iQEcBAABAgAGBQJSTvRQAAoJEBkJRdwI6BaHSrsH/2r6sTKIXqVoohlSFScWLWvT
75vDpTN0y0IkM8TtbmSUombaIt8M6GTaKumruaWFUgCUDIhz3OveytdckN/zCO1S
rmxnyCrCvYr/ttfoGHz5SOURSPbfeZM5PX4CiiRgjsgwOa8+mFfVqQVs5RbB5nwB
/sYbfvdnP5m9rNVSXOuXv3lJ5LyORoxkxT0vUfOF8fsymrsMB/IcsS4kP2tFWjT5
nNRZLZHIyKH+WoIi+uF7GuQia2nb1LVNrCRw3zL5zL1cBAwT0MHTTlCleMz8nibU
yt+qKu0xI3iCvb1m5Y6C3HopS86oPkdFBUdDkmTCiZXLSJOLmluNNOdeXPQvyrI=
=kr8+
-----END PGP SIGNATURE-----

--=-PoqG66kFQ3mtexPQW068--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1380906072.2915.2.camel>