GitHub/LineageOS/android_kernel_motorola_exynos9610.git
4 months ago[COMMON] lib: dss: add to support Debug-SnapShot(DSS)
Donghyeok Choe [Sun, 13 May 2018 06:21:23 +0000 (15:21 +0900)]
[COMMON] lib: dss: add to support Debug-SnapShot(DSS)

Change-Id: I28ab91356cc2852a38ee6b7c08d1bcb837d6e8ca
Signed-off-by: Donghyeok Choe <d7271.choe@samsung.com>
4 months ago[COMMON] lib: dss: rename exynos-snapshot to debug-snapshot
Donghyeok Choe [Sun, 13 May 2018 04:32:33 +0000 (13:32 +0900)]
[COMMON] lib: dss: rename exynos-snapshot to debug-snapshot

Change-Id: I196cfc11cd7d24d134bfbf89d5dec27c5450a22f
Signed-off-by: Donghyeok Choe <d7271.choe@samsung.com>
4 months ago[COMMON] printk: add hooking function for exynos-snapshot
Hosung Kim [Sat, 13 Jun 2015 04:15:44 +0000 (13:15 +0900)]
[COMMON] printk: add hooking function for exynos-snapshot

This commit adds hooking function for gathering kernel log
in exynos-snapshot.

Change-Id: I4132288aec8664861f2b51873feb52d8a7da981b
Signed-off-by: Hosung Kim <hosung0.kim@samsung.com>
4 months ago[COMMON] printk: add supporting core number and process information
Hosung Kim [Fri, 12 Jun 2015 13:40:21 +0000 (22:40 +0900)]
[COMMON] printk: add supporting core number and process information

This commit adds supporting to output the core number and process
information. They are depending on as following configuration.
- CONFIG_PRINTK_PROCESS

Change-Id: I09698dc00e5acd1bb11b9a564fdc3f129c04b642
Signed-off-by: Hosung Kim <hosung0.kim@samsung.com>
Signed-off-by: Hyunki Koo <hyunki00.koo@samsung.com>
4 months ago[9610][ERD] arm64: created dt node and added configs for S2MPB02
Jieun Yi [Tue, 15 May 2018 02:23:07 +0000 (11:23 +0900)]
[9610][ERD] arm64: created dt node and added configs for S2MPB02

Change-Id: Id07066b8d4e5279f7a768f0099ed3137a96db83c
Signed-off-by: Jieun Yi <jieun.yi@samsung.com>
4 months ago[9610][ERD] drivers: leds: created led driver for S2MPB02
Jieun Yi [Tue, 15 May 2018 02:22:36 +0000 (11:22 +0900)]
[9610][ERD] drivers: leds: created led driver for S2MPB02

Change-Id: Ifbadf66539f5fb58734d4d9bf7dee37b083ff745
Signed-off-by: Jieun Yi <jieun.yi@samsung.com>
4 months ago[9610][ERD] drivers: regulator: created regulator driver for S2MPB02
Jieun Yi [Tue, 15 May 2018 02:21:59 +0000 (11:21 +0900)]
[9610][ERD] drivers: regulator: created regulator driver for S2MPB02

Change-Id: If727403c00e0f791aa683017abb8a47fbc18376e
Signed-off-by: Jieun Yi <jieun.yi@samsung.com>
4 months ago[9610][ERD] drivers: mfd: created mfd driver for S2MPB02
Jieun Yi [Tue, 15 May 2018 02:20:39 +0000 (11:20 +0900)]
[9610][ERD] drivers: mfd: created mfd driver for S2MPB02

Change-Id: I718feaf8c5b5a41ee9e2cb3056ce394c9afd88f2
Signed-off-by: Jieun Yi <jieun.yi@samsung.com>
4 months agoandroid: ion: confirm to unmap invalid secure iova
hyesoo.yu [Fri, 20 Apr 2018 08:19:55 +0000 (17:19 +0900)]
android: ion: confirm to unmap invalid secure iova

Change-Id: Ifc926d9f85bed09c7c953fd4126f8a22e9c16e76
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
4 months agoandroid: ion: fix missing dma address assignment
Cho KyongHo [Thu, 19 Apr 2018 04:36:02 +0000 (13:36 +0900)]
android: ion: fix missing dma address assignment

Change-Id: I1653dd69e383d559cf3c0f1cb323d3e5640782c8
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix incorrect protection by HPA heap
Cho KyongHo [Wed, 18 Apr 2018 13:46:45 +0000 (22:46 +0900)]
android: ion: fix incorrect protection by HPA heap

<3>[   14.274076]  [4:HwBinder:2696_2: 2720] ion_secure_iova_alloc: failed alloc secure iova. 1610612736/1610612736 bytes used
<3>[   14.274091]  [4:HwBinder:2696_2: 2720] ion_secure_protect: PROT:-2113920752 (err=0,va=0x0,len=0x80000000,cnt=65536,flg=2)

It is caused by incorrect protection information from HPA heap:
- buffer count <-> buffer length in bytes
- chunk size <-> buffer count

Change-Id: I42cb1b31535c698d5ec063d0229a213913d863b4
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix showing incorrect value type
Cho KyongHo [Wed, 18 Apr 2018 13:45:09 +0000 (22:45 +0900)]
android: ion: fix showing incorrect value type

Error message when buffer protection is failed is misleading.

Change-Id: I399ebf66afb86e393e65903a11353775d4a37312
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix success on protection failure
Cho KyongHo [Wed, 18 Apr 2018 13:36:11 +0000 (22:36 +0900)]
android: ion: fix success on protection failure

Change-Id: I26a3055cbd6b20bac7cee26992ce7d308993f614
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix build break with secure DRM on
Cho KyongHo [Wed, 18 Apr 2018 05:52:33 +0000 (14:52 +0900)]
android: ion: fix build break with secure DRM on

Change-Id: I56841d7748b8ae1d546425b0fcbf70b83d443fda
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: assign ion_device for oom notifier
Janghyuck Kim [Fri, 30 Mar 2018 03:32:39 +0000 (12:32 +0900)]
android: ion: assign ion_device for oom notifier

ion_device should be assigned before registering oom notifier.

Change-Id: I14b0af58533591f0d01037607ab2e9f047034c41
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months agoarm64: erd9610_defconfig: enable HPA
hyesoo.yu [Fri, 11 May 2018 07:43:00 +0000 (16:43 +0900)]
arm64: erd9610_defconfig: enable HPA

Change-Id: I322854cd634e48be078a22f2f37ec7199ec5104a
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
4 months agoandroid: ion: show the list of buffers for debug
Cho KyongHo [Thu, 22 Mar 2018 11:20:41 +0000 (20:20 +0900)]
android: ion: show the list of buffers for debug

