Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1267651 > unrolled thread

[PATCH] acpi: add support for extended IRQ to PCI link

Started bySinan Kaya <okaya@codeaurora.org>
First post2015-11-12 07:20 +0100
Last post2015-11-12 17:00 +0100
Articles 6 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] acpi: add support for extended IRQ to PCI link Sinan Kaya <okaya@codeaurora.org> - 2015-11-12 07:20 +0100
    Re: [PATCH] acpi: add support for extended IRQ to PCI link Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-12 11:00 +0100
      Re: [PATCH] acpi: add support for extended IRQ to PCI link Sinan Kaya <okaya@codeaurora.org> - 2015-11-12 16:10 +0100
        Re: [PATCH] acpi: add support for extended IRQ to PCI link Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-12 16:20 +0100
          Re: [PATCH] acpi: add support for extended IRQ to PCI link Timur Tabi <timur@codeaurora.org> - 2015-11-12 17:00 +0100
          Re: [PATCH] acpi: add support for extended IRQ to PCI link okaya@codeaurora.org - 2015-11-12 17:00 +0100

#1267651 — [PATCH] acpi: add support for extended IRQ to PCI link

FromSinan Kaya <okaya@codeaurora.org>
Date2015-11-12 07:20 +0100
Subject[PATCH] acpi: add support for extended IRQ to PCI link
Message-ID<qtToJ-5fA-5@gated-at.bofh.it>
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.

1020 is the maximum interrupt ID that can be assigned to
an ARM SPI interrupt according to ARM architecture.

Additional checks have been placed to prevent out of bounds
writes.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 drivers/acpi/pci_link.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 7c8408b..a2becab 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 <andrew.grover@intel.com>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
@@ -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;
 };
@@ -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;
 		}
@@ -541,14 +543,16 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
 	else
 		irq = link->irq.possible[link->irq.possible_count - 1];
 
-	if (acpi_irq_balance || !link->irq.active) {
+	if ((acpi_irq_balance || !link->irq.active) && (irq < ACPI_MAX_IRQS)) {
 		/*
-		 * Select the best IRQ.  This is done in reverse to promote
-		 * the use of IRQs 9, 10, 11, and >15.
+		 * 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]])
+		i = link->irq.possible_count;
+		while (--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];
 		}
 	}
@@ -568,7 +572,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);
-- 
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

--
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/

[toc] | [next] | [standalone]


#1267766

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2015-11-12 11:00 +0100
Message-ID<qtWPE-7f8-17@gated-at.bofh.it>
In reply to#1267651
On Thu, Nov 12, 2015 at 8:14 AM, Sinan Kaya <okaya@codeaurora.org> 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.
>
> 1020 is the maximum interrupt ID that can be assigned to
> an ARM SPI interrupt according to ARM architecture.

I think it worth to put these lines in the code as well.

>
> Additional checks have been placed to prevent out of bounds
> writes.
>
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  drivers/acpi/pci_link.c | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
> index 7c8408b..a2becab 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 <andrew.grover@intel.com>
>   *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
>   *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
> @@ -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;
>  };
> @@ -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;
>                 }
> @@ -541,14 +543,16 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
>         else
>                 irq = link->irq.possible[link->irq.possible_count - 1];
>
> -       if (acpi_irq_balance || !link->irq.active) {
> +       if ((acpi_irq_balance || !link->irq.active) && (irq < ACPI_MAX_IRQS)) {
>                 /*

> -                * Select the best IRQ.  This is done in reverse to promote
> -                * the use of IRQs 9, 10, 11, and >15.
> +                * Select the best IRQ.  This is done in reverse to
> +                * promote the use of IRQs 9, 10, 11, and >15.

What was changed here?

>                  */
> -               for (i = (link->irq.possible_count - 1); i >= 0; i--) {
> -                       if (acpi_irq_penalty[irq] >
> -                           acpi_irq_penalty[link->irq.possible[i]])
> +               i = link->irq.possible_count;
> +               while (--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];
>                 }
>         }
> @@ -568,7 +572,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);


-- 
With Best Regards,
Andy Shevchenko
--
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/

[toc] | [prev] | [next] | [standalone]


#1268018

FromSinan Kaya <okaya@codeaurora.org>
Date2015-11-12 16:10 +0100
Message-ID<qu1FE-240-31@gated-at.bofh.it>
In reply to#1267766
On 11/12/2015 4:56 AM, Andy Shevchenko wrote:
> On Thu, Nov 12, 2015 at 8:14 AM, Sinan Kaya <okaya@codeaurora.org> 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.
>>
>> 1020 is the maximum interrupt ID that can be assigned to
>> an ARM SPI interrupt according to ARM architecture.
> 
> I think it worth to put these lines in the code as well.
> 

ok

