From: Sinan Kaya <hidden> Date: 2016-10-19 22:21:01
By the time ACPI gets initialized, this code tries to determine an
IRQ number based on penalty values in this array. It will try to locate
the IRQ with the least penalty assignment so that interrupt sharing is
avoided if possible.
A couple of notes about the external APIs:
1. These API can be called before the ACPI is started. Therefore, one
cannot assume that the PCI link objects are initialized for calculating
penalties.
2. The polarity and trigger information passed via the
acpi_penalize_sci_irq from the BIOS may not match what the IRQ subsystem
is reporting as the call might have been placed before the IRQ is
registered by the interrupt subsystem.
The reverted changes were in the direction to remove these external API and
try to calculate the penalties at runtime for the ISA, SCI as well as PCI
IRQS.
This didn't work out well with the existing platforms.
V4:
* Drop ACPI, PCI IRQ: add PCI_USING penalty for ISA interrupts
* A new patch to isolate early boot ISA penalty calculations from dynamic
penalty calculation by directly modifying the array members in
("ACPI, PCI, IRQ: assign ISA IRQ directly during early boot stages")
* Now that we isolated both SCI and ISA interrupts, revert commit ("Revert
"ACPI,PCI,IRQ: separate ISA penalty calculation"") and commit
("487cf917ed0d
(Revert "ACPI, PCI, IRQ: remove redundant code in acpi_irq_penalty_init()")
to share code between ISA and PCI penalties as originally intended.
V3:
http://www.spinics.net/lists/arm-kernel/msg536208.html
* drop patch #1 as discussed with Bjorn
* add patch #3 to track SCI irq and penalty separately
V2: https://lkml.org/lkml/2016/10/1/106
* Commit message updates
V1:
http://lists-archives.com/linux-kernel/28673954-revert-acpi-pci-irq-reduce-static-irq-array-size-to-16.html
* initial implementation
Sinan Kaya (3):
ACPI, PCI, IRQ: assign ISA IRQ directly during early boot stages
Revert "ACPI,PCI,IRQ: remove SCI penalize function"
Revert "ACPI,PCI,IRQ: separate ISA penalty calculation"
arch/x86/kernel/acpi/boot.c | 1 +
arch/x86/pci/acpi.c | 1 -
drivers/acpi/pci_link.c | 72 ++++++++++++---------------------------------
include/acpi/acpi_drivers.h | 1 -
include/linux/acpi.h | 1 +
5 files changed, 21 insertions(+), 55 deletions(-)
--
1.9.1
From: Sinan Kaya <hidden> Date: 2016-10-19 22:21:17
The penalty determination of ISA IRQ goes through 4 paths.
1. assign PCI_USING during power up via acpi_irq_penalty_init.
2. update the penalty with acpi_penalize_isa_irq function based on the
active parameter.
3. kernel command line penalty update via acpi_irq_penalty_update function.
4. increment the penalty as USING right after the IRQ is assign to PCI.
acpi_penalize_isa_irq and acpi_irq_penalty_update functions get called
before the ACPI subsystem is started.
These API need to bypass the acpi_irq_get_penalty function.
Signed-off-by: Sinan Kaya <redacted>
---
drivers/acpi/pci_link.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Sinan Kaya <hidden> Date: 2016-10-19 22:21:25
The SCI penalize function was removed in two steps (first refactor
and then remove) and these changes are reverted here in one go.
The commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
refactored the original code so that SCI penalty is calculated dynamically
by the time get_penalty function is called. That change is partially
reverted here, specifically for the SCI IRQ alone.
The SCI penalize function was finally dropped by commit 9e5ed6d1fb87
("ACPI,PCI,IRQ: remove SCI penalize function") that replaced the old SCI
penalty API with penalty calculation carried out dynamically and based
on the acpi_gbl_FADT.sci_interrupt value.
However, that new algorithm relies on the accurate setting of IRQ
types and that doesn't happen early enough on some platforms which
leads to incorrect penalty assignments for PCI IRQs. In those cases,
irq_get_trigger_type() returns incorrect values for the IRQs in
question, because they have not been registered yet by the time the
penalties are calculated.
To fix this problem, we only need to fix the penalty for the SCI interrupt.
It seems better to add a single "sci_penalty" variable, set it to
PIRQ_PENALTY_PCI_USING if it's level/low or PIRQ_PENALTY_ISA_ALWAYS
otherwise, and add "sci_penalty" in when appropriate. That should fix it
for *any* SCI IRQ, not just those less than 256, and we don't have to add
these extra penalty table entries that are all unused (except possibly for
one entry if we have an SCI in the 16-255 range).
For this reason, revert commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI
penalize function") completely to restore the correct behavior.
Link: https://lkml.org/lkml/2016/10/4/283
Signed-off-by: Sinan Kaya <redacted>
Fixes: commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
Fixes: commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI penalize function")
---
arch/x86/kernel/acpi/boot.c | 1 +
drivers/acpi/pci_link.c | 30 +++++++++++++++---------------
include/linux/acpi.h | 1 +
3 files changed, 17 insertions(+), 15 deletions(-)
From: Sinan Kaya <hidden> Date: 2016-10-19 22:21:27
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 <redacted>
---
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(-)
@@ -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;
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2016-10-20 21:39:21
On Thu, Oct 20, 2016 at 12:21 AM, Sinan Kaya [off-list ref] wrote:
quoted hunk
The penalty determination of ISA IRQ goes through 4 paths.
1. assign PCI_USING during power up via acpi_irq_penalty_init.
2. update the penalty with acpi_penalize_isa_irq function based on the
active parameter.
3. kernel command line penalty update via acpi_irq_penalty_update function.
4. increment the penalty as USING right after the IRQ is assign to PCI.
acpi_penalize_isa_irq and acpi_irq_penalty_update functions get called
before the ACPI subsystem is started.
These API need to bypass the acpi_irq_get_penalty function.
Signed-off-by: Sinan Kaya <redacted>
---
drivers/acpi/pci_link.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
On Wed, Oct 19, 2016 at 06:21:02PM -0400, Sinan Kaya wrote:
The penalty determination of ISA IRQ goes through 4 paths.
1. assign PCI_USING during power up via acpi_irq_penalty_init.
2. update the penalty with acpi_penalize_isa_irq function based on the
active parameter.
3. kernel command line penalty update via acpi_irq_penalty_update function.
4. increment the penalty as USING right after the IRQ is assign to PCI.
acpi_penalize_isa_irq and acpi_irq_penalty_update functions get called
before the ACPI subsystem is started.
These API need to bypass the acpi_irq_get_penalty function.
I don't mind this patch, but the changelog doesn't tell me what's
broken and why we need this fix. Apparently acpi_irq_get_penalty()
doesn't work before ACPI is initialized, but I don't see *why* it
wouldn't work.
However, I see one bug it *does* fix: we do not store the SCI penalty
in the acpi_isa_irq_penalty[] table because acpi_isa_irq_penalty[]
only holds ISA IRQ penalties, and there's no guarantee that the SCI is
an ISA IRQ. But prior to this patch, we added in the SCI penalty to
the acpi_isa_irq_penalty[] entry when the SCI was an ISA IRQ, which
makes acpi_irq_get_penalty() return the wrong thing. Consider:
Initially acpi_isa_irq_penalty[9] = 0.
Assume sci_interrupt = 9.
Then acpi_irq_get_penalty(9) returns X.
If we call acpi_penalize_isa_irq(9, 1),
it sets acpi_isa_irq_penalty[9] = X,
and now acpi_irq_get_penalty(9) returns X + X.
I'd propose a changelog like this:
We do not want to store the SCI penalty in the acpi_isa_irq_penalty[]
table because acpi_isa_irq_penalty[] only holds ISA IRQ penalties and
there's no guarantee that the SCI is an ISA IRQ. We add in the SCI
penalty as a special case in acpi_irq_get_penalty().
But if we called acpi_penalize_isa_irq() or acpi_irq_penalty_update()
for an SCI that happened to be an ISA IRQ, they stored the SCI
penalty (part of the acpi_irq_get_penalty() return value) in
acpi_isa_irq_penalty[]. Subsequent calls to acpi_irq_get_penalty()
returned a penalty that included *two* SCI penalties.
If this actually fixes a worse problem related to ACPI initialization,
of course you should detail that.
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
quoted hunk
Signed-off-by: Sinan Kaya <redacted>
---
drivers/acpi/pci_link.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
On Wed, Oct 19, 2016 at 06:21:03PM -0400, Sinan Kaya wrote:
The SCI penalize function was removed in two steps (first refactor
and then remove) and these changes are reverted here in one go.
The commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
refactored the original code so that SCI penalty is calculated dynamically
by the time get_penalty function is called. That change is partially
reverted here, specifically for the SCI IRQ alone.
The SCI penalize function was finally dropped by commit 9e5ed6d1fb87
("ACPI,PCI,IRQ: remove SCI penalize function") that replaced the old SCI
penalty API with penalty calculation carried out dynamically and based
on the acpi_gbl_FADT.sci_interrupt value.
However, that new algorithm relies on the accurate setting of IRQ
types and that doesn't happen early enough on some platforms which
leads to incorrect penalty assignments for PCI IRQs. In those cases,
irq_get_trigger_type() returns incorrect values for the IRQs in
question, because they have not been registered yet by the time the
penalties are calculated.
To fix this problem, we only need to fix the penalty for the SCI interrupt.
It seems better to add a single "sci_penalty" variable, set it to
PIRQ_PENALTY_PCI_USING if it's level/low or PIRQ_PENALTY_ISA_ALWAYS
otherwise, and add "sci_penalty" in when appropriate. That should fix it
for *any* SCI IRQ, not just those less than 256, and we don't have to add
these extra penalty table entries that are all unused (except possibly for
one entry if we have an SCI in the 16-255 range).
For this reason, revert commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI
penalize function") completely to restore the correct behavior.
I like this patch fine, except for the changelog. I don't think it's
useful to describe this as a revert and give all the historical
details. I think the important part is something like this:
We previously used irq_get_trigger_type(irq) to help compute the
penalty for the SCI, but that depends on the SCI having been
registered already. Add acpi_penalize_sci_irq() so platforms can
tell us the SCI IRQ, trigger, and polarity so we can compute the
penalty even before the SCI has been registered.
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
"commit" is redundant; it's sufficient to say:
Fixes: 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
In fact, I don't think you really need to include "commit" in the
reference to 9e5ed6d1fb87 above either.
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?
@@ -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;
From: Sinan Kaya <hidden> Date: 2016-10-21 02:59:03
On 10/20/2016 7:31 PM, Bjorn Helgaas wrote:
quoted
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.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
On Thu, Oct 20, 2016 at 08:39:30PM -0500, Bjorn Helgaas wrote:
On Wed, Oct 19, 2016 at 06:21:02PM -0400, Sinan Kaya wrote:
quoted
The penalty determination of ISA IRQ goes through 4 paths.
1. assign PCI_USING during power up via acpi_irq_penalty_init.
2. update the penalty with acpi_penalize_isa_irq function based on the
active parameter.
3. kernel command line penalty update via acpi_irq_penalty_update function.
4. increment the penalty as USING right after the IRQ is assign to PCI.
acpi_penalize_isa_irq and acpi_irq_penalty_update functions get called
before the ACPI subsystem is started.
These API need to bypass the acpi_irq_get_penalty function.
I don't mind this patch, but the changelog doesn't tell me what's
broken and why we need this fix. Apparently acpi_irq_get_penalty()
doesn't work before ACPI is initialized, but I don't see *why* it
wouldn't work.
However, I see one bug it *does* fix: we do not store the SCI penalty
in the acpi_isa_irq_penalty[] table because acpi_isa_irq_penalty[]
only holds ISA IRQ penalties, and there's no guarantee that the SCI is
an ISA IRQ. But prior to this patch, we added in the SCI penalty to
the acpi_isa_irq_penalty[] entry when the SCI was an ISA IRQ, which
makes acpi_irq_get_penalty() return the wrong thing. Consider:
Initially acpi_isa_irq_penalty[9] = 0.
Assume sci_interrupt = 9.
Then acpi_irq_get_penalty(9) returns X.
If we call acpi_penalize_isa_irq(9, 1),
it sets acpi_isa_irq_penalty[9] = X,
and now acpi_irq_get_penalty(9) returns X + X.
Oops, I forgot the penalty we *intended* to add with
acpi_penalize_isa_irq(). It's really like this, where X is the SCI
penalty and Y is the part added by acpi_penalize_isa_irq():
Initially acpi_isa_irq_penalty[9] = 0.
Assume sci_interrupt = 9.
Then acpi_irq_get_penalty(9) returns X.
If we call acpi_penalize_isa_irq(9, 1),
it sets acpi_isa_irq_penalty[9] = X + Y,
and now acpi_irq_get_penalty(9) returns X + X + Y.
At the end, acpi_irq_get_penalty(9) *should* return X + Y, but instead
it returns X + X + Y, i.e., the SCI penalty is included twice.
On Thu, Oct 20, 2016 at 08:58:14PM -0500, Bjorn Helgaas wrote:
On Wed, Oct 19, 2016 at 06:21:03PM -0400, Sinan Kaya wrote:
quoted
The SCI penalize function was removed in two steps (first refactor
and then remove) and these changes are reverted here in one go.
The commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
refactored the original code so that SCI penalty is calculated dynamically
by the time get_penalty function is called. That change is partially
reverted here, specifically for the SCI IRQ alone.
The SCI penalize function was finally dropped by commit 9e5ed6d1fb87
("ACPI,PCI,IRQ: remove SCI penalize function") that replaced the old SCI
penalty API with penalty calculation carried out dynamically and based
on the acpi_gbl_FADT.sci_interrupt value.
However, that new algorithm relies on the accurate setting of IRQ
types and that doesn't happen early enough on some platforms which
leads to incorrect penalty assignments for PCI IRQs. In those cases,
irq_get_trigger_type() returns incorrect values for the IRQs in
question, because they have not been registered yet by the time the
penalties are calculated.
To fix this problem, we only need to fix the penalty for the SCI interrupt.
It seems better to add a single "sci_penalty" variable, set it to
PIRQ_PENALTY_PCI_USING if it's level/low or PIRQ_PENALTY_ISA_ALWAYS
otherwise, and add "sci_penalty" in when appropriate. That should fix it
for *any* SCI IRQ, not just those less than 256, and we don't have to add
these extra penalty table entries that are all unused (except possibly for
one entry if we have an SCI in the 16-255 range).
For this reason, revert commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI
penalize function") completely to restore the correct behavior.
I like this patch fine, except for the changelog. I don't think it's
useful to describe this as a revert and give all the historical
details. I think the important part is something like this:
We previously used irq_get_trigger_type(irq) to help compute the
penalty for the SCI, but that depends on the SCI having been
registered already. Add acpi_penalize_sci_irq() so platforms can
tell us the SCI IRQ, trigger, and polarity so we can compute the
penalty even before the SCI has been registered.
Thanks for the pointer [1] to the issues around
acpi_penalize_sci_irq() being called before kmalloc() is available.
That begs the question of exactly *why* we need
acpi_penalize_sci_irq() so early -- I doubt we actually need to handle
SCIs that early, and obviously we don't need to look up penalties that
early (because we only look them up when enabling interrupt links,
which happens much later).
[1] http://marc.info/?l=linux-acpi&m=145580159209240&w=2)
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Wait a minute, I still have a question here: what about other ACPI
arches (ia64, arm64)? Don't they need to call acpi_penalize_sci_irq()
somewhere?
--
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-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Wait a minute, I still have a question here: what about other ACPI
arches (ia64, arm64)? Don't they need to call acpi_penalize_sci_irq()
somewhere?
ACPI ARM64 architecture implements reduced ACPI profile which doesn't
have GED object. Instead, ARM64 architecture uses onchip peripherals
for similar functionality. If there is a need to signal interrupts,
this is done by ACPI Notify in ASL or if absolutely needed using
ACPI Generic Event Device (GED).
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Wait a minute, I still have a question here: what about other ACPI
arches (ia64, arm64)? Don't they need to call acpi_penalize_sci_irq()
somewhere?
ACPI ARM64 architecture implements reduced ACPI profile which doesn't
have GED object. Instead, ARM64 architecture uses onchip peripherals
for similar functionality. If there is a need to signal interrupts,
this is done by ACPI Notify in ASL or if absolutely needed using
ACPI Generic Event Device (GED).
OK. I guess ia64 never did call acpi_penalize_sci_irq(), so while it
could be added someday to unify things, we don't need to add it now.
Same for arm64.
So I'd like it if you updated the changelog, but I'm OK with the
patch:
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
On Thu, Oct 20, 2016 at 08:58:14PM -0500, Bjorn Helgaas wrote:
On Wed, Oct 19, 2016 at 06:21:03PM -0400, Sinan Kaya wrote:
quoted
The SCI penalize function was removed in two steps (first refactor
and then remove) and these changes are reverted here in one go.
The commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
refactored the original code so that SCI penalty is calculated dynamically
by the time get_penalty function is called. That change is partially
reverted here, specifically for the SCI IRQ alone.
The SCI penalize function was finally dropped by commit 9e5ed6d1fb87
("ACPI,PCI,IRQ: remove SCI penalize function") that replaced the old SCI
penalty API with penalty calculation carried out dynamically and based
on the acpi_gbl_FADT.sci_interrupt value.
However, that new algorithm relies on the accurate setting of IRQ
types and that doesn't happen early enough on some platforms which
leads to incorrect penalty assignments for PCI IRQs. In those cases,
irq_get_trigger_type() returns incorrect values for the IRQs in
question, because they have not been registered yet by the time the
penalties are calculated.
To fix this problem, we only need to fix the penalty for the SCI interrupt.
It seems better to add a single "sci_penalty" variable, set it to
PIRQ_PENALTY_PCI_USING if it's level/low or PIRQ_PENALTY_ISA_ALWAYS
otherwise, and add "sci_penalty" in when appropriate. That should fix it
for *any* SCI IRQ, not just those less than 256, and we don't have to add
these extra penalty table entries that are all unused (except possibly for
one entry if we have an SCI in the 16-255 range).
For this reason, revert commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI
penalize function") completely to restore the correct behavior.
I like this patch fine, except for the changelog. I don't think it's
useful to describe this as a revert and give all the historical
details. I think the important part is something like this:
We previously used irq_get_trigger_type(irq) to help compute the
penalty for the SCI, but that depends on the SCI having been
registered already. Add acpi_penalize_sci_irq() so platforms can
tell us the SCI IRQ, trigger, and polarity so we can compute the
penalty even before the SCI has been registered.
I think this is actually the critical patch that fixes the regression
reported by Ondrej, so the changelog really should include details
about the regression, e.g., something like this:
ACPI: pci_link: Penalize SCI correctly
Ondrej reported that IRQs stopped working in v4.7 on several
platforms. A typical scenario, from Ondrej's VT82C694X/694X, is:
ACPI: Using PIC for interrupt routing
ACPI: PCI Interrupt Link [LNKA] (IRQs 1 3 4 5 6 7 10 *11 12 14 15)
ACPI: No IRQ available for PCI Interrupt Link [LNKA]
8139too 0000:00:0f.0: PCI INT A: no GSI
We're using PIC routing, so acpi_irq_balance == 0, and LNKA is already
active at IRQ 11. In that case, acpi_pci_link_allocate() only tries
to use the active IRQ (IRQ 11) which also happens to be the SCI.
We should penalize the SCI by PIRQ_PENALTY_PCI_USING, but
irq_get_trigger_type(11) returns something other than
IRQ_TYPE_LEVEL_LOW, so we penalize it by PIRQ_PENALTY_ISA_ALWAYS
instead, which makes acpi_pci_link_allocate() assume the IRQ isn't
available and give up.
Add acpi_penalize_sci_irq() so platforms can tell us the SCI IRQ,
trigger, and polarity directly and we don't have to depend on
irq_get_trigger_type().
Link: http://lkml.kernel.org/r/201609251512.05657.linux@rainbow-software.org
Reported-by: Ondrej Zary [off-list ref]
I don't understand what's broken about using irq_get_trigger_type().
The SCI is registered in the following path, which is certainly before
we try to enable LNKA for the 8139too device:
acpi_init # subsys_initcall
acpi_bus_init
acpi_enable_subsystem
acpi_ev_install_xrupt_handlers
acpi_ev_install_sci_handler
acpi_os_install_interrupt_handler(sci_interrupt, ...)
acpi_gsi_to_irq
acpi_register_gsi
irq_create_fwspec_mapping
irqd_set_trigger_type
In any event, I think this patch to add acpi_penalize_sci_irq() is
fine.
"commit" is redundant; it's sufficient to say:
Fixes: 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
In fact, I don't think you really need to include "commit" in the
reference to 9e5ed6d1fb87 above either.
--
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-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Oct 20, 2016 at 07:58:57PM -0700, Sinan Kaya wrote:
On 10/20/2016 7:31 PM, Bjorn Helgaas wrote:
...
quoted
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
From: Jonathan Liu <hidden> Date: 2016-10-23 03:49:02
On 20 October 2016 at 09:21, Sinan Kaya [off-list ref] wrote:
quoted hunk
The penalty determination of ISA IRQ goes through 4 paths.
1. assign PCI_USING during power up via acpi_irq_penalty_init.
2. update the penalty with acpi_penalize_isa_irq function based on the
active parameter.
3. kernel command line penalty update via acpi_irq_penalty_update function.
4. increment the penalty as USING right after the IRQ is assign to PCI.
acpi_penalize_isa_irq and acpi_irq_penalty_update functions get called
before the ACPI subsystem is started.
These API need to bypass the acpi_irq_get_penalty function.
Signed-off-by: Sinan Kaya <redacted>
---
drivers/acpi/pci_link.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -849,7 +849,7 @@ static int __init acpi_irq_penalty_update(char *str, int used)continue;if(used)-new_penalty=acpi_irq_get_penalty(irq)++new_penalty=acpi_isa_irq_penalty[irq]+PIRQ_PENALTY_ISA_USED;elsenew_penalty=0;
@@ -871,7 +871,7 @@ static int __init acpi_irq_penalty_update(char *str, int used)voidacpi_penalize_isa_irq(intirq,intactive){if((irq>=0)&&(irq<ARRAY_SIZE(acpi_isa_irq_penalty)))-acpi_isa_irq_penalty[irq]=acpi_irq_get_penalty(irq)++acpi_isa_irq_penalty[irq]=acpi_isa_irq_penalty[irq]+(active?PIRQ_PENALTY_ISA_USED:PIRQ_PENALTY_PCI_USING);}
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 <redacted>
From: Jonathan Liu <hidden> Date: 2016-10-23 03:49:20
On 20 October 2016 at 09:21, Sinan Kaya [off-list ref] wrote:
quoted hunk
The SCI penalize function was removed in two steps (first refactor
and then remove) and these changes are reverted here in one go.
The commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
refactored the original code so that SCI penalty is calculated dynamically
by the time get_penalty function is called. That change is partially
reverted here, specifically for the SCI IRQ alone.
The SCI penalize function was finally dropped by commit 9e5ed6d1fb87
("ACPI,PCI,IRQ: remove SCI penalize function") that replaced the old SCI
penalty API with penalty calculation carried out dynamically and based
on the acpi_gbl_FADT.sci_interrupt value.
However, that new algorithm relies on the accurate setting of IRQ
types and that doesn't happen early enough on some platforms which
leads to incorrect penalty assignments for PCI IRQs. In those cases,
irq_get_trigger_type() returns incorrect values for the IRQs in
question, because they have not been registered yet by the time the
penalties are calculated.
To fix this problem, we only need to fix the penalty for the SCI interrupt.
It seems better to add a single "sci_penalty" variable, set it to
PIRQ_PENALTY_PCI_USING if it's level/low or PIRQ_PENALTY_ISA_ALWAYS
otherwise, and add "sci_penalty" in when appropriate. That should fix it
for *any* SCI IRQ, not just those less than 256, and we don't have to add
these extra penalty table entries that are all unused (except possibly for
one entry if we have an SCI in the 16-255 range).
For this reason, revert commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI
penalize function") completely to restore the correct behavior.
Link: https://lkml.org/lkml/2016/10/4/283
Signed-off-by: Sinan Kaya <redacted>
Fixes: commit 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
Fixes: commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI penalize function")
---
arch/x86/kernel/acpi/boot.c | 1 +
drivers/acpi/pci_link.c | 30 +++++++++++++++---------------
include/linux/acpi.h | 1 +
3 files changed, 17 insertions(+), 15 deletions(-)
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 <redacted>
From: Jonathan Liu <hidden> Date: 2016-10-23 03:49:34
On 20 October 2016 at 09:21, Sinan Kaya [off-list ref] wrote:
quoted hunk
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 <redacted>
---
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(-)
@@ -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;
@@ -78,7 +78,6 @@/* ACPI PCI Interrupt Link (pci_link.c) */-intacpi_irq_penalty_init(void);intacpi_pci_link_allocate_irq(acpi_handlehandle,intindex,int*triggering,int*polarity,char**name);intacpi_pci_link_free_irq(acpi_handlehandle);
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 <redacted>
From: Sinan Kaya <hidden> Date: 2016-10-24 03:22:10
On 10/20/2016 9:39 PM, Bjorn Helgaas wrote:
quoted
These API need to bypass the acpi_irq_get_penalty function.
I don't mind this patch, but the changelog doesn't tell me what's
broken and why we need this fix. Apparently acpi_irq_get_penalty()
doesn't work before ACPI is initialized, but I don't see *why* it
wouldn't work.
I'll update the commit message as you suggested. The code doesn't work
if we apply PATCH V4 2/3 + PATCH V4 3/3 without PATCH V4 1/3 since
the caller is going to end up calling get_penalty function while ACPI
is not initialized. This happened during the debug of this regression.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Makes sense.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Sinan Kaya <hidden> Date: 2016-10-24 03:48:55
On 10/21/2016 12:13 PM, Sinan Kaya wrote:
quoted
Wait a minute, I still have a question here: what about other ACPI
quoted
arches (ia64, arm64)? Don't they need to call acpi_penalize_sci_irq()
somewhere?
ACPI ARM64 architecture implements reduced ACPI profile which doesn't
have GED object.
I actually wanted to mean that ARM64 architecture doesn't have *GPE* object
implemented on ACPI reduced profile.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Sinan Kaya <hidden> Date: 2016-10-24 03:49:04
On 10/20/2016 9:58 PM, Bjorn Helgaas wrote:
I like this patch fine, except for the changelog. I don't think it's
useful to describe this as a revert and give all the historical
details. I think the important part is something like this:
We previously used irq_get_trigger_type(irq) to help compute the
penalty for the SCI, but that depends on the SCI having been
registered already. Add acpi_penalize_sci_irq() so platforms can
tell us the SCI IRQ, trigger, and polarity so we can compute the
penalty even before the SCI has been registered.
OK, will replace with this and also change the commit summary as
"ACPI,PCI,IRQ: save SCI IRQ details for runtime penalty calculation"
OK. I have been fighting with checkpatch. Checkpatch doesn't like a commit
summary without "commit 12 char SHA"
Fixes: 103544d86976 ("ACPI,PCI,IRQ: reduce resource requirements")
In fact, I don't think you really need to include "commit" in the
reference to 9e5ed6d1fb87 above either.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Sinan Kaya <hidden> Date: 2016-10-24 04:16:24
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.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Sinan Kaya <hidden> Date: 2016-10-24 04:17:35
Thanks,
On 10/22/2016 11:48 PM, Jonathan Liu wrote:
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 <redacted>
I'm hoping that you can retest V5 so that Rafael can pull in your tested-by into
the commit message.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Jonathan Liu <hidden> Date: 2016-10-24 04:21:49
On 24 October 2016 at 15:17, Sinan Kaya [off-list ref] wrote:
Thanks,
On 10/22/2016 11:48 PM, Jonathan Liu wrote:
quoted
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 <redacted>
I'm hoping that you can retest V5 so that Rafael can pull in your tested-by into
the commit message.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Sure. Please CC me when you submit V5.
Regards,
Jonathan