kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sheng Yang <sheng@linux.intel.com>
To: kvm@vger.kernel.org
Cc: Avi Kivity <avi@redhat.com>,
	"Han, Weidong" <weidong.han@intel.com>,
	"Kay, Allen M" <allen.m.kay@intel.com>
Subject: Re: [PATCH 4/4] KVM: x86: Enable MSI for assigned device
Date: Tue, 7 Oct 2008 13:59:58 +0800	[thread overview]
Message-ID: <200810071359.58975.sheng@linux.intel.com> (raw)
In-Reply-To: <200810061136.08909.sheng.yang@intel.com>

On Monday 06 October 2008 11:36:08 Yang, Sheng wrote:
> On Sunday 05 October 2008 18:27:20 Avi Kivity wrote:
> > Sheng Yang wrote:
> > > As well as export ioapic_get_delivery_bitmask().
> > >
> > > @@ -132,8 +177,12 @@ static void
> > > kvm_assigned_dev_interrupt_work_handler(struct work_struct *work) *
> > > finer-grained lock, update this
> > >        */
> > >       mutex_lock(&assigned_dev->kvm->lock);
> > > -     kvm_set_irq(assigned_dev->kvm,
> > > -                 assigned_dev->guest_irq, 1);
> > > +     if (assigned_dev->guest_intr_type == KVM_ASSIGNED_DEV_INTR)
> > > +             kvm_set_irq(assigned_dev->kvm, assigned_dev->guest_irq,
> > > 1); +     else if (assigned_dev->guest_intr_type ==
> > > KVM_ASSIGNED_DEV_MSI) { +            
> > > assigned_device_msi_dispatch(assigned_dev);
> > > +             enable_irq(assigned_dev->host_irq);
> > > +     }
> >
> > What happens if the host interrupt is level triggered pci and the guest
> > interrupt is msi?  Or do we not support this combination?
> >
> > If not, how do we prevent it?
>
> I think we don't need to support this combination. Currently, fail to
> enable MSI would fallback to enable IRQ. And MSI disabled guest should not
> expose MSI capability to guest. And also if guest fail to enable MSI, MSI
> enable bit in PCI configuration space should be set 0.
>
> So I would like to sent another return value to tell userspace MSI enable
> failed. And before try to enable, we may also provide a interface to
> userspace to know if MSI can be enabled.

Seems we needn't tell userspace if MSI can be enabled. It's determined mostly 
by the device, and pci_enable_msi() checked that. 

So I think QEmu can expose MSI capability if the device got it. If it's fail 
to be enabled, just fall back to IRQ and return error to QEmu is enough, of 
course, QEmu should set MSI enable bit after kernel space done.

-- 
regards
Yang, Sheng
>
> > > diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> > > index 4269be1..a9b408b 100644
> > > --- a/include/linux/kvm.h
> > > +++ b/include/linux/kvm.h
> > > @@ -493,9 +493,13 @@ struct kvm_assigned_irq {
> > >       __u32 assigned_dev_id;
> > >       __u32 host_irq;
> > >       __u32 guest_irq;
> > > +     __u16 guest_msi_data;
> >
> > Need padding here, just to be safe.
> >
> > > +     __u32 guest_msi_addr;
> >
> > Is u32 enough for the msi address?  Including ia64?
> >
> > >       __u32 flags;
> > >  };
> > >
> > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > > index e24280b..dc6a046 100644
> > > --- a/include/linux/kvm_host.h
> > > +++ b/include/linux/kvm_host.h
> > > @@ -300,8 +300,11 @@ struct kvm_assigned_dev_kernel {
> > >       int host_busnr;
> > >       int host_devfn;
> > >       int host_irq;
> > > +     u16 guest_msi_addr;
> >
> > u32?  or even u64?
>
> Oops...
>
> Well, here is enough for MSI (I mean u16 for msi_data), for PCI spec define
> the size. But I'd better extend msi_data to u32, later I will extend
> msi_addr to u64 or msi_add_lo and msi_addr_hi, for the support of MSI-X.
>
> --
> regards
> Yang, Sheng
>
> > --
> > error compiling committee.c: too many arguments to function
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



  reply	other threads:[~2008-10-07  6:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-26  5:17 [PATCH 4/4] KVM: x86: Enable MSI for assigned device Sheng Yang
2008-10-05 10:27 ` Avi Kivity
2008-10-06  3:36   ` Yang, Sheng
2008-10-07  5:59     ` Sheng Yang [this message]
2008-10-07 13:42       ` Avi Kivity
2008-10-08  2:55         ` Sheng Yang
  -- strict thread matches above, loose matches on Subject: below --
2008-10-07  6:09 Sheng Yang

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=200810071359.58975.sheng@linux.intel.com \
    --to=sheng@linux.intel.com \
    --cc=allen.m.kay@intel.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=weidong.han@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).