Skip to content

Commit b4d3aca

Browse files
committed
drm/i915/gt: Pull sseu context updates under gt
Lift the routines to emit a request to update the SSEU on the intel_context out of i915_gem_context. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200131104548.2451485-6-chris@chris-wilson.co.uk
1 parent 0a3b94a commit b4d3aca

File tree

4 files changed

+102
-85
lines changed

4 files changed

+102
-85
lines changed

drivers/gpu/drm/i915/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ gt-y += \
8181
gt/gen8_ppgtt.o \
8282
gt/intel_breadcrumbs.o \
8383
gt/intel_context.o \
84+
gt/intel_context_sseu.o \
8485
gt/intel_engine_cs.o \
8586
gt/intel_engine_heartbeat.o \
8687
gt/intel_engine_pm.o \

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

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@
7272
#include "gt/gen6_ppgtt.h"
7373
#include "gt/intel_context.h"
7474
#include "gt/intel_engine_heartbeat.h"
75-
#include "gt/intel_engine_pm.h"
7675
#include "gt/intel_engine_user.h"
77-
#include "gt/intel_lrc_reg.h"
7876
#include "gt/intel_ring.h"
7977

8078
#include "i915_gem_context.h"
@@ -1184,89 +1182,6 @@ static int set_ppgtt(struct drm_i915_file_private *file_priv,
11841182
return err;
11851183
}
11861184

