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
This commit is contained in:
shurd 2017-11-29 18:14:57 +00:00
parent 1643870966
commit 0de624aa47

View File

@ -4259,6 +4259,14 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
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())