Skip to contentSkip to conversation

sparc64: sparse irq

PATCH In review Bob Picco 2 participants 12 messages Sep 17, 2014 – Sep 25, 2014 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Bob Picco

author
#0 lore raw

PATCH v3 1/1 sparc64: sparse irq

From: bob picco <[email protected]>

This patch attempts to do a few things. The highlights are: 1) enable SPARSE_IRQ unconditionally, 2) kills off !SPARSE_IRQ code 3) allocates ivector_table at boot time and 4) default to cookie only VIRQ mechanism for supported firmware. The first firmware with cookie only support for me appears on T5. You can optionally force the HV firmware to not cookie only mode which is the sysino support.

The sysino is a deprecated HV mechanism according to the most recent SPARC Virtual Machine Specification. HV_GRP_INTR is what controls the cookie/sysino firmware versioning. The history appears to be something like this:
major version 2 was dropped.
major version 3 is where a cookie only VIRQ
is possible. Using version 3 means ivector_table isn't required.

A new boot option is provided should cookie only HV support have issues. hvirq - this is the version for HV_GRP_INTR. This is related to HV API versioning. The code attempts major=3 first by default. The option can be used to override this default.

I've tested with SPARSE_IRQ on T5-8, M7-4 and T4-X and Jalap?no.

---
V3: kill off !SPARSE_IRQ code and conditional code.
Update commit log and learn to bite the bullet.
V2: default to SPARSE_IRQ.
numa_node_id() used as argument to __irq_alloc_descs(). timer_irq_action is reason for IRQ 0 being special. NR_IRQ to 2048.

 arch/sparc/Kconfig              |    1 +
 arch/sparc/include/asm/irq_64.h |    7 +-
 arch/sparc/kernel/irq_64.c      |  485 +++++++++++++++++++++++++--------------
 3 files changed, 319 insertions(+), 174 deletions(-)
arch/sparc/Kconfig +1 -0
index a537816..96ac69c 100644
@@ -67,6 +67,7 @@ config SPARC64
 	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_CONTEXT_TRACKING
 	select HAVE_DEBUG_KMEMLEAK
+	select SPARSE_IRQ
 	select RTC_DRV_CMOS
 	select RTC_DRV_BQ4802
 	select RTC_DRV_SUN4V
arch/sparc/include/asm/irq_64.h +2 -5
index 91d2193..3f70f90 100644
@@ -37,7 +37,7 @@
  *
  * ino_bucket->irq allocation is made during {sun4v_,}build_irq().
  */
