提交 9398d41d 编写于 作者: J Jonathan Calmels

Add support for display capability

上级 57a0dd58
......@@ -25,6 +25,7 @@ const struct argp configure_usage = {
{"utility", 'u', NULL, 0, "Enable utility capability", -1},
{"video", 'v', NULL, 0, "Enable video capability", -1},
{"graphics", 'g', NULL, 0, "Enable graphics capability", -1},
{"display", 'D', NULL, 0, "Enable display capability", -1},
{"compat32", 0x80, NULL, 0, "Enable 32bits compatibility", -1},
{"no-cgroups", 0x81, NULL, 0, "Don't use cgroup enforcement", -1},
{"no-devbind", 0x82, NULL, 0, "Don't bind mount devices", -1},
......@@ -88,6 +89,10 @@ configure_parser(int key, char *arg, struct argp_state *state)
if (strjoin(&err, &ctx->container_flags, "graphics", " ") < 0)
goto fatal;
break;
case 'D':
if (strjoin(&err, &ctx->container_flags, "display", " ") < 0)
goto fatal;
break;
case 0x80:
if (strjoin(&err, &ctx->container_flags, "compat32", " ") < 0)
goto fatal;
......
......@@ -330,9 +330,10 @@ lookup_binaries(struct error *err, struct nvc_driver_info *info, const char *roo
static int
lookup_devices(struct error *err, struct nvc_driver_info *info, const char *root, int32_t flags)
{
struct nvc_device_node uvm, uvm_tools, *node;
struct nvc_device_node uvm, uvm_tools, modeset, *node;
int has_uvm = 0;
int has_uvm_tools = 0;
int has_modeset = 0;
if (!(flags & OPT_NO_UVM)) {
if ((has_uvm = find_device_node(err, root, NV_UVM_DEVICE_PATH, &uvm)) < 0)
......@@ -340,8 +341,13 @@ lookup_devices(struct error *err, struct nvc_driver_info *info, const char *root
if ((has_uvm_tools = find_device_node(err, root, NV_UVM_TOOLS_DEVICE_PATH, &uvm_tools)) < 0)
return (-1);
}
if (!(flags & OPT_NO_MODESET)) {
modeset.path = (char *)NV_MODESET_DEVICE_PATH;
modeset.id = makedev(NV_DEVICE_MAJOR, NV_MODESET_DEVICE_MINOR);
has_modeset = 1;
}
info->ndevs = (size_t)(1 + has_uvm + has_uvm_tools);
info->ndevs = (size_t)(1 + has_uvm + has_uvm_tools + has_modeset);
info->devs = node = xcalloc(err, info->ndevs, sizeof(*info->devs));
if (info->devs == NULL)
return (-1);
......@@ -352,6 +358,8 @@ lookup_devices(struct error *err, struct nvc_driver_info *info, const char *root
*(++node) = uvm;
if (has_uvm_tools)
*(++node) = uvm_tools;
if (has_modeset)
*(++node) = modeset;
for (size_t i = 0; i < info->ndevs; ++i)
log_infof("listing device %s", info->devs[i].path);
......
......@@ -24,10 +24,12 @@
#define NV_DEVICE_MAJOR 195
#define NV_CTL_DEVICE_MINOR 255
#define NV_MODESET_DEVICE_MINOR 254
#define NV_DEVICE_PATH _PATH_DEV "nvidia%d"
#define NV_CTL_DEVICE_PATH _PATH_DEV "nvidiactl"
#define NV_UVM_DEVICE_PATH _PATH_DEV "nvidia-uvm"
#define NV_UVM_TOOLS_DEVICE_PATH _PATH_DEV "nvidia-uvm-tools"
#define NV_MODESET_DEVICE_PATH _PATH_DEV "nvidia-modeset"
#define NV_PERSISTENCED_SOCKET _PATH_VARRUN "nvidia-persistenced/socket"
#define NV_MPS_PIPE_DIR _PATH_TMP "nvidia-mps"
#define NV_PROC_DRIVER "/proc/driver/nvidia"
......
......@@ -466,6 +466,9 @@ nvc_driver_mount(struct nvc_context *ctx, const struct nvc_container *cnt, const
/* XXX Only compute libraries require specific devices (e.g. UVM). */
if (!(cnt->flags & OPT_COMPUTE_LIBS) && major(info->devs[i].id) != NV_DEVICE_MAJOR)
continue;
/* XXX Only display capability requires the modeset device. */
if (!(cnt->flags & OPT_DISPLAY) && minor(info->devs[i].id) == NV_MODESET_DEVICE_MINOR)
continue;
if (!(cnt->flags & OPT_NO_DEVBIND)) {
if ((*ptr++ = mount_device(&ctx->err, ctx->cfg.root, cnt, &info->devs[i])) == NULL)
goto fail;
......
......@@ -29,13 +29,15 @@ static const char * const default_library_opts = "";
enum {
OPT_NO_GLVND = 1 << 0,
OPT_NO_UVM = 1 << 1,
OPT_NO_MPS = 1 << 2,
OPT_NO_PERSISTENCED = 1 << 3,
OPT_NO_MODESET = 1 << 2,
OPT_NO_MPS = 1 << 3,
OPT_NO_PERSISTENCED = 1 << 4,
};
static const struct option driver_opts[] = {
{"no-glvnd", OPT_NO_GLVND},
{"no-uvm", OPT_NO_UVM},
{"no-modeset", OPT_NO_MODESET},
{"no-mps", OPT_NO_MPS},
{"no-persistenced", OPT_NO_PERSISTENCED},
};
......@@ -57,12 +59,13 @@ enum {
OPT_COMPUTE_LIBS = 1 << 5,
OPT_VIDEO_LIBS = 1 << 6,
OPT_GRAPHICS_LIBS = 1 << 7,
OPT_UTILITY_BINS = 1 << 8,
OPT_COMPUTE_BINS = 1 << 9,
OPT_DISPLAY = 1 << 8,
OPT_UTILITY_BINS = 1 << 9,
OPT_COMPUTE_BINS = 1 << 10,
#if defined(__powerpc64__) /* ppc64le doesn't support compat32. */
OPT_COMPAT32 = 1 << 0,
#else
OPT_COMPAT32 = 1 << 10,
OPT_COMPAT32 = 1 << 11,
#endif /* defined(__powerpc64__) */
};
......@@ -75,6 +78,7 @@ static const struct option container_opts[] = {
{"compute", OPT_COMPUTE_BINS|OPT_COMPUTE_LIBS},
{"video", OPT_VIDEO_LIBS|OPT_COMPUTE_LIBS},
{"graphics", OPT_GRAPHICS_LIBS},
{"display", OPT_DISPLAY|OPT_GRAPHICS_LIBS},
{"compat32", OPT_COMPAT32},
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册