Re: [PATCH 7/9] kvm tools: Use dynamic IO port allocation in virtio-console driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2011-05-25 at 16:42 +0200, Ingo Molnar wrote:
> * Sasha Levin <levinsasha928@xxxxxxxxx> wrote:
> 
> >  void virtio_console__init(struct kvm *kvm)
> >  {
> >  	u8 dev, line, pin;
> > +	u16 console_base_addr;
> >  
> >  	if (irq__register_device(VIRTIO_ID_CONSOLE, &dev, &pin, &line) < 0)
> >  		return;
> >  
> >  	virtio_console_pci_device.irq_pin	= pin;
> >  	virtio_console_pci_device.irq_line	= line;
> > +	console_base_addr			= ioport__find_free_range();
> > +	virtio_console_pci_device.bar[0]	= console_base_addr | PCI_BASE_ADDRESS_SPACE_IO;
> > +	cdev.base_addr				= console_base_addr;
> >  	pci__register(&virtio_console_pci_device, dev);
> > -	ioport__register(IOPORT_VIRTIO_CONSOLE, &virtio_console_io_ops, IOPORT_VIRTIO_CONSOLE_SIZE);
> > +	ioport__register(console_base_addr, &virtio_console_io_ops, IOPORT_SIZE);
> 
> Why is the ioport registration done in two steps?
> 
> Wouldnt a better sequence be something like:
> 
> > +	console_base_addr			= ioport__register(&virtio_console_io_ops, IOPORT_SIZE);
> >
> > +	virtio_console_pci_device.bar[0]	= console_base_addr | PCI_BASE_ADDRESS_SPACE_IO;
> > +	cdev.base_addr				= console_base_addr;
> >  	pci__register(&virtio_console_pci_device, dev);
> 
> I.e. first register the ioport range - this would also get a free 
> range for you, and then register the PCI driver?
> 
> Or something even more compact could be done i suspect - all of the 
> drivers seem to be using the same registration sequence.

Some drivers need explicit IO ports, such as the serial driver.

It was a question of whether I create another registration function
(which may be as simple as calling 'ioport__find_free_range()' before
calling the real registration) but it would lead to two 'registration'
functions behaving very differently - one returning a new port and one
that just does nothing except registering.

-- 

Sasha.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux