cmem: Add portability fix for user space library source
Adds handling of 64 bit properly
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Adds handling of 64 bit properly
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
version: update to new version 4.16.0.0
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
version: update to new version 4.15.0.2
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
lu.mak: Update to allow building for aarch64
Remove hard coding to ARCH=arm
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Remove hard coding to ARCH=arm
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
cmem: Update version number to 4.15.0.1
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
Fixes one issue related to falling through for direct mapped memory.
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
Need to check all negative values not only -1.
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
version: Update version number to 4.15.00.00
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
cmemk: Cleanup of tabs and spaces
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
cmemk: Clean up of tabs and spaces
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
cmemk: Add error checks and cleanup
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
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>
In case of error, function expected to return negative value
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
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>
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>
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>
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>
cmem: Update version to 4.14.01.00
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
Updating Android makefile to generate cmem userspace binaries and
libraries in /vendor location instead of /system.
Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
version: Update cmem version to 4.14
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
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>
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>
cmem: Update version
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
This is a bug fix. Uninitialized variable caused freeing of random
pointer and page fault.
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
version: Update cmem version
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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
---
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
---
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.
---
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.
---
tests: Update apitest to exercise dmabuf export
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
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>
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>
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>
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>
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>
coherent_dma_mask was not set for Am57x platforms and resulted in
allocation failure
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Documentation: Add kernel device tree documentation
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
- 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>
version: Update version to 4.12.0.0
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
Revert "Remove assembly function hack for !MULTI_CACHE case"
This reverts commit d5481f4d32edbc320a0853b2ddfdfe8dedc8d017.
This reverts commit d5481f4d32edbc320a0853b2ddfdfe8dedc8d017.
cmem: Update version to 4.1.0.1
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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.
Revert "Remove assembly function hack for !MULTI_CACHE case"
This reverts commit 09d38fe7dfed7067e4e6d10a1c22a0bcc3af0271.
This reverts commit 09d38fe7dfed7067e4e6d10a1c22a0bcc3af0271.
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
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
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
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
Fix some typos
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.
All the makefiles for Android builds were refactored into a single file and moved
to the root of the repo.
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.
When the -n option is given, the test does not prompt for ENTER and runs
to completion without user input.
Change int to unsigned int to suppress warnings
Warnings for signed/unsigned comparisons are obnoxious, change certain
int to unsigned int to remove warnings.
Warnings for signed/unsigned comparisons are obnoxious, change certain
int to unsigned int to remove warnings.
Modify apitest for Android
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.
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.
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.
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.
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.
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.
Cleanup #if 0|1 blocks and commented-out code
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.
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.
Fix cache handling code
Cache handling code was using the wrong physical address.
Cache invalidations need to use outer/inner operation ordering (was
reversed).
Cache handling code was using the wrong physical address.
Cache invalidations need to use outer/inner operation ordering (was
reversed).
Restrict new DT processing code to KERNEL_VERSION(3,14,0) or greater
Add @code directive for DT snippet
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.
The README file in src/cmem was out-of-date and needed updating.
Updated CMEM cdoc content in cmem.h with DT support.
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.
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.
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.
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.
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.
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.
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).
Added the necessary makefiles to build the CMEM user library and tests
applications from within the Android Filesystem Sources (AFS).
Add CMEM_cacheWbInvAll() API
For buffer sizes above a certain threshold, a writeback/invalidate-all
operation is quicker than a range-based writeback/invalidate.
For buffer sizes above a certain threshold, a writeback/invalidate-all
operation is quicker than a range-based writeback/invalidate.
Remove printk() of __FILE__ in intro banner()
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.
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.
Fixes stack corruption for FREEPHYS ioctl()
Allow cmemk.c's mmap method to map a subset of an allocated buffer
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.
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.
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.
Doxygen runs were complaining about some of the non-escaped
characters. This commit wordsmiths around those issues.
CMEM: Minor debug trace fixes
Fix a few typos and __D macro usages.
Fix a few typos and __D macro usages.
SDOCM00105600: Support 4 blocks by default (was 2)
A key customer required 4 blocks rather than the 2 blocks
supported by default.
A key customer required 4 blocks rather than the 2 blocks
supported by default.
SDOCM00105476: CMEM user lib has debug hard-enabled
Backing out this inadvertently added definition.
Backing out this inadvertently added definition.
CMEM: Fix debug build warnings
Adjust the format string in some debug print statements
to accommodate for there [now larger] sizes.
Adjust the format string in some debug print statements
to accommodate for there [now larger] sizes.
Docs: Fix errant documentation
Changes for 'make' subsystem to accommodate yocto
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.
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.
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.
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.
Fix for issue preventing phys block spec > 2GB length
Change physical block length handling to be > 31 bits (signed int limit).
Change physical block length handling to be > 31 bits (signed int limit).
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
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
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.
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.
Change TOOLCHAIN_PREFIX assignment to be conditional.
Changed "TOOLCHAIN_PREFIX = ..." to "TOOLCHAIN_PREFIX ?= ..."
Changed "TOOLCHAIN_PREFIX = ..." to "TOOLCHAIN_PREFIX ?= ..."
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.
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.
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.
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.
Remove automake files not being used
Signed-off-by: Chris Ring <cring@ti.com>
Signed-off-by: Chris Ring <cring@ti.com>
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).
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).
Added missing autotools configure and helper scripts
Signed-off-by: Chris Ring <cring@ti.com>
Signed-off-by: Chris Ring <cring@ti.com>
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.
All sources are Copyright TI.
The user space content, including tests is BSD licensed.
The kernel content is GPLv2 licensed.
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.
The CMEM module has been taken from the linuxutils stream and ported to
use in-kernel CMA. The user API set remains the same.