* [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409
[not found] <1414387308-27148-1-git-send-email-jiang.liu@linux.intel.com>
@ 2014-10-27 5:21 ` Jiang Liu
2014-10-28 17:44 ` Pavel Machek
2014-10-28 18:13 ` Bjorn Helgaas
2014-10-27 5:21 ` [Patch v7 03/18] ACPI, irq, x86: Return IRQ instead of GSI in mp_register_gsi() Jiang Liu
` (4 subsequent siblings)
5 siblings, 2 replies; 12+ messages in thread
From: Jiang Liu @ 2014-10-27 5:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, Len Brown, Pavel Machek, x86
Cc: Jiang Liu, Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck,
Joerg Roedel, Greg Kroah-Hartman, linux-kernel, linux-pci,
linux-acpi, rui.zhang, linux-pm
When IOAPIC is disabled, acpi_gsi_to_irq() should return gsi directly
instead of calling mp_map_gsi_to_irq() to translate gsi to IRQ by IOAPIC.
It fixes https://bugzilla.kernel.org/show_bug.cgi?id=84381.
Reported-by: Thomas Richter <thor@math.tu-berlin.de>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: rui.zhang@intel.com
Cc: <stable@vger.kernel.org> # 3.17
---
arch/x86/kernel/acpi/boot.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index b436fc735aa4..eceba9d9e116 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -604,14 +604,19 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
{
- int irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
+ int irq;
- if (irq >= 0) {
+ if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
+ *irqp = gsi;
+ } else {
+ irq = mp_map_gsi_to_irq(gsi,
+ IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
+ if (irq < 0)
+ return -1;
*irqp = irq;
- return 0;
}
- return -1;
+ return 0;
}
EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409
2014-10-27 5:21 ` [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409 Jiang Liu
@ 2014-10-28 17:44 ` Pavel Machek
2014-10-28 18:13 ` Bjorn Helgaas
1 sibling, 0 replies; 12+ messages in thread
From: Pavel Machek @ 2014-10-28 17:44 UTC (permalink / raw)
To: Jiang Liu
Cc: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, Len Brown, x86,
Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel, linux-pci, linux-acpi,
rui.zhang, linux-pm
Hi!
> When IOAPIC is disabled, acpi_gsi_to_irq() should return gsi directly
> instead of calling mp_map_gsi_to_irq() to translate gsi to IRQ by IOAPIC.
> It fixes https://bugzilla.kernel.org/show_bug.cgi?id=84381.
>
> Reported-by: Thomas Richter <thor@math.tu-berlin.de>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> Cc: rui.zhang@intel.com
> Cc: <stable@vger.kernel.org> # 3.17
> ---
> arch/x86/kernel/acpi/boot.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index b436fc735aa4..eceba9d9e116 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -604,14 +604,19 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
>
> int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
> {
> - int irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
> + int irq;
>
> - if (irq >= 0) {
> + if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
> + *irqp = gsi;
As you have multiple return points, anyway, I'd do return 0; here
> + } else {
> + irq = mp_map_gsi_to_irq(gsi,
> + IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
> + if (irq < 0)
> + return -1;
> *irqp = irq;
> - return 0;
> }
...so that one level of nesting is avoided, and there are no problems
with fiting to 80 colums.
With that,
Acked-by: Pavel Machek <pavel@ucw.cz>
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409
2014-10-27 5:21 ` [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409 Jiang Liu
2014-10-28 17:44 ` Pavel Machek
@ 2014-10-28 18:13 ` Bjorn Helgaas
2014-10-28 18:45 ` Thomas Gleixner
1 sibling, 1 reply; 12+ messages in thread
From: Bjorn Helgaas @ 2014-10-28 18:13 UTC (permalink / raw)
To: Jiang Liu
Cc: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Randy Dunlap, Yinghai Lu,
Borislav Petkov, Len Brown, Pavel Machek, x86@kernel.org,
Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, Zhang, Rui,
Linux PM list
The subject should describe the change you're making. "Fix regression
caused by xxx" doesn't say anything about what the patch does.
On Sun, Oct 26, 2014 at 11:21 PM, Jiang Liu <jiang.liu@linux.intel.com> wrote:
> When IOAPIC is disabled, acpi_gsi_to_irq() should return gsi directly
> instead of calling mp_map_gsi_to_irq() to translate gsi to IRQ by IOAPIC.
I don't know what the convention is or if there even is one, but "GSI"
is even more of an acronym than "IRQ", so I'd capitalize it.
> It fixes https://bugzilla.kernel.org/show_bug.cgi?id=84381.
A line like the following may be useful to those who have to backport this.
Fixes: 6b9fb7082409 ("x86, ACPI, irq: Consolidate algorithm of mapping
(ioapic, pin) to IRQ number")
> Reported-by: Thomas Richter <thor@math.tu-berlin.de>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> Cc: rui.zhang@intel.com
> Cc: <stable@vger.kernel.org> # 3.17
> ---
> arch/x86/kernel/acpi/boot.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index b436fc735aa4..eceba9d9e116 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -604,14 +604,19 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
>
> int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
> {
> - int irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
> + int irq;
>
> - if (irq >= 0) {
> + if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
> + *irqp = gsi;
> + } else {
> + irq = mp_map_gsi_to_irq(gsi,
> + IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
> + if (irq < 0)
> + return -1;
> *irqp = irq;
> - return 0;
> }
>
> - return -1;
> + return 0;
> }
> EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
>
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409
2014-10-28 18:13 ` Bjorn Helgaas
@ 2014-10-28 18:45 ` Thomas Gleixner
0 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2014-10-28 18:45 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Jiang Liu, Benjamin Herrenschmidt, Ingo Molnar, H. Peter Anvin,
Rafael J. Wysocki, Randy Dunlap, Yinghai Lu, Borislav Petkov,
Len Brown, Pavel Machek, x86@kernel.org, Konrad Rzeszutek Wilk,
Andrew Morton, Tony Luck, Joerg Roedel, Greg Kroah-Hartman,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-acpi@vger.kernel.org, Zhang, Rui, Linux PM list
On Tue, 28 Oct 2014, Bjorn Helgaas wrote:
> The subject should describe the change you're making. "Fix regression
> caused by xxx" doesn't say anything about what the patch does.
>
> On Sun, Oct 26, 2014 at 11:21 PM, Jiang Liu <jiang.liu@linux.intel.com> wrote:
> > When IOAPIC is disabled, acpi_gsi_to_irq() should return gsi directly
> > instead of calling mp_map_gsi_to_irq() to translate gsi to IRQ by IOAPIC.
>
> I don't know what the convention is or if there even is one, but "GSI"
> is even more of an acronym than "IRQ", so I'd capitalize it.
>
> > It fixes https://bugzilla.kernel.org/show_bug.cgi?id=84381.
>
> A line like the following may be useful to those who have to backport this.
>
> Fixes: 6b9fb7082409 ("x86, ACPI, irq: Consolidate algorithm of mapping
> (ioapic, pin) to IRQ number")
The patch is already queued in tip x86/urgent with a proper changelog.
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=961b6a7003acec4f9d70dabc1a253b783cb74272
Thanks,
tglx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Patch v7 03/18] ACPI, irq, x86: Return IRQ instead of GSI in mp_register_gsi()
[not found] <1414387308-27148-1-git-send-email-jiang.liu@linux.intel.com>
2014-10-27 5:21 ` [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409 Jiang Liu
@ 2014-10-27 5:21 ` Jiang Liu
2014-10-27 5:21 ` [Patch v7 14/18] x86, irq, ACPI: Introduce a rwsem to protect IOAPIC operations from hotplug Jiang Liu
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Jiang Liu @ 2014-10-27 5:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, Len Brown, Pavel Machek, x86
Cc: Jiang Liu, Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck,
Joerg Roedel, Greg Kroah-Hartman, linux-kernel, linux-pci,
linux-acpi, linux-pm
The GSI for ACPI SCI may be shared with other devices. For example,
Function mp_register_gsi() should return IRQ number, so fix a regression
by returning mp_map_gsi_to_irq(gsi, 0) instead of gsi.
The regression was caused by commit 84245af7297ced9e8fe "x86, irq, ACPI:
Change __acpi_register_gsi to return IRQ number instead of GSI" and
exposed on a SuperMicro system, which shares one GSI between ACPI SCI
and PCI device, with following failure:
http://sourceforge.net/p/linux1394/mailman/linux1394-user/?viewmonth=201410
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low
level)
[ 2.699224] firewire_ohci 0000:06:00.0: failed to allocate interrupt
20
Reported-and-Tested-by: Daniel Robbins <drobbins@funtoo.org>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: <stable@vger.kernel.org> # 3.17
---
arch/x86/kernel/acpi/boot.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index eceba9d9e116..e077c080a519 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -397,7 +397,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,
/* Don't set up the ACPI SCI because it's already set up */
if (acpi_gbl_FADT.sci_interrupt == gsi)
- return gsi;
+ return mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC);
trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Patch v7 14/18] x86, irq, ACPI: Introduce a rwsem to protect IOAPIC operations from hotplug
[not found] <1414387308-27148-1-git-send-email-jiang.liu@linux.intel.com>
2014-10-27 5:21 ` [Patch v7 01/18] ACPI, irq: fix regression casued by 6b9fb7082409 Jiang Liu
2014-10-27 5:21 ` [Patch v7 03/18] ACPI, irq, x86: Return IRQ instead of GSI in mp_register_gsi() Jiang Liu
@ 2014-10-27 5:21 ` Jiang Liu
2014-11-01 18:59 ` Thomas Gleixner
2014-10-27 5:21 ` [Patch v7 15/18] x86, irq, ACPI: Implement interface to support ACPI based IOAPIC hot-addition Jiang Liu
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Jiang Liu @ 2014-10-27 5:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, Len Brown, Pavel Machek, x86
Cc: Jiang Liu, Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck,
Joerg Roedel, Greg Kroah-Hartman, linux-kernel, linux-pci,
linux-acpi, linux-pm
We are going to support ACPI based IOAPIC hotplug, so introduce a rwsem
to protect IOAPIC data structures from IOAPIC hotplug. We choose to
serialize in ACPI instead of in the IOAPIC core because:
1) currently we are only plan to support ACPI based IOAPIC hotplug
2) it's much more cleaner and easier
3) It does't affect IOAPIC discovered by devicetree, SFI and mpparse.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
arch/x86/kernel/acpi/boot.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e077c080a519..3f6b665f5aa6 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -76,6 +76,19 @@ int acpi_fix_pin2_polarity __initdata;
static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
#endif
+/*
+ * Locks related to IOAPIC hotplug
+ * Hotplug side:
+ * ->lock_device_hotplug() //device_hotplug_lock
+ * ->acpi_ioapic_rwsem
+ * ->ioapic_lock
+ * Interrupt mapping side:
+ * ->acpi_ioapic_rwsem
+ * ->ioapic_mutex
+ * ->ioapic_lock
+ */
+static DECLARE_RWSEM(acpi_ioapic_rwsem);
+
/* --------------------------------------------------------------------------
Boot-time Configuration
-------------------------------------------------------------------------- */
@@ -609,8 +622,10 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
*irqp = gsi;
} else {
+ down_read(&acpi_ioapic_rwsem);
irq = mp_map_gsi_to_irq(gsi,
IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
+ up_read(&acpi_ioapic_rwsem);
if (irq < 0)
return -1;
*irqp = irq;
@@ -651,7 +666,9 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
int irq = gsi;
#ifdef CONFIG_X86_IO_APIC
+ down_read(&acpi_ioapic_rwsem);
irq = mp_register_gsi(dev, gsi, trigger, polarity);
+ up_read(&acpi_ioapic_rwsem);
#endif
return irq;
@@ -660,7 +677,9 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
static void acpi_unregister_gsi_ioapic(u32 gsi)
{
#ifdef CONFIG_X86_IO_APIC
+ down_read(&acpi_ioapic_rwsem);
mp_unregister_gsi(gsi);
+ up_read(&acpi_ioapic_rwsem);
#endif
}
@@ -1186,7 +1205,9 @@ static void __init acpi_process_madt(void)
/*
* Parse MADT IO-APIC entries
*/
+ down_write(&acpi_ioapic_rwsem);
error = acpi_parse_madt_ioapic_entries();
+ up_write(&acpi_ioapic_rwsem);
if (!error) {
acpi_set_irq_model_ioapic();
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Patch v7 14/18] x86, irq, ACPI: Introduce a rwsem to protect IOAPIC operations from hotplug
2014-10-27 5:21 ` [Patch v7 14/18] x86, irq, ACPI: Introduce a rwsem to protect IOAPIC operations from hotplug Jiang Liu
@ 2014-11-01 18:59 ` Thomas Gleixner
2014-11-02 5:24 ` Jiang Liu
0 siblings, 1 reply; 12+ messages in thread
From: Thomas Gleixner @ 2014-11-01 18:59 UTC (permalink / raw)
To: Jiang Liu
Cc: Benjamin Herrenschmidt, Ingo Molnar, H. Peter Anvin,
Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap, Yinghai Lu,
Borislav Petkov, Len Brown, Pavel Machek, x86,
Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel, linux-pci, linux-acpi, linux-pm
On Mon, 27 Oct 2014, Jiang Liu wrote:
> We are going to support ACPI based IOAPIC hotplug, so introduce a rwsem
> to protect IOAPIC data structures from IOAPIC hotplug. We choose to
> serialize in ACPI instead of in the IOAPIC core because:
> 1) currently we are only plan to support ACPI based IOAPIC hotplug
> 2) it's much more cleaner and easier
> 3) It does't affect IOAPIC discovered by devicetree, SFI and mpparse.
I had a last intensive look at this series as I was about to merge
it. So I looked at the locking rules here again
> +/*
> + * Locks related to IOAPIC hotplug
> + * Hotplug side:
> + * ->lock_device_hotplug() //device_hotplug_lock
> + * ->acpi_ioapic_rwsem
> + * ->ioapic_lock
> + * Interrupt mapping side:
> + * ->acpi_ioapic_rwsem
> + * ->ioapic_mutex
> + * ->ioapic_lock
> + */
This looks sane, but I cannot figure out at all why this needs to be a
rwsem.
> +static DECLARE_RWSEM(acpi_ioapic_rwsem);
I think it should be a simple mutex because the rwsem does not protect
against concurrent execution what taken for read.
And the site which takes it for write is in the early boot process
where nothing runs in parallel AFAICT.
Thanks,
tglx
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Patch v7 14/18] x86, irq, ACPI: Introduce a rwsem to protect IOAPIC operations from hotplug
2014-11-01 18:59 ` Thomas Gleixner
@ 2014-11-02 5:24 ` Jiang Liu
0 siblings, 0 replies; 12+ messages in thread
From: Jiang Liu @ 2014-11-02 5:24 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Benjamin Herrenschmidt, Ingo Molnar, H. Peter Anvin,
Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap, Yinghai Lu,
Borislav Petkov, Len Brown, Pavel Machek, x86,
Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel, linux-pci, linux-acpi, linux-pm
On 2014/11/2 2:59, Thomas Gleixner wrote:
> On Mon, 27 Oct 2014, Jiang Liu wrote:
>> We are going to support ACPI based IOAPIC hotplug, so introduce a rwsem
>> to protect IOAPIC data structures from IOAPIC hotplug. We choose to
>> serialize in ACPI instead of in the IOAPIC core because:
>> 1) currently we are only plan to support ACPI based IOAPIC hotplug
>> 2) it's much more cleaner and easier
>> 3) It does't affect IOAPIC discovered by devicetree, SFI and mpparse.
>
> I had a last intensive look at this series as I was about to merge
> it. So I looked at the locking rules here again
>
>> +/*
>> + * Locks related to IOAPIC hotplug
>> + * Hotplug side:
>> + * ->lock_device_hotplug() //device_hotplug_lock
>> + * ->acpi_ioapic_rwsem
>> + * ->ioapic_lock
>> + * Interrupt mapping side:
>> + * ->acpi_ioapic_rwsem
>> + * ->ioapic_mutex
>> + * ->ioapic_lock
>> + */
>
> This looks sane, but I cannot figure out at all why this needs to be a
> rwsem.
>
>> +static DECLARE_RWSEM(acpi_ioapic_rwsem);
>
> I think it should be a simple mutex because the rwsem does not protect
> against concurrent execution what taken for read.
>
> And the site which takes it for write is in the early boot process
> where nothing runs in parallel AFAICT.
Hi Thomas,
You are right. It's not on hot path, so a mutex is better than
a rwsem here. I will send out an updated version soon.
Regards!
Gerry
>
> Thanks,
>
> tglx
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Patch v7 15/18] x86, irq, ACPI: Implement interface to support ACPI based IOAPIC hot-addition
[not found] <1414387308-27148-1-git-send-email-jiang.liu@linux.intel.com>
` (2 preceding siblings ...)
2014-10-27 5:21 ` [Patch v7 14/18] x86, irq, ACPI: Introduce a rwsem to protect IOAPIC operations from hotplug Jiang Liu
@ 2014-10-27 5:21 ` Jiang Liu
2014-10-27 5:21 ` [Patch v7 16/18] x86, irq, ACPI: Implement interfaces to support ACPI based IOAPIC hot-removal Jiang Liu
2014-10-27 5:21 ` [Patch v7 17/18] x86, irq: Introduce helper to check whether an IOAPIC has been registered Jiang Liu
5 siblings, 0 replies; 12+ messages in thread
From: Jiang Liu @ 2014-10-27 5:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, Len Brown, Pavel Machek, x86,
Jiang Liu, Grant Likely, Prarit Bhargava
Cc: Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel, linux-pci, linux-acpi,
Ingo Molnar, linux-pm
Implement acpi_register_ioapic() and enhance mp_register_ioapic()
to support ACPI based IOAPIC hot-addition.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
arch/x86/kernel/acpi/boot.c | 31 +++++++++++++++++++++++++++++--
arch/x86/kernel/apic/io_apic.c | 22 +++++++++++++++++++++-
2 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 3f6b665f5aa6..8205f6381d77 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -779,8 +779,35 @@ EXPORT_SYMBOL(acpi_unmap_lsapic);
int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
{
- /* TBD */
- return -EINVAL;
+ int ret = -ENOSYS;
+#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
+ int ioapic_id;
+ u64 addr;
+ struct ioapic_domain_cfg cfg = {
+ .type = IOAPIC_DOMAIN_DYNAMIC,
+ .ops = &acpi_irqdomain_ops,
+ };
+
+ ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
+ if (ioapic_id < 0) {
+ unsigned long long uid;
+ acpi_status status;
+
+ status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
+ NULL, &uid);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_warn(handle, "failed to get IOAPIC ID.\n");
+ return -EINVAL;
+ }
+ ioapic_id = (int)uid;
+ }
+
+ down_write(&acpi_ioapic_rwsem);
+ ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg);
+ up_write(&acpi_ioapic_rwsem);
+#endif
+
+ return ret;
}
EXPORT_SYMBOL(acpi_register_ioapic);
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 59267659e5b1..4d9d87cc3259 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3853,7 +3853,13 @@ static int bad_ioapic_register(int idx)
static int find_free_ioapic_entry(void)
{
- return nr_ioapics;
+ int idx;
+
+ for (idx = 0; idx < MAX_IO_APICS; idx++)
+ if (ioapics[idx].nr_registers == 0)
+ return idx;
+
+ return MAX_IO_APICS;
}
/**
@@ -3869,6 +3875,7 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base,
u32 gsi_end;
int idx, ioapic, entries;
struct mp_ioapic_gsi *gsi_cfg;
+ bool hotplug = !!ioapic_initialized;
if (!address) {
pr_warn("Bogus (zero) I/O APIC address found, skipping!\n");
@@ -3927,6 +3934,19 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base,
ioapics[idx].irqdomain = NULL;
ioapics[idx].irqdomain_cfg = *cfg;
+ /*
+ * If mp_register_ioapic() is called during early boot stage when
+ * walking ACPI/SFI/DT tables, it's too early to create irqdomain,
+ * we are still using bootmem allocator. So delay it to setup_IO_APIC().
+ */
+ if (hotplug) {
+ if (mp_irqdomain_create(idx)) {
+ clear_fixmap(FIX_IO_APIC_BASE_0 + idx);
+ return -ENOMEM;
+ }
+ alloc_ioapic_saved_registers(idx);
+ }
+
if (gsi_cfg->gsi_end >= gsi_top)
gsi_top = gsi_cfg->gsi_end + 1;
if (nr_ioapics <= idx)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Patch v7 16/18] x86, irq, ACPI: Implement interfaces to support ACPI based IOAPIC hot-removal
[not found] <1414387308-27148-1-git-send-email-jiang.liu@linux.intel.com>
` (3 preceding siblings ...)
2014-10-27 5:21 ` [Patch v7 15/18] x86, irq, ACPI: Implement interface to support ACPI based IOAPIC hot-addition Jiang Liu
@ 2014-10-27 5:21 ` Jiang Liu
2014-10-27 5:21 ` [Patch v7 17/18] x86, irq: Introduce helper to check whether an IOAPIC has been registered Jiang Liu
5 siblings, 0 replies; 12+ messages in thread
From: Jiang Liu @ 2014-10-27 5:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, x86, Len Brown, Pavel Machek,
Jiang Liu, Grant Likely, Prarit Bhargava
Cc: Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel, linux-pci, linux-acpi,
Ingo Molnar, linux-pm
Implement acpi_unregister_ioapic() to support ACPI based IOAPIC hot-removal.
An IOAPIC could only be removed when all its pins are unused.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
arch/x86/include/asm/io_apic.h | 1 +
arch/x86/kernel/acpi/boot.c | 13 +++++++---
arch/x86/kernel/apic/io_apic.c | 55 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 8741c1ea33c3..7c04b8ec22a4 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -190,6 +190,7 @@ extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags);
extern void mp_unmap_irq(int irq);
extern int mp_register_ioapic(int id, u32 address, u32 gsi_base,
struct ioapic_domain_cfg *cfg);
+extern int mp_unregister_ioapic(u32 gsi_base);
extern int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq);
extern void mp_irqdomain_unmap(struct irq_domain *domain, unsigned int virq);
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 8205f6381d77..bc61a5c0e7b6 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -809,15 +809,20 @@ int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
return ret;
}
-
EXPORT_SYMBOL(acpi_register_ioapic);
int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
{
- /* TBD */
- return -EINVAL;
-}
+ int ret = -ENOSYS;
+
+#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
+ down_write(&acpi_ioapic_rwsem);
+ ret = mp_unregister_ioapic(gsi_base);
+ up_write(&acpi_ioapic_rwsem);
+#endif
+ return ret;
+}
EXPORT_SYMBOL(acpi_unregister_ioapic);
static int __init acpi_parse_sbf(struct acpi_table_header *table)
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 4d9d87cc3259..9e5432ee2070 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -112,6 +112,7 @@ static struct ioapic {
struct ioapic_domain_cfg irqdomain_cfg;
struct irq_domain *irqdomain;
struct mp_pin_info *pin_info;
+ struct resource *iomem_res;
} ioapics[MAX_IO_APICS];
#define mpc_ioapic_ver(ioapic_idx) ioapics[ioapic_idx].mp_config.apicver
@@ -250,6 +251,12 @@ static void alloc_ioapic_saved_registers(int idx)
pr_err("IOAPIC %d: suspend/resume impossible!\n", idx);
}
+static void free_ioapic_saved_registers(int idx)
+{
+ kfree(ioapics[idx].saved_registers);
+ ioapics[idx].saved_registers = NULL;
+}
+
int __init arch_early_irq_init(void)
{
struct irq_cfg *cfg;
@@ -2973,6 +2980,16 @@ static int mp_irqdomain_create(int ioapic)
return 0;
}
+static void ioapic_destroy_irqdomain(int idx)
+{
+ if (ioapics[idx].irqdomain) {
+ irq_domain_remove(ioapics[idx].irqdomain);
+ ioapics[idx].irqdomain = NULL;
+ }
+ kfree(ioapics[idx].pin_info);
+ ioapics[idx].pin_info = NULL;
+}
+
void __init setup_IO_APIC(void)
{
int ioapic;
@@ -3735,6 +3752,7 @@ static struct resource * __init ioapic_setup_resources(void)
snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i);
mem += IOAPIC_RESOURCE_NAME_SIZE;
num++;
+ ioapics[i].iomem_res = res;
}
ioapic_resources = res;
@@ -3963,6 +3981,43 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base,
return 0;
}
+int mp_unregister_ioapic(u32 gsi_base)
+{
+ int ioapic, pin;
+ int found = 0;
+ struct mp_pin_info *pin_info;
+
+ for_each_ioapic(ioapic)
+ if (ioapics[ioapic].gsi_config.gsi_base == gsi_base) {
+ found = 1;
+ break;
+ }
+ if (!found) {
+ pr_warn("can't find IOAPIC for GSI %d\n", gsi_base);
+ return -ENODEV;
+ }
+
+ for_each_pin(ioapic, pin) {
+ pin_info = mp_pin_info(ioapic, pin);
+ if (pin_info->count) {
+ pr_warn("pin%d on IOAPIC%d is still in use.\n",
+ pin, ioapic);
+ return -EBUSY;
+ }
+ }
+
+ /* Mark entry not present */
+ ioapics[ioapic].nr_registers = 0;
+ ioapic_destroy_irqdomain(ioapic);
+ free_ioapic_saved_registers(ioapic);
+ if (ioapics[ioapic].iomem_res)
+ release_resource(ioapics[ioapic].iomem_res);
+ clear_fixmap(FIX_IO_APIC_BASE_0 + ioapic);
+ memset(&ioapics[ioapic], 0, sizeof(ioapics[ioapic]));
+
+ return 0;
+}
+
int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq)
{
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Patch v7 17/18] x86, irq: Introduce helper to check whether an IOAPIC has been registered
[not found] <1414387308-27148-1-git-send-email-jiang.liu@linux.intel.com>
` (4 preceding siblings ...)
2014-10-27 5:21 ` [Patch v7 16/18] x86, irq, ACPI: Implement interfaces to support ACPI based IOAPIC hot-removal Jiang Liu
@ 2014-10-27 5:21 ` Jiang Liu
2014-10-28 17:47 ` Pavel Machek
5 siblings, 1 reply; 12+ messages in thread
From: Jiang Liu @ 2014-10-27 5:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, x86, Len Brown, Pavel Machek,
Jiang Liu, Grant Likely, Prarit Bhargava
Cc: Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck, Joerg Roedel,
Greg Kroah-Hartman, linux-kernel, linux-pci, linux-acpi,
Ingo Molnar, linux-pm
Introduce acpi_ioapic_registered() to check whether an IOAPIC has already
been registered, it will be used when enabling IOAPIC hotplug.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
arch/x86/include/asm/io_apic.h | 1 +
arch/x86/kernel/acpi/boot.c | 22 ++++++++++++++++++++++
arch/x86/kernel/apic/io_apic.c | 11 +++++++++++
include/linux/acpi.h | 1 +
4 files changed, 35 insertions(+)
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 7c04b8ec22a4..ca742d5249db 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -191,6 +191,7 @@ extern void mp_unmap_irq(int irq);
extern int mp_register_ioapic(int id, u32 address, u32 gsi_base,
struct ioapic_domain_cfg *cfg);
extern int mp_unregister_ioapic(u32 gsi_base);
+extern int mp_ioapic_registered(u32 gsi_base);
extern int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq);
extern void mp_irqdomain_unmap(struct irq_domain *domain, unsigned int virq);
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index bc61a5c0e7b6..f27b33194e06 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -825,6 +825,28 @@ int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
}
EXPORT_SYMBOL(acpi_unregister_ioapic);
+/**
+ * acpi_ioapic_registered - Check whether IOAPIC assoicatied with @gsi_base
+ * has been registered
+ * @handle: ACPI handle of the IOAPIC deivce
+ * @gsi_base: GSI base associated with the IOAPIC
+ *
+ * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
+ * with acpi_register_ioapic()/acpi_unregister_ioapic().
+ */
+int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base)
+{
+ int ret = 0;
+
+#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
+ down_read(&acpi_ioapic_rwsem);
+ ret = mp_ioapic_registered(gsi_base);
+ up_read(&acpi_ioapic_rwsem);
+#endif
+
+ return ret;
+}
+
static int __init acpi_parse_sbf(struct acpi_table_header *table)
{
struct acpi_table_boot *sb;
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 9e5432ee2070..df3858de3031 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -4018,6 +4018,17 @@ int mp_unregister_ioapic(u32 gsi_base)
return 0;
}
+int mp_ioapic_registered(u32 gsi_base)
+{
+ int ioapic;
+
+ for_each_ioapic(ioapic)
+ if (ioapics[ioapic].gsi_config.gsi_base == gsi_base)
+ return 1;
+
+ return 0;
+}
+
int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq)
{
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 77cecd0350e7..be6be0f91337 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -152,6 +152,7 @@ int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
+int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
void acpi_irq_stats_init(void);
extern u32 acpi_irq_handled;
extern u32 acpi_irq_not_handled;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Patch v7 17/18] x86, irq: Introduce helper to check whether an IOAPIC has been registered
2014-10-27 5:21 ` [Patch v7 17/18] x86, irq: Introduce helper to check whether an IOAPIC has been registered Jiang Liu
@ 2014-10-28 17:47 ` Pavel Machek
0 siblings, 0 replies; 12+ messages in thread
From: Pavel Machek @ 2014-10-28 17:47 UTC (permalink / raw)
To: Jiang Liu
Cc: Benjamin Herrenschmidt, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Rafael J. Wysocki, Bjorn Helgaas, Randy Dunlap,
Yinghai Lu, Borislav Petkov, x86, Len Brown, Grant Likely,
Prarit Bhargava, Konrad Rzeszutek Wilk, Andrew Morton, Tony Luck,
Joerg Roedel, Greg Kroah-Hartman, linux-kernel, linux-pci,
linux-acpi, Ingo Molnar, linux-pm
On Mon 2014-10-27 13:21:47, Jiang Liu wrote:
> Introduce acpi_ioapic_registered() to check whether an IOAPIC has already
> been registered, it will be used when enabling IOAPIC hotplug.
>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Nothing obviously wrong.
Acked-by: Pavel Machek <pavel@ucw.cz>
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 12+ messages in thread