2019-03-29 14:12:17 +08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-01-23 17:39:12 +08:00
|
|
|
From: "Zhong,Fangjian" <fangjian.zhong@intel.com>
|
|
|
|
Date: Tue, 11 Jul 2017 04:44:59 +0000
|
2019-03-29 14:12:17 +08:00
|
|
|
Subject: [PATCH] trusty: switch to use version 3 of TRUSTY_API
|
2019-01-23 17:39:12 +08:00
|
|
|
|
|
|
|
Version 3 of Trusty API adds support for new command
|
|
|
|
(SMC_NC_VDEV_KICK_VQ) that can be used to notify virtqueue
|
|
|
|
that new item is available. This command is a parameterized
|
|
|
|
NOP, it has to be queued using trusty_enqueue_nop API and as
|
|
|
|
such can be executed concurrently on multiple CPUs.
|
|
|
|
|
|
|
|
Change-Id: I9ba615e70b59e0689a47fa6eae0a6d9ba6033841
|
|
|
|
Signed-off-by: Zhong,Fangjian <fangjian.zhong@intel.com>
|
|
|
|
Author: Michael Ryleev <gmar@google.com>
|
|
|
|
---
|
|
|
|
drivers/trusty/trusty-virtio.c | 18 +++++++++++++++---
|
|
|
|
include/linux/trusty/smcall.h | 1 +
|
|
|
|
2 files changed, 16 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/drivers/trusty/trusty-virtio.c b/drivers/trusty/trusty-virtio.c
|
2020-10-27 02:14:06 +08:00
|
|
|
index 6bbf80ce7d7f..b2418d7da5e1 100644
|
2019-01-23 17:39:12 +08:00
|
|
|
--- a/drivers/trusty/trusty-virtio.c
|
|
|
|
+++ b/drivers/trusty/trusty-virtio.c
|
|
|
|
@@ -60,7 +60,8 @@ struct trusty_vring {
|
|
|
|
atomic_t needs_kick;
|
|
|
|
struct fw_rsc_vdev_vring *vr_descr;
|
|
|
|
struct virtqueue *vq;
|
|
|
|
- struct trusty_vdev *tvdev;
|
|
|
|
+ struct trusty_vdev *tvdev;
|
|
|
|
+ struct trusty_nop kick_nop;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct trusty_vdev {
|
|
|
|
@@ -144,8 +145,14 @@ static bool trusty_virtio_notify(struct virtqueue *vq)
|
|
|
|
struct trusty_vdev *tvdev = tvr->tvdev;
|
|
|
|
struct trusty_ctx *tctx = tvdev->tctx;
|
|
|
|
|
|
|
|
- atomic_set(&tvr->needs_kick, 1);
|
|
|
|
- queue_work(tctx->kick_wq, &tctx->kick_vqs);
|
|
|
|
+ u32 api_ver = trusty_get_api_version(tctx->dev->parent);
|
|
|
|
+
|
|
|
|
+ if (api_ver < TRUSTY_API_VERSION_SMP_NOP) {
|
|
|
|
+ atomic_set(&tvr->needs_kick, 1);
|
|
|
|
+ queue_work(tctx->kick_wq, &tctx->kick_vqs);
|
|
|
|
+ } else {
|
|
|
|
+ trusty_enqueue_nop(tctx->dev->parent, &tvr->kick_nop);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
@@ -269,6 +276,9 @@ static void _del_vqs(struct virtio_device *vdev)
|
|
|
|
struct trusty_vring *tvr = &tvdev->vrings[0];
|
|
|
|
|
|
|
|
for (i = 0; i < tvdev->vring_num; i++, tvr++) {
|
|
|
|
+ /* dequeue kick_nop */
|
|
|
|
+ trusty_dequeue_nop(tvdev->tctx->dev->parent, &tvr->kick_nop);
|
|
|
|
+
|
|
|
|
/* delete vq */
|
|
|
|
if (tvr->vq) {
|
|
|
|
vring_del_virtqueue(tvr->vq);
|
|
|
|
@@ -431,6 +441,8 @@ static int trusty_virtio_add_device(struct trusty_ctx *tctx,
|
|
|
|
tvr->align = vr_descr->align;
|
|
|
|
tvr->elem_num = vr_descr->num;
|
|
|
|
tvr->notifyid = vr_descr->notifyid;
|
|
|
|
+ trusty_nop_init(&tvr->kick_nop, SMC_NC_VDEV_KICK_VQ,
|
|
|
|
+ tvdev->notifyid, tvr->notifyid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* register device */
|
|
|
|
diff --git a/include/linux/trusty/smcall.h b/include/linux/trusty/smcall.h
|
2020-10-27 02:14:06 +08:00
|
|
|
index fc98b3e5b2e7..037b3fa4429e 100644
|
2019-01-23 17:39:12 +08:00
|
|
|
--- a/include/linux/trusty/smcall.h
|
|
|
|
+++ b/include/linux/trusty/smcall.h
|
|
|
|
@@ -131,5 +131,6 @@
|
|
|
|
|
|
|
|
#define SMC_SC_VDEV_RESET SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23)
|
|
|
|
#define SMC_SC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24)
|
|
|
|
+#define SMC_NC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 25)
|
|
|
|
|
|
|
|
#endif /* __LINUX_TRUSTY_SMCALL_H */
|
|
|
|
--
|
2019-04-08 18:08:36 +08:00
|
|
|
https://clearlinux.org
|
2019-01-23 17:39:12 +08:00
|
|
|
|