This repository has been archived by the owner on Oct 5, 2018. It is now read-only.
forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'working-hikey960-upstream-ion' into working-hikey960-up…
…stream-rebase-v4.14-rc7-2017-11-03-18-10-36 * working-hikey960-upstream-ion: HACK: ion: Revert ION to 4.11 era code to avoid ABI break
- Loading branch information
Showing
27 changed files
with
3,295 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,23 @@ TODO: | |
|
||
|
||
ion/ | ||
- Add dt-bindings for remaining heaps (chunk and carveout heaps). This would | ||
involve putting appropriate bindings in a memory node for Ion to find. | ||
- Split /dev/ion up into multiple nodes (e.g. /dev/ion/heap0) | ||
- Better test framework (integration with VGEM was suggested) | ||
- Remove ION_IOC_SYNC: Flushing for devices should be purely a kernel internal | ||
interface on top of dma-buf. flush_for_device needs to be added to dma-buf | ||
first. | ||
- Remove ION_IOC_CUSTOM: Atm used for cache flushing for cpu access in some | ||
vendor trees. Should be replaced with an ioctl on the dma-buf to expose the | ||
begin/end_cpu_access hooks to userspace. | ||
- Clarify the tricks ion plays with explicitly managing coherency behind the | ||
dma api's back (this is absolutely needed for high-perf gpu drivers): Add an | ||
explicit coherency management mode to flush_for_device to be used by drivers | ||
which want to manage caches themselves and which indicates whether cpu caches | ||
need flushing. | ||
- With those removed there's probably no use for ION_IOC_IMPORT anymore either | ||
since ion would just be the central allocator for shared buffers. | ||
- Add dt-binding to expose cma regions as ion heaps, with the rule that any | ||
such cma regions must already be used by some device for dma. I.e. ion only | ||
exposes existing cma regions and doesn't reserve unecessarily memory when | ||
booting a system which doesn't use ion. | ||
|
||
Please send patches to Greg Kroah-Hartman <[email protected]> and Cc: | ||
Arve Hjønnevåg <[email protected]> and Riley Andrews <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
obj-$(CONFIG_ION) += ion.o ion-ioctl.o ion_heap.o | ||
obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o | ||
obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o | ||
obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o | ||
obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o | ||
obj-$(CONFIG_ION) += ion.o ion-ioctl.o ion_heap.o \ | ||
ion_page_pool.o ion_system_heap.o \ | ||
ion_carveout_heap.o ion_chunk_heap.o ion_cma_heap.o | ||
obj-$(CONFIG_ION_TEST) += ion_test.o | ||
ifdef CONFIG_COMPAT | ||
obj-$(CONFIG_ION) += compat_ion.o | ||
endif | ||
|
||
obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o | ||
obj-$(CONFIG_ION_TEGRA) += tegra/ | ||
obj-$(CONFIG_ION_HISI) += hisilicon/ | ||
obj-$(CONFIG_ION_OF) += ion_of.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
/* | ||
* drivers/staging/android/ion/compat_ion.c | ||
* | ||
* Copyright (C) 2013 Google, Inc. | ||
* | ||
* This software is licensed under the terms of the GNU General Public | ||
* License version 2, as published by the Free Software Foundation, and | ||
* may be copied, distributed, and modified under those terms. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
#include <linux/compat.h> | ||
#include <linux/fs.h> | ||
#include <linux/uaccess.h> | ||
|
||
#include "ion.h" | ||
#include "compat_ion.h" | ||
|
||
/* See drivers/staging/android/uapi/ion.h for the definition of these structs */ | ||
struct compat_ion_allocation_data { | ||
compat_size_t len; | ||
compat_size_t align; | ||
compat_uint_t heap_id_mask; | ||
compat_uint_t flags; | ||
compat_int_t handle; | ||
}; | ||
|
||
struct compat_ion_custom_data { | ||
compat_uint_t cmd; | ||
compat_ulong_t arg; | ||
}; | ||
|
||
struct compat_ion_handle_data { | ||
compat_int_t handle; | ||
}; | ||
|
||
#define COMPAT_ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ | ||
struct compat_ion_allocation_data) | ||
#define COMPAT_ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, \ | ||
struct compat_ion_handle_data) | ||
#define COMPAT_ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, \ | ||
struct compat_ion_custom_data) | ||
|
||
static int compat_get_ion_allocation_data( | ||
struct compat_ion_allocation_data __user *data32, | ||
struct ion_allocation_data __user *data) | ||
{ | ||
compat_size_t s; | ||
compat_uint_t u; | ||
compat_int_t i; | ||
int err; | ||
|
||
err = get_user(s, &data32->len); | ||
err |= put_user(s, &data->len); | ||
err |= get_user(s, &data32->align); | ||
err |= put_user(s, &data->align); | ||
err |= get_user(u, &data32->heap_id_mask); | ||
err |= put_user(u, &data->heap_id_mask); | ||
err |= get_user(u, &data32->flags); | ||
err |= put_user(u, &data->flags); | ||
err |= get_user(i, &data32->handle); | ||
err |= put_user(i, &data->handle); | ||
|
||
return err; | ||
} | ||
|
||
static int compat_get_ion_handle_data( | ||
struct compat_ion_handle_data __user *data32, | ||
struct ion_handle_data __user *data) | ||
{ | ||
compat_int_t i; | ||
int err; | ||
|
||
err = get_user(i, &data32->handle); | ||
err |= put_user(i, &data->handle); | ||
|
||
return err; | ||
} | ||
|
||
static int compat_put_ion_allocation_data( | ||
struct compat_ion_allocation_data __user *data32, | ||
struct ion_allocation_data __user *data) | ||
{ | ||
compat_size_t s; | ||
compat_uint_t u; | ||
compat_int_t i; | ||
int err; | ||
|
||
err = get_user(s, &data->len); | ||
err |= put_user(s, &data32->len); | ||
err |= get_user(s, &data->align); | ||
err |= put_user(s, &data32->align); | ||
err |= get_user(u, &data->heap_id_mask); | ||
err |= put_user(u, &data32->heap_id_mask); | ||
err |= get_user(u, &data->flags); | ||
err |= put_user(u, &data32->flags); | ||
err |= get_user(i, &data->handle); | ||
err |= put_user(i, &data32->handle); | ||
|
||
return err; | ||
} | ||
|
||
static int compat_get_ion_custom_data( | ||
struct compat_ion_custom_data __user *data32, | ||
struct ion_custom_data __user *data) | ||
{ | ||
compat_uint_t cmd; | ||
compat_ulong_t arg; | ||
int err; | ||
|
||
err = get_user(cmd, &data32->cmd); | ||
err |= put_user(cmd, &data->cmd); | ||
err |= get_user(arg, &data32->arg); | ||
err |= put_user(arg, &data->arg); | ||
|
||
return err; | ||
}; | ||
|
||
long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | ||
{ | ||
long ret; | ||
|
||
if (!filp->f_op->unlocked_ioctl) | ||
return -ENOTTY; | ||
|
||
switch (cmd) { | ||
case COMPAT_ION_IOC_ALLOC: | ||
{ | ||
struct compat_ion_allocation_data __user *data32; | ||
struct ion_allocation_data __user *data; | ||
int err; | ||
|
||
data32 = compat_ptr(arg); | ||
data = compat_alloc_user_space(sizeof(*data)); | ||
if (!data) | ||
return -EFAULT; | ||
|
||
err = compat_get_ion_allocation_data(data32, data); | ||
if (err) | ||
return err; | ||
ret = filp->f_op->unlocked_ioctl(filp, ION_IOC_ALLOC, | ||
(unsigned long)data); | ||
err = compat_put_ion_allocation_data(data32, data); | ||
return ret ? ret : err; | ||
} | ||
case COMPAT_ION_IOC_FREE: | ||
{ | ||
struct compat_ion_handle_data __user *data32; | ||
struct ion_handle_data __user *data; | ||
int err; | ||
|
||
data32 = compat_ptr(arg); | ||
data = compat_alloc_user_space(sizeof(*data)); | ||
if (!data) | ||
return -EFAULT; | ||
|
||
err = compat_get_ion_handle_data(data32, data); | ||
if (err) | ||
return err; | ||
|
||
return filp->f_op->unlocked_ioctl(filp, ION_IOC_FREE, | ||
(unsigned long)data); | ||
} | ||
case COMPAT_ION_IOC_CUSTOM: { | ||
struct compat_ion_custom_data __user *data32; | ||
struct ion_custom_data __user *data; | ||
int err; | ||
|
||
data32 = compat_ptr(arg); | ||
data = compat_alloc_user_space(sizeof(*data)); | ||
if (!data) | ||
return -EFAULT; | ||
|
||
err = compat_get_ion_custom_data(data32, data); | ||
if (err) | ||
return err; | ||
|
||
return filp->f_op->unlocked_ioctl(filp, ION_IOC_CUSTOM, | ||
(unsigned long)data); | ||
} | ||
case ION_IOC_SHARE: | ||
case ION_IOC_MAP: | ||
case ION_IOC_IMPORT: | ||
case ION_IOC_SYNC: | ||
return filp->f_op->unlocked_ioctl(filp, cmd, | ||
(unsigned long)compat_ptr(arg)); | ||
default: | ||
return -ENOIOCTLCMD; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* drivers/staging/android/ion/compat_ion.h | ||
* | ||
* Copyright (C) 2013 Google, Inc. | ||
* | ||
* This software is licensed under the terms of the GNU General Public | ||
* License version 2, as published by the Free Software Foundation, and | ||
* may be copied, distributed, and modified under those terms. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
#ifndef _LINUX_COMPAT_ION_H | ||
#define _LINUX_COMPAT_ION_H | ||
|
||
#if IS_ENABLED(CONFIG_COMPAT) | ||
|
||
long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); | ||
|
||
#else | ||
|
||
#define compat_ion_ioctl NULL | ||
|
||
#endif /* CONFIG_COMPAT */ | ||
#endif /* _LINUX_COMPAT_ION_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Ion Memory Manager | ||
|
||
Ion is a memory manager that allows for sharing of buffers via dma-buf. | ||
Ion allows for different types of allocation via an abstraction called | ||
a 'heap'. A heap represents a specific type of memory. Each heap has | ||
a different type. There can be multiple instances of the same heap | ||
type. | ||
|
||
Specific heap instances are tied to heap IDs. Heap IDs are not to be specified | ||
in the devicetree. | ||
|
||
Required properties for Ion | ||
|
||
- compatible: "linux,ion" PLUS a compatible property for the device | ||
|
||
All child nodes of a linux,ion node are interpreted as heaps | ||
|
||
required properties for heaps | ||
|
||
- compatible: compatible string for a heap type PLUS a compatible property | ||
for the specific instance of the heap. Current heap types | ||
-- linux,ion-heap-system | ||
-- linux,ion-heap-system-contig | ||
-- linux,ion-heap-carveout | ||
-- linux,ion-heap-chunk | ||
-- linux,ion-heap-dma | ||
-- linux,ion-heap-custom | ||
|
||
Optional properties | ||
- memory-region: A phandle to a memory region. Required for DMA heap type | ||
(see reserved-memory.txt for details on the reservation) | ||
|
||
Example: | ||
|
||
ion { | ||
compatbile = "hisilicon,ion", "linux,ion"; | ||
|
||
ion-system-heap { | ||
compatbile = "hisilicon,system-heap", "linux,ion-heap-system" | ||
}; | ||
|
||
ion-camera-region { | ||
compatible = "hisilicon,camera-heap", "linux,ion-heap-dma" | ||
memory-region = <&camera_region>; | ||
}; | ||
|
||
ion-fb-region { | ||
compatbile = "hisilicon,fb-heap", "linux,ion-heap-dma" | ||
memory-region = <&fb_region>; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
config HI6220_ION | ||
bool "Hi6220 ION Driver" | ||
depends on ARCH_HISI && ION | ||
help | ||
Build the Hisilicon Hi6220 ion driver. |
Oops, something went wrong.