Skip to content

Commit 1f2ad79

Browse files
committed
Add no-create-imex-channels command line option
This change adds a no-create-imex-channels command line option to opt-out of the creation of imex channel device nodes. Note that the creation of device nodes is only triggered if --load-kmods is specified. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 4ef6252 commit 1f2ad79

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/cli/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static struct argp usage = {
3232
{"user", 'u', "UID[:GID]", OPTION_ARG_OPTIONAL, "User and group to use for privilege separation", -1},
3333
{"root", 'r', "PATH", 0, "Path to the driver root directory", -1},
3434
{"ldcache", 'l', "FILE", 0, "Path to the system's DSO cache", -1},
35+
{"no-create-imex-channels", 0x80, NULL, 0, "Don't automatically create IMEX channel device nodes", -1},
3536
{NULL, 0, NULL, 0, "Commands:", 0},
3637
{"info", 0, NULL, OPTION_DOC|OPTION_NO_USAGE, "Report information about the driver and devices", 0},
3738
{"list", 0, NULL, OPTION_DOC|OPTION_NO_USAGE, "List driver components", 0},
@@ -112,6 +113,10 @@ parser(int key, char *arg, struct argp_state *state)
112113
case 'l':
113114
ctx->ldcache = arg;
114115
break;
116+
case 0x80:
117+
if (str_join(&err, &ctx->init_flags, "no-create-imex-channels", " ") < 0)
118+
goto fatal;
119+
break;
115120
case ARGP_KEY_ARGS:
116121
state->argv += state->next;
117122
state->argc -= state->next;

src/nvc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "xfuncs.h"
3434

3535
static int init_within_userns(struct error *);
36-
static int load_kernel_modules(struct error *, const char *, const struct nvc_imex_info *);
36+
static int load_kernel_modules(struct error *, const char *, const struct nvc_imex_info *, int32_t);
3737
static int copy_config(struct error *, struct nvc_context *, const struct nvc_config *);
3838

3939
const char interpreter[] __attribute__((section(".interp"))) = LIB_DIR "/" LD_SO;
@@ -229,7 +229,7 @@ mig_nvcaps_mknodes(struct error *err, int num_gpus) {
229229
}
230230

231231
static int
232-
load_kernel_modules(struct error *err, const char *root, const struct nvc_imex_info *imex)
232+
load_kernel_modules(struct error *err, const char *root, const struct nvc_imex_info *imex, int32_t flags)
233233
{
234234
int userns;
235235
pid_t pid;
@@ -290,10 +290,13 @@ load_kernel_modules(struct error *err, const char *root, const struct nvc_imex_i
290290
log_info("running mknod for all nvcaps in " NV_CAPS_DEVICE_DIR);
291291
if (mig_nvcaps_mknodes(err, devs.num_matches) < 0)
292292
log_errf("could not create kernel module device nodes: %s", err->msg);
293-
for (int i = 0; i < (int)imex->nchans; ++i) {
294-
log_infof("running mknod for " NV_CAPS_IMEX_DEVICE_PATH, imex->chans[i].id);
295-
if (nvidia_cap_imex_channel_mknod(imex->chans[i].id) == 0)
296-
log_errf("could not mknod for IMEX channel %d", imex->chans[i].id);
293+
294+
if (!(flags & OPT_NO_CREATE_IMEX_CHANNELS)) {
295+
for (int i = 0; i < (int)imex->nchans; ++i) {
296+
log_infof("running mknod for " NV_CAPS_IMEX_DEVICE_PATH, imex->chans[i].id);
297+
if (nvidia_cap_imex_channel_mknod(imex->chans[i].id) == 0)
298+
log_errf("could not mknod for IMEX channel %d", imex->chans[i].id);
299+
}
297300
}
298301
error_reset(err);
299302
}
@@ -420,7 +423,7 @@ nvc_init(struct nvc_context *ctx, const struct nvc_config *cfg, const char *opts
420423
if (flags & OPT_LOAD_KMODS) {
421424
if (ctx->dxcore.initialized)
422425
log_warn("skipping kernel modules load on WSL");
423-
else if (load_kernel_modules(&ctx->err, ctx->cfg.root, &ctx->cfg.imex) < 0)
426+
else if (load_kernel_modules(&ctx->err, ctx->cfg.root, &ctx->cfg.imex, flags) < 0)
424427
goto fail;
425428
}
426429

src/options.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ struct option {
1616

1717
/* Library options */
1818
enum {
19-
OPT_LOAD_KMODS = 1 << 0,
19+
OPT_LOAD_KMODS = 1 << 0,
20+
OPT_NO_CREATE_IMEX_CHANNELS = 1 << 1,
2021
};
2122

2223
static const struct option library_opts[] = {
2324
{"load-kmods", OPT_LOAD_KMODS},
25+
{"no-create-imex-channels", OPT_NO_CREATE_IMEX_CHANNELS}
2426
};
2527

2628
static const char * const default_library_opts = "";

0 commit comments

Comments
 (0)