debugfs/ion/buffers shows the list of buffers and the page pools of
ion_system_heap.
Also added an oom notifier to show the list of buffers when OOM Killer
is invoked. It is very useful to see if the OOM is caused by too many
ION buffers.

Change-Id: I1784014099844917ad15901909a9c2c87e23f32f
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add buffer protection to HPA heap
Cho KyongHo [Wed, 21 Mar 2018 13:38:58 +0000 (22:38 +0900)]
android: ion: add buffer protection to HPA heap

Change-Id: I922780c3378a0e9d6e152ba1a41cc7aaa5cae0f2
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add HPA heap
Cho KyongHo [Wed, 21 Mar 2018 12:37:11 +0000 (21:37 +0900)]
android: ion: add HPA heap

Introducing HPA heap backed by High-order Pages Allocator which
guarantees allocation of higher order pages than PAGE_SIZE.

Change-Id: I1ff9c5727509e9e8cdec00469c704d489614bdf2
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agomm/hpa: fix dependency to lowmemorykiller
Cho KyongHo [Mon, 19 Mar 2018 13:33:19 +0000 (22:33 +0900)]
mm/hpa: fix dependency to lowmemorykiller

lowmemorykiller is removed from the tree by the following commit:
915e70f ("staging, android: remove lowmemory killer from the tree")

Instead HPA killer borrows victim selection logic from oom_killer.
oom_killer selectes a victim task with the combination of the total
rss of the task and oom_adj_score. But HPA killer selects the task
with the largest rss among the tasks with the same oom_adj_score that
is also the largest to select a task with less panelty.

Change-Id: I0ef31e5c44faad9c6216dbdbd085082167b3f256
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm/hpa: remove test condition that always true
Cho KyongHo [Fri, 8 Sep 2017 02:42:00 +0000 (11:42 +0900)]
[COMMON] mm/hpa: remove test condition that always true

Coverity CID197219

Change-Id: I6afd75fdaf705dbfa4c905bb8e0c859bd77999de
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa: reclaim non-lru movable pages in HPA
Cho KyongHo [Fri, 12 May 2017 12:16:25 +0000 (21:16 +0900)]
[COMMON] mm: hpa: reclaim non-lru movable pages in HPA

The patch series of "Support non-lru page migration"
(https://lwn.net/Articles/689343/) introduced the way of migrating
movable pages which are not in LRU list by providing callback
functions called on migration. With that patch series, zsmalloc()
starts allocating pages from Movable zone even though it it is not LRU
pages. Therefore HPA should check if a page is non-lru movable.
Otherwise, HPA may suffer from lack of pages to migrate to other
zones.

Change-Id: Iaa35d16e6b5af21a1eb30c518e371e28995d0d8a
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa: fix parameter that hides global identifier
Cho KyongHo [Fri, 12 May 2017 11:54:25 +0000 (20:54 +0900)]
[COMMON] mm: hpa: fix parameter that hides global identifier

The first parameter to is_movable_chunk() is start_pfn that is
declared as a global variable with the file scope. It is not harm
even though the parameter hids the global variable but it causes
the readers confusing so that it likely leads a mistake in the change
of some statements in the function.
Therefore the name of the first parameter to is_movable_chunk() is
changed and modified the logic of the body of is_movable_chunk() for
clear understanding.

Change-Id: I7b97aefb0b25dd09ca6c22fe0077b3d76b372210
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa: fix using invalid array index
Cho KyongHo [Wed, 19 Apr 2017 14:27:03 +0000 (23:27 +0900)]
[COMMON] mm: hpa: fix using invalid array index

Change-Id: I433e9f33ae3931319b52cb977bbf178a74287fe4
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa/cma: introduce alloc_contig_range_fast()
Cho KyongHo [Wed, 19 Apr 2017 14:57:19 +0000 (23:57 +0900)]
[COMMON] mm: hpa/cma: introduce alloc_contig_range_fast()

HPA allocates lots of order-4 pages from alloc_contig_range(). But it
consumes the most of time to flush per-cpu LRU and per-cpu free pages
that is not required for HPA.
alloc_contig_range_fast() does not flush the per-cpu pages. Therefore
it may fail to reclaim the given range of pages. The users that need
guarantee of success of reclamation of the given range of pages, they
can call alloc_contig_range() as they did. Its behavior is unchanged.

Change-Id: Ie9d545132c7450713ff7724099d24a2ffd766cb1
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa: avoid selecting a victim that was a victim
Cho KyongHo [Fri, 3 Feb 2017 12:35:39 +0000 (21:35 +0900)]
[COMMON] mm: hpa: avoid selecting a victim that was a victim

Totally the same logic with the following patch:
0f7b387 [COMMON] lowmemorykiller: when killing timeout, choose other process

HPA eventually invokes its internal task killer, HPA Killer that
selects a victim task with the highest oom_adj and the largest rss. It
signals SIGKILL the victim task and expects the victim task to be soon
died.
HPA Killer skips selecting another task on the next invocation until
the victim task is finally died during a second unless it finds
another victim task that is more proper to kill. If the task is not
died in a second, HPA killer is to select the same task as a victim
because of the victim selection logic.
If the victim task is in disk sleep state and it waits for a resource
that is occupied by the task that invoking HPA Killer, HPA Killer will
be never finished until another larger task with higher oom_adj is
appeared.
To end ths dead-lock condition, HPA Killer should select next proper
victim task even though the current victim task is not died.

Change-Id: I73afdce457976c9a8f60e92d8d96e792ea854c7c
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa: prevent allocating cma pages from HPA
Cho KyongHo [Thu, 2 Feb 2017 15:07:24 +0000 (00:07 +0900)]
[COMMON] mm: hpa: prevent allocating cma pages from HPA

HPA turns movable pages into the unmovable for playing DRM contents.
But CMA pages should be always ready for reclamation. Therefore, they
should not be unmovable at all time.

Change-Id: I4dbdd7bc065c1c40f7c6bd80fa55c49a46711482
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] mm: hpa: initialize local variable
Sunyoung Kang [Fri, 2 Sep 2016 02:47:26 +0000 (11:47 +0900)]
[COMMON] mm: hpa: initialize local variable

Fix Svace: 64228

Change-Id: Ic29475767bd4cbd8043677abf435c4ab478dd2b7
Signed-off-by: Sunyoung Kang <sy0816.kang@samsung.com>
4 months ago[COMMON] mm: introduce High-order Pages Allocator
Sunyoung Kang [Mon, 4 Jul 2016 06:50:57 +0000 (15:50 +0900)]
[COMMON] mm: introduce High-order Pages Allocator

