From owner-svn-src-head@freebsd.org Wed Nov 29 18:14:58 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65C97E5FC37; Wed, 29 Nov 2017 18:14:58 +0000 (UTC) (envelope-from shurd@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 mx1.freebsd.org (Postfix) with ESMTPS id 3081C7F2A1; Wed, 29 Nov 2017 18:14:58 +0000 (UTC) (envelope-from shurd@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vATIEvlw015599; Wed, 29 Nov 2017 18:14:57 GMT (envelope-from shurd@FreeBSD.org) Received: (from shurd@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vATIEv0T015598; Wed, 29 Nov 2017 18:14:57 GMT (envelope-from shurd@FreeBSD.org) Message-Id: <201711291814.vATIEv0T015598@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: shurd set sender to shurd@FreeBSD.org using -f From: Stephen Hurd Date: Wed, 29 Nov 2017 18:14:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326369 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: shurd X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 326369 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Nov 2017 18:14:58 -0000 Author: shurd Date: Wed Nov 29 18:14:57 2017 New Revision: 326369 URL: https://svnweb.freebsd.org/changeset/base/326369 Log: Ensure that ctx->ifc_cpus is always initialized If a device didn't support MSI-X, ctx->ifc_cpus would not be initialized, but the IRQ allocation routines still uses the value. Move the initialization to common code. Sponsored by: Limelight Networks Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c ============================================================================== --- head/sys/net/iflib.c Wed Nov 29 14:45:28 2017 (r326368) +++ head/sys/net/iflib.c Wed Nov 29 18:14:57 2017 (r326369) @@ -4259,6 +4259,14 @@ iflib_device_register(device_t dev, void *sc, if_share GROUPTASK_INIT(&ctx->ifc_admin_task, 0, _task_fn_admin, ctx); /* XXX format name */ taskqgroup_attach(qgroup_if_config_tqg, &ctx->ifc_admin_task, ctx, -1, "admin"); + + /* Set up cpu set. If it fails, zero out the set. */ + if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) != 0) { + device_printf(dev, "Unable to fetch CPU list\n"); + CPU_COPY(&all_cpus, &ctx->ifc_cpus); + } + MPASS(CPU_COUNT(&ctx->ifc_cpus) > 0); + /* ** Now setup MSI or MSI/X, should ** return us the number of supported @@ -4984,7 +4992,7 @@ find_nth(if_ctx_t ctx, cpuset_t *cpus, int qid) int i, cpuid, eqid, count; CPU_COPY(&ctx->ifc_cpus, cpus); - count = CPU_COUNT(&ctx->ifc_cpus); + count = CPU_COUNT(cpus); eqid = qid % count; /* clear up to the qid'th bit */ for (i = 0; i < eqid; i++) { @@ -5391,20 +5399,14 @@ iflib_msix_init(if_ctx_t ctx) #else queuemsgs = msgs - admincnt; #endif - if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) == 0) { #ifdef RSS - queues = imin(queuemsgs, rss_getnumbuckets()); + queues = imin(queuemsgs, rss_getnumbuckets()); #else - queues = queuemsgs; + queues = queuemsgs; #endif - queues = imin(CPU_COUNT(&ctx->ifc_cpus), queues); - device_printf(dev, "pxm cpus: %d queue msgs: %d admincnt: %d\n", - CPU_COUNT(&ctx->ifc_cpus), queuemsgs, admincnt); - } else { - device_printf(dev, "Unable to fetch CPU list\n"); - /* Figure out a reasonable auto config value */ - queues = min(queuemsgs, mp_ncpus); - } + queues = imin(CPU_COUNT(&ctx->ifc_cpus), queues); + device_printf(dev, "pxm cpus: %d queue msgs: %d admincnt: %d\n", + CPU_COUNT(&ctx->ifc_cpus), queuemsgs, admincnt); #ifdef RSS /* If we're doing RSS, clamp at the number of RSS buckets */ if (queues > rss_getnumbuckets())