Skip to contentSkip to conversation

ACPI, PCI, irq: remove interrupt limitations

PATCH In review Sinan Kaya 4 participants 15 messages Dec 9, 2015 – Jan 4, 2016

Subsystems (2)
lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

v9 cover ACPI, PCI, irq: remove interrupt limitations

Code currently supports 256 maximum interrupts at this moment. The patch is reconfiguring the penalty array as a dynamic list to remove this limitation.

The ACPI compiler uses the extended format when used interrupt numbers are greater than 15. The extended IRQ is 32 bits according to the ACPI spec. The code supports parsing the extended interrupt numbers. However, due to used data structure type; the code silently truncates interrupt numbers greater than 256.

Changes from V8: (https://lkml.org/lkml/2015/12/3/579)
* split the patch into two as
** ACPI, PCI, irq: remove interrupt count restriction ** ACPI, PCI, irq: remove interrupt number restriction
* add acpi_irq_add_penalty API to simplify code

Sinan Kaya (2):
ACPI, PCI, irq: remove interrupt count restriction ACPI, PCI, irq: remove interrupt number restriction

 drivers/acpi/pci_link.c | 140 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 104 insertions(+), 36 deletions(-)
Signature · 2 lines
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
author
#1 lore raw

PATCH v9 1/2 ACPI, PCI, irq: remove interrupt count restriction

Code currently supports 256 maximum interrupts at this moment. The patch is reconfiguring the penalty array as a dynamic list to remove this limitation.

A new penalty linklist has been added for all other interrupts greater than
16. If an IRQ is not found in the link list, an IRQ info structure will be dynamically allocated on the first access and will be placed on the list for further reuse. The list will grow by the number of supported interrupts in the ACPI table rather than having a 256 hard limitation.

---
 drivers/acpi/pci_link.c | 136 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 34 deletions(-)
drivers/acpi/pci_link.c +102 -34
index 7c8408b..0286f17 100644
@@ -4,6 +4,7 @@
  *  Copyright (C) 2001, 2002 Andy Grover <[email protected]>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]>
  *  Copyright (C) 2002       Dominik Brodowski <[email protected]>
+ *  Copyright (c) 2015, The Linux Foundation. All rights reserved.
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
@@ -437,7 +438,6 @@ 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 PIRQ_PENALTY_PCI_AVAILABLE	(0)
@@ -447,7 +447,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_irq_isa_penalty[ACPI_MAX_ISA_IRQ] = {
 	PIRQ_PENALTY_ISA_ALWAYS,	/* IRQ0 timer */
 	PIRQ_PENALTY_ISA_ALWAYS,	/* IRQ1 keyboard */
 	PIRQ_PENALTY_ISA_ALWAYS,	/* IRQ2 cascade */
@@ -464,9 +464,68 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
 	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
 	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
 	PIRQ_PENALTY_ISA_USED,		/* IRQ15 ide1 */
-	/* >IRQ15 */
 };
 