The high-order pages allocator (aka. HPA) has been introduced to ensure
successful allocation of high-order pages always with given order and size.
The HPA tries to allocate pages from buddy and then if any pages are in use,
tries to reclaim and migrate pages.

Change-Id: I61a7fe76d4a1c6a1058d2fe731bbfef8d3e6959a
Signed-off-by: Jinsung Yang <jsgood.yang@samsung.com>
Signed-off-by: Sunyoung Kang <sy0816.kang@samsung.com>
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix missing debug info of cma heap
Cho KyongHo [Tue, 6 Mar 2018 12:19:30 +0000 (21:19 +0900)]
android: ion: fix missing debug info of cma heap

cma heaps shows the list of allocated buffers from their heap. But
cma heaps do not show the list when cma fails to allocate, actually.

Change-Id: I4b2264bd213d77d7c4276a45b560e6611b4c3b93
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add dmabuf cpu access ops for exynos
Cho KyongHo [Fri, 2 Mar 2018 14:03:48 +0000 (23:03 +0900)]
android: ion: add dmabuf cpu access ops for exynos

.begin_cpu_access and .end_cpu_access of dmabuf ops provided by ION
needs scatter-gather list because they rely on dma-mapping api.

After 'commit 8dbbf7b ("android: ion: do not map in dma_map_attach()
for Exynos")', ion_dma_buf_begin_cpu_access() and
ion_dma_buf_end_cpu_access() loose scatter-gather list stored in
the dma-buf attachment that is eliminated by the above commit.

Instead, dma-mapping api can be used with ion_buffer.sg_table and the
miscdevice of ion_device because they are initialized at buffer
allocation and ION initialization, respectively since 'commit 10a41c2
("android: ion: add fixups to ion exynos extension")'.

Uncached buffers are not required to maintain CPU caches for CPU
accesses because dma_buf_kmap() returns the kernel address with the
cacheability attribute of the buffer.

Change-Id: I6656f22b696ae96de9f2766751970b25f17572f6
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix compile error
Janghyuck Kim [Tue, 6 Mar 2018 02:03:28 +0000 (11:03 +0900)]
android: ion: fix compile error

This patch fixed below compile error when CONFIG_ION_EXYNOS is not
defined.

