Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: host1x: Add option to skip firewall for a job

The new UAPI will have its own firewall, and we don't want to run
the firewall in the Host1x driver for those jobs. As such, add a
parameter to host1x_job_alloc to specify if we want to skip the
firewall in the Host1x driver.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Mikko Perttunen and committed by
Thierry Reding
0fddaa85 e902585f

+19 -10
+1 -1
drivers/gpu/drm/tegra/drm.c
··· 193 193 return -EINVAL; 194 194 195 195 job = host1x_job_alloc(context->channel, args->num_cmdbufs, 196 - args->num_relocs); 196 + args->num_relocs, false); 197 197 if (!job) 198 198 return -ENOMEM; 199 199
+13 -8
drivers/gpu/host1x/job.c
··· 24 24 #define HOST1X_WAIT_SYNCPT_OFFSET 0x8 25 25 26 26 struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, 27 - u32 num_cmdbufs, u32 num_relocs) 27 + u32 num_cmdbufs, u32 num_relocs, 28 + bool skip_firewall) 28 29 { 29 30 struct host1x_job *job = NULL; 30 31 unsigned int num_unpins = num_relocs; 32 + bool enable_firewall; 31 33 u64 total; 32 34 void *mem; 33 35 34 - if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) 36 + enable_firewall = IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && !skip_firewall; 37 + 38 + if (!enable_firewall) 35 39 num_unpins += num_cmdbufs; 36 40 37 41 /* Check that we're not going to overflow */ ··· 51 47 mem = job = kzalloc(total, GFP_KERNEL); 52 48 if (!job) 53 49 return NULL; 50 + 51 + job->enable_firewall = enable_firewall; 54 52 55 53 kref_init(&job->ref); 56 54 job->channel = ch; ··· 220 214 * We will copy gathers BO content later, so there is no need to 221 215 * hold and pin them. 222 216 */ 223 - if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) 217 + if (job->enable_firewall) 224 218 return 0; 225 219 226 220 for (i = 0; i < job->num_cmds; i++) { ··· 327 321 if (cmdbuf != reloc->cmdbuf.bo) 328 322 continue; 329 323 330 - if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) { 324 + if (job->enable_firewall) { 331 325 target = (u32 *)job->gather_copy_mapped + 332 326 reloc->cmdbuf.offset / sizeof(u32) + 333 327 g->offset / sizeof(u32); ··· 640 634 if (err) 641 635 goto out; 642 636 643 - if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) { 637 + if (job->enable_firewall) { 644 638 err = copy_gathers(host->dev, job, dev); 645 639 if (err) 646 640 goto out; ··· 659 653 continue; 660 654 661 655 /* copy_gathers() sets gathers base if firewall is enabled */ 662 - if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) 656 + if (!job->enable_firewall) 663 657 g->base = job->gather_addr_phys[i]; 664 658 665 659 for (j = i + 1; j < job->num_cmds; j++) { ··· 694 688 struct device *dev = unpin->dev ?: host->dev; 695 689 struct sg_table *sgt = unpin->sgt; 696 690 697 - if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && 698 - unpin->size && host->domain) { 691 + if (!job->enable_firewall && unpin->size && host->domain) { 699 692 iommu_unmap(host->domain, job->addr_phys[i], 700 693 unpin->size); 701 694 free_iova(&host->iova,
+5 -1
include/linux/host1x.h
··· 272 272 /* Callback called when job is freed */ 273 273 void (*release)(struct host1x_job *job); 274 274 void *user_data; 275 + 276 + /* Whether host1x-side firewall should be ran for this job or not */ 277 + bool enable_firewall; 275 278 }; 276 279 277 280 struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, 278 - u32 num_cmdbufs, u32 num_relocs); 281 + u32 num_cmdbufs, u32 num_relocs, 282 + bool skip_firewall); 279 283 void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *bo, 280 284 unsigned int words, unsigned int offset); 281 285 void host1x_job_add_wait(struct host1x_job *job, u32 id, u32 thresh,