# [PATCH 2/4] ACPI, PCI, IRQ: remove double penalty calculation

From: Sinan Kaya
Date: Wed Sep 28 2016 - 19:08:34 EST

acpi_irq_get_penalty returns the penalty for both PCI and ISA penalties.
Now that we don't have any storage place for PCI IRQs, we run into some
math problem such as follows:

The original code was as simple as this:
acpi_isa_irq_penalty += penalty

In order to hide PCI IRQ calculation difference vs. ISA IRQ difference, we
created the acpi_irq_get_penalty function and replaced the above statement
as

acpi_isa_irq_penalty = acpi_irq_get_penalty() + penalty

This is what acpi_irq_get_penalty returns.

acpi_irq_get_penalty()= acpi_isa_irq_penalty + SCI penalty

When you call acpi_penalize_isa_irq twice, you end up with:

acpi_isa_irq_penalty = 2 * SCI penalty + acpi_isa_irq_penalty

Fixing this by directly modifying acpi_isa_irq_penalty for the new penalty

Signed-off-by: Sinan Kaya <okaya@xxxxxxxxxxxxxx>
---
1 file changed, 3 insertions(+), 2 deletions(-)

index 1edda48..df58153 100644
@@ -871,9 +871,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
*/
void acpi_penalize_isa_irq(int irq, int active)
{
+ int penalty = active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING;
+
if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty)))
- acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
- (active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
+ acpi_isa_irq_penalty[irq] += penalty;
}

bool acpi_isa_irq_available(int irq)
--
1.9.1

--------------97707A6EB943ECEA41FEED52
Content-Type: text/plain; charset=UTF-8;