Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbbKIFY6 (ORCPT ); Mon, 9 Nov 2015 00:24:58 -0500 Received: from mga14.intel.com ([192.55.52.115]:10990 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750814AbbKIFYz (ORCPT ); Mon, 9 Nov 2015 00:24:55 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,265,1444719600"; d="scan'208";a="845810253" Subject: Re: [PATCH] acpi: add support for extended IRQ to PCI link To: Sinan Kaya , linux-acpi@vger.kernel.org, timur@codeaurora.org, cov@codeaurora.org, jcm@redhat.com References: <1446998832-7023-1-git-send-email-okaya@codeaurora.org> Cc: agross@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Rafael J. Wysocki" , Len Brown , linux-kernel@vger.kernel.org From: Jiang Liu Organization: Intel Message-ID: <56402E23.1070805@linux.intel.com> Date: Mon, 9 Nov 2015 13:24:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446998832-7023-1-git-send-email-okaya@codeaurora.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4151 Lines: 113 On 2015/11/9 0:07, Sinan Kaya wrote: > The ACPI compiler uses the extended format when > used interrupt numbers are greater than 256. > The PCI link code currently only supports simple > interrupt format. The IRQ numbers are represented > using 32 bits when extended IRQ syntax. This patch > changes the interrupt number type to 32 bits and > places an upper limit of 1020 as possible interrupt > id. Additional checks have been placed to prevent > out of bounds writes. > > Signed-off-by: Sinan Kaya > --- > drivers/acpi/pci_link.c | 35 ++++++++++++++++++++++------------- > 1 file changed, 22 insertions(+), 13 deletions(-) > > diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c > index 7c8408b..18a9190 100644 > --- a/drivers/acpi/pci_link.c > +++ b/drivers/acpi/pci_link.c > @@ -1,6 +1,7 @@ > /* > * pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $) > * > + * Copyright (c) 2015, The Linux Foundation. All rights reserved. > * Copyright (C) 2001, 2002 Andy Grover > * Copyright (C) 2001, 2002 Paul Diefenbaugh > * Copyright (C) 2002 Dominik Brodowski > @@ -67,12 +68,12 @@ static struct acpi_scan_handler pci_link_handler = { > * later even the link is disable. Instead, we just repick the active irq > */ > struct acpi_pci_link_irq { > - u8 active; /* Current IRQ */ > + u32 active; /* Current IRQ */ > u8 triggering; /* All IRQs */ > u8 polarity; /* All IRQs */ > u8 resource_type; > u8 possible_count; > - u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; > + u32 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; > u8 initialized:1; > u8 reserved:7; > }; Hi Sinan, This data structure become some sort of big, any idea to reduce memory consumption? Thanks, Gerry > @@ -437,7 +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_IRQS 1020 > #define ACPI_MAX_ISA_IRQ 16 > > #define PIRQ_PENALTY_PCI_AVAILABLE (0) > @@ -493,7 +494,8 @@ int __init acpi_irq_penalty_init(void) > penalty; > } > > - } else if (link->irq.active) { > + } else if (link->irq.active && > + (link->irq.active < ACPI_MAX_IRQS)) { > acpi_irq_penalty[link->irq.active] += > PIRQ_PENALTY_PCI_POSSIBLE; > } > @@ -542,14 +544,19 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) > irq = link->irq.possible[link->irq.possible_count - 1]; > > if (acpi_irq_balance || !link->irq.active) { > - /* > - * Select the best IRQ. This is done in reverse to promote > - * the use of IRQs 9, 10, 11, and >15. > - */ > - for (i = (link->irq.possible_count - 1); i >= 0; i--) { > - if (acpi_irq_penalty[irq] > > - acpi_irq_penalty[link->irq.possible[i]]) > - irq = link->irq.possible[i]; > + > + if (irq < ACPI_MAX_IRQS) { > + /* > + * Select the best IRQ. This is done in reverse to > + * promote the use of IRQs 9, 10, 11, and >15. > + */ > + for (i = (link->irq.possible_count - 1); i >= 0; > + i--) { > + if ((link->irq.possible[i] < ACPI_MAX_IRQS) && > + (acpi_irq_penalty[irq] > > + acpi_irq_penalty[link->irq.possible[i]])) > + irq = link->irq.possible[i]; > + } > } > } > if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) { > @@ -568,7 +575,9 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) > acpi_device_bid(link->device)); > return -ENODEV; > } else { > - acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; > + if (link->irq.active < ACPI_MAX_IRQS) > + acpi_irq_penalty[link->irq.active] += > + PIRQ_PENALTY_PCI_USING; > printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n", > acpi_device_name(link->device), > acpi_device_bid(link->device), link->irq.active); > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/