+struct irq_penalty_info {
+	int irq;
+	int penalty;
+	struct list_head node;
+};
+
+static LIST_HEAD(acpi_irq_penalty_list);
+
+static int acpi_irq_get_penalty(int irq)
+{
+	struct irq_penalty_info *irq_info;
+
+	if (irq < ACPI_MAX_ISA_IRQ)
+		return acpi_irq_isa_penalty[irq];
+
+	list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
+		if (irq_info->irq == irq)
+			return irq_info->penalty;
+	}
+
+	return 0;
+}
+
+static int acpi_irq_set_penalty(int irq, int new_penalty)
+{
+	struct irq_penalty_info *irq_info;
+
+	/* see if this is a ISA IRQ */
+	if (irq < ACPI_MAX_ISA_IRQ) {
+		acpi_irq_isa_penalty[irq] = new_penalty;
+		return 0;
+	}
+
+	/* next, try to locate from the dynamic list */
+	list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
+		if (irq_info->irq == irq) {
+			irq_info->penalty  = new_penalty;
+			return 0;
+		}
+	}
+
+	/* nope, let's allocate a slot for this IRQ */
+	irq_info = kzalloc(sizeof(*irq_info), GFP_KERNEL);
+	if (!irq_info)
+		return -ENOMEM;
+
+	irq_info->irq = irq;
+	irq_info->penalty = new_penalty;
+	list_add_tail(&irq_info->node, &acpi_irq_penalty_list);
+
+	return 0;
+}
+
+static void acpi_irq_add_penalty(int irq, int penalty)
+{
+	int curpen = acpi_irq_get_penalty(irq);
+
+	acpi_irq_set_penalty(irq, curpen + penalty);
+}
+
 int __init acpi_irq_penalty_init(void)
 {
 	struct acpi_pci_link *link;
@@ -487,15 +546,16 @@ int __init acpi_irq_penalty_init(void)
 			    link->irq.possible_count;
 
 			for (i = 0; i < link->irq.possible_count; i++) {
-				if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
-					acpi_irq_penalty[link->irq.
-							 possible[i]] +=
-					    penalty;
+				if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) {
+					int irqpos = link->irq.possible[i];
+
+					acpi_irq_add_penalty(irqpos, penalty);
+				}
 			}
 
 		} else if (link->irq.active) {
-			acpi_irq_penalty[link->irq.active] +=
-			    PIRQ_PENALTY_PCI_POSSIBLE;
+			acpi_irq_add_penalty(link->irq.active,
+					     PIRQ_PENALTY_PCI_POSSIBLE);
 		}
 	}
 
@@ -547,12 +607,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
 		 * 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]])
+			if (acpi_irq_get_penalty(irq) >
+			    acpi_irq_get_penalty(link->irq.possible[i]))
 				irq = link->irq.possible[i];
 		}
 	}
-	if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) {
+	if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) {
 		printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. "
 			    "Try pci=noacpi or acpi=off\n",
 			    acpi_device_name(link->device),
@@ -568,7 +628,8 @@ 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;
+		acpi_irq_add_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);
@@ -778,7 +839,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
 }
 
 /*
- * modify acpi_irq_penalty[] from cmdline
+ * modify penalty from cmdline
  */
 static int __init acpi_irq_penalty_update(char *str, int used)
 {
@@ -796,13 +857,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
 		if (irq < 0)
 			continue;
 
-		if (irq >= ARRAY_SIZE(acpi_irq_penalty))
-			continue;
-
 		if (used)
-			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
+			acpi_irq_add_penalty(irq, PIRQ_PENALTY_ISA_USED);
 		else
-			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
+			acpi_irq_set_penalty(irq, PIRQ_PENALTY_PCI_AVAILABLE);
 
 		if (retval != 2)	/* no next number */
 			break;
@@ -819,18 +877,23 @@ static int __init acpi_irq_penalty_update(char *str, int used)
  */
 void acpi_penalize_isa_irq(int irq, int active)
 {
-	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
-		if (active)
-			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
-		else
-			acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
-	}
+	int penalty;
+
+	if (irq < 0)
+		return;
+
+	if (active)
+		penalty = PIRQ_PENALTY_ISA_USED;
+	else
+		penalty = PIRQ_PENALTY_PCI_USING;
+
+	acpi_irq_add_penalty(irq, penalty);
 }
 
 bool acpi_isa_irq_available(int irq)
 {
-	return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) ||
-			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
+	return irq >= 0 &&
+		(acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
 }
 
 /*
@@ -840,13 +903,18 @@ bool acpi_isa_irq_available(int irq)
  */
 void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
 {
-	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
-		if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
-		    polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
-			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS;
-		else
-			acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
-	}
+	int penalty;
+
+	if (irq < 0)
+		return;
+
+	if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
+	    polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+		penalty = PIRQ_PENALTY_ISA_ALWAYS;
+	else
+		penalty = PIRQ_PENALTY_PCI_USING;
+
+	acpi_irq_add_penalty(irq, penalty);
 }
 
 /*
Signature · 2 lines
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
#2 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 4 lines · Sinan Kaya

Code currently supports 256 maximum interrupts at this moment. The patch is reconfiguring the penalty array as a dynamic list to remove this limitation.

Quoted 8 lines

A new penalty linklist has been added for all other interrupts greater than
16. If an IRQ is not found in the link list, an IRQ info structure will be dynamically allocated on the first access and will be placed on the list for further reuse. The list will grow by the number of supported interrupts in the ACPI table rather than having a 256 hard limitation.

Few nitpicks, though if Bjorn is okay with this one, you may ignore below.

Quoted 73 lines
---
 drivers/acpi/pci_link.c | 136 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 102 insertions(+), 34 deletions(-)
drivers/acpi/pci_link.c +35 -3
index 7c8408b..0286f17 100644
@@ -4,6 +4,7 @@
  *  Copyright (C) 2001, 2002 Andy Grover <[email protected]>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]>
  *  Copyright (C) 2002       Dominik Brodowski <[email protected]>
+ *  Copyright (c) 2015, The Linux Foundation. All rights reserved.
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
@@ -437,7 +438,6 @@ 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 PIRQ_PENALTY_PCI_AVAILABLE     (0)
@@ -447,7 +447,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_irq_isa_penalty[ACPI_MAX_ISA_IRQ] = {
        PIRQ_PENALTY_ISA_ALWAYS,        /* IRQ0 timer */
        PIRQ_PENALTY_ISA_ALWAYS,        /* IRQ1 keyboard */
        PIRQ_PENALTY_ISA_ALWAYS,        /* IRQ2 cascade */
