From patchwork Mon May 4 12:49:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 48003 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8E1E22121F for ; Mon, 4 May 2015 12:50:12 +0000 (UTC) Received: by wixv7 with SMTP id v7sf33952942wix.0 for ; Mon, 04 May 2015 05:50:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=JKZHnO73KonBzv7pK4iavjwA3HFbfTwRyDv5paR1G0w=; b=ABvM8dhIwFAS5aef5ynHeheVggdacvIUipoH+hZX66ZYeWsJ/5fLGUVy+QcDUDmxLe X8br5MAlAi3R1pPW82LxGG4p3yWs8qjNKYNwrSjAL+JwoktfhrgcpbBEAMHXOa7wrP5W i654S22mY4ONA4zDlev9yCJnvCgRJrSDsjabTXnJEwHs1VeQdUj37BUU4ZIuzY45eO9/ pCAu7sGQjEjja+raVCtDY27+XQ5F/x+MyT7klBec02l55lsJ9BsdsfJp5krngq//gSzA HG4yyQLbAYa2zknz1wKlYLf4HpoLFhfX5Ql2QhAWoK9D93Ex9KtbvjFpJDjDlFXdxJWM Yrrg== X-Gm-Message-State: ALoCoQld2bJWL+5W9PW6W6njC4THQSV2xrncJHcuZD3DZVEm4rwCarpYEfyE5eBctfxoLi/E/5NB X-Received: by 10.112.118.162 with SMTP id kn2mr18603545lbb.22.1430743811893; Mon, 04 May 2015 05:50:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.231 with SMTP id i7ls683597lae.85.gmail; Mon, 04 May 2015 05:50:11 -0700 (PDT) X-Received: by 10.112.54.225 with SMTP id m1mr19741466lbp.34.1430743811757; Mon, 04 May 2015 05:50:11 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id h8si10032311lbc.56.2015.05.04.05.50.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 05:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbuc2 with SMTP id uc2so103812321lbb.2 for ; Mon, 04 May 2015 05:50:11 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr11464594lbc.32.1430743811630; Mon, 04 May 2015 05:50:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1641088lbt; Mon, 4 May 2015 05:50:10 -0700 (PDT) X-Received: by 10.194.122.105 with SMTP id lr9mr42145014wjb.153.1430743809231; Mon, 04 May 2015 05:50:09 -0700 (PDT) Received: from mail-wg0-f54.google.com (mail-wg0-f54.google.com. [74.125.82.54]) by mx.google.com with ESMTPS id o2si11360830wic.59.2015.05.04.05.50.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 05:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.54 as permitted sender) client-ip=74.125.82.54; Received: by wgin8 with SMTP id n8so148764398wgi.0 for ; Mon, 04 May 2015 05:50:08 -0700 (PDT) X-Received: by 10.194.193.66 with SMTP id hm2mr40416073wjc.111.1430743808895; Mon, 04 May 2015 05:50:08 -0700 (PDT) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id z13sm20482370wjr.44.2015.05.04.05.50.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 May 2015 05:50:08 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org, alex.williamson@redhat.com Cc: christoffer.dall@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, b.reynal@virtualopensystems.com Subject: [RFC v2 3/4] kvm: add kvm_vfio_get_device_irq Date: Mon, 4 May 2015 13:49:57 +0100 Message-Id: <1430743798-8839-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1430743798-8839-1-git-send-email-eric.auger@linaro.org> References: <1430743798-8839-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Since the introduction of the qemu_irq/gsi hash table in kvm, the gsi information is stored in kvm. New functions are introduced to allocate/populate a kvm_vfio_dev_irq struct pointer from a qemu_irq object and free it. Signed-off-by: Eric Auger --- include/sysemu/kvm.h | 5 +++++ kvm-all.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index bc3f230..42cc6c4 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -423,6 +423,11 @@ int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, qemu_irq irq); void kvm_irqchip_set_qemuirq_gsi(KVMState *s, qemu_irq irq, int gsi); +struct kvm_vfio_dev_irq; +int kvm_vfio_get_device_irq(KVMState *s, int fd, int index, + int start, int count, qemu_irq irq, + struct kvm_vfio_dev_irq **vfio_dev_irq); +void kvm_vfio_put_device_irq(struct kvm_vfio_dev_irq *vfio_dev_irq); void kvm_pc_gsi_handler(void *opaque, int n, int level); void kvm_pc_setup_irq_routing(bool pci_enabled); void kvm_init_irq_routing(KVMState *s); diff --git a/kvm-all.c b/kvm-all.c index d2cb7ed..83a9689 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1454,6 +1454,38 @@ static int kvm_irqchip_create(MachineState *machine, KVMState *s) return 0; } +int kvm_vfio_get_device_irq(KVMState *s, int fd, int index, + int start, int count, qemu_irq irq, + struct kvm_vfio_dev_irq **vfio_dev_irq) +{ + gpointer key, gsi; + gboolean found = g_hash_table_lookup_extended(s->gsimap, irq, &key, &gsi); + struct kvm_vfio_dev_irq *pirq; + __u32 *pgsi; + int argsz; + + if (!found) { + return -ENXIO; + } + + argsz = sizeof(*pirq) + sizeof(*pgsi); + pirq = g_malloc0(argsz); + pirq->argsz = argsz; + pirq->fd = fd; + pirq->index = index; + pirq->start = start; + pirq->count = count; + pgsi = (__u32 *)&pirq->gsi; + *pgsi = GPOINTER_TO_INT(gsi); + *vfio_dev_irq = pirq; + return 0; +} + +void kvm_vfio_put_device_irq(struct kvm_vfio_dev_irq *vfio_dev_irq) +{ + g_free(vfio_dev_irq); +} + /* Find number of supported CPUs using the recommended * procedure from the kernel API documentation to cope with * older kernels that may be missing capabilities.