Skip to content

Commit 8d286e2

Browse files
committed
Merge tag 'drm-intel-next-fixes-2020-06-04' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
- Includes gvt-next-fixes-2020-05-28 - Use after free fix for display global state. - Whitelisting context-local timestamp on Gen9 and two scheduler fixes with deps (Cc: stable) - Removal of write flag from sysfs files where ineffective Signed-off-by: Dave Airlie <[email protected]> From: Joonas Lahtinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents fa3fa22 + f8665d7 commit 8d286e2

File tree

11 files changed

+295
-159
lines changed

11 files changed

+295
-159
lines changed

drivers/gpu/drm/i915/display/intel_global_state.c

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,39 @@
1010
#include "intel_display_types.h"
1111
#include "intel_global_state.h"
1212

13+
static void __intel_atomic_global_state_free(struct kref *kref)
14+
{
15+
struct intel_global_state *obj_state =
16+
container_of(kref, struct intel_global_state, ref);
17+
struct intel_global_obj *obj = obj_state->obj;
18+
19+
obj->funcs->atomic_destroy_state(obj, obj_state);
20+
}
21+
22+
static void intel_atomic_global_state_put(struct intel_global_state *obj_state)
23+
{
24+
kref_put(&obj_state->ref, __intel_atomic_global_state_free);
25+
}
26+
27+
static struct intel_global_state *
28+
intel_atomic_global_state_get(struct intel_global_state *obj_state)
29+
{
30+
kref_get(&obj_state->ref);
31+
32+
return obj_state;
33+
}
34+
1335
void intel_atomic_global_obj_init(struct drm_i915_private *dev_priv,
1436
struct intel_global_obj *obj,
1537
struct intel_global_state *state,
1638
const struct intel_global_state_funcs *funcs)
1739
{
1840
memset(obj, 0, sizeof(*obj));
1941

42+
state->obj = obj;
43+
44+
kref_init(&state->ref);
45+
2046
obj->state = state;
2147
obj->funcs = funcs;
2248
list_add_tail(&obj->head, &dev_priv->global_obj_list);
@@ -28,7 +54,9 @@ void intel_atomic_global_obj_cleanup(struct drm_i915_private *dev_priv)
2854

2955
list_for_each_entry_safe(obj, next, &dev_priv->global_obj_list, head) {
3056
list_del(&obj->head);
31-
obj->funcs->atomic_destroy_state(obj, obj->state);
57+
58+
drm_WARN_ON(&dev_priv->drm, kref_read(&obj->state->ref) != 1);
59+
intel_atomic_global_state_put(obj->state);
3260
}
3361
}
3462

@@ -97,10 +125,14 @@ intel_atomic_get_global_obj_state(struct intel_atomic_state *state,
97125
if (!obj_state)
98126
return ERR_PTR(-ENOMEM);
99127

128+
obj_state->obj = obj;
100129
obj_state->changed = false;
101130

131+
kref_init(&obj_state->ref);
132+
102133
state->global_objs[index].state = obj_state;
103-
state->global_objs[index].old_state = obj->state;
134+
state->global_objs[index].old_state =
135+
intel_atomic_global_state_get(obj->state);
104136
state->global_objs[index].new_state = obj_state;
105137
state->global_objs[index].ptr = obj;
106138
obj_state->state = state;
@@ -163,7 +195,9 @@ void intel_atomic_swap_global_state(struct intel_atomic_state *state)
163195
new_obj_state->state = NULL;
164196

165197
state->global_objs[i].state = old_obj_state;
166-
obj->state = new_obj_state;
198+
199+
intel_atomic_global_state_put(obj->state);
200+
obj->state = intel_atomic_global_state_get(new_obj_state);
167201
}
168202
}
169203

@@ -172,10 +206,9 @@ void intel_atomic_clear_global_state(struct intel_atomic_state *state)
172206
int i;
173207