@@ -464,9 +464,68 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
        PIRQ_PENALTY_ISA_USED,          /* IRQ13 fpe, sometimes */
        PIRQ_PENALTY_ISA_USED,          /* IRQ14 ide0 */
        PIRQ_PENALTY_ISA_USED,          /* IRQ15 ide1 */
-       /* >IRQ15 */
 };
 
+struct irq_penalty_info {
+       int irq;
+       int penalty;
+       struct list_head node;
+};
+
+static LIST_HEAD(acpi_irq_penalty_list);
+
+static int acpi_irq_get_penalty(int irq)
+{
+       struct irq_penalty_info *irq_info;
+
+       if (irq < ACPI_MAX_ISA_IRQ)
+               return acpi_irq_isa_penalty[irq];
+
+       list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
+               if (irq_info->irq == irq)
+                       return irq_info->penalty;
+       }
+
+       return 0;
+}
+
+static int acpi_irq_set_penalty(int irq, int new_penalty)
+{
+       struct irq_penalty_info *irq_info;
+
+       /* see if this is a ISA IRQ */
+       if (irq < ACPI_MAX_ISA_IRQ) {
+               acpi_irq_isa_penalty[irq] = new_penalty;
+               return 0;
+       }
+

drivers/acpi/pci_link.c static int acpi_irq_penalty[ACPI_MAX_IRQS] = { · line 511

Quoted 10 lines
drivers/acpi/pci_link.c +10 -0
+       /* next, try to locate from the dynamic list */
+       list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
+               if (irq_info->irq == irq) {
+                       irq_info->penalty  = new_penalty;
+                       return 0;
+               }
+       }
+
+       /* nope, let's allocate a slot for this IRQ */
+       irq_info = kzalloc(sizeof(*irq_info), GFP_KERNEL);

Maybe a comment to explain why we don't have a symmetric free() option.

Quoted 6 lines
drivers/acpi/pci_link.c +6 -0
+       if (!irq_info)
+               return -ENOMEM;
+
+       irq_info->irq = irq;
+       irq_info->penalty = new_penalty;
+       list_add_tail(&irq_info->node, &acpi_irq_penalty_list);

drivers/acpi/pci_link.c static int acpi_irq_penalty[ACPI_MAX_IRQS] = { · line 526

Quoted 10 lines
drivers/acpi/pci_link.c +9 -0
+
+       return 0;
+}
+
+static void acpi_irq_add_penalty(int irq, int penalty)
+{
 
+       int curpen = acpi_irq_get_penalty(irq);
+
+       acpi_irq_set_penalty(irq, curpen + penalty);

Can it be one line?

Quoted 90 lines
drivers/acpi/pci_link.c +2 -0
+}
+
 int __init acpi_irq_penalty_init(void)
 {
        struct acpi_pci_link *link;
drivers/acpi/pci_link.c +16 -22
@@ -487,15 +546,16 @@ int __init acpi_irq_penalty_init(void)
                            link->irq.possible_count;
 
                        for (i = 0; i < link->irq.possible_count; i++) {
-                               if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
-                                       acpi_irq_penalty[link->irq.
-                                                        possible[i]] +=
-                                           penalty;
+                               if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) {
+                                       int irqpos = link->irq.possible[i];
+
+                                       acpi_irq_add_penalty(irqpos, penalty);
+                               }
                        }
 
                } else if (link->irq.active) {
-                       acpi_irq_penalty[link->irq.active] +=
-                           PIRQ_PENALTY_PCI_POSSIBLE;
+                       acpi_irq_add_penalty(link->irq.active,
+                                            PIRQ_PENALTY_PCI_POSSIBLE);
                }
        }
 