-#define NR_IRQS    255
+#define NR_IRQS		(2048)
 
 void irq_install_pre_handler(int irq,
 			     void (*func)(unsigned int, void *, void *),
@@ -57,11 +57,8 @@ unsigned int sun4u_build_msi(u32 portid, unsigned int *irq_p,
 			     unsigned long iclr_base);
 void sun4u_destroy_msi(unsigned int irq);
 
-unsigned char irq_alloc(unsigned int dev_handle,
-			unsigned int dev_ino);
-#ifdef CONFIG_PCI_MSI
+unsigned int irq_alloc(unsigned int dev_handle, unsigned int dev_ino);
 void irq_free(unsigned int irq);
-#endif
 
 void __init init_IRQ(void);
 void fixup_irqs(void);
arch/sparc/kernel/irq_64.c +316 -169

656 lines not on this page · raw message

Signature · 1 line
1.7.1
maintainer
#1 lore raw

From: Bob Picco <[email protected]>
Date: Wed, 17 Sep 2014 15:31:28 -0400

Quoted 1 line

I've tested with SPARSE_IRQ on T5-8, M7-4 and T4-X and Jalap?no.

I'm currently reviewing this, and I have to ask if any of your Niagara test scenerios had a hypervisor with HV_GRP_INTR major < 3?

I have a sense that the legacy hypervisor case wasn't covered, and it seems that this patch will emit an ugly log message when that situation is triggered which probably isn't appropriate as the event isn't an error. It's just an older hypervisor that lacks cookie only VIRQ support.

author
#2 lore raw
In reply to Bob Picco

Hi,
David Miller wrote: [Thu Sep 25 2014, 11:53:21AM EDT]

Quoted 5 lines

From: Bob Picco <[email protected]>
Date: Wed, 17 Sep 2014 15:31:28 -0400

Quoted 1 line

I've tested with SPARSE_IRQ on T5-8, M7-4 and T4-X and Jalap?no.

Quoted 8 lines

I'm currently reviewing this, and I have to ask if any of your Niagara test scenerios had a hypervisor with HV_GRP_INTR major < 3?

I have a sense that the legacy hypervisor case wasn't covered, and it seems that this patch will emit an ugly log message when that situation is triggered which probably isn't appropriate as the event isn't an error. It's just an older hypervisor that lacks cookie only VIRQ support.

Yes this issue actually came up indirectly yesterday. Some T4-X will have legacy sysino and some cookie. Though I've never seen a T4-X with cookie. For example an older T4 with older HV firmware has this:
[root@ca-qasparc14 bugdb-19677751.d]# dmesg | grep hv_error

[    0.000000] irq_group_hv.129 hv_error = -22 major = 3

on an older kernel. I totally forgot about this issue.

You might have additional feedback. So please let me know whether you'd like another version of the patch.

maintainer
#3 lore raw
In reply to Bob Picco

From: Bob Picco <[email protected]>
Date: Wed, 17 Sep 2014 15:31:28 -0400

Quoted 6 lines

SPARC Virtual Machine Specification. HV_GRP_INTR is what controls the cookie/sysino firmware versioning. The history appears to be something like this:
major version 2 was dropped.
major version 3 is where a cookie only VIRQ
is possible. Using version 3 means ivector_table isn't required.

Can I get some clarification on this?

Major version 2 of HV_GRP_INTR was meant to behave the way that you say major version 3 does.

My understanding is that due to Solaris erratum 6496266, the hypervisor has to provide the VIRQ cookie interfaces even if the guest only negotiates major version 1.

So supposedly, major version 3 was provided to untangle this mess.

Can you clear this up for me?

Thanks.

maintainer
#4 lore raw
In reply to Bob Picco

From: Bob Picco <[email protected]>
Date: Thu, 25 Sep 2014 12:20:05 -0400

Quoted 3 lines

Yes this issue actually came up indirectly yesterday. Some T4-X will have legacy sysino and some cookie. Though I've never seen a T4-X with cookie. For example an older T4 with older HV firmware has this:

Ok. Presumably, these systems support major=2 HV_GRP_IRQ. Even back to Huron and Ontario hypervisors I see major=2 support present.

Quoted 6 lines

[root@ca-qasparc14 bugdb-19677751.d]# dmesg | grep hv_error

[    0.000000] irq_group_hv.129 hv_error = -22 major = 3

on an older kernel. I totally forgot about this issue.

You might have additional feedback. So please let me know whether you'd like another version of the patch.

If we agree about the log message, I can just kill it off myself when applying your patch.

author
#5 lore raw
In reply to Bob Picco

David Miller wrote: [Thu Sep 25 2014, 12:35:20PM EDT]

Quoted 11 lines

From: Bob Picco <[email protected]>
Date: Wed, 17 Sep 2014 15:31:28 -0400

Quoted 6 lines

SPARC Virtual Machine Specification. HV_GRP_INTR is what controls the cookie/sysino firmware versioning. The history appears to be something like this:
major version 2 was dropped.
major version 3 is where a cookie only VIRQ
is possible. Using version 3 means ivector_table isn't required.

Can I get some clarification on this?

I'll attempt to but will have to make an inquiry. For me this came during debug of painful P0 hardware.

Quoted 3 lines

Major version 2 of HV_GRP_INTR was meant to behave the way that you say major version 3 does.

This is what I recall but could be incorrect.

Quoted 4 lines

My understanding is that due to Solaris erratum 6496266, the hypervisor has to provide the VIRQ cookie interfaces even if the guest only negotiates major version 1.

Possibly for newer firmware but uncertain.

Quoted 2 lines

So supposedly, major version 3 was provided to untangle this mess.

This is what I observed but obviously could have been incorrect.

Quoted 2 lines

Can you clear this up for me?

I'll attempt to but consider this example. M7 was dead in the water, except for my M7, because of an HV change which impacted sysino and cookies. So it is possibe the firmware I observed this issue was never released?

Quoted 3 lines

Thanks.

you're welcome.

author
#6 lore raw
In reply to Bob Picco

David Miller wrote: [Thu Sep 25 2014, 12:42:54PM EDT]

Quoted 14 lines

From: Bob Picco <[email protected]>
Date: Thu, 25 Sep 2014 12:20:05 -0400

Quoted 3 lines

Yes this issue actually came up indirectly yesterday. Some T4-X will have legacy sysino and some cookie. Though I've never seen a T4-X with cookie. For example an older T4 with older HV firmware has this:

Ok. Presumably, these systems support major=2 HV_GRP_IRQ. Even back to Huron and Ontario hypervisors I see major=2 support present.

Quoted 4 lines

[root@ca-qasparc14 bugdb-19677751.d]# dmesg | grep hv_error

[    0.000000] irq_group_hv.129 hv_error = -22 major = 3

on an older kernel. I totally forgot about this issue.

Quoted 5 lines
Quoted 2 lines

You might have additional feedback. So please let me know whether you'd like another version of the patch.

If we agree about the log message, I can just kill it off myself when applying your patch.

We agree.

maintainer
#7 lore raw
In reply to Bob Picco

From: Bob Picco <[email protected]>
Date: Thu, 25 Sep 2014 13:14:18 -0400

Quoted 7 lines

David Miller wrote: [Thu Sep 25 2014, 12:35:20PM EDT]

Quoted 5 lines

From: Bob Picco <[email protected]>
Date: Wed, 17 Sep 2014 15:31:28 -0400

Major version 2 of HV_GRP_INTR was meant to behave the way that you say major version 3 does.

This is what I recall but could be incorrect.

I an attempt to test this, I'm using your patch but I modified it to negotiate HV_GRP_INTR major=2 and then use the cookie only routines if that succeeded.

The negotiation of major=2 works, but hv calls fail with EINVAL and other strange things.

Trying to investigate further, because making this work with major=2 would be great because we could avoid the ivector table allocation on even more machines.

author
#8 lore raw
In reply to Bob Picco

David Miller wrote: [Thu Sep 25 2014, 01:34:20PM EDT]

Quoted 15 lines

From: Bob Picco <[email protected]>
Date: Thu, 25 Sep 2014 13:14:18 -0400

Quoted 7 lines

David Miller wrote: [Thu Sep 25 2014, 12:35:20PM EDT]

Quoted 5 lines

From: Bob Picco <[email protected]>
Date: Wed, 17 Sep 2014 15:31:28 -0400

Major version 2 of HV_GRP_INTR was meant to behave the way that you say major version 3 does.

This is what I recall but could be incorrect.

I an attempt to test this, I'm using your patch but I modified it to negotiate HV_GRP_INTR major=2 and then use the cookie only routines if that succeeded.

Quoted 6 lines

The negotiation of major=2 works, but hv calls fail with EINVAL and other strange things.

Trying to investigate further, because making this work with major=2 would be great because we could avoid the ivector table allocation on even more machines.

Now that I understand your motivation.
Okay. I just looked quickly at the current specification for UltraSPARC Virtualization which possibly isn't publicly available.
For Group HV_GRP_INTR 1.X and 3.X are supported. 2.X was declared broken. This I didn't have accessible to me at the time of debug. Also one needs to read with extreme caution.

maintainer
#9 lore raw
In reply to Bob Picco

From: David Miller <[email protected]>
Date: Thu, 25 Sep 2014 13:34:20 -0400 (EDT)

Quoted 10 lines

In an attempt to test this, I'm using your patch but I modified it to negotiate HV_GRP_INTR major=2 and then use the cookie only routines if that succeeded.

The negotiation of major=2 works, but hv calls fail with EINVAL and other strange things.

Trying to investigate further, because making this work with major=2 would be great because we could avoid the ivector table allocation on even more machines.

Ok the problem is that with pre-major=3 supporting hypervisors, it looks like VIRQs are only supported for LDC interrupts.

So we really do need major>=3 for cookie-only system wide.

maintainer
#10 lore raw
In reply to Bob Picco

Ok Bob, I think I've resolved everything, and I made some minor adjustments to your patch. The final version is below and works well for me.

The changes I made were roughly:

1) Add a helper test function sun4v_cookie_only_virqs()