In file included from drivers/staging/android/ion/ion.c:42:0:
drivers/staging/android/ion/ion_exynos.h:102:25: error:
'ion_exynos_map_dma_buf' defined but not used [-Werror=unused-function]
 static struct sg_table *ion_exynos_map_dma_buf(struct
dma_buf_attachment *att,

Change-Id: I22b9d0e87856bff9a9e307e49698fa9fa3677a3b
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months agoandroid: ion: add checking of returned page
Janghyuck Kim [Wed, 28 Feb 2018 08:11:52 +0000 (17:11 +0900)]
android: ion: add checking of returned page

This patch added checking code to avoid invalid address access for cache
operation.
ion_page_pool_alloc_pages() might return NULL when alloc_pages() could
not get enough pages as requested order, especially in high-order case.

Change-Id: I7aa2bb08f32f523f5b76930b46c0f47d3457895b
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months agoandroid: ion: free iova at buffer destruction time
Janghyuck Kim [Tue, 27 Feb 2018 09:24:10 +0000 (18:24 +0900)]
android: ion: free iova at buffer destruction time

In order to optimize the performance of ion_iovmm_unmap(), the actual
unmapping of the device virtual address is deferred. It is expected to
work at buffer destruction time, but this is missing. So unmapping code
is added to work properly.

Change-Id: Ie2dffa58df5125baf4a4e9723db241846e860443
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months agoarm64: dts: add reserve mem for exynos9610 of 4.14
hyesoo.yu [Fri, 11 May 2018 07:06:00 +0000 (16:06 +0900)]
arm64: dts: add reserve mem for exynos9610 of 4.14

Change-Id: I4d304c4c8010febf5ffa25f660215a6020e0616e
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
4 months agoarm64: erd9610_defconfig: enable the new ION
hyesoo.yu [Fri, 11 May 2018 06:54:56 +0000 (15:54 +0900)]
arm64: erd9610_defconfig: enable the new ION

Change-Id: I51e5aa321ffea0ad8147a5f3c3e4fc47eade0380
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
4 months agoandroid: ion: add show all buffers of contig heaps
Cho KyongHo [Wed, 21 Feb 2018 09:28:52 +0000 (18:28 +0900)]
android: ion: add show all buffers of contig heaps

ION heaps of physically contiguous memory pool is vulnerable to memory
external fragmentations. If an allocation from such heaps has failed,
ION just returns 'out of memory' error. But users need to know if the
error is caused by insufficient free space or fragmentations. Their
actions to the error should be different according to the reason.
Therefore ION ought to tell the users the list of allocated buffers
from the physically contiguous heaps.

Change-Id: I0ea0dd81cfac8f8b019a763480f5c7af22b8eac0
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add kernel log on errors
Cho KyongHo [Thu, 22 Feb 2018 11:55:24 +0000 (20:55 +0900)]
android: ion: add kernel log on errors

It is very important to know the reason of an exception. It is too
difficult to know the details about the exception with an error
number returned by ION.

Change-Id: I51f92bb1cc1c1eee2e0a1a17803d4f5bb0720433
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: do not map in dma_map_attach() for Exynos
Cho KyongHo [Thu, 22 Feb 2018 06:40:48 +0000 (15:40 +0900)]
android: ion: do not map in dma_map_attach() for Exynos

dma_buf ops of ION does two unneccessary works. One is duplicating
sg_table in dma_map_attach() and the other is dma_map_sg() call in
dma_buf_map_attachment(). The duplication of sg_table is neccessary
in fact because dma_map_sg() updates dma_address fields of scatter-
gather list in sg_table with the DMA address of the given device.
It is true with the devices with IOMMU that provides dma-mapping ops.
But our IOMMU, System MMU driver does not provide dma-mapping ops.
Therefor, DMA addresses of the same physical memory location are not
different between devices in Exynos SoCs.

ion_buffer_create() calls dma_map_sg() to initialize dma_address
fields sg_table from the following commit:
'commit 8215d29 ("android: ion: add fixups to ion exynos extension")'

Now we can use the sg_table in ion_buffer for all devices. We can
avoid duplicating sg_table on every dma_buf_attach() call. We can
replace dma_map_sg() with dma_sync_sg_for_device() in
dma_buf_map_attachment().
ion_dma_buf_attach() and ion_dma_buf_detach() are no more required.
it does nothing after sg_table duplication is removed.

For the maintenance reason, we do not remove the unused dma_buf ops
of ION in ion.c. Instead we adds our implementation of map_dma_buf()
and unmap_dma_buf() ops to dma_buf ops of ION if CONFIG_ION_EXYNOS
is configured.

Change-Id: I1764a7eb62e948f074b596e316fe3f48ed3f8662
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add fixups to ion exynos extension
Cho KyongHo [Wed, 21 Feb 2018 12:42:47 +0000 (21:42 +0900)]
android: ion: add fixups to ion exynos extension

The purpose of the exynos extension is to attach addtional
improvements to ION. The first improvment is the elimination of
dma-mapping overhead.
dma_map_sg() and dma_unmap_sg() maps the given memory to the address
space of the given device. The mapping can be translation table update
if the device has iommu. It may allocate swiotlb buffer if the device
does not have iommu and the address space of the device is smaller
than the physical address space. dma_map_sg() and dma_unmap_sg() also
maintain CPU caches to ensure memory coherency.
The purpose of calls to dma_map_sg() and dma_unmap_sg() in
ion_map_dma_buf() and ion_unmap_dma_buf(), respectively is just
ensuring cache coherency in Exynos SoCs. We have another approach to
map the physical memory to the device address space, ion_iovmm_map().
But replacing dma_map_sg() with dma_sync_sg_for_device() does not work
because dma_sync_sg_for_device() needs dma_address fields to be
initialized by dma_map_sg().
This is the first step to replacing dma_map_sg() with
dma_sync_sg_for_device() in ion_map_dma_buf().
Buffer allocation now involves dma_map_sg() to assign dma_address
fields of ion_buffer.sg_table. dma_unmap_sg() is called by
ion_buffer_destroy().
Then we can finally use dma_sync_sg_for_device() in ion_map_dma_buf().

Change-Id: I8b439eddc0b3722a297ea395aa7e6f3ebc00b294
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: do not cache flush for uncached buffers
Cho KyongHo [Thu, 22 Feb 2018 06:52:48 +0000 (15:52 +0900)]
android: ion: do not cache flush for uncached buffers

Uncached buffers are touched by CPU with uncached addresses. Cache
maintenance on the uncached buffers is just redundant, no effect.

Change-Id: I04283f55760845834c1d12102669caa6ccc4f45a
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: remove redundant statements
Cho KyongHo [Wed, 21 Feb 2018 12:55:22 +0000 (21:55 +0900)]
android: ion: remove redundant statements

Change-Id: Ibaef184155aaef44c6d471e3a1d567c21d3f9115
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add ION_FLAG_MAY_HWRENDER
Cho KyongHo [Mon, 12 Feb 2018 05:48:49 +0000 (14:48 +0900)]
android: ion: add ION_FLAG_MAY_HWRENDER

Clients of ION in userland can specify if the allocated buffer is
written by H/W like GPU before S/W initializes it. If the cache
maintenance is fully supported by all H/Ws that touch the buffer or
all H/Ws touching the buffer are in the same cache coherency domain,
everything goes right. But the problem occurs due to the drivers that
does not perform cache maintenance due to the performance reason.
For the the different H/Ws that touch the same buffer in the different
cache coherency domain, the drivers should care when creating IO
memory mapping. ION_FLAG_MAY_HWRENDER and ion_hwrender_dmabuf() helper
give information to such drivers if the buffer is initialized by H/W.
ION_FLAG_MAY_HWRENDER effects nonthing in ION. Just documentation
purpose.

Change-Id: Iab6293f2c5d6017cf67378356721de4256f049b9
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add ion_cached_dmabuf()
Cho KyongHo [Mon, 12 Feb 2018 05:35:24 +0000 (14:35 +0900)]
android: ion: add ion_cached_dmabuf()

Some kernel clients of ION need to know if an ION buffer is cached.

Change-Id: I8a179e2ba4476408732e2d32441268883c9dc2c6
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add ion_iovmm_[un]map()
Cho KyongHo [Mon, 12 Feb 2018 02:19:32 +0000 (11:19 +0900)]
android: ion: add ion_iovmm_[un]map()

iovmm_map() provided by exynos-iovmm is time-consuming. If the same
buffer is iovm mapped to a device, iovmm_map() does the same thing
with much time. iovmm_map() is not able to avoid this repeat because
it has no information to identify a buffer. Thus, ION provides the
avoidance of repeating mapping the same buffer.

Change-Id: I4c62f615dca6dfb5f8d2fe366ccc0a89af1d485e
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: make dma_buf_ops of ION global
Cho KyongHo [Mon, 12 Feb 2018 01:34:16 +0000 (10:34 +0900)]
android: ion: make dma_buf_ops of ION global

It is the only way to verify if the given dma-buf is exported by ION.

Change-Id: I7925e9f88e34f6ecd123a4178531fd237b807ffa
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: remove the list of attachments
Cho KyongHo [Mon, 12 Feb 2018 00:45:03 +0000 (09:45 +0900)]
android: ion: remove the list of attachments

dma_buf also has the list of attachments. ion_buffer.attachments is
redundant. So, let's remove it.
dma_buf.attachment should be accessed with dma_buf.lock held. Holding
dma_buf.lock in begin_cpu_access() and end_cpu_access() is okay. But
it should be handled with care to prevent possible deadlock.

Change-Id: I6a4a5c74c1030874fc08684c6c84485373b47919
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add ion_alloc_dmabuf()
Cho KyongHo [Sun, 11 Feb 2018 11:37:11 +0000 (20:37 +0900)]
android: ion: add ion_alloc_dmabuf()

ION does not provide API to the kernel drivers.
Thus, ion_alloc_dmabuf() is introduced. To allocate a buffer from a
specific heap of ION, the client should query heaps to search proper
heap then allocate buffers with heap mask of the found heap. This
is tedious and error-prone task for drivers.
Let's allow drivers select a heap with heap name. The Exynos extension
to ION will find the heap with the given name and select the heap for
buffer allocation.
ion_alloc_dmabuf() returns dma_buf instead of fd. To deliver the
allocated dma_buf from ion_alloc_dmabuf() to the userspace, the client
driver should assign it to an unused fd by itself.

Change-Id: Iedc0f970fcc2ddcf4739a5d8c3ecec3cd137e280
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add properties to ion_heap_data
Cho KyongHo [Sun, 11 Feb 2018 08:34:49 +0000 (17:34 +0900)]
android: ion: add properties to ion_heap_data

ion_heap_data is lack of heap properties that is critical to users.
Users may want to know the total size of the cma/carved out memory
pools served by cma heap and carveout heap, respectively. They also
need to know if a heap provides buffer protection for DRM video
streams or allocated buffer from a heap can be accessed.

Change-Id: I3c3a6b9a41d32398ddfe1b1c21b3977e790e5c25
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add buffer protection
Cho KyongHo [Sun, 11 Feb 2018 08:08:35 +0000 (17:08 +0900)]
android: ion: add buffer protection

DRM video contents need protection of the decrypted video stream from
copying to insecure buffer. For the protection from copying, Exynos
SoC provides H/W based protection. Since H/W has limitation of
resources, the H/W needs the types of buffer protection, some special
limitation to alignments and limits to the memory pool to serve buffer
protection.
Every memory pool needs buffer protection should be specified in the
flattened device tree under 'reserved-memory' node like cma heaps and
carveout heaps. The heaps needs protection should have 'ion,secure'
boolean property that specifies buffers from the heap may needs buffer
protection. They also need 'ion,protection_id' which specifies the
types of buffer protection.
Buffers from the secure heaps are not protected unless users gives ION
ION_FLAG_PROTECTED flag. non-secure heaps just ignore the flag.

Change-Id: Ibef18c3fde7d628c2298abb95e71379c67cf7471
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add nozero and sync_force flags
Cho KyongHo [Fri, 9 Feb 2018 07:18:43 +0000 (16:18 +0900)]
android: ion: add nozero and sync_force flags

Allocation with ION_FLAG_NOZERED returns buffers without clearing data
written by previous users. ION should not allow userspace accessing
the buffer due to the security reason.
ION_FLAG_SYNC_FORCE is also introduced for some users that want to
decide the point of cache maintenance by itself. With the flag, ION
performs cache flush to the allocated even for cached buffers. those
users want this redundant cache flush to prevent buffer corruption by
victim dirty cache lines about the buffer after DMA write without
proper cache maintenance.

Change-Id: Ib3c4f9c93a6cd0240ae12b8c061142355e2b1605
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: initialize cma heap from device tree
Cho KyongHo [Thu, 8 Feb 2018 08:05:11 +0000 (17:05 +0900)]
android: ion: initialize cma heap from device tree

ION creates cma heaps for all cma region but a lot of cma regions are
not needed to be serviced by ION. If cma heap is required, some users
of ION needs physically contiguous memory for graphics and multimedia.
Exynos SoCs traditionally defines such cma regions in the flattened
device tree node under 'reserved-memory' node.
Since the cma regions may have additional properties which are not
identified by of_reserved_mem.c, the cma region definitions should be
handled by ION.

Change-Id: Ia23fd12f9422f1d9e3a86e5b1d403caa12a29867
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add fdt handling for carveout_heap
Cho KyongHo [Wed, 7 Feb 2018 11:36:08 +0000 (20:36 +0900)]
android: ion: add fdt handling for carveout_heap

Carveout heap provides buffer management for a reserved pool of
physical memory which is carved out by an early allocator like
memblock. Current ION is lack of how to initialize carveout heap.
We have decided to define the reserved memory pool in
"reserved-memory" device tree node with "exynos9820-ion" compatible
string.
The node may have the following properties in addition to the properties
of the child nodes of "reserved-memory" node:
- ion,untouchable: the buffer from the heap should not creates a
              mapping in the kernel and userland.
- ion,heapname: The name of the heap.
- ion,alignment: The alignment of buffers from the heap.

Change-Id: I41cdc72078a88795c8d6aca6af2c40e910330894
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add properties to carveout_heap
Cho KyongHo [Wed, 7 Feb 2018 08:01:10 +0000 (17:01 +0900)]
android: ion: add properties to carveout_heap

Added size, alloc_align, and untouchable properties to carveout heaps.
size property is used for debugging purpose. carvedout heaps are
suffering from the external fragmentations and out of memory when
users do not carefully handle the heaps. When allocation from a carved
out heap happens, the base and the size of the heap is very useful for
debugging.

Some heaps should have restriction of alignment of allocated buffers
to be larger than PAGE_SIZE. alloc_align property specifies this
restriction.

Some special heap has strange property, untouchable. If it is
specified, buffers from the heap should not be accessed from both of
userland and the kernel.

Change-Id: Ib4fd2a4af2e6307bf67aa28d06bbcbca393d4475
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: give name to carveout_heap
Cho KyongHo [Wed, 7 Feb 2018 07:38:09 +0000 (16:38 +0900)]
android: ion: give name to carveout_heap

Heap name is required by ion_query_heaps() because we cannot identify
a specific heap without name.

Change-Id: I39d886255c8381d11f067ec6f19a105e7269010c
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix missing error number in cma heap
Cho KyongHo [Thu, 22 Feb 2018 12:05:28 +0000 (21:05 +0900)]
android: ion: fix missing error number in cma heap

Change-Id: Ib08aa1eefbeb954327ce8052471c621fb1a91063
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: fix missing buffer initialization
Cho KyongHo [Fri, 9 Feb 2018 06:11:15 +0000 (15:11 +0900)]
android: ion: fix missing buffer initialization

Every buffer allocated to userspace should be initialized to a
specific pattern to remove data written by previous users of the
memory in the buffer. The initialization should include elimination
of dirty cache lines allocated for a uncached buffer to prevent write
back from dirty cache lines after uncached data write to the buffer.
This write-back corrupts the buffer with the stale data in the cache.

Cache flush on allocation uses __flush_dcache_area() that is not a
kernel API function allowed for the drivers. But we have no chice than
that because dma-mapping API needs a device descriptor configured for
DMA. Instead modifying pseudo device descriptor, ion_device, we have
decided to use ARM64 specific function __funsh_dcache_area() for
convenient maintenance.

Change-Id: I6d6dda56a5ac4f8cf9dc796b3eddb7ba40e337d9
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: do not defer free for carveout heap
Cho KyongHo [Wed, 7 Feb 2018 05:46:49 +0000 (14:46 +0900)]
android: ion: do not defer free for carveout heap

Carved out heaps allocate buffers from a memory pool of with a limited
size. If it frees buffers in deferred manner, the heap may not be
available in a rare condition by unexpected external fragmentations.
Let's think about the following scenario in a 10MB carveout pool:
  1. allocated 4MB @ +0MB
  2. allocated 2MB @ +4MB
  3. freed 1 but defferred
  4. freed 2 but defferred
  5. allocated 3MB @ +6MB
  6. returned buffer 1 and 2 to the heap.
  7. allocated 4MB @ +0MB
  8. allocation of 3MB failed due to the fragmentation.

Any defferred behavior to the very limited resources is harmful.

Change-Id: I0a64fdec56f0ec1992c20f8ccd50d5c7fbfa8d40
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] android: ion: fix overwriting gfp flags
Cho KyongHo [Thu, 22 Feb 2018 14:22:24 +0000 (23:22 +0900)]
[COMMON] android: ion: fix overwriting gfp flags

