ipc/ludev.git
2 years agoversion: update to new version 4.16.0.0 lu-next master 4.16.00.00
Sam Nelson [Fri, 19 Oct 2018 23:19:16 +0000 (19:19 -0400)]
version: update to new version 4.16.0.0

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agotests: Cleanup to prevent size mismatch warnings
Shravan Karthik [Wed, 31 Oct 2018 05:39:16 +0000 (11:09 +0530)]
tests: Cleanup to prevent size mismatch warnings

Signed-off-by: Shravan Karthik <shravan.karthik@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agomodule: cmemk: Modifications to dmabuf operations for Linux Kernel > v4.18
Shravan Karthik [Thu, 25 Oct 2018 12:54:25 +0000 (18:24 +0530)]
module: cmemk: Modifications to dmabuf operations for Linux Kernel > v4.18

From kernel versions 4.18, the map_atomic, unmap_atomic interfaces are
removed.
The device parameter for the attach callback is also removed.

Signed-off-by: Shravan Karthik <shravan.karthik@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agoapitest: Update to check for return value for allocPhys
Sam Nelson [Tue, 6 Nov 2018 21:44:51 +0000 (16:44 -0500)]
apitest: Update to check for return value for allocPhys

Adds check for return value of zero and exit instead of going ahead with
map.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agocmem: Code clean up
Sam Nelson [Tue, 6 Nov 2018 21:40:09 +0000 (16:40 -0500)]
cmem: Code clean up

Add spaces instead of spaces for consistency across code

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agocmemk: portability fixes for handling physical address
Sam Nelson [Wed, 31 Oct 2018 14:45:07 +0000 (10:45 -0400)]
cmemk: portability fixes for handling physical address

Fixes return of unsigned long long to user space for physp
Fixes print issues to be address with portability in mind.
Fix argument pointers

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agocmem: Add portability fix for user space library source
Sam Nelson [Mon, 29 Oct 2018 19:57:00 +0000 (15:57 -0400)]
cmem: Add portability fix for user space library source

Adds handling of 64 bit properly

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agocmemk: Update for K3 architecture
Sam Nelson [Wed, 10 Oct 2018 17:16:22 +0000 (13:16 -0400)]
cmemk: Update for K3 architecture

Adds portabilty fix for 64 bit address handling.
Also, with K3 cache coherence architecture, Cache operations are not
required from the Arm Host side. This patch disables all cache
operations for K3 architecture.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agoversion: update to new version 4.15.0.2 4.15.00.02
Sam Nelson [Tue, 21 Aug 2018 22:41:25 +0000 (18:41 -0400)]
version: update to new version 4.15.0.2

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agolu.mak: Update to allow building for aarch64
Sam Nelson [Sat, 18 Aug 2018 03:08:23 +0000 (23:08 -0400)]
lu.mak: Update to allow building for aarch64

Remove hard coding to ARCH=arm

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
2 years agocmemk: Fix mmap failures on K2 devices with v4.14.49
Suman Anna [Fri, 17 Aug 2018 03:07:52 +0000 (22:07 -0500)]
cmemk: Fix mmap failures on K2 devices with v4.14.49

The commit 16d7ceb04b55 ("mmap: introduce sane default mmap limits")
that came through v4.14.49 stable tree has added additional range
checks that resulted in the mmap() calls on the CMEM device to fail
on K2 SoCs. K2 SoCs use 36-bit address spaces and the range check
fails when comparing (in page indices) the 33-bit physical address
against the 4 GB address imit, resulting in CMEM API failures and
unable to launch MPM daemon on K2 SoCs affecting all MPM based IPC
use-cases.

