diff --git a/drivers/gpu/nvgpu/Makefile.linux.configs b/drivers/gpu/nvgpu/Makefile.linux.configs index d231e7c91..431e947f1 100644 --- a/drivers/gpu/nvgpu/Makefile.linux.configs +++ b/drivers/gpu/nvgpu/Makefile.linux.configs @@ -35,18 +35,8 @@ CONFIG_NVGPU_HAL_NON_FUSA := y # Support recovery on failure (which may involve engine reset) CONFIG_NVGPU_RECOVERY := y -# Enable support for compression on pre-K6.2 kernels. K6.2+ changes the -# internals of dma-bufs which breaks some hacks we implemented to support -# compression meta-data tracking. For now, on K6.2+ kernels, just disable -# compression. This is a hack that should be fixed. +# Support for compression CONFIG_NVGPU_COMPRESSION := y -ifeq ($(VERSION),6) -ifneq ($(PATCHLEVEL),0) -ifneq ($(PATCHLEVEL),1) -CONFIG_NVGPU_COMPRESSION := n -endif -endif -endif # Enable MIG Support CONFIG_NVGPU_MIG := y diff --git a/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c b/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c index 363ee68d4..7875a6c42 100644 --- a/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c +++ b/drivers/gpu/nvgpu/os/linux/dmabuf_priv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,6 +17,12 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) +#include +#else +#include +#include +#endif #include #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) @@ -100,13 +106,31 @@ static void nvgpu_dma_buf_release(struct dma_buf *dmabuf) dmabuf->ops->release(dmabuf); } +static void gk20a_dma_buf_lock(struct dma_buf *dmabuf) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) + dma_resv_lock(dmabuf->resv, NULL); +#else + ww_mutex_lock(&dmabuf->resv->lock, NULL); +#endif +} + +static void gk20a_dma_buf_unlock(struct dma_buf *dmabuf) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) + dma_resv_unlock(dmabuf->resv); +#else + ww_mutex_unlock(&dmabuf->resv->lock); +#endif +} + /* This function must be called with priv->lock held */ static int gk20a_dma_buf_set_drvdata(struct dma_buf *dmabuf, struct device *device, struct gk20a_dmabuf_priv *priv) { priv->dmabuf = dmabuf; - mutex_lock(&dmabuf->lock); + gk20a_dma_buf_lock(dmabuf); priv->previous_ops = dmabuf->ops; /* * Make a copy of the original ops struct and then update the @@ -115,7 +139,7 @@ static int gk20a_dma_buf_set_drvdata(struct dma_buf *dmabuf, struct device *devi priv->local_ops = *(dmabuf->ops); priv->local_ops.release = nvgpu_dma_buf_release; dmabuf->ops = &priv->local_ops; - mutex_unlock(&dmabuf->lock); + gk20a_dma_buf_unlock(dmabuf); return 0; } @@ -131,11 +155,11 @@ struct gk20a_dmabuf_priv *gk20a_dma_buf_get_drvdata( { struct gk20a_dmabuf_priv *priv = NULL; - mutex_lock(&dmabuf->lock); + gk20a_dma_buf_lock(dmabuf); if (dmabuf->ops->release == nvgpu_dma_buf_release) { priv = dma_buf_ops_to_gk20a_priv((struct dma_buf_ops *)dmabuf->ops); } - mutex_unlock(&dmabuf->lock); + gk20a_dma_buf_unlock(dmabuf); return priv; } @@ -211,9 +235,9 @@ void gk20a_mm_delete_priv(struct gk20a_dmabuf_priv *priv) } /* The original pointer to dma_buf_ops is always put back here*/ - mutex_lock(&dmabuf->lock); + gk20a_dma_buf_lock(dmabuf); dmabuf->ops = priv->previous_ops; - mutex_unlock(&dmabuf->lock); + gk20a_dma_buf_unlock(dmabuf); /* Remove this entry from the global tracking list */ nvgpu_list_del(&priv->list);