From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============2378550566886056532==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 5/6] accel-config: Make idxd_mdev module optional Date: Sat, 23 Jan 2021 00:35:41 -0500 Message-ID: <20210123053542.615622-6-ramesh.thomas@intel.com> In-Reply-To: 20210123053542.615622-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============2378550566886056532== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas Add conditional load and unload of idxd_mdev and make existence of the module optional. Signed-off-by: Ramesh Thomas --- test/libaccfg.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/libaccfg.c b/test/libaccfg.c index 88108a9..031b7fa 100644 --- a/test/libaccfg.c +++ b/test/libaccfg.c @@ -1067,12 +1067,16 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, st= ruct kmod_module **mod, if (rc =3D=3D -ENOENT) rc =3D kmod_module_probe_insert_module(*mdev_mod, 0, NULL, NULL, NULL, NULL); - if (rc >=3D 0) - rc =3D kmod_module_get_initstate(*mod); - if (rc < 0) { - kmod_module_unref(*mod); kmod_module_unref(*mdev_mod); + *mdev_mod =3D NULL; + } + rc =3D kmod_module_get_initstate(*mod); + if (rc =3D=3D -ENOENT) + rc =3D kmod_module_probe_insert_module(*mod, 0, NULL, NULL, NULL, + NULL); + if (rc < 0) { + kmod_module_unref(*mod); kmod_unref(*ctx); } = @@ -1140,10 +1144,13 @@ int test_libaccfg(int loglevel, struct accfg_test *= test, = test_cleanup(ctx); = - kmod_module_remove_module(mdev_mod, 0); - kmod_module_probe_insert_module(mdev_mod, 0, NULL, NULL, NULL, NULL); + if (mdev_mod) { + kmod_module_remove_module(mdev_mod, 0); + kmod_module_unref(mdev_mod); + } + kmod_module_remove_module(mod, 0); + kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); kmod_module_unref(mod); - kmod_module_unref(mdev_mod); kmod_unref(kmod_ctx); = return result; -- = 2.26.2 --===============2378550566886056532==--