All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
@ 2016-04-17 17:36 Sinan Kaya
  2016-04-17 17:36 ` [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16 Sinan Kaya
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Sinan Kaya @ 2016-04-17 17:36 UTC (permalink / raw)
  To: linux-acpi, timur, cov
  Cc: linux-pci, ravikanth.nalla, lenb, harish.k, ashwin.reghunandanan,
	bhelgaas, rjw, Sinan Kaya, linux-kernel

Code has been redesigned to calculate penalty requirements on the fly. This
significantly simplifies the implementation and removes some of the init
calls from x86 architecture.

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

diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index ededa90..cc0ba16 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -36,6 +36,7 @@
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/irq.h>
 
 #include "internal.h"
 
@@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
 #define ACPI_MAX_IRQS		256
 #define ACPI_MAX_ISA_IRQ	16
 
-#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
 #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
 #define PIRQ_PENALTY_PCI_USING		(16*16*16)
 #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
@@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
 	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
 	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
 	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
-	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
-	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
-	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
+	0,				/* IRQ9  PCI, often acpi */
+	0,				/* IRQ10 PCI */
+	0,				/* IRQ11 PCI */
 	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
 	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
 	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
@@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
 	/* >IRQ15 */
 };
 
+static int acpi_irq_pci_sharing_penalty(int irq)
+{
+	struct acpi_pci_link *link;
+	int penalty = 0;
+
+	list_for_each_entry(link, &acpi_link_list, list) {
+		/*
+		 * If a link is active, penalize its IRQ heavily
+		 * so we try to choose a different IRQ.
+		 */
+		if (link->irq.active && link->irq.active == irq)
+			penalty += PIRQ_PENALTY_PCI_USING;
+		else {
+			int i;
+
+			/*
+			 * If a link is inactive, penalize the IRQs it
+			 * might use, but not as severely.
+			 */
+			for (i = 0; i < link->irq.possible_count; i++)
+				if (link->irq.possible[i] == irq)
+					penalty += PIRQ_PENALTY_PCI_POSSIBLE /
+						link->irq.possible_count;
+		}
+	}
+
+	return penalty;
+}
+
+static int acpi_irq_get_penalty(int irq)
+{
+	int penalty = 0;
+
+	if (irq < ACPI_MAX_ISA_IRQ)
+		penalty += acpi_irq_penalty[irq];
+
+	/*
+	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
+	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
+	* use for PCI IRQs.
+	*/
+	if (irq == acpi_gbl_FADT.sci_interrupt) {
+		u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
+
+		if (type != IRQ_TYPE_LEVEL_LOW)
+			penalty += PIRQ_PENALTY_ISA_ALWAYS;
+		else
+			penalty += PIRQ_PENALTY_PCI_USING;
+	}
+
+	penalty += acpi_irq_pci_sharing_penalty(irq);
+	return penalty;
+}
+
 int __init acpi_irq_penalty_init(void)
 {
 	struct acpi_pci_link *link;
@@ -547,12 +601,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 +622,6 @@ 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;
 		printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
 		       acpi_device_name(link->device),
 		       acpi_device_bid(link->device), link->irq.active);
@@ -800,9 +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
 			continue;
 
 		if (used)
-			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
+			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
+				PIRQ_PENALTY_ISA_USED;
 		else
-			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
+			acpi_irq_penalty[irq] = 0;
 
 		if (retval != 2)	/* no next number */
 			break;
@@ -819,34 +873,19 @@ 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;
-	}
+	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
+		acpi_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) ||
-			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
+		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
 }
 
-/*
- * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict with
- * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be use for
- * PCI IRQs.
- */
 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;
-	}
 }
 
 /*
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16
  2016-04-17 17:36 [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Sinan Kaya
@ 2016-04-17 17:36 ` Sinan Kaya
  2016-04-26 18:38   ` Bjorn Helgaas
  2016-04-17 17:36 ` [PATCH V3 3/4] acpi,pci,irq: remove redundant code in acpi_irq_penalty_init Sinan Kaya
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Sinan Kaya @ 2016-04-17 17:36 UTC (permalink / raw)
  To: linux-acpi, timur, cov
  Cc: linux-pci, ravikanth.nalla, lenb, harish.k, ashwin.reghunandanan,
	bhelgaas, rjw, Sinan Kaya, linux-kernel

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@codeaurora.org>
---
 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)
+		penalty += acpi_isa_irq_penalty[irq];
 
 	/*
 	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
@@ -541,14 +540,15 @@ 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.
+				if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS)
+					acpi_isa_irq_penalty[link->irq.
 							 possible[i]] +=
 					    penalty;
 			}
 
-		} else if (link->irq.active) {
-			acpi_irq_penalty[link->irq.active] +=
+		} else if (link->irq.active &&
+				(link->irq.active < ACPI_MAX_ISA_IRQS)) {
+			acpi_isa_irq_penalty[link->irq.active] +=
 			    PIRQ_PENALTY_PCI_POSSIBLE;
 		}
 	}
@@ -831,7 +831,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
 }
 
 /*
- * modify acpi_irq_penalty[] from cmdline
+ * modify acpi_isa_irq_penalty[] from cmdline
  */
 static int __init acpi_irq_penalty_update(char *str, int used)
 {
@@ -840,24 +840,24 @@ static int __init acpi_irq_penalty_update(char *str, int used)
 	for (i = 0; i < 16; i++) {
 		int retval;
 		int irq;
+		int new_penalty;
 
 		retval = get_option(&str, &irq);
 
 		if (!retval)
 			break;	/* no number found */
 
-		if (irq < 0)
-			continue;
-
-		if (irq >= ARRAY_SIZE(acpi_irq_penalty))
+		/* see if this is a ISA IRQ */
+		if ((irq < 0) || (irq >= ACPI_MAX_ISA_IRQS))
 			continue;
 
 		if (used)
-			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
-				PIRQ_PENALTY_ISA_USED;
+			new_penalty = acpi_irq_get_penalty(irq) +
+					PIRQ_PENALTY_ISA_USED;
 		else
-			acpi_irq_penalty[irq] = 0;
+			new_penalty = 0;
 
+		acpi_isa_irq_penalty[irq] = new_penalty;
 		if (retval != 2)	/* no next number */
 			break;
 	}
@@ -873,14 +873,14 @@ 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))
-		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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH V3 3/4] acpi,pci,irq: remove redundant code in acpi_irq_penalty_init
  2016-04-17 17:36 [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Sinan Kaya
  2016-04-17 17:36 ` [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16 Sinan Kaya
@ 2016-04-17 17:36 ` Sinan Kaya
  2016-04-26 18:39   ` Bjorn Helgaas
  2016-04-17 17:36 ` [PATCH V3 4/4] acpi,pci,irq: remove SCI penalize function Sinan Kaya
  2016-04-26 18:36 ` [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Bjorn Helgaas
  3 siblings, 1 reply; 19+ messages in thread
From: Sinan Kaya @ 2016-04-17 17:36 UTC (permalink / raw)
  To: linux-acpi, timur, cov
  Cc: linux-pci, ravikanth.nalla, lenb, harish.k, ashwin.reghunandanan,
	bhelgaas, rjw, Sinan Kaya, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, Robert Moore, Lv Zheng, linux-kernel, devel

acpi_irq_get_penalty is now calculating the penalty on the fly now.
No need to maintain global list of penalties or calculate them
at the init time. Removing duplicate code in acpi_irq_penalty_init.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 arch/x86/pci/acpi.c         |  1 -
 drivers/acpi/pci_link.c     | 36 ------------------------------------
 include/acpi/acpi_drivers.h |  1 -
 3 files changed, 38 deletions(-)

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 3cd6983..b2a4e2a 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -396,7 +396,6 @@ int __init pci_acpi_init(void)
 		return -ENODEV;
 
 	printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
-	acpi_irq_penalty_init();
 	pcibios_enable_irq = acpi_pci_irq_enable;
 	pcibios_disable_irq = acpi_pci_irq_disable;
 	x86_init.pci.init_irq = x86_init_noop;
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 12ea784..ab39208 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -520,42 +520,6 @@ static int acpi_irq_get_penalty(int irq)
 	return penalty;
 }
 
-int __init acpi_irq_penalty_init(void)
-{
-	struct acpi_pci_link *link;
-	int i;
-
-	/*
-	 * Update penalties to facilitate IRQ balancing.
-	 */
-	list_for_each_entry(link, &acpi_link_list, list) {
-
-		/*
-		 * reflect the possible and active irqs in the penalty table --
-		 * useful for breaking ties.
-		 */
-		if (link->irq.possible_count) {
-			int penalty =
-			    PIRQ_PENALTY_PCI_POSSIBLE /
-			    link->irq.possible_count;
-
-			for (i = 0; i < link->irq.possible_count; i++) {
-				if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS)
-					acpi_isa_irq_penalty[link->irq.
-							 possible[i]] +=
-					    penalty;
-			}
-
-		} else if (link->irq.active &&
-				(link->irq.active < ACPI_MAX_ISA_IRQS)) {
-			acpi_isa_irq_penalty[link->irq.active] +=
-			    PIRQ_PENALTY_PCI_POSSIBLE;
-		}
-	}
-
-	return 0;
-}
-
 static int acpi_irq_balance = -1;	/* 0: static, 1: balance */
 
 static int acpi_pci_link_allocate(struct acpi_pci_link *link)
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 29c6912..797ae2e 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -78,7 +78,6 @@
 
 /* ACPI PCI Interrupt Link (pci_link.c) */
 
-int acpi_irq_penalty_init(void);
 int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
 			       int *polarity, char **name);
 int acpi_pci_link_free_irq(acpi_handle handle);
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH V3 4/4] acpi,pci,irq: remove SCI penalize function
  2016-04-17 17:36 [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Sinan Kaya
  2016-04-17 17:36 ` [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16 Sinan Kaya
  2016-04-17 17:36 ` [PATCH V3 3/4] acpi,pci,irq: remove redundant code in acpi_irq_penalty_init Sinan Kaya
@ 2016-04-17 17:36 ` Sinan Kaya
  2016-04-26 18:36 ` [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Bjorn Helgaas
  3 siblings, 0 replies; 19+ messages in thread
From: Sinan Kaya @ 2016-04-17 17:36 UTC (permalink / raw)
  To: linux-acpi, timur, cov
  Cc: linux-pci, ravikanth.nalla, lenb, harish.k, ashwin.reghunandanan,
	bhelgaas, rjw, Sinan Kaya, Len Brown, Pavel Machek,
	Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-pm,
	linux-kernel

Removing the SCI penalize function as the penalty is now calculated on the
fly.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 arch/x86/kernel/acpi/boot.c | 1 -
 drivers/acpi/pci_link.c     | 4 ----
 include/linux/acpi.h        | 1 -
 3 files changed, 6 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 8c2f1ef..edf4840 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -445,7 +445,6 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,
 		polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
 
 	mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
-	acpi_penalize_sci_irq(bus_irq, trigger, polarity);
 
 	/*
 	 * stash over-ride to indicate we've been here
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index ab39208..8fc7323 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -848,10 +848,6 @@ bool acpi_isa_irq_available(int irq)
 		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
 }
 
-void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
-{
-}
-
 /*
  * Over-ride default table to reserve additional IRQs for use by ISA
  * e.g. acpi_irq_isa=5
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 06ed7e5..0f41317 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -311,7 +311,6 @@ struct pci_dev;
 int acpi_pci_irq_enable (struct pci_dev *dev);
 void acpi_penalize_isa_irq(int irq, int active);
 bool acpi_isa_irq_available(int irq);
-void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
 void acpi_pci_irq_disable (struct pci_dev *dev);
 
 extern int ec_read(u8 addr, u8 *val);
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-17 17:36 [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Sinan Kaya
                   ` (2 preceding siblings ...)
  2016-04-17 17:36 ` [PATCH V3 4/4] acpi,pci,irq: remove SCI penalize function Sinan Kaya
@ 2016-04-26 18:36 ` Bjorn Helgaas
  2016-04-26 19:00   ` Sinan Kaya
  2016-04-27  0:06   ` Bjorn Helgaas
  3 siblings, 2 replies; 19+ messages in thread
From: Bjorn Helgaas @ 2016-04-26 18:36 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: linux-acpi, timur, cov, linux-pci, ravikanth.nalla, lenb,
	harish.k, ashwin.reghunandanan, bhelgaas, rjw, linux-kernel

On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
> Code has been redesigned to calculate penalty requirements on the fly. This
> significantly simplifies the implementation and removes some of the init
> calls from x86 architecture.
> 
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>

For all four patches:

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/acpi/pci_link.c | 97 ++++++++++++++++++++++++++++++++++---------------
>  1 file changed, 68 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
> index ededa90..cc0ba16 100644
> --- a/drivers/acpi/pci_link.c
> +++ b/drivers/acpi/pci_link.c
> @@ -36,6 +36,7 @@
>  #include <linux/mutex.h>
>  #include <linux/slab.h>
>  #include <linux/acpi.h>
> +#include <linux/irq.h>
>  
>  #include "internal.h"
>  
> @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
>  #define ACPI_MAX_IRQS		256
>  #define ACPI_MAX_ISA_IRQ	16
>  
> -#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
>  #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
> @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
> +	0,				/* IRQ9  PCI, often acpi */
> +	0,				/* IRQ10 PCI */
> +	0,				/* IRQ11 PCI */
>  	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
>  	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
>  	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
> @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>  	/* >IRQ15 */
>  };
>  
> +static int acpi_irq_pci_sharing_penalty(int irq)
> +{
> +	struct acpi_pci_link *link;
> +	int penalty = 0;
> +
> +	list_for_each_entry(link, &acpi_link_list, list) {
> +		/*
> +		 * If a link is active, penalize its IRQ heavily
> +		 * so we try to choose a different IRQ.
> +		 */
> +		if (link->irq.active && link->irq.active == irq)
> +			penalty += PIRQ_PENALTY_PCI_USING;
> +		else {
> +			int i;
> +
> +			/*
> +			 * If a link is inactive, penalize the IRQs it
> +			 * might use, but not as severely.
> +			 */
> +			for (i = 0; i < link->irq.possible_count; i++)
> +				if (link->irq.possible[i] == irq)
> +					penalty += PIRQ_PENALTY_PCI_POSSIBLE /
> +						link->irq.possible_count;
> +		}
> +	}
> +
> +	return penalty;
> +}
> +
> +static int acpi_irq_get_penalty(int irq)
> +{
> +	int penalty = 0;
> +
> +	if (irq < ACPI_MAX_ISA_IRQ)
> +		penalty += acpi_irq_penalty[irq];
> +
> +	/*
> +	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
> +	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
> +	* use for PCI IRQs.
> +	*/
> +	if (irq == acpi_gbl_FADT.sci_interrupt) {
> +		u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
> +
> +		if (type != IRQ_TYPE_LEVEL_LOW)
> +			penalty += PIRQ_PENALTY_ISA_ALWAYS;
> +		else
> +			penalty += PIRQ_PENALTY_PCI_USING;
> +	}
> +
> +	penalty += acpi_irq_pci_sharing_penalty(irq);
> +	return penalty;
> +}
> +
>  int __init acpi_irq_penalty_init(void)
>  {
>  	struct acpi_pci_link *link;
> @@ -547,12 +601,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 +622,6 @@ 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;
>  		printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
>  		       acpi_device_name(link->device),
>  		       acpi_device_bid(link->device), link->irq.active);
> @@ -800,9 +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
>  			continue;
>  
>  		if (used)
> -			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
> +			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
> +				PIRQ_PENALTY_ISA_USED;
>  		else
> -			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
> +			acpi_irq_penalty[irq] = 0;
>  
>  		if (retval != 2)	/* no next number */
>  			break;
> @@ -819,34 +873,19 @@ 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;
> -	}
> +	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
> +		acpi_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) ||
> -			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
> +		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
>  }
>  
> -/*
> - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict with
> - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be use for
> - * PCI IRQs.
> - */
>  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;
> -	}
>  }
>  
>  /*
> -- 
> 1.8.2.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16
  2016-04-17 17:36 ` [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16 Sinan Kaya
@ 2016-04-26 18:38   ` Bjorn Helgaas
  0 siblings, 0 replies; 19+ messages in thread
From: Bjorn Helgaas @ 2016-04-26 18:38 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: linux-acpi, timur, cov, linux-pci, ravikanth.nalla, lenb,
	harish.k, ashwin.reghunandanan, bhelgaas, rjw, linux-kernel

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@codeaurora.org>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 3/4] acpi,pci,irq: remove redundant code in acpi_irq_penalty_init
  2016-04-17 17:36 ` [PATCH V3 3/4] acpi,pci,irq: remove redundant code in acpi_irq_penalty_init Sinan Kaya
@ 2016-04-26 18:39   ` Bjorn Helgaas
  0 siblings, 0 replies; 19+ messages in thread
From: Bjorn Helgaas @ 2016-04-26 18:39 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: linux-acpi, timur, cov, linux-pci, ravikanth.nalla, lenb,
	harish.k, ashwin.reghunandanan, bhelgaas, rjw, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86, Robert Moore, Lv Zheng,
	linux-kernel, devel

On Sun, Apr 17, 2016 at 01:36:55PM -0400, Sinan Kaya wrote:
> acpi_irq_get_penalty is now calculating the penalty on the fly now.
> No need to maintain global list of penalties or calculate them
> at the init time. Removing duplicate code in acpi_irq_penalty_init.
> 
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  arch/x86/pci/acpi.c         |  1 -
>  drivers/acpi/pci_link.c     | 36 ------------------------------------
>  include/acpi/acpi_drivers.h |  1 -
>  3 files changed, 38 deletions(-)
> 
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 3cd6983..b2a4e2a 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -396,7 +396,6 @@ int __init pci_acpi_init(void)
>  		return -ENODEV;
>  
>  	printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
> -	acpi_irq_penalty_init();

Yay!  Another x86-ism and init ordering issue gone!  Thanks for doing
this!

>  	pcibios_enable_irq = acpi_pci_irq_enable;
>  	pcibios_disable_irq = acpi_pci_irq_disable;
>  	x86_init.pci.init_irq = x86_init_noop;
> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
> index 12ea784..ab39208 100644
> --- a/drivers/acpi/pci_link.c
> +++ b/drivers/acpi/pci_link.c
> @@ -520,42 +520,6 @@ static int acpi_irq_get_penalty(int irq)
>  	return penalty;
>  }
>  
> -int __init acpi_irq_penalty_init(void)
> -{
> -	struct acpi_pci_link *link;
> -	int i;
> -
> -	/*
> -	 * Update penalties to facilitate IRQ balancing.
> -	 */
> -	list_for_each_entry(link, &acpi_link_list, list) {
> -
> -		/*
> -		 * reflect the possible and active irqs in the penalty table --
> -		 * useful for breaking ties.
> -		 */
> -		if (link->irq.possible_count) {
> -			int penalty =
> -			    PIRQ_PENALTY_PCI_POSSIBLE /
> -			    link->irq.possible_count;
> -
> -			for (i = 0; i < link->irq.possible_count; i++) {
> -				if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS)
> -					acpi_isa_irq_penalty[link->irq.
> -							 possible[i]] +=
> -					    penalty;
> -			}
> -
> -		} else if (link->irq.active &&
> -				(link->irq.active < ACPI_MAX_ISA_IRQS)) {
> -			acpi_isa_irq_penalty[link->irq.active] +=
> -			    PIRQ_PENALTY_PCI_POSSIBLE;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
>  static int acpi_irq_balance = -1;	/* 0: static, 1: balance */
>  
>  static int acpi_pci_link_allocate(struct acpi_pci_link *link)
> diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
> index 29c6912..797ae2e 100644
> --- a/include/acpi/acpi_drivers.h
> +++ b/include/acpi/acpi_drivers.h
> @@ -78,7 +78,6 @@
>  
>  /* ACPI PCI Interrupt Link (pci_link.c) */
>  
> -int acpi_irq_penalty_init(void);
>  int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
>  			       int *polarity, char **name);
>  int acpi_pci_link_free_irq(acpi_handle handle);
> -- 
> 1.8.2.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-26 18:36 ` [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Bjorn Helgaas
@ 2016-04-26 19:00   ` Sinan Kaya
  2016-04-26 20:33       ` Nalla, Ravikanth
  2016-05-02 17:44       ` Nalla, Ravikanth
  2016-04-27  0:06   ` Bjorn Helgaas
  1 sibling, 2 replies; 19+ messages in thread
From: Sinan Kaya @ 2016-04-26 19:00 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, ravikanth.nalla, lenb,
	harish.k, ashwin.reghunandanan, bhelgaas, rjw, linux-kernel

On 4/26/2016 2:36 PM, Bjorn Helgaas wrote:
> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
>> Code has been redesigned to calculate penalty requirements on the fly. This
>> significantly simplifies the implementation and removes some of the init
>> calls from x86 architecture.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> 
> For all four patches:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Thanks, can the HPE developers in CC test the series in order to avoid another revert? 

> 
>> ---
>>  drivers/acpi/pci_link.c | 97 ++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 68 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
>> index ededa90..cc0ba16 100644
>> --- a/drivers/acpi/pci_link.c
>> +++ b/drivers/acpi/pci_link.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/mutex.h>
>>  #include <linux/slab.h>
>>  #include <linux/acpi.h>
>> +#include <linux/irq.h>
>>  
>>  #include "internal.h"
>>  
>> @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
>>  #define ACPI_MAX_IRQS		256
>>  #define ACPI_MAX_ISA_IRQ	16
>>  
>> -#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
>>  #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
>> @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
>> +	0,				/* IRQ9  PCI, often acpi */
>> +	0,				/* IRQ10 PCI */
>> +	0,				/* IRQ11 PCI */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
>> @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	/* >IRQ15 */
>>  };
>>  
>> +static int acpi_irq_pci_sharing_penalty(int irq)
>> +{
>> +	struct acpi_pci_link *link;
>> +	int penalty = 0;
>> +
>> +	list_for_each_entry(link, &acpi_link_list, list) {
>> +		/*
>> +		 * If a link is active, penalize its IRQ heavily
>> +		 * so we try to choose a different IRQ.
>> +		 */
>> +		if (link->irq.active && link->irq.active == irq)
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +		else {
>> +			int i;
>> +
>> +			/*
>> +			 * If a link is inactive, penalize the IRQs it
>> +			 * might use, but not as severely.
>> +			 */
>> +			for (i = 0; i < link->irq.possible_count; i++)
>> +				if (link->irq.possible[i] == irq)
>> +					penalty += PIRQ_PENALTY_PCI_POSSIBLE /
>> +						link->irq.possible_count;
>> +		}
>> +	}
>> +
>> +	return penalty;
>> +}
>> +
>> +static int acpi_irq_get_penalty(int irq)
>> +{
>> +	int penalty = 0;
>> +
>> +	if (irq < ACPI_MAX_ISA_IRQ)
>> +		penalty += acpi_irq_penalty[irq];
>> +
>> +	/*
>> +	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
>> +	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
>> +	* use for PCI IRQs.
>> +	*/
>> +	if (irq == acpi_gbl_FADT.sci_interrupt) {
>> +		u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
>> +
>> +		if (type != IRQ_TYPE_LEVEL_LOW)
>> +			penalty += PIRQ_PENALTY_ISA_ALWAYS;
>> +		else
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +	}
>> +
>> +	penalty += acpi_irq_pci_sharing_penalty(irq);
>> +	return penalty;
>> +}
>> +
>>  int __init acpi_irq_penalty_init(void)
>>  {
>>  	struct acpi_pci_link *link;
>> @@ -547,12 +601,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 +622,6 @@ 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;
>>  		printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
>>  		       acpi_device_name(link->device),
>>  		       acpi_device_bid(link->device), link->irq.active);
>> @@ -800,9 +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
>>  			continue;
>>  
>>  		if (used)
>> -			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
>> +			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
>> +				PIRQ_PENALTY_ISA_USED;
>>  		else
>> -			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
>> +			acpi_irq_penalty[irq] = 0;
>>  
>>  		if (retval != 2)	/* no next number */
>>  			break;
>> @@ -819,34 +873,19 @@ 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;
>> -	}
>> +	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
>> +		acpi_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) ||
>> -			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
>> +		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
>>  }
>>  
>> -/*
>> - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict with
>> - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be use for
>> - * PCI IRQs.
>> - */
>>  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;
>> -	}
>>  }
>>  
>>  /*
>> -- 
>> 1.8.2.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-26 19:00   ` Sinan Kaya
@ 2016-04-26 20:33       ` Nalla, Ravikanth
  2016-05-02 17:44       ` Nalla, Ravikanth
  1 sibling, 0 replies; 19+ messages in thread
