diff options
author | Krishna Reddy <vdumpa@nvidia.com> | 2012-01-10 16:46:32 -0800 |
---|---|---|
committer | Rohan Somvanshi <rsomvanshi@nvidia.com> | 2012-01-19 09:53:39 -0800 |
commit | fd155eff25e7946e280c753c4a0b661b850b64c7 (patch) | |
tree | f25a08aa85cf4719e5b602724830efdb5e677370 /drivers/gpu | |
parent | 93baa0571aea8ab4bb923ce07971c64792c2c05a (diff) |
gpu: ion: tegra: Fixes to tegra ion.
Fix print format issues.
Fix NULL pointer handling during unpin.
Change-Id: I2f537928819093d6c50dc7add734136c7078717e
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/74469
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-by: Hiroshi Doyu <hdoyu@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/ion/tegra/tegra_ion.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/drivers/gpu/ion/tegra/tegra_ion.c b/drivers/gpu/ion/tegra/tegra_ion.c index a750a22f404b..65335d265362 100644 --- a/drivers/gpu/ion/tegra/tegra_ion.c +++ b/drivers/gpu/ion/tegra/tegra_ion.c @@ -15,6 +15,8 @@ * */ +#define pr_fmt(fmt) "%s():%d: " fmt, __func__, __LINE__ + #include <linux/err.h> #include <linux/ion.h> #include <linux/tegra_ion.h> @@ -25,6 +27,9 @@ #include <linux/io.h> #include "../ion_priv.h" +#define CLIENT_HEAP_MASK 0xFFFFFFFF +#define HEAP_FLAGS 0xFF + #if !defined(CONFIG_TEGRA_NVMAP) #include "mach/nvmap.h" struct nvmap_device *nvmap_dev; @@ -65,10 +70,12 @@ static int tegra_ion_pin(struct ion_client *client, mutex_lock(&client->lock); for (i = 0; i < data.count; i++) { + /* Ignore NULL pointers during unpin operation. */ + if (!refs[i] && cmd == TEGRA_ION_UNPIN) + continue; valid_handle = ion_handle_validate(client, refs[i]); if (!valid_handle) { - pr_err("invalid handle passed to tegra_ion_pin, h=0x%x", - (u32)refs[i]); + WARN(1, "invalid handle passed h=0x%x", (u32)refs[i]); mutex_unlock(&client->lock); ret = -EINVAL; goto err; @@ -90,14 +97,15 @@ static int tegra_ion_pin(struct ion_client *client, return ret; } } else if (cmd == TEGRA_ION_UNPIN) { - /* FIXME: unpin it. */ - for (i = 0; i < data.count; i++) - ion_handle_put(refs[i]); + for (i = 0; i < data.count; i++) { + if (refs[i]) + ion_handle_put(refs[i]); + } } err: if (ret) { - pr_err("\n*****%s: error, ret=0x%x", __func__, ret); + pr_err("error, ret=0x%x", ret); /* FIXME: undo pinning. */ } if (refs != on_stack) @@ -113,7 +121,6 @@ static int tegra_ion_alloc_from_id(struct ion_client *client, struct ion_buffer *buffer; struct tegra_ion_id_data *user_data = (struct tegra_ion_id_data *)arg; - pr_debug("%s", __func__); if (copy_from_user(&data, (void __user *)arg, sizeof(data))) return -EFAULT; buffer = (struct ion_buffer *)data.id; @@ -142,13 +149,11 @@ static int tegra_ion_get_id(struct ion_client *client, mutex_unlock(&client->lock); if (!valid_handle) { - pr_err("%s: invalid handle passed, h=0x%x\n", - __func__, (u32)data.handle); - WARN("%s: invalid handle passed\n", __func__); + WARN(1, "invalid handle passed\n"); return -EINVAL; } - pr_debug("%s: h=0x%x, b=0x%x, bref=%d", __func__, + pr_debug("h=0x%x, b=0x%x, bref=%d", (u32)data.handle, (u32)data.handle->buffer, atomic_read(&data.handle->buffer->ref.refcount)); if (put_user((unsigned long)ion_handle_buffer(data.handle), @@ -186,7 +191,7 @@ static int tegra_ion_rw(struct ion_client *client, mutex_unlock(&client->lock); if (!valid_handle) { - WARN("%s: invalid handle passed to get id.\n", __func__); + WARN(1, "%s: invalid handle passed to get id.\n", __func__); return -EINVAL; } @@ -202,7 +207,7 @@ static int tegra_ion_rw(struct ion_client *client, while (data.count--) { if (data.offset + data.elem_size > data.handle->buffer->size) { - pr_err("%s: read/write outside of handle\n", __func__); + WARN(1, "read/write outside of handle\n"); ret = -EFAULT; break; } @@ -245,7 +250,7 @@ static int tegra_ion_get_param(struct ion_client *client, mutex_unlock(&client->lock); if (!valid_handle) { - WARN("%s: invalid handle passed to get id.\n", __func__); + WARN(1, "%s: invalid handle passed to get id.\n", __func__); return -EINVAL; } @@ -288,7 +293,7 @@ static long tegra_ion_ioctl(struct ion_client *client, ret = tegra_ion_get_param(client, cmd, arg); break; default: - pr_err("%s: Unknown custom ioctl\n", __func__); + WARN(1, "Unknown custom ioctl\n"); return -ENOTTY; } return ret; @@ -364,13 +369,13 @@ module_exit(ion_exit); struct nvmap_client *nvmap_create_client(struct nvmap_device *dev, const char *name) { - return ion_client_create(dev, 0xFFFFFFFF, name); + return ion_client_create(dev, CLIENT_HEAP_MASK, name); } struct nvmap_handle_ref *nvmap_alloc(struct nvmap_client *client, size_t size, size_t align, unsigned int flags) { - return ion_alloc(client, size, align, 1); + return ion_alloc(client, size, align, HEAP_FLAGS); } void nvmap_free(struct nvmap_client *client, struct nvmap_handle_ref *r) @@ -417,21 +422,19 @@ phys_addr_t nvmap_pin(struct nvmap_client *c, struct nvmap_handle_ref *r) phys_addr_t nvmap_handle_address(struct nvmap_client *c, unsigned long id) { - struct ion_buffer *buffer = (struct ion_buffer *)id; struct ion_handle *handle; ion_phys_addr_t addr; size_t len; - handle = ion_import(c, buffer); + handle = nvmap_convert_handle_u2k(id); ion_phys(c, handle, &addr, &len); - ion_handle_put(handle); return addr; } void nvmap_unpin(struct nvmap_client *client, struct nvmap_handle_ref *r) { - /* FIXME: this should be implemented for iommu heap. */ - ion_handle_put(r); + if (r) + ion_handle_put(r); } static int nvmap_reloc_pin_array(struct ion_client *client, @@ -532,9 +535,9 @@ struct nvmap_handle *nvmap_get_handle_id(struct nvmap_client *client, { struct ion_handle *handle; - handle = (struct ion_handle *)*((unsigned int*)id); - pr_debug("%s: id=0x%x, h=0x%x,c=0x%x", - __func__, (u32)id, (u32)handle, (u32)client); + handle = (struct ion_handle *)nvmap_convert_handle_u2k(id); + pr_debug("id=0x%x, h=0x%x,c=0x%x", + (u32)id, (u32)handle, (u32)client); nvmap_handle_get(handle); return handle; } @@ -546,9 +549,9 @@ struct nvmap_handle_ref *nvmap_duplicate_handle_id(struct nvmap_client *client, struct ion_handle *handle; struct ion_client *ion_client = client; - handle = (struct ion_handle *)*((unsigned int*)id); - pr_debug("%s: id=0x%x, h=0x%x,c=0x%x", - __func__, (u32)id, (u32)handle, (u32)client); + handle = (struct ion_handle *)nvmap_convert_handle_u2k(id); + pr_debug("id=0x%x, h=0x%x,c=0x%x", + (u32)id, (u32)handle, (u32)client); buffer = handle->buffer; handle = ion_handle_create(client, buffer); @@ -557,8 +560,7 @@ struct nvmap_handle_ref *nvmap_duplicate_handle_id(struct nvmap_client *client, ion_handle_add(ion_client, handle); mutex_unlock(&ion_client->lock); - pr_debug("%s: dup id=0x%x, h=0x%x", __func__, - (u32)id, (u32)handle); + pr_debug("dup id=0x%x, h=0x%x", (u32)id, (u32)handle); return handle; } @@ -576,7 +578,7 @@ struct nvmap_handle_ref *nvmap_alloc_iovm(struct nvmap_client *client, void nvmap_free_iovm(struct nvmap_client *client, struct nvmap_handle_ref *r) { - /* FIXME: */ + ion_free(client, r); } struct nvmap_handle *nvmap_handle_get(struct nvmap_handle *h) |