gpu: nvgpu: make buffer metadata support independent of compression

Earlier, buffer metadata support was made dependent on compression.
However that is not required.

Update the enabled flag NVGPU_SUPPORT_BUFFER_METADATA setup for
various hals. Enable it for all from linux characteristics init.

Update REGISTER_BUFFER and GET_BUFFER_INFO ioctls to seggregate
the compile/runtime compression functionality.

If compression is disabled, return error in case comptags are
required else don't fail the REGISTER_BUFFER ioctl.

Bug 200767700

Change-Id: I3850ccc879f180c97b830fb3d652c094b9d28a5b
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2614378
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sagar Kamble
2021-10-21 15:37:06 +05:30
committed by mobile promotions
parent c347b6e4ff
commit 83dbb711bb
11 changed files with 28 additions and 22 deletions

View File

@@ -1928,7 +1928,6 @@ int ga100_init_hal(struct gk20a *g)
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) { if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_POST_L2_COMPRESSION, false); nvgpu_set_enabled(g, NVGPU_SUPPORT_POST_L2_COMPRESSION, false);
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
} else { } else {
gops->cbc.init = NULL; gops->cbc.init = NULL;
gops->cbc.ctrl = NULL; gops->cbc.ctrl = NULL;

View File

@@ -1898,7 +1898,6 @@ int ga10b_init_hal(struct gk20a *g)
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) { if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_POST_L2_COMPRESSION, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_POST_L2_COMPRESSION, true);
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
} else { } else {
gops->cbc.init = NULL; gops->cbc.init = NULL;
gops->cbc.ctrl = NULL; gops->cbc.ctrl = NULL;

View File

@@ -1225,9 +1225,7 @@ int gm20b_init_hal(struct gk20a *g)
#ifdef CONFIG_NVGPU_COMPRESSION #ifdef CONFIG_NVGPU_COMPRESSION
nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true);
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) { if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
} else {
gops->cbc.init = NULL; gops->cbc.init = NULL;
gops->cbc.ctrl = NULL; gops->cbc.ctrl = NULL;
gops->cbc.alloc_comptags = NULL; gops->cbc.alloc_comptags = NULL;

View File

@@ -1318,9 +1318,7 @@ int gp10b_init_hal(struct gk20a *g)
#ifdef CONFIG_NVGPU_COMPRESSION #ifdef CONFIG_NVGPU_COMPRESSION
nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true);
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) { if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
} else {
gops->cbc.init = NULL; gops->cbc.init = NULL;
gops->cbc.ctrl = NULL; gops->cbc.ctrl = NULL;
gops->cbc.alloc_comptags = NULL; gops->cbc.alloc_comptags = NULL;

View File

@@ -1596,9 +1596,7 @@ int gv11b_init_hal(struct gk20a *g)
#ifdef CONFIG_NVGPU_COMPRESSION #ifdef CONFIG_NVGPU_COMPRESSION
nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true);
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) { if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
} else {
gops->cbc.init = NULL; gops->cbc.init = NULL;
gops->cbc.ctrl = NULL; gops->cbc.ctrl = NULL;
gops->cbc.alloc_comptags = NULL; gops->cbc.alloc_comptags = NULL;

View File

@@ -1853,9 +1853,7 @@ int tu104_init_hal(struct gk20a *g)
nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true);
} }
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) { if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
} else {
gops->cbc.init = NULL; gops->cbc.init = NULL;
gops->cbc.ctrl = NULL; gops->cbc.ctrl = NULL;
gops->cbc.alloc_comptags = NULL; gops->cbc.alloc_comptags = NULL;

View File

@@ -1208,7 +1208,6 @@ int vgpu_ga10b_init_hal(struct gk20a *g)
#ifdef CONFIG_NVGPU_COMPRESSION #ifdef CONFIG_NVGPU_COMPRESSION
nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, false); nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, false);
nvgpu_set_enabled(g, NVGPU_SUPPORT_POST_L2_COMPRESSION, false); nvgpu_set_enabled(g, NVGPU_SUPPORT_POST_L2_COMPRESSION, false);
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, false);
#endif #endif
#ifdef CONFIG_NVGPU_RECOVERY #ifdef CONFIG_NVGPU_RECOVERY

View File

