1 // SPDX-License-Identifier: MIT
3 * Copyright © 2023 Intel Corporation
8 #include "intel_uncore.h"
10 void gen2_irq_reset(struct intel_uncore *uncore, struct i915_irq_regs regs)
12 intel_uncore_write(uncore, regs.imr, 0xffffffff);
13 intel_uncore_posting_read(uncore, regs.imr);
15 intel_uncore_write(uncore, regs.ier, 0);
17 /* IIR can theoretically queue up two events. Be paranoid. */
18 intel_uncore_write(uncore, regs.iir, 0xffffffff);
19 intel_uncore_posting_read(uncore, regs.iir);
20 intel_uncore_write(uncore, regs.iir, 0xffffffff);
21 intel_uncore_posting_read(uncore, regs.iir);
25 * We should clear IMR at preinstall/uninstall, and just check at postinstall.
27 void gen2_assert_iir_is_zero(struct intel_uncore *uncore, i915_reg_t reg)
29 struct xe_device *xe = container_of(uncore, struct xe_device, uncore);
30 u32 val = intel_uncore_read(uncore, reg);
36 "Interrupt register 0x%x is not zero: 0x%08x\n",
37 i915_mmio_reg_offset(reg), val);
38 intel_uncore_write(uncore, reg, 0xffffffff);
39 intel_uncore_posting_read(uncore, reg);
40 intel_uncore_write(uncore, reg, 0xffffffff);
41 intel_uncore_posting_read(uncore, reg);
44 void gen2_irq_init(struct intel_uncore *uncore, struct i915_irq_regs regs,
45 u32 imr_val, u32 ier_val)
47 gen2_assert_iir_is_zero(uncore, regs.iir);
49 intel_uncore_write(uncore, regs.ier, ier_val);
50 intel_uncore_write(uncore, regs.imr, imr_val);
51 intel_uncore_posting_read(uncore, regs.imr);
54 bool intel_irqs_enabled(struct xe_device *xe)
57 * XXX: i915 has a racy handling of the irq.enabled, since it doesn't
58 * lock its transitions. Because of that, the irq.enabled sometimes
59 * is not read with the irq.lock in place.
60 * However, the most critical cases like vblank and page flips are
61 * properly using the locks.
62 * We cannot take the lock in here or run any kind of assert because
63 * of i915 inconsistency.
64 * But at this point the xe irq is better protected against races,
65 * although the full solution would be protecting the i915 side.
67 return xe->irq.enabled;
70 void intel_synchronize_irq(struct xe_device *xe)
72 synchronize_irq(to_pci_dev(xe->drm.dev)->irq);