Skip to content

Commit 5adacf1

Browse files
aalteresRadhakrishna Sripada
authored andcommitted
drm/i915/pxp: Add MTL hw-plumbing enabling for KCR operation
Add MTL hw-plumbing enabling for KCR operation under PXP which includes: 1. Updating 'pick-gt' to get the media tile for KCR interrupt handling 2. Adding MTL's KCR registers for PXP operation (init, status-checking, etc.). While doing #2, lets create a separate registers header file for PXP to be consistent with other i915 global subsystems. Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-3-alan.previn.teres.alexis@intel.com
1 parent d6bf74d commit 5adacf1

5 files changed

Lines changed: 58 additions & 22 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ static struct intel_gt *pick_gt(struct intel_gt *gt, u8 class, u8 instance)
106106
case OTHER_CLASS:
107107
if (instance == OTHER_GSC_HECI_2_INSTANCE)
108108
return media_gt;
109-
if (instance == OTHER_GSC_INSTANCE && HAS_ENGINE(media_gt, GSC0))
109+
if ((instance == OTHER_GSC_INSTANCE || instance == OTHER_KCR_INSTANCE) &&
110+
HAS_ENGINE(media_gt, GSC0))
110111
return media_gt;
111112
fallthrough;
112113
default:

drivers/gpu/drm/i915/pxp/intel_pxp.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "intel_pxp.h"
1515
#include "intel_pxp_gsccs.h"
1616
#include "intel_pxp_irq.h"
17+
#include "intel_pxp_regs.h"
1718
#include "intel_pxp_session.h"
1819
#include "intel_pxp_tee.h"
1920
#include "intel_pxp_types.h"
@@ -61,21 +62,22 @@ bool intel_pxp_is_active(const struct intel_pxp *pxp)
6162
return IS_ENABLED(CONFIG_DRM_I915_PXP) && pxp && pxp->arb_is_valid;
6263
}
6364

64-
/* KCR register definitions */
65-
#define KCR_INIT _MMIO(0x320f0)
66-
/* Setting KCR Init bit is required after system boot */
67-
#define KCR_INIT_ALLOW_DISPLAY_ME_WRITES REG_BIT(14)
65+
static void kcr_pxp_set_status(const struct intel_pxp *pxp, bool enable)
66+
{
67+
u32 val = enable ? _MASKED_BIT_ENABLE(KCR_INIT_ALLOW_DISPLAY_ME_WRITES) :
68+
_MASKED_BIT_DISABLE(KCR_INIT_ALLOW_DISPLAY_ME_WRITES);
69+
70+
intel_uncore_write(pxp->ctrl_gt->uncore, KCR_INIT(pxp->kcr_base), val);
71+
}
6872

69-
static void kcr_pxp_enable(struct intel_gt *gt)
73+
static void kcr_pxp_enable(const struct intel_pxp *pxp)
7074
{
71-
intel_uncore_write(gt->uncore, KCR_INIT,
72-
_MASKED_BIT_ENABLE(KCR_INIT_ALLOW_DISPLAY_ME_WRITES));
75+
kcr_pxp_set_status(pxp, true);
7376
}
7477

75-
static void kcr_pxp_disable(struct intel_gt *gt)
78+
static void kcr_pxp_disable(const struct intel_pxp *pxp)
7679
{
77-
intel_uncore_write(gt->uncore, KCR_INIT,
78-
_MASKED_BIT_DISABLE(KCR_INIT_ALLOW_DISPLAY_ME_WRITES));
80+
kcr_pxp_set_status(pxp, false);
7981
}
8082

8183
static int create_vcs_context(struct intel_pxp *pxp)
@@ -127,6 +129,11 @@ static void pxp_init_full(struct intel_pxp *pxp)
127129
init_completion(&pxp->termination);
128130
complete_all(&pxp->termination);
129131

132+
if (pxp->ctrl_gt->type == GT_MEDIA)
133+
pxp->kcr_base = MTL_KCR_BASE;
134+
else
135+
pxp->kcr_base = GEN12_KCR_BASE;
136+
130137
intel_pxp_session_management_init(pxp);
131138

132139
ret = create_vcs_context(pxp);
@@ -369,14 +376,13 @@ int intel_pxp_start(struct intel_pxp *pxp)
369376