>>
>> Additional checks have been placed to prevent out of bounds
>> writes.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
>> ---
>>  drivers/acpi/pci_link.c | 28 +++++++++++++++++-----------
>>  1 file changed, 17 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
>> index 7c8408b..a2becab 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 <andrew.grover@intel.com>
>>   *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
>>   *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
>> @@ -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;
>>  };
>> @@ -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;
>>                 }
>> @@ -541,14 +543,16 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
>>         else
>>                 irq = link->irq.possible[link->irq.possible_count - 1];
>>
>> -       if (acpi_irq_balance || !link->irq.active) {
>> +       if ((acpi_irq_balance || !link->irq.active) && (irq < ACPI_MAX_IRQS)) {
>>                 /*
> 
>> -                * Select the best IRQ.  This is done in reverse to promote
>> -                * the use of IRQs 9, 10, 11, and >15.
>> +                * Select the best IRQ.  This is done in reverse to
>> +                * promote the use of IRQs 9, 10, 11, and >15.
> 
> What was changed here?

See your comments here.
https://lkml.org/lkml/2015/11/8/231

> 
>>                  */
>> -               for (i = (link->irq.possible_count - 1); i >= 0; i--) {
>> -                       if (acpi_irq_penalty[irq] >
>> -                           acpi_irq_penalty[link->irq.possible[i]])
>> +               i = link->irq.possible_count;
>> +               while (--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];
>>                 }
>>         }
>> @@ -568,7 +572,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);
> 
> 


-- 
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project
--
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/

[toc] | [prev] | [next] | [standalone]


#1268020

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2015-11-12 16:20 +0100
Message-ID<qu1Pj-27m-3@gated-at.bofh.it>
In reply to#1268018
On Thu, Nov 12, 2015 at 5:04 PM, Sinan Kaya <okaya@codeaurora.org> wrote:
> On 11/12/2015 4:56 AM, Andy Shevchenko wrote:
>> On Thu, Nov 12, 2015 at 8:14 AM, Sinan Kaya <okaya@codeaurora.org> wrote:
>>> -       if (acpi_irq_balance || !link->irq.active) {
>>> +       if ((acpi_irq_balance || !link->irq.active) && (irq < ACPI_MAX_IRQS)) {
>>>                 /*
>>
>>> -                * Select the best IRQ.  This is done in reverse to promote
>>> -                * the use of IRQs 9, 10, 11, and >15.
>>> +                * Select the best IRQ.  This is done in reverse to
>>> +                * promote the use of IRQs 9, 10, 11, and >15.
>>
>> What was changed here?
>
> See your comments here.
> https://lkml.org/lkml/2015/11/8/231

So, you refer to narrow commentary blocks, right?
It was about *new* code, leave as is what was before your patch series.

-- 
With Best Regards,
Andy Shevchenko
--
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/

[toc] | [prev] | [next] | [standalone]


#1268051

FromTimur Tabi <timur@codeaurora.org>
Date2015-11-12 17:00 +0100
Message-ID<qu2s1-2lX-11@gated-at.bofh.it>
In reply to#1268020
okaya@codeaurora.org wrote:
> This is what it was before.
>
>> >         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];
> I added a range check for link->irq.possible[i] and irq into this code.
>
>

This change:

-	 * Select the best IRQ.  This is done in reverse to promote
-	 * the use of IRQs 9, 10, 11, and >15.
+	 * Select the best IRQ.  This is done in reverse to
+	 * promote the use of IRQs 9, 10, 11, and >15.

is an unrelated whitespace change.  It doesn't belong in this patch.

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
--
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/

[toc] | [prev] | [next] | [standalone]


#1268062

Fromokaya@codeaurora.org
Date2015-11-12 17:00 +0100
Message-ID<qu2s1-2lX-13@gated-at.bofh.it>
In reply to#1268020
> On Thu, Nov 12, 2015 at 5:04 PM, Sinan Kaya <okaya@codeaurora.org> wrote:
>> On 11/12/2015 4:56 AM, Andy Shevchenko wrote:
>>> On Thu, Nov 12, 2015 at 8:14 AM, Sinan Kaya <okaya@codeaurora.org>
>>> wrote:
>>>> -       if (acpi_irq_balance || !link->irq.active) {
>>>> +       if ((acpi_irq_balance || !link->irq.active) && (irq <
>>>> ACPI_MAX_IRQS)) {
>>>>                 /*
>>>
>>>> -                * Select the best IRQ.  This is done in reverse to
>>>> promote
>>>> -                * the use of IRQs 9, 10, 11, and >15.
>>>> +                * Select the best IRQ.  This is done in reverse to
>>>> +                * promote the use of IRQs 9, 10, 11, and >15.
>>>
>>> What was changed here?
>>
>> See your comments here.
>> https://lkml.org/lkml/2015/11/8/231
>
> So, you refer to narrow commentary blocks, right?
> It was about *new* code, leave as is what was before your patch series.
>
> --
> With Best Regards,
> Andy Shevchenko
>

This is what it was before.

>         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];

I added a range check for link->irq.possible[i] and irq into this code.


--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web