The following commit by Chen Feng introduces cached page pools to
improve the allocation perfromance of system heap types.
'commit e7f63771b60e ("ION: Sys_heap: Add cached pool to spead up
 cached buffer alloc")'

But it has a logical problem assigning gfp mask for page allocation
from the kernel page allocator. low_order_gfp_flags should be applied
to the low order page allocations but is is actually not because
high_order_gfp_flags overwrites the gfp_flags at the first iteration
of page pool creation and there is no chance to get back to
low_order_gfp_flags.

Change-Id: I4fb10bfc9f517e660e2f78661d67146380441ecb
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion-test: set correct dma configurations
Cho KyongHo [Tue, 6 Feb 2018 16:26:32 +0000 (01:26 +0900)]
android: ion-test: set correct dma configurations

ion-test does not need swiotlb buffer because it temporarily creates
writecombine mappings for test. Therefore it should have full dma
mask. Moreover, without correct dma_ops, dma_buf_map_attachment()
always fails. Let's configure dma_ops with arch_setup_dma_ops().

Change-Id: Iccdd0f7f593af42d7e708877723aae273bd4acf1
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion-test: addr error message about dmabuf
Cho KyongHo [Tue, 6 Feb 2018 16:21:23 +0000 (01:21 +0900)]
android: ion-test: addr error message about dmabuf