174208
for (i = 0; i < state->num_global_objs; i++) {
175-
struct intel_global_obj *obj = state->global_objs[i].ptr;
209+
intel_atomic_global_state_put(state->global_objs[i].old_state);
210+
intel_atomic_global_state_put(state->global_objs[i].new_state);
176211

177-
obj->funcs->atomic_destroy_state(obj,
178-
state->global_objs[i].state);
179212
state->global_objs[i].ptr = NULL;
180213
state->global_objs[i].state = NULL;
181214
state->global_objs[i].old_state = NULL;

drivers/gpu/drm/i915/display/intel_global_state.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef __INTEL_GLOBAL_STATE_H__
77
#define __INTEL_GLOBAL_STATE_H__
88

9+
#include <linux/kref.h>
910
#include <linux/list.h>
1011

1112
struct drm_i915_private;
@@ -54,7 +55,9 @@ struct intel_global_obj {
5455
for_each_if(obj)
5556

5657
struct intel_global_state {
58+
struct intel_global_obj *obj;
5759
struct intel_atomic_state *state;
60+
struct kref ref;
5861
bool changed;
5962
};
6063

drivers/gpu/drm/i915/gem/i915_gem_context.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static void intel_context_set_gem(struct intel_context *ce,
230230
ce->timeline = intel_timeline_get(ctx->timeline);
231231

232232
if (ctx->sched.priority >= I915_PRIORITY_NORMAL &&
233-
intel_engine_has_semaphores(ce->engine))
233+
intel_engine_has_timeslices(ce->engine))
234234
__set_bit(CONTEXT_USE_SEMAPHORES, &ce->flags);
235235
}
236236

@@ -1969,7 +1969,7 @@ static int __apply_priority(struct intel_context *ce, void *arg)
19691969
{
19701970
struct i915_gem_context *ctx = arg;
19711971

1972-
if (!intel_engine_has_semaphores(ce->engine))
1972+
if (!intel_engine_has_timeslices(ce->engine))
19731973
return 0;
19741974

19751975
if (ctx->sched.priority >= I915_PRIORITY_NORMAL)

drivers/gpu/drm/i915/gem/i915_gem_shmem.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
3939
unsigned long last_pfn = 0; /* suppress gcc warning */
4040
unsigned int max_segment = i915_sg_segment_size();
4141
unsigned int sg_page_sizes;
42-
struct pagevec pvec;
4342
gfp_t noreclaim;
4443
int ret;
4544

@@ -192,13 +191,17 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
192191
sg_mark_end(sg);
193192
err_pages:
194193
mapping_clear_unevictable(mapping);
195-
pagevec_init(&pvec);
196-
for_each_sgt_page(page, sgt_iter, st) {
197-
if (!pagevec_add(&pvec, page))
194+
if (sg != st->sgl) {
195+
struct pagevec pvec;
196+
197+
pagevec_init(&pvec);
198+
for_each_sgt_page(page, sgt_iter, st) {
199+
if (!pagevec_add(&pvec, page))
200+
check_release_pagevec(&pvec);
201+
}
202+
if (pagevec_count(&pvec))
198203
check_release_pagevec(&pvec);
199204
}
200-
if (pagevec_count(&pvec))
201-
check_release_pagevec(&pvec);
202205
sg_free_table(st);
203206
kfree(st);
204207

drivers/gpu/drm/i915/gt/intel_context.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ int __intel_context_do_pin(struct intel_context *ce)
9797
{
9898
int err;
9999

100-
GEM_BUG_ON(intel_context_is_closed(ce));
101-
102100
if (unlikely(!test_bit(CONTEXT_ALLOC_BIT, &ce->flags))) {
103101
err = intel_context_alloc_state(ce);
104102
if (err)

drivers/gpu/drm/i915/gvt/vgpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
124124
*/
125125
low_avail = gvt_aperture_sz(gvt) - HOST_LOW_GM_SIZE;
126126
high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE;
127-
num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]);
127+
num_types = ARRAY_SIZE(vgpu_types);
128128

129129
gvt->types = kcalloc(num_types, sizeof(struct intel_vgpu_type),
130130
GFP_KERNEL);

drivers/gpu/drm/i915/i915_cmd_parser.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ struct drm_i915_reg_descriptor {
572572
#define REG32(_reg, ...) \
573573
{ .addr = (_reg), __VA_ARGS__ }
574574

575+
#define REG32_IDX(_reg, idx) \
576+
{ .addr = _reg(idx) }
577+
575578
/*
576579
* Convenience macro for adding 64-bit registers.
577580
*
@@ -669,6 +672,7 @@ static const struct drm_i915_reg_descriptor gen9_blt_regs[] = {
669672
REG64_IDX(RING_TIMESTAMP, BSD_RING_BASE),
670673
REG32(BCS_SWCTRL),
671674
REG64_IDX(RING_TIMESTAMP, BLT_RING_BASE),
675+
REG32_IDX(RING_CTX_TIMESTAMP, BLT_RING_BASE),
672676
REG64_IDX(BCS_GPR, 0),
673677
REG64_IDX(BCS_GPR, 1),
674678
REG64_IDX(BCS_GPR, 2),

drivers/gpu/drm/i915/i915_params.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ i915_param_named(enable_gvt, bool, 0400,
173173
#endif
174174

175175
#if IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)
176-
i915_param_named_unsafe(fake_lmem_start, ulong, 0600,
176+
i915_param_named_unsafe(fake_lmem_start, ulong, 0400,
177177
"Fake LMEM start offset (default: 0)");
178178
#endif
179179

drivers/gpu/drm/i915/i915_params.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct drm_printer;
6464
param(int, mmio_debug, -IS_ENABLED(CONFIG_DRM_I915_DEBUG_MMIO), 0600) \
6565
param(int, edp_vswing, 0, 0400) \
6666
param(unsigned int, reset, 3, 0600) \
67-
param(unsigned int, inject_probe_failure, 0, 0600) \
67+
param(unsigned int, inject_probe_failure, 0, 0) \
6868
param(int, fastboot, -1, 0600) \
6969
param(int, enable_dpcd_backlight, -1, 0600) \
7070
param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE, 0400) \

0 commit comments

Comments
 (0)