diff mbox

[V4,3/3] Revert "ACPI,PCI,IRQ: separate ISA penalty calculation"

Message ID 1476915664-27231-4-git-send-email-okaya@codeaurora.org
State Superseded
Headers show

Commit Message

Sinan Kaya Oct. 19, 2016, 10:21 p.m. UTC
This reverts commit f7eca374f000 ("ACPI,PCI,IRQ: separate ISA penalty
calculation") and commit 487cf917ed0d ("revert "ACPI, PCI, IRQ: remove
redundant code in acpi_irq_penalty_init()"").

Now that we understand the real issue (SCI and ISA penalty getting
calculated before ACPI start), there is no need for special handling
for ISA interrupts.

Let's try to simplify the code one more time to share code.

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

Comments

Bjorn Helgaas Oct. 21, 2016, 2:31 a.m. UTC | #1
On Wed, Oct 19, 2016 at 06:21:04PM -0400, Sinan Kaya wrote:
> This reverts commit f7eca374f000 ("ACPI,PCI,IRQ: separate ISA penalty
> calculation") and commit 487cf917ed0d ("revert "ACPI, PCI, IRQ: remove
> redundant code in acpi_irq_penalty_init()"").
> 
> Now that we understand the real issue (SCI and ISA penalty getting
> calculated before ACPI start), there is no need for special handling
> for ISA interrupts.
> 
> Let's try to simplify the code one more time to share code.

I'm sort of OK with this, but it's not exactly a revert of the above
(the commits you mention don't check "link->irq.initialized == 1".

Previously acpi_irq_penalty_init() looked at _PRS info ("possible"
IRQs), but now we won't.  Maybe that's good; I dunno.  But it should
be mentioned.

And I don't think it fixes a user-visible problem, so it doesn't need
to be applied immediately.  I'm not sure this is worth doing by
itself; maybe it should wait until we can do more cleanup and think
about all these issues together?

> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  arch/x86/pci/acpi.c         |  1 -
>  drivers/acpi/pci_link.c     | 44 +++++---------------------------------------
>  include/acpi/acpi_drivers.h |  1 -
>  3 files changed, 5 insertions(+), 41 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 294b190..dd14d78 100644
> --- a/drivers/acpi/pci_link.c
> +++ b/drivers/acpi/pci_link.c
> @@ -478,7 +478,8 @@ static int acpi_irq_pci_sharing_penalty(int irq)
>  		 * 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)
> +		if ((link->irq.active && link->irq.active == irq) &&
> +				(link->irq.initialized == 1))
>  			penalty += PIRQ_PENALTY_PCI_USING;
>  
>  		/*
> @@ -501,45 +502,10 @@ static int acpi_irq_get_penalty(int irq)
>  		penalty += sci_penalty;
>  
>  	if (irq < ACPI_MAX_ISA_IRQS)
> -		return penalty + acpi_isa_irq_penalty[irq];
> +		penalty += acpi_isa_irq_penalty[irq];
>  
> -	return penalty + acpi_irq_pci_sharing_penalty(irq);
> -}
> -
> -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;
> +	penalty += acpi_irq_pci_sharing_penalty(irq);
> +	return penalty;
>  }
>  
>  static int acpi_irq_balance = -1;	/* 0: static, 1: balance */
> 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.9.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
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 Oct. 21, 2016, 2:58 a.m. UTC | #2
On 10/20/2016 7:31 PM, Bjorn Helgaas wrote:
>> Let's try to simplify the code one more time to share code.
> I'm sort of OK with this, but it's not exactly a revert of the above
> (the commits you mention don't check "link->irq.initialized == 1".

I can split the initialized bit. If I remove it from this commit, it can
break the git bisect. That's why, I folded it into this review. I
briefly mentioned about it in the cover letter. It might not be quiet
clear.

> 
> Previously acpi_irq_penalty_init() looked at _PRS info ("possible"
> IRQs), but now we won't.  Maybe that's good; I dunno.  But it should
> be mentioned.

I'm directing all IRQs to  acpi_irq_pci_sharing_penalty function. 
acpi_irq_pci_sharing_penalty checks for the possible values here from
_PRS.

/*
 * penalize the IRQs PCI 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;

> 
> And I don't think it fixes a user-visible problem, so it doesn't need
> to be applied immediately.  I'm not sure this is worth doing by
> itself; maybe it should wait until we can do more cleanup and think
> about all these issues together?
> 

It does fix the PCI_USING penalty assignment. 

                if (link->irq.active && link->irq.active == irq)
                         penalty += PIRQ_PENALTY_PCI_USING;


If we drop this patch, then we need
[PATCH V3 1/3] ACPI, PCI IRQ: add PCI_USING penalty for ISA interrupts

http://www.gossamer-threads.com/lists/linux/kernel/2547605

as somebody needs to increment the penalty with PCI_USING when IRQ is assigned
for a given ISA IRQ.

We might as well take [PATCH V4 1/3], [PATCH V4 2/3] and [PATCH V3 1/3]
for this regression.
Bjorn Helgaas Oct. 22, 2016, 11:59 p.m. UTC | #3
On Thu, Oct 20, 2016 at 07:58:57PM -0700, Sinan Kaya wrote:
> On 10/20/2016 7:31 PM, Bjorn Helgaas wrote:
> ...
> > And I don't think it fixes a user-visible problem, so it doesn't need
> > to be applied immediately.  I'm not sure this is worth doing by
> > itself; maybe it should wait until we can do more cleanup and think
> > about all these issues together?
> 
> It does fix the PCI_USING penalty assignment. 
> 
>                 if (link->irq.active && link->irq.active == irq)
>                          penalty += PIRQ_PENALTY_PCI_USING;
> 
> 
> If we drop this patch, then we need
> [PATCH V3 1/3] ACPI, PCI IRQ: add PCI_USING penalty for ISA interrupts
> 
> http://www.gossamer-threads.com/lists/linux/kernel/2547605
> 
> as somebody needs to increment the penalty with PCI_USING when IRQ is assigned
> for a given ISA IRQ.
> 
> We might as well take [PATCH V4 1/3], [PATCH V4 2/3] and [PATCH V3 1/3]
> for this regression.

It sounds like either V3 1/3 or V4 3/3 will fix the regression.  The
V3 1/3 patch is much smaller and essentially makes this piece look
like it did in v4.6.

The V4 3/3 patch removes acpi_irq_penalty_init() and compensates by
using acpi_irq_pci_sharing_penalty() for ISA IRQs again.  But
acpi_irq_penalty_init() added PIRQ_PENALTY_PCI_POSSIBLE for _CRS, and
only if there was no _PRS, while acpi_irq_pci_sharing_penalty() always
adds PIRQ_PENALTY_PCI_USING for _CRS, regardless of whether _PRS
exists.

Since V4 3/3 is so much bigger and makes this quite subtle change in
how _CRS is handled, I like V3 1/3 better.

Are we all set to go now?  I think I've acked the patches you
mentioned.

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
Jonathan Liu Oct. 23, 2016, 3:49 a.m. UTC | #4
On 20 October 2016 at 09:21, Sinan Kaya <okaya@codeaurora.org> wrote:
> This reverts commit f7eca374f000 ("ACPI,PCI,IRQ: separate ISA penalty
> calculation") and commit 487cf917ed0d ("revert "ACPI, PCI, IRQ: remove
> redundant code in acpi_irq_penalty_init()"").
>
> Now that we understand the real issue (SCI and ISA penalty getting
> calculated before ACPI start), there is no need for special handling
> for ISA interrupts.
>
> Let's try to simplify the code one more time to share code.
>
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  arch/x86/pci/acpi.c         |  1 -
>  drivers/acpi/pci_link.c     | 44 +++++---------------------------------------
>  include/acpi/acpi_drivers.h |  1 -
>  3 files changed, 5 insertions(+), 41 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 294b190..dd14d78 100644
> --- a/drivers/acpi/pci_link.c
> +++ b/drivers/acpi/pci_link.c
> @@ -478,7 +478,8 @@ static int acpi_irq_pci_sharing_penalty(int irq)
>                  * 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)
> +               if ((link->irq.active && link->irq.active == irq) &&
> +                               (link->irq.initialized == 1))
>                         penalty += PIRQ_PENALTY_PCI_USING;
>
>                 /*
> @@ -501,45 +502,10 @@ static int acpi_irq_get_penalty(int irq)
>                 penalty += sci_penalty;
>
>         if (irq < ACPI_MAX_ISA_IRQS)
> -               return penalty + acpi_isa_irq_penalty[irq];
> +               penalty += acpi_isa_irq_penalty[irq];
>
> -       return penalty + acpi_irq_pci_sharing_penalty(irq);
> -}
> -
> -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;
> +       penalty += acpi_irq_pci_sharing_penalty(irq);
> +       return penalty;
>  }
>
>  static int acpi_irq_balance = -1;      /* 0: static, 1: balance */
> 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);

