Skip to contentSkip to conversation

kvm tools: Fix IRQ mapping

PATCH In review Sasha Levin 4 participants 7 messages Aug 11, 2011 KVM

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 kvm tools: Use correct size for VESA memory bar

In reply to Sasha Levin

This patch makes BAR 1 16k, instead of BAR0 - which is the PIO bar.

This fixes wrong output on lspci command and ioremap warnings during boot.

---
 tools/kvm/hw/serial.c |    2 +-
 tools/kvm/hw/vesa.c   |    2 +-
 tools/kvm/pci.c       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/kvm/hw/serial.c +1 -1
index 1199264..0393d3d 100644
@@ -213,7 +213,7 @@ static bool serial8250_out(struct ioport *ioport, struct kvm *kvm, u16 port, voi
 		case UART_TX: {
 			char *addr = data;
 
-			if (!(dev->mcr & UART_MCR_LOOP))
+			if (!(dev->mcr & (UART_MCR_LOOP | UART_MCR_OUT2)))
 				term_putc(CONSOLE_8250, addr, size * count);
 
 			dev->iir		= UART_IIR_NO_INT;
tools/kvm/hw/vesa.c +1 -1
index 2af08df..9caa6c4 100644
@@ -39,6 +39,7 @@ static struct pci_device_header vesa_pci_device = {
 	.subsys_vendor_id	= PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
 	.subsys_id		= PCI_SUBSYSTEM_ID_VESA,
 	.bar[1]			= VESA_MEM_ADDR | PCI_BASE_ADDRESS_SPACE_MEMORY,
+	.bar_size[1]		= VESA_MEM_SIZE,
 };
 
 static struct framebuffer vesafb;
@@ -56,7 +57,6 @@ struct framebuffer *vesa__init(struct kvm *kvm)
 	vesa_pci_device.irq_line	= line;
 	vesa_base_addr			= ioport__register(IOPORT_EMPTY, &vesa_io_ops, IOPORT_SIZE, NULL);
 	vesa_pci_device.bar[0]		= vesa_base_addr | PCI_BASE_ADDRESS_SPACE_IO;
-	vesa_pci_device.bar_size[0]	= VESA_MEM_SIZE;
 	pci__register(&vesa_pci_device, dev);
 
 	mem = mmap(NULL, VESA_MEM_SIZE, PROT_RW, MAP_ANON_NORESERVE, -1, 0);
tools/kvm/pci.c +1 -1
index fd19b73..0449aca 100644
@@ -95,7 +95,7 @@ static bool pci_config_data_out(struct ioport *ioport, struct kvm *kvm, u16 port
 		offset = start + (pci_config_address.register_number << 2);
 		if (offset < sizeof(struct pci_device_header)) {
 			void *p = pci_devices[dev_num];
-			u8 bar = offset - PCI_BAR_OFFSET(0);
+			u8 bar = offset - PCI_BAR_OFFSET(0) / (sizeof(u32));
 			u32 sz = PCI_IO_SIZE;
 
 			if (bar < 6 && pci_devices[dev_num]->bar_size[bar])
Signature · 1 line
1.7.6
#0 lore raw

PATCH 1/1 kvm tools: Fix IRQ mapping

This thread fixes two issues:
- Slave IRQCHIP was mapped wrong, this caused all IRQs which belong
to it to be ignored (breaking such things as the mouse).
- Line 2 was being mapped, since it's the link between slave and master
IRQCHIPs it shouldn't be.

---
 tools/kvm/irq.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
tools/kvm/irq.c +4 -3
index 85e2238..e35bf18 100644
@@ -147,17 +147,18 @@ void irq__init(struct kvm *kvm)
 
 	/* Hook first 8 GSIs to master IRQCHIP */
 	for (i = 0; i < 8; i++)
-		irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_MASTER, i);
+		if (i != 2)
+			irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_MASTER, i);
 
 	/* Hook next 8 GSIs to slave IRQCHIP */
 	for (i = 8; i < 16; i++)
-		irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_SLAVE, 8-i);
+		irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_SLAVE, i - 8);
 
 	/* Last but not least, IOAPIC */
 	for (i = 0; i < 24; i++) {
 		if (i == 0)
 			irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_IOAPIC, 2);