370377
void intel_pxp_init_hw(struct intel_pxp *pxp)
371378
{
372-
kcr_pxp_enable(pxp->ctrl_gt);
379+
kcr_pxp_enable(pxp);
373380
intel_pxp_irq_enable(pxp);
374381
}
375382

376383
void intel_pxp_fini_hw(struct intel_pxp *pxp)
377384
{
378-
kcr_pxp_disable(pxp->ctrl_gt);
379-
385+
kcr_pxp_disable(pxp);
380386
intel_pxp_irq_disable(pxp);
381387
}
382388

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright(c) 2023, Intel Corporation. All rights reserved.
4+
*/
5+
6+
#ifndef __INTEL_PXP_REGS_H__
7+
#define __INTEL_PXP_REGS_H__
8+
9+
#include "i915_reg_defs.h"
10+
11+
/* KCR subsystem register base address */
12+
#define GEN12_KCR_BASE 0x32000
13+
#define MTL_KCR_BASE 0x386000
14+
15+
/* KCR enable/disable control */
16+
#define KCR_INIT(base) _MMIO((base) + 0xf0)
17+
18+
/* Setting KCR Init bit is required after system boot */
19+
#define KCR_INIT_ALLOW_DISPLAY_ME_WRITES REG_BIT(14)
20+
21+
/* KCR hwdrm session in play status 0-31 */
22+
#define KCR_SIP(base) _MMIO((base) + 0x260)
23+
24+
/* PXP global terminate register for session termination */
25+
#define KCR_GLOBAL_TERMINATE(base) _MMIO((base) + 0xf8)
26+
27+
#endif /* __INTEL_PXP_REGS_H__ */

drivers/gpu/drm/i915/pxp/intel_pxp_session.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@
1010
#include "intel_pxp_session.h"
1111
#include "intel_pxp_tee.h"
1212
#include "intel_pxp_types.h"
13+
#include "intel_pxp_regs.h"
1314

1415
#define ARB_SESSION I915_PROTECTED_CONTENT_DEFAULT_SESSION /* shorter define */
1516

16-
#define GEN12_KCR_SIP _MMIO(0x32260) /* KCR hwdrm session in play 0-31 */
17-
18-
/* PXP global terminate register for session termination */
19-
#define PXP_GLOBAL_TERMINATE _MMIO(0x320f8)
20-
2117
static bool intel_pxp_session_is_in_play(struct intel_pxp *pxp, u32 id)
2218
{
2319
struct intel_uncore *uncore = pxp->ctrl_gt->uncore;
@@ -26,7 +22,7 @@ static bool intel_pxp_session_is_in_play(struct intel_pxp *pxp, u32 id)
2622

2723
/* if we're suspended the session is considered off */
2824
with_intel_runtime_pm_if_in_use(uncore->rpm, wakeref)
29-
sip = intel_uncore_read(uncore, GEN12_KCR_SIP);
25+
sip = intel_uncore_read(uncore, KCR_SIP(pxp->kcr_base));
3026

3127
return sip & BIT(id);
3228
}
@@ -44,7 +40,7 @@ static int pxp_wait_for_session_state(struct intel_pxp *pxp, u32 id, bool in_pla
4440
return in_play ? -ENODEV : 0;
4541

4642
ret = intel_wait_for_register(uncore,
47-
GEN12_KCR_SIP,
43+
KCR_SIP(pxp->kcr_base),
4844
mask,
4945
in_play ? mask : 0,
5046
100);
@@ -108,7 +104,7 @@ static int pxp_terminate_arb_session_and_global(struct intel_pxp *pxp)
108104
return ret;
109105
}
110106

111-
intel_uncore_write(gt->uncore, PXP_GLOBAL_TERMINATE, 1);
107+
intel_uncore_write(gt->uncore, KCR_GLOBAL_TERMINATE(pxp->kcr_base), 1);
112108

113109
intel_pxp_tee_end_arb_fw_session(pxp, ARB_SESSION);
114110

drivers/gpu/drm/i915/pxp/intel_pxp_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ struct intel_pxp {
2626
*/
2727
struct intel_gt *ctrl_gt;
2828

29+
/**
30+
* @kcr_base: base mmio offset for the KCR engine which is different on legacy platforms
31+
* vs newer platforms where the KCR is inside the media-tile.
32+
*/
33+
u32 kcr_base;
34+
2935
/**
3036
* @gsccs_res: resources for request submission for platforms that have a GSC engine.
3137
*/

0 commit comments

Comments
 (0)