Skip to contentSkip to conversation

small fixes for PCI devices in mptable

PATCH In review Cyrill Gorcunov 3 participants 11 messages May 7, 2011 KVM

lore
Share & tools
lore
#0 lore raw

cover small fixes for PCI devices in mptable

Please review.

Thanks,
Cyrill

#1 lore raw

PATCH 1/2 kvm tools: Fix up PCI pin assignment to conform specification

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

---
 tools/kvm/irq.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/kvm/irq.c +7 -2
Index: linux-2.6.git/tools/kvm/irq.c
=====================================================================
@@ -7,7 +7,6 @@
 #include <stddef.h>
 #include <stdlib.h>
 
-static u8		next_pin	= 1;
 static u8		next_line	= 3;
 static u8		next_dev	= 1;
 static struct rb_root	pci_tree	= RB_ROOT;
@@ -71,7 +70,13 @@ int irq__register_device(u32 dev, u8 *nu
 
 		*node = (struct pci_dev) {
 			.id	= dev,
-			.pin	= next_pin++,
+			/*
+			 * PCI supports only INTA#,B#,C#,D# per device.
+			 * B#,C#,D# are allowed for multifunctional
+			 * devices so stick with INTA# for our single
+			 * function devices.
+			 */
+			.pin	= 1,
 		};
 
 		INIT_LIST_HEAD(&node->lines);
#2 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

Quoted 3 lines · Cyrill Gorcunov

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

There's two typos in this changelog ...

Thanks,

Ingo

#3 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

Quoted 7 lines · Ingo Molnar
Quoted 3 lines · Cyrill Gorcunov

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

Quoted 5 lines

There's two typos in this changelog ...

Thanks,

Ingo

Ouch, I've fixed 'sindle', but missed 'compilant', thanks Ingo!

Pekka if you pick them (second series), could you s/compilant/compliant/ please?

Signature · 2 lines
Thanks,
  Cyrill
#4 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

Quoted 10 lines · Cyrill Gorcunov
Quoted 9 lines · Ingo Molnar
Quoted 3 lines · Cyrill Gorcunov

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

There's two typos in this changelog ...

Quoted 8 lines
Quoted 3 lines

Thanks,

Ingo

Ouch, I've fixed 'sindle', but missed 'compilant', thanks Ingo!

Pekka if you pick them (second series), could you s/compilant/compliant/ please?

There's a third typo as well: s/Mutlifunctional/Multifunctional.

Thanks,

Ingo

#5 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

On 05/07/2011 07:08 PM, Ingo Molnar wrote:
..

Quoted 6 lines

There's a third typo as well: s/Mutlifunctional/Multifunctional.

Thanks,

Ingo

Sigh, thanks Ingo.

Signature · 2 lines
Thanks,
  Cyrill
#6 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

In reply to Ingo Molnar
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · Cyrill Gorcunov

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

There's two typos in this changelog ...

Three in fact.

Thanks,

Ingo

#7 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

In reply to Cyrill Gorcunov
Quoted 5 lines · Cyrill Gorcunov

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

Could you point me to the relevant specification and section that I can use to double-check this patch (and include it in the changelog)?

#8 lore raw

Re: [patch 1/2] kvm tools: Fix up PCI pin assignment to conform specification

Quoted 9 lines · Pekka Enberg
Quoted 5 lines · Cyrill Gorcunov

Only 4 pins are allowed for every PCI compilant device. Mutlifunctional devices can use up to all INTA#,B#,C#,D# pins, for our sindle function devices pin INTA# is enough.

Could you point me to the relevant specification and section that I can use to double-check this patch (and include it in the changelog)?

PCI spec 2.2, 2.2.6 Interrupt Pins (Optional)

Signature · 2 lines
Thanks,
  Cyrill
#9 lore raw

PATCH 2/2 kvm tools: mptable -- Fix up srcbusirq assignment for PCI devices

In reply to Cyrill Gorcunov

The kernel expects srcbusirq follows MP specification and consists a tuple of PCI device number with pin encoded. Make it so, otherwise the kernel reports kind of "buggy MP table" found.

---
 tools/kvm/mptable.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/kvm/mptable.c +7 -3
Index: linux-2.6.git/tools/kvm/mptable.c
=====================================================================
@@ -191,12 +191,16 @@ void mptable_setup(struct kvm *kvm, unsi
 
 	for (pci_tree = irq__get_pci_tree(); pci_tree; pci_tree = rb_next(pci_tree)) {
 		struct pci_dev *dev = rb_entry(pci_tree, struct pci_dev, node);
-		struct irq_line *tmp;
+		struct irq_line *irq_line;
+
+		list_for_each_entry(irq_line, &dev->lines, node) {
+			unsigned char srcbusirq;
+
+			srcbusirq = (dev->id << 2) | (dev->pin - 1);
 
-		list_for_each_entry(tmp, &dev->lines, node) {
 			mpc_intsrc = last_addr;
 
-			mptable_add_irq_src(mpc_intsrc, pcibusid, dev->pin, ioapicid, tmp->line);
+			mptable_add_irq_src(mpc_intsrc, pcibusid, dev->pin, ioapicid, irq_line->line);
 			last_addr = (void *)&mpc_intsrc[1];
 			nentries++;
 		}
#10 lore raw

Re: [patch 2/2] kvm tools: mptable -- Fix up srcbusirq assignment for PCI devices

Quoted 24 lines · Cyrill Gorcunov

The kernel expects srcbusirq follows MP specification and consists a tuple of PCI device number with pin encoded. Make it so, otherwise the kernel reports kind of "buggy MP table" found.

---
 tools/kvm/mptable.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6.git/tools/kvm/mptable.c
=====================================================================

tools/kvm/mptable.c +5 -1
@@ -191,12 +191,16 @@ void mptable_setup(struct kvm *kvm, unsi
 
 	for (pci_tree = irq__get_pci_tree(); pci_tree; pci_tree = rb_next(pci_tree)) {
 		struct pci_dev *dev = rb_entry(pci_tree, struct pci_dev, node);
-		struct irq_line *tmp;
+		struct irq_line *irq_line;
+
+		list_for_each_entry(irq_line, &dev->lines, node) {
+			unsigned char srcbusirq;
+

tools/kvm/mptable.c void mptable_setup(struct kvm *kvm, unsi · line 206

Quoted 10 lines
tools/kvm/mptable.c +2 -2
+			srcbusirq = (dev->id << 2) | (dev->pin - 1);
 
-		list_for_each_entry(tmp, &dev->lines, node) {
 			mpc_intsrc = last_addr;
 
-			mptable_add_irq_src(mpc_intsrc, pcibusid, dev->pin, ioapicid, tmp->line);
+			mptable_add_irq_src(mpc_intsrc, pcibusid, dev->pin, ioapicid, irq_line->line);
 			last_addr = (void *)&mpc_intsrc[1];
 			nentries++;
 		}

Crap, forgot to update quilt. Pekka drop this series please.

Signature · 2 lines
Thanks,
  Cyrill