@@ -1175,7 +1175,6 @@ int vgpu_gv11b_init_hal(struct gk20a *g)
#ifdef CONFIG_NVGPU_COMPRESSION #ifdef CONFIG_NVGPU_COMPRESSION
nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_COMPRESSION, true);
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
#endif #endif
#ifdef CONFIG_NVGPU_RECOVERY #ifdef CONFIG_NVGPU_RECOVERY

View File

@@ -1917,7 +1917,6 @@ out:
} }
#endif #endif
#ifdef CONFIG_NVGPU_COMPRESSION
static int nvgpu_gpu_ioctl_get_buffer_info(struct gk20a *g, static int nvgpu_gpu_ioctl_get_buffer_info(struct gk20a *g,
struct nvgpu_gpu_get_buffer_info_args *args) struct nvgpu_gpu_get_buffer_info_args *args)
{ {
@@ -1981,10 +1980,13 @@ static int nvgpu_gpu_ioctl_get_buffer_info(struct gk20a *g,
NVGPU_GPU_BUFFER_INFO_FLAGS_METADATA_REGISTERED; NVGPU_GPU_BUFFER_INFO_FLAGS_METADATA_REGISTERED;
} }
if (priv->comptags.enabled) { #ifdef CONFIG_NVGPU_COMPRESSION
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION) &&
priv->comptags.enabled) {
args->out.flags |= args->out.flags |=
NVGPU_GPU_BUFFER_INFO_FLAGS_COMPTAGS_ALLOCATED; NVGPU_GPU_BUFFER_INFO_FLAGS_COMPTAGS_ALLOCATED;
} }
#endif
if (priv->mutable_metadata) { if (priv->mutable_metadata) {
args->out.flags |= args->out.flags |=
@@ -2001,6 +2003,7 @@ out:
return err; return err;
} }
#ifdef CONFIG_NVGPU_COMPRESSION
static int nvgpu_handle_comptags_control(struct gk20a *g, static int nvgpu_handle_comptags_control(struct gk20a *g,
struct dma_buf *dmabuf, struct dma_buf *dmabuf,
struct gk20a_dmabuf_priv *priv, struct gk20a_dmabuf_priv *priv,
@@ -2009,6 +2012,14 @@ static int nvgpu_handle_comptags_control(struct gk20a *g,
struct nvgpu_os_buffer os_buf = {0}; struct nvgpu_os_buffer os_buf = {0};
int err = 0; int err = 0;
if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION)) {
if (comptags_alloc_control == NVGPU_GPU_COMPTAGS_ALLOC_REQUIRED) {
nvgpu_err(g, "Comptags allocation (required) failed. Compression disabled.");
return -EINVAL;
}
return 0;
}
if (comptags_alloc_control == NVGPU_GPU_COMPTAGS_ALLOC_NONE) { if (comptags_alloc_control == NVGPU_GPU_COMPTAGS_ALLOC_NONE) {
if (priv->comptags.allocated) { if (priv->comptags.allocated) {
/* /*
@@ -2060,6 +2071,7 @@ static int nvgpu_handle_comptags_control(struct gk20a *g,
return err; return err;
} }
#endif
static int nvgpu_gpu_ioctl_register_buffer(struct gk20a *g, static int nvgpu_gpu_ioctl_register_buffer(struct gk20a *g,
struct nvgpu_gpu_register_buffer_args *args) struct nvgpu_gpu_register_buffer_args *args)
@@ -2144,6 +2156,7 @@ static int nvgpu_gpu_ioctl_register_buffer(struct gk20a *g,
goto out_priv_unlock; goto out_priv_unlock;
} }
#ifdef CONFIG_NVGPU_COMPRESSION
/* Comptags allocation */ /* Comptags allocation */
err = nvgpu_handle_comptags_control(g, dmabuf, priv, err = nvgpu_handle_comptags_control(g, dmabuf, priv,
args->comptags_alloc_control); args->comptags_alloc_control);
@@ -2151,6 +2164,7 @@ static int nvgpu_gpu_ioctl_register_buffer(struct gk20a *g,
nvgpu_err(g, "Comptags alloc control failed %d", err); nvgpu_err(g, "Comptags alloc control failed %d", err);
goto out_priv_unlock; goto out_priv_unlock;
} }
#endif
/* All done, update metadata blob */ /* All done, update metadata blob */
nvgpu_kfree(g, priv->metadata_blob); nvgpu_kfree(g, priv->metadata_blob);
@@ -2165,10 +2179,14 @@ static int nvgpu_gpu_ioctl_register_buffer(struct gk20a *g,
/* Output variables */ /* Output variables */
args->flags = 0; args->flags = 0;
if (priv->comptags.enabled) {
#ifdef CONFIG_NVGPU_COMPRESSION
if (nvgpu_is_enabled(g, NVGPU_SUPPORT_COMPRESSION) &&
priv->comptags.enabled) {
args->flags |= args->flags |=
NVGPU_GPU_REGISTER_BUFFER_FLAGS_COMPTAGS_ALLOCATED; NVGPU_GPU_REGISTER_BUFFER_FLAGS_COMPTAGS_ALLOCATED;
} }
#endif
nvgpu_log_info(g, "buffer registered: mutable: %s, metadata size: %u, flags: 0x%8x", nvgpu_log_info(g, "buffer registered: mutable: %s, metadata size: %u, flags: 0x%8x",
priv->mutable_metadata ? "yes" : "no", priv->metadata_blob_size, priv->mutable_metadata ? "yes" : "no", priv->metadata_blob_size,
@@ -2182,7 +2200,6 @@ out:
return err; return err;
} }
#endif
long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ {
@@ -2548,7 +2565,6 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg
(struct nvgpu_gpu_set_deterministic_opts_args *)buf); (struct nvgpu_gpu_set_deterministic_opts_args *)buf);
break; break;
#ifdef CONFIG_NVGPU_COMPRESSION
case NVGPU_GPU_IOCTL_REGISTER_BUFFER: case NVGPU_GPU_IOCTL_REGISTER_BUFFER:
err = nvgpu_gpu_ioctl_register_buffer(g, err = nvgpu_gpu_ioctl_register_buffer(g,
(struct nvgpu_gpu_register_buffer_args *)buf); (struct nvgpu_gpu_register_buffer_args *)buf);
@@ -2558,7 +2574,6 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg
err = nvgpu_gpu_ioctl_get_buffer_info(g, err = nvgpu_gpu_ioctl_get_buffer_info(g,
(struct nvgpu_gpu_get_buffer_info_args *)buf); (struct nvgpu_gpu_get_buffer_info_args *)buf);
break; break;
#endif
default: default:
nvgpu_log_info(g, "unrecognized gpu ioctl cmd: 0x%x", cmd); nvgpu_log_info(g, "unrecognized gpu ioctl cmd: 0x%x", cmd);

View File

@@ -330,6 +330,7 @@ void gk20a_init_linux_characteristics(struct gk20a *g)
nvgpu_set_enabled(g, NVGPU_SUPPORT_DETERMINISTIC_OPTS, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_DETERMINISTIC_OPTS, true);
nvgpu_set_enabled(g, NVGPU_SUPPORT_USERSPACE_MANAGED_AS, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_USERSPACE_MANAGED_AS, true);
nvgpu_set_enabled(g, NVGPU_SUPPORT_REMAP, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_REMAP, true);
nvgpu_set_enabled(g, NVGPU_SUPPORT_BUFFER_METADATA, true);
if (!IS_ENABLED(CONFIG_NVGPU_SYNCFD_NONE)) { if (!IS_ENABLED(CONFIG_NVGPU_SYNCFD_NONE)) {
nvgpu_set_enabled(g, NVGPU_SUPPORT_SYNC_FENCE_FDS, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_SYNC_FENCE_FDS, true);

View File

@@ -995,6 +995,8 @@ struct nvgpu_gpu_set_deterministic_opts_args {
* return 0 on success, < 0 in case of failure. * return 0 on success, < 0 in case of failure.
* retval -EINVAL if the enabled flag NVGPU_SUPPORT_BUFFER_METADATA * retval -EINVAL if the enabled flag NVGPU_SUPPORT_BUFFER_METADATA
* isn't set or invalid params. * isn't set or invalid params.
* retval -EINVAL if the enabled flag NVGPU_SUPPORT_COMPRESSION
* isn't set and comptags are required.
* retval -ENOMEM in case of sufficient memory is not available for * retval -ENOMEM in case of sufficient memory is not available for
* privdata or comptags. * privdata or comptags.
* retval -EFAULT if the metadata blob copy fails. * retval -EFAULT if the metadata blob copy fails.