job.c (0f563a4bf66e5182f0882efee398f7e6bc0bb1be) | job.c (a47ac10e6e628740dd122d650afd193941f4770b) |
---|---|
1/* 2 * Tegra host1x Job 3 * 4 * Copyright (c) 2010-2015, NVIDIA Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. --- 17 unchanged lines hidden (view full) --- 26#include <linux/vmalloc.h> 27#include <trace/events/host1x.h> 28 29#include "channel.h" 30#include "dev.h" 31#include "job.h" 32#include "syncpt.h" 33 | 1/* 2 * Tegra host1x Job 3 * 4 * Copyright (c) 2010-2015, NVIDIA Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. --- 17 unchanged lines hidden (view full) --- 26#include <linux/vmalloc.h> 27#include <trace/events/host1x.h> 28 29#include "channel.h" 30#include "dev.h" 31#include "job.h" 32#include "syncpt.h" 33 |
34#define HOST1X_WAIT_SYNCPT_OFFSET 0x8 35 |
|
34struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, 35 u32 num_cmdbufs, u32 num_relocs, 36 u32 num_waitchks) 37{ 38 struct host1x_job *job = NULL; 39 unsigned int num_unpins = num_cmdbufs + num_relocs; 40 u64 total; 41 void *mem; --- 290 unchanged lines hidden (view full) --- 332 333 /* relocation shift value validation isn't implemented yet */ 334 if (reloc->shift) 335 return false; 336 337 return true; 338} 339 | 36struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, 37 u32 num_cmdbufs, u32 num_relocs, 38 u32 num_waitchks) 39{ 40 struct host1x_job *job = NULL; 41 unsigned int num_unpins = num_cmdbufs + num_relocs; 42 u64 total; 43 void *mem; --- 290 unchanged lines hidden (view full) --- 334 335 /* relocation shift value validation isn't implemented yet */ 336 if (reloc->shift) 337 return false; 338 339 return true; 340} 341 |
342static bool check_wait(struct host1x_waitchk *wait, struct host1x_bo *cmdbuf, 343 unsigned int offset) 344{ 345 offset *= sizeof(u32); 346 347 if (wait->bo != cmdbuf || wait->offset != offset) 348 return false; 349 350 return true; 351} 352 |
|
340struct host1x_firewall { 341 struct host1x_job *job; 342 struct device *dev; 343 344 unsigned int num_relocs; 345 struct host1x_reloc *reloc; 346 | 353struct host1x_firewall { 354 struct host1x_job *job; 355 struct device *dev; 356 357 unsigned int num_relocs; 358 struct host1x_reloc *reloc; 359 |
360 unsigned int num_waitchks; 361 struct host1x_waitchk *waitchk; 362 |
|
347 struct host1x_bo *cmdbuf; 348 unsigned int offset; 349 350 u32 words; 351 u32 class; 352 u32 reg; 353 u32 mask; 354 u32 count; --- 10 unchanged lines hidden (view full) --- 365 366 if (!check_reloc(fw->reloc, fw->cmdbuf, fw->offset)) 367 return -EINVAL; 368 369 fw->num_relocs--; 370 fw->reloc++; 371 } 372 | 363 struct host1x_bo *cmdbuf; 364 unsigned int offset; 365 366 u32 words; 367 u32 class; 368 u32 reg; 369 u32 mask; 370 u32 count; --- 10 unchanged lines hidden (view full) --- 381 382 if (!check_reloc(fw->reloc, fw->cmdbuf, fw->offset)) 383 return -EINVAL; 384 385 fw->num_relocs--; 386 fw->reloc++; 387 } 388 |
389 if (offset == HOST1X_WAIT_SYNCPT_OFFSET) { 390 if (fw->class != HOST1X_CLASS_HOST1X) 391 return -EINVAL; 392 393 if (!fw->num_waitchks) 394 return -EINVAL; 395 396 if (!check_wait(fw->waitchk, fw->cmdbuf, fw->offset)) 397 return -EINVAL; 398 399 fw->num_waitchks--; 400 fw->waitchk++; 401 } 402 |
|
373 return 0; 374} 375 376static int check_class(struct host1x_firewall *fw, u32 class) 377{ 378 if (!fw->job->is_valid_class) { 379 if (fw->class != class) 380 return -EINVAL; --- 148 unchanged lines hidden (view full) --- 529 size_t size = 0; 530 size_t offset = 0; 531 int i; 532 533 fw.job = job; 534 fw.dev = dev; 535 fw.reloc = job->relocarray; 536 fw.num_relocs = job->num_relocs; | 403 return 0; 404} 405 406static int check_class(struct host1x_firewall *fw, u32 class) 407{ 408 if (!fw->job->is_valid_class) { 409 if (fw->class != class) 410 return -EINVAL; --- 148 unchanged lines hidden (view full) --- 559 size_t size = 0; 560 size_t offset = 0; 561 int i; 562 563 fw.job = job; 564 fw.dev = dev; 565 fw.reloc = job->relocarray; 566 fw.num_relocs = job->num_relocs; |
567 fw.waitchk = job->waitchk; 568 fw.num_waitchks = job->num_waitchk; |
|
537 fw.class = job->class; 538 539 for (i = 0; i < job->num_gathers; i++) { 540 struct host1x_job_gather *g = &job->gathers[i]; 541 542 size += g->words * sizeof(u32); 543 } 544 --- 22 unchanged lines hidden (view full) --- 567 568 /* Validate the job */ 569 if (validate(&fw, g)) 570 return -EINVAL; 571 572 offset += g->words * sizeof(u32); 573 } 574 | 569 fw.class = job->class; 570 571 for (i = 0; i < job->num_gathers; i++) { 572 struct host1x_job_gather *g = &job->gathers[i]; 573 574 size += g->words * sizeof(u32); 575 } 576 --- 22 unchanged lines hidden (view full) --- 599 600 /* Validate the job */ 601 if (validate(&fw, g)) 602 return -EINVAL; 603 604 offset += g->words * sizeof(u32); 605 } 606 |
575 /* No relocs should remain at this point */ 576 if (fw.num_relocs) | 607 /* No relocs and waitchks should remain at this point */ 608 if (fw.num_relocs || fw.num_waitchks) |
577 return -EINVAL; 578 579 return 0; 580} 581 582int host1x_job_pin(struct host1x_job *job, struct device *dev) 583{ 584 int err; --- 103 unchanged lines hidden --- | 609 return -EINVAL; 610 611 return 0; 612} 613 614int host1x_job_pin(struct host1x_job *job, struct device *dev) 615{ 616 int err; --- 103 unchanged lines hidden --- |