@@ -547,12 +607,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
                 * 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]])
+                       if (acpi_irq_get_penalty(irq) >
+                           acpi_irq_get_penalty(link->irq.possible[i]))
                                irq = link->irq.possible[i];
                }
        }
-       if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) {
+       if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) {
                printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. "
                            "Try pci=noacpi or acpi=off\n",
                            acpi_device_name(link->device),
@@ -568,7 +628,8 @@ 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;
+               acpi_irq_add_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);
@@ -778,7 +839,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
 }
 
 /*
- * modify acpi_irq_penalty[] from cmdline
+ * modify penalty from cmdline
  */
 static int __init acpi_irq_penalty_update(char *str, int used)
 {
@@ -796,13 +857,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
                if (irq < 0)
                        continue;
 
-               if (irq >= ARRAY_SIZE(acpi_irq_penalty))
-                       continue;
-
                if (used)
-                       acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
+                       acpi_irq_add_penalty(irq, PIRQ_PENALTY_ISA_USED);
                else
-                       acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
+                       acpi_irq_set_penalty(irq, PIRQ_PENALTY_PCI_AVAILABLE);
 
                if (retval != 2)        /* no next number */
                        break;
@@ -819,18 +877,23 @@ static int __init acpi_irq_penalty_update(char *str, int used)
  */
 void acpi_penalize_isa_irq(int irq, int active)
 {
-       if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
-               if (active)
-                       acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
-               else
-                       acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
-       }
+       int penalty;

drivers/acpi/pci_link.c static int __init acpi_irq_penalty_update(char *str, int used) · line 890

Quoted 10 lines
drivers/acpi/pci_link.c +10 -0
+
+       if (irq < 0)
+               return;
+
+       if (active)
+               penalty = PIRQ_PENALTY_ISA_USED;
+       else
+               penalty = PIRQ_PENALTY_PCI_USING;
+
+       acpi_irq_add_penalty(irq, penalty);

Same as below

Quoted 24 lines
drivers/acpi/pci_link.c +4 -9
 }
 
 bool acpi_isa_irq_available(int irq)
 {
-       return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) ||
-                           acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
+       return irq >= 0 &&
+               (acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
 }
 
 /*
@@ -840,13 +903,18 @@ bool acpi_isa_irq_available(int irq)
  */
 void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
 {
-       if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
-               if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
-                   polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
-                       acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS;
-               else
-                       acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
-       }
+       int penalty;
+

drivers/acpi/pci_link.c bool acpi_isa_irq_available(int irq) · line 917

Quoted 10 lines
drivers/acpi/pci_link.c +10 -0
+       if (irq < 0)
+               return;
+
+       if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
+           polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+               penalty = PIRQ_PENALTY_ISA_ALWAYS;
+       else
+               penalty = PIRQ_PENALTY_PCI_USING;
+
+       acpi_irq_add_penalty(irq, penalty);

Why not to change in place? I think a common sense rule is not to change something existing if it doesn't add any significant value.

- acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+ acpi_irq_add_penalty(irq, PIRQ_PENALTY_PCI_USING);

Quoted 1 line
drivers/acpi/pci_link.c +0 -0
 }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#3 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 10 lines · Andy Shevchenko
Quoted 7 lines

