summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2022-04-20 23:07:28 -0700
committerWill McVicker <willmcvicker@google.com>2022-04-29 16:57:44 -0700
commit6305b885670758d16631983d435b984081a0d38d (patch)
tree2ae7c3df639c44e52d63bce7ad95b6c0db8a13c4
parent2100a8b61eb49ab5426003a5040283c95810be67 (diff)
downloadtrusty-6305b885670758d16631983d435b984081a0d38d.tar.gz
trusty: add a toggle for using high prio WQ
Bug: 229350721 Test: UDFPS with stress Signed-off-by: Wei Wang <wvw@google.com> (cherry picked from commit 229137adb4627cb9341b7148bee797fbddad2e80) Change-Id: I241a9a6ecd840577601dae7886fb212a2d46d71d (cherry picked from commit bc10c2f6eb1a3f51a814c7acd84ee07cba63e144) Signed-off-by: Will McVicker <willmcvicker@google.com>
-rw-r--r--drivers/trusty/trusty-virtio.c37
-rw-r--r--drivers/trusty/trusty.c19
2 files changed, 51 insertions, 5 deletions
diff --git a/drivers/trusty/trusty-virtio.c b/drivers/trusty/trusty-virtio.c
index fea59cd..30111c4 100644
--- a/drivers/trusty/trusty-virtio.c
+++ b/drivers/trusty/trusty-virtio.c
@@ -31,7 +31,8 @@
#define RSC_DESCR_VER 1
struct trusty_vdev;
-
+static bool use_high_wq;
+module_param(use_high_wq, bool, 0660);
struct trusty_ctx {
struct device *dev;
void *shared_va;
@@ -45,6 +46,8 @@ struct trusty_ctx {
struct mutex mlock; /* protects vdev_list */
struct workqueue_struct *kick_wq;
struct workqueue_struct *check_wq;
+ struct workqueue_struct *kick_wq_high;
+ struct workqueue_struct *check_wq_high;
};
struct trusty_vring {
@@ -99,8 +102,10 @@ static int trusty_call_notify(struct notifier_block *nb,
return NOTIFY_DONE;
tctx = container_of(nb, struct trusty_ctx, call_notifier);
- queue_work(tctx->check_wq, &tctx->check_vqs);
-
+ if (use_high_wq)
+ queue_work(tctx->check_wq_high, &tctx->check_vqs);
+ else
+ queue_work(tctx->check_wq, &tctx->check_vqs);
return NOTIFY_OK;
}
@@ -148,7 +153,10 @@ static bool trusty_virtio_notify(struct virtqueue *vq)
if (api_ver < TRUSTY_API_VERSION_SMP_NOP) {
atomic_set(&tvr->needs_kick, 1);
- queue_work(tctx->kick_wq, &tctx->kick_vqs);
+ if (use_high_wq)
+ queue_work(tctx->kick_wq_high, &tctx->kick_vqs);
+ else
+ queue_work(tctx->kick_wq, &tctx->kick_vqs);
} else {
trusty_enqueue_nop(tctx->dev->parent, &tvr->kick_nop);
}
@@ -751,6 +759,21 @@ static int trusty_virtio_probe(struct platform_device *pdev)
goto err_create_kick_wq;
}
+ tctx->check_wq_high = alloc_workqueue("trusty-check-wq-high", WQ_UNBOUND | WQ_HIGHPRI, 0);
+ if (!tctx->check_wq_high) {
+ ret = -ENODEV;
+ dev_err(&pdev->dev, "Failed create trusty-check-wq-high\n");
+ goto err_create_check_wq_high;
+ }
+
+ tctx->kick_wq_high = alloc_workqueue("trusty-kick-wq-high",
+ WQ_UNBOUND | WQ_CPU_INTENSIVE | WQ_HIGHPRI, 0);
+ if (!tctx->kick_wq_high) {
+ ret = -ENODEV;
+ dev_err(&pdev->dev, "Failed create trusty-kick-wq-high\n");
+ goto err_create_kick_wq_high;
+ }
+
ret = trusty_virtio_add_devices(tctx);
if (ret) {
dev_err(&pdev->dev, "Failed to add virtio devices\n");
@@ -761,6 +784,10 @@ static int trusty_virtio_probe(struct platform_device *pdev)
return 0;
err_add_devices:
+ destroy_workqueue(tctx->kick_wq_high);
+err_create_kick_wq_high:
+ destroy_workqueue(tctx->check_wq_high);
+err_create_check_wq_high:
destroy_workqueue(tctx->kick_wq);
err_create_kick_wq:
destroy_workqueue(tctx->check_wq);
@@ -786,6 +813,8 @@ static int trusty_virtio_remove(struct platform_device *pdev)
/* destroy workqueues */
destroy_workqueue(tctx->kick_wq);
destroy_workqueue(tctx->check_wq);
+ destroy_workqueue(tctx->kick_wq_high);
+ destroy_workqueue(tctx->check_wq_high);
/* notify remote that shared area goes away */
trusty_virtio_stop(tctx, tctx->shared_id, tctx->shared_sz);
diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c
index 265eab5..3cfe7e2 100644
--- a/drivers/trusty/trusty.c
+++ b/drivers/trusty/trusty.c
@@ -24,6 +24,9 @@
struct trusty_state;
static struct platform_driver trusty_driver;
+static bool use_high_wq;
+module_param(use_high_wq, bool, 0660);
+
struct trusty_work {
struct trusty_state *ts;
struct work_struct work;
@@ -38,6 +41,7 @@ struct trusty_state {
bool trusty_panicked;
struct device *dev;
struct workqueue_struct *nop_wq;
+ struct workqueue_struct *nop_wq_high;
struct trusty_work __percpu *nop_works;
struct list_head nop_queue;
spinlock_t nop_lock; /* protects nop_queue */
@@ -799,7 +803,10 @@ void trusty_enqueue_nop(struct device *dev, struct trusty_nop *nop)
list_add_tail(&nop->node, &s->nop_queue);
spin_unlock_irqrestore(&s->nop_lock, flags);
}
- queue_work(s->nop_wq, &tw->work);
+ if (use_high_wq)
+ queue_work(s->nop_wq_high, &tw->work);
+ else
+ queue_work(s->nop_wq, &tw->work);
preempt_enable();
}
EXPORT_SYMBOL(trusty_enqueue_nop);
@@ -873,6 +880,13 @@ static int trusty_probe(struct platform_device *pdev)
goto err_create_nop_wq;
}
+ s->nop_wq_high = alloc_workqueue("trusty-nop-wq-high", WQ_HIGHPRI | WQ_CPU_INTENSIVE, 0);
+ if (!s->nop_wq_high) {
+ ret = -ENODEV;
+ dev_err(&pdev->dev, "Failed create trusty-nop-wq-high\n");
+ goto err_create_nop_wq_high;
+ }
+
s->nop_works = alloc_percpu(struct trusty_work);
if (!s->nop_works) {
ret = -ENOMEM;
@@ -908,6 +922,8 @@ err_add_children:
}
free_percpu(s->nop_works);
err_alloc_works:
+ destroy_workqueue(s->nop_wq_high);
+err_create_nop_wq_high:
destroy_workqueue(s->nop_wq);
err_create_nop_wq:
trusty_free_msg_buf(s, &pdev->dev);
@@ -937,6 +953,7 @@ static int trusty_remove(struct platform_device *pdev)
}
free_percpu(s->nop_works);
destroy_workqueue(s->nop_wq);
+ destroy_workqueue(s->nop_wq_high);
mutex_destroy(&s->share_memory_msg_lock);
mutex_destroy(&s->smc_lock);