Work around this problem by setting FMODE_UNSIGNED_OFFSET in the file
flags in the driver's open() fops implementation for the /dev/cmem
device. The change follows the suggestion in the above commit to mark
the file descriptors as safe in the full 64-bit mmap address space
by using the repurposed FMODE_UNSIGNED_OFFSET bit. The fix was also
inspired by a similar fix in commit 2abd4c3ed20d ("drm: set
FMODE_UNSIGNED_OFFSET for drm files") for the same problem.

The same fix applies when using CMEM against kernels v4.17-rc5 and
above as well overcoming the corresponding upstream equivalent commit
be83bbf80682 ("mmap: introduce sane default mmap limits").

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmem: Update version number to 4.15.0.1 4.15.00.01
Sam Nelson [Mon, 5 Mar 2018 18:09:52 +0000 (13:09 -0500)]
cmem: Update version number to 4.15.0.1

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Update handling of get_phys
Sam Nelson [Thu, 15 Feb 2018 22:07:06 +0000 (17:07 -0500)]
cmemk: Update handling of get_phys

Fixes one issue related to falling through for direct mapped memory.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmem: Bug fix: Correct return value checking
Sam Nelson [Thu, 15 Feb 2018 22:05:07 +0000 (17:05 -0500)]
cmem: Bug fix: Correct return value checking

Need to check all negative values not only -1.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agoversion: Update version number to 4.15.00.00 4.15.00.00_eng
Sam Nelson [Wed, 31 Jan 2018 17:50:55 +0000 (12:50 -0500)]
version: Update version number to 4.15.00.00

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Cleanup of tabs and spaces
Sam Nelson [Wed, 31 Jan 2018 15:52:11 +0000 (10:52 -0500)]
cmemk: Cleanup of tabs and spaces

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Update to make code work with kernel 4.14
Sam Nelson [Wed, 31 Jan 2018 15:49:53 +0000 (10:49 -0500)]
cmemk: Update to make code work with kernel 4.14

Changes are backward compatible with Linux Kernel 4.4 as well.
Replaced use of deprecated ioremap_page_range function with ioremap

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Clean up of tabs and spaces
Sam Nelson [Fri, 26 Jan 2018 17:56:39 +0000 (12:56 -0500)]
cmemk: Clean up of tabs and spaces

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Add error checks and cleanup
Sam Nelson [Fri, 26 Jan 2018 17:35:59 +0000 (12:35 -0500)]
cmemk: Add error checks and cleanup

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Need protection for find_vma for multithread use
Sam Nelson [Fri, 26 Jan 2018 17:28:45 +0000 (12:28 -0500)]
cmemk: Need protection for find_vma for multithread use

There is a race condition when mmap is happening simultaneously in a
different thread and  find_vma returns invalid value.
Adding protection here to avoid race condition

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmem: Fix return value for export_dmabuf
Sam Nelson [Fri, 26 Jan 2018 17:26:26 +0000 (12:26 -0500)]
cmem: Fix return value for export_dmabuf

In case of error, function expected to return negative value

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agocmemk: Fix the dma_buf ops names on 4.12+ kernels
Suman Anna [Thu, 13 Jul 2017 16:52:05 +0000 (11:52 -0500)]
cmemk: Fix the dma_buf ops names on 4.12+ kernels

The dma-buf ops .kmap_atomic, .kunmap_atomic, .kmap and .kunmap have
been renamed to .map_atomic, .unmap_atomic, .map and .unmap respectively
on 4.12+ kernels to avoid conflict with a kmap_atomic macro from the
Linux highmem.h header file. Fix the ops names in the current definitions
of cmem_dmabuf_ops, so that the CMEM module can be built against 4.12+
kernels properly.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/dma-buf.h?id=f9b67f0014cba18f1aabb6fa9272335a043eb6fd

Signed-off-by: Suman Anna <s-anna@ti.com>
3 years agocmemk: Use architecture agnostic uaccess.h header
Suman Anna [Thu, 19 Oct 2017 18:18:15 +0000 (13:18 -0500)]
cmemk: Use architecture agnostic uaccess.h header

Replace the architecture specific asm/uaccess.h with the Linux
generic linux/uaccess.h header file. The architecture specific
header files will be included by the generic header file.

This fixes an issue when building the CMEM kernel module against
4.12+ kernels.

Signed-off-by: Suman Anna <s-anna@ti.com>
3 years agocmemk: Fix usage of get_user_pages_remote() on 4.10+ kernels
Suman Anna [Thu, 13 Jul 2017 16:52:05 +0000 (11:52 -0500)]
cmemk: Fix usage of get_user_pages_remote() on 4.10+ kernels

The get_user_pages_remote() function signature has changed in 4.10
kernel, it gained an additional integer pointer argument [1]. Fix
the current get_user_pages_remote() invocation in cmemk kernel with
the appropriate signature to build properly for these kernels.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=5b56d49fc31dbb0487e14ead790fc81ca9fb2c99

Signed-off-by: Suman Anna <s-anna@ti.com>
3 years agocmem: Update version to 4.14.01.00 4.14.01.00
Sam Nelson [Wed, 1 Nov 2017 15:45:27 +0000 (11:45 -0400)]
cmem: Update version to 4.14.01.00

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
3 years agoAndroid: move cmem libraries/binaries to vendor partition
Vishal Mahaveer [Tue, 19 Sep 2017 18:21:24 +0000 (13:21 -0500)]
Android: move cmem libraries/binaries to vendor partition

Updating Android makefile to generate cmem userspace binaries and
libraries in /vendor location instead of /system.

Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
4 years agoversion: Update cmem version to 4.14 4.14.00.00 4.14.00.00.eng
Sam Nelson [Thu, 16 Feb 2017 15:15:18 +0000 (10:15 -0500)]
version: Update cmem version to 4.14

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Fix usage of get_user_pages() on 4.6+ kernels
Suman Anna [Tue, 14 Feb 2017 22:08:02 +0000 (16:08 -0600)]
cmemk: Fix usage of get_user_pages() on 4.6+ kernels

The get_user_pages() function has gone through a bunch of changes
between 4.4 and 4.9 Linux kernel versions. The function first lost
the first two arguments - the task_struct and the mm_struct pointers
in 4.6 kernel (and got replaced with a new get_user_pages_remote()
function)[1][2], and then replaced two other arguments 'write' and
'force' with a single 'gup_flags' argument in 4.9 kernel[3][4]. Fix
the current get_user_pages() invocation in cmemk kernel with the
appropriate functions to build properly for these kernels.

[1]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=1e9877902dc7e11d2be038371c6fbf2dfcd469d7
[2]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=c12d2da56d0e07d230968ee2305aaa86b93a6832
[3]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=768ae309a96103ed02eb1e111e838c87854d8b51
[4]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=9beae1ea89305a9667ceaab6d0bf46a045ad71e7

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Fix cmem_dma_buf_end_cpu_access() signature on 4.6+ kernels
Suman Anna [Tue, 14 Feb 2017 21:58:07 +0000 (15:58 -0600)]
cmemk: Fix cmem_dma_buf_end_cpu_access() signature on 4.6+ kernels

Commit 18b862dcd57a ("dma-buf, drm, ion: Propagate error code from
dma_buf_start_cpu_access()") in Linux kernel has changed the signature
for the dma_buf's end_cpu_access() ops. It now returns an error code,
so adjust the signature for the cmem_dma_buf_end_cpu_access() function
appropriately based on the kernel version.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmem: Update version 4.13.00.01 4.13.00.01.eng
Sam Nelson [Tue, 10 Jan 2017 16:02:31 +0000 (11:02 -0500)]
cmem: Update version

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Initialize vma variable
Sam Nelson [Tue, 10 Jan 2017 13:15:15 +0000 (08:15 -0500)]
cmemk: Initialize vma variable

This is a bug fix. Uninitialized variable caused freeing of random
pointer and page fault.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agoversion: Update cmem version 4.13.00.00.eng
Sam Nelson [Fri, 2 Dec 2016 20:54:37 +0000 (15:54 -0500)]
version: Update cmem version

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agoDocumentation: Update ti,cmem.txt with updated features
Sam Nelson [Fri, 2 Dec 2016 16:46:23 +0000 (11:46 -0500)]
Documentation: Update ti,cmem.txt with updated features

Adds support for using sram node
Also updated documentation by demarcating the entries in  the block
subnodes

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
---
Updated documentation with "sram" node definition
---

4 years agocmemk: Add support for blocks using sram nodes
Sam Nelson [Fri, 2 Dec 2016 16:17:15 +0000 (11:17 -0500)]
cmemk: Add support for blocks using sram nodes

Some memory sections can be managed by sram nodes in the dts.
Adding support for sram subnodes allows the CMEM memory to use sram
memory areas.

Parsing of addresses on the subnodes now use of_address_to_resource for
both sram and mem-region nodes.

NOTE: For some of the routines the spacing and tabs are updated to general linux kernel coding guidelines.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
---
Change from previous version
Redesigned to use "sram" node instead of mem-type.
---

4 years agotests: Update apitest to exercise dmabuf export
Sam Nelson [Wed, 2 Nov 2016 17:14:47 +0000 (13:14 -0400)]
tests: Update apitest to exercise dmabuf export

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmem: Add support to export cmem buffer as dmabuf
Sam Nelson [Wed, 2 Nov 2016 17:14:22 +0000 (13:14 -0400)]
cmem: Add support to export cmem buffer as dmabuf

Added new API to export buffer as dmabuf
Added kernel driver code to support dmabuf ops

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmem: Fix duplication of block_struct
Sam Nelson [Fri, 11 Nov 2016 21:47:14 +0000 (16:47 -0500)]
cmem: Fix duplication of block_struct

Cleanup: The block_struct was duplicated in both cmem.c and cmemk.c
Removing it and add it in the common cmem.h file

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Add error check for ioremap function call
Sam Nelson [Fri, 11 Nov 2016 21:55:06 +0000 (16:55 -0500)]
cmemk: Add error check for ioremap function call

Added error check for ioremap_page_range in case of failure
Also added initialisation of virtp

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Fix for issue with allocating memory from CMA pool with non-keystone
Sam Nelson [Wed, 2 Nov 2016 17:17:13 +0000 (13:17 -0400)]
cmemk: Fix for issue with allocating memory from CMA pool with non-keystone

coherent_dma_mask was not set for Am57x platforms and resulted in
allocation failure

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agoDocumentation: Add kernel device tree documentation 4.12.00.00
Sam Nelson [Mon, 26 Sep 2016 16:40:11 +0000 (12:40 -0400)]
Documentation: Add kernel device tree documentation

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: UPdate cache wb and invalidate function. 4.12.00.00_eng
Sam Nelson [Wed, 7 Sep 2016 18:06:49 +0000 (14:06 -0400)]
cmemk: UPdate cache wb and invalidate function.

- Found that __cpuc_flush_dcache_area doesnot work properly: Needed to
be replaced by dmac_map_area
- Other minor spacing issues fixed.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agoversion: Update version to 4.12.0.0
Sam Nelson [Wed, 7 Sep 2016 17:35:16 +0000 (13:35 -0400)]
version: Update version to 4.12.0.0

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Update to use local assembly for cache operations
Sam Nelson [Wed, 7 Sep 2016 16:49:57 +0000 (12:49 -0400)]
cmemk: Update to use local assembly for cache operations

dmac_map_area and associated assembly functions are no longer available
for use in kernel modules in kernel version >= 4.4 and there are no
equivalent higher level function available for cache operations.

Use of dma_sync_single* function creates additional issues with address
translation and does not really solve the problem for memory range > 4
GB and hence reverting back that change.

Reverting back to local assembly functions. Modified code to add
local functions for all kernels versions where dmac_map_area is not
available.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agoRevert "Remove assembly function hack for !MULTI_CACHE case"
Sam Nelson [Wed, 7 Sep 2016 16:41:50 +0000 (12:41 -0400)]
Revert "Remove assembly function hack for !MULTI_CACHE case"

This reverts commit d5481f4d32edbc320a0853b2ddfdfe8dedc8d017.

4 years agocmem: Update version to 4.1.0.1 4.11.00.01
Sam Nelson [Fri, 24 Jun 2016 19:16:23 +0000 (15:16 -0400)]
cmem: Update version to 4.1.0.1

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Update to use high level functions for cache operations 4.11.00.00_eng
Sam Nelson [Fri, 22 Apr 2016 15:48:17 +0000 (11:48 -0400)]
cmemk: Update to use high level functions for cache operations

linux kernel 4.4 made the dmac_map_area function to internal only to dma
module.
Replaced with higher level cache operation functions to achieve the same
result, but avoid using the low level internal function to resolve
issue.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Cleanup on cmem_cma_dev_0
Sam Nelson [Wed, 13 Apr 2016 21:21:06 +0000 (17:21 -0400)]
cmemk: Cleanup on cmem_cma_dev_0

cmem_cma_dev_0 need not be keystone 2 specific and can be common for all
platforms. Added similar handling for all platforms.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agocmemk: Update to remove return value for seq_printf
Sam Nelson [Wed, 13 Apr 2016 21:18:41 +0000 (17:18 -0400)]
cmemk: Update to remove return value for seq_printf

In kernel version 4.4 the return value for seq_printf is removed.
Removed all return value handling for seq_printf

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
4 years agoRemove assembly function hack for !MULTI_CACHE case
Robert Tivy [Fri, 21 Aug 2015 00:32:39 +0000 (17:32 -0700)]
Remove assembly function hack for !MULTI_CACHE case

With older Linux kernels the linkage to architecture-specific cache APIs
was not available, yet CMEM needed their functionality.  This problem
existed for architectures that didn't #define MULTI_CACHE.  CMEM worked
around this limitation by having a copy of the needed
architecture-specific assembly functions, taken from the architecture's
source code.

The current Linux kernels don't suffer this limitation, so the copies of
the architecture's assembly source code are no longer needed and should
be removed altogether.

Addresses SDOCM00117426 & SDOCM00118582

Signed-off-by: Rob Tivy <rtivy@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
5 years agocmemk: Use #define for keystone dma pfn offset
Sam Nelson [Thu, 17 Mar 2016 20:25:57 +0000 (16:25 -0400)]
cmemk: Use #define for keystone dma pfn offset

Cleanup to define the dma pfn offset at one location instead of spread
all over the code

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
5 years agocmemk: Update to ensure backward compatibility with older kernel
Sam Nelson [Thu, 17 Mar 2016 19:02:14 +0000 (15:02 -0400)]
cmemk: Update to ensure backward compatibility with older kernel

The per device dma_pfn_offset was introduced in Kernel version 3.18.
The conditional compilation allows to compile with older kernel as well.

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
5 years agoks2: set dma_pfn_offset for keystone2 devices 4.10.02.05_eng 4.10.02.06
Vitaly Andrianov [Fri, 4 Mar 2016 15:36:46 +0000 (10:36 -0500)]
ks2: set dma_pfn_offset for keystone2 devices

On kestone2 SOC where aliased memory is being used dma_alloc_coherent()
cannot be called with pointer to device set to NULL. The real
"struct device" has to be used. And the dma_pfn_offset has to be set
correctly. Otherwise the function returns wrong dma address.

This commit adds the cmem_cma_dev_0 pointer, which is set by
device_create(). It sets the correct coherent_dma_mask and dma_pfn_offset
for this device.

Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
5 years agoAdd support for LPAE in DT processing 4.10.02.04_eng
Robert Tivy [Fri, 16 Oct 2015 18:28:42 +0000 (11:28 -0700)]
Add support for LPAE in DT processing

When memory is using LPAE mode pointers are > 32 bit, and as such the
"reg" values in a memory-region are 64 bits each for address and size.
Change CMEM DT processing to honor #address-cells and #size-cells for
memory-region nodes.

Also, pool buffer sizes need to be specified as 64 bit values, so add
a #pool-size-cells property to the cmem node and read values from the
cmem-buf-pools property as appropriate.

5 years agoRevert "Remove assembly function hack for !MULTI_CACHE case"
Robert Tivy [Tue, 25 Aug 2015 23:59:22 +0000 (16:59 -0700)]
Revert "Remove assembly function hack for !MULTI_CACHE case"

This reverts commit 09d38fe7dfed7067e4e6d10a1c22a0bcc3af0271.

5 years agoUpdates to accommodate GCC 4.9 4.10.02.03_eng
Robert Tivy [Fri, 21 Aug 2015 00:46:47 +0000 (17:46 -0700)]
Updates to accommodate GCC 4.9

A 'space' between -I and the following path seems to cause the path
element to not be used for #include file searches.

The __DATE__ & __TIME__ macro usage causes a warning (that can be an
error with -Wall).

Addresses SDOCM00118585

5 years agoRemove assembly function hack for !MULTI_CACHE case
Robert Tivy [Fri, 21 Aug 2015 00:32:39 +0000 (17:32 -0700)]
Remove assembly function hack for !MULTI_CACHE case

With older Linux kernels the linkage to architecture-specific cache APIs
was not available, yet CMEM needed their functionality.  This problem
existed for architectures that didn't #define MULTI_CACHE.  CMEM worked
around this limitation by having a copy of the needed
architecture-specific assembly functions, taken from the architecture's
source code.

The current Linux kernels don't suffer this limitation, so the copies of
the architecture's assembly source code are no longer needed and should
be removed altogether.

Addresses SDOCM00117426 & SDOCM00118582

5 years agoFix some typos
Robert Tivy [Thu, 20 Aug 2015 23:25:17 +0000 (16:25 -0700)]
Fix some typos

5 years agoAndroid: Refactored makefiles into a single Android.mk 4.10.01.02
Arnie Reynoso [Wed, 13 May 2015 22:03:31 +0000 (15:03 -0700)]
Android: Refactored makefiles into a single Android.mk

All the makefiles for Android builds were refactored into a single file and moved
to the root of the repo.

5 years agoAdd non-interactive mode option -n
Robert Tivy [Tue, 12 May 2015 20:19:49 +0000 (13:19 -0700)]
Add non-interactive mode option -n

When the -n option is given, the test does not prompt for ENTER and runs
to completion without user input.

6 years agoChange int to unsigned int to suppress warnings 4.10.00.01
Robert Tivy [Thu, 29 Jan 2015 00:25:33 +0000 (16:25 -0800)]
Change int to unsigned int to suppress warnings

Warnings for signed/unsigned comparisons are obnoxious, change certain
int to unsigned int to remove warnings.

6 years agoModify apitest for Android
Robert Tivy [Thu, 29 Jan 2015 00:11:22 +0000 (16:11 -0800)]
Modify apitest for Android

6 years agoAdd support for Android to use mmap64
Robert Tivy [Tue, 27 Jan 2015 21:32:51 +0000 (13:32 -0800)]
Add support for Android to use mmap64

In the Android Lollipop build environment, the bionic mmap() API doesn't
work for addresses (off_t offset, really) >= 2 GB.  Technically, an off_t
offset can't be >= 2 GB since it's a signed 32-bit type, but it works in
non-Android environments, and a cmemk.c driver module change would need
to be made to accommodate using an offset < 2 GB.

This commit adds internal usage of mmap64 in the CMEM library, plus adds
new 64-bit "flavor" APIs:
    CMEM_getPhys64()
    CMEM_map64()
    CMEM_registerAlloc64()
    CMEM_allocPhys64()
    CMEM_allocPoolPhys64()
    CMEM_freePhys64()
to be used by Android user applications that need to do so, in lieu of
the non-64 counterparts.  An application source file build needs to
    -DLINUXUTILS_BUILDOS_ANDROID
in order for the prototypes of these new APis to be exposed in the header
file cmem.h.

6 years agoChange vm_page_prot WRITETHROUGH to WRITEALLOC for CMEM_CACHED case
Robert Tivy [Fri, 23 Jan 2015 01:31:20 +0000 (17:31 -0800)]
Change vm_page_prot WRITETHROUGH to WRITEALLOC for CMEM_CACHED case

We received a recommendation to change the vma->vm_page_prot flags
for buffers mapped as CMEM_CACHED from using
    L_PTE_MT_WRITETHROUGH
to
    L_PTE_MT_WRITEALLOC
since "writethrough" is not supported on the A15.

6 years agoAdd back allowOverlap processing but deprecate it and warn if used
Robert Tivy [Fri, 23 Jan 2015 01:23:53 +0000 (17:23 -0800)]
Add back allowOverlap processing but deprecate it and warn if used

allowOverlap is not needed since any real overlap of CMEM memory with
kernel memory will be detected and errored.  The previous overlap detection
was weak and allowOverlap was originally introduced to overcome false
overlap detection.

6 years agoCleanup #if 0|1 blocks and commented-out code
Robert Tivy [Fri, 23 Jan 2015 01:11:02 +0000 (17:11 -0800)]
Cleanup #if 0|1 blocks and commented-out code

6 years agoAdd LPAE 36-bit phys addr adjustment for Keystone CMA allocs
Robert Tivy [Mon, 19 Jan 2015 23:14:31 +0000 (15:14 -0800)]
Add LPAE 36-bit phys addr adjustment for Keystone CMA allocs

A CMA allocation within CMEM returns a 32-bit phys addr in the "alias"
region for the 36-bit LPAE phys addr, but CMEM customers need the actual
36-bit real phys addr.  Adding 0x780000000ULL to the 'dma' address that
is returned by dma_alloc_coherent() accomplishes this.

6 years agoFix cache handling code
Robert Tivy [Wed, 7 Jan 2015 02:07:47 +0000 (18:07 -0800)]
Fix cache handling code

Cache handling code was using the wrong physical address.

Cache invalidations need to use outer/inner operation ordering (was
reversed).

6 years agoRestrict new DT processing code to KERNEL_VERSION(3,14,0) or greater
Robert Tivy [Wed, 7 Jan 2015 01:58:42 +0000 (17:58 -0800)]
Restrict new DT processing code to KERNEL_VERSION(3,14,0) or greater

6 years agoAdd @code directive for DT snippet
Robert Tivy [Tue, 6 Jan 2015 22:46:14 +0000 (14:46 -0800)]
Add @code directive for DT snippet

6 years agoUpdated CMEM README, and cmem.h cdoc for DT support
Robert Tivy [Tue, 23 Dec 2014 01:00:24 +0000 (17:00 -0800)]
Updated CMEM README, and cmem.h cdoc for DT support

The README file in src/cmem was out-of-date and needed updating.

Updated CMEM cdoc content in cmem.h with DT support.

6 years agoChange comparison of get_phys() return value to ~(0LL)
Robert Tivy [Mon, 22 Dec 2014 19:17:13 +0000 (11:17 -0800)]
Change comparison of get_phys() return value to ~(0LL)

get_phys() returns a phys_addr_t, and returns ~(0LL) on failure.  Code that
checks for failure from get_phys() should check against ~(0LL) instead of
~(0L).  This mostly affects systems that are compiled using the LPAE mode
which causes phys_addr_t to be 64-bits instead of 32-bits.

6 years agoAdd DT processing for CMEM blocks and pools
Robert Tivy [Fri, 12 Dec 2014 23:32:21 +0000 (15:32 -0800)]
Add DT processing for CMEM blocks and pools

Until now, CMEM memory blocks and pool geometry have been specified on
the insmod/modprobe command-line (with phys_start/phys_end/pools, etc.).
Support is added for processing CMEM memory blocks and pool geometry from
the Linux Device Tree (DT).  Both the DT and the command-line can be used
simultaneously, with CMEM DT specifications taking precedence over
corresponding command-line specification.

6 years agoBump CMEM_VERSION to 0x04000300 4.00 4.00.03.13_eng 4.00.03.14
Robert Tivy [Thu, 22 May 2014 21:36:00 +0000 (14:36 -0700)]
Bump CMEM_VERSION to 0x04000300

CMEM_VERSION has been changed from 0x04000000 to 0x04000300 (reflecting
MSRP 4.00.03.xx) since a new ioctl() command was added.  Programs wanting
to use the new ioctl() can check if CMEM_VERSION >= 0x04000300.

6 years agoAndroid: Added makefiles to build CMEM in AFS environment 4.00.03.12_eng
Arnie Reynoso [Fri, 2 May 2014 18:21:21 +0000 (11:21 -0700)]
Android: Added makefiles to build CMEM in AFS environment

Added the necessary makefiles to build the CMEM user library and tests
applications from within the Android Filesystem Sources (AFS).

6 years agoAdd CMEM_cacheWbInvAll() API
Robert Tivy [Fri, 9 May 2014 00:24:11 +0000 (17:24 -0700)]
Add CMEM_cacheWbInvAll() API

For buffer sizes above a certain threshold, a writeback/invalidate-all
operation is quicker than a range-based writeback/invalidate.

7 years agoRemove printk() of __FILE__ in intro banner()
Robert Tivy [Wed, 2 Apr 2014 22:48:33 +0000 (15:48 -0700)]
Remove printk() of __FILE__ in intro banner()

7 years agoAllow bigger sizes for CMEM_getBlock and CMEM_getPool 4.00.02.10_eng 4.00.02.11
Robert Tivy [Sat, 18 Jan 2014 01:25:49 +0000 (17:25 -0800)]
Allow bigger sizes for CMEM_getBlock and CMEM_getPool

CMEM_getBlock() (and CMEM_getBlockAttrs) was broken for the new extended
blocks.  The interface has been changed to allow for returning a size
greater than the value that will fit in a 'size_t' type.

CMEM_getPool() did not allow a size greater than the value that will fit
in a 'size_t' type.  This API has been changed to allow specifying an
extended size, to support pools with an extended buffer size.

7 years agoFixes stack corruption for FREEPHYS ioctl() 4.00.02.09_eng
Robert Tivy [Mon, 13 Jan 2014 19:20:31 +0000 (11:20 -0800)]
Fixes stack corruption for FREEPHYS ioctl()

7 years agoAllow cmemk.c's mmap method to map a subset of an allocated buffer
Robert Tivy [Fri, 10 Jan 2014 22:40:03 +0000 (14:40 -0800)]
Allow cmemk.c's mmap method to map a subset of an allocated buffer

7 years agoAllow pool size to be > 2 GB
Robert Tivy [Thu, 9 Jan 2014 23:15:41 +0000 (15:15 -0800)]
Allow pool size to be > 2 GB

Change pool-based sizes to be unsigned long long instead of int.

The interface is still limited to size_t (4 byte) amounts, so the only
way to effectively allocate a pool buffer that is > 2 GB in size is to
use CMEM_allocPoolPhys(), which doesn't involve a size parameter nor
need a size back from the driver since it doesn't mmap() the buffer.
When using CMEM_allocPoolPhys(), the user "knows" the pool number that
contains the big buffers and also the size of those buffers.

7 years agoDocs: Fix some comments giving doxygen a hard time
Chris Ring [Fri, 13 Dec 2013 02:13:59 +0000 (18:13 -0800)]
Docs: Fix some comments giving doxygen a hard time

Doxygen runs were complaining about some of the non-escaped
characters.  This commit wordsmiths around those issues.

7 years agoCMEM: Minor debug trace fixes
Chris Ring [Thu, 12 Dec 2013 22:58:36 +0000 (14:58 -0800)]
CMEM: Minor debug trace fixes

Fix a few typos and __D macro usages.

7 years agoSDOCM00105600: Support 4 blocks by default (was 2)
Chris Ring [Thu, 12 Dec 2013 00:19:59 +0000 (16:19 -0800)]
SDOCM00105600: Support 4 blocks by default (was 2)

A key customer required 4 blocks rather than the 2 blocks
supported by default.

7 years agoSDOCM00105476: CMEM user lib has debug hard-enabled
Chris Ring [Wed, 11 Dec 2013 21:47:17 +0000 (13:47 -0800)]
SDOCM00105476: CMEM user lib has debug hard-enabled

Backing out this inadvertently added definition.

7 years agoCMEM: Fix debug build warnings
Chris Ring [Wed, 11 Dec 2013 18:04:43 +0000 (10:04 -0800)]
CMEM: Fix debug build warnings

Adjust the format string in some debug print statements
to accommodate for there [now larger] sizes.

7 years agoDocs: Fix errant documentation
Chris Ring [Thu, 21 Nov 2013 22:48:48 +0000 (14:48 -0800)]
Docs: Fix errant documentation

7 years agoChanges for 'make' subsystem to accommodate yocto 4.00.01.08
Robert Tivy [Tue, 19 Nov 2013 01:23:59 +0000 (17:23 -0800)]
Changes for 'make' subsystem to accommodate yocto

7 years agoNew APIs to allocate and map separately
Robert Tivy [Thu, 7 Nov 2013 01:26:50 +0000 (17:26 -0800)]
New APIs to allocate and map separately

Introduced a "Phys" version of every CMEM_alloc*() API as well as
CMEM_freePhys().  Also introduced a CMEM_map()/CMEM_unmap() API set
that allows user-space mapping of physical buffers decoupled from the
allocation.

7 years agoAccommodate Linux kernel removal of 'num_physpages'
Robert Tivy [Thu, 7 Nov 2013 00:00:42 +0000 (16:00 -0800)]
Accommodate Linux kernel removal of 'num_physpages'

The global var 'num_physpages' was removed in Linux 3.11 mainline, and
was replaced by a function named get_num_physpages().  New code to handle
this is added conditionally.

7 years agoFix for issue preventing phys block spec > 2GB length
Robert Tivy [Wed, 6 Nov 2013 23:45:11 +0000 (15:45 -0800)]
Fix for issue preventing phys block spec > 2GB length

Change physical block length handling to be > 31 bits (signed int limit).

7 years agoAccomodate changes in new v3.10 kernel trees 4.00.01.07_eng
Robert Tivy [Thu, 10 Oct 2013 22:18:26 +0000 (15:18 -0700)]
Accomodate changes in new v3.10 kernel trees

The kernel API create_proc_entry() went away in v3.10 Linux, so replace
it with proc_create() (which has existed for many moons).

Need to also #include <linux/slab.h> for kmalloc()/kfree() prototypes

7 years agoAdd support for CMA-based pools 4.00.00.05_eng 4.00.00.06
Robert Tivy [Wed, 3 Jul 2013 01:14:52 +0000 (18:14 -0700)]
Add support for CMA-based pools

Add ability to perform pool allocations from CMEM-specific CMA pools.
This is supported by a new "block" for CMA, named CMEM_CMABLOCKID, which
can be specified as the block ID in "2" flavors of CMEM APIs (e.g.,
CMEM_alloc2()).  Needs builtin kernel stub file cmemk_stub.c.

CMEM CMA heap allocations are supported with and without the cmemk_stub.c
file.

7 years agoChange TOOLCHAIN_PREFIX assignment to be conditional. 4.00.00.04_eng
Robert Tivy [Thu, 27 Jun 2013 23:13:06 +0000 (16:13 -0700)]
Change TOOLCHAIN_PREFIX assignment to be conditional.

Changed "TOOLCHAIN_PREFIX = ..." to "TOOLCHAIN_PREFIX ?= ..."

7 years agoChange HeapMem management to be based on physical addresses 4.00.00.03_eng
Robert Tivy [Mon, 24 Jun 2013 22:44:53 +0000 (15:44 -0700)]
Change HeapMem management to be based on physical addresses

Changes HeapMem management from handling VA-based freelist to handling
PA-based freelist.

Need to no longer create a kernel mapping for the whole physical block, as
this can take up way too much kernel VA space, and instead create/destroy
mappings on-the-fly when we need to update the freelist that is contained in
the heap itself.

7 years agoAdd support for > 32-bit physical address and global CMA allocations 4.00.00.02_eng
Robert Tivy [Fri, 14 Jun 2013 22:41:44 +0000 (15:41 -0700)]
Add support for > 32-bit physical address and global CMA allocations

Add support for physically-specified "carveouts" whose address is
> 32-bits.  Architectures with LPAE (Large Physical Address Extension),
such as Keystone II, use a 36-bit address for DRAM.  This involves:
- treating all physical addresses as phys_addr_t types in the
  kernel module.
- treating all physical addresses in the ioctl interface as
  unsigned long long.
- treating all physical addresses in the user layer as off_t
By doing the above bullets, everything will adjust correctly when
phys_addr_t (at kernel level) and off_t (at user level) are 32-bit
or 64-bit types.

When using a physical carveout with > 32-bits, you must build the user
layers (both tests/applications and cmem library) with the option
"-D_FILE_OFFSET_BITS=64".

Add support for global CMA area allocations.  A new CMEM_AllocParams.type
of CMEM_CMA is added to support this.  CMEM treats the global CMA area
as a heap, so any size allocation can be requested.

7 years agoRemove automake files not being used 4.00.00.01_eng
Arnie Reynoso [Wed, 15 May 2013 21:00:16 +0000 (14:00 -0700)]
Remove automake files not being used

Signed-off-by: Chris Ring <cring@ti.com>
7 years agoCMEM: Fix copyright/license, branding
Chris Ring [Wed, 15 May 2013 20:06:18 +0000 (13:06 -0700)]
CMEM: Fix copyright/license, branding

cmem.h was missing a copyright and [BSD] license.

Also, as the branding changed from Linux Utils 3.x to 4.x, removed
'sdo' and 'linuxutils' from some of the places these global namespaces
were used (doxygen, multiple inclusion guards).

7 years agoAdded missing autotools configure and helper scripts
Arnie Reynoso [Wed, 15 May 2013 18:42:03 +0000 (11:42 -0700)]
Added missing autotools configure and helper scripts

Signed-off-by: Chris Ring <cring@ti.com>
7 years agoCopyright: Added copyright and license statements
Chris Ring [Wed, 15 May 2013 18:58:14 +0000 (11:58 -0700)]
Copyright: Added copyright and license statements

All sources are Copyright TI.

The user space content, including tests is BSD licensed.

The kernel content is GPLv2 licensed.

7 years agoInitial commit
Robert Tivy [Wed, 15 May 2013 18:06:58 +0000 (11:06 -0700)]
Initial commit

The CMEM module has been taken from the linuxutils stream and ported to
use in-kernel CMA. The user API set remains the same.