clear-pkgs-linux-iot-lts2018/0940-unify-trusty-driver.patch

128 lines
4.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Zhang, Qi" <qi1.zhang@intel.com>
Date: Wed, 7 Mar 2018 15:45:48 +0800
Subject: [PATCH] unify trusty driver
Keep One Trusty driver accross different version kernel as we have One Trusty OS
Change-Id: Ie81201bb543ffdf6050bfab7560bd275f3a92eb0
Signed-off-by: Zhang, Qi <qi1.zhang@intel.com>
---
drivers/trusty/trusty-ipc.c | 7 +++++++
drivers/trusty/trusty-mem.c | 6 +++---
drivers/trusty/trusty-virtio.c | 14 ++++++++++++++
3 files changed, 24 insertions(+), 3 deletions(-)
mode change 100755 => 100644 drivers/trusty/trusty-mem.c
diff --git a/drivers/trusty/trusty-ipc.c b/drivers/trusty/trusty-ipc.c
index a2bc3fc..7df0972 100644
--- a/drivers/trusty/trusty-ipc.c
+++ b/drivers/trusty/trusty-ipc.c
@@ -21,7 +21,10 @@
#include <linux/poll.h>
#include <linux/idr.h>
#include <linux/completion.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
#include <linux/sched/signal.h>
+#endif
#include <linux/sched.h>
#include <linux/compat.h>
#include <linux/uio.h>
@@ -1558,7 +1561,11 @@ static int tipc_virtio_probe(struct virtio_device *vdev)
vds->cdev_name[sizeof(vds->cdev_name)-1] = '\0';
/* find tx virtqueues (rx and tx and in this order) */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
err = vdev->config->find_vqs(vdev, 2, vqs, vq_cbs, vq_names, NULL, NULL);
+#else
+ err = vdev->config->find_vqs(vdev, 2, vqs, vq_cbs, vq_names);
+#endif
if (err)
goto err_find_vqs;
diff --git a/drivers/trusty/trusty-mem.c b/drivers/trusty/trusty-mem.c
old mode 100755
new mode 100644
index fc299e3..470df88
--- a/drivers/trusty/trusty-mem.c
+++ b/drivers/trusty/trusty-mem.c
@@ -77,7 +77,7 @@ static int get_mem_attr(struct page *page, pgprot_t pgprot)
return -EINVAL;
}
#elif defined(CONFIG_X86)
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
/* The porting to CHT kernel (3.14.55) is in the #else clause.
** For BXT kernel (4.1.0), the function get_page_memtype() is static.
**
@@ -93,7 +93,7 @@ static int get_mem_attr(struct page *page, pgprot_t pgprot)
** with SMP, which only allow UNCACHED.
*/
return NS_MAIR_NORMAL_UNCACHED;
- #else
+#else
unsigned long type;
int ret_mem_attr = 0;
@@ -124,7 +124,7 @@ static int get_mem_attr(struct page *page, pgprot_t pgprot)
ret_mem_attr = -EINVAL;
}
return ret_mem_attr;
- #endif
+#endif
#else
return 0;
#endif
diff --git a/drivers/trusty/trusty-virtio.c b/drivers/trusty/trusty-virtio.c
index 743a478..66b4ee7 100644
--- a/drivers/trusty/trusty-virtio.c
+++ b/drivers/trusty/trusty-virtio.c
@@ -15,6 +15,7 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
+#include <linux/version.h>
#include <linux/module.h>
#include <linux/mutex.h>
@@ -337,9 +338,15 @@ static struct virtqueue *_find_vq(struct virtio_device *vdev,
dev_info(&vdev->dev, "vring%d: va(pa) %p(%llx) qsz %d notifyid %d\n",
id, tvr->vaddr, (u64)tvr->paddr, tvr->elem_num, tvr->notifyid);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
tvr->vq = vring_new_virtqueue(id, tvr->elem_num, tvr->align,
vdev, true, true, tvr->vaddr,
trusty_virtio_notify, callback, name);
+#else
+ tvr->vq = vring_new_virtqueue(id, tvr->elem_num, tvr->align,
+ vdev, true, tvr->vaddr,
+ trusty_virtio_notify, callback, name);
+#endif
if (!tvr->vq) {
dev_err(&vdev->dev, "vring_new_virtqueue %s failed\n",
name);
@@ -356,12 +363,19 @@ static struct virtqueue *_find_vq(struct virtio_device *vdev,
return ERR_PTR(-ENOMEM);
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
static int trusty_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
struct virtqueue *vqs[],
vq_callback_t *callbacks[],
const char * const names[],
const bool *ctx,
struct irq_affinity *desc)
+#else
+static int trusty_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
+ struct virtqueue *vqs[],
+ vq_callback_t *callbacks[],
+ const char * const names[])
+#endif
{
uint i;
int ret;
--
https://clearlinux.org