-		else
+		else if (i != 2)
 			irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_IOAPIC, i);
 	}
 
Signature · 1 line
1.7.6
#4 lore raw
Quoted 7 lines · Sasha Levin

This thread fixes two issues:
- Slave IRQCHIP was mapped wrong, this caused all IRQs which belong
to it to be ignored (breaking such things as the mouse).
- Line 2 was being mapped, since it's the link between slave and master
IRQCHIPs it shouldn't be.

Asias, does this fix the VNC mouse problem for you?

Quoted 30 lines
---
  tools/kvm/irq.c |    7 ++++---
  1 files changed, 4 insertions(+), 3 deletions(-)
tools/kvm/irq.c +4 -3
index 85e2238..e35bf18 100644
@@ -147,17 +147,18 @@ void irq__init(struct kvm *kvm)
 
  	/* Hook first 8 GSIs to master IRQCHIP */
  	for (i = 0; i<  8; i++)
-		irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_MASTER, i);
+		if (i != 2)
+			irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_MASTER, i);
 
  	/* Hook next 8 GSIs to slave IRQCHIP */
  	for (i = 8; i<  16; i++)
-		irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_SLAVE, 8-i);
+		irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_SLAVE, i - 8);
 
  	/* Last but not least, IOAPIC */
  	for (i = 0; i<  24; i++) {
  		if (i == 0)
  			irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_IOAPIC, 2);
-		else
+		else if (i != 2)
  			irq__add_routing(i, KVM_IRQ_ROUTING_IRQCHIP, IRQCHIP_IOAPIC, i);
  	}
 
#2 lore raw

Re: [PATCH] kvm tools: Use correct size for VESA memory bar

In reply to Sasha Levin
Quoted 17 lines · Sasha Levin

This patch makes BAR 1 16k, instead of BAR0 - which is the PIO bar.

This fixes wrong output on lspci command and ioremap warnings during boot.

---

tools/kvm/hw/serial.c |    2 +-
tools/kvm/hw/vesa.c   |    2 +-
tools/kvm/pci.c       |    2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
tools/kvm/hw/serial.c +0 -0
index 1199264..0393d3d 100644