+ if (trigger != ACPI_MADT_TRIGGER_LEVEL ||

Quoted 6 lines
drivers/acpi/pci_link.c +6 -0
+           polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+               penalty = PIRQ_PENALTY_ISA_ALWAYS;
+       else
+               penalty = PIRQ_PENALTY_PCI_USING;
+
+       acpi_irq_add_penalty(irq, penalty);

Why not to change in place? I think a common sense rule is not to change something existing if it doesn't add any significant value.

Sorry, I didn't understand what you mean. Are you asking why we are changing lines like above?

If yes, acpi_irq_penalty used to be an array of 256 entries. Now, acpi_irq_penalty doesn't exist anymore as it was replaced with a linklist.

Quoted 3 lines
(quoted diff) +1 -1
-               acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+              acpi_irq_add_penalty(irq, PIRQ_PENALTY_PCI_USING);
Signature · 4 lines
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
#4 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Hi Sinan,

Quoted 8 lines · Sinan Kaya
Quoted 7 lines · Andy Shevchenko
Quoted 7 lines

+ if (trigger != ACPI_MADT_TRIGGER_LEVEL ||

Quoted 6 lines
drivers/acpi/pci_link.c +6 -0
+           polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+               penalty = PIRQ_PENALTY_ISA_ALWAYS;
+       else
+               penalty = PIRQ_PENALTY_PCI_USING;
+
+       acpi_irq_add_penalty(irq, penalty);
Quoted 11 lines
Quoted 3 lines

Why not to change in place? I think a common sense rule is not to change something existing if it doesn't add any significant value.

Sorry, I didn't understand what you mean. Are you asking why we are changing lines like above?

If yes, acpi_irq_penalty used to be an array of 256 entries. Now, acpi_irq_penalty doesn't exist anymore as it was replaced with a linklist.

Quoted 2 lines
(quoted diff) +1 -1
-               acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+              acpi_irq_add_penalty(irq, PIRQ_PENALTY_PCI_USING);

I think Andy was suggesting that you make the change without introducing the penalty variable.

Christopher Covington

Signature · 3 lines
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#5 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Hi Bjorn, Andy;

Quoted 20 lines · Christopher Covington

Hi Sinan,

Quoted 17 lines · Sinan Kaya
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines

+ if (trigger != ACPI_MADT_TRIGGER_LEVEL ||

Quoted 6 lines
drivers/acpi/pci_link.c +6 -0
+           polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+               penalty = PIRQ_PENALTY_ISA_ALWAYS;
+       else
+               penalty = PIRQ_PENALTY_PCI_USING;
+
+       acpi_irq_add_penalty(irq, penalty);

Why not to change in place? I think a common sense rule is not to change something existing if it doesn't add any significant value.

Sorry, I didn't understand what you mean. Are you asking why we are changing lines like above?

If yes, acpi_irq_penalty used to be an array of 256 entries. Now, acpi_irq_penalty doesn't exist anymore as it was replaced with a linklist.

Quoted 8 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-               acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+              acpi_irq_add_penalty(irq, PIRQ_PENALTY_PCI_USING);

I think Andy was suggesting that you make the change without introducing the penalty variable.

Christopher Covington

Andy,
Is Chris' interpretation correct?

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Bjorn,
Is there any other question you need me to address on this patch?

Signature · 3 lines
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
#6 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 14 lines · Sinan Kaya
Quoted 12 lines · Christopher Covington
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines
Quoted 8 lines

+ if (trigger != ACPI_MADT_TRIGGER_LEVEL ||

Quoted 6 lines
drivers/acpi/pci_link.c +6 -0
+           polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+               penalty = PIRQ_PENALTY_ISA_ALWAYS;
+       else
+               penalty = PIRQ_PENALTY_PCI_USING;
+
+       acpi_irq_add_penalty(irq, penalty);

Why not to change in place? I think a common sense rule is not to change something existing if it doesn't add any significant value.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-               acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+              acpi_irq_add_penalty(irq, PIRQ_PENALTY_PCI_USING);

I think Andy was suggesting that you make the change without introducing the penalty variable.

Is Chris' interpretation correct?

Yep, I meant not to use an additional variable.

Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#7 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 5 lines · Andy Shevchenko

Yep, I meant not to use an additional variable.

Quoted 2 lines
Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

It is a request not a question. I hate wasting your time and my time with things that I could have fixed before submitting a patch.

I ran the checkpatch and it said I'm good to go. But, obviously I'm not.

Signature · 3 lines
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
#8 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 11 lines · Sinan Kaya
Quoted 5 lines · Andy Shevchenko

Yep, I meant not to use an additional variable.

Quoted 2 lines
Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

It is a request not a question. I hate wasting your time and my time with things that I could have fixed before submitting a patch.

I ran the checkpatch and it said I'm good to go. But, obviously I'm not.

Hmm… checkpatch.pl is just a small helper to fix style issues. Here is just a common sense rule, or kind of Occam's razor: no need to have more variables then needed if it doesn't improve something really significantly.

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Sinan Kaya
Quoted 5 lines · Andy Shevchenko

Yep, I meant not to use an additional variable.

Quoted 2 lines
Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

It is a request not a question. I hate wasting your time and my time with things that I could have fixed before submitting a patch.

Quoted 6 lines
Quoted 1 line

I ran the checkpatch and it said I'm good to go. But, obviously I'm not.

Hmm… checkpatch.pl is just a small helper to fix style issues. Here is just a common sense rule, or kind of Occam's razor: no need to have more variables then needed if it doesn't improve something really significantly.

That said, compilers optimize things anyway, so using an extra local variable shouldn't matter for the resulting machine code.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · Sinan Kaya
Quoted 5 lines · Andy Shevchenko

Yep, I meant not to use an additional variable.

Quoted 2 lines
Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

It is a request not a question. I hate wasting your time and my time with things that I could have fixed before submitting a patch.

I ran the checkpatch and it said I'm good to go. But, obviously I'm not.

Quoted 7 lines
Quoted 4 lines

Hmm… checkpatch.pl is just a small helper to fix style issues. Here is just a common sense rule, or kind of Occam's razor: no need to have more variables then needed if it doesn't improve something really significantly.

That said, compilers optimize things anyway, so using an extra local variable shouldn't matter for the resulting machine code.

I'm not totally against that, but is the additional variable helpful here?

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 20 lines · Andy Shevchenko
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · Andy Shevchenko
Quoted 11 lines · Sinan Kaya
Quoted 5 lines · Andy Shevchenko

Yep, I meant not to use an additional variable.

Quoted 2 lines
Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

It is a request not a question. I hate wasting your time and my time with things that I could have fixed before submitting a patch.

I ran the checkpatch and it said I'm good to go. But, obviously I'm not.

Hmm… checkpatch.pl is just a small helper to fix style issues. Here is just a common sense rule, or kind of Occam's razor: no need to have more variables then needed if it doesn't improve something really significantly.

Quoted 4 lines
Quoted 2 lines

That said, compilers optimize things anyway, so using an extra local variable shouldn't matter for the resulting machine code.

I'm not totally against that, but is the additional variable helpful here?

Well, I guess you can argue both ways.

Surely, the same result can be achieved with fewer lines of code if that's what you mean, so what about the following change on top of the $subject patch?

---
From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] ACPI / PCI: Simplify acpi_penalize_isa_irq()

acpi_penalize_isa_irq() can be written in fewer lines of code, so do that. No functional change.

---
 drivers/acpi/pci_link.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/acpi/pci_link.c +3 -11
Index: linux-pm/drivers/acpi/pci_link.c
===================================================================
@@ -877,17 +877,9 @@ static int __init acpi_irq_penalty_updat
  */
 void acpi_penalize_isa_irq(int irq, int active)
 {
-	int penalty;
-
-	if (irq < 0)
-		return;
-
-	if (active)
-		penalty = PIRQ_PENALTY_ISA_USED;
-	else
-		penalty = PIRQ_PENALTY_PCI_USING;
-
-	acpi_irq_add_penalty(irq, penalty);
+	if (irq >= 0)
+		acpi_irq_add_penalty(irq, active ?
+			PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
 }
 
 bool acpi_isa_irq_available(int irq)
#12 lore raw

Re: [PATCH V9 1/2] ACPI, PCI, irq: remove interrupt count restriction

Quoted 55 lines · Rafael J. Wysocki
Quoted 20 lines · Andy Shevchenko
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines · Andy Shevchenko
Quoted 11 lines · Sinan Kaya
Quoted 5 lines · Andy Shevchenko

Yep, I meant not to use an additional variable.

Quoted 2 lines
Quoted 2 lines

BTW, I suggest you spend some time around checkpatch for contributions. I could have caught most of the issues you are generally concerned before submitting a patch.

Is it a question?

It is a request not a question. I hate wasting your time and my time with things that I could have fixed before submitting a patch.

I ran the checkpatch and it said I'm good to go. But, obviously I'm not.

Hmm… checkpatch.pl is just a small helper to fix style issues. Here is just a common sense rule, or kind of Occam's razor: no need to have more variables then needed if it doesn't improve something really significantly.

Quoted 4 lines
Quoted 2 lines

That said, compilers optimize things anyway, so using an extra local variable shouldn't matter for the resulting machine code.

I'm not totally against that, but is the additional variable helpful here?

Well, I guess you can argue both ways.

Surely, the same result can be achieved with fewer lines of code if that's what you mean, so what about the following change on top of the $subject patch?

---
From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] ACPI / PCI: Simplify acpi_penalize_isa_irq()

acpi_penalize_isa_irq() can be written in fewer lines of code, so do that. No functional change.

---
 drivers/acpi/pci_link.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Index: linux-pm/drivers/acpi/pci_link.c
===================================================================

drivers/acpi/pci_link.c +0 -4
@@ -877,17 +877,9 @@ static int __init acpi_irq_penalty_updat
  */
 void acpi_penalize_isa_irq(int irq, int active)
 {
-       int penalty;
-
-       if (irq < 0)
-               return;

drivers/acpi/pci_link.c static int __init acpi_irq_penalty_updat · line 882

Quoted 10 lines
drivers/acpi/pci_link.c +3 -7
-
-       if (active)
-               penalty = PIRQ_PENALTY_ISA_USED;
-       else
-               penalty = PIRQ_PENALTY_PCI_USING;
-
-       acpi_irq_add_penalty(irq, penalty);
+       if (irq >= 0)
+               acpi_irq_add_penalty(irq, active ?
+                       PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);

Works for me as well!

Quoted 4 lines
drivers/acpi/pci_link.c +0 -0
 }
 
 bool acpi_isa_irq_available(int irq)
Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#13 lore raw

PATCH v9 2/2 ACPI, PCI, irq: remove interrupt number restriction

In reply to Sinan Kaya

The ACPI compiler uses the extended format when used interrupt numbers are greater than 15. The extended IRQ syntax is 32 bits according to the ACPI spec. The code supports parsing the extended interrupt numbers. However, due to used data structure type; the code silently truncates interrupt numbers greater than 256.

---
 drivers/acpi/pci_link.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/pci_link.c +2 -2
index 0286f17..5114d80 100644
@@ -68,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;
 };
Signature · 2 lines
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
#14 lore raw
In reply to Sinan Kaya
Quoted 16 lines · Sinan Kaya

Code currently supports 256 maximum interrupts at this moment. The patch is reconfiguring the penalty array as a dynamic list to remove this limitation.

The ACPI compiler uses the extended format when used interrupt numbers are greater than 15. The extended IRQ is 32 bits according to the ACPI spec. The code supports parsing the extended interrupt numbers. However, due to used data structure type; the code silently truncates interrupt numbers greater than 256.

Changes from V8: (https://lkml.org/lkml/2015/12/3/579)
* split the patch into two as
** ACPI, PCI, irq: remove interrupt count restriction ** ACPI, PCI, irq: remove interrupt number restriction
* add acpi_irq_add_penalty API to simplify code

Quoted 6 lines

Sinan Kaya (2):
ACPI, PCI, irq: remove interrupt count restriction ACPI, PCI, irq: remove interrupt number restriction

 drivers/acpi/pci_link.c | 140 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 104 insertions(+), 36 deletions(-)

Both patches applied, thanks!