Skip to content

Commit b18fe4b

Browse files
committed
drm/i915: Enlarge vma->pin_count
Previously we only accommodated having a vma pinned by a small number of users, with the maximum being pinned for use by the display engine. As such, we used a small bitfield only large enough to allow the vma to be pinned twice (for back/front buffers) in each scanout plane. Keeping the maximum permissible pin_count small allows us to quickly catch a potential leak. However, as we want to split a 4096B page into 64 different cachelines and pin each cacheline for use by a different timeline, we will exceed the current maximum permissible vma->pin_count and so time has come to enlarge it. Whilst we are here, try to pull together the similar bits: Address/layout specification: - bias, mappable, zone_4g: address limit specifiers - fixed: address override, limits still apply though - high: not strictly an address limit, but an address direction to search Search controls: - nonblock, nonfault, noevict v2: Rewrite the guideline comment on bit consumption. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: John Harrison <john.C.Harrison@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190128181812.22804-2-chris@chris-wilson.co.uk
1 parent 3adac46 commit b18fe4b

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

drivers/gpu/drm/i915/i915_gem_gtt.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -642,19 +642,19 @@ int i915_gem_gtt_insert(struct i915_address_space *vm,
642642

643643
/* Flags used by pin/bind&friends. */
644644
#define PIN_NONBLOCK BIT_ULL(0)
645-
#define PIN_MAPPABLE BIT_ULL(1)
646-
#define PIN_ZONE_4G BIT_ULL(2)
647-
#define PIN_NONFAULT BIT_ULL(3)
648-
#define PIN_NOEVICT BIT_ULL(4)
649-
650-
#define PIN_MBZ BIT_ULL(5) /* I915_VMA_PIN_OVERFLOW */
651-
#define PIN_GLOBAL BIT_ULL(6) /* I915_VMA_GLOBAL_BIND */
652-
#define PIN_USER BIT_ULL(7) /* I915_VMA_LOCAL_BIND */
653-
#define PIN_UPDATE BIT_ULL(8)
654-
655-
#define PIN_HIGH BIT_ULL(9)
656-
#define PIN_OFFSET_BIAS BIT_ULL(10)
657-
#define PIN_OFFSET_FIXED BIT_ULL(11)
645+
#define PIN_NONFAULT BIT_ULL(1)
646+
#define PIN_NOEVICT BIT_ULL(2)
647+
#define PIN_MAPPABLE BIT_ULL(3)
648+
#define PIN_ZONE_4G BIT_ULL(4)
649+
#define PIN_HIGH BIT_ULL(5)
650+
#define PIN_OFFSET_BIAS BIT_ULL(6)
651+
#define PIN_OFFSET_FIXED BIT_ULL(7)
652+
653+
#define PIN_MBZ BIT_ULL(8) /* I915_VMA_PIN_OVERFLOW */
654+
#define PIN_GLOBAL BIT_ULL(9) /* I915_VMA_GLOBAL_BIND */
655+
#define PIN_USER BIT_ULL(10) /* I915_VMA_LOCAL_BIND */
656+
#define PIN_UPDATE BIT_ULL(11)
657+
658658
#define PIN_OFFSET_MASK (-I915_GTT_PAGE_SIZE)
659659

660660
#endif

drivers/gpu/drm/i915/i915_vma.h

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,42 @@ struct i915_vma {
7171
unsigned int open_count;
7272
unsigned long flags;
7373
/**
74-
* How many users have pinned this object in GTT space. The following
75-
* users can each hold at most one reference: pwrite/pread, execbuffer
76-
* (objects are not allowed multiple times for the same batchbuffer),
77-
* and the framebuffer code. When switching/pageflipping, the
78-
* framebuffer code has at most two buffers pinned per crtc.
74+
* How many users have pinned this object in GTT space.
7975
*
80-
* In the worst case this is 1 + 1 + 1 + 2*2 = 7. That would fit into 3
81-
* bits with absolutely no headroom. So use 4 bits.
76+
* This is a tightly bound, fairly small number of users, so we
77+
* stuff inside the flags field so that we can both check for overflow
78+
* and detect a no-op i915_vma_pin() in a single check, while also
79+
* pinning the vma.
80+
*
81+
* The worst case display setup would have the same vma pinned for
82+
* use on each plane on each crtc, while also building the next atomic
83+
* state and holding a pin for the length of the cleanup queue. In the
84+
* future, the flip queue may be increased from 1.
85+
* Estimated worst case: 3 [qlen] * 4 [max crtcs] * 7 [max planes] = 84
86+
*
87+
* For GEM, the number of concurrent users for pwrite/pread is
88+
* unbounded. For execbuffer, it is currently one but will in future
89+
* be extended to allow multiple clients to pin vma concurrently.
90+
*
91+
* We also use suballocated pages, with each suballocation claiming
92+
* its own pin on the shared vma. At present, this is limited to
93+
* exclusive cachelines of a single page, so a maximum of 64 possible
94+
* users.
8295
*/
83-
#define I915_VMA_PIN_MASK 0xf
84-
#define I915_VMA_PIN_OVERFLOW BIT(5)
96+
#define I915_VMA_PIN_MASK 0xff
97+
#define I915_VMA_PIN_OVERFLOW BIT(8)
8598

8699
/** Flags and address space this VMA is bound to */
87-
#define I915_VMA_GLOBAL_BIND BIT(6)
88-
#define I915_VMA_LOCAL_BIND BIT(7)
100+
#define I915_VMA_GLOBAL_BIND BIT(9)
101+
#define I915_VMA_LOCAL_BIND BIT(10)
89102
#define I915_VMA_BIND_MASK (I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND | I915_VMA_PIN_OVERFLOW)
90103

91-
#define I915_VMA_GGTT BIT(8)
92-
#define I915_VMA_CAN_FENCE BIT(9)
93-
#define I915_VMA_CLOSED BIT(10)
94-
#define I915_VMA_USERFAULT_BIT 11
104+
#define I915_VMA_GGTT BIT(11)
105+
#define I915_VMA_CAN_FENCE BIT(12)
106+
#define I915_VMA_CLOSED BIT(13)
107+
#define I915_VMA_USERFAULT_BIT 14
95108
#define I915_VMA_USERFAULT BIT(I915_VMA_USERFAULT_BIT)
96-
#define I915_VMA_GGTT_WRITE BIT(12)
109+
#define I915_VMA_GGTT_WRITE BIT(15)
97110

98111
unsigned int active_count;
99112
struct rb_root active;

0 commit comments

Comments
 (0)