diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-07-24 11:40:12 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-07-27 04:25:06 -0400 |
commit | a794f62a300194dbc53165f10cc5ad236a6a43c2 (patch) | |
tree | 10e674ad8efdc899334bf5643cf5a460aa3c3437 /drivers/gpu/drm/i915/i915_gem_fence.c | |
parent | 41a36b739ae378043ecc3984bec3dba00353fa34 (diff) |
drm/i915: kerneldoc for fences
v2: Clarify that this is about fence _registers_. Also clarify that
the fence code revokes cpu ptes and not gtt ptes. Both suggested by
Chris.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_fence.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_fence.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_fence.c b/drivers/gpu/drm/i915/i915_gem_fence.c index d3284ee04794..0434c42d8c11 100644 --- a/drivers/gpu/drm/i915/i915_gem_fence.c +++ b/drivers/gpu/drm/i915/i915_gem_fence.c | |||
@@ -25,6 +25,36 @@ | |||
25 | #include <drm/i915_drm.h> | 25 | #include <drm/i915_drm.h> |
26 | #include "i915_drv.h" | 26 | #include "i915_drv.h" |
27 | 27 | ||
28 | /** | ||
29 | * DOC: fence register handling | ||
30 | * | ||
31 | * Important to avoid confusions: "fences" in the i915 driver are not execution | ||
32 | * fences used to track command completion but hardware detiler objects which | ||
33 | * wrap a given range of the global GTT. Each platform has only a fairly limited | ||
34 | * set of these objects. | ||
35 | * | ||
36 | * Fences are used to detile GTT memory mappings. They're also connected to the | ||
37 | * hardware frontbuffer render tracking and hence interract with frontbuffer | ||
38 | * conmpression. Furthermore on older platforms fences are required for tiled | ||
39 | * objects used by the display engine. They can also be used by the render | ||
40 | * engine - they're required for blitter commands and are optional for render | ||
41 | * commands. But on gen4+ both display (with the exception of fbc) and rendering | ||
42 | * have their own tiling state bits and don't need fences. | ||
43 | * | ||
44 | * Also note that fences only support X and Y tiling and hence can't be used for | ||
45 | * the fancier new tiling formats like W, Ys and Yf. | ||
46 | * | ||
47 | * Finally note that because fences are such a restricted resource they're | ||
48 | * dynamically associated with objects. Furthermore fence state is committed to | ||
49 | * the hardware lazily to avoid unecessary stalls on gen2/3. Therefore code must | ||
50 | * explictly call i915_gem_object_get_fence() to synchronize fencing status | ||
51 | * for cpu access. Also note that some code wants an unfenced view, for those | ||
52 | * cases the fence can be removed forcefully with i915_gem_object_put_fence(). | ||
53 | * | ||
54 | * Internally these functions will synchronize with userspace access by removing | ||
55 | * CPU ptes into GTT mmaps (not the GTT ptes themselves) as needed. | ||
56 | */ | ||
57 | |||
28 | static void i965_write_fence_reg(struct drm_device *dev, int reg, | 58 | static void i965_write_fence_reg(struct drm_device *dev, int reg, |
29 | struct drm_i915_gem_object *obj) | 59 | struct drm_i915_gem_object *obj) |
30 | { | 60 | { |
@@ -247,6 +277,17 @@ i915_gem_object_wait_fence(struct drm_i915_gem_object *obj) | |||
247 | return 0; | 277 | return 0; |
248 | } | 278 | } |
249 | 279 | ||
280 | /** | ||
281 | * i915_gem_object_put_fence - force-remove fence for an object | ||
282 | * @obj: object to map through a fence reg | ||
283 | * | ||
284 | * This function force-removes any fence from the given object, which is useful | ||
285 | * if the kernel wants to do untiled GTT access. | ||
286 | * | ||
287 | * Returns: | ||
288 | * | ||
289 | * 0 on success, negative error code on failure. | ||
290 | */ | ||
250 | int | 291 | int |
251 | i915_gem_object_put_fence(struct drm_i915_gem_object *obj) | 292 | i915_gem_object_put_fence(struct drm_i915_gem_object *obj) |
252 | { | 293 | { |
@@ -322,6 +363,10 @@ deadlock: | |||
322 | * and tiling format. | 363 | * and tiling format. |
323 | * | 364 | * |
324 | * For an untiled surface, this removes any existing fence. | 365 | * For an untiled surface, this removes any existing fence. |
366 | * | ||
367 | * Returns: | ||
368 | * | ||
369 | * 0 on success, negative error code on failure. | ||
325 | */ | 370 | */ |
326 | int | 371 | int |
327 | i915_gem_object_get_fence(struct drm_i915_gem_object *obj) | 372 | i915_gem_object_get_fence(struct drm_i915_gem_object *obj) |
@@ -374,6 +419,21 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj) | |||
374 | return 0; | 419 | return 0; |
375 | } | 420 | } |
376 | 421 | ||
422 | /** | ||
423 | * i915_gem_object_pin_fence - pin fencing state | ||
424 | * @obj: object to pin fencing for | ||
425 | * | ||
426 | * This pins the fencing state (whether tiled or untiled) to make sure the | ||
427 | * object is ready to be used as a scanout target. Fencing status must be | ||
428 | * synchronize first by calling i915_gem_object_get_fence(): | ||
429 | * | ||
430 | * The resulting fence pin reference must be released again with | ||
431 | * i915_gem_object_unpin_fence(). | ||
432 | * | ||
433 | * Returns: | ||
434 | * | ||
435 | * True if the object has a fence, false otherwise. | ||
436 | */ | ||
377 | bool | 437 | bool |
378 | i915_gem_object_pin_fence(struct drm_i915_gem_object *obj) | 438 | i915_gem_object_pin_fence(struct drm_i915_gem_object *obj) |
379 | { | 439 | { |
@@ -390,6 +450,14 @@ i915_gem_object_pin_fence(struct drm_i915_gem_object *obj) | |||
390 | return false; | 450 | return false; |
391 | } | 451 | } |
392 | 452 | ||
453 | /** | ||
454 | * i915_gem_object_unpin_fence - unpin fencing state | ||
455 | * @obj: object to unpin fencing for | ||
456 | * | ||
457 | * This releases the fence pin reference acquired through | ||
458 | * i915_gem_object_pin_fence. It will handle both objects with and without an | ||
459 | * attached fence correctly, callers do not need to distinguish this. | ||
460 | */ | ||
393 | void | 461 | void |
394 | i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj) | 462 | i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj) |
395 | { | 463 | { |
@@ -400,6 +468,13 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj) | |||
400 | } | 468 | } |
401 | } | 469 | } |
402 | 470 | ||
471 | /** | ||
472 | * i915_gem_restore_fences - restore fence state | ||
473 | * @dev: DRM device | ||
474 | * | ||
475 | * Restore the hw fence state to match the software tracking again, to be called | ||
476 | * after a gpu reset and on resume. | ||
477 | */ | ||
403 | void i915_gem_restore_fences(struct drm_device *dev) | 478 | void i915_gem_restore_fences(struct drm_device *dev) |
404 | { | 479 | { |
405 | struct drm_i915_private *dev_priv = dev->dev_private; | 480 | struct drm_i915_private *dev_priv = dev->dev_private; |