From owner-svn-src-all@freebsd.org Tue Nov 13 18:49:44 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D182112DD12; Tue, 13 Nov 2018 18:49:44 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A17E728EB; Tue, 13 Nov 2018 18:49:44 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF5661422A; Tue, 13 Nov 2018 18:49:43 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wADInh0X035754; Tue, 13 Nov 2018 18:49:43 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wADInhkw035752; Tue, 13 Nov 2018 18:49:43 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201811131849.wADInhkw035752@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 13 Nov 2018 18:49:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r340403 - in stable/11/sys/dev: mpr mps X-SVN-Group: stable-11 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/11/sys/dev: mpr mps X-SVN-Commit-Revision: 340403 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1A17E728EB X-Spamd-Result: default: False [-106.87 / 200.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; ALLOW_DOMAIN_WHITELIST(-100.00)[FreeBSD.org]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: mx1.FreeBSD.org]; NEURAL_HAM_SHORT(-0.99)[-0.989,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; IP_SCORE(-3.77)[ip: (-9.91), ipnet: 2610:1c1:1::/48(-4.93), asn: 11403(-3.91), country: US(-0.09)] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2018 18:49:44 -0000 Author: scottl Date: Tue Nov 13 18:49:43 2018 New Revision: 340403 URL: https://svnweb.freebsd.org/changeset/base/340403 Log: Fix a regression from prior to 11.2 that caused MSI (not MSI-X) interrupt allocation to fail. While here, refactor the code so that it's more clear and less likely to break in the future. This is not an MFC due to the code in 12/head being very different, but it follows the latter's structure more closely than before. Reported by: Harry Schmalzbauer Modified: stable/11/sys/dev/mpr/mpr_pci.c stable/11/sys/dev/mps/mps_pci.c Modified: stable/11/sys/dev/mpr/mpr_pci.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_pci.c Tue Nov 13 18:40:01 2018 (r340402) +++ stable/11/sys/dev/mpr/mpr_pci.c Tue Nov 13 18:49:43 2018 (r340403) @@ -262,12 +262,16 @@ mpr_pci_alloc_interrupts(struct mpr_softc *sc) error = 0; msgs = 0; - if ((sc->disable_msix == 0) && - ((msgs = pci_msix_count(dev)) >= MPR_MSI_COUNT)) - error = mpr_alloc_msix(sc, MPR_MSI_COUNT); - if ((error != 0) && (sc->disable_msi == 0) && - ((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT)) - error = mpr_alloc_msi(sc, MPR_MSI_COUNT); + if (sc->disable_msix == 0) { + msgs = pci_msix_count(dev); + if (msgs >= MPR_MSI_COUNT) + error = mpr_alloc_msix(sc, MPR_MSI_COUNT); + } + if (((error != 0) || (msgs == 0)) && (sc->disable_msi == 0)) { + msgs = pci_msi_count(dev); + if (msgs >= MPR_MSI_COUNT) + error = mpr_alloc_msi(sc, MPR_MSI_COUNT); + } if (error != 0) msgs = 0; Modified: stable/11/sys/dev/mps/mps_pci.c ============================================================================== --- stable/11/sys/dev/mps/mps_pci.c Tue Nov 13 18:40:01 2018 (r340402) +++ stable/11/sys/dev/mps/mps_pci.c Tue Nov 13 18:49:43 2018 (r340403) @@ -247,12 +247,16 @@ mps_pci_alloc_interrupts(struct mps_softc *sc) error = 0; msgs = 0; - if ((sc->disable_msix == 0) && - ((msgs = pci_msix_count(dev)) >= MPS_MSI_COUNT)) - error = mps_alloc_msix(sc, MPS_MSI_COUNT); - if ((error != 0) && (sc->disable_msi == 0) && - ((msgs = pci_msi_count(dev)) >= MPS_MSI_COUNT)) - error = mps_alloc_msi(sc, MPS_MSI_COUNT); + if (sc->disable_msix == 0) { + msgs = pci_msix_count(dev); + if (msgs >= MPS_MSI_COUNT) + error = mps_alloc_msix(sc, MPS_MSI_COUNT); + } + if (((error != 0) || (msgs == 0)) && (sc->disable_msi == 0)) { + msgs = pci_msi_count(dev); + if (msgs >= MPS_MSI_COUNT) + error = mps_alloc_msi(sc, MPS_MSI_COUNT); + } if (error != 0) msgs = 0;