It is useful to distinguish where the error is returned.

Change-Id: I32a3ea5a81f7599fadf1d282fd2776305a0f749d
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion-test: change vmap() to map_vm_ram()
Cho KyongHo [Tue, 6 Feb 2018 16:17:40 +0000 (01:17 +0900)]
android: ion-test: change vmap() to map_vm_ram()

map_vm_ram() is faster than vmap() and is safe for short lived
mappings.

Change-Id: Iec262ade2ebf232b7cd4719e1ddf21f23c5474ae
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] android: ion: ion_test add ION_IOC_TEST_PHYS
Cho KyongHo [Tue, 30 May 2017 15:00:57 +0000 (00:00 +0900)]
[COMMON] android: ion: ion_test add ION_IOC_TEST_PHYS

ION_IOC_TEST_PHYS tests various aspects of the buffers from ION.

Change-Id: I67ac43837eca444ebd4c7b6e838b96532e6d3c9e
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] staging: android: ion_test: fix copying incorrect size to userspace
Cho KyongHo [Fri, 9 Jun 2017 13:53:47 +0000 (22:53 +0900)]
[COMMON] staging: android: ion_test: fix copying incorrect size to userspace

ion_test_ioctl() copies the data to userspace if ioctl command
includes read property. But it copies incorrect number of bytes
because 'data' in sizeof(data) is union of various length data
structures.

Change-Id: I3bcafa6823a38b8ce949f90086dbc9f4c5d3e8c3
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: revive ion-test device
Cho KyongHo [Tue, 6 Feb 2018 10:59:06 +0000 (19:59 +0900)]
android: ion: revive ion-test device

ion-test is the only tool for regression test for ION itself.
Let's restore ion-test device. The restored ion-test device is based
on the following commit:
'commit 4485842493fe ("Staging: android: ion: ion_test.c: fix
 parenthesis alignment")'

Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
Change-Id: I0dc3ee70656926e52c6d21afcc31a46215a3928b

4 months agoandroid: ion: kill system_contig heap
Cho KyongHo [Fri, 2 Feb 2018 13:56:04 +0000 (22:56 +0900)]
android: ion: kill system_contig heap

system_contig heap is very restrictive to be used by graphic/multimedia
use. Since it relies on the page allocator even for the large
physically contiguous buffers.
Let's kill system_contig heap to prevent users from confusion.

Change-Id: Id5bcca56d2139b95c706c5068d797f77904d4888
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: promote heap add priority
Cho KyongHo [Fri, 2 Feb 2018 14:01:10 +0000 (23:01 +0900)]
android: ion: promote heap add priority

Changed heap registration priority to subsys_initcall_sync() because
some drivers calls ion_alloc() in probe() that is called in
device_initcall() priority.

Change-Id: Ib1a06d147c75b0601c4807cea82dfcaca4cb526a
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months agoandroid: ion: add vmap/vunmap ops to dma-buf
Cho KyongHo [Fri, 2 Feb 2018 13:47:34 +0000 (22:47 +0900)]
android: ion: add vmap/vunmap ops to dma-buf

Kernel drivers that allocate buffers from ION sometimes requires
kernel address of the buffers. The drivers tend to access the whole
buffer instead of accessing several pages from the large buffers in
megabytes. Therefore dma_buf_vmap() is proper for the drivers than
dma_buf_kmap().

Change-Id: Ie5edf4c325a34c8ed419291b4490b917b755b551
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[9610] arm64: configs: enable SysMMU
Janghyuck Kim [Fri, 11 May 2018 02:23:48 +0000 (11:23 +0900)]
[9610] arm64: configs: enable SysMMU

Change-Id: Icde7bb364dafb57cbbf128ff1052174020729cc9
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[9610] dtsi: fix TLB mask of sysmmu cam & isp0
Janghyuck Kim [Fri, 1 Dec 2017 06:52:08 +0000 (15:52 +0900)]
[9610] dtsi: fix TLB mask of sysmmu cam & isp0

Change-Id: I0f81a2ccc08c4ef9c3783895c6500bd85d180980
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[9610] dtsi: add no-rpm-control for sysmmu abox
Janghyuck Kim [Mon, 23 Oct 2017 11:49:11 +0000 (20:49 +0900)]
[9610] dtsi: add no-rpm-control for sysmmu abox

Change-Id: I0e0c293de0f49b93191af2eaa4d25594c3e383aa
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[9610] dtsi: add sysmmu properties
Janghyuck Kim [Mon, 25 Sep 2017 12:39:07 +0000 (21:39 +0900)]
[9610] dtsi: add sysmmu properties

Change-Id: Ie855f0baa5cfec54c5950203398d010be7613fdc
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[9610] dtsi: add no suspend property for abox sysmmu
Janghyuck Kim [Tue, 19 Sep 2017 11:54:19 +0000 (20:54 +0900)]
[9610] dtsi: add no suspend property for abox sysmmu

Change-Id: I8d8bc6f010e02561f624ac893ac663aea1a9389e
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[9610] arm64: dts: add System MMU device nodes to 9610
Cho KyongHo [Fri, 15 Sep 2017 11:14:16 +0000 (20:14 +0900)]
[9610] arm64: dts: add System MMU device nodes to 9610

