linuxdriver: kernel4.19 "struct dma_buf_ops" have changed [1/1]
authorLiqiang Jin <liqiang.jin@amlogic.com>
Wed, 9 Jan 2019 06:44:59 +0000 (14:44 +0800)
committerLiqiang Jin <liqiang.jin@amlogic.com>
Mon, 21 Jan 2019 03:26:01 +0000 (11:26 +0800)
PD#SWPL-2814

Problem:
because "struct dma_buf_ops" have changed, so compile failed

Solution:
use "struct dma_buf_ops" according to the kernel version

Verify:
Android P + G12A(U200)

Change-Id: I47573d1cfcdc942e4de2ac2c92938ebc4bc975d9
Signed-off-by: Liqiang Jin <liqiang.jin@amlogic.com>
build.sh [new file with mode: 0755]
build_gx.sh [deleted file]
optee/Makefile [changed mode: 0755->0644]
tee_shm.c

diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..5bc4b81
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+LOCAL_PATH=`pwd`
+BASE_PATH=$(cd "$(dirname $0)"; pwd)
+export ARCH=arm
+
+if [ ${ARCH} = arm ]
+then
+       KERNEL_CONFIG=meson64_a32_defconfig
+       export KERNEL_A32_SUPPORT=true
+       export CROSS_COMPILE=arm-linux-gnueabihf-
+else
+       KERNEL_CONFIG=meson64_a64_defconfig
+       export CROSS_COMPILE=aarch64-linux-gnu-
+fi
+
+if [ "${KERNEL_SRC_DIR}" = "" ]
+then
+       KERNEL_SRC_DIR=${BASE_PATH}/../../../../../common/
+fi
+
+if [ "${KERNEL_OUT_DIR}" = "" ]
+then
+       KERNEL_OUT_DIR=${BASE_PATH}/../../../../../common/
+fi
+
+show_help()
+{
+       echo "*** Please export KERNEL_SRC_DIR and KERNEL_OUT_DIR before building."
+       echo "e.g."
+       echo "    export KERNEL_SRC_DIR=/mnt/fileroot/peifu/kernel"
+       echo "    export KERNEL_OUT_DIR=/mnt/fileroot/peifu/kernel/out"
+       echo "    ./build_gx.sh"
+}
+
+show_path()
+{
+       echo "*** KERNEL_SRC_DIR=$KERNEL_SRC_DIR"
+       echo "*** KERNEL_OUT_DIR=$KERNEL_OUT_DIR"
+}
+
+do_build()
+{
+       if [ ! -d $KERNEL_SRC_DIR ]; then
+               echo "*** $KERNEL_SRC_DIR: No such directory!"
+               show_help;
+               exit;
+       fi
+       if [ ! -d $KERNEL_OUT_DIR ]; then
+               echo "*** $KERNEL_OUT_DIR not exist, create now\n"
+               mkdir -p $KERNEL_OUT_DIR
+       fi
+       if [ ! -e $KERNEL_OUT_DIR/include/generated/autoconf.h ]; then
+               make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR $KERNEL_CONFIG
+               make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR modules_prepare
+       fi
+       make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR M=$LOCAL_PATH modules
+}
+
+do_clean()
+{
+       if [ ! -d $KERNEL_SRC_DIR ]; then
+               echo "*** $KERNEL_SRC_DIR: No such directory!\n"
+               show_help;
+               exit;
+       fi
+       make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR M=$LOCAL_PATH clean
+}
+
+if [ "$1" = "help" ]; then
+       show_help;
+       exit;
+elif [ "$1" = "clean" ]; then
+       do_clean;
+       exit;
+else
+       show_path;
+       do_build;
+fi
diff --git a/build_gx.sh b/build_gx.sh
deleted file mode 100755 (executable)
index 53bb93d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash
-
-LOCAL_PATH=`pwd`
-KERNEL_CONFIG=meson64_defconfig
-export ARCH=arm64
-export CROSS_COMPILE=aarch64-linux-gnu-
-
-if [ "$KERNEL_SRC_DIR" = "" ]; then
-       KERNEL_SRC_DIR=/mnt/fileroot/peifu/kernel-m8
-fi
-if [ "$KERNEL_OUT_DIR" = "" ]; then
-       KERNEL_OUT_DIR=/mnt/fileroot/peifu/kernel-m8/out
-fi
-
-show_help()
-{
-       echo "*** Please export KERNEL_SRC_DIR and KERNEL_OUT_DIR before building."
-       echo "e.g."
-       echo "    export KERNEL_SRC_DIR=/mnt/fileroot/peifu/kernel"
-       echo "    export KERNEL_OUT_DIR=/mnt/fileroot/peifu/kernel/out"
-       echo "    ./build_gx.sh"
-}
-
-show_path()
-{
-       echo "*** KERNEL_SRC_DIR=$KERNEL_SRC_DIR"
-       echo "*** KERNEL_OUT_DIR=$KERNEL_OUT_DIR"
-}
-
-do_build()
-{
-       if [ ! -d $KERNEL_SRC_DIR ]; then
-               echo "*** $KERNEL_SRC_DIR: No such directory!"
-               show_help;
-               exit;
-       fi
-       if [ ! -d $KERNEL_OUT_DIR ]; then
-               echo "*** $KERNEL_OUT_DIR not exist, create now\n"
-               mkdir -p $KERNEL_OUT_DIR
-       fi
-       if [ ! -e $KERNEL_OUT_DIR/include/generated/autoconf.h ]; then
-               make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR $KERNEL_CONFIG
-               make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR modules_prepare
-       fi
-       make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR M=$LOCAL_PATH modules
-}
-
-do_clean()
-{
-       if [ ! -d $KERNEL_SRC_DIR ]; then
-               echo "*** $KERNEL_SRC_DIR: No such directory!\n"
-               show_help;
-               exit;
-       fi
-       make -C $KERNEL_SRC_DIR O=$KERNEL_OUT_DIR M=$LOCAL_PATH clean
-}
-
-if [ "$1" = "help" ]; then
-       show_help;
-       exit;
-elif [ "$1" = "clean" ]; then
-       do_clean;
-       exit;
-else
-       show_path;
-       do_build;
-fi
old mode 100755 (executable)
new mode 100644 (file)
index b820d4b2ebb602e64b3a4ed7dd74a76e4e4cb6e3..89b1c070a694c74eb980e193f9bdebf73b173f77 100755 (executable)
--- a/tee_shm.c
+++ b/tee_shm.c
@@ -81,6 +81,12 @@ static void tee_shm_op_release(struct dma_buf *dmabuf)
        tee_shm_release(shm);
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 12)
+static void *tee_shm_op_map(struct dma_buf *dmabuf, unsigned long pgnum)
+{
+       return NULL;
+}
+#else
 static void *tee_shm_op_kmap_atomic(struct dma_buf *dmabuf, unsigned long pgnum)
 {
        return NULL;
@@ -90,6 +96,7 @@ static void *tee_shm_op_kmap(struct dma_buf *dmabuf, unsigned long pgnum)
 {
        return NULL;
 }
+#endif
 
 static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
 {
@@ -104,8 +111,12 @@ static struct dma_buf_ops tee_shm_dma_buf_ops = {
        .map_dma_buf = tee_shm_op_map_dma_buf,
        .unmap_dma_buf = tee_shm_op_unmap_dma_buf,
        .release = tee_shm_op_release,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 12)
+       .map = tee_shm_op_map,
+#else
        .kmap_atomic = tee_shm_op_kmap_atomic,
        .kmap = tee_shm_op_kmap,
+#endif
        .mmap = tee_shm_op_mmap,
 };