Skip to contentSkip to conversation

kvm tools: Use correct size for VESA memory BAR

PATCH In review Sasha Levin 5 participants 5 messages Aug 9, 2011 – Aug 10, 2011 KVM

lore
Share & tools
lore
#0 lore raw

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

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

---
 tools/kvm/hw/vesa.c |    2 +-
 tools/kvm/pci.c     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
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
#1 lore raw
Quoted 7 lines · Sasha Levin

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

---
 tools/kvm/hw/vesa.c |    2 +-
 tools/kvm/pci.c     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

This changelog is missing some key information:

- how did you find the bug (by chance via code review or did you see some actual badness?)

- what practical effect (if any) did you see from this patch?

- what practical effect (if any) do you expect others to see from this patch?

I suspect this patch is only for completeness/correctness but has no practical effect - but that's a guess.

Thanks,

Ingo

#2 lore raw
Quoted 10 lines · Ingo Molnar
Quoted 2 lines · Sasha Levin

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

This changelog is missing some key information:

- how did you find the bug (by chance via code review or did you see some actual badness?)

Quoted 7 lines

- what practical effect (if any) did you see from this patch?

- what practical effect (if any) do you expect others to see from this patch?

I suspect this patch is only for completeness/correctness but has no practical effect - but that's a guess.

My guess would be that seabios tried to lay out the BARs and had trouble fitting a 16k pio bar in the small PCI pio region.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Ingo Molnar
Quoted 2 lines · Sasha Levin

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

This changelog is missing some key information:

- how did you find the bug (by chance via code review or did you see some actual badness?)

- what practical effect (if any) did you see from this patch?

Quoted 8 lines
Quoted 6 lines

- what practical effect (if any) do you expect others to see from
this patch?

I suspect this patch is only for completeness/correctness but has no practical effect - but that's a guess.

My guess would be that seabios tried to lay out the BARs and had trouble fitting a 16k pio bar in the small PCI pio region.

Sasha? IIRC this fixed some issue with David's out-of-tree PCI driver?

#4 lore raw

I don't know if there were any other drivers for this patch, but it along with another patch (maybe integrated elsewhere for 32bit BAR vs 8bit) certainly helped me out a lot. These patches fixed ioremap errors I was seeing (I had a 16MB PCI memory region, but it appeared to be only 256 bytes in size; the kernel complained bitterly about that on ioremap). It also was an issue of expected vs unexpected output from lspci -vvv.

I'm working on my out-of-tree PCI driver to see if it can become in tree. I have more cleanup to do, and seeing how close I can come to the target coding standards.

\dae

Quoted 25 lines · Pekka Enberg
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Ingo Molnar
Quoted 2 lines · Sasha Levin

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

This changelog is missing some key information:

- how did you find the bug (by chance via code review or did you see some actual badness?)

- what practical effect (if any) did you see from this patch?

- what practical effect (if any) do you expect others to see
from this patch?

Quoted 6 lines
Quoted 3 lines

I suspect this patch is only for completeness/correctness but has no practical effect - but that's a guess.

My guess would be that seabios tried to lay out the BARs and had trouble fitting a 16k pio bar in the small PCI pio region.

Sasha? IIRC this fixed some issue with David's out-of-tree PCI driver?