tools/kvm/hw/serial.c static bool serial8250_out(struct ioport *ioport, struct kvm *kvm, u16 port, voi · line 216

Quoted 5 lines
tools/kvm/hw/serial.c +1 -1
@@ -213,7 +213,7 @@ static bool serial8250_out(struct ioport *ioport, struct kvm *kvm, u16 port, voi
 		case UART_TX: {
 			char *addr = data;
 
-			if (!(dev->mcr & UART_MCR_LOOP))
+			if (!(dev->mcr & (UART_MCR_LOOP | UART_MCR_OUT2)))

I assume it was your mistake to include this part?

walimis

Quoted 43 lines
tools/kvm/hw/serial.c +0 -0
 				term_putc(CONSOLE_8250, addr, size * count);
 
 			dev->iir		= UART_IIR_NO_INT;
tools/kvm/hw/vesa.c +1 -1
index 2af08df..9caa6c4 100644
@@ -39,6 +39,7 @@ static struct pci_device_header vesa_pci_device = {
 	.subsys_vendor_id	= PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
 	.subsys_id		= PCI_SUBSYSTEM_ID_VESA,
 	.bar[1]			= VESA_MEM_ADDR | PCI_BASE_ADDRESS_SPACE_MEMORY,
+	.bar_size[1]		= VESA_MEM_SIZE,
 };
 
 static struct framebuffer vesafb;
@@ -56,7 +57,6 @@ struct framebuffer *vesa__init(struct kvm *kvm)
 	vesa_pci_device.irq_line	= line;
 	vesa_base_addr			= ioport__register(IOPORT_EMPTY, &vesa_io_ops, IOPORT_SIZE, NULL);
 	vesa_pci_device.bar[0]		= vesa_base_addr | PCI_BASE_ADDRESS_SPACE_IO;
-	vesa_pci_device.bar_size[0]	= VESA_MEM_SIZE;
 	pci__register(&vesa_pci_device, dev);
 
 	mem = mmap(NULL, VESA_MEM_SIZE, PROT_RW, MAP_ANON_NORESERVE, -1, 0);
tools/kvm/pci.c +1 -1
index fd19b73..0449aca 100644
@@ -95,7 +95,7 @@ static bool pci_config_data_out(struct ioport *ioport, struct kvm *kvm, u16 port
 		offset = start + (pci_config_address.register_number << 2);
 		if (offset < sizeof(struct pci_device_header)) {
 			void *p = pci_devices[dev_num];
-			u8 bar = offset - PCI_BAR_OFFSET(0);
+			u8 bar = offset - PCI_BAR_OFFSET(0) / (sizeof(u32));
 			u32 sz = PCI_IO_SIZE;
 
 			if (bar < 6 && pci_devices[dev_num]->bar_size[bar])
Signature · 6 lines
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Re: [PATCH] kvm tools: Use correct size for VESA memory bar

Quoted 21 lines · walimis
Quoted 20 lines · Sasha Levin

This patch makes BAR 1 16k, instead of BAR0 - which is the PIO bar.

This fixes wrong output on lspci command and ioremap warnings during boot.

---

tools/kvm/hw/serial.c |    2 +-
tools/kvm/hw/vesa.c   |    2 +-
tools/kvm/pci.c       |    2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
tools/kvm/hw/serial.c +0 -0
index 1199264..0393d3d 100644
@@ -213,7 +213,7 @@ static bool serial8250_out(struct ioport *ioport, struct kvm *kvm, u16 port, voi
 		case UART_TX: {
 			char *addr = data;
 
Quoted 5 lines

tools/kvm/hw/serial.c static bool serial8250_out(struct ioport *ioport, struct kvm *kvm, u16 port, voi · line 216

Quoted 2 lines
tools/kvm/hw/serial.c +1 -1
-			if (!(dev->mcr & UART_MCR_LOOP))
+			if (!(dev->mcr & (UART_MCR_LOOP | UART_MCR_OUT2)))

I assume it was your mistake to include this part?

walimis

Heh... yes it was. Thanks :)

Signature · 1 line
Sasha.
#5 lore raw
In reply to Pekka Enberg
Quoted 10 lines · Pekka Enberg
Quoted 7 lines · Sasha Levin

This thread fixes two issues:
- Slave IRQCHIP was mapped wrong, this caused all IRQs which belong
to it to be ignored (breaking such things as the mouse).
- Line 2 was being mapped, since it's the link between slave and master
IRQCHIPs it shouldn't be.

Asias, does this fix the VNC mouse problem for you?

Yup. But gpm still can not work, it complains can not open /dev/psaux.

Signature · 2 lines
Best Regards,
Asias He
#6 lore raw
Quoted 8 lines · Asias He
Quoted 7 lines · Pekka Enberg
Quoted 6 lines · Sasha Levin

This thread fixes two issues:
- Slave IRQCHIP was mapped wrong, this caused all IRQs which belong
to it to be ignored (breaking such things as the mouse).
- Line 2 was being mapped, since it's the link between slave and master
IRQCHIPs it shouldn't be.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Asias, does this fix the VNC mouse problem for you?

Yup. But gpm still can not work, it complains can not open /dev/psaux.

Do you enable mouse/ps2 option in the kernel?

walimis

Quoted 9 lines
Signature · 7 lines
-- 
Best Regards,
Asias He
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html