diff options
author | Brad Volkin <bradley.d.volkin@intel.com> | 2014-03-27 14:43:38 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-04-02 05:33:51 -0400 |
commit | 300233ee23d6ab8f05f0b673a278c66e6b19f079 (patch) | |
tree | 8ce17f5c8c4a72dea61cbb5205d6b48a4d52c097 /drivers/gpu/drm/i915 | |
parent | 85b8d5c21564e0388d4ab68adadbfe0cdb8ec728 (diff) |
drm/i915: BUG_ON() when cmd/reg tables are not sorted
As suggested during review, this makes it much more obvious
when the tables are not sorted.
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Brad Volkin <bradley.d.volkin@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r-- | drivers/gpu/drm/i915/i915_cmd_parser.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c index d8e5034bdb1d..d25143424576 100644 --- a/drivers/gpu/drm/i915/i915_cmd_parser.c +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c | |||
@@ -493,12 +493,13 @@ static u32 gen7_blt_get_cmd_length_mask(u32 cmd_header) | |||
493 | return 0; | 493 | return 0; |
494 | } | 494 | } |
495 | 495 | ||
496 | static void validate_cmds_sorted(struct intel_ring_buffer *ring) | 496 | static bool validate_cmds_sorted(struct intel_ring_buffer *ring) |
497 | { | 497 | { |
498 | int i; | 498 | int i; |
499 | bool ret = true; | ||
499 | 500 | ||
500 | if (!ring->cmd_tables || ring->cmd_table_count == 0) | 501 | if (!ring->cmd_tables || ring->cmd_table_count == 0) |
501 | return; | 502 | return true; |
502 | 503 | ||
503 | for (i = 0; i < ring->cmd_table_count; i++) { | 504 | for (i = 0; i < ring->cmd_table_count; i++) { |
504 | const struct drm_i915_cmd_table *table = &ring->cmd_tables[i]; | 505 | const struct drm_i915_cmd_table *table = &ring->cmd_tables[i]; |
@@ -510,35 +511,45 @@ static void validate_cmds_sorted(struct intel_ring_buffer *ring) | |||
510 | &table->table[i]; | 511 | &table->table[i]; |
511 | u32 curr = desc->cmd.value & desc->cmd.mask; | 512 | u32 curr = desc->cmd.value & desc->cmd.mask; |
512 | 513 | ||
513 | if (curr < previous) | 514 | if (curr < previous) { |
514 | DRM_ERROR("CMD: table not sorted ring=%d table=%d entry=%d cmd=0x%08X prev=0x%08X\n", | 515 | DRM_ERROR("CMD: table not sorted ring=%d table=%d entry=%d cmd=0x%08X prev=0x%08X\n", |
515 | ring->id, i, j, curr, previous); | 516 | ring->id, i, j, curr, previous); |
517 | ret = false; | ||
518 | } | ||
516 | 519 | ||
517 | previous = curr; | 520 | previous = curr; |
518 | } | 521 | } |
519 | } | 522 | } |
523 | |||
524 | return ret; | ||
520 | } | 525 | } |
521 | 526 | ||
522 | static void check_sorted(int ring_id, const u32 *reg_table, int reg_count) | 527 | static bool check_sorted(int ring_id, const u32 *reg_table, int reg_count) |
523 | { | 528 | { |
524 | int i; | 529 | int i; |
525 | u32 previous = 0; | 530 | u32 previous = 0; |
531 | bool ret = true; | ||
526 | 532 | ||
527 | for (i = 0; i < reg_count; i++) { | 533 | for (i = 0; i < reg_count; i++) { |
528 | u32 curr = reg_table[i]; | 534 | u32 curr = reg_table[i]; |
529 | 535 | ||
530 | if (curr < previous) | 536 | if (curr < previous) { |
531 | DRM_ERROR("CMD: table not sorted ring=%d entry=%d reg=0x%08X prev=0x%08X\n", | 537 | DRM_ERROR("CMD: table not sorted ring=%d entry=%d reg=0x%08X prev=0x%08X\n", |
532 | ring_id, i, curr, previous); | 538 | ring_id, i, curr, previous); |
539 | ret = false; | ||
540 | } | ||
533 | 541 | ||
534 | previous = curr; | 542 | previous = curr; |
535 | } | 543 | } |
544 | |||
545 | return ret; | ||
536 | } | 546 | } |
537 | 547 | ||
538 | static void validate_regs_sorted(struct intel_ring_buffer *ring) | 548 | static bool validate_regs_sorted(struct intel_ring_buffer *ring) |
539 | { | 549 | { |
540 | check_sorted(ring->id, ring->reg_table, ring->reg_count); | 550 | return check_sorted(ring->id, ring->reg_table, ring->reg_count) && |
541 | check_sorted(ring->id, ring->master_reg_table, ring->master_reg_count); | 551 | check_sorted(ring->id, ring->master_reg_table, |
552 | ring->master_reg_count); | ||
542 | } | 553 | } |
543 | 554 | ||
544 | /** | 555 | /** |
@@ -617,8 +628,8 @@ void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring) | |||
617 | BUG(); | 628 | BUG(); |
618 | } | 629 | } |
619 | 630 | ||
620 | validate_cmds_sorted(ring); | 631 | BUG_ON(!validate_cmds_sorted(ring)); |
621 | validate_regs_sorted(ring); | 632 | BUG_ON(!validate_regs_sorted(ring)); |
622 | } | 633 | } |
623 | 634 | ||
624 | static const struct drm_i915_cmd_descriptor* | 635 | static const struct drm_i915_cmd_descriptor* |