2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 12:14:01 +08:00

genirq: Avoid unnecessary low level irq function calls

Check irq state in enable/disable/unmask/mask_irq to avoid unnecessary
low level irq function calls.

This has two advantages:
    - Conditionals are faster than hardware access

    - Solves issues with the underlying refcounting of the pinctrl
      infrastructure

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: tfiga@chromium.org
Cc: briannorris@chromium.org
Cc: dianders@chromium.org
Link: http://lkml.kernel.org/r/1498476814-12563-2-git-send-email-jeffy.chen@rock-chips.com
This commit is contained in:
Jeffy Chen 2017-06-26 19:33:34 +08:00 committed by Thomas Gleixner
parent d829b8fb24
commit bf22ff45be

View File

@ -314,22 +314,32 @@ void irq_shutdown(struct irq_desc *desc)
void irq_enable(struct irq_desc *desc) void irq_enable(struct irq_desc *desc)
{ {
irq_state_clr_disabled(desc); if (!irqd_irq_disabled(&desc->irq_data)) {
if (desc->irq_data.chip->irq_enable) unmask_irq(desc);
desc->irq_data.chip->irq_enable(&desc->irq_data); } else {
else irq_state_clr_disabled(desc);
desc->irq_data.chip->irq_unmask(&desc->irq_data); if (desc->irq_data.chip->irq_enable) {
irq_state_clr_masked(desc); desc->irq_data.chip->irq_enable(&desc->irq_data);
irq_state_clr_masked(desc);
} else {
unmask_irq(desc);
}
}
} }
static void __irq_disable(struct irq_desc *desc, bool mask) static void __irq_disable(struct irq_desc *desc, bool mask)
{ {
irq_state_set_disabled(desc); if (irqd_irq_disabled(&desc->irq_data)) {
if (desc->irq_data.chip->irq_disable) { if (mask)
desc->irq_data.chip->irq_disable(&desc->irq_data); mask_irq(desc);
irq_state_set_masked(desc); } else {
} else if (mask) { irq_state_set_disabled(desc);
mask_irq(desc); if (desc->irq_data.chip->irq_disable) {
desc->irq_data.chip->irq_disable(&desc->irq_data);
irq_state_set_masked(desc);
} else if (mask) {
mask_irq(desc);
}
} }
} }
@ -378,18 +388,21 @@ void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu)
static inline void mask_ack_irq(struct irq_desc *desc) static inline void mask_ack_irq(struct irq_desc *desc)
{ {
if (desc->irq_data.chip->irq_mask_ack) if (desc->irq_data.chip->irq_mask_ack) {
desc->irq_data.chip->irq_mask_ack(&desc->irq_data); desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
else { irq_state_set_masked(desc);
desc->irq_data.chip->irq_mask(&desc->irq_data); } else {
mask_irq(desc);
if (desc->irq_data.chip->irq_ack) if (desc->irq_data.chip->irq_ack)
desc->irq_data.chip->irq_ack(&desc->irq_data); desc->irq_data.chip->irq_ack(&desc->irq_data);
} }
irq_state_set_masked(desc);
} }
void mask_irq(struct irq_desc *desc) void mask_irq(struct irq_desc *desc)
{ {
if (irqd_irq_masked(&desc->irq_data))
return;
if (desc->irq_data.chip->irq_mask) { if (desc->irq_data.chip->irq_mask) {
desc->irq_data.chip->irq_mask(&desc->irq_data); desc->irq_data.chip->irq_mask(&desc->irq_data);
irq_state_set_masked(desc); irq_state_set_masked(desc);
@ -398,6 +411,9 @@ void mask_irq(struct irq_desc *desc)
void unmask_irq(struct irq_desc *desc) void unmask_irq(struct irq_desc *desc)
{ {
if (!irqd_irq_masked(&desc->irq_data))
return;
if (desc->irq_data.chip->irq_unmask) { if (desc->irq_data.chip->irq_unmask) {
desc->irq_data.chip->irq_unmask(&desc->irq_data); desc->irq_data.chip->irq_unmask(&desc->irq_data);
irq_state_clr_masked(desc); irq_state_clr_masked(desc);
@ -411,10 +427,7 @@ void unmask_threaded_irq(struct irq_desc *desc)
if (chip->flags & IRQCHIP_EOI_THREADED) if (chip->flags & IRQCHIP_EOI_THREADED)
chip->irq_eoi(&desc->irq_data); chip->irq_eoi(&desc->irq_data);
if (chip->irq_unmask) { unmask_irq(desc);
chip->irq_unmask(&desc->irq_data);
irq_state_clr_masked(desc);
}
} }
/* /*