public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Christoffer Dall <cdall@cs.columbia.edu>
Cc: Alexander Graf <agraf@suse.de>, <kvm-ppc@vger.kernel.org>,
	<kvm@vger.kernel.org>
Subject: Re: [RFC PATCH 1/6] kvm: add device control API
Date: Tue, 19 Feb 2013 14:16:06 -0600	[thread overview]
Message-ID: <1361304966.29654.8@snotra> (raw)
In-Reply-To: <CAEDV+gKU604RN5uh0=xbFVPMYUfvqdqLbVc0nxJJykO2cCoivA@mail.gmail.com> (from cdall@cs.columbia.edu on Mon Feb 18 23:50:44 2013)

On 02/18/2013 11:50:44 PM, Christoffer Dall wrote:
> On Mon, Feb 18, 2013 at 4:53 PM, Scott Wood <scottwood@freescale.com>  
> wrote:
> > On 02/18/2013 06:44:20 PM, Christoffer Dall wrote:
> >>
> >> On Wed, Feb 13, 2013 at 9:49 PM, Scott Wood  
> <scottwood@freescale.com>
> >> > +#define KVM_CREATE_DEVICE        _IOWR(KVMIO,  0xac, struct
> >> > kvm_create_device)
> >> > +#define KVM_SET_DEVICE_ATTR      _IOW(KVMIO,  0xad, struct
> >> > kvm_device_attr)
> >> > +#define KVM_GET_DEVICE_ATTR      _IOW(KVMIO,  0xae, struct
> >> > kvm_device_attr)
> >>
> >> _IOWR ?
> >
> >
> > struct kvm_device_attr itself is write-only, though the data  
> pointed to by
> > the addr field goes the other way for GET.  ONE_REG is in the same  
> situation
> > and also uses _IOW for both.
> >
> >
> 
> ok.
> 
> Btw., what about the size of the attr? implicitly defined through the  
> attr id?

Yes, same as in ONE_REG.

> and I also think it's easier to read the
> arch-specific bits of the code that way, instead of some arbitrary
> function that you have to trace through to figure out where it's
> called from.

I don't follow.

> > By doing device recognition here we don't need a separate copy of  
> this per
> > arch (including some #ifdef or modifying every arch at once --  
> including ARM
> > which I can't modify yet because it's not merged), and *if* we  
> should end up
> > with an in-kernel-emulated device that gets used across multiple
> > architectures, it would be annoying to have to modify all relevant
> > architectures (and worse to deal with per-arch numberspaces).
> 
> I would say that's exactly what you're going to need with your  
> approach:
> 
> switch (cd->type) {
> case KVM_ARM_VGIC_V2_0:
>     kvm_arm_vgic_v2_0_create(...);
> }
> 
> 
> are you going to ifdef here in this function, or? I think it's cleaner
> to have the single arch-specific hooks and handle the cases there.

There's an ifdef, as you can see from the patch that adds MPIC  
support.  But it's the same ifdef that gets used to determine whether  
the device code gets built in.  Nothing special needs to be added; no  
per-architecture hoop to jump through.

Note that we would still need per-device ifdefs in the arch code,  
because not all PPC KVM builds are going to have MPIC support.

What if, instead of a switch statement and ifdefs, it operated on a  
registration basis?

> The use case of having a single device which is so central to the
> system that we emulate it inside the kernel and is shared across
> multiple archs is pretty far fetched to me.

I don't think it's that far fetched.  APIC is shared between x86 and  
ia64 -- even if APIC has no need for anything beyond existing API, it  
shows that it's not a crazy possibility.  Freescale already has some  
devices that are shared between PPC and ARM, and that set will expand  
(probably not to irq controllers, though the probability is non-zero)  
with Layerscape, about which Freeescale says, "The unique,  
core-agnostic architecture incorporates the optimum core for the given  
application—ARM cores or Power Architecture cores."  We already need to  
go back and non-ppc-ize various drivers, including their reliance on  
I/O accessors that are defined in architecture-specific ways...  Making  
things gratuitiously architecture specific is just a bad idea, even if  
the "use case" for it actually being used on multiple architectures is  
remote.

Normal kernel drivers tend to go in drivers/, not arch/, even if  
they're only used on one architecture...

> However, this is internal and can always be changed, so if everyone
> agrees on the overall API, whichever way you implement it is fine with
> me.

We at least need the numberspace to not be architecture-specific if we  
want to retain the possibility of changing later -- not to mention what  
happens if architectures merge.  I see that "arm" and "arm64" are  
separate, despite the fact that other architectures that used to be  
split this way have since merged.  Maybe "arm64" is too different from  
"arm" for that to happen, but who knows...

