From: "Michael S. Tsirkin" <mst@redhat.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: Krishna Kumar <krkumar2@in.ibm.com>,
kvm@vger.kernel.org, Pawel Moll <pawel.moll@arm.com>,
Wang Sheng-Hui <shhuiw@gmail.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
virtualization@lists.linux-foundation.org, penberg@kernel.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
avi@redhat.com, Amit Shah <amit.shah@redhat.com>
Subject: Re: [PATCHv2 RFC] virtio-spec: flexible configuration layout
Date: Wed, 16 Nov 2011 11:09:38 +0200 [thread overview]
Message-ID: <20111116090938.GA17290@redhat.com> (raw)
In-Reply-To: <1321431459.3221.4.camel@lappy>
On Wed, Nov 16, 2011 at 10:17:39AM +0200, Sasha Levin wrote:
> On Wed, 2011-11-16 at 09:21 +0200, Michael S. Tsirkin wrote:
> > On Wed, Nov 16, 2011 at 10:28:52AM +1030, Rusty Russell wrote:
> > > On Fri, 11 Nov 2011 09:39:13 +0200, Sasha Levin <levinsasha928@gmail.com> wrote:
> > > > On Fri, Nov 11, 2011 at 6:24 AM, Rusty Russell <rusty@rustcorp.com.au> wrote:
> > > > > (2) There's no huge win in keeping the same layout. Let's make some
> > > > > cleanups. There are more users ahead of us then behind us (I
> > > > > hope!).
> > > >
> > > > Actually, if we already do cleanups, here are two more suggestions:
> > > >
> > > > 1. Make 64bit features a one big 64bit block, instead of having 32bits
> > > > in one place and 32 in another.
> > > > 2. Remove the reserved fields out of the config (the ones that were
> > > > caused by moving the ISR and the notifications out).
> > >
> > > Yes, those were exactly what I was thinking. I left it vague because
> > > there might be others you can see if we're prepared to abandon the
> > > current format.
> > >
> > > Cheers,
> > > Rusty.
> >
> > Yes but driver code doesn't get any cleaner by moving the fields.
> > And in fact, the legacy support makes the code messier.
> > What are the advantages?
> >
The advantages question is what should really balance out the overhead.
> What about splitting the parts which handle legacy code and new code?
Well, I considered that. Something along the lines of
#define VIRTIO_NEW_MSI_CONFIG_VECTOR 18
And so on for all registers.
This seems to add a significant maintainance burden because of code
duplication. Note that, for example, vector programming is affected.
Multiply that by the number of guest OSes.
> It'll make it easier playing with the new spec more freely
I'm really worried about maintaing drivers long term.
Ease of experimentation is secondary for me.
> and will also
> make it easier removing legacy code in the future since you'll need to
> simply delete a chunk of code instead of removing legacy bits out of
> working code with a surgical knife.
It's unlikely to be a single chunk: we'd have structures and macros
which are separate. So at least 3 chunks.
Just for fun, here's what's involved in removing legacy map
support on top of my patch. As you see there are 4 chunks:
structure decl, map, unmap, and msix enable/disable.
And finding them was as simple as looking for legacy_map.
---
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index d242fcc..6c4d2faf 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -64,9 +64,6 @@ struct virtio_pci_device
/* Various IO mappings: used for resource tracking only. */
- /* Legacy BAR0: typically PIO. */
- void __iomem *legacy_map;
-
/* Mappings specified by device capabilities: typically in MMIO */
void __iomem *isr_map;
void __iomem *notify_map;
@@ -81,11 +78,7 @@ struct virtio_pci_device
static void virtio_pci_set_msix_enabled(struct virtio_pci_device *vp_dev, int enabled)
{
vp_dev->msix_enabled = enabled;
- if (vp_dev->device_map)
- vp_dev->ioaddr_device = vp_dev->device_map;
- else
- vp_dev->ioaddr_device = vp_dev->legacy_map +
- VIRTIO_PCI_CONFIG(vp_dev);
+ vp_dev->ioaddr_device = vp_dev->device_map;
}
static void __iomem *virtio_pci_map_cfg(struct virtio_pci_device *vp_dev, u8 cap_id,
@@ -147,8 +140,6 @@ err:
static void virtio_pci_iounmap(struct virtio_pci_device *vp_dev)
{
- if (vp_dev->legacy_map)
- pci_iounmap(vp_dev->pci_dev, vp_dev->legacy_map);
if (vp_dev->isr_map)
pci_iounmap(vp_dev->pci_dev, vp_dev->isr_map);
if (vp_dev->notify_map)
@@ -176,36 +167,15 @@ static int virtio_pci_iomap(struct virtio_pci_device *vp_dev)
if (!vp_dev->notify_map || !vp_dev->common_map ||
!vp_dev->device_map) {
- /*
- * If not all capabilities present, map legacy PIO.
- * Legacy access is at BAR 0. We never need to map
- * more than 256 bytes there, since legacy config space
- * used PIO which has this size limit.
- * */
- vp_dev->legacy_map = pci_iomap(vp_dev->pci_dev, 0, 256);
- if (!vp_dev->legacy_map) {
- dev_err(&vp_dev->vdev.dev, "Unable to map legacy PIO");
- goto err;
- }
+ dev_err(&vp_dev->vdev.dev, "Unable to map IO");
+ goto err;
}
- /* Prefer MMIO if available. If not, fallback to legacy PIO. */
- if (vp_dev->common_map)
- vp_dev->ioaddr = vp_dev->common_map;
- else
- vp_dev->ioaddr = vp_dev->legacy_map;
+ vp_dev->ioaddr = vp_dev->common_map;
- if (vp_dev->device_map)
- vp_dev->ioaddr_device = vp_dev->device_map;
- else
- vp_dev->ioaddr_device = vp_dev->legacy_map +
- VIRTIO_PCI_CONFIG(vp_dev);
+ vp_dev->ioaddr_device = vp_dev->device_map;
- if (vp_dev->notify_map)
- vp_dev->ioaddr_notify = vp_dev->notify_map;
- else
- vp_dev->ioaddr_notify = vp_dev->legacy_map +
- VIRTIO_PCI_QUEUE_NOTIFY;
+ vp_dev->ioaddr_notify = vp_dev->notify_map;
return 0;
err:
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
Amit Shah <amit.shah@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Krishna Kumar <krkumar2@in.ibm.com>,
Pawel Moll <pawel.moll@arm.com>,
Wang Sheng-Hui <shhuiw@gmail.com>,
virtualization@lists.linux-foundation.org, kvm@vger.kernel.org,
avi@redhat.com, penberg@kernel.org
Subject: Re: [PATCHv2 RFC] virtio-spec: flexible configuration layout
Date: Wed, 16 Nov 2011 11:09:38 +0200 [thread overview]
Message-ID: <20111116090938.GA17290@redhat.com> (raw)
In-Reply-To: <1321431459.3221.4.camel@lappy>
On Wed, Nov 16, 2011 at 10:17:39AM +0200, Sasha Levin wrote:
> On Wed, 2011-11-16 at 09:21 +0200, Michael S. Tsirkin wrote:
> > On Wed, Nov 16, 2011 at 10:28:52AM +1030, Rusty Russell wrote:
> > > On Fri, 11 Nov 2011 09:39:13 +0200, Sasha Levin <levinsasha928@gmail.com> wrote:
> > > > On Fri, Nov 11, 2011 at 6:24 AM, Rusty Russell <rusty@rustcorp.com.au> wrote:
> > > > > (2) There's no huge win in keeping the same layout. Let's make some
> > > > > cleanups. There are more users ahead of us then behind us (I
> > > > > hope!).
> > > >
> > > > Actually, if we already do cleanups, here are two more suggestions:
> > > >
> > > > 1. Make 64bit features a one big 64bit block, instead of having 32bits
> > > > in one place and 32 in another.
> > > > 2. Remove the reserved fields out of the config (the ones that were
> > > > caused by moving the ISR and the notifications out).
> > >
> > > Yes, those were exactly what I was thinking. I left it vague because
> > > there might be others you can see if we're prepared to abandon the
> > > current format.
> > >
> > > Cheers,
> > > Rusty.
> >
> > Yes but driver code doesn't get any cleaner by moving the fields.
> > And in fact, the legacy support makes the code messier.
> > What are the advantages?
> >
The advantages question is what should really balance out the overhead.
> What about splitting the parts which handle legacy code and new code?
Well, I considered that. Something along the lines of
#define VIRTIO_NEW_MSI_CONFIG_VECTOR 18
And so on for all registers.
This seems to add a significant maintainance burden because of code
duplication. Note that, for example, vector programming is affected.
Multiply that by the number of guest OSes.
> It'll make it easier playing with the new spec more freely
I'm really worried about maintaing drivers long term.
Ease of experimentation is secondary for me.
> and will also
> make it easier removing legacy code in the future since you'll need to
> simply delete a chunk of code instead of removing legacy bits out of
> working code with a surgical knife.
It's unlikely to be a single chunk: we'd have structures and macros
which are separate. So at least 3 chunks.
Just for fun, here's what's involved in removing legacy map
support on top of my patch. As you see there are 4 chunks:
structure decl, map, unmap, and msix enable/disable.
And finding them was as simple as looking for legacy_map.
---
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index d242fcc..6c4d2faf 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -64,9 +64,6 @@ struct virtio_pci_device
/* Various IO mappings: used for resource tracking only. */
- /* Legacy BAR0: typically PIO. */
- void __iomem *legacy_map;
-
/* Mappings specified by device capabilities: typically in MMIO */
void __iomem *isr_map;
void __iomem *notify_map;
@@ -81,11 +78,7 @@ struct virtio_pci_device
static void virtio_pci_set_msix_enabled(struct virtio_pci_device *vp_dev, int enabled)
{
vp_dev->msix_enabled = enabled;
- if (vp_dev->device_map)
- vp_dev->ioaddr_device = vp_dev->device_map;
- else
- vp_dev->ioaddr_device = vp_dev->legacy_map +
- VIRTIO_PCI_CONFIG(vp_dev);
+ vp_dev->ioaddr_device = vp_dev->device_map;
}
static void __iomem *virtio_pci_map_cfg(struct virtio_pci_device *vp_dev, u8 cap_id,
@@ -147,8 +140,6 @@ err:
static void virtio_pci_iounmap(struct virtio_pci_device *vp_dev)
{
- if (vp_dev->legacy_map)
- pci_iounmap(vp_dev->pci_dev, vp_dev->legacy_map);
if (vp_dev->isr_map)
pci_iounmap(vp_dev->pci_dev, vp_dev->isr_map);
if (vp_dev->notify_map)
@@ -176,36 +167,15 @@ static int virtio_pci_iomap(struct virtio_pci_device *vp_dev)
if (!vp_dev->notify_map || !vp_dev->common_map ||
!vp_dev->device_map) {
- /*
- * If not all capabilities present, map legacy PIO.
- * Legacy access is at BAR 0. We never need to map
- * more than 256 bytes there, since legacy config space
- * used PIO which has this size limit.
- * */
- vp_dev->legacy_map = pci_iomap(vp_dev->pci_dev, 0, 256);
- if (!vp_dev->legacy_map) {
- dev_err(&vp_dev->vdev.dev, "Unable to map legacy PIO");
- goto err;
- }
+ dev_err(&vp_dev->vdev.dev, "Unable to map IO");
+ goto err;
}
- /* Prefer MMIO if available. If not, fallback to legacy PIO. */
- if (vp_dev->common_map)
- vp_dev->ioaddr = vp_dev->common_map;
- else
- vp_dev->ioaddr = vp_dev->legacy_map;
+ vp_dev->ioaddr = vp_dev->common_map;
- if (vp_dev->device_map)
- vp_dev->ioaddr_device = vp_dev->device_map;
- else
- vp_dev->ioaddr_device = vp_dev->legacy_map +
- VIRTIO_PCI_CONFIG(vp_dev);
+ vp_dev->ioaddr_device = vp_dev->device_map;
- if (vp_dev->notify_map)
- vp_dev->ioaddr_notify = vp_dev->notify_map;
- else
- vp_dev->ioaddr_notify = vp_dev->legacy_map +
- VIRTIO_PCI_QUEUE_NOTIFY;
+ vp_dev->ioaddr_notify = vp_dev->notify_map;
return 0;
err:
next prev parent reply other threads:[~2011-11-16 9:09 UTC|newest]
Thread overview: 134+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87wrbkvh3v.fsf@rustcorp.com.au>
2011-11-01 11:45 ` [PULL] virtio Michael S. Tsirkin
2011-11-01 11:45 ` Michael S. Tsirkin
2011-11-01 12:33 ` Sasha Levin
2011-11-01 12:33 ` Sasha Levin
2011-11-01 12:42 ` Michael S. Tsirkin
2011-11-01 12:42 ` Michael S. Tsirkin
2011-11-01 12:45 ` Sasha Levin
2011-11-01 12:45 ` Sasha Levin
2011-11-02 1:09 ` Rusty Russell
2011-11-02 4:52 ` Sasha Levin
2011-11-02 4:52 ` Sasha Levin
2011-11-02 22:07 ` Rusty Russell
2011-11-02 22:07 ` Rusty Russell
2011-11-02 23:31 ` [PATCH RFC] virtio-pci: flexible configuration layout Michael S. Tsirkin
2011-11-02 23:31 ` Michael S. Tsirkin
2011-11-03 0:19 ` Sasha Levin
2011-11-03 0:19 ` Sasha Levin
2011-11-03 10:33 ` Michael S. Tsirkin
2011-11-03 10:33 ` Michael S. Tsirkin
2011-11-03 11:09 ` Sasha Levin
2011-11-03 11:09 ` Sasha Levin
2011-11-03 11:36 ` Michael S. Tsirkin
2011-11-03 11:36 ` Michael S. Tsirkin
2011-11-03 13:30 ` Michael S. Tsirkin
2011-11-03 13:30 ` Michael S. Tsirkin
2011-11-03 10:37 ` Avi Kivity
2011-11-03 10:37 ` Avi Kivity
2011-11-03 12:11 ` Michael S. Tsirkin
2011-11-03 12:11 ` Michael S. Tsirkin
2011-11-03 13:37 ` Avi Kivity
2011-11-03 13:37 ` Avi Kivity
2011-11-03 13:53 ` Michael S. Tsirkin
2011-11-03 13:53 ` Michael S. Tsirkin
2011-11-03 14:59 ` Jesse Barnes
2011-11-03 14:59 ` Jesse Barnes
2011-11-08 21:40 ` [PATCH RFC] virtio-spec: " Michael S. Tsirkin
2011-11-08 21:40 ` Michael S. Tsirkin
2011-11-08 21:41 ` Michael S. Tsirkin
2011-11-09 10:21 ` Avi Kivity
2011-11-09 8:46 ` Sasha Levin
2011-11-09 10:13 ` Michael S. Tsirkin
2011-11-09 10:13 ` Michael S. Tsirkin
2011-11-09 10:26 ` Sasha Levin
2011-11-09 10:26 ` Sasha Levin
2011-11-09 10:49 ` Michael S. Tsirkin
2011-11-09 10:49 ` Michael S. Tsirkin
2011-11-09 12:25 ` Pekka Enberg
2011-11-09 12:28 ` Sasha Levin
2011-11-09 12:28 ` Sasha Levin
2011-11-09 12:36 ` Pekka Enberg
2011-11-09 15:33 ` Michael S. Tsirkin
2011-11-09 15:33 ` Michael S. Tsirkin
2012-06-18 11:54 ` Michael S. Tsirkin
2012-06-18 11:54 ` Michael S. Tsirkin
2012-06-18 12:05 ` Sasha Levin
2012-06-18 12:07 ` Michael S. Tsirkin
2012-06-18 12:07 ` Michael S. Tsirkin
2012-06-18 12:05 ` Sasha Levin
2011-11-09 12:36 ` Pekka Enberg
2011-11-09 12:25 ` Pekka Enberg
2011-11-09 12:38 ` Avi Kivity
2011-11-09 12:38 ` Avi Kivity
2011-11-09 12:48 ` Sasha Levin
2011-11-09 12:48 ` Sasha Levin
2011-11-09 15:19 ` Michael S. Tsirkin
2011-11-13 14:07 ` Ronen Hod
2011-11-13 14:07 ` Ronen Hod
2011-11-09 15:19 ` Michael S. Tsirkin
2011-11-09 15:51 ` Michael S. Tsirkin
2011-11-09 15:51 ` Michael S. Tsirkin
2011-11-13 20:40 ` Vadim Rozenfeld
2011-11-13 20:40 ` Vadim Rozenfeld
2011-11-09 8:46 ` Sasha Levin
2011-11-09 9:55 ` Sasha Levin
2011-11-09 10:18 ` Michael S. Tsirkin
2011-11-09 10:18 ` Michael S. Tsirkin
2011-11-09 10:20 ` Sasha Levin
2011-11-09 10:20 ` Sasha Levin
2011-11-09 10:20 ` Sasha Levin
2011-11-09 10:47 ` Pawel Moll
2011-11-09 10:55 ` Sasha Levin
2011-11-09 10:55 ` Sasha Levin
2011-11-09 11:06 ` Pawel Moll
2011-11-09 11:39 ` Peter Maydell
2011-11-09 11:39 ` Peter Maydell
2011-11-09 12:07 ` Sasha Levin
2011-11-09 12:07 ` Sasha Levin
2011-11-09 11:06 ` Pawel Moll
2011-11-09 10:47 ` Pawel Moll
2011-11-09 9:55 ` Sasha Levin
2011-11-09 19:59 ` [PATCHv2 " Michael S. Tsirkin
2011-11-09 19:59 ` Michael S. Tsirkin
2011-11-09 20:00 ` Michael S. Tsirkin
2011-11-09 20:24 ` Sasha Levin
2011-11-09 20:24 ` Sasha Levin
2011-11-09 20:52 ` Michael S. Tsirkin
2011-11-09 20:52 ` Michael S. Tsirkin
2011-11-09 20:57 ` Sasha Levin
2011-11-09 20:57 ` Sasha Levin
2011-11-09 21:14 ` Michael S. Tsirkin
2011-11-09 21:14 ` Michael S. Tsirkin
2011-11-09 21:13 ` Sasha Levin
2011-11-09 21:13 ` Sasha Levin
2011-11-10 8:55 ` Michael S. Tsirkin
2011-11-10 8:55 ` Michael S. Tsirkin
2011-11-11 4:24 ` Rusty Russell
2011-11-11 4:24 ` Rusty Russell
2011-11-11 7:39 ` Sasha Levin
2011-11-11 7:39 ` Sasha Levin
2011-11-11 12:59 ` Michael S. Tsirkin
2011-11-11 12:59 ` Michael S. Tsirkin
2011-11-11 13:06 ` Pawel Moll
2011-11-11 13:06 ` Pawel Moll
2011-11-15 23:58 ` Rusty Russell
2011-11-15 23:58 ` Rusty Russell
2011-11-16 7:21 ` Michael S. Tsirkin
2011-11-16 7:21 ` Michael S. Tsirkin
2011-11-16 8:17 ` Sasha Levin
2011-11-16 8:17 ` Sasha Levin
2011-11-16 9:09 ` Michael S. Tsirkin [this message]
2011-11-16 9:09 ` Michael S. Tsirkin
2011-11-11 13:03 ` Michael S. Tsirkin
2011-11-11 13:03 ` Michael S. Tsirkin
2011-11-13 15:14 ` Michael S. Tsirkin
2011-11-13 15:14 ` Michael S. Tsirkin
2011-11-14 6:59 ` Michael S. Tsirkin
2011-11-14 6:59 ` Michael S. Tsirkin
2011-11-15 23:58 ` Rusty Russell
2011-11-15 23:58 ` Rusty Russell
2011-11-16 7:03 ` Michael S. Tsirkin
2011-11-16 7:03 ` Michael S. Tsirkin
2011-11-10 12:24 ` [PATCHv3 " Michael S. Tsirkin
2011-11-10 12:24 ` Michael S. Tsirkin
2011-11-02 1:09 ` [PULL] virtio Rusty Russell
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=20111116090938.GA17290@redhat.com \
--to=mst@redhat.com \
--cc=aik@ozlabs.ru \
--cc=amit.shah@redhat.com \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=krkumar2@in.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pawel.moll@arm.com \
--cc=penberg@kernel.org \
--cc=shhuiw@gmail.com \
--cc=virtualization@lists.linux-foundation.org \
/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.