Change-Id: I910fd34892a22d0c06407c17fe23b3f805a5fe6f
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu: fix detach_device() condition
Janghyuck Kim [Fri, 27 May 2016 01:14:35 +0000 (10:14 +0900)]
[COMMON] iommu: fix detach_device() condition

attach_device() was fixed not to care group condition. So
detach_device() should be changed as same condition.

Change-Id: I300cf0927588dba4d79502e7a5beb07b479396fd
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu: fix condition for exynos-iommu
Janghyuck Kim [Tue, 26 Apr 2016 05:03:18 +0000 (14:03 +0900)]
[COMMON] iommu: fix condition for exynos-iommu

Fix up condition of iommu framework to operate exynos-iommu.
exynos-iommu doesn't use dma-iommu for virtual address management.
And it doesn't need to care about group status in attach_device.

Change-Id: Ie9cbb7f2a4963fb279356d54be36c71b7ffd293d
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[HACK] iommu/exynos: fix compile error
Janghyuck Kim [Tue, 9 Jan 2018 04:23:45 +0000 (13:23 +0900)]
[HACK] iommu/exynos: fix compile error

Change-Id: Iff1e5c745b0065e7a2bff2c29f5dd3fffd69485e
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: fix prevent issue
Janghyuck Kim [Thu, 23 Nov 2017 08:10:50 +0000 (17:10 +0900)]
[COMMON] iommu/exynos: fix prevent issue

This patch fixed below prevent issue which are other violation types.

CID 201989,201988,201971,201965,201958,201937,201925,201912,200894

Change-Id: Ic43a796b3f159a8f6cd36756b5e7b42df97a1ec2
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: separate register access file
Janghyuck Kim [Fri, 21 Jul 2017 08:03:45 +0000 (17:03 +0900)]
[COMMON] iommu/exynos: separate register access file

H/W access codes are separated into exynos-iommu-reg.h.

Change-Id: Ifcb239ba84f2545ae9174adc531248843265e56f
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add sysmmu operation logging
Janghyuck Kim [Wed, 19 Jul 2017 09:58:40 +0000 (18:58 +0900)]
[COMMON] iommu/exynos: add sysmmu operation logging

Sysmmu operation logging is added that would be useful for unexpected
situation.

Change-Id: I3d8381cdb8eb1a80f9e52c685affa885c613a73e
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add slot property setting
Janghyuck Kim [Mon, 2 Jan 2017 11:41:27 +0000 (20:41 +0900)]
[COMMON] iommu/exynos: add slot property setting

This patch added parsing DT about slot properties, and parsed
information is used at the beginning of sysmmu.

Change-Id: I1148177911eff50ee71282c4bba508368b1a4a0b
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add TLB port setting
Janghyuck Kim [Tue, 8 Nov 2016 11:34:41 +0000 (20:34 +0900)]
[COMMON] iommu/exynos: add TLB port setting

To support TLB port setting, parsing device tree and setting code are
added.

Change-Id: I63f5854d4d23f2aabb4fe9a4a68a35b8902ab6fd
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add TLB match type flags
Janghyuck Kim [Mon, 31 Oct 2016 08:03:09 +0000 (17:03 +0900)]
[COMMON] iommu/exynos: add TLB match type flags

TLB match type can be different by the supported version.
This patch reads supported feature from H/W, and calls handling function
for each type.

Change-Id: Id674fa9687c4a3839c2dcfa04061c2c8386a4c34
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: remove __initconst for sysmmu_of_match table
Janghyuck Kim [Wed, 22 Feb 2017 07:24:21 +0000 (16:24 +0900)]
[COMMON] iommu/exynos: remove __initconst for sysmmu_of_match table

KASAN reported use-after-free case like below.
To avoid this case, __instconst is removed.

BUG: KASAN: use-after-free in __of_match_node+0xb0/0x104 at addr
ffffffc002653338
Read of size 1 by task kworker/u16:0/6
page:ffffffbdc00994c0 count:0 mapcount:0 mapping:          (null)
index:0x1
flags: 0x0()
page dumped because: kasan: bad access detected

.. < skip > ..

Workqueue: deferwq deferred_probe_work_func
Call trace:
[<ffffffc0000e7140>] dump_backtrace+0x0/0x21c
[<ffffffc0000e7370>] show_stack+0x14/0x1c
[<ffffffc0007a4dc8>] dump_stack+0xa8/0xe8
[<ffffffc000393e04>] kasan_report+0x468/0x484
[<ffffffc000393e38>] __asan_report_load1_noabort+0x18/0x20
[<ffffffc00125f65c>] __of_match_node+0xb0/0x104
[<ffffffc00125f6e8>] of_match_node+0x38/0x5c
[<ffffffc00125ff3c>] of_match_device+0x50/0x5c
[<ffffffc000b0fa5c>] platform_match+0x9c/0x1c4
[<ffffffc000b0be84>] __device_attach_driver+0x100/0x180
[<ffffffc000b08bb0>] bus_for_each_drv+0x15c/0x164
[<ffffffc000b0b584>] __device_attach+0x198/0x208
[<ffffffc000b0c180>] device_initial_probe+0x10/0x18
[<ffffffc000b09020>] bus_probe_device+0x98/0x190
[<ffffffc000b0ac78>] deferred_probe_work_func+0xd4/0xec
[<ffffffc000145428>] process_one_work+0x978/0x1208
[<ffffffc00014636c>] worker_thread+0x654/0x824
[<ffffffc0001524fc>] kthread+0x240/0x250
[<ffffffc0000dde30>] ret_from_fork+0x10/0x20
Memory state around the buggy address:

Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
Change-Id: Ibc46808a38b0db3f9cc62a1e106022fa9383dd20

4 months ago[COMMON] iommu/exynos: display sysmmu name when fault occurred
Janghyuck Kim [Wed, 1 Feb 2017 08:24:20 +0000 (17:24 +0900)]
[COMMON] iommu/exynos: display sysmmu name when fault occurred

In case of sysmmu page fault, it was difficult to distinguish the owner
of invalid request. This patch displays sysmmu name to improve
readability.

Change-Id: I2a11a503c4ad64eaa819e8f76640c3dffc999d00
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: alloc page table entry with gfp mask
Janghyuck Kim [Sat, 7 Jan 2017 05:53:35 +0000 (14:53 +0900)]
[COMMON] iommu/exynos: alloc page table entry with gfp mask

Page table entry can be allocated with GFP_KERNEL if mapping request is
passed by iommu_map(), because it is outside of spinlock boundary.

