drm/tegra: Update to UAPI v5

Update the tegra-drm driver to the 'Host1x/Tegra UAPI v5' series [0].
This fixes a few minor bugs found in the previous series.

[0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=223684

Bug 200687525

Change-Id: I270016756b6b689c1fada208896cee81223e7042
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2469984
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Jon Hunter
2021-01-12 10:49:02 +00:00
committed by Laxman Dewangan
parent d088bfa37d
commit d3ea27d381
5 changed files with 48 additions and 16 deletions

View File

@@ -44,6 +44,9 @@ static void *alloc_copy_user_array(void __user *from, size_t count, size_t size)
if (check_mul_overflow(count, size, &copy_len))
return ERR_PTR(-EINVAL);
if (copy_len > 0x4000)
return ERR_PTR(-E2BIG);
data = kvmalloc(copy_len, GFP_KERNEL);
if (!data)
return ERR_PTR(-ENOMEM);
@@ -110,8 +113,10 @@ static int submit_write_reloc(struct gather_bo *bo,
dma_addr_t iova = mapping->iova + buf->reloc.target_offset;
u32 written_ptr = (u32)(iova >> buf->reloc.shift);
#ifdef CONFIG_ARM64
if (buf->flags & DRM_TEGRA_SUBMIT_BUF_RELOC_BLOCKLINEAR)
written_ptr |= BIT(39);
#endif
if (buf->reloc.gather_offset_words >= bo->gather_data_words)
return -EINVAL;
@@ -219,7 +224,8 @@ static int submit_job_add_gather(struct host1x_job *job,
struct tegra_drm_channel_ctx *ctx,
struct drm_tegra_submit_cmd_gather_uptr *cmd,
struct gather_bo *bo, u32 *offset,
struct tegra_drm_submit_data *job_data)
struct tegra_drm_submit_data *job_data,
u32 *class)
{
u32 next_offset;
@@ -237,7 +243,7 @@ static int submit_job_add_gather(struct host1x_job *job,
return -EINVAL;
if (tegra_drm_fw_validate(ctx->client, bo->gather_data, *offset,
cmd->words, job_data))
cmd->words, job_data, class))
return -EINVAL;
host1x_job_add_gather(job, &bo->base, cmd->words, *offset * 4);
@@ -254,10 +260,13 @@ static int submit_create_job(struct drm_device *drm, struct host1x_job **pjob,
struct tegra_drm_submit_data *job_data)
{
struct drm_tegra_submit_cmd *cmds;
u32 i, gather_offset = 0;
u32 i, gather_offset = 0, class;
struct host1x_job *job;
int err;
/* Set initial class for firewall. */
class = ctx->client->base.class;
cmds = alloc_copy_user_array(u64_to_user_ptr(args->cmds_ptr),
args->num_cmds, sizeof(*cmds));
if (IS_ERR(cmds))
@@ -283,7 +292,7 @@ static int submit_create_job(struct drm_device *drm, struct host1x_job **pjob,
if (cmd->type == DRM_TEGRA_SUBMIT_CMD_GATHER_UPTR) {
err = submit_job_add_gather(job, ctx, &cmd->gather_uptr,
bo, &gather_offset,
job_data);
job_data, &class);
if (err)
goto free_job;
} else if (cmd->type == DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT) {