From ecdf991f7d049d0dbebb12e7cb4f00f49fb5ebf0 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 17 Dec 2021 12:19:05 +0000 Subject: [PATCH] nvdla: Use upstream speculation barrier The Linux v5.10 kernel defines a 'spec_bar()' macro to inhibit speculation for ARM64 and so if we use this macro, then we can remove the downstream speculation_barrier(). Please note that it is important to remove such downstream macros because these prevent us getting the various NVIDIA kernel drivers from working with upstream Linux kernels. Bug 3409896 Bug 3477445 Change-Id: Ie8d44f219d2dded2fc7bd36f24980b91c92395d9 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2643778 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/video/tegra/host/nvdla/dla_queue.c | 6 +++--- drivers/video/tegra/host/nvdla/nvdla_buffer.c | 6 +++--- drivers/video/tegra/host/nvdla/nvdla_ioctl.c | 18 ++++++++---------- drivers/video/tegra/host/nvdla/nvdla_queue.c | 16 ++++++++-------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/drivers/video/tegra/host/nvdla/dla_queue.c b/drivers/video/tegra/host/nvdla/dla_queue.c index b34bb120..6cd656ad 100644 --- a/drivers/video/tegra/host/nvdla/dla_queue.c +++ b/drivers/video/tegra/host/nvdla/dla_queue.c @@ -219,7 +219,7 @@ struct nvdla_queue_pool *nvdla_queue_init(struct platform_device *pdev, queue->task_pool = (void *)&task_pool[i]; nvdla_queue_get_task_size(queue); } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ return pool; @@ -340,7 +340,7 @@ struct nvdla_queue *nvdla_queue_alloc(struct nvdla_queue_pool *pool, err = -ENOMEM; goto err_alloc_queue; } - speculation_barrier(); /* break_spec_p#1 */ + spec_bar(); /* break_spec_p#1 */ /* reserve the queue */ queue = &queues[index]; @@ -516,7 +516,7 @@ int nvdla_queue_submit_to_host1x(struct nvdla_queue *queue, job->waitchk[i].thresh = wait_syncpt_thresholds[i]; job->waitchk[i].mem = 0; } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ /* Initialize syncpoint increments */ job->sp->id = queue->syncpt_id; diff --git a/drivers/video/tegra/host/nvdla/nvdla_buffer.c b/drivers/video/tegra/host/nvdla/nvdla_buffer.c index 454032c1..d4777a8e 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_buffer.c +++ b/drivers/video/tegra/host/nvdla/nvdla_buffer.c @@ -269,7 +269,7 @@ int nvdla_buffer_submit_pin(struct nvdla_buffers *nvdla_buffers, if (heap != NULL) heap[i] = vm->heap; } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ mutex_unlock(&nvdla_buffers->mutex); return 0; @@ -313,7 +313,7 @@ int nvdla_buffer_pin(struct nvdla_buffers *nvdla_buffers, nvdla_buffer_insert_map_buffer(nvdla_buffers, vm); } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ mutex_unlock(&nvdla_buffers->mutex); return err; @@ -372,7 +372,7 @@ void nvdla_buffer_unpin(struct nvdla_buffers *nvdla_buffers, vm->user_map_count = 0; nvdla_buffer_unmap(nvdla_buffers, vm); } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ mutex_unlock(&nvdla_buffers->mutex); } diff --git a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c index 4e0869b4..3a14c96f 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_ioctl.c +++ b/drivers/video/tegra/host/nvdla/nvdla_ioctl.c @@ -23,8 +23,6 @@ #include #include -#include "host1x/host1x.h" - #include "nvdla/nvdla.h" #include "nvdla/dla_queue.h" #include "nvdla/nvdla_buffer.h" @@ -197,7 +195,7 @@ static int nvdla_pin(struct nvdla_private *priv, void *arg) goto nvdla_buffer_cpy_err; } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ err = nvdla_buffer_pin(priv->buffers, handles, count); @@ -245,7 +243,7 @@ static int nvdla_unpin(struct nvdla_private *priv, void *arg) goto nvdla_buffer_cpy_err; } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ nvdla_buffer_unpin(priv->buffers, handles, count); @@ -447,7 +445,7 @@ static int nvdla_send_emu_signal_fences(struct nvdla_emu_task *task, } } } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ nvdla_dbg_fn(dla_pdev, "copy prefences to user"); /* send pre fences */ @@ -489,7 +487,7 @@ static int nvdla_send_emu_signal_fences(struct nvdla_emu_task *task, } } } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ nvdla_dbg_fn(dla_pdev, "copy postfences to user"); /* send post fences */ @@ -551,7 +549,7 @@ static int nvdla_update_signal_fences(struct nvdla_task *task, } } } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ nvdla_dbg_fn(dla_pdev, "copy prefences to user"); /* copy pre fences */ @@ -593,7 +591,7 @@ static int nvdla_update_signal_fences(struct nvdla_task *task, } } } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ nvdla_dbg_fn(dla_pdev, "copy postfences to user"); /* copy post fences */ @@ -826,7 +824,7 @@ static void nvdla_dump_task(struct nvdla_task *task) i, task->memory_handles[i].handle, task->memory_handles[i].offset); } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ } static int nvdla_emu_task_submit(struct nvdla_private *priv, void *arg) @@ -912,7 +910,7 @@ static int nvdla_emu_task_submit(struct nvdla_private *priv, void *arg) } nvdla_dbg_info(pdev, "signal fences of task[%d] sent", i + 1); } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ nvdla_dbg_fn(pdev, "Emulator task submitted, done!"); exit: diff --git a/drivers/video/tegra/host/nvdla/nvdla_queue.c b/drivers/video/tegra/host/nvdla/nvdla_queue.c index eb9e467f..d19bc0e9 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_queue.c +++ b/drivers/video/tegra/host/nvdla/nvdla_queue.c @@ -80,7 +80,7 @@ static void nvdla_queue_dump_op(struct nvdla_queue *queue, struct seq_file *s) } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ mutex_unlock(&queue->list_lock); } @@ -252,7 +252,7 @@ static int nvdla_unmap_task_memory(struct nvdla_task *task) } nvdla_dbg_fn(pdev, "all out timestamps unmaped"); - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ return 0; } @@ -559,7 +559,7 @@ static int nvdla_map_task_memory(struct nvdla_task *task) next = add_address(next, dma_addr + task->memory_handles[jj].offset); } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ fail_to_pin_mem: return err; @@ -919,7 +919,7 @@ static int nvdla_fill_postactions(struct nvdla_task *task) postactionl->offset = postactionlist_of; postactionl->size = next - start; - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ fail: return err; } @@ -1029,7 +1029,7 @@ static int nvdla_fill_preactions(struct nvdla_task *task) preactionl->offset = preactionlist_of; preactionl->size = next - start; - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ fail: return err; } @@ -1164,7 +1164,7 @@ static int nvdla_send_cmd_channel(struct platform_device *pdev, syncpt_wait_thresh[i] = task->prefences[i].syncpoint_value; } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ cmdbuf[0] = nvhost_opcode_incr(NV_DLA_THI_METHOD_ID >> 2, 2); cmdbuf[1] = method_id; @@ -1296,7 +1296,7 @@ int nvdla_emulator_submit(struct nvdla_queue *queue, struct nvdla_emu_task *task } } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ return 0; } @@ -1354,7 +1354,7 @@ int nvdla_get_signal_fences(struct nvdla_queue *queue, void *in_task) counter = counter - 1; } } - speculation_barrier(); /* break_spec_p#5_1 */ + spec_bar(); /* break_spec_p#5_1 */ return 0; }