diff options
Diffstat (limited to 'drivers/video/tegra/nvmap')
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap.c | 16 | ||||
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_handle.c | 13 |
2 files changed, 24 insertions, 5 deletions
diff --git a/drivers/video/tegra/nvmap/nvmap.c b/drivers/video/tegra/nvmap/nvmap.c index e66ca982f2f3..3329153b2c1b 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; } EXPORT_SYMBOL(nvmap_pin); @@ -624,3 +622,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; +} diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index c1add8383e83..d1d5f267f5c5 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 @@ -905,7 +905,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) @@ -989,6 +989,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) { |