diff options
-rw-r--r-- | drivers/trusty/trusty-virtio.c | 22 | ||||
-rw-r--r-- | drivers/trusty/trusty.c | 26 |
2 files changed, 29 insertions, 19 deletions
diff --git a/drivers/trusty/trusty-virtio.c b/drivers/trusty/trusty-virtio.c index 30111c4..8a7eb69 100644 --- a/drivers/trusty/trusty-virtio.c +++ b/drivers/trusty/trusty-virtio.c @@ -33,6 +33,7 @@ struct trusty_vdev; static bool use_high_wq; module_param(use_high_wq, bool, 0660); + struct trusty_ctx { struct device *dev; void *shared_va; @@ -46,7 +47,6 @@ 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; }; @@ -106,6 +106,7 @@ static int trusty_call_notify(struct notifier_block *nb, queue_work(tctx->check_wq_high, &tctx->check_vqs); else queue_work(tctx->check_wq, &tctx->check_vqs); + return NOTIFY_OK; } @@ -153,10 +154,7 @@ static bool trusty_virtio_notify(struct virtqueue *vq) if (api_ver < TRUSTY_API_VERSION_SMP_NOP) { atomic_set(&tvr->needs_kick, 1); - if (use_high_wq) - queue_work(tctx->kick_wq_high, &tctx->kick_vqs); - else - queue_work(tctx->kick_wq, &tctx->kick_vqs); + queue_work(tctx->kick_wq, &tctx->kick_vqs); } else { trusty_enqueue_nop(tctx->dev->parent, &tvr->kick_nop); } @@ -759,21 +757,14 @@ 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); + 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"); @@ -784,8 +775,6 @@ 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); @@ -813,7 +802,6 @@ 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 */ diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c index 3cfe7e2..c773beb 100644 --- a/drivers/trusty/trusty.c +++ b/drivers/trusty/trusty.c @@ -757,9 +757,26 @@ static void nop_work_func(struct work_struct *work) u32 last_arg0; struct trusty_work *tw = container_of(work, struct trusty_work, work); struct trusty_state *s = tw->ts; + int old_nice = task_nice(current); + bool nice_changed = false; dequeue_nop(s, args); do { + /* + * In case use_high_wq flaged when trusty is not idle, + * change the work's prio directly. + */ + if (!WARN_ON(current->policy != SCHED_NORMAL)) { + if (use_high_wq && task_nice(current) != MIN_NICE) { + nice_changed = true; + set_user_nice(current, MIN_NICE); + } else if (!use_high_wq && + task_nice(current) == MIN_NICE) { + nice_changed = true; + set_user_nice(current, 0); + } + } + dev_dbg(s->dev, "%s: %x %x %x\n", __func__, args[0], args[1], args[2]); @@ -783,7 +800,11 @@ static void nop_work_func(struct work_struct *work) } } } while (next); - + /* + * Restore nice if even changed. + */ + if (nice_changed) + set_user_nice(current, old_nice); dev_dbg(s->dev, "%s: done\n", __func__); } @@ -880,7 +901,8 @@ 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); + 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"); |