All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: penberg@kernel.org, john@jfloren.net, kvm@vger.kernel.org,
	asias.hejun@gmail.com, gorcunov@gmail.com,
	prasadjoshi124@gmail.com
Subject: Re: [PATCH 7/9] kvm tools: Use dynamic IO port allocation in virtio-console driver
Date: Wed, 25 May 2011 16:42:50 +0200	[thread overview]
Message-ID: <20110525144250.GC29179@elte.hu> (raw)
In-Reply-To: <1306333427-26186-7-git-send-email-levinsasha928@gmail.com>


* Sasha Levin <levinsasha928@gmail.com> 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.

Thanks,

	Ingo

  reply	other threads:[~2011-05-25 14:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-25 14:23 [PATCH 1/9] kvm tools: Add optional parameter used in ioport callbacks Sasha Levin
2011-05-25 14:23 ` [PATCH 2/9] kvm tools: Add basic ioport dynamic allocation Sasha Levin
2011-05-25 14:34   ` Ingo Molnar
2011-05-25 14:23 ` [PATCH 3/9] kvm tools: Use ioport context to control blk devices Sasha Levin
2011-05-25 14:23 ` [PATCH 4/9] kvm tools: Add support for multiple virtio-rng devices Sasha Levin
2011-05-25 14:23 ` [PATCH 5/9] kvm tools: Use dynamic IO port allocation in vesa driver Sasha Levin
2011-05-25 14:23 ` [PATCH 6/9] kvm tools: Use dynamic IO port allocation in 9p driver Sasha Levin
2011-05-25 14:23 ` [PATCH 7/9] kvm tools: Use dynamic IO port allocation in virtio-console driver Sasha Levin
2011-05-25 14:42   ` Ingo Molnar [this message]
2011-05-25 15:35     ` Sasha Levin
2011-05-25 14:23 ` [PATCH 8/9] kvm tools: Use dynamic IO port allocation in virtio-net driver Sasha Levin
2011-05-25 14:23 ` [PATCH 9/9] kvm tools: Remove static ioport allocations Sasha Levin
2011-05-25 14:43   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110525144250.GC29179@elte.hu \
    --to=mingo@elte.hu \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=john@jfloren.net \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.