gpu: ion: Pull in patches for 3.4
Pull in Ion patches for 3.4 upgrade. Inclues the following
patches from google:
commit 7191e9ba2508ca6f1eaab251cf3f0a2318eebe26
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Mon Jan 30 14:18:08 2012 -0800
ion: Switch map/unmap dma api to sg_tables
Switch these api's from scatterlists to sg_tables
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
commit 6f9e56945d4ee3a2621968caa72b135cb07e49c4
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Tue Jan 31 09:40:30 2012 -0800
ion: Add reserve function to ion
Rather than requiring each platform call memblock_remove or reserve
from the board file, add this to ion
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
commit 9ae7e01de1cf03c77054da44d135a7e85863fcb0
Author: KyongHo Cho <pullip.cho@samsung.com>
Date: Wed Sep 7 11:27:07 2011 +0900
gpu: ion: several bugfixes and enhancements of ION
1. Verifying if the size of memory allocation in ion_alloc() is aligned
by PAGE_SIZE at least. If it is not, this change makes the size to be
aligned by PAGE_SIZE.
2. Unmaps all mappings to the kernel and DMA address spaces when
destroying ion_buffer in ion_buffer_destroy(). This prevents leaks in
those virtual address spaces.
3. Makes the return value of ion_alloc() to be explicit Linux error code
when it fails to allocate a buffer.
4. Makes ion_alloc() implementation simpler. Removes 'goto' statement and
relavant call to ion_buffer_put().
5. Checks if the task is valid before calling put_task_struct() due
to failure on creating a ion client in ion_client_create().
6. Returns error when buffer allocation requested by userspace is failed.
Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
commit 043a61468f395dd6d4fc518299726955e9999c59
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Wed Feb 1 11:09:46 2012 -0800
ion: Switch ion to use dma-buf
Ion now uses dma-buf file descriptors to share
buffers with userspace. Ion becomes a dma-buf
exporter and any driver that can import dma-bufs
can now import ion file descriptors.
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
commit 0d1259b5f84969bd00811ff9faa1c44cdb9fdbb5
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Mon Apr 30 16:45:38 2012 -0700
gpu: ion: Use alloc_pages instead of vmalloc from the system heap
With this change the ion_system_heap will only use kernel address
space when the memory is mapped into the kernel (rare case).
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
commit be4a1ee79a89da3ca705aecc2ac92cbeedd032bd
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Thu Apr 26 20:44:10 2012 -0700
gpu: ion: support begin/end and kmap/kunmap dma_buf ops
These ops were added in the 3.4 kernel. This patch adds support
for them to ion. Previous ion_map/unmap_kernel api is also
retained in addition to this new api.
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
commit 46d71337f9aa84694e4e6cca7f3beb6b033bbf76
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Mon May 7 16:06:32 2012 -0700
gpu: ion: Allocate the sg_table at creation time rather than dynamically
Rather than calling map_dma on the allocations dynamically, this patch
switches to creating the sg_table at the time the buffer is created.
This is necessary because in future updates the sg_table will be used
for cache maintenance.
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
commit 903f6c716db3d4e26952aae9717f81dd5bc9e4ba
Author: Rebecca Schultz Zavin <rebecca@android.com>
Date: Wed May 23 12:55:55 2012 -0700
gpu: ion: Get an sg_table from an ion handle
This patch adds an interface to return and sg_table given a
valid ion handle.
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
The commit also includes fixups needed for MSM specific code.
Change-Id: Idbcfa9d6af0febf06f56daaa6beaa59cc08e4351
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/include/linux/ion.h b/include/linux/ion.h
index fca5517..2519270 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -21,7 +21,6 @@
#include <linux/ioctl.h>
#include <linux/types.h>
-
struct ion_handle;
/**
* enum ion_heap_types - list of all possible types of heaps
@@ -261,6 +260,17 @@
#ifdef CONFIG_ION
/**
+ * ion_reserve() - reserve memory for ion heaps if applicable
+ * @data: platform data specifying starting physical address and
+ * size
+ *
+ * Calls memblock reserve to set aside memory for heaps that are
+ * located at specific memory addresses or of specfic sizes not
+ * managed by the kernel
+ */
+void ion_reserve(struct ion_platform_data *data);
+
+/**
* ion_client_create() - allocate a client and returns it
* @dev: the global ion device
* @heap_mask: mask of heaps this client can allocate from
@@ -323,7 +333,7 @@
* This function queries the heap for a particular handle to get the
* handle's physical address. It't output is only correct if
* a heap returns physically contiguous memory -- in other cases
- * this api should not be implemented -- ion_map_dma should be used
+ * this api should not be implemented -- ion_sg_table should be used
* instead. Returns -EINVAL if the handle is invalid. This has
* no implications on the reference counting of the handle --
* the returned value may not be valid if the caller is not
@@ -333,6 +343,17 @@
ion_phys_addr_t *addr, size_t *len);
/**
+ * ion_map_dma - return an sg_table describing a handle
+ * @client: the client
+ * @handle: the handle
+ *
+ * This function returns the sg_table describing
+ * a particular ion handle.
+ */
+struct sg_table *ion_sg_table(struct ion_client *client,
+ struct ion_handle *handle);
+
+/**
* ion_map_kernel - create mapping for the given handle
* @client: the client
* @handle: handle to map
@@ -353,64 +374,22 @@
void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle);
/**
- * ion_map_dma - create a dma mapping for a given handle
+ * ion_share_dma_buf() - given an ion client, create a dma-buf fd
* @client: the client
- * @handle: handle to map
- *
- * Return an sglist describing the given handle
+ * @handle: the handle
*/
-struct scatterlist *ion_map_dma(struct ion_client *client,
- struct ion_handle *handle,
- unsigned long flags);
+int ion_share_dma_buf(struct ion_client *client, struct ion_handle *handle);
/**
- * ion_unmap_dma() - destroy a dma mapping for a handle
+ * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
* @client: the client
- * @handle: handle to unmap
- */
-void ion_unmap_dma(struct ion_client *client, struct ion_handle *handle);
-
-/**
- * ion_share() - given a handle, obtain a buffer to pass to other clients
- * @client: the client
- * @handle: the handle to share
+ * @fd: the dma-buf fd
*
- * Given a handle, return a buffer, which exists in a global name
- * space, and can be passed to other clients. Should be passed into ion_import
- * to obtain a new handle for this buffer.
- *
- * NOTE: This function does do not an extra reference. The burden is on the
- * caller to make sure the buffer doesn't go away while it's being passed to
- * another client. That is, ion_free should not be called on this handle until
- * the buffer has been imported into the other client.
+ * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
+ * import that fd and return a handle representing it. If a dma-buf from
+ * another exporter is passed in this function will return ERR_PTR(-EINVAL)
*/
-struct ion_buffer *ion_share(struct ion_client *client,
- struct ion_handle *handle);
-
-/**
- * ion_import() - given an buffer in another client, import it
- * @client: this blocks client
- * @buffer: the buffer to import (as obtained from ion_share)
- *
- * Given a buffer, add it to the client and return the handle to use to refer
- * to it further. This is called to share a handle from one kernel client to
- * another.
- */
-struct ion_handle *ion_import(struct ion_client *client,
- struct ion_buffer *buffer);
-
-/**
- * ion_import_fd() - given an fd obtained via ION_IOC_SHARE ioctl, import it
- * @client: this blocks client
- * @fd: the fd
- *
- * A helper function for drivers that will be recieving ion buffers shared
- * with them from userspace. These buffers are represented by a file
- * descriptor obtained as the return from the ION_IOC_SHARE ioctl.
- * This function coverts that fd into the underlying buffer, and returns
- * the handle to use to refer to it further.
- */
-struct ion_handle *ion_import_fd(struct ion_client *client, int fd);
+struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
/**
* ion_handle_get_flags - get the flags for a given handle
@@ -575,6 +554,11 @@
void *vaddr, unsigned long len, unsigned int cmd);
#else
+static inline void ion_reserve(struct ion_platform_data *data)
+{
+
+}
+
static inline struct ion_client *ion_client_create(struct ion_device *dev,
unsigned int heap_mask, const char *name)
{
@@ -605,6 +589,12 @@
return -ENODEV;
}
+static inline struct sg_table *ion_sg_table(struct ion_client *client,
+ struct ion_handle *handle)
+{
+ return ERR_PTR(-ENODEV);
+}
+
static inline void *ion_map_kernel(struct ion_client *client,
struct ion_handle *handle, unsigned long flags)
{
@@ -614,29 +604,12 @@
static inline void ion_unmap_kernel(struct ion_client *client,
struct ion_handle *handle) { }
-static inline struct scatterlist *ion_map_dma(struct ion_client *client,
- struct ion_handle *handle, unsigned long flags)
+static inline int ion_share_dma_buf(struct ion_client *client, struct ion_handle *handle)
{
- return ERR_PTR(-ENODEV);
+ return -ENODEV;
}
-static inline void ion_unmap_dma(struct ion_client *client,
- struct ion_handle *handle) { }
-
-static inline struct ion_buffer *ion_share(struct ion_client *client,
- struct ion_handle *handle)
-{
- return ERR_PTR(-ENODEV);
-}
-
-static inline struct ion_handle *ion_import(struct ion_client *client,
- struct ion_buffer *buffer)
-{
- return ERR_PTR(-ENODEV);
-}
-
-static inline struct ion_handle *ion_import_fd(struct ion_client *client,
- int fd)
+static inline struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
{
return ERR_PTR(-ENODEV);
}