This series fixes one or more network adapters not working in Linux
32-bit x86 guest running inside VirtualBox if I have 4 network
adapters enabled. The following message no longer appears in the
kernel log:
ACPI: No IRQ available for PCI Interrupt Link [LNKD]. Try pci=noacpi or acpi=off

Tested-by: Jonathan Liu <net147@gmail.com>
--
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 Oct. 24, 2016, 4:16 a.m. UTC | #5
On 10/22/2016 7:59 PM, Bjorn Helgaas wrote:
> Since V4 3/3 is so much bigger and makes this quite subtle change in
> how _CRS is handled, I like V3 1/3 better.
> 

OK

> Are we all set to go now?  I think I've acked the patches you
> mentioned.

Yes, I'll post a follow up with your recommendations.
diff mbox

Patch

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 294b190..dd14d78 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -478,7 +478,8 @@  static int acpi_irq_pci_sharing_penalty(int irq)
 		 * 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)
+		if ((link->irq.active && link->irq.active == irq) &&
+				(link->irq.initialized == 1))
 			penalty += PIRQ_PENALTY_PCI_USING;
 
 		/*
@@ -501,45 +502,10 @@  static int acpi_irq_get_penalty(int irq)
 		penalty += sci_penalty;
 
 	if (irq < ACPI_MAX_ISA_IRQS)
-		return penalty + acpi_isa_irq_penalty[irq];
+		penalty += acpi_isa_irq_penalty[irq];
 
-	return penalty + acpi_irq_pci_sharing_penalty(irq);
-}
-
-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;
+	penalty += acpi_irq_pci_sharing_penalty(irq);
+	return penalty;
 }
 
 static int acpi_irq_balance = -1;	/* 0: static, 1: balance */
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);