...and if they don't merge, wouldn't that be a likely case for devices  
shared across architectures?  Does arm64 use gic/vgic?  This post  
suggests that there is at least something in common (the bit about  
"once the GIC code is shared between
arm and arm64"):
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-December/135836.html

-Scott

  parent reply	other threads:[~2013-02-19 20:16 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14  5:49 [RFC PATCH 0/6] kvm/ppc/mpic: in-kernel irqchip Scott Wood
2013-02-14  5:49 ` [RFC PATCH 1/6] kvm: add device control API Scott Wood
2013-02-18 12:21   ` Gleb Natapov
2013-02-18 23:01     ` Scott Wood
2013-02-19  0:43       ` Christoffer Dall
2013-02-19 12:24       ` Gleb Natapov
2013-02-19 15:51         ` Christoffer Dall
2013-02-19 21:16         ` Scott Wood
2013-02-20 13:09           ` Gleb Natapov
2013-02-20 21:28             ` Marcelo Tosatti
2013-02-20 22:44               ` Marcelo Tosatti
2013-02-20 23:53               ` Scott Wood
2013-02-21  0:14                 ` Marcelo Tosatti
2013-02-21  1:28                   ` Scott Wood
2013-02-21  6:39                     ` Gleb Natapov
2013-02-21 23:03                     ` Marcelo Tosatti
2013-02-22  2:00                       ` Scott Wood
2013-02-23 15:04                         ` Marcelo Tosatti
2013-02-26  0:27                           ` Scott Wood
2013-02-21  2:05             ` Scott Wood
2013-02-21  8:22               ` Gleb Natapov
2013-02-22  2:17                 ` Scott Wood
2013-02-24 15:46                   ` Gleb Natapov
2013-02-25 15:23                     ` Alexander Graf
2013-02-26  2:38                     ` Scott Wood
2013-02-20 21:17       ` Marcelo Tosatti
2013-02-20 23:20         ` Scott Wood
2013-02-21  0:01           ` Marcelo Tosatti
2013-02-21  0:33             ` Scott Wood
2013-02-25  1:11     ` Paul Mackerras
2013-02-25 13:09       ` Gleb Natapov
2013-02-25 15:29         ` Alexander Graf
2013-02-19  0:44   ` Christoffer Dall
2013-02-19  0:53     ` Scott Wood
2013-02-19  5:50       ` Christoffer Dall
2013-02-19 12:45         ` Gleb Natapov
2013-02-19 20:16         ` Scott Wood [this message]
2013-02-20  2:16           ` Christoffer Dall
2013-02-24 13:12             ` Marc Zyngier
2013-03-06  0:59   ` Paul Mackerras
2013-03-06  1:20     ` Scott Wood
2013-03-06  2:48   ` Benjamin Herrenschmidt
2013-03-06  3:36     ` Scott Wood
2013-03-06  4:28       ` Benjamin Herrenschmidt
2013-03-06 10:18     ` Gleb Natapov
2013-02-14  5:49 ` [RFC PATCH 2/6] kvm/ppc: add a notifier chain for vcpu creation/destruction Scott Wood
2013-02-14  5:49 ` [RFC PATCH 3/6] kvm/ppc/mpic: import hw/openpic.c from QEMU Scott Wood
2013-02-14  5:49 ` [RFC PATCH 4/6] kvm/ppc/mpic: remove some obviously unneeded code Scott Wood
2013-02-14  5:49 ` [RFC PATCH 5/6] kvm/ppc/mpic: adapt to kernel style and environment Scott Wood
2013-02-14  5:49 ` [RFC PATCH 6/6] kvm/ppc/mpic: in-kernel MPIC emulation Scott Wood
2013-03-21  8:28   ` Alexander Graf
2013-03-21 14:43     ` Scott Wood
2013-03-21 14:52       ` Alexander Graf
2013-02-18 12:04 ` [RFC PATCH 0/6] kvm/ppc/mpic: in-kernel irqchip Gleb Natapov
2013-02-18 23:05   ` Scott Wood
2013-04-01 22:47 ` [RFC PATCH v2 0/6] device control and in-kernel MPIC Scott Wood
2013-04-01 22:47   ` [RFC PATCH v2 1/6] kvm: add device control API Scott Wood
2013-04-02  6:59     ` tiejun.chen
     [not found]       ` <1364923807.24520.2@snotra>
2013-04-03  1:28         ` tiejun.chen
     [not found]           ` <1364952853.8690.3@snotra>
2013-04-03  1:42             ` tiejun.chen
2013-04-03  1:02     ` Paul Mackerras
2013-04-03  1:19       ` Scott Wood
2013-04-03  2:17         ` Paul Mackerras
2013-04-03 13:22           ` Alexander Graf
2013-04-03 17:37             ` Scott Wood
2013-04-03 17:39               ` Alexander Graf
2013-04-04  9:58                 ` Gleb Natapov
2013-04-03 21:03           ` Scott Wood
2013-04-01 22:47   ` [RFC PATCH v2 2/6] kvm/ppc/mpic: import hw/openpic.c from QEMU Scott Wood
2013-04-01 22:47   ` [RFC PATCH v2 3/6] kvm/ppc/mpic: remove some obviously unneeded code Scott Wood
2013-04-01 22:47   ` [RFC PATCH v2 4/6] kvm/ppc/mpic: adapt to kernel style and environment Scott Wood
2013-04-01 22:47   ` [RFC PATCH v2 5/6] kvm/ppc/mpic: in-kernel MPIC emulation Scott Wood
2013-04-01 22:47   ` [RFC PATCH v2 6/6] kvm/ppc/mpic: add KVM_CAP_IRQ_MPIC Scott Wood
2013-04-03  1:57   ` [RFC PATCH v3 0/6] device control and in-kernel MPIC Scott Wood
2013-04-03  1:57     ` [RFC PATCH v3 1/6] kvm: add device control API Scott Wood
2013-04-03 15:13       ` Alexander Graf
2013-04-04 10:41       ` Gleb Natapov
2013-04-04 23:47         ` Scott Wood
2013-04-08 10:34           ` Gleb Natapov
2013-04-05  1:02         ` Paul Mackerras
2013-04-08 10:37           ` Gleb Natapov
2013-04-08  5:33       ` Paul Mackerras
2013-04-09  0:50         ` Scott Wood
2013-04-03  1:57     ` [RFC PATCH v3 2/6] kvm/ppc/mpic: import hw/openpic.c from QEMU Scott Wood
2013-04-03  1:57     ` [RFC PATCH v3 3/6] kvm/ppc/mpic: remove some obviously unneeded code Scott Wood
2013-04-03  1:57     ` [RFC PATCH v3 4/6] kvm/ppc/mpic: adapt to kernel style and environment Scott Wood
2013-04-03  1:57     ` [RFC PATCH v3 5/6] kvm/ppc/mpic: in-kernel MPIC emulation Scott Wood
2013-04-03 15:55       ` Gleb Natapov
2013-04-03 20:58         ` Scott Wood
2013-04-04  5:59           ` Gleb Natapov
2013-04-04 23:33             ` Scott Wood
2013-04-08 10:39               ` Gleb Natapov
2013-04-03 16:19       ` Alexander Graf
2013-04-03 21:38         ` Scott Wood
2013-04-03 21:58           ` Alexander Graf
2013-04-03 22:07             ` Scott Wood
2013-04-03 22:12               ` Alexander Graf
2013-04-03 22:54                 ` Scott Wood
2013-04-04  9:42                   ` Alexander Graf
2013-04-03 23:23               ` Scott Wood
2013-04-08  6:30       ` Paul Mackerras
2013-04-09  0:49         ` Scott Wood
2013-04-03  1:57     ` [RFC PATCH v3 6/6] kvm/ppc/mpic: add KVM_CAP_IRQ_MPIC Scott Wood
2013-04-04 12:54       ` Alexander Graf
2013-04-04 18:41         ` Scott Wood
2013-04-04 22:30           ` Alexander Graf
2013-04-04 22:35             ` Scott Wood
2013-04-05  6:09               ` Alexander Graf
2013-04-05 17:11                 ` Scott Wood
2013-04-13  0:08     ` [PATCH v4 0/6] device-control and in-kernel MPIC Scott Wood
2013-04-13  0:08       ` [PATCH v4 1/6] kvm: add device control API Scott Wood
2013-04-25  9:43         ` Gleb Natapov
2013-04-25 10:47           ` Alexander Graf
2013-04-25 12:07             ` Gleb Natapov
2013-04-25 13:45               ` Alexander Graf
2013-04-25 13:51                 ` Gleb Natapov
2013-04-25 16:51             ` Scott Wood
2013-04-25 18:22               ` Gleb Natapov
2013-04-25 18:59                 ` Scott Wood
2013-04-26  9:53                   ` Gleb Natapov
2013-04-26  9:55                     ` Alexander Graf
2013-04-26  9:57                       ` Gleb Natapov
2013-04-13  0:08       ` [PATCH v4 2/6] kvm/ppc/mpic: import hw/openpic.c from QEMU Scott Wood
2013-04-13  0:08       ` [PATCH v4 3/6] kvm/ppc/mpic: remove some obviously unneeded code Scott Wood
2013-04-13  0:08       ` [PATCH v4 4/6] kvm/ppc/mpic: adapt to kernel style and environment Scott Wood
2013-04-13  0:08       ` [PATCH v4 5/6] kvm/ppc/mpic: in-kernel MPIC emulation Scott Wood
2013-04-13  0:08       ` [PATCH v4 6/6] kvm/ppc/mpic: add KVM_CAP_IRQ_MPIC Scott Wood
2013-04-15  5:23         ` Paul Mackerras
2013-04-15 17:52           ` Scott Wood
2013-04-16  3:59             ` Paul Mackerras

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=1361304966.29654.8@snotra \
    --to=scottwood@freescale.com \
    --cc=agraf@suse.de \
    --cc=cdall@cs.columbia.edu \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox