diff mbox

[V3,1/4] acpi,pci,irq: reduce resource requirements

Message ID 1460914617-8259-1-git-send-email-okaya@codeaurora.org
State Not Applicable
Headers show

Commit Message

Sinan Kaya April 17, 2016, 5:36 p.m. UTC
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(-)

Comments

Bjorn Helgaas April 26, 2016, 6:36 p.m. UTC | #1
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
--
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 April 26, 2016, 7 p.m. UTC | #2
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
Nalla, Ravikanth April 26, 2016, 8:33 p.m. UTC | #3
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
--
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
Bjorn Helgaas April 27, 2016, 12:06 a.m. UTC | #4
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
--
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
Rafael J. Wysocki April 27, 2016, 12:17 a.m. UTC | #5
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.
--
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
Nalla, Ravikanth May 2, 2016, 5:44 p.m. UTC | #6
-----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
--
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 May 2, 2016, 5:58 p.m. UTC | #7
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/
Nalla, Ravikanth May 3, 2016, 4:17 p.m. UTC | #8
-----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
--
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 May 3, 2016, 5:16 p.m. UTC | #9
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.
Rafael J. Wysocki May 5, 2016, 11:40 p.m. UTC | #10
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

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

Patch

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;
-	}
 }
 
 /*