Skip to content

Commit d501b1d

Browse files
committed
drm/i915: Add GEM debugging Kconfig option
Currently there is a #define to enable extra BUG_ON for debugging requests and associated activities. I want to expand its use to cover all of GEM internals (so that we can saturate the code with asserts). We can add a Kconfig option to make it easier to enable - with the usual caveats of not enabling unless explicitly requested. Signed-off-by: Chris Wilson <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Reviewed-by: Joonas Lahtinen <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e73bdd2 commit d501b1d

File tree

4 files changed

+52
-7
lines changed

4 files changed

+52
-7
lines changed

drivers/gpu/drm/i915/Kconfig.debug

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@ config DRM_I915_DEBUG
2727

2828
If in doubt, say "N".
2929

30+
config DRM_I915_DEBUG_GEM
31+
bool "Insert extra checks into the GEM internals"
32+
default n
33+
depends on DRM_I915_WERROR
34+
help
35+
Enable extra sanity checks (including BUGs) along the GEM driver
36+
paths that may slow the system down and if hit hang the machine.
37+
38+
Recommended for driver developers only.
39+
40+
If in doubt, say "N".
41+

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "intel_lrc.h"
5858
#include "intel_ringbuffer.h"
5959

60+
#include "i915_gem.h"
6061
#include "i915_gem_gtt.h"
6162
#include "i915_gem_render_state.h"
6263

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#include <linux/pci.h>
3939
#include <linux/dma-buf.h>
4040

41-
#define RQ_BUG_ON(expr)
42-
4341
static void i915_gem_object_flush_gtt_write_domain(struct drm_i915_gem_object *obj);
4442
static void i915_gem_object_flush_cpu_write_domain(struct drm_i915_gem_object *obj);
4543
static void
@@ -1521,7 +1519,7 @@ i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj,
15211519

15221520
i915_gem_object_retire__read(obj, i);
15231521
}
1524-
RQ_BUG_ON(obj->active);
1522+
GEM_BUG_ON(obj->active);
15251523
}
15261524

15271525
return 0;
@@ -2473,8 +2471,8 @@ void i915_vma_move_to_active(struct i915_vma *vma,
24732471
static void
24742472
i915_gem_object_retire__write(struct drm_i915_gem_object *obj)
24752473
{
2476-
RQ_BUG_ON(obj->last_write_req == NULL);
2477-
RQ_BUG_ON(!(obj->active & intel_engine_flag(obj->last_write_req->engine)));
2474+
GEM_BUG_ON(obj->last_write_req == NULL);
2475+
GEM_BUG_ON(!(obj->active & intel_engine_flag(obj->last_write_req->engine)));
24782476

24792477
i915_gem_request_assign(&obj->last_write_req, NULL);
24802478
intel_fb_obj_flush(obj, true, ORIGIN_CS);
@@ -2485,8 +2483,8 @@ i915_gem_object_retire__read(struct drm_i915_gem_object *obj, int ring)
24852483
{
24862484
struct i915_vma *vma;
24872485

2488-
RQ_BUG_ON(obj->last_read_req[ring] == NULL);
2489-
RQ_BUG_ON(!(obj->active & (1 << ring)));
2486+
GEM_BUG_ON(obj->last_read_req[ring] == NULL);
2487+
GEM_BUG_ON(!(obj->active & (1 << ring)));
24902488

24912489
list_del_init(&obj->engine_list[ring]);
24922490
i915_gem_request_assign(&obj->last_read_req[ring], NULL);

drivers/gpu/drm/i915/i915_gem.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright © 2016 Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice (including the next
12+
* paragraph) shall be included in all copies or substantial portions of the
13+
* Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21+
* IN THE SOFTWARE.
22+
*
23+
*/
24+
25+
#ifndef __I915_GEM_H__
26+
#define __I915_GEM_H__
27+
28+
#ifdef CONFIG_DRM_I915_DEBUG_GEM
29+
#define GEM_BUG_ON(expr) BUG_ON(expr)
30+
#else
31+
#define GEM_BUG_ON(expr)
32+
#endif
33+
34+
#endif /* __I915_GEM_H__ */

0 commit comments

Comments
 (0)