Make sure the header file for Ion gets exported to userspace.
Also make sure userspace can actually use the header.
Change-Id: I44f436005a6a503811c85d4fb0f89264ba160571
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Add the ability to pass flags into the iommu_domain_alloc
function to specify domain attributes.
Change-Id: Ia33aa8d887a57f76d97ab8921385dcc551716846
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
[sboyd: Only iommu_domains.c part]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Add ioctl to support flushing the caches of ion
buffers from userspace.
Change-Id: I60f1daf0eef09e1307242bb3fd0ce4aef374a111
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Add a proper IS_CACHED macro for detecting whether or not
flags indicated a cached mapping.
Change-Id: I2a7e130bd185d6b0bcb4b11593420b5888937880
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Ion needs to be initialized before most other subsystems.
Move the call to be earlier to ensure drivers that need to
allocate memory at bootup can.
Change-Id: I3892798850b64006dec6aaa2633281925208e20d
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Add explicit support for cached and uncached mappings. Functions
now describe whether mappings will be cached or uncached.
Change-Id: I3f0540c0486b134d7bc610480a3f72350337e5b1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Add infrastructure for supporting ion carveout heaps.
The memory type should be specified in the board file using
mach/ion.h. The ion platform driver will be responsible for
allocating the correct memory.
Change-Id: Id70ed1fd799f9a5a16ff971b18d0e868bc09d875
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Add platform driver for msm specific ion devices
Change-Id: I8f5f2c135c667ef1ff2504306ffedc295553efe0
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Check the return value from gen_pool_add and handle
any error gracefully.
Change-Id: I648f3aaafde66f484195024b5c21ef2c6a20b95a
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
In future work, there will only be support for a page size
of 4k. Remove support for anything else.
Change-Id: Ide73160250e1a15a9af662c23497341d356414d6
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Most contexts related to a subsystem (e.g. camera, display)
will all share the same domain. Get rid of all the extra subsystem
ids which just create confusion.
Change-Id: I1a051651ed86296338053c9747795928d467cf87
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Some clients have specific alignment requirements for
iova addresses. Allow those requirements to be specified
via the upper bits of the flag field. Since all iommu
alignment must be at least 4k, the lower bits can specify
other options while the upper bits specify the alignment.
Change-Id: I825e8d9949ac50ecc92992e3defa3526ae81b4b7
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Due to the way allocations are performed, over mapping must be
disallowed. Otherwise, it may be possible to inadvertently
unmap other physical addresses. The smallest length that can
now be mapped is 4K. Lengths less than 4k can be safely
overmapped since physical addresses must be 4k aligned as well.
Change-Id: I897f479c0cec29d499406b52b624a6f2b34b718a
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Group the iommu context together in a logical manner (by subsystem)
to make the code easier to read. Also correct some errors with the
initial pass of context and domains (missing video context and
ijpeg+jpegd domains incorrectly marked as video)
Change-Id: I29064063e1117209beea9fbad044389cc246ed39
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Wrappers to simplify mapping of buffers in kernel and iommu
address space.
Change-Id: I79a261cf8a33e11c3ac68bd0b7f8577c53055d5f
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
When destroying a handle, all kernel mappings to that handle
should be destroyed. Other handles may still have references
and valid mappings to the buffer underneath which should not
be destroyed. Loop on the handle reference count, not the buffer
reference count to get rid of all kernel mappings for the handle.
Change-Id: I7dc5d6a86513fc5fa4e21110ceab434714ea2493
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Add get_ashmem_file and put_ashmem_file routines in ashmem driver to get
and return file references to ashmem file from within the kernel.
Change-Id: Ifbb54f7c1aab90f6d656a10a3c40ca2b65ceb89a
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Flush routines are required by msm architecture to properly
flush the cache based on cache architure.
Change-Id: Ic427a7393eccda794d681401fa7e3eb6807b0f0f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
The majority of the binder messages are not very informative
and useful to the reader. Make them available via debug
mechanisms.
Change-Id: Ie0d262372d10fd82b0743dfd79ce7d1de14ae143
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
The fuction get_loadavg was unused and this also caused
a warning during build. This change also removes it from
the allowed warnings white-list.
Change-Id: I85b184e1eb0ab8b3cf763cab87a30e140d00332b
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
This reverts commit 7f141c58da.
This patch should not have been applied in the first place. The USB
string id index is limited to 255. Function drivers are supposed
to allocate string id for the first time their bind is called. There
is no API to release string id index. If string id is reset in unbind,
we will run out of string id after multiple bind/unbind.
CRs-Fixed: 425501
Change-Id: Ia82a528f9e0af192063970a9227c9c739ed77f48
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
This replaces the uses of PPP_MTU with PPP_MRU
since both are identical.
Change-Id: Id5c1c590f4c04ab5d6b79da520b5c8eae01881e6
Signed-off-by: tirupathireddy <tirupath@codeaurora.org>
There is no longer a SPIN_LOCK_UNLOCKED macro; replace it with
__SPIN_LOCK_UNLOCKED so that lockdep can give the lock a name.
Also include spinlock.h so that this compiles.
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
This reverts commit ffdcd796e23c86d2cfeb25cb2d140f11d5fd6411.
This feature is replaced by passing 'earlyprintk' on the
kernel command line.
Change-Id: I2d4f2812e39b1c7afc061f106863b63710762fa7
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Running a kernel that never enables the interactive cpufreq
will eventually hit the following warning:
INFO: task kinteractiveup:112 blocked for more than 120 seconds.
kinteractiveup D c07ae3a4 7072 112 2 0x00000000
[<c07ae3a4>] (__schedule+0x4e4/0x5c4) from [<c00a1b8c>] (kthread+0x70/0x94)
[<c00a1b8c>] (kthread+0x70/0x94) from [<c000f368>]
(kernel_thread_exit+0x0/0x8)
due to the fact that the kthread is never woken up after being
forked. Kick the thread to its idle loop so that it can
schedule() and move out of the D state.
Change-Id: Idc490e707d9a14dd143306a8ee1c2241320d29d5
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
When a new cpu is added and if does not enter idle
for long, the interactive timer is not started and hence
the cpu remains at lowest frequecny, despite the system
load. This impacts mainly benchmarks. Starting a timer
at governor start to handle low frequency.
Change-Id: I8ac9705b9f166a95715c985efacd2ae8ef387cb7
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
A sync point that is not added to the active_list will never signal
in sync_timeline_signal thus causing sync_fence_wait to deadlock or
block until the timeout expired.
Change-Id: I75168d0eec874bf70dd8c28db9508dd8fc1077d3
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Wastes less memory and allows using more memory for ecc than data.
Change-Id: I1537d28ef3e8626e2dfdc69f2e185d28b7600916
Signed-off-by: Arve Hjønnevåg <arve@android.com>
This is needed to allow modules to link against the sync subsystem
Change-Id: I15c1818de329f24e4113ef1d0923413b22fd0eff
Signed-off-by: Erik Gilling <konkers@android.com>
In order to allow drivers to cleanly handled teardown we need to allow them
to cancel pending async waits. To do this cleanly, we move allocation of
sync_fence_waiter to the driver calling sync_async_wait().
Change-Id: Ifcd95648be6ec07026d67f810070a4310f099989
Signed-off-by: Erik Gilling <konkers@android.com>
Product names may contain spaces and scanf %s only matches the 1st word.
Use strlcpy instead.
Change-Id: Ie8703fea9775f7fc17fe615a42597ca3816d36b0
Signed-off-by: Benoit Goby <benoit@android.com>
This patch adds an interface to return and sg_table given a
valid ion handle.
Change-Id: Icd948c60c1af0a4279f337bcd591cd39b46325e8
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
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.
Change-Id: I49aac7c6d3a5afc440d18b917ae0e73be5d3f56d
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
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.
Change-Id: I6d2db284dce12c2d8cc4e540865beee2da43bd0c
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
With this change the ion_system_heap will only use kernel address
space when the memory is mapped into the kernel (rare case).
Change-Id: I8702cf89ffec0bd5c337bd88d7444013d4d94bc8
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
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.
Change-Id: Ia04d6d72fb301dc088eb8db6576822e9260ff332
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Compared to Rob Clark's RFC I've ditched the prepare/finish hooks
and corresponding ioctls on the dma_buf file. The major reason for
that is that many people seem to be under the impression that this is
also for synchronization with outstanding asynchronous processsing.
I'm pretty massively opposed to this because:
- It boils down reinventing a new rather general-purpose userspace
synchronization interface. If we look at things like futexes, this
is hard to get right.
- Furthermore a lot of kernel code has to interact with this
synchronization primitive. This smells a look like the dri1 hw_lock,
a horror show I prefer not to reinvent.
- Even more fun is that multiple different subsystems would interact
here, so we have plenty of opportunities to create funny deadlock
scenarios.
I think synchronization is a wholesale different problem from data
sharing and should be tackled as an orthogonal problem.
Now we could demand that prepare/finish may only ensure cache
coherency (as Rob intended), but that runs up into the next problem:
We not only need mmap support to facilitate sw-only processing nodes
in a pipeline (without jumping through hoops by importing the dma_buf
into some sw-access only importer), which allows for a nicer
ION->dma-buf upgrade path for existing Android userspace. We also need
mmap support for existing importing subsystems to support existing
userspace libraries. And a loot of these subsystems are expected to
export coherent userspace mappings.
So prepare/finish can only ever be optional and the exporter /needs/
to support coherent mappings. Given that mmap access is always
somewhat fallback-y in nature I've decided to drop this optimization,
instead of just making it optional. If we demonstrate a clear need for
this, supported by benchmark results, we can always add it in again
later as an optional extension.
Other differences compared to Rob's RFC is the above mentioned support
for mapping a dma-buf through facilities provided by the importer.
Which results in mmap support no longer being optional.
Note that this dma-buf mmap patch does _not_ support every possible
insanity an existing subsystem could pull of with mmap: Because it
does not allow to intercept pagefaults and shoot down ptes importing
subsystems can't add some magic of their own at these points (e.g. to
automatically synchronize with outstanding rendering or set up some
special resources). I've done a cursory read through a few mmap
implementions of various subsytems and I'm hopeful that we can avoid
this (and the complexity it'd bring with it).
Additonally I've extended the documentation a bit to explain the hows
and whys of this mmap extension.
In case we ever want to add support for explicitly cache maneged
userspace mmap with a prepare/finish ioctl pair, we could specify that
userspace needs to mmap a different part of the dma_buf, e.g. the
range starting at dma_buf->size up to dma_buf->size*2. This works
because the size of a dma_buf is invariant over it's lifetime. The
exporter would obviously need to fall back to coherent mappings for
both ranges if a legacy clients maps the coherent range and the
architecture cannot suppor conflicting caching policies. Also, this
would obviously be optional and userspace needs to be able to fall
back to coherent mappings.
v2:
- Spelling fixes from Rob Clark.
- Compile fix for !DMA_BUF from Rob Clark.
- Extend commit message to explain how explicitly cache managed mmap
support could be added later.
- Extend the documentation with implementations notes for exporters
that need to manually fake coherency.
Change-Id: Ia8f2ae5d8a1b1c87ed12ca1c89d7bf2067239ee4
Cc: Rob Clark <rob.clark@linaro.org>
Cc: Rebecca Schultz Zavin <rebecca@android.com>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
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.
Change-Id: I4fa9859f4a0b665fcb44e5c0da43c569732e93ae
Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>