1187-
static int gen8_emit_rpcs_config(struct i915_request *rq,
1188-
struct intel_context *ce,
1189-
struct intel_sseu sseu)
1190-
{
1191-
u64 offset;
1192-
u32 *cs;
1193-
1194-
cs = intel_ring_begin(rq, 4);
1195-
if (IS_ERR(cs))
1196-
return PTR_ERR(cs);
1197-
1198-
offset = i915_ggtt_offset(ce->state) +
1199-
LRC_STATE_PN * PAGE_SIZE +
1200-
CTX_R_PWR_CLK_STATE * 4;
1201-
1202-
*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
1203-
*cs++ = lower_32_bits(offset);
1204-
*cs++ = upper_32_bits(offset);
1205-
*cs++ = intel_sseu_make_rpcs(rq->i915, &sseu);
1206-
1207-
intel_ring_advance(rq, cs);
1208-
1209-
return 0;
1210-
}
1211-
1212-
static int
1213-
gen8_modify_rpcs(struct intel_context *ce, struct intel_sseu sseu)
1214-
{
1215-
struct i915_request *rq;
1216-
int ret;
1217-
1218-
lockdep_assert_held(&ce->pin_mutex);
1219-
1220-
/*
1221-
* If the context is not idle, we have to submit an ordered request to
1222-
* modify its context image via the kernel context (writing to our own
1223-
* image, or into the registers directory, does not stick). Pristine
1224-
* and idle contexts will be configured on pinning.
1225-
*/
1226-
if (!intel_context_pin_if_active(ce))
1227-
return 0;
1228-
1229-
rq = intel_engine_create_kernel_request(ce->engine);
1230-
if (IS_ERR(rq)) {
1231-
ret = PTR_ERR(rq);
1232-
goto out_unpin;
1233-
}
1234-
1235-
/* Serialise with the remote context */
1236-
ret = intel_context_prepare_remote_request(ce, rq);
1237-
if (ret == 0)
1238-
ret = gen8_emit_rpcs_config(rq, ce, sseu);
1239-
1240-
i915_request_add(rq);
1241-
out_unpin:
1242-
intel_context_unpin(ce);
1243-
return ret;
1244-
}
1245-
1246-
static int
1247-
intel_context_reconfigure_sseu(struct intel_context *ce, struct intel_sseu sseu)
1248-
{
1249-
int ret;
1250-
1251-
GEM_BUG_ON(INTEL_GEN(ce->engine->i915) < 8);
1252-
1253-
ret = intel_context_lock_pinned(ce);
1254-
if (ret)
1255-
return ret;
1256-
1257-
/* Nothing to do if unmodified. */
1258-
if (!memcmp(&ce->sseu, &sseu, sizeof(sseu)))
1259-
goto unlock;
1260-
1261-
ret = gen8_modify_rpcs(ce, sseu);
1262-
if (!ret)
1263-
ce->sseu = sseu;
1264-
1265-
unlock:
1266-
intel_context_unlock_pinned(ce);
1267-
return ret;
1268-
}
1269-
12701185
static int
12711186
user_to_context_sseu(struct drm_i915_private *i915,
12721187
const struct drm_i915_gem_context_param_sseu *user,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ int intel_context_alloc_state(struct intel_context *ce);
3535

3636
void intel_context_free(struct intel_context *ce);
3737

38+
int intel_context_reconfigure_sseu(struct intel_context *ce,
39+
const struct intel_sseu sseu);
40+
3841
/**
3942
* intel_context_lock_pinned - Stablises the 'pinned' status of the HW context
4043
* @ce - the context
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright © 2019 Intel Corporation
4+
*/
5+
6+
#include "i915_drv.h"
7+
#include "i915_vma.h"
8+
#include "intel_context.h"
9+
#include "intel_engine_pm.h"
10+
#include "intel_gpu_commands.h"
11+
#include "intel_lrc.h"
12+
#include "intel_lrc_reg.h"
13+
#include "intel_ring.h"
14+
#include "intel_sseu.h"
15+
16+
static int gen8_emit_rpcs_config(struct i915_request *rq,
17+
const struct intel_context *ce,
18+
const struct intel_sseu sseu)
19+
{
20+
u64 offset;
21+
u32 *cs;
22+
23+
cs = intel_ring_begin(rq, 4);
24+
if (IS_ERR(cs))
25+
return PTR_ERR(cs);
26+
27+
offset = i915_ggtt_offset(ce->state) +
28+
LRC_STATE_PN * PAGE_SIZE +
29+
CTX_R_PWR_CLK_STATE * 4;
30+
31+
*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
32+
*cs++ = lower_32_bits(offset);
33+
*cs++ = upper_32_bits(offset);
34+
*cs++ = intel_sseu_make_rpcs(rq->i915, &sseu);
35+
36+
intel_ring_advance(rq, cs);
37+
38+
return 0;
39+
}
40+
41+
static int
42+
gen8_modify_rpcs(struct intel_context *ce, const struct intel_sseu sseu)
43+
{
44+
struct i915_request *rq;
45+
int ret;
46+
47+
lockdep_assert_held(&ce->pin_mutex);
48+
49+
/*
50+
* If the context is not idle, we have to submit an ordered request to
51+
* modify its context image via the kernel context (writing to our own
52+
* image, or into the registers directory, does not stick). Pristine
53+
* and idle contexts will be configured on pinning.
54+
*/
55+
if (!intel_context_pin_if_active(ce))
56+
return 0;
57+
58+
rq = intel_engine_create_kernel_request(ce->engine);
59+
if (IS_ERR(rq)) {
60+
ret = PTR_ERR(rq);
61+
goto out_unpin;
62+
}
63+
64+
/* Serialise with the remote context */
65+
ret = intel_context_prepare_remote_request(ce, rq);
66+
if (ret == 0)
67+
ret = gen8_emit_rpcs_config(rq, ce, sseu);
68+
69+
i915_request_add(rq);
70+
out_unpin:
71+
intel_context_unpin(ce);
72+
return ret;
73+
}
74+
75+
int
76+
intel_context_reconfigure_sseu(struct intel_context *ce,
77+
const struct intel_sseu sseu)
78+
{
79+
int ret;
80+
81+
GEM_BUG_ON(INTEL_GEN(ce->engine->i915) < 8);
82+
83+
ret = intel_context_lock_pinned(ce);
84+
if (ret)
85+
return ret;
86+
87+
/* Nothing to do if unmodified. */
88+
if (!memcmp(&ce->sseu, &sseu, sizeof(sseu)))
89+
goto unlock;
90+
91+
ret = gen8_modify_rpcs(ce, sseu);
92+
if (!ret)
93+
ce->sseu = sseu;
94+
95+
unlock:
96+
intel_context_unlock_pinned(ce);
97+
return ret;
98+
}

0 commit comments

Comments
 (0)