diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c index 5063ba88a..003da143d 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.c +++ b/drivers/gpu/nvgpu/common/linux/cde.c @@ -973,6 +973,10 @@ __releases(&l->cde_app->mutex) struct gk20a *g = &l->g; struct gk20a_cde_ctx *cde_ctx = NULL; struct gk20a_comptags comptags; + struct nvgpu_os_buffer os_buf = { + compbits_scatter_buf, + dev_from_gk20a(g) + }; u64 mapped_compbits_offset = 0; u64 compbits_size = 0; u64 mapped_scatterbuffer_offset = 0; @@ -1103,7 +1107,7 @@ __releases(&l->cde_app->mutex) } /* store source buffer compression tags */ - gk20a_get_comptags(dev_from_gk20a(g), compbits_scatter_buf, &comptags); + gk20a_get_comptags(&os_buf, &comptags); cde_ctx->surf_param_offset = comptags.offset; cde_ctx->surf_param_lines = comptags.lines; diff --git a/drivers/gpu/nvgpu/common/linux/comptags.c b/drivers/gpu/nvgpu/common/linux/comptags.c index 517429d81..f55989f79 100644 --- a/drivers/gpu/nvgpu/common/linux/comptags.c +++ b/drivers/gpu/nvgpu/common/linux/comptags.c @@ -18,12 +18,15 @@ #include +#include + #include "dmabuf.h" -void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, +void gk20a_get_comptags(struct nvgpu_os_buffer *buf, struct gk20a_comptags *comptags) { - struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); + struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, + buf->dev); if (!comptags) return; @@ -37,12 +40,12 @@ void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, } int gk20a_alloc_comptags(struct gk20a *g, - struct device *dev, - struct dma_buf *dmabuf, + struct nvgpu_os_buffer *buf, struct gk20a_comptag_allocator *allocator, u32 lines) { - struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(dmabuf, dev); + struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, + buf->dev); u32 ctaglines_allocsize; u32 offset; int err; diff --git a/drivers/gpu/nvgpu/common/linux/dmabuf.h b/drivers/gpu/nvgpu/common/linux/dmabuf.h index b4b614590..8e6c139b9 100644 --- a/drivers/gpu/nvgpu/common/linux/dmabuf.h +++ b/drivers/gpu/nvgpu/common/linux/dmabuf.h @@ -48,19 +48,6 @@ struct gk20a_dmabuf_priv { u64 buffer_id; }; -/* - * These are implemented in common/linux/comptags.c - these are dmabuf related - * functions though so they are defined here. They cannot be defined in - * since that file must be OS agnostic. - */ -int gk20a_alloc_comptags(struct gk20a *g, - struct device *dev, - struct dma_buf *dmabuf, - struct gk20a_comptag_allocator *allocator, - u32 lines); -void gk20a_get_comptags(struct device *dev, struct dma_buf *dmabuf, - struct gk20a_comptags *comptags); - struct sg_table *gk20a_mm_pin(struct device *dev, struct dma_buf *dmabuf); void gk20a_mm_unpin(struct device *dev, struct dma_buf *dmabuf, struct sg_table *sgt); diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index 006216c26..9178a0b0d 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.c @@ -165,6 +165,7 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm, struct nvgpu_sgt *nvgpu_sgt = NULL; struct sg_table *sgt; struct nvgpu_mapped_buf *mapped_buffer = NULL; + struct nvgpu_os_buffer os_buf = { dmabuf, dev }; enum nvgpu_aperture aperture; bool va_allocated = false; bool clear_ctags = false; @@ -277,11 +278,11 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm, if (!vm->enable_ctag) binfo.ctag_lines = 0; - gk20a_get_comptags(dev, dmabuf, &comptags); + gk20a_get_comptags(&os_buf, &comptags); if (binfo.ctag_lines && !comptags.lines) { /* allocate compression resources if needed */ - err = gk20a_alloc_comptags(g, dev, dmabuf, + err = gk20a_alloc_comptags(g, &os_buf, &g->gr.comp_tags, binfo.ctag_lines); if (err) { @@ -296,8 +297,7 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm, goto clean_up; } } else { - gk20a_get_comptags(dev, - dmabuf, &comptags); + gk20a_get_comptags(&os_buf, &comptags); if (g->ops.ltc.cbc_ctrl) g->ops.ltc.cbc_ctrl(g, gk20a_cbc_op_clear, diff --git a/drivers/gpu/nvgpu/include/nvgpu/comptags.h b/drivers/gpu/nvgpu/include/nvgpu/comptags.h index 6e3062ec3..5482d0ce5 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/comptags.h +++ b/drivers/gpu/nvgpu/include/nvgpu/comptags.h @@ -20,6 +20,7 @@ #include struct gk20a; +struct nvgpu_os_buffer; struct gk20a_comptags { u32 offset; @@ -52,6 +53,17 @@ int gk20a_comptaglines_alloc(struct gk20a_comptag_allocator *allocator, void gk20a_comptaglines_free(struct gk20a_comptag_allocator *allocator, u32 offset, u32 len); +/* + * Defined by OS specific code since comptags are stored in a highly OS specific + * way. + */ +int gk20a_alloc_comptags(struct gk20a *g, + struct nvgpu_os_buffer *buf, + struct gk20a_comptag_allocator *allocator, + u32 lines); +void gk20a_get_comptags(struct nvgpu_os_buffer *buf, + struct gk20a_comptags *comptags); + #endif diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h index dee8fa092..39deeb697 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/vm.h @@ -33,11 +33,17 @@ struct sg_table; struct dma_buf; +struct device; struct vm_gk20a; struct vm_gk20a_mapping_batch; struct nvgpu_vm_area; +struct nvgpu_os_buffer { + struct dma_buf *dmabuf; + struct device *dev; +}; + /* NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL must be set */ int nvgpu_vm_map_linux(struct vm_gk20a *vm, struct dma_buf *dmabuf, diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index 10a7f7ce4..b91b41e43 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h @@ -107,6 +107,12 @@ struct nvgpu_mapped_buf { bool va_allocated; }; +/* + * Defined by each OS. Allows the common VM code do things to the OS specific + * buffer structures. + */ +struct nvgpu_os_buffer; + static inline struct nvgpu_mapped_buf * nvgpu_mapped_buf_from_buffer_list(struct nvgpu_list_node *node) {