From owner-freebsd-scsi@FreeBSD.ORG Fri Oct 4 21:59:48 2013 Return-Path: Delivered-To: FreeBSD-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4DB9EA0C; Fri, 4 Oct 2013 21:59:48 +0000 (UTC) (envelope-from dgilbert@interlog.com) Received: from smtp.infotech.no (smtp.infotech.no [82.134.31.41]) by mx1.freebsd.org (Postfix) with ESMTP id 0B21C293F; Fri, 4 Oct 2013 21:59:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 22CC520423A; Fri, 4 Oct 2013 23:59:39 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k+w-ASAxYC8i; Fri, 4 Oct 2013 23:59:38 +0200 (CEST) Received: from [10.7.0.30] (unknown [10.7.0.30]) by smtp.infotech.no (Postfix) with ESMTPA id 3DBB52041D0; Fri, 4 Oct 2013 23:59:37 +0200 (CEST) Message-ID: <524F3A2A.2010700@interlog.com> Date: Fri, 04 Oct 2013 17:59:06 -0400 From: Douglas Gilbert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: John-Mark Gurney , sbruno@freebsd.org, "FreeBSD-scsi@freebsd.org" Subject: Re: pci_alloc_msi is always called, is this bad? References: <20131003194704.GG41229@kib.kiev.ua> <1380902209.2621.11.camel@localhost> <20131004165701.GJ56872@funkthat.com> In-Reply-To: <20131004165701.GJ56872@funkthat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: dgilbert@interlog.com List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Oct 2013 21:59:48 -0000 On 13-10-04 12:57 PM, John-Mark Gurney wrote: > Sean Bruno wrote this message on Fri, Oct 04, 2013 at 08:56 -0700: >> 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; >> } >> ------------------------------------------------------------------------ > > Per C99 6.5.13 Logical AND operator, para 4: > Unlike the bitwise binary & operator, the && operator guarantees > left-to-right evaluation; there is a sequence point after the > evaluation of the first operand. If the first operand compares equal > to 0, the second operand is not evaluated. The C Programming Language, Kernighan and Ritchie, Copyright 1978. See the middle of page 38. After explaining this feature they say: "These properties are critical to writing programs that work." BTW the book was phototypeset "by a PDP 11/70 running under the Unix operating system".