From d633a68ac0c4758927bc436142c196421287d10a Mon Sep 17 00:00:00 2001 From: pdabade Date: Thu, 12 Dec 2013 16:09:30 +0530 Subject: video: tegra: fb: Update and synchronize dc window Update and synchronize DC window after enabling DC while unblanking. bug 1416339 Change-Id: I404004e1cbb3908cceade8aa033a660dc488d400 Signed-off-by: Pankaj Dabade Reviewed-on: http://git-master/r/344778 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bibek Basu Reviewed-by: Jong Kim Reviewed-by: Matthew Pedro Tested-by: Matthew Pedro --- drivers/video/tegra/fb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/video/tegra') diff --git a/drivers/video/tegra/fb.c b/drivers/video/tegra/fb.c index f69048f62cc2..e5ddfd503301 100644 --- a/drivers/video/tegra/fb.c +++ b/drivers/video/tegra/fb.c @@ -6,7 +6,7 @@ * Colin Cross * Travis Geiselbrecht * - * Copyright (c) 2010-2012, NVIDIA CORPORATION, All rights reserved. + * Copyright (c) 2010-2013, NVIDIA CORPORATION, All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -284,6 +284,8 @@ static int tegra_fb_blank(int blank, struct fb_info *info) dev_dbg(&tegra_fb->ndev->dev, "unblank\n"); tegra_fb->win->flags = TEGRA_WIN_FLAG_ENABLED; tegra_dc_enable(tegra_fb->win->dc); + tegra_dc_update_windows(&tegra_fb->win, 1); + tegra_dc_sync_windows(&tegra_fb->win, 1); return 0; case FB_BLANK_NORMAL: -- cgit v1.2.3 From 95c7d5a8c9fc4c4d6326d608723237ed197b893a Mon Sep 17 00:00:00 2001 From: pdabade Date: Tue, 10 Dec 2013 10:42:01 +0530 Subject: video: tegra: hdmi: validate variable screeninfo verify variable screeninfo by checking xres and yres before validating aspect ratio. bug 1417318 Change-Id: I473f3e2f30888c053ca53559e33355f216d2a8d3 Signed-off-by: Pankaj Dabade Reviewed-on: http://git-master/r/340236 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Jong Kim Reviewed-by: Jon Mayo Reviewed-by: Matthew Pedro --- drivers/video/tegra/dc/hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/video/tegra') diff --git a/drivers/video/tegra/dc/hdmi.c b/drivers/video/tegra/dc/hdmi.c index 55d9163d4faf..f3fcf2e2ee09 100644 --- a/drivers/video/tegra/dc/hdmi.c +++ b/drivers/video/tegra/dc/hdmi.c @@ -4,7 +4,7 @@ * Copyright (C) 2010 Google, Inc. * Author: Erik Gilling * - * Copyright (c) 2010-2012, NVIDIA CORPORATION, All rights reserved. + * Copyright (c) 2010-2013, NVIDIA CORPORATION, All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -1259,7 +1259,8 @@ static bool tegra_dc_hdmi_valid_asp_ratio(const struct tegra_dc *dc, int s_aspratio = 0; /* To check the aspect upto two decimal digits, calculate in % */ - m_aspratio = (mode->xres*100 / mode->yres); + if (mode->yres) + m_aspratio = (mode->xres*100 / mode->yres); if ((m_aspratio < TEGRA_DC_HDMI_MIN_ASPECT_RATIO_PERCENT) || (m_aspratio > TEGRA_DC_HDMI_MAX_ASPECT_RATIO_PERCENT)) -- cgit v1.2.3 From d283f029d9b971f93f6f4b0e62d3cacb2571a204 Mon Sep 17 00:00:00 2001 From: Rahool Paliwal Date: Mon, 9 Dec 2013 18:07:05 +0530 Subject: media: nvmap: Allow access to videobuf2-dma-nvmap Allow the "user" nvmap client to access the nvmap memory handle of "videobuf2-dma-nvmap" client. Bug 1421388 Change-Id: Id7a28c06214508d807098a6b258345023192a601 Signed-off-by: Rahool Paliwal Reviewed-on: http://git-master/r/344620 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Matthew Pedro --- drivers/video/tegra/nvmap/nvmap_handle.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/video/tegra') diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index 4b7760b22190..1c5e61ccd45d 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -3,7 +3,7 @@ * * Handle allocation and freeing routines for nvmap * - * Copyright (c) 2009-2012, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2009-2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -988,6 +988,15 @@ struct nvmap_handle_ref *nvmap_duplicate_handle_id(struct nvmap_client *client, BUG_ON(!client || client->dev != nvmap_dev); /* on success, the reference count for the handle should be * incremented, so the success paths will not call nvmap_handle_put */ + + /* Allow the handle to be accessed by other (non-owner) + clients only if the owner is "videobuf2-dma-nvmap + which is a V4L2 capture kernel module. This handle can + be accessed by the "user" client for rendering/encoding */ + if (!strcmp(((struct nvmap_handle *)id)->owner->name, + "videobuf2-dma-nvmap")) + client = ((struct nvmap_handle *)id)->owner; + h = nvmap_validate_get(client, id); if (!h) { -- cgit v1.2.3 From 30f8d578556191ac90ca5d1ec4cba5f05cd690ce Mon Sep 17 00:00:00 2001 From: Bibek Basu Date: Tue, 8 Jul 2014 14:24:49 +0530 Subject: video: tegra: nvhost: validate nvmap_handle_ref nvhost_job_unpin should always get the nvmap_handle_ref from rb_entry after validating handle and presence in the tree. Bug 1478467 Change-Id: Ibf5f64a1a82fea8adbf7500bdb36b76357776448 Signed-off-by: Bibek Basu Reviewed-on: http://git-master/r/436076 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Venkat Moganty Reviewed-by: Matthew Pedro --- drivers/video/tegra/host/nvhost_job.c | 9 ++++++--- drivers/video/tegra/host/nvmap.c | 11 ++++++++++- drivers/video/tegra/host/nvmap.h | 5 +++-- drivers/video/tegra/nvmap/nvmap.c | 16 +++++++++++++--- 4 files changed, 32 insertions(+), 9 deletions(-) (limited to 'drivers/video/tegra') diff --git a/drivers/video/tegra/host/nvhost_job.c b/drivers/video/tegra/host/nvhost_job.c index f0f7e64d4504..5587f51ea996 100644 --- a/drivers/video/tegra/host/nvhost_job.c +++ b/drivers/video/tegra/host/nvhost_job.c @@ -3,7 +3,7 @@ * * Tegra Graphics Host Job * - * Copyright (c) 2010-2012, NVIDIA Corporation. + * Copyright (c) 2010-2014, 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, @@ -30,6 +30,7 @@ #include "dev.h" #include "nvhost_memmgr.h" #include "chip_support.h" +#include "nvmap.h" /* Magic to use to fill freed handle slots */ #define BAD_MAGIC 0xdeadbeef @@ -327,8 +328,10 @@ void nvhost_job_unpin(struct nvhost_job *job) int i; for (i = 0; i < job->num_unpins; i++) { - mem_op().unpin(job->memmgr, job->unpins[i]); - mem_op().put(job->memmgr, job->unpins[i]); + struct mem_handle *handle; + handle = nvhost_nvmap_validate_ref(job->memmgr, job->unpins[i]); + mem_op().unpin(job->memmgr, handle); + mem_op().put(job->memmgr, handle); } memset(job->unpins, BAD_MAGIC, diff --git a/drivers/video/tegra/host/nvmap.c b/drivers/video/tegra/host/nvmap.c index fd82f40c59ff..b8361c4a1a36 100644 --- a/drivers/video/tegra/host/nvmap.c +++ b/drivers/video/tegra/host/nvmap.c @@ -3,7 +3,7 @@ * * Tegra Graphics Host Nvmap support * - * Copyright (c) 2012, NVIDIA Corporation. + * Copyright (c) 2012-2014, 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, @@ -82,6 +82,15 @@ struct mem_handle *nvhost_nvmap_get(struct mem_mgr *mgr, u32 id) nvmap_duplicate_handle_id((struct nvmap_client *)mgr, id); } +struct mem_handle *nvhost_nvmap_validate_ref(struct mem_mgr *mgr, + struct mem_handle *handle) +{ + unsigned long ref; + ref = nvmap_validate_ref((struct nvmap_client *)mgr, + (struct nvmap_handle_ref *)handle); + return (struct mem_handle *)ref; +} + int nvhost_init_nvmap_support(struct nvhost_chip_support *chip) { chip->mem.alloc_mgr = nvhost_nvmap_alloc_mgr; diff --git a/drivers/video/tegra/host/nvmap.h b/drivers/video/tegra/host/nvmap.h index 90f64d44f434..25e3535ce544 100644 --- a/drivers/video/tegra/host/nvmap.h +++ b/drivers/video/tegra/host/nvmap.h @@ -3,7 +3,7 @@ * * Tegra Graphics Host nvmap memory manager * - * Copyright (c) 2010-2012, NVIDIA Corporation. + * Copyright (c) 2010-2014, 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, @@ -23,5 +23,6 @@ struct nvhost_chip_support; int nvhost_init_nvmap_support(struct nvhost_chip_support *op); - +struct mem_handle *nvhost_nvmap_validate_ref(struct mem_mgr *mgr, + struct mem_handle *handle); #endif diff --git a/drivers/video/tegra/nvmap/nvmap.c b/drivers/video/tegra/nvmap/nvmap.c index 19b821d41284..07463f78d4c0 100644 --- a/drivers/video/tegra/nvmap/nvmap.c +++ b/drivers/video/tegra/nvmap/nvmap.c @@ -3,7 +3,7 @@ * * Memory manager for Tegra GPU * - * Copyright (c) 2009-2012, NVIDIA Corporation. + * Copyright (c) 2009-2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -366,7 +366,6 @@ phys_addr_t nvmap_pin(struct nvmap_client *client, h = nvmap_handle_get(ref->handle); if (WARN_ON(!h)) return -EINVAL; - atomic_inc(&ref->pin); if (WARN_ON(mutex_lock_interruptible(&client->share->pin_lock))) { @@ -384,7 +383,6 @@ phys_addr_t nvmap_pin(struct nvmap_client *client, map_iovmm_area(h); phys = handle_phys(h); } - return ret ?: phys; } @@ -618,3 +616,15 @@ int nvmap_mark_global(struct nvmap_client *client, struct nvmap_handle_ref *r) return 0; } + +unsigned long nvmap_validate_ref(struct nvmap_client *client, + struct nvmap_handle_ref *r) +{ + struct nvmap_handle_ref *ref; + unsigned long id = nvmap_ref_to_id(r); + + nvmap_ref_lock(client); + ref = _nvmap_validate_id_locked(client, id); + nvmap_ref_unlock(client); + return (unsigned long)ref; +} -- cgit v1.2.3 From 8a370a3b55ee8750167174238ce316900409f558 Mon Sep 17 00:00:00 2001 From: Bibek Basu Date: Wed, 30 Jul 2014 11:57:09 +0530 Subject: video: tegra: host: power module before access There could be race in refcount update leading to access of module registers without enabling the clock and power.This patch tries to catch such instances and enables power. Bug 1478467 Change-Id: Ia32da44bfcd7838e312815b6261ccadf4470a761 Signed-off-by: Bibek Basu Reviewed-on: http://git-master/r/448701 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Venkat Moganty Reviewed-by: Matthew Pedro --- drivers/video/tegra/host/nvhost_acm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/video/tegra') diff --git a/drivers/video/tegra/host/nvhost_acm.c b/drivers/video/tegra/host/nvhost_acm.c index 5bde55ad2ff5..fcedb5c1a2c8 100644 --- a/drivers/video/tegra/host/nvhost_acm.c +++ b/drivers/video/tegra/host/nvhost_acm.c @@ -3,7 +3,7 @@ * * Tegra Graphics Host Automatic Clock Management * - * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2010-2014, 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, @@ -219,8 +219,11 @@ void nvhost_module_busy(struct nvhost_device *dev) cancel_delayed_work(&dev->powerstate_down); dev->refcount++; - if (dev->refcount > 0 && !nvhost_module_powered(dev)) + if (unlikely(dev->refcount <= 0)) + pr_err("unbalanced refcount %d\n", dev->refcount); + if (!nvhost_module_powered(dev)) to_state_running_locked(dev); + mutex_unlock(&dev->lock); } -- cgit v1.2.3 From bc4bd19dd6e9de8518a784753d7b69224be0b9f6 Mon Sep 17 00:00:00 2001 From: Bibek Basu Date: Fri, 1 Aug 2014 11:29:19 +0530 Subject: nvmap: fix test condition to avoid infinite loop Make sure that we dont enter infinite loop due to negative value of pins in some cases. Also remove debugging check for refcount. Bug 1478467 Change-Id: I7df8efa5b3cf8927a0c18363add4f031aca48e48 Signed-off-by: Bibek Basu Reviewed-on: http://git-master/r/450209 Reviewed-by: Matthew Pedro Tested-by: Matthew Pedro --- drivers/video/tegra/host/nvhost_acm.c | 4 +--- drivers/video/tegra/nvmap/nvmap_handle.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/video/tegra') diff --git a/drivers/video/tegra/host/nvhost_acm.c b/drivers/video/tegra/host/nvhost_acm.c index fcedb5c1a2c8..edf9286566b4 100644 --- a/drivers/video/tegra/host/nvhost_acm.c +++ b/drivers/video/tegra/host/nvhost_acm.c @@ -219,9 +219,7 @@ void nvhost_module_busy(struct nvhost_device *dev) cancel_delayed_work(&dev->powerstate_down); dev->refcount++; - if (unlikely(dev->refcount <= 0)) - pr_err("unbalanced refcount %d\n", dev->refcount); - if (!nvhost_module_powered(dev)) + if (dev->refcount > 0 && !nvhost_module_powered(dev)) to_state_running_locked(dev); mutex_unlock(&dev->lock); diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index 1c5e61ccd45d..1a6aec5ae998 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -904,7 +904,7 @@ void nvmap_free_handle_id(struct nvmap_client *client, unsigned long id) nvmap_err(client, "%s freeing pinned handle %p\n", current->group_leader->comm, h); - while (pins--) + while (pins-- > 0) nvmap_unpin_handles(client, &ref->handle, 1); if (h->owner == client) -- cgit v1.2.3