From: Nalla, Ravikanth @ 2016-04-26 20:33 UTC (permalink / raw)
  To: Sinan Kaya, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel


Hi Sinan Kaya,

Will  verify and comeback with the results soon.

Thanks,
Ravi

-----Original Message-----
From: Sinan Kaya [mailto:okaya@codeaurora.org] 
Sent: Wednesday, April 27, 2016 12:30 AM
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-acpi@vger.kernel.org; timur@codeaurora.org; cov@codeaurora.org; linux-pci@vger.kernel.org; Nalla, Ravikanth <ravikanth.nalla@hpe.com>; lenb@kernel.org; K, Harish (MCOU/UPEL) <harish.k@hpe.com>; Reghunandanan, Ashwin (STSD) <ashwin.reghunandanan@hpe.com>; bhelgaas@google.com; rjw@rjwysocki.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements

On 4/26/2016 2:36 PM, Bjorn Helgaas wrote:
> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
>> Code has been redesigned to calculate penalty requirements on the 
>> fly. This significantly simplifies the implementation and removes 
>> some of the init calls from x86 architecture.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> 
> For all four patches:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Thanks, can the HPE developers in CC test the series in order to avoid another revert? 

> 
>> ---
>>  drivers/acpi/pci_link.c | 97 
>> ++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 68 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 
>> ededa90..cc0ba16 100644
>> --- a/drivers/acpi/pci_link.c
>> +++ b/drivers/acpi/pci_link.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/mutex.h>
>>  #include <linux/slab.h>
>>  #include <linux/acpi.h>
>> +#include <linux/irq.h>
>>  
>>  #include "internal.h"
>>  
>> @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
>>  #define ACPI_MAX_IRQS		256
>>  #define ACPI_MAX_ISA_IRQ	16
>>  
>> -#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
>>  #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
>> @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
>> +	0,				/* IRQ9  PCI, often acpi */
>> +	0,				/* IRQ10 PCI */
>> +	0,				/* IRQ11 PCI */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
>> @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	/* >IRQ15 */
>>  };
>>  
>> +static int acpi_irq_pci_sharing_penalty(int irq) {
>> +	struct acpi_pci_link *link;
>> +	int penalty = 0;
>> +
>> +	list_for_each_entry(link, &acpi_link_list, list) {
>> +		/*
>> +		 * If a link is active, penalize its IRQ heavily
>> +		 * so we try to choose a different IRQ.
>> +		 */
>> +		if (link->irq.active && link->irq.active == irq)
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +		else {
>> +			int i;
>> +
>> +			/*
>> +			 * If a link is inactive, penalize the IRQs it
>> +			 * might use, but not as severely.
>> +			 */
>> +			for (i = 0; i < link->irq.possible_count; i++)
>> +				if (link->irq.possible[i] == irq)
>> +					penalty += PIRQ_PENALTY_PCI_POSSIBLE /
>> +						link->irq.possible_count;
>> +		}
>> +	}
>> +
>> +	return penalty;
>> +}
>> +
>> +static int acpi_irq_get_penalty(int irq) {
>> +	int penalty = 0;
>> +
>> +	if (irq < ACPI_MAX_ISA_IRQ)
>> +		penalty += acpi_irq_penalty[irq];
>> +
>> +	/*
>> +	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
>> +	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
>> +	* use for PCI IRQs.
>> +	*/
>> +	if (irq == acpi_gbl_FADT.sci_interrupt) {
>> +		u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
>> +
>> +		if (type != IRQ_TYPE_LEVEL_LOW)
>> +			penalty += PIRQ_PENALTY_ISA_ALWAYS;
>> +		else
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +	}
>> +
>> +	penalty += acpi_irq_pci_sharing_penalty(irq);
>> +	return penalty;
>> +}
>> +
>>  int __init acpi_irq_penalty_init(void)  {
>>  	struct acpi_pci_link *link;
>> @@ -547,12 +601,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 +622,6 @@ 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;
>>  		printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
>>  		       acpi_device_name(link->device),
>>  		       acpi_device_bid(link->device), link->irq.active); @@ -800,9 
>> +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
>>  			continue;
>>  
>>  		if (used)
>> -			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
>> +			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
>> +				PIRQ_PENALTY_ISA_USED;
>>  		else
>> -			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
>> +			acpi_irq_penalty[irq] = 0;
>>  
>>  		if (retval != 2)	/* no next number */
>>  			break;
>> @@ -819,34 +873,19 @@ 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;
>> -	}
>> +	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
>> +		acpi_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) ||
>> -			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
>> +		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
>>  }
>>  
>> -/*
>> - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes 
>> conflict with
>> - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be 
>> use for
>> - * PCI IRQs.
>> - */
>>  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;
>> -	}
>>  }
>>  
>>  /*
>> --
>> 1.8.2.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" 
>> in the body of a message to majordomo@vger.kernel.org More majordomo 
>> info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
@ 2016-04-26 20:33       ` Nalla, Ravikanth
  0 siblings, 0 replies; 19+ messages in thread
From: Nalla, Ravikanth @ 2016-04-26 20:33 UTC (permalink / raw)
  To: Sinan Kaya, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel


Hi Sinan Kaya,

Will  verify and comeback with the results soon.

Thanks,
Ravi

-----Original Message-----
From: Sinan Kaya [mailto:okaya@codeaurora.org] 
Sent: Wednesday, April 27, 2016 12:30 AM
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-acpi@vger.kernel.org; timur@codeaurora.org; cov@codeaurora.org; linux-pci@vger.kernel.org; Nalla, Ravikanth <ravikanth.nalla@hpe.com>; lenb@kernel.org; K, Harish (MCOU/UPEL) <harish.k@hpe.com>; Reghunandanan, Ashwin (STSD) <ashwin.reghunandanan@hpe.com>; bhelgaas@google.com; rjw@rjwysocki.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements

On 4/26/2016 2:36 PM, Bjorn Helgaas wrote:
> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
>> Code has been redesigned to calculate penalty requirements on the 
>> fly. This significantly simplifies the implementation and removes 
>> some of the init calls from x86 architecture.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> 
> For all four patches:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Thanks, can the HPE developers in CC test the series in order to avoid another revert? 

> 
>> ---
>>  drivers/acpi/pci_link.c | 97 
>> ++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 68 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 
>> ededa90..cc0ba16 100644
>> --- a/drivers/acpi/pci_link.c
>> +++ b/drivers/acpi/pci_link.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/mutex.h>
>>  #include <linux/slab.h>
>>  #include <linux/acpi.h>
>> +#include <linux/irq.h>
>>  
>>  #include "internal.h"
>>  
>> @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
>>  #define ACPI_MAX_IRQS		256
>>  #define ACPI_MAX_ISA_IRQ	16
>>  
>> -#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
>>  #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
>> @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
>> +	0,				/* IRQ9  PCI, often acpi */
>> +	0,				/* IRQ10 PCI */
>> +	0,				/* IRQ11 PCI */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
>> @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	/* >IRQ15 */
>>  };
>>  
>> +static int acpi_irq_pci_sharing_penalty(int irq) {
>> +	struct acpi_pci_link *link;
>> +	int penalty = 0;
>> +
>> +	list_for_each_entry(link, &acpi_link_list, list) {
>> +		/*
>> +		 * If a link is active, penalize its IRQ heavily
>> +		 * so we try to choose a different IRQ.
>> +		 */
>> +		if (link->irq.active && link->irq.active == irq)
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +		else {
>> +			int i;
>> +
>> +			/*
>> +			 * If a link is inactive, penalize the IRQs it
>> +			 * might use, but not as severely.
>> +			 */
>> +			for (i = 0; i < link->irq.possible_count; i++)
>> +				if (link->irq.possible[i] == irq)
>> +					penalty += PIRQ_PENALTY_PCI_POSSIBLE /
>> +						link->irq.possible_count;
>> +		}
>> +	}
>> +
>> +	return penalty;
>> +}
>> +
>> +static int acpi_irq_get_penalty(int irq) {
>> +	int penalty = 0;
>> +
>> +	if (irq < ACPI_MAX_ISA_IRQ)
>> +		penalty += acpi_irq_penalty[irq];
>> +
>> +	/*
>> +	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
>> +	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
>> +	* use for PCI IRQs.
>> +	*/
>> +	if (irq == acpi_gbl_FADT.sci_interrupt) {
>> +		u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
>> +
>> +		if (type != IRQ_TYPE_LEVEL_LOW)
>> +			penalty += PIRQ_PENALTY_ISA_ALWAYS;
>> +		else
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +	}
>> +
>> +	penalty += acpi_irq_pci_sharing_penalty(irq);
>> +	return penalty;
>> +}
>> +
>>  int __init acpi_irq_penalty_init(void)  {
>>  	struct acpi_pci_link *link;
>> @@ -547,12 +601,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 +622,6 @@ 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;
>>  		printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
>>  		       acpi_device_name(link->device),
>>  		       acpi_device_bid(link->device), link->irq.active); @@ -800,9 
>> +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
>>  			continue;
>>  
>>  		if (used)
>> -			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
>> +			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
>> +				PIRQ_PENALTY_ISA_USED;
>>  		else
>> -			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
>> +			acpi_irq_penalty[irq] = 0;
>>  
>>  		if (retval != 2)	/* no next number */
>>  			break;
>> @@ -819,34 +873,19 @@ 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;
>> -	}
>> +	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
>> +		acpi_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) ||
>> -			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
>> +		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
>>  }
>>  
>> -/*
>> - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes 
>> conflict with
>> - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be 
>> use for
>> - * PCI IRQs.
>> - */
>>  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;
>> -	}
>>  }
>>  
>>  /*
>> --
>> 1.8.2.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" 
>> in the body of a message to majordomo@vger.kernel.org More majordomo 
>> info at  http://vger.kernel.org/majordomo-info.html


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-26 18:36 ` [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Bjorn Helgaas
  2016-04-26 19:00   ` Sinan Kaya
@ 2016-04-27  0:06   ` Bjorn Helgaas
  2016-04-27  0:17     ` Rafael J. Wysocki
  1 sibling, 1 reply; 19+ messages in thread
From: Bjorn Helgaas @ 2016-04-27  0:06 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: linux-acpi, timur, cov, linux-pci, ravikanth.nalla, lenb,
	harish.k, ashwin.reghunandanan, bhelgaas, rjw, linux-kernel

On Tue, Apr 26, 2016 at 01:36:11PM -0500, Bjorn Helgaas wrote:
> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
> > Code has been redesigned to calculate penalty requirements on the fly. This
> > significantly simplifies the implementation and removes some of the init
> > calls from x86 architecture.
> > 
> > Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> 
> For all four patches:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Rafael, I should have mentioned that I'm assuming you'll take these
because they're in drivers/acpi and you merged the previous ones,
e.g.,

  0971686954f9 ACPI / PCI: Simplify acpi_penalize_isa_irq()
  37c5939136d7 ACPI, PCI, irq: remove interrupt number restriction
  b5bd02695471 ACPI, PCI, irq: remove interrupt count restriction

Just let me know if you'd rather have me take them.

Bjorn

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-27  0:06   ` Bjorn Helgaas
@ 2016-04-27  0:17     ` Rafael J. Wysocki
  2016-05-05 23:40       ` Rafael J. Wysocki
  0 siblings, 1 reply; 19+ messages in thread
From: Rafael J. Wysocki @ 2016-04-27  0:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Sinan Kaya, ACPI Devel Maling List, Timur Tabi,
	Christopher Covington, Linux PCI, ravikanth.nalla, Len Brown,
	harish.k, ashwin.reghunandanan, Bjorn Helgaas, Rafael J. Wysocki,
	Linux Kernel Mailing List

On Wed, Apr 27, 2016 at 2:06 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Tue, Apr 26, 2016 at 01:36:11PM -0500, Bjorn Helgaas wrote:
>> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
>> > Code has been redesigned to calculate penalty requirements on the fly. This
>> > significantly simplifies the implementation and removes some of the init
>> > calls from x86 architecture.
>> >
>> > Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
>>
>> For all four patches:
>>
>> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>
> Rafael, I should have mentioned that I'm assuming you'll take these
> because they're in drivers/acpi and you merged the previous ones,
> e.g.,
>
>   0971686954f9 ACPI / PCI: Simplify acpi_penalize_isa_irq()
>   37c5939136d7 ACPI, PCI, irq: remove interrupt number restriction
>   b5bd02695471 ACPI, PCI, irq: remove interrupt count restriction
>
> Just let me know if you'd rather have me take them.

I can handle them.

I'll wait for the testing feedback from the HPE people though in case
there are any problems.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-26 19:00   ` Sinan Kaya
@ 2016-05-02 17:44       ` Nalla, Ravikanth
  2016-05-02 17:44       ` Nalla, Ravikanth
  1 sibling, 0 replies; 19+ messages in thread
From: Nalla, Ravikanth @ 2016-05-02 17:44 UTC (permalink / raw)
  To: Sinan Kaya, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel


-----Original Message-----
From: Sinan Kaya [mailto:okaya@codeaurora.org] 
Sent: Wednesday, April 27, 2016 12:30 AM
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-acpi@vger.kernel.org; timur@codeaurora.org; cov@codeaurora.org; linux-pci@vger.kernel.org; Nalla, Ravikanth <ravikanth.nalla@hpe.com>; lenb@kernel.org; K, Harish (MCOU/UPEL) <harish.k@hpe.com>; Reghunandanan, Ashwin (STSD) <ashwin.reghunandanan@hpe.com>; bhelgaas@google.com; rjw@rjwysocki.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements

On 4/26/2016 2:36 PM, Bjorn Helgaas wrote:
> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
>> Code has been redesigned to calculate penalty requirements on the 
>> fly. This significantly simplifies the implementation and removes 
>> some of the init calls from x86 architecture.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> 
> For all four patches:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> Thanks, can the HPE developers in CC test the series in order to avoid another revert? 

 I'm facing below errors while applying these patches on mainline kernel for verification. Please check and let me know what is the issue or if I'm 
 missing  anything. I use outlook for mail and I copied your mail formatted patches into each individual file manually and converted these files into
 unix format (using dos2unix cmd)  and when trying to apply with cmd "patch -p1  patch1.patch" /  "git apply patch1.patch" i see
 below errors. I'm getting similar errors for remaining  patches too and also "checkpatch.pl" looks to be throwing errors. Hence I'm not able to 
 verify your changes.

 linux]# dos2unix patch1.patch
 dos2unix: converting file patch1.patch to Unix format ...
 linux]# patch -p1 < patch1.patch
 patching file drivers/acpi/pci_link.c
 patch: **** malformed patch at line 99: @@ -547,12 +601,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
 linux]# git apply patch1.patch
 fatal: corrupt patch at line 99

 "checkpatch.pl" errors:
-----------------------------
 linux]# ./scripts/checkpatch.pl patch1.patch
 ERROR: open brace '{' following function declarations go on the next line
 #44: FILE: drivers/acpi/pci_link.c:470:
 +static int acpi_irq_pci_sharing_penalty(int irq) {

 ERROR: open brace '{' following function declarations go on the next line
 #72: FILE: drivers/acpi/pci_link.c:498:
+static int acpi_irq_get_penalty(int irq) {

ERROR: patch seems to be corrupt (line wrapped?)
#173: FILE: drivers/acpi/pci_link.c:889:
1.8.2.1

total: 3 errors, 0 warnings, 144 lines checked

patch1.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
> 
>> ---
>>  drivers/acpi/pci_link.c | 97 
>> ++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 68 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 
>> ededa90..cc0ba16 100644
>> --- a/drivers/acpi/pci_link.c
>> +++ b/drivers/acpi/pci_link.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/mutex.h>
>>  #include <linux/slab.h>
>>  #include <linux/acpi.h>
>> +#include <linux/irq.h>
>>  
>>  #include "internal.h"
>>  
>> @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
>>  #define ACPI_MAX_IRQS		256
>>  #define ACPI_MAX_ISA_IRQ	16
>>  
>> -#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
>>  #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
>> @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
>> +	0,				/* IRQ9  PCI, often acpi */
>> +	0,				/* IRQ10 PCI */
>> +	0,				/* IRQ11 PCI */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
>> @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
>>  	/* >IRQ15 */
>>  };
>>  
>> +static int acpi_irq_pci_sharing_penalty(int irq) {
>> +	struct acpi_pci_link *link;
>> +	int penalty = 0;
>> +
>> +	list_for_each_entry(link, &acpi_link_list, list) {
>> +		/*
>> +		 * If a link is active, penalize its IRQ heavily
>> +		 * so we try to choose a different IRQ.
>> +		 */
>> +		if (link->irq.active && link->irq.active == irq)
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +		else {
>> +			int i;
>> +
>> +			/*
>> +			 * If a link is inactive, penalize the IRQs it
>> +			 * might use, but not as severely.
>> +			 */
>> +			for (i = 0; i < link->irq.possible_count; i++)
>> +				if (link->irq.possible[i] == irq)
>> +					penalty += PIRQ_PENALTY_PCI_POSSIBLE /
>> +						link->irq.possible_count;
>> +		}
>> +	}
>> +
>> +	return penalty;
>> +}
>> +
>> +static int acpi_irq_get_penalty(int irq) {
>> +	int penalty = 0;
>> +
>> +	if (irq < ACPI_MAX_ISA_IRQ)
>> +		penalty += acpi_irq_penalty[irq];
>> +
>> +	/*
>> +	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
>> +	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
>> +	* use for PCI IRQs.
>> +	*/
>> +	if (irq == acpi_gbl_FADT.sci_interrupt) {
>> +		u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
>> +
>> +		if (type != IRQ_TYPE_LEVEL_LOW)
>> +			penalty += PIRQ_PENALTY_ISA_ALWAYS;
>> +		else
>> +			penalty += PIRQ_PENALTY_PCI_USING;
>> +	}
>> +
>> +	penalty += acpi_irq_pci_sharing_penalty(irq);
>> +	return penalty;
>> +}
>> +
>>  int __init acpi_irq_penalty_init(void)  {
>>  	struct acpi_pci_link *link;
>> @@ -547,12 +601,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 +622,6 @@ 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;
>>  		printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
>>  		       acpi_device_name(link->device),
>>  		       acpi_device_bid(link->device), link->irq.active); @@ -800,9 
>> +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used)
>>  			continue;
>>  
>>  		if (used)
>> -			acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
>> +			acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
>> +				PIRQ_PENALTY_ISA_USED;
>>  		else
>> -			acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
>> +			acpi_irq_penalty[irq] = 0;
>>  
>>  		if (retval != 2)	/* no next number */
>>  			break;
>> @@ -819,34 +873,19 @@ 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;
>> -	}
>> +	if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
>> +		acpi_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) ||
>> -			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
>> +		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
>>  }
>>  
>> -/*
>> - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes 
>> conflict with
>> - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be 
>> use for
>> - * PCI IRQs.
>> - */
>>  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;
>> -	}
>>  }
>>  
>>  /*
>> --
>> 1.8.2.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci" 
>> in the body of a message to majordomo@vger.kernel.org More majordomo 
>> info at  http://vger.kernel.org/majordomo-info.html


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
@ 2016-05-02 17:44       ` Nalla, Ravikanth
  0 siblings, 0 replies; 19+ messages in thread
From: Nalla, Ravikanth @ 2016-05-02 17:44 UTC (permalink / raw)
  To: Sinan Kaya, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel


-----Original Message-----
From: Sinan Kaya [mailto:okaya@codeaurora.org]=20
Sent: Wednesday, April 27, 2016 12:30 AM
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-acpi@vger.kernel.org; timur@codeaurora.org; cov@codeaurora.org; l=
inux-pci@vger.kernel.org; Nalla, Ravikanth <ravikanth.nalla@hpe.com>; lenb@=
kernel.org; K, Harish (MCOU/UPEL) <harish.k@hpe.com>; Reghunandanan, Ashwin=
 (STSD) <ashwin.reghunandanan@hpe.com>; bhelgaas@google.com; rjw@rjwysocki.=
net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements

On 4/26/2016 2:36 PM, Bjorn Helgaas wrote:
> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
>> Code has been redesigned to calculate penalty requirements on the=20
>> fly. This significantly simplifies the implementation and removes=20
>> some of the init calls from x86 architecture.
>>
>> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
>=20
> For all four patches:
>=20
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> Thanks, can the HPE developers in CC test the series in order to avoid an=
other revert?=20

 I'm facing below errors while applying these patches on mainline kernel fo=
r verification. Please check and let me know what is the issue or if I'm=20
 missing  anything. I use outlook for mail and I copied your mail formatted=
 patches into each individual file manually and converted these files into
 unix format (using dos2unix cmd)  and when trying to apply with cmd "patch=
 -p1  patch1.patch" /  "git apply patch1.patch" i see
 below errors. I'm getting similar errors for remaining  patches too and al=
so "checkpatch.pl" looks to be throwing errors. Hence I'm not able to=20
 verify your changes.

 linux]# dos2unix patch1.patch
 dos2unix: converting file patch1.patch to Unix format ...
 linux]# patch -p1 < patch1.patch
 patching file drivers/acpi/pci_link.c
 patch: **** malformed patch at line 99: @@ -547,12 +601,12 @@ static int a=
cpi_pci_link_allocate(struct acpi_pci_link *link)
 linux]# git apply patch1.patch
 fatal: corrupt patch at line 99

 "checkpatch.pl" errors:
-----------------------------
 linux]# ./scripts/checkpatch.pl patch1.patch
 ERROR: open brace '{' following function declarations go on the next line
 #44: FILE: drivers/acpi/pci_link.c:470:
 +static int acpi_irq_pci_sharing_penalty(int irq) {

 ERROR: open brace '{' following function declarations go on the next line
 #72: FILE: drivers/acpi/pci_link.c:498:
+static int acpi_irq_get_penalty(int irq) {

ERROR: patch seems to be corrupt (line wrapped?)
#173: FILE: drivers/acpi/pci_link.c:889:
1.8.2.1

total: 3 errors, 0 warnings, 144 lines checked

patch1.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
>=20
>> ---
>>  drivers/acpi/pci_link.c | 97=20
>> ++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 68 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index=20
>> ededa90..cc0ba16 100644
>> --- a/drivers/acpi/pci_link.c
>> +++ b/drivers/acpi/pci_link.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/mutex.h>
>>  #include <linux/slab.h>
>>  #include <linux/acpi.h>
>> +#include <linux/irq.h>
>> =20
>>  #include "internal.h"
>> =20
>> @@ -440,7 +441,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *l=
ink, int irq)
>>  #define ACPI_MAX_IRQS		256
>>  #define ACPI_MAX_ISA_IRQ	16
>> =20
>> -#define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
>>  #define PIRQ_PENALTY_ISA_TYPICAL	(16*16*16*16)
>> @@ -457,9 +457,9 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] =3D {
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ6 */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ7 parallel, spurious */
>>  	PIRQ_PENALTY_ISA_TYPICAL,	/* IRQ8 rtc, sometimes */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ9  PCI, often acpi */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ10 PCI */
>> -	PIRQ_PENALTY_PCI_AVAILABLE,	/* IRQ11 PCI */
>> +	0,				/* IRQ9  PCI, often acpi */
>> +	0,				/* IRQ10 PCI */
>> +	0,				/* IRQ11 PCI */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ12 mouse */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ13 fpe, sometimes */
>>  	PIRQ_PENALTY_ISA_USED,		/* IRQ14 ide0 */
>> @@ -467,6 +467,60 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] =3D {
>>  	/* >IRQ15 */
>>  };
>> =20
>> +static int acpi_irq_pci_sharing_penalty(int irq) {
>> +	struct acpi_pci_link *link;
>> +	int penalty =3D 0;
>> +
>> +	list_for_each_entry(link, &acpi_link_list, list) {
>> +		/*
>> +		 * If a link is active, penalize its IRQ heavily
>> +		 * so we try to choose a different IRQ.
>> +		 */
>> +		if (link->irq.active && link->irq.active =3D=3D irq)
>> +			penalty +=3D PIRQ_PENALTY_PCI_USING;
>> +		else {
>> +			int i;
>> +
>> +			/*
>> +			 * If a link is inactive, penalize the IRQs it
>> +			 * might use, but not as severely.
>> +			 */
>> +			for (i =3D 0; i < link->irq.possible_count; i++)
>> +				if (link->irq.possible[i] =3D=3D irq)
>> +					penalty +=3D PIRQ_PENALTY_PCI_POSSIBLE /
>> +						link->irq.possible_count;
>> +		}
>> +	}
>> +
>> +	return penalty;
>> +}
>> +
>> +static int acpi_irq_get_penalty(int irq) {
>> +	int penalty =3D 0;
>> +
>> +	if (irq < ACPI_MAX_ISA_IRQ)
>> +		penalty +=3D acpi_irq_penalty[irq];
>> +
>> +	/*
>> +	* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
>> +	* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
>> +	* use for PCI IRQs.
>> +	*/
>> +	if (irq =3D=3D acpi_gbl_FADT.sci_interrupt) {
>> +		u32 type =3D irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
>> +
>> +		if (type !=3D IRQ_TYPE_LEVEL_LOW)
>> +			penalty +=3D PIRQ_PENALTY_ISA_ALWAYS;
>> +		else
>> +			penalty +=3D PIRQ_PENALTY_PCI_USING;
>> +	}
>> +
>> +	penalty +=3D acpi_irq_pci_sharing_penalty(irq);
>> +	return penalty;
>> +}
>> +
>>  int __init acpi_irq_penalty_init(void)  {
>>  	struct acpi_pci_link *link;
>> @@ -547,12 +601,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_=
link *link)
>>  		 * the use of IRQs 9, 10, 11, and >15.
>>  		 */
>>  		for (i =3D (link->irq.possible_count - 1); i >=3D 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 =3D link->irq.possible[i];
>>  		}
>>  	}
>> -	if (acpi_irq_penalty[irq] >=3D PIRQ_PENALTY_ISA_ALWAYS) {
>> +	if (acpi_irq_get_penalty(irq) >=3D PIRQ_PENALTY_ISA_ALWAYS) {
>>  		printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. "
>>  			    "Try pci=3Dnoacpi or acpi=3Doff\n",
>>  			    acpi_device_name(link->device), @@ -568,7 +622,6 @@ static=20
>> int acpi_pci_link_allocate(struct acpi_pci_link *link)
>>  			    acpi_device_bid(link->device));
>>  		return -ENODEV;
>>  	} else {
>> -		acpi_irq_penalty[link->irq.active] +=3D 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); @@ -800,9=20
>> +853,10 @@ static int __init acpi_irq_penalty_update(char *str, int used=
)
>>  			continue;
>> =20
>>  		if (used)
>> -			acpi_irq_penalty[irq] +=3D PIRQ_PENALTY_ISA_USED;
>> +			acpi_irq_penalty[irq] =3D acpi_irq_get_penalty(irq) +
>> +				PIRQ_PENALTY_ISA_USED;
>>  		else
>> -			acpi_irq_penalty[irq] =3D PIRQ_PENALTY_PCI_AVAILABLE;
>> +			acpi_irq_penalty[irq] =3D 0;
>> =20
>>  		if (retval !=3D 2)	/* no next number */
>>  			break;
>> @@ -819,34 +873,19 @@ static int __init acpi_irq_penalty_update(char *st=
r, int used)
>>   */
>>  void acpi_penalize_isa_irq(int irq, int active)  {
>> -	if (irq >=3D 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
>> -		if (active)
>> -			acpi_irq_penalty[irq] +=3D PIRQ_PENALTY_ISA_USED;
>> -		else
>> -			acpi_irq_penalty[irq] +=3D PIRQ_PENALTY_PCI_USING;
>> -	}
>> +	if (irq >=3D 0 && irq < ARRAY_SIZE(acpi_irq_penalty))
>> +		acpi_irq_penalty[irq] =3D acpi_irq_get_penalty(irq) +
>> +			active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING;
>>  }
>> =20
>>  bool acpi_isa_irq_available(int irq)  {
>>  	return irq >=3D 0 && (irq >=3D ARRAY_SIZE(acpi_irq_penalty) ||
>> -			    acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
>> +		    acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
>>  }
>> =20
>> -/*
>> - * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes=20
>> conflict with
>> - * PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be=20
>> use for
>> - * PCI IRQs.
>> - */
>>  void acpi_penalize_sci_irq(int irq, int trigger, int polarity)  {
>> -	if (irq >=3D 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
>> -		if (trigger !=3D ACPI_MADT_TRIGGER_LEVEL ||
>> -		    polarity !=3D ACPI_MADT_POLARITY_ACTIVE_LOW)
>> -			acpi_irq_penalty[irq] +=3D PIRQ_PENALTY_ISA_ALWAYS;
>> -		else
>> -			acpi_irq_penalty[irq] +=3D PIRQ_PENALTY_PCI_USING;
>> -	}
>>  }
>> =20
>>  /*
>> --
>> 1.8.2.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pci"=20
>> in the body of a message to majordomo@vger.kernel.org More majordomo=20
>> info at  http://vger.kernel.org/majordomo-info.html


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-05-02 17:44       ` Nalla, Ravikanth
  (?)
@ 2016-05-02 17:58       ` Sinan Kaya
  2016-05-03 16:17           ` Nalla, Ravikanth
  -1 siblings, 1 reply; 19+ messages in thread
From: Sinan Kaya @ 2016-05-02 17:58 UTC (permalink / raw)
  To: Nalla, Ravikanth, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel

On 5/2/2016 1:44 PM, Nalla, Ravikanth wrote:
>> Thanks, can the HPE developers in CC test the series in order to avoid another revert? 
>  I'm facing below errors while applying these patches on mainline kernel for verification. Please check and let me know what is the issue or if I'm 
>  missing  anything. I use outlook for mail and I copied your mail formatted patches into each individual file manually and converted these files into
>  unix format (using dos2unix cmd)  and when trying to apply with cmd "patch -p1  patch1.patch" /  "git apply patch1.patch" i see
>  below errors. I'm getting similar errors for remaining  patches too and also "checkpatch.pl" looks to be throwing errors. Hence I'm not able to 
>  verify your changes.

This should get you the patch files.

https://patchwork.ozlabs.org/patch/611493/raw/
https://patchwork.ozlabs.org/patch/611496/raw/
https://patchwork.ozlabs.org/patch/611495/raw/
https://patchwork.ozlabs.org/patch/611494/raw/

You can download the mailbox files here and do "git am" instead

https://patchwork.ozlabs.org/patch/611493/mbox/
https://patchwork.ozlabs.org/patch/611496/mbox/
https://patchwork.ozlabs.org/patch/611495/mbox/
https://patchwork.ozlabs.org/patch/611494/mbox/

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-05-02 17:58       ` Sinan Kaya
@ 2016-05-03 16:17           ` Nalla, Ravikanth
  0 siblings, 0 replies; 19+ messages in thread
From: Nalla, Ravikanth @ 2016-05-03 16:17 UTC (permalink / raw)
  To: Sinan Kaya, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel


-----Original Message-----
From: Sinan Kaya [mailto:okaya@codeaurora.org] 
Sent: Monday, May 02, 2016 11:29 PM
To: Nalla, Ravikanth <ravikanth.nalla@hpe.com>; Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-acpi@vger.kernel.org; timur@codeaurora.org; cov@codeaurora.org; linux-pci@vger.kernel.org; lenb@kernel.org; K, Harish (MCOU/UPEL) <harish.k@hpe.com>; Reghunandanan, Ashwin (STSD) <ashwin.reghunandanan@hpe.com>; bhelgaas@google.com; rjw@rjwysocki.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements

On 5/2/2016 1:44 PM, Nalla, Ravikanth wrote:
>> Thanks, can the HPE developers in CC test the series in order to avoid another revert? 
>  I'm facing below errors while applying these patches on mainline 
> kernel for verification. Please check and let me know what is the 
> issue or if I'm  missing  anything. I use outlook for mail and I 
> copied your mail formatted patches into each individual file manually 
> and converted these files into  unix format (using dos2unix cmd)  and when trying to apply with cmd "patch -p1  patch1.patch" /  "git apply patch1.patch" i see  below errors. I'm getting similar errors for remaining  patches too and also "checkpatch.pl" looks to be throwing errors. Hence I'm not able to  verify your changes.

>This should get you the patch files.

>https://patchwork.ozlabs.org/patch/611493/raw/
>https://patchwork.ozlabs.org/patch/611496/raw/
>https://patchwork.ozlabs.org/patch/611495/raw/
>https://patchwork.ozlabs.org/patch/611494/raw/

>You can download the mailbox files here and do "git am" instead

>https://patchwork.ozlabs.org/patch/611493/mbox/
>https://patchwork.ozlabs.org/patch/611496/mbox/
>https://patchwork.ozlabs.org/patch/611495/mbox/
>https://patchwork.ozlabs.org/patch/611494/mbox/

The above mbox patches worked with "git apply".  We have now verified the fix after applying these 4 patches on a 60 CPU system 
with mainline kernel (4.6-rc6) and we don't see any panic or issues during boot (multiple). We will try verifying on a high end system 
and we will let you know the results.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
@ 2016-05-03 16:17           ` Nalla, Ravikanth
  0 siblings, 0 replies; 19+ messages in thread
From: Nalla, Ravikanth @ 2016-05-03 16:17 UTC (permalink / raw)
  To: Sinan Kaya, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel


-----Original Message-----
From: Sinan Kaya [mailto:okaya@codeaurora.org]=20
Sent: Monday, May 02, 2016 11:29 PM
To: Nalla, Ravikanth <ravikanth.nalla@hpe.com>; Bjorn Helgaas <helgaas@kern=
el.org>
Cc: linux-acpi@vger.kernel.org; timur@codeaurora.org; cov@codeaurora.org; l=
inux-pci@vger.kernel.org; lenb@kernel.org; K, Harish (MCOU/UPEL) <harish.k@=
hpe.com>; Reghunandanan, Ashwin (STSD) <ashwin.reghunandanan@hpe.com>; bhel=
gaas@google.com; rjw@rjwysocki.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements

On 5/2/2016 1:44 PM, Nalla, Ravikanth wrote:
>> Thanks, can the HPE developers in CC test the series in order to avoid a=
nother revert?=20
>  I'm facing below errors while applying these patches on mainline=20
> kernel for verification. Please check and let me know what is the=20
> issue or if I'm  missing  anything. I use outlook for mail and I=20
> copied your mail formatted patches into each individual file manually=20
> and converted these files into  unix format (using dos2unix cmd)  and whe=
n trying to apply with cmd "patch -p1  patch1.patch" /  "git apply patch1.p=
atch" i see  below errors. I'm getting similar errors for remaining  patche=
s too and also "checkpatch.pl" looks to be throwing errors. Hence I'm not a=
ble to  verify your changes.

>This should get you the patch files.

>https://patchwork.ozlabs.org/patch/611493/raw/
>https://patchwork.ozlabs.org/patch/611496/raw/
>https://patchwork.ozlabs.org/patch/611495/raw/
>https://patchwork.ozlabs.org/patch/611494/raw/

>You can download the mailbox files here and do "git am" instead

>https://patchwork.ozlabs.org/patch/611493/mbox/
>https://patchwork.ozlabs.org/patch/611496/mbox/
>https://patchwork.ozlabs.org/patch/611495/mbox/
>https://patchwork.ozlabs.org/patch/611494/mbox/

The above mbox patches worked with "git apply".  We have now verified the f=
ix after applying these 4 patches on a 60 CPU system=20
with mainline kernel (4.6-rc6) and we don't see any panic or issues during =
boot (multiple). We will try verifying on a high end system=20
and we will let you know the results.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-05-03 16:17           ` Nalla, Ravikanth
  (?)
@ 2016-05-03 17:16           ` Sinan Kaya
  -1 siblings, 0 replies; 19+ messages in thread
From: Sinan Kaya @ 2016-05-03 17:16 UTC (permalink / raw)
  To: Nalla, Ravikanth, Bjorn Helgaas
  Cc: linux-acpi, timur, cov, linux-pci, lenb, K, Harish (MCOU/UPEL),
	Reghunandanan, Ashwin (STSD),
	bhelgaas, rjw, linux-kernel

On 5/3/2016 12:17 PM, Nalla, Ravikanth wrote:
>> >https://patchwork.ozlabs.org/patch/611493/mbox/
>> >https://patchwork.ozlabs.org/patch/611496/mbox/
>> >https://patchwork.ozlabs.org/patch/611495/mbox/
>> >https://patchwork.ozlabs.org/patch/611494/mbox/
> The above mbox patches worked with "git apply".  We have now verified the fix after applying these 4 patches on a 60 CPU system 
> with mainline kernel (4.6-rc6) and we don't see any panic or issues during boot (multiple). We will try verifying on a high end system 
> and we will let you know the results.

Thanks, let us know how it goes.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements
  2016-04-27  0:17     ` Rafael J. Wysocki
@ 2016-05-05 23:40       ` Rafael J. Wysocki
  0 siblings, 0 replies; 19+ messages in thread
From: Rafael J. Wysocki @ 2016-05-05 23:40 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: Rafael J. Wysocki, Bjorn Helgaas, ACPI Devel Maling List,
	Timur Tabi, Christopher Covington, Linux PCI, ravikanth.nalla,
	Len Brown, harish.k, ashwin.reghunandanan, Bjorn Helgaas,
	Linux Kernel Mailing List

On Wednesday, April 27, 2016 02:17:58 AM Rafael J. Wysocki wrote:
> On Wed, Apr 27, 2016 at 2:06 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Tue, Apr 26, 2016 at 01:36:11PM -0500, Bjorn Helgaas wrote:
> >> On Sun, Apr 17, 2016 at 01:36:53PM -0400, Sinan Kaya wrote:
> >> > Code has been redesigned to calculate penalty requirements on the fly. This
> >> > significantly simplifies the implementation and removes some of the init
> >> > calls from x86 architecture.
> >> >
> >> > Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> >>
> >> For all four patches:
> >>
> >> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> >
> > Rafael, I should have mentioned that I'm assuming you'll take these
> > because they're in drivers/acpi and you merged the previous ones,
> > e.g.,
> >
> >   0971686954f9 ACPI / PCI: Simplify acpi_penalize_isa_irq()
> >   37c5939136d7 ACPI, PCI, irq: remove interrupt number restriction
> >   b5bd02695471 ACPI, PCI, irq: remove interrupt count restriction
> >
> > Just let me know if you'd rather have me take them.
> 
> I can handle them.
> 
> I'll wait for the testing feedback from the HPE people though in case
> there are any problems.

All [1-4/4] applied with Bjorn's ACKs.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-05-05 23:40 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-17 17:36 [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Sinan Kaya
2016-04-17 17:36 ` [PATCH V3 2/4] acpi,pci,irq: reduce static IRQ array size to 16 Sinan Kaya
2016-04-26 18:38   ` Bjorn Helgaas
2016-04-17 17:36 ` [PATCH V3 3/4] acpi,pci,irq: remove redundant code in acpi_irq_penalty_init Sinan Kaya
2016-04-26 18:39   ` Bjorn Helgaas
2016-04-17 17:36 ` [PATCH V3 4/4] acpi,pci,irq: remove SCI penalize function Sinan Kaya
2016-04-26 18:36 ` [PATCH V3 1/4] acpi,pci,irq: reduce resource requirements Bjorn Helgaas
2016-04-26 19:00   ` Sinan Kaya
2016-04-26 20:33     ` Nalla, Ravikanth
2016-04-26 20:33       ` Nalla, Ravikanth
2016-05-02 17:44     ` Nalla, Ravikanth
2016-05-02 17:44       ` Nalla, Ravikanth
2016-05-02 17:58       ` Sinan Kaya
2016-05-03 16:17         ` Nalla, Ravikanth
2016-05-03 16:17           ` Nalla, Ravikanth
2016-05-03 17:16           ` Sinan Kaya
2016-04-27  0:06   ` Bjorn Helgaas
2016-04-27  0:17     ` Rafael J. Wysocki
2016-05-05 23:40       ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.