public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCHv3] qemu-kvm: enable msi with irqchip
Date: Sun, 05 Jul 2009 21:03:00 +0300	[thread overview]
Message-ID: <4A50EAD4.8010800@redhat.com> (raw)
In-Reply-To: <20090705173545.GA9882@redhat.com>

On 07/05/2009 08:35 PM, Michael S. Tsirkin wrote:
> Support msi-x with irqchip in kernel: allocate entries
> when they are used, and update when they are unmasked.
>
> @@ -340,6 +447,10 @@ void msix_notify(PCIDevice *dev, unsigned vector)
>           msix_set_pending(dev, vector);
>           return;
>       }
> +    if (kvm_enabled()&&  qemu_kvm_irqchip_in_kernel()) {
> +        kvm_set_irq(dev->msix_irq_entries[vector].gsi, 1, NULL);
>    

Toggle back to zero after setting to one, for consistency.

> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -1448,6 +1448,60 @@ int kvm_del_routing_entry(kvm_context_t kvm,
>   #endif
>   }
>
> +int kvm_update_routing_entry(kvm_context_t kvm,
> +	                  struct kvm_irq_routing_entry* entry,
> +                          struct kvm_irq_routing_entry* newentry)
> +{
> +#ifdef KVM_CAP_IRQ_ROUTING
> +	struct kvm_irq_routing_entry *e;
> +	int i, gsi, found = 0;
> +
> +        if (entry->gsi != newentry->gsi ||
> +            entry->type != newentry->type) {
> +            return -EINVAL;
> +        }
> +	gsi = entry->gsi;
> +
> +	for (i = 0; i<  kvm->irq_routes->nr; ++i) {
> +		e =&kvm->irq_routes->entries[i];
> +		if (e->type != entry->type || e->gsi != gsi) {
> +                    continue;
> +                }
> +		switch (e->type)
> +		{
> +		case KVM_IRQ_ROUTING_IRQCHIP: {
> +			if (e->u.irqchip.irqchip ==
> +			    entry->u.irqchip.irqchip
> +			&&  e->u.irqchip.pin ==
> +			    entry->u.irqchip.pin) {
> +			    found = 1;
> +                        }
>    

this
is
not
readable

> +			break;
> +		}
> +		case KVM_IRQ_ROUTING_MSI: {
> +			if (e->u.msi.address_lo ==
> +			    entry->u.msi.address_lo
> +			&&  e->u.msi.address_hi ==
> +			    entry->u.msi.address_hi
> +			&&  e->u.msi.data == entry->u.msi.data) {
> +			    found = 1;
> +                        }
> +			break;
> +		}
> +		default:
> +			break;
> +		}
> +		if (found) {
> +			memcpy(e, entry, sizeof *e);
> +			return 0;
> +		}
> +	}
> +	return -ESRCH;
> +#else
> +	return -ENOSYS;
> +#endif
> +}
>    

Please detab the whole thing.

You use perror() on functions that return -errno; please fix.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


  reply	other threads:[~2009-07-05 18:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-05 17:35 [PATCHv3] qemu-kvm: enable msi with irqchip Michael S. Tsirkin
2009-07-05 18:03 ` Avi Kivity [this message]
2009-07-05 18:26   ` Michael S. Tsirkin
2009-07-07 11:21     ` Avi Kivity
2009-07-05 18:52   ` Michael S. Tsirkin
2009-07-07 11:27     ` Avi Kivity

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=4A50EAD4.8010800@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.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