i915_scheduler.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * SPDX-License-Identifier: MIT
  3. *
  4. * Copyright © 2018 Intel Corporation
  5. */
  6. #ifndef _I915_SCHEDULER_H_
  7. #define _I915_SCHEDULER_H_
  8. #include <linux/bitops.h>
  9. #include <uapi/drm/i915_drm.h>
  10. enum {
  11. I915_PRIORITY_MIN = I915_CONTEXT_MIN_USER_PRIORITY - 1,
  12. I915_PRIORITY_NORMAL = I915_CONTEXT_DEFAULT_PRIORITY,
  13. I915_PRIORITY_MAX = I915_CONTEXT_MAX_USER_PRIORITY + 1,
  14. I915_PRIORITY_INVALID = INT_MIN
  15. };
  16. struct i915_sched_attr {
  17. /**
  18. * @priority: execution and service priority
  19. *
  20. * All clients are equal, but some are more equal than others!
  21. *
  22. * Requests from a context with a greater (more positive) value of
  23. * @priority will be executed before those with a lower @priority
  24. * value, forming a simple QoS.
  25. *
  26. * The &drm_i915_private.kernel_context is assigned the lowest priority.
  27. */
  28. int priority;
  29. };
  30. /*
  31. * "People assume that time is a strict progression of cause to effect, but
  32. * actually, from a nonlinear, non-subjective viewpoint, it's more like a big
  33. * ball of wibbly-wobbly, timey-wimey ... stuff." -The Doctor, 2015
  34. *
  35. * Requests exist in a complex web of interdependencies. Each request
  36. * has to wait for some other request to complete before it is ready to be run
  37. * (e.g. we have to wait until the pixels have been rendering into a texture
  38. * before we can copy from it). We track the readiness of a request in terms
  39. * of fences, but we also need to keep the dependency tree for the lifetime
  40. * of the request (beyond the life of an individual fence). We use the tree
  41. * at various points to reorder the requests whilst keeping the requests
  42. * in order with respect to their various dependencies.
  43. *
  44. * There is no active component to the "scheduler". As we know the dependency
  45. * DAG of each request, we are able to insert it into a sorted queue when it
  46. * is ready, and are able to reorder its portion of the graph to accommodate
  47. * dynamic priority changes.
  48. */
  49. struct i915_sched_node {
  50. struct list_head signalers_list; /* those before us, we depend upon */
  51. struct list_head waiters_list; /* those after us, they depend upon us */
  52. struct list_head link;
  53. struct i915_sched_attr attr;
  54. };
  55. struct i915_dependency {
  56. struct i915_sched_node *signaler;
  57. struct list_head signal_link;
  58. struct list_head wait_link;
  59. struct list_head dfs_link;
  60. unsigned long flags;
  61. #define I915_DEPENDENCY_ALLOC BIT(0)
  62. };
  63. #endif /* _I915_SCHEDULER_H_ */