-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drm/i915/pxp: Implement PXP irq handler
The HW will generate a teardown interrupt when session termination is required, which requires i915 to submit a terminating batch. Once the HW is done with the termination it will generate another interrupt, at which point it is safe to re-create the session. Since the termination and re-creation flow is something we want to trigger from the driver as well, use a common work function that can be called both from the irq handler and from the driver set-up flows, which has the addded benefit of allowing us to skip any extra locks because the work itself serializes the operations. v2: use struct completion instead of bool (Chris) v3: drop locks, clean up functions and improve comments (Chris), move to common work function. v4: improve comments, simplify wait logic (Rodrigo) v5: unconditionally set interrupts, rename state_attacked var (Rodrigo) v10: remove inclusion of intel_gt_types.h from intel_pxp.h (Jani) Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com> Signed-off-by: Huang, Sean Z <sean.z.huang@intel.com> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210924191452.1539378-10-alan.previn.teres.alexis@intel.com
- Loading branch information
Huang, Sean Z
authored and
Rodrigo Vivi
committed
Oct 4, 2021
1 parent
95c9e12
commit 2ae0968
Showing
11 changed files
with
284 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// SPDX-License-Identifier: MIT | ||
/* | ||
* Copyright(c) 2020 Intel Corporation. | ||
*/ | ||
#include <linux/workqueue.h> | ||
#include "intel_pxp.h" | ||
#include "intel_pxp_irq.h" | ||
#include "intel_pxp_session.h" | ||
#include "gt/intel_gt_irq.h" | ||
#include "gt/intel_gt_types.h" | ||
#include "i915_irq.h" | ||
#include "i915_reg.h" | ||
|
||
/** | ||
* intel_pxp_irq_handler - Handles PXP interrupts. | ||
* @pxp: pointer to pxp struct | ||
* @iir: interrupt vector | ||
*/ | ||
void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir) | ||
{ | ||
struct intel_gt *gt = pxp_to_gt(pxp); | ||
|
||
if (GEM_WARN_ON(!intel_pxp_is_enabled(pxp))) | ||
return; | ||
|
||
lockdep_assert_held(>->irq_lock); | ||
|
||
if (unlikely(!iir)) | ||
return; | ||
|
||
if (iir & (GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT | | ||
GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT)) { | ||
/* immediately mark PXP as inactive on termination */ | ||
intel_pxp_mark_termination_in_progress(pxp); | ||
pxp->session_events |= PXP_TERMINATION_REQUEST; | ||
} | ||
|
||
if (iir & GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT) | ||
pxp->session_events |= PXP_TERMINATION_COMPLETE; | ||
|
||
if (pxp->session_events) | ||
queue_work(system_unbound_wq, &pxp->session_work); | ||
} | ||
|
||
static inline void __pxp_set_interrupts(struct intel_gt *gt, u32 interrupts) | ||
{ | ||
struct intel_uncore *uncore = gt->uncore; | ||
const u32 mask = interrupts << 16; | ||
|
||
intel_uncore_write(uncore, GEN11_CRYPTO_RSVD_INTR_ENABLE, mask); | ||
intel_uncore_write(uncore, GEN11_CRYPTO_RSVD_INTR_MASK, ~mask); | ||
} | ||
|
||
static inline void pxp_irq_reset(struct intel_gt *gt) | ||
{ | ||
spin_lock_irq(>->irq_lock); | ||
gen11_gt_reset_one_iir(gt, 0, GEN11_KCR); | ||
spin_unlock_irq(>->irq_lock); | ||
} | ||
|
||
void intel_pxp_irq_enable(struct intel_pxp *pxp) | ||
{ | ||
struct intel_gt *gt = pxp_to_gt(pxp); | ||
|
||
spin_lock_irq(>->irq_lock); | ||
|
||
if (!pxp->irq_enabled) | ||
WARN_ON_ONCE(gen11_gt_reset_one_iir(gt, 0, GEN11_KCR)); | ||
|
||
__pxp_set_interrupts(gt, GEN12_PXP_INTERRUPTS); | ||
pxp->irq_enabled = true; | ||
|
||
spin_unlock_irq(>->irq_lock); | ||
} | ||
|
||
void intel_pxp_irq_disable(struct intel_pxp *pxp) | ||
{ | ||
struct intel_gt *gt = pxp_to_gt(pxp); | ||
|
||
/* | ||
* We always need to submit a global termination when we re-enable the | ||
* interrupts, so there is no need to make sure that the session state | ||
* makes sense at the end of this function. Just make sure this is not | ||
* called in a path were the driver consider the session as valid and | ||
* doesn't call a termination on restart. | ||
*/ | ||
GEM_WARN_ON(intel_pxp_is_active(pxp)); | ||
|
||
spin_lock_irq(>->irq_lock); | ||
|
||
pxp->irq_enabled = false; | ||
__pxp_set_interrupts(gt, 0); | ||
|
||
spin_unlock_irq(>->irq_lock); | ||
intel_synchronize_irq(gt->i915); | ||
|
||
pxp_irq_reset(gt); | ||
|
||
flush_work(&pxp->session_work); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
/* | ||
* Copyright(c) 2020, Intel Corporation. All rights reserved. | ||
*/ | ||
|
||
#ifndef __INTEL_PXP_IRQ_H__ | ||
#define __INTEL_PXP_IRQ_H__ | ||
|
||
#include <linux/types.h> | ||
|
||
struct intel_pxp; | ||
|
||
#define GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT BIT(1) | ||
#define GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT BIT(2) | ||
#define GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT BIT(3) | ||
|
||
#define GEN12_PXP_INTERRUPTS \ | ||
(GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT | \ | ||
GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT | \ | ||
GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT) | ||
|
||
#ifdef CONFIG_DRM_I915_PXP | ||
void intel_pxp_irq_enable(struct intel_pxp *pxp); | ||
void intel_pxp_irq_disable(struct intel_pxp *pxp); | ||
void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir); | ||
#else | ||
static inline void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir) | ||
{ | ||
} | ||
#endif | ||
|
||
#endif /* __INTEL_PXP_IRQ_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.