From ae57a78c73413224247f52ae9a6692a5bbc53b5b Mon Sep 17 00:00:00 2001 From: Anup Mahindre Date: Wed, 21 Nov 2018 15:44:52 +0530 Subject: [PATCH] gpu: nvgpu: Return size of ring buffer from NVGPU_CTXSW_IOCTL_RING_SETUP NVGPU_CTXSW_IOCTL_RING_SETUP is used to setup a ring buffer of custom size for FECS tracing. It uses size field from its arguments to setup a user-mapped ring buffer for holding FECS Trace entries. The value from this field is rounded up to nearest page-size boundary. This rounded up value is supposed to be returned by the IOCTL (as per description of the field in nvgpu.h). That is currently not the case and the IOCTL just returns the same value as that was passed. This change fixes this issue by returning updated value. Bug 200469520 Change-Id: I477aefaede9a4cdba921026466db3fb8fbfd0712 Signed-off-by: Anup Mahindre Reviewed-on: https://git-master.nvidia.com/r/1955337 Reviewed-by: Terje Bergstrom Reviewed-by: Deepak Nibade Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/ctxsw_trace.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c b/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c index 7bffae09a..ee970998a 100644 --- a/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c +++ b/drivers/gpu/nvgpu/os/linux/ctxsw_trace.c @@ -170,7 +170,7 @@ static int gk20a_ctxsw_dev_ioctl_trace_disable(struct gk20a_ctxsw_dev *dev) } static int gk20a_ctxsw_dev_alloc_buffer(struct gk20a_ctxsw_dev *dev, - size_t size) + size_t *size) { struct gk20a *g = dev->g; void *buf; @@ -184,14 +184,14 @@ static int gk20a_ctxsw_dev_alloc_buffer(struct gk20a_ctxsw_dev *dev, dev->hdr = NULL; } - err = g->ops.fecs_trace.alloc_user_buffer(g, &buf, &size); + err = g->ops.fecs_trace.alloc_user_buffer(g, &buf, size); if (err) return err; dev->hdr = buf; dev->ents = (struct nvgpu_gpu_ctxsw_trace_entry *) (dev->hdr + 1); - dev->size = size; + dev->size = *size; dev->num_ents = dev->hdr->num_ents; nvgpu_log(g, gpu_dbg_ctxsw, "size=%zu hdr=%p ents=%p num_ents=%d", @@ -244,9 +244,10 @@ static int gk20a_ctxsw_dev_ioctl_ring_setup(struct gk20a_ctxsw_dev *dev, return -EINVAL; nvgpu_mutex_acquire(&dev->write_lock); - ret = gk20a_ctxsw_dev_alloc_buffer(dev, size); + ret = gk20a_ctxsw_dev_alloc_buffer(dev, &size); nvgpu_mutex_release(&dev->write_lock); + args->size = size; return ret; } @@ -366,7 +367,7 @@ int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp) nvgpu_log(g, gpu_dbg_ctxsw, "size=%zu entries=%d ent_size=%zu", size, n, sizeof(struct nvgpu_gpu_ctxsw_trace_entry)); - err = gk20a_ctxsw_dev_alloc_buffer(dev, size); + err = gk20a_ctxsw_dev_alloc_buffer(dev, &size); if (!err) { filp->private_data = dev; nvgpu_log(g, gpu_dbg_ctxsw, "filp=%p dev=%p size=%zu",