From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "Zhang, Qi" Date: Tue, 17 Jul 2018 21:16:53 +0800 Subject: [PATCH] refine work queue in trusty driver Change-Id: I049497485f87d2c90e23be11893696513602800b Tracked-On: OAM-66823 Signed-off-by: Zhang, Qi --- drivers/trusty/trusty-timer.c | 7 +------ drivers/trusty/trusty-virtio.c | 4 ++-- drivers/trusty/trusty.c | 9 ++++++--- include/linux/trusty/smcall.h | 3 +++ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/trusty/trusty-timer.c b/drivers/trusty/trusty-timer.c index 18e315c25067..6783a30b4a11 100644 --- a/drivers/trusty/trusty-timer.c +++ b/drivers/trusty/trusty-timer.c @@ -36,11 +36,6 @@ struct trusty_timer_dev_state { struct workqueue_struct *workqueue; }; -/* Max entity defined as SMC_NUM_ENTITIES(64) */ -#define SMC_ENTITY_SMC_X86 63 /* Used for customized SMC calls */ - -#define SMC_SC_LK_TIMER SMC_STDCALL_NR(SMC_ENTITY_SMC_X86, 0) - static void timer_work_func(struct work_struct *work) { int ret; @@ -59,7 +54,7 @@ static enum hrtimer_restart trusty_timer_cb(struct hrtimer *tm) s = container_of(tm, struct trusty_timer_dev_state, timer.tm); - queue_work(s->workqueue, &s->timer.work); + queue_work_on(0, s->workqueue, &s->timer.work); return HRTIMER_NORESTART; } diff --git a/drivers/trusty/trusty-virtio.c b/drivers/trusty/trusty-virtio.c index 66b4ee7caf0d..df066dda80d3 100644 --- a/drivers/trusty/trusty-virtio.c +++ b/drivers/trusty/trusty-virtio.c @@ -150,7 +150,7 @@ 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); + queue_work_on(0, tctx->kick_wq, &tctx->kick_vqs); } else { trusty_enqueue_nop(tctx->dev->parent, &tvr->kick_nop); } @@ -685,7 +685,7 @@ static int trusty_virtio_probe(struct platform_device *pdev) } tctx->kick_wq = alloc_workqueue("trusty-kick-wq", - WQ_UNBOUND | WQ_CPU_INTENSIVE, 0); + WQ_CPU_INTENSIVE, 0); if (!tctx->kick_wq) { ret = -ENODEV; dev_err(&pdev->dev, "Failed create trusty-kick-wq\n"); diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c index 4d33f269851d..8f80f9b84772 100755 --- a/drivers/trusty/trusty.c +++ b/drivers/trusty/trusty.c @@ -270,7 +270,6 @@ static long trusty_std_call32_work(void *args) s32 trusty_std_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2) { - const int cpu = 0; struct trusty_std_call32_args args = { .dev = dev, .smcnr = smcnr, @@ -280,7 +279,11 @@ s32 trusty_std_call32(struct device *dev, u32 smcnr, u32 a0, u32 a1, u32 a2) }; /* bind cpu 0 for now since trusty OS is running on physical cpu #0*/ - return work_on_cpu(cpu, trusty_std_call32_work, (void *) &args); + if((smcnr == SMC_SC_VDEV_KICK_VQ) || (smcnr == SMC_SC_LK_TIMER) + || (smcnr == SMC_SC_LOCKED_NOP) || (smcnr == SMC_SC_NOP)) + return trusty_std_call32_work((void *) &args); + else + return work_on_cpu(0, trusty_std_call32_work, (void *) &args); } EXPORT_SYMBOL(trusty_std_call32); @@ -490,7 +493,7 @@ 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); + queue_work_on(0, s->nop_wq, &tw->work); preempt_enable(); } EXPORT_SYMBOL(trusty_enqueue_nop); diff --git a/include/linux/trusty/smcall.h b/include/linux/trusty/smcall.h index 3ab2f688cb33..55d25dddc4a8 100644 --- a/include/linux/trusty/smcall.h +++ b/include/linux/trusty/smcall.h @@ -152,4 +152,7 @@ #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) +/* Max entity defined as SMC_NUM_ENTITIES(64) */ +#define SMC_ENTITY_SMC_X86 63 /* Used for customized SMC calls */ +#define SMC_SC_LK_TIMER SMC_STDCALL_NR(SMC_ENTITY_SMC_X86, 0) #endif /* __LINUX_TRUSTY_SMCALL_H */ -- https://clearlinux.org