Change-Id: I59fc5666597ee41f060bccfe91772c603acf9a12
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: force non-shareable for non-cached buffers
Cho KyongHo [Wed, 4 Jan 2017 08:23:19 +0000 (17:23 +0900)]
[COMMON] iommu/exynos: force non-shareable for non-cached buffers

exynos_iovmm_map_userptr() migrates the given userspace mapping to the
device virtual address space. If the given mapping is uncached or
writecombine, cache lines that are allocated to some part of the given
range can be stale. Therefore the mapping is not cached, the mapping
to the System MMU page table should also be non-shareable.

Change-Id: I748ae92525c916d580cb55f9deeb9c43f03a6386
Signe-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] iommu/exynos: fix possible NULL pointer dereference
Cho KyongHo [Thu, 5 Jan 2017 13:59:33 +0000 (22:59 +0900)]
[COMMON] iommu/exynos: fix possible NULL pointer dereference

find_vma() may return NULL. It should be checked even though
exynos_iovmm_map_userptr() requires the callers to acquire mmap_sem.

SVACE WGID 87553

Change-Id: Ice3239234dc46177bce5963444f0c4cbc094fe40
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
4 months ago[COMMON] iommu/exynos: implement API to show status
Janghyuck Kim [Thu, 8 Dec 2016 02:23:31 +0000 (11:23 +0900)]
[COMMON] iommu/exynos: implement API to show status

exynos_sysmmu_show_status() provides information of sysmmu status.

Change-Id: Ia448f085acd3b7d605941481f7799899940420f3
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: support no-suspend feature
Janghyuck Kim [Tue, 25 Oct 2016 10:29:53 +0000 (19:29 +0900)]
[COMMON] iommu/exynos: support no-suspend feature

This patch supports no-suspend mode that not to disable sysmmu when it
is going to suspend state. It is necessary for the master driver like
abox that should operate in suspend mode.

Change-Id: I1ff1ccd83997f3852d5b962767c43bc0d6cd6819
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: check condition before pointer access
Janghyuck Kim [Mon, 5 Sep 2016 03:21:20 +0000 (12:21 +0900)]
[COMMON] iommu/exynos: check condition before pointer access

Fix Svace : 64214, 64219

Change-Id: I5ab4d2e84d4a510693978b6aac97ebf8c037119e
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add shareablity setting in iommu_map
Janghyuck Kim [Thu, 11 Aug 2016 04:23:33 +0000 (13:23 +0900)]
[COMMON] iommu/exynos: add shareablity setting in iommu_map

Current exynos iommu driver supports shareability setting by userptr
case only, and prot was ignored in case of iommu_map().
This patch enables shareability setting for iommu_map().

Change-Id: I5431a029746b5d9b89ceb8d4b0a6b2190e8d43e6
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: support secure sysmmu interrupt
Janghyuck Kim [Sat, 6 Aug 2016 07:20:47 +0000 (16:20 +0900)]
[COMMON] iommu/exynos: support secure sysmmu interrupt

Abnormal situation like page fault can be happened when sysmmu is
operating in secure context. To ease debugging with maintaining secure
state, secure interrupt handler is added. In this handler, useful
information of sysmmu status can be obtained through exynos_smc().

Change-Id: I066f70f655e41eda9ba5d7f2d8dd83f1cea94176
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: fix overflow check condition
Janghyuck Kim [Thu, 7 Jul 2016 14:01:16 +0000 (23:01 +0900)]
[COMMON] iommu/exynos: fix overflow check condition

Considering 32bit dma address, overflow checking condition is fixed.

Change-Id: I98066be8a219f9a26e076b2f64285455f48d057d
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] include: add definition for prefetch read/write
Janghyuck Kim [Mon, 1 May 2017 08:28:04 +0000 (17:28 +0900)]
[COMMON] include: add definition for prefetch read/write

Change-Id: Ibac9935d7ed568bcc62845643e7fb00af003f926
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] include: add definition for TLB port setting
Janghyuck Kim [Tue, 8 Nov 2016 11:33:51 +0000 (20:33 +0900)]
[COMMON] include: add definition for TLB port setting

Change-Id: I49560e481edc20b8134861f9314cbda19cb48925
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: parsing DT for sysmmu properties
Janghyuck Kim [Mon, 16 May 2016 12:19:54 +0000 (21:19 +0900)]
[COMMON] iommu/exynos: parsing DT for sysmmu properties

Sysmmu properties that read from DT are parsed and stored into driver
data.

1) QoS property is defined like below in DT.
sysmmu_node:
qos = <4>;

2) TLB properties are defined like below in DT.
sysmmu_node:
sysmmu,tlb_property =
<PRIV_WAY_CFG ID SYSMMU_ID(X)>,
<PRIV_WAY_CFG ID SYSMMU_ID(X)>,
<PUBLIC_WAY_CFG SYSMMU_NOID>;
Refer to include/dt-bindings/sysmmu/sysmmu.h for detailed definitions.

Change-Id: Ibdca6081351e997ba3a01f0173c751d30bb69a1d
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add dma-window property parsing
Janghyuck Kim [Wed, 11 May 2016 02:25:18 +0000 (11:25 +0900)]
[COMMON] iommu/exynos: add dma-window property parsing

Each domain may need different dma ranges for client device's
requirement. 'dma-window' property specifies dma ranges
for each domain.

This property is optional, so if it doesn't exist,
default dma ranges from 0x10000000 to 0xD0000000 are used.

If this property is used, address and size cells should be described.
Below is an example.

iommu-domain_something {
compatible = "samsung,exynos-iommu-bus";

#dma-address-cells = <1>;
#dma-size-cells = <1>;
/* start address, size */
dma-window = <0x10000000 0xC0000000>;

domain-clients = <&something>;
};

Change-Id: I2765f8a4a6b142475c5de80aa73234bef0bd3248
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: add dump of TLB status
Janghyuck Kim [Thu, 16 Jun 2016 08:12:46 +0000 (17:12 +0900)]
[COMMON] iommu/exynos: add dump of TLB status

Dumping TLB status and TLB set/way information are added to provide
useful information in sysmmu status dumping

Change-Id: I37bfdfbd1baa2c6f10275c93f3d43b055ad0b6e7
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
4 months ago[COMMON] iommu/exynos: support fault handler for v7
Janghyuck Kim [Wed, 1 Jun 2016 05:10:39 +0000 (14:10 +0900)]
[COMMON] iommu/exynos: support fault handler for v7

Reading interrupt status and displaying information are changed to
support sysmmu v7.

Change-Id: I29acc8fd8427933a58a2330526f74f283a0d2d01
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>