]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: split gen11_irq_handler to make it shareable
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 24 Oct 2019 19:51:22 +0000 (12:51 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 25 Oct 2019 20:55:49 +0000 (13:55 -0700)
Split gen11_irq_handler() to receive as parameter the function
pointers. This allows to share the interrupt handler even if the enable/disable
functions are different.

Make sure it's always inlined to avoid the extra indirect call on the
hot path. Checking with gcc 9 this produce the exact same code as of
now:

$ size drivers/gpu/drm/i915/i915_irq*.o
   text    data     bss     dec     hex filename
  47511     560       0   48071    bbc7 drivers/gpu/drm/i915/i915_irq.o
  47511     560       0   48071    bbc7 drivers/gpu/drm/i915/i915_irq_new.o

$ gdb -batch -ex 'file drivers/gpu/drm/i915/i915_irq.o' -ex 'disassemble gen11_irq_handler' > /tmp/old.s
$ gdb -batch -ex 'file drivers/gpu/drm/i915/i915_irq_new.o' -ex 'disassemble gen11_irq_handler' > /tmp/new.s
$ git diff --no-index /tmp/{old,new}.s
$

So, no change in behavior, just a simple refactor.

Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20191024195122.22877-4-lucas.demarchi@intel.com
drivers/gpu/drm/i915/i915_irq.c

index a048c79a6a55d49361d69b05bd991876e6be11af..33020c8ca5f61cab661313d604ca256df9508229 100644 (file)
@@ -2861,9 +2861,11 @@ static inline void gen11_master_intr_enable(void __iomem * const regs)
        raw_reg_write(regs, GEN11_GFX_MSTR_IRQ, GEN11_MASTER_IRQ);
 }
 
-static irqreturn_t gen11_irq_handler(int irq, void *arg)
+static __always_inline irqreturn_t
+__gen11_irq_handler(struct drm_i915_private * const i915,
+                   u32 (*intr_disable)(void __iomem * const regs),
+                   void (*intr_enable)(void __iomem * const regs))
 {
-       struct drm_i915_private * const i915 = arg;
        void __iomem * const regs = i915->uncore.regs;
        struct intel_gt *gt = &i915->gt;
        u32 master_ctl;
@@ -2872,9 +2874,9 @@ static irqreturn_t gen11_irq_handler(int irq, void *arg)
        if (!intel_irqs_enabled(i915))
                return IRQ_NONE;
 
-       master_ctl = gen11_master_intr_disable(regs);
+       master_ctl = intr_disable(regs);
        if (!master_ctl) {
-               gen11_master_intr_enable(regs);
+               intr_enable(regs);
                return IRQ_NONE;
        }
 
@@ -2896,13 +2898,20 @@ static irqreturn_t gen11_irq_handler(int irq, void *arg)
 
        gu_misc_iir = gen11_gu_misc_irq_ack(gt, master_ctl);
 
-       gen11_master_intr_enable(regs);
+       intr_enable(regs);
 
        gen11_gu_misc_irq_handler(gt, gu_misc_iir);
 
        return IRQ_HANDLED;
 }
 
+static irqreturn_t gen11_irq_handler(int irq, void *arg)
+{
+       return __gen11_irq_handler(arg,
+                                  gen11_master_intr_disable,
+                                  gen11_master_intr_enable);
+}
+
 /* Called from drm generic code, passed 'crtc' which
  * we use as a pipe index
  */