2) Put a big comment above that function explaining the version behaviors. Adjust the commit log message to match.

3) Don't bark in the kernel log if the negoatiation fails. But do print an informative message about what style of IRQs we are going to use.

4) Minor indentation fixes here and there.

Let me know if this works for you:

==========
From 4ded0847fb9988d13d9e1315f18c8d6e9da45aea Mon Sep 17 00:00:00 2001
From: bob picco <[email protected]>
Date: Thu, 25 Sep 2014 12:25:03 -0700
Subject: [PATCH] sparc64: sparse irq

This patch attempts to do a few things. The highlights are: 1) enable SPARSE_IRQ unconditionally, 2) kills off !SPARSE_IRQ code 3) allocates ivector_table at boot time and 4) default to cookie only VIRQ mechanism for supported firmware. The first firmware with cookie only support for me appears on T5. You can optionally force the HV firmware to not cookie only mode which is the sysino support.

The sysino is a deprecated HV mechanism according to the most recent SPARC Virtual Machine Specification. HV_GRP_INTR is what controls the cookie/sysino firmware versioning.

The history of this interface is:

1) Major version 1.0 only supported sysino based interrupt interfaces.

2) Major version 2.0 added cookie based VIRQs, however due to the fact that OSs were using the VIRQs without negoatiating major version 2.0 (Linux and Solaris are both guilty), the VIRQs calls were allowed even with major version 1.0

To complicate things even further, the VIRQ interfaces were only actually hooked up in the hypervisor for LDC interrupt sources. VIRQ calls on other device types would result in HV_EINVAL errors.

So effectively, major version 2.0 is unusable.

3) Major version 3.0 was created to signal use of VIRQs and the fact that the hypervisor has these calls hooked up for all interrupt sources, not just those for LDC devices.

A new boot option is provided should cookie only HV support have issues. hvirq - this is the version for HV_GRP_INTR. This is related to HV API versioning. The code attempts major=3 first by default. The option can be used to override this default.

I've tested with SPARSE_IRQ on T5-8, M7-4 and T4-X and Jalap?no.

---
 arch/sparc/Kconfig              |   1 +
 arch/sparc/include/asm/irq_64.h |   7 +-
 arch/sparc/kernel/irq_64.c      | 507 ++++++++++++++++++++++++++--------------
 3 files changed, 341 insertions(+), 174 deletions(-)
arch/sparc/Kconfig +1 -0
index a537816..96ac69c 100644
@@ -67,6 +67,7 @@ config SPARC64
 	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_CONTEXT_TRACKING
 	select HAVE_DEBUG_KMEMLEAK
+	select SPARSE_IRQ
 	select RTC_DRV_CMOS
 	select RTC_DRV_BQ4802
 	select RTC_DRV_SUN4V
arch/sparc/include/asm/irq_64.h +2 -5
index 91d2193..3f70f90 100644
@@ -37,7 +37,7 @@
  *
  * ino_bucket->irq allocation is made during {sun4v_,}build_irq().
  */
-#define NR_IRQS    255
+#define NR_IRQS		(2048)
 
 void irq_install_pre_handler(int irq,
 			     void (*func)(unsigned int, void *, void *),
@@ -57,11 +57,8 @@ unsigned int sun4u_build_msi(u32 portid, unsigned int *irq_p,
 			     unsigned long iclr_base);
 void sun4u_destroy_msi(unsigned int irq);
 
-unsigned char irq_alloc(unsigned int dev_handle,
-			unsigned int dev_ino);
-#ifdef CONFIG_PCI_MSI
+unsigned int irq_alloc(unsigned int dev_handle, unsigned int dev_ino);
 void irq_free(unsigned int irq);
-#endif
 
 void __init init_IRQ(void);
 void fixup_irqs(void);
arch/sparc/kernel/irq_64.c +338 -169

678 lines not on this page · raw message

Signature · 1 line
1.8.1.2
author
#11 lore raw
In reply to Bob Picco

David Miller wrote: [Thu Sep 25 2014, 03:28:29PM EDT]

Quoted 12 lines

Ok Bob, I think I've resolved everything, and I made some minor adjustments to your patch. The final version is below and works well for me.

The changes I made were roughly:

1) Add a helper test function sun4v_cookie_only_virqs()

2) Put a big comment above that function explaining the version behaviors. Adjust the commit log message to match.

Quoted 7 lines

3) Don't bark in the kernel log if the negoatiation fails. But do print an informative message about what style of IRQs we are going to use.

4) Minor indentation fixes here and there.

Let me know if this works for you:

Looks good to me. I also learned what caused me much pain.

thanx!