scripts/setup: Handle kenv while looking up contigmem opts

In case contigmem is loaded, but the kernel environment hasn't been
properly updated with hw.contigmem.* options, kenv will fail,
breaking the check to determine if contigmem should be unloaded.

Avoid the above scenario by determining first if given option is
actually set in kernel's environment.

Change-Id: I4118b7622fd876b28f0c07d081c583f5782f0357
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4656
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Michal Berger 2020-10-14 10:36:41 +02:00 committed by Jim Harris
parent 5df2c9a343
commit 1431ea025c

View File

@ -646,7 +646,13 @@ function configure_freebsd() {
# If contigmem is already loaded but the HUGEMEM specified doesn't match the
# previous value, unload contigmem so that we can reload with the new value.
if kldstat -q -m contigmem; then
if [ $(kenv hw.contigmem.num_buffers) -ne "$((HUGEMEM / 256))" ]; then
# contigmem may be loaded, but the kernel environment doesn't have to
# be necessarily set at this point. If it isn't, kenv will fail to
# pick up the hw. options. Handle it.
if ! contigmem_num_buffers=$(kenv hw.contigmem.num_buffers); then
contigmem_num_buffers=-1
fi 2> /dev/null
if ((contigmem_num_buffers != HUGEMEM / 256)); then
kldunload contigmem.ko
fi
fi