|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +/* |
| 3 | + * Copyright(c) 2020 Intel Corporation. |
| 4 | + */ |
| 5 | +#include <linux/workqueue.h> |
| 6 | +#include "intel_pxp.h" |
| 7 | +#include "intel_pxp_irq.h" |
| 8 | +#include "intel_pxp_session.h" |
| 9 | +#include "gt/intel_gt_irq.h" |
| 10 | +#include "gt/intel_gt_types.h" |
| 11 | +#include "i915_irq.h" |
| 12 | +#include "i915_reg.h" |
| 13 | + |
| 14 | +/** |
| 15 | + * intel_pxp_irq_handler - Handles PXP interrupts. |
| 16 | + * @pxp: pointer to pxp struct |
| 17 | + * @iir: interrupt vector |
| 18 | + */ |
| 19 | +void intel_pxp_irq_handler(struct intel_pxp *pxp, u16 iir) |
| 20 | +{ |
| 21 | + struct intel_gt *gt = pxp_to_gt(pxp); |
| 22 | + |
| 23 | + if (GEM_WARN_ON(!intel_pxp_is_enabled(pxp))) |
| 24 | + return; |
| 25 | + |
| 26 | + lockdep_assert_held(>->irq_lock); |
| 27 | + |
| 28 | + if (unlikely(!iir)) |
| 29 | + return; |
| 30 | + |
| 31 | + if (iir & (GEN12_DISPLAY_PXP_STATE_TERMINATED_INTERRUPT | |
| 32 | + GEN12_DISPLAY_APP_TERMINATED_PER_FW_REQ_INTERRUPT)) { |
| 33 | + /* immediately mark PXP as inactive on termination */ |
| 34 | + intel_pxp_mark_termination_in_progress(pxp); |
| 35 | + pxp->session_events |= PXP_TERMINATION_REQUEST; |
| 36 | + } |
| 37 | + |
| 38 | + if (iir & GEN12_DISPLAY_STATE_RESET_COMPLETE_INTERRUPT) |
| 39 | + pxp->session_events |= PXP_TERMINATION_COMPLETE; |
| 40 | + |
| 41 | + if (pxp->session_events) |
| 42 | + queue_work(system_unbound_wq, &pxp->session_work); |
| 43 | +} |
| 44 | + |
| 45 | +static inline void __pxp_set_interrupts(struct intel_gt *gt, u32 interrupts) |
| 46 | +{ |
| 47 | + struct intel_uncore *uncore = gt->uncore; |
| 48 | + const u32 mask = interrupts << 16; |
| 49 | + |
| 50 | + intel_uncore_write(uncore, GEN11_CRYPTO_RSVD_INTR_ENABLE, mask); |
| 51 | + intel_uncore_write(uncore, GEN11_CRYPTO_RSVD_INTR_MASK, ~mask); |
| 52 | +} |
| 53 | + |
| 54 | +static inline void pxp_irq_reset(struct intel_gt *gt) |
| 55 | +{ |
| 56 | + spin_lock_irq(>->irq_lock); |
| 57 | + gen11_gt_reset_one_iir(gt, 0, GEN11_KCR); |
| 58 | + spin_unlock_irq(>->irq_lock); |
| 59 | +} |
| 60 | + |
| 61 | +void intel_pxp_irq_enable(struct intel_pxp *pxp) |
| 62 | +{ |
| 63 | + struct intel_gt *gt = pxp_to_gt(pxp); |
| 64 | + |
| 65 | + spin_lock_irq(>->irq_lock); |
| 66 | + |
| 67 | + if (!pxp->irq_enabled) |
| 68 | + WARN_ON_ONCE(gen11_gt_reset_one_iir(gt, 0, GEN11_KCR)); |
| 69 | + |
| 70 | + __pxp_set_interrupts(gt, GEN12_PXP_INTERRUPTS); |
| 71 | + pxp->irq_enabled = true; |
| 72 | + |
| 73 | + spin_unlock_irq(>->irq_lock); |
| 74 | +} |
| 75 | + |
| 76 | +void intel_pxp_irq_disable(struct intel_pxp *pxp) |
| 77 | +{ |
| 78 | + struct intel_gt *gt = pxp_to_gt(pxp); |
| 79 | + |
| 80 | + /* |
| 81 | + * We always need to submit a global termination when we re-enable the |
| 82 | + * interrupts, so there is no need to make sure that the session state |
| 83 | + * makes sense at the end of this function. Just make sure this is not |
| 84 | + * called in a path were the driver consider the session as valid and |
| 85 | + * doesn't call a termination on restart. |
| 86 | + */ |
| 87 | + GEM_WARN_ON(intel_pxp_is_active(pxp)); |
| 88 | + |
| 89 | + spin_lock_irq(>->irq_lock); |
| 90 | + |
| 91 | + pxp->irq_enabled = false; |
| 92 | + __pxp_set_interrupts(gt, 0); |
| 93 | + |
| 94 | + spin_unlock_irq(>->irq_lock); |
| 95 | + intel_synchronize_irq(gt->i915); |
| 96 | + |
| 97 | + pxp_irq_reset(gt); |
| 98 | + |
| 99 | + flush_work(&pxp->session_work); |
| 100 | +} |
0 commit comments