Re: [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16

From: Bjorn Helgaas
Date: Tue Apr 26 2016 - 14:38:42 EST


On Sun, Apr 17, 2016 at 01:36:54PM -0400, Sinan Kaya wrote:
> Now that the supported number of PCI IRQs are no longer capped
> with 256, renaming the static array to support ISA IRQs only
> and removing the MAX_IRQS constant.
>
> Signed-off-by: Sinan Kaya <okaya@xxxxxxxxxxxxxx>
> ---
> drivers/acpi/pci_link.c | 40 ++++++++++++++++++++--------------------
> 1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
> index cc0ba16..12ea784 100644
> --- a/drivers/acpi/pci_link.c
> +++ b/drivers/acpi/pci_link.c
> @@ -438,8 +438,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
> * enabled system.
> */
>
> -#define ACPI_MAX_IRQS 256
> -#define ACPI_MAX_ISA_IRQ 16
> +#define ACPI_MAX_ISA_IRQS 16
>
> #define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
> #define PIRQ_PENALTY_PCI_USING (16*16*16)
> @@ -447,7 +446,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
> #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
> #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
>
> -static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
> +static int acpi_isa_irq_penalty[ACPI_MAX_ISA_IRQS] = {
> PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
> PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
> PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
> @@ -500,8 +499,8 @@ static int acpi_irq_get_penalty(int irq)
> {
> int penalty = 0;
>
> - if (irq < ACPI_MAX_ISA_IRQ)
> - penalty += acpi_irq_penalty[irq];
> + if (irq < ACPI_MAX_ISA_IRQS)

Nit: sometimes you use "irq < ACPI_MAX_ISA_IRQS", other times you use
"irq < ARRAY_SIZE(acpi_isa_irq_penalty)". Seems like they could be
consistent.

> - if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
> - acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
> + 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;
> }
>
> bool acpi_isa_irq_available(int irq)
> {
> - return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) ||
> + return irq >= 0 && (irq >= ARRAY_SIZE(acpi_isa_irq_penalty) ||
> acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
> }
>
> --
> 1.8.2.1
>