From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636044747; cv=none; d=zohomail.com; s=zohoarc; b=iHvKLUwY7hioDXG+5aFQxu10xNiim135Cnp5/z57uc3CkD50gCpBtl49Qv09sc3we9utVuXvC1PECt8x6C0bBER76e4liqkscMl2F+xxT8tcUbeDk3FeoGaH2yneJvhkstdA0IxlPcPjlGnqPoTmTXilTWDjB1on4t/icEVfyDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636044747; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AjgZMwIbfi0x6GDZmi4I5ljuAuKyRoJiGngpEFNQY7E=; b=bYihzQPX8QlPsKM3Nrt4w1KuqUV0GFRGy0XQfmJwUl23ZDVFB/lj9dlR4+e4V1RsScif4c6kLrLNUIccPSUbGWmFvQrfX272O3MNJXAFbx8V+wW7jsrf4b9kucOD3b8lqtSk6Aj49fggYlpyU5IlTRdMNWArJAeAkcSq9tg/P8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636044747958724.7988017634484; Thu, 4 Nov 2021 09:52:27 -0700 (PDT) Received: from localhost ([::1]:49796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mifyV-0005Ek-0t for importer@patchew.org; Thu, 04 Nov 2021 12:52:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifw2-0001NE-3x for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:49:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifw0-0005dc-Cu for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:49:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-axW-WSYlNf2Ru3i2gdV_Ow-1; Thu, 04 Nov 2021 12:49:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F3558066FB; Thu, 4 Nov 2021 16:49:41 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5449B19C79; Thu, 4 Nov 2021 16:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AjgZMwIbfi0x6GDZmi4I5ljuAuKyRoJiGngpEFNQY7E=; b=BmVSV+8CqM/u++2yBMXRX0Jv3jgf6iDSB/LbWVLRKc9QVgXEbVCq8cpUtZnc+uKLUscSWz vgpxPwbAvfy3KhFkewxh7+bQhiUFRYBVLqkMyGTVrA7khm99SggXp5eS9AZJOXeUw16lkP 1PtEtGphDM0LerLPZre4g8CjOhzrrkM= X-MC-Unique: axW-WSYlNf2Ru3i2gdV_Ow-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 01/10] virtio: introduce macro IRTIO_CONFIG_IRQ_IDX Date: Fri, 5 Nov 2021 00:48:18 +0800 Message-Id: <20211104164827.21911-2-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636044749354100002 Content-Type: text/plain; charset="utf-8" To support configure interrupt for vhost-vdpa Introduce VIRTIO_CONFIG_IRQ_IDX -1 as configure interrupt's queue index, Then we can reuse the functions guest_notifier_mask and guest_notifier_pend= ing. Add the check of queue index in these drivers, if the driver does not suppo= rt configure interrupt, the function will just return Signed-off-by: Cindy Lu --- hw/display/vhost-user-gpu.c | 6 ++++++ hw/net/virtio-net.c | 10 ++++++++-- hw/virtio/vhost-user-fs.c | 6 ++++++ hw/virtio/vhost-vsock-common.c | 6 ++++++ hw/virtio/virtio-crypto.c | 6 ++++++ include/hw/virtio/virtio.h | 3 +++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 49df56cd14..73ad3d84c9 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -485,6 +485,9 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vde= v, int idx) { VhostUserGPU *g =3D VHOST_USER_GPU(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&g->vhost->dev, idx); } =20 @@ -493,6 +496,9 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, = int idx, bool mask) { VhostUserGPU *g =3D VHOST_USER_GPU(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask); } =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f2014d5ea0..a15437d550 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3163,6 +3163,9 @@ static bool virtio_net_guest_notifier_pending(VirtIOD= evice *vdev, int idx) VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } =20 @@ -3172,8 +3175,11 @@ static void virtio_net_guest_notifier_mask(VirtIODev= ice *vdev, int idx, VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); - vhost_net_virtqueue_mask(get_vhost_net(nc->peer), - vdev, idx, mask); + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } + + vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask); } =20 static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_feature= s) diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index c595957983..9b0349922e 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -161,6 +161,9 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev,= int idx, { VHostUserFS *fs =3D VHOST_USER_FS(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask); } =20 @@ -168,6 +171,9 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vd= ev, int idx) { VHostUserFS *fs =3D VHOST_USER_FS(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&fs->vhost_dev, idx); } =20 diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f3771274e..d1b9c027b6 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -125,6 +125,9 @@ static void vhost_vsock_common_guest_notifier_mask(Virt= IODevice *vdev, int idx, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask); } =20 @@ -133,6 +136,9 @@ static bool vhost_vsock_common_guest_notifier_pending(V= irtIODevice *vdev, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&vvc->vhost_dev, idx); } =20 diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 54f9bbb789..1d5192f8b4 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -948,6 +948,9 @@ static void virtio_crypto_guest_notifier_mask(VirtIODev= ice *vdev, int idx, =20 assert(vcrypto->vhost_started); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask); } =20 @@ -958,6 +961,9 @@ static bool virtio_crypto_guest_notifier_pending(VirtIO= Device *vdev, int idx) =20 assert(vcrypto->vhost_started); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } =20 diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8bab9cfb75..605ea79c90 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -67,6 +67,9 @@ typedef struct VirtQueueElement =20 #define VIRTIO_NO_VECTOR 0xffff =20 +/* special index value used internally for config irqs */ +#define VIRTIO_CONFIG_IRQ_IDX -1 + #define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) =20 --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636044747; cv=none; d=zohomail.com; s=zohoarc; b=SPoY0ro3vpRkbqVK6LJ0epH6J7lzUORX/C4XyfU653DlloHQFcSK8kSiCC79J6TBr2o1Cnr6ESucB5fZKfCj87Zhq6kkWtq3QMmpaO0uhsZIRPQe2O/eltfC+LeJwzKGrlr1oNC9Fa+Uzdo50ry4dwSE2XjQhYcE+NXZOdtlh8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636044747; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W8BvRwJr7Umrvfb1zdL365Mx8SUovRxx6wwO8cIXYq0=; b=eGSe9PcxRGorIVYnOaUDcwTNHK2iuW6O6uRDdd/atwxMcmyPVyNy1Cee2X20eOezQ2zY2S2mzZf2m1ugdZhgTyyqGsEAj8dqDTE3TUizv/MGvscn7TrNkkrXQXT0OsS19k+TA0x0RvbFRGC46z18mDpHtTnFxMCIF1MA0KtNfVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636044747911552.5891532051563; Thu, 4 Nov 2021 09:52:27 -0700 (PDT) Received: from localhost ([::1]:49568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mifyU-00055r-T7 for importer@patchew.org; Thu, 04 Nov 2021 12:52:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwZ-0002CM-JX for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwX-0005jo-4Q for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:27 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-D9HtbeHMM76nDA-qzcYqJw-1; Thu, 04 Nov 2021 12:50:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47804100B717; Thu, 4 Nov 2021 16:50:22 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07CC919C79; Thu, 4 Nov 2021 16:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W8BvRwJr7Umrvfb1zdL365Mx8SUovRxx6wwO8cIXYq0=; b=HW49IJjop0V4SeijUACevElYGx8iokUopt820ALXmP2N/41ABfMS+SUEFzQsGdgxaKPxlB oJJ6wQmuoFocR5d8lyjHnrijvw3dBjG855UPLdXbGncMxFmiM6jos/1JPk1TpxnqtAtnK0 NkbPvl0JWbNiWpFzINCi0lXXvfK/ViE= X-MC-Unique: D9HtbeHMM76nDA-qzcYqJw-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 02/10] virtio-pci: decouple notifier from interrupt process Date: Fri, 5 Nov 2021 00:48:19 +0800 Message-Id: <20211104164827.21911-3-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636044749348100001 Content-Type: text/plain; charset="utf-8" To reuse the notifier process in configure interrupt. Use the virtio_pci_get_notifier function to get the notifier. the INPUT of this function is the IDX, the OUTPUT is notifier and the vector Signed-off-by: Cindy Lu --- hw/virtio/virtio-pci.c | 88 +++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 750aa47ec1..4bdb6e5694 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -704,29 +704,41 @@ static void kvm_virtio_pci_vq_vector_release(VirtIOPC= IProxy *proxy, } =20 static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy, - unsigned int queue_no, + EventNotifier *n, unsigned int vector) { VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; - VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - VirtQueue *vq =3D virtio_get_queue(vdev, queue_no); - EventNotifier *n =3D virtio_queue_get_guest_notifier(vq); return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->v= irq); } =20 static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy, - unsigned int queue_no, + EventNotifier *n , unsigned int vector) { - VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - VirtQueue *vq =3D virtio_get_queue(vdev, queue_no); - EventNotifier *n =3D virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; int ret; =20 ret =3D kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->vir= q); assert(ret =3D=3D 0); } +static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, + EventNotifier **n, unsigned int *vec= tor) +{ + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + VirtQueue *vq; + + if (queue_no =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return -1; + } else { + if (!virtio_queue_get_num(vdev, queue_no)) { + return -1; + } + *vector =3D virtio_queue_vector(vdev, queue_no); + vq =3D virtio_get_queue(vdev, queue_no); + *n =3D virtio_queue_get_guest_notifier(vq); + } + return 0; +} =20 static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) { @@ -735,12 +747,15 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *= proxy, int nvqs) VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); unsigned int vector; int ret, queue_no; - + EventNotifier *n; for (queue_no =3D 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - vector =3D virtio_queue_vector(vdev, queue_no); + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } if (vector >=3D msix_nr_vectors_allocated(dev)) { continue; } @@ -752,7 +767,7 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *pr= oxy, int nvqs) * Otherwise, delay until unmasked in the frontend. */ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret =3D kvm_virtio_pci_irqfd_use(proxy, queue_no, vector); + ret =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); if (ret < 0) { kvm_virtio_pci_vq_vector_release(proxy, vector); goto undo; @@ -768,7 +783,11 @@ undo: continue; } if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector); + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } + kvm_virtio_pci_irqfd_release(proxy, n, vector); } kvm_virtio_pci_vq_vector_release(proxy, vector); } @@ -782,12 +801,16 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIPr= oxy *proxy, int nvqs) unsigned int vector; int queue_no; VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - + EventNotifier *n; + int ret ; for (queue_no =3D 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - vector =3D virtio_queue_vector(vdev, queue_no); + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } if (vector >=3D msix_nr_vectors_allocated(dev)) { continue; } @@ -795,21 +818,20 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIPr= oxy *proxy, int nvqs) * Otherwise, it was cleaned when masked in the frontend. */ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector); + kvm_virtio_pci_irqfd_release(proxy, n, vector); } kvm_virtio_pci_vq_vector_release(proxy, vector); } } =20 -static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy, +static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy, unsigned int queue_no, unsigned int vector, - MSIMessage msg) + MSIMessage msg, + EventNotifier *n) { VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - VirtQueue *vq =3D virtio_get_queue(vdev, queue_no); - EventNotifier *n =3D virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd; int ret =3D 0; =20 @@ -836,14 +858,15 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy= *proxy, event_notifier_set(n); } } else { - ret =3D kvm_virtio_pci_irqfd_use(proxy, queue_no, vector); + ret =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); } return ret; } =20 -static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy, +static void virtio_pci_one_vector_mask(VirtIOPCIProxy *proxy, unsigned int queue_no, - unsigned int vector) + unsigned int vector, + EventNotifier *n) { VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); @@ -854,7 +877,7 @@ static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *p= roxy, if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { k->guest_notifier_mask(vdev, queue_no, true); } else { - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector); + kvm_virtio_pci_irqfd_release(proxy, n, vector); } } =20 @@ -864,6 +887,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, uns= igned vector, VirtIOPCIProxy *proxy =3D container_of(dev, VirtIOPCIProxy, pci_dev); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtQueue *vq =3D virtio_vector_first_queue(vdev, vector); + EventNotifier *n; int ret, index, unmasked =3D 0; =20 while (vq) { @@ -872,7 +896,8 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, uns= igned vector, break; } if (index < proxy->nvqs_with_notifiers) { - ret =3D virtio_pci_vq_vector_unmask(proxy, index, vector, msg); + n =3D virtio_queue_get_guest_notifier(vq); + ret =3D virtio_pci_one_vector_unmask(proxy, index, vector, msg= , n); if (ret < 0) { goto undo; } @@ -888,7 +913,8 @@ undo: while (vq && unmasked >=3D 0) { index =3D virtio_get_queue_index(vq); if (index < proxy->nvqs_with_notifiers) { - virtio_pci_vq_vector_mask(proxy, index, vector); + n =3D virtio_queue_get_guest_notifier(vq); + virtio_pci_one_vector_mask(proxy, index, vector, n); --unmasked; } vq =3D virtio_vector_next_queue(vq); @@ -901,15 +927,17 @@ static void virtio_pci_vector_mask(PCIDevice *dev, un= signed vector) VirtIOPCIProxy *proxy =3D container_of(dev, VirtIOPCIProxy, pci_dev); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtQueue *vq =3D virtio_vector_first_queue(vdev, vector); + EventNotifier *n; int index; =20 while (vq) { index =3D virtio_get_queue_index(vq); + n =3D virtio_queue_get_guest_notifier(vq); if (!virtio_queue_get_num(vdev, index)) { break; } if (index < proxy->nvqs_with_notifiers) { - virtio_pci_vq_vector_mask(proxy, index, vector); + virtio_pci_one_vector_mask(proxy, index, vector, n); } vq =3D virtio_vector_next_queue(vq); } @@ -925,19 +953,17 @@ static void virtio_pci_vector_poll(PCIDevice *dev, int queue_no; unsigned int vector; EventNotifier *notifier; - VirtQueue *vq; + int ret; =20 for (queue_no =3D 0; queue_no < proxy->nvqs_with_notifiers; queue_no++= ) { - if (!virtio_queue_get_num(vdev, queue_no)) { + ret =3D virtio_pci_get_notifier(proxy, queue_no, ¬ifier, &vecto= r); + if (ret < 0) { break; } - vector =3D virtio_queue_vector(vdev, queue_no); if (vector < vector_start || vector >=3D vector_end || !msix_is_masked(dev, vector)) { continue; } - vq =3D virtio_get_queue(vdev, queue_no); - notifier =3D virtio_queue_get_guest_notifier(vq); if (k->guest_notifier_pending) { if (k->guest_notifier_pending(vdev, queue_no)) { msix_set_pending(dev, vector); --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636044755; cv=none; d=zohomail.com; s=zohoarc; b=au5IeG9/ZDBLsQg74AU+3KrIXfkAE6c7QY7TyO28LBGUv6hobO5YHnw+nxsPgjAfoMDwtI//J/Iy+xu8MOSxkAP8pLzdApC88GPP3drl++ojSSXGGHkZBLYm24AxCB1K0tZMtIb+PfiX1Zucw5lTM7JI/lNEIS7pvNKj5X3nUcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636044755; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C4VQXqcxIdlbk9ABt3FO8SkhjnZdMz70WOgDYAbB06g=; b=iSXrdh0IKRYpzFRbqwdyxSQb2xiPY465gz90GdI6uvMO5c9yqRGR+blLjQUJksfDmiPNXaAKp62ohg4bu0HixkYPvX0Z+ZyUwT2pzDolDSkgasCVwVsN9/pz7XXEfx94n7JO9anhWpKpVLAFDnZlTxoSxdb+2OHEw8w7rThRQkM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636044755013332.67608269165; Thu, 4 Nov 2021 09:52:35 -0700 (PDT) Received: from localhost ([::1]:50360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mifyc-0005cH-25 for importer@patchew.org; Thu, 04 Nov 2021 12:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwd-0002En-8x for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwb-0005kA-DQ for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-6-itgwRDO7SrFhabuiirAQ-1; Thu, 04 Nov 2021 12:50:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFED48066FD; Thu, 4 Nov 2021 16:50:26 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C867E19D9F; Thu, 4 Nov 2021 16:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C4VQXqcxIdlbk9ABt3FO8SkhjnZdMz70WOgDYAbB06g=; b=RutJ6R/YyYLkaucScb2rjFTz7SOgD4GzlD576B6Sl+2+UkooPLou7qbr7/SGU3nmJYHcko nCRdhvqzltzasHwmLSXuG+UnWboujv2rZqEMU5bYQ0aJjgTXUCvVYdDCvYoDoEqb3saFui H3ilKEj3t5p+1j7fgXEkOHrl2uBkkHg= X-MC-Unique: 6-itgwRDO7SrFhabuiirAQ-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 03/10] virtio-pci: decouple the single vector from the interrupt process Date: Fri, 5 Nov 2021 00:48:20 +0800 Message-Id: <20211104164827.21911-4-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636044756195100001 Content-Type: text/plain; charset="utf-8" To reuse the interrupt process in configure interrupt Need to decouple the single vector from the interrupt process. Add new func= tion kvm_virtio_pci_vector_use_one and _release_one. These functions are use for the single vector, the whole process will finish in a loop for the vq n= umber. Signed-off-by: Cindy Lu --- hw/virtio/virtio-pci.c | 131 +++++++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 58 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4bdb6e5694..7201cf3dc1 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -677,7 +677,6 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev, } =20 static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy, - unsigned int queue_no, unsigned int vector) { VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; @@ -740,87 +739,103 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *p= roxy, int queue_no, return 0; } =20 -static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) +static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_= no) { + unsigned int vector; + int ret; + EventNotifier *n; PCIDevice *dev =3D &proxy->pci_dev; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - unsigned int vector; - int ret, queue_no; - EventNotifier *n; - for (queue_no =3D 0; queue_no < nvqs; queue_no++) { - if (!virtio_queue_get_num(vdev, queue_no)) { - break; - } - ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - if (vector >=3D msix_nr_vectors_allocated(dev)) { - continue; - } - ret =3D kvm_virtio_pci_vq_vector_use(proxy, queue_no, vector); + + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return ret; + } + if (vector >=3D msix_nr_vectors_allocated(dev)) { + return 0; + } + ret =3D kvm_virtio_pci_vq_vector_use(proxy, vector); + if (ret < 0) { + goto undo; + } + /* + * If guest supports masking, set up irqfd now. + * Otherwise, delay until unmasked in the frontend. + */ + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + ret =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); if (ret < 0) { + kvm_virtio_pci_vq_vector_release(proxy, vector); goto undo; } - /* If guest supports masking, set up irqfd now. - * Otherwise, delay until unmasked in the frontend. - */ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); - if (ret < 0) { - kvm_virtio_pci_vq_vector_release(proxy, vector); - goto undo; - } - } } - return 0; =20 + return 0; undo: - while (--queue_no >=3D 0) { - vector =3D virtio_queue_vector(vdev, queue_no); - if (vector >=3D msix_nr_vectors_allocated(dev)) { - continue; + + vector =3D virtio_queue_vector(vdev, queue_no); + if (vector >=3D msix_nr_vectors_allocated(dev)) { + return ret; + } + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return ret; } - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - kvm_virtio_pci_irqfd_release(proxy, n, vector); + kvm_virtio_pci_irqfd_release(proxy, n, vector); + } + return ret; +} +static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) +{ + int queue_no; + int ret =3D 0; + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + + for (queue_no =3D 0; queue_no < nvqs; queue_no++) { + if (!virtio_queue_get_num(vdev, queue_no)) { + return -1; } - kvm_virtio_pci_vq_vector_release(proxy, vector); + ret =3D kvm_virtio_pci_vector_use_one(proxy, queue_no); } return ret; } =20 -static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) + +static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy, + int queue_no) { - PCIDevice *dev =3D &proxy->pci_dev; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); unsigned int vector; - int queue_no; - VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); EventNotifier *n; - int ret ; + int ret; + VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); + PCIDevice *dev =3D &proxy->pci_dev; + + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return; + } + if (vector >=3D msix_nr_vectors_allocated(dev)) { + return; + } + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + kvm_virtio_pci_irqfd_release(proxy, n, vector); + } + kvm_virtio_pci_vq_vector_release(proxy, vector); +} + +static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) +{ + int queue_no; + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + for (queue_no =3D 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - if (vector >=3D msix_nr_vectors_allocated(dev)) { - continue; - } - /* If guest supports masking, clean up irqfd now. - * Otherwise, it was cleaned when masked in the frontend. - */ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - kvm_virtio_pci_irqfd_release(proxy, n, vector); - } - kvm_virtio_pci_vq_vector_release(proxy, vector); + kvm_virtio_pci_vector_release_one(proxy, queue_no); } } =20 --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636044937; cv=none; d=zohomail.com; s=zohoarc; b=S11AM/IxIVVnMdx5oO1BHvFibUz55jIm5LdSA4d6Mr2amXDl2QWiKDsDimtjkhoWOdCsinxcayzlH3g0ACMiB+lV208xUodknr+bjkm2k7Wn8/ZpGJ96SER9FTFnXJHlFC2ndfiypr/HYd70xyMY4pC0EDEpdg+TX59RmYgUpRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636044937; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dXqJdu8m4mfKoJRJDUh9ecC0KPJj1oKZs1EF2JRfya8=; b=Rtc1lsO8qiazm5IXptAp7G7NWj0QnIBjqgC/LSsRusi24enKMY8CnSwbg41XBEJBPOVBNMxwbDpo4offYz7kqKt7pEa/hxTIa04P1hxtJznt4fUQFnzptoHuEBOkeNOm+r1/k017jD3N2vAI9jjaNB4A0HdQof4EV4bFbxHfxP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636044937196334.918468417946; Thu, 4 Nov 2021 09:55:37 -0700 (PDT) Received: from localhost ([::1]:32988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig1X-0004RY-RS for importer@patchew.org; Thu, 04 Nov 2021 12:55:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwi-0002MW-E2 for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwg-0005ks-Ql for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-3N3G6fDYO6-EnFBzwAuf2w-1; Thu, 04 Nov 2021 12:50:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B84F79EEA; Thu, 4 Nov 2021 16:50:30 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5928019723; Thu, 4 Nov 2021 16:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dXqJdu8m4mfKoJRJDUh9ecC0KPJj1oKZs1EF2JRfya8=; b=JumEqJiPzZqwKE0V2hLprRMkyBbxYvTZPmULFcwFseAUOyKSlVeqJoOMmA+I/9+ua6lEXl AceabDusLv8B7rt+eF4ZTimvqRP8MHJFOQXM+G5lpy24Rjgsr0T8v7AiGERTK/g7xaJxcy 0ZZlLpQqmwMFSp8JDuDNpCuIp+S6zL8= X-MC-Unique: 3N3G6fDYO6-EnFBzwAuf2w-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 04/10] vhost: introduce new VhostOps vhost_set_config_call Date: Fri, 5 Nov 2021 00:48:21 +0800 Message-Id: <20211104164827.21911-5-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636044938032100001 Content-Type: text/plain; charset="utf-8" This patch introduces new VhostOps vhost_set_config_call. This function all= ows the vhost to set the event fd to kernel Signed-off-by: Cindy Lu --- include/hw/virtio/vhost-backend.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index 81bf3109f8..ff34eb7c8a 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -126,6 +126,8 @@ typedef int (*vhost_get_device_id_op)(struct vhost_dev = *dev, uint32_t *dev_id); =20 typedef bool (*vhost_force_iommu_op)(struct vhost_dev *dev); =20 +typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev, + int fd); typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -171,6 +173,7 @@ typedef struct VhostOps { vhost_vq_get_addr_op vhost_vq_get_addr; vhost_get_device_id_op vhost_get_device_id; vhost_force_iommu_op vhost_force_iommu; + vhost_set_config_call_op vhost_set_config_call; } VhostOps; =20 int vhost_backend_update_device_iotlb(struct vhost_dev *dev, --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636044898; cv=none; d=zohomail.com; s=zohoarc; b=IfbuKj9rQGytLlDPQfarVFba/nwpJqaaD1Gg/xxUhXciB2cT29GKM1vepjLNTIICxsAkfjWXxh5IBEjcGJ8oc3l3ZYjLQa+s2j16zum53blWpRNk7z1g/uMEueKDgjqua7fiDIQboMZ4c9yEbVTxM2LFEVnGU+RY1ooJ0iwIwzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636044898; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iguch9u2+PHlJzQFa6f7Cpvfd5ci8T6b1ek0E7WwpZw=; b=bNtyEJ5bxshYI0mGgNZKqQw9J8WDH4Zbm99q9JvRd0s6ALK0p/gEwrDOm4JEgHIq3nKrbGA5ZhqNv4ijL7mUpsP9Ww0CE+EiyfJdOcSBecu6hglriCbbQoFZx9oRcqeEK5O8dMhBXpX24WXKtgMgyRpR8IlhQ48seKkddsQsxJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636044898413915.6934671626417; Thu, 4 Nov 2021 09:54:58 -0700 (PDT) Received: from localhost ([::1]:58990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig0v-0002wx-9E for importer@patchew.org; Thu, 04 Nov 2021 12:54:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwm-0002bY-Iz for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwk-0005lF-Se for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-534-VkQq4CSwMwyQWJMSmOP9YA-1; Thu, 04 Nov 2021 12:50:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8081100B704; Thu, 4 Nov 2021 16:50:33 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8ACD19723; Thu, 4 Nov 2021 16:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iguch9u2+PHlJzQFa6f7Cpvfd5ci8T6b1ek0E7WwpZw=; b=PC5H4pBqLJ3fU2tt+EKldNf39R7OD8dm4IUQkOEZ1yVRYic8c+1zWch8Qpb+7F4vCk/nkr vWF6ABr7bOzVZMBZKMkd4566WRztXXlx6wjBIDsApAKpKdtfVsVO+n91JcO409idiWBXVo wMBBvHd7XkwyR6oDwfLBRJYCsNaioPc= X-MC-Unique: VkQq4CSwMwyQWJMSmOP9YA-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 05/10] vhost-vdpa: add support for config interrupt Date: Fri, 5 Nov 2021 00:48:22 +0800 Message-Id: <20211104164827.21911-6-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636044900271100001 Content-Type: text/plain; charset="utf-8" Add new call back function in vhost-vdpa, this function will set the event fd to kernel. This function will be called in the vhost_dev_start and vhost_dev_stop Signed-off-by: Cindy Lu --- hw/virtio/trace-events | 1 + hw/virtio/vhost-vdpa.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 650e521e35..39c36ff7a6 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -53,6 +53,7 @@ vhost_vdpa_get_features(void *dev, uint64_t features) "de= v: %p features: 0x%"PRI vhost_vdpa_set_owner(void *dev) "dev: %p" vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint6= 4_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_add= r: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64 vhost_vdpa_get_iova_range(void *dev, uint64_t first, uint64_t last) "dev: = %p first: 0x%"PRIx64" last: 0x%"PRIx64 +vhost_vdpa_set_config_call(void *dev, int fd)"dev: %p fd: %d" =20 # virtio.c virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned o= ut_num) "elem %p size %zd in_num %u out_num %u" diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 12661fd5b1..abec1b5bbb 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -712,6 +712,12 @@ static int vhost_vdpa_set_vring_call(struct vhost_dev = *dev, trace_vhost_vdpa_set_vring_call(dev, file->index, file->fd); return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file); } +static int vhost_vdpa_set_config_call(struct vhost_dev *dev, + int fd) +{ + trace_vhost_vdpa_set_config_call(dev, fd); + return vhost_vdpa_call(dev, VHOST_VDPA_SET_CONFIG_CALL, &fd); +} =20 static int vhost_vdpa_get_features(struct vhost_dev *dev, uint64_t *features) @@ -782,4 +788,5 @@ const VhostOps vdpa_ops =3D { .vhost_get_device_id =3D vhost_vdpa_get_device_id, .vhost_vq_get_addr =3D vhost_vdpa_vq_get_addr, .vhost_force_iommu =3D vhost_vdpa_force_iommu, + .vhost_set_config_call =3D vhost_vdpa_set_config_call, }; --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636045030; cv=none; d=zohomail.com; s=zohoarc; b=mqmDpeZVoe0s2iR8TcYUfl0DYVcBR0kCIGCqLIthxs9159PInixz7obnVOTfrWF0meQISRxwUi6Xv5wg+h5hqkOYItAEKZSheYc67GT5Sa/EvN5eouOGP2h/i6BhtuFNGmEd+L4kSwKT3UC1r4VsWKfPeVcYKSUvb01m+Q8asOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636045030; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g617noijUXa3UMu9e0Ou21XBI1LIdOqzKE9NgDG9ACU=; b=O3Ci5q7mS5u1Av94Bfdr2U7rYojidyDoX90F5ZDRIPt4eBtQuqj/P3VSE1xZQkZz/Dd8lUYtcBV0zXVn+s0M8bI9Ir6qsBENSxyvCfM+a10qHIpQb1dycCGoQWHGLJD5uQ2k29o9TF/AqIX2ucCS0YB9dohqe9gbWfDxTWiwF4Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636045030860838.9100268663332; Thu, 4 Nov 2021 09:57:10 -0700 (PDT) Received: from localhost ([::1]:37816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig33-0007mD-Sy for importer@patchew.org; Thu, 04 Nov 2021 12:57:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwp-0002ne-Kx for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwn-0005ly-Sn for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-bxiHMB9CPD2zKwBDgxeGmg-1; Thu, 04 Nov 2021 12:50:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 620171006AA8; Thu, 4 Nov 2021 16:50:37 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61A1519D9F; Thu, 4 Nov 2021 16:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g617noijUXa3UMu9e0Ou21XBI1LIdOqzKE9NgDG9ACU=; b=Epv8e80tBQEgEVI7MIzRJe7SB4/xy0ttF1CCQ/Z/Z4Fklr1UFBv3wFSJNKF/5hA1npkYqI Wf3YQyTNQOTLNq57WExwq2k4B67B583ARTif85QECWugWBNP9aKKXdOnBtdVWWZ3+rMrH9 Zq1crVKAPaFkPjA39ntoBx4RaMQkYVI= X-MC-Unique: bxiHMB9CPD2zKwBDgxeGmg-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 06/10] virtio: add support for configure interrupt Date: Fri, 5 Nov 2021 00:48:23 +0800 Message-Id: <20211104164827.21911-7-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636045033026100001 Content-Type: text/plain; charset="utf-8" Add the functions to support the configure interrupt in virtio The function virtio_config_guest_notifier_read will notify the guest if there is an configure interrupt. The function virtio_config_set_guest_notifier_fd_handler is to set the fd hander for the notifier Signed-off-by: Cindy Lu --- hw/virtio/virtio.c | 29 +++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index cc69a9b881..0aab3ea1df 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3499,7 +3499,14 @@ static void virtio_queue_guest_notifier_read(EventNo= tifier *n) virtio_irq(vq); } } +static void virtio_config_guest_notifier_read(EventNotifier *n) +{ + VirtIODevice *vdev =3D container_of(n, VirtIODevice, config_notifier); =20 + if (event_notifier_test_and_clear(n)) { + virtio_notify_config(vdev); + } +} void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign, bool with_irqfd) { @@ -3516,6 +3523,23 @@ void virtio_queue_set_guest_notifier_fd_handler(Virt= Queue *vq, bool assign, } } =20 +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev, + bool assign, bool with_ir= qfd) +{ + EventNotifier *n; + n =3D &vdev->config_notifier; + if (assign && !with_irqfd) { + event_notifier_set_handler(n, virtio_config_guest_notifier_read); + } else { + event_notifier_set_handler(n, NULL); + } + if (!assign) { + /* Test and clear notifier before closing it,*/ + /* in case poll callback didn't have time to run. */ + virtio_config_guest_notifier_read(n); + } +} + EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq) { return &vq->guest_notifier; @@ -3589,6 +3613,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQu= eue *vq) return &vq->host_notifier; } =20 +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev) +{ + return &vdev->config_notifier; +} + void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled) { vq->host_notifier_enabled =3D enabled; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 605ea79c90..d78088d872 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -111,6 +111,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + EventNotifier config_notifier; }; =20 struct VirtioDeviceClass { @@ -313,11 +314,14 @@ uint16_t virtio_get_queue_index(VirtQueue *vq); EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq); void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign, bool with_irqfd); +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev, + bool assign, bool with_ir= qfd); int virtio_device_start_ioeventfd(VirtIODevice *vdev); int virtio_device_grab_ioeventfd(VirtIODevice *vdev); void virtio_device_release_ioeventfd(VirtIODevice *vdev); bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev); EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq); +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev); void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled); void virtio_queue_host_notifier_read(EventNotifier *n); void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext = *ctx, --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636045128; cv=none; d=zohomail.com; s=zohoarc; b=OCl/QCgyslLhfe4//tfTMNRSG2lj6adCQ5EgVp89hj5GimxElDsz4CVLbiznO2/6AfButYs2VN+lQVtxK5RJc2vUEgs7cql+oDoYZPo/oOD1zZTBUK3qTxa3jVOxGy9yOc/XFR+JOaVk742QxAihdciRcLOj+xGsq6b2Rk/vCZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636045128; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NS7XVIajNLxHzN/j7VzsMNfhK27CUllcV1KUOHe/Ok4=; b=lf9uO9gAfODBojCTGrPoWpsqrXGxyc/K7Z5qxvbh9rIIQlS5BsQav8aipp+D260bEf0KMD6DORmPKy6jWb/KYwO94OJDGLr9wpWRV6D/x81OkJz8+uY8Gu1rLh6+hZrMTiUvJqiLGyiUSzJG1fiy3otqGoAHg9WQkP7AIoQJVfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636045128422532.5833201712376; Thu, 4 Nov 2021 09:58:48 -0700 (PDT) Received: from localhost ([::1]:42510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig4d-0002gg-GP for importer@patchew.org; Thu, 04 Nov 2021 12:58:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwu-0002xL-H8 for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwr-0005mv-HV for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-PsV6V4PUMUO_iKGYQmBJOA-1; Thu, 04 Nov 2021 12:50:41 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE36F1006AA9; Thu, 4 Nov 2021 16:50:40 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF4AC19C79; Thu, 4 Nov 2021 16:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NS7XVIajNLxHzN/j7VzsMNfhK27CUllcV1KUOHe/Ok4=; b=FxoQ9S+FyA+nETYxf25bi1w1zaVhMc/73SKO083sDSm5UvUYdY6WU14vhI68OS0/k5dLF0 5Y4pBlp6Iej0z9w1TPfQnAuvZF3UltfHgd6CjC+q1vz3SBtsQWd5Uho2K7SJ2zX1RdIVO2 BLg/xzjOb9UOUUyF2rQaiOF47Mgani8= X-MC-Unique: PsV6V4PUMUO_iKGYQmBJOA-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 07/10] vhost: add support for configure interrupt Date: Fri, 5 Nov 2021 00:48:24 +0800 Message-Id: <20211104164827.21911-8-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636045129006100001 Content-Type: text/plain; charset="utf-8" Add functions to support configure interrupt. The configure interrupt process will start in vhost_dev_start and stop in vhost_dev_stop. Also add the functions to support vhost_config_pending and vhost_config_mask, for masked_config_notifier, we only use the notifier saved in vq 0. Signed-off-by: Cindy Lu --- hw/virtio/vhost.c | 76 +++++++++++++++++++++++++++++++++++++++ include/hw/virtio/vhost.h | 4 +++ 2 files changed, 80 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 437347ad01..9451a6222e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1561,6 +1561,67 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vi= rtIODevice *vdev, int n, } } =20 +bool vhost_config_pending(struct vhost_dev *hdev) +{ + assert(hdev->vhost_ops); + if ((hdev->started =3D=3D false) || + (hdev->vhost_ops->vhost_set_config_call =3D=3D NULL)) { + return false; + } + + EventNotifier *notifier =3D + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; + return event_notifier_test_and_clear(notifier); +} + +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool ma= sk) +{ + int fd; + int r; + EventNotifier *notifier =3D + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; + EventNotifier *config_notifier =3D &vdev->config_notifier; + assert(hdev->vhost_ops); + + if ((hdev->started =3D=3D false) || + (hdev->vhost_ops->vhost_set_config_call =3D=3D NULL)) { + return; + } + if (mask) { + assert(vdev->use_guest_notifier_mask); + fd =3D event_notifier_get_fd(notifier); + } else { + fd =3D event_notifier_get_fd(config_notifier); + } + r =3D hdev->vhost_ops->vhost_set_config_call(hdev, fd); + if (r < 0) { + VHOST_OPS_DEBUG("vhost_set_config_call failed"); + } +} + +static void vhost_stop_config_intr(struct vhost_dev *dev) +{ + int fd =3D -1; + assert(dev->vhost_ops); + if (dev->vhost_ops->vhost_set_config_call) { + dev->vhost_ops->vhost_set_config_call(dev, fd); + } +} + +static void vhost_start_config_intr(struct vhost_dev *dev) +{ + int r; + + assert(dev->vhost_ops); + int fd =3D event_notifier_get_fd(&dev->vdev->config_notifier); + if (dev->vhost_ops->vhost_set_config_call) { + r =3D dev->vhost_ops->vhost_set_config_call(dev, fd); + if (!r) { + event_notifier_set(&dev->vdev->config_notifier); + } + } +} + uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bit= s, uint64_t features) { @@ -1773,6 +1834,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODe= vice *vdev) } } =20 + r =3D event_notifier_init( + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier, 0); + if (r < 0) { + return r; + } + event_notifier_test_and_clear( + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); + if (!vdev->use_guest_notifier_mask) { + vhost_config_mask(hdev, vdev, true); + } if (hdev->log_enabled) { uint64_t log_base; =20 @@ -1806,6 +1877,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) vhost_device_iotlb_miss(hdev, vq->used_phys, true); } } + vhost_start_config_intr(hdev); return 0; fail_log: vhost_log_put(hdev, false); @@ -1831,6 +1903,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) =20 /* should only be called after backend is connected */ assert(hdev->vhost_ops); + event_notifier_test_and_clear( + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); + event_notifier_test_and_clear(&vdev->config_notifier); =20 if (hdev->vhost_ops->vhost_dev_start) { hdev->vhost_ops->vhost_dev_start(hdev, false); @@ -1848,6 +1923,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) } memory_listener_unregister(&hdev->iommu_listener); } + vhost_stop_config_intr(hdev); vhost_log_put(hdev, true); hdev->started =3D false; hdev->vdev =3D NULL; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 3fa0b554ef..ef649ea004 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -29,6 +29,7 @@ struct vhost_virtqueue { unsigned long long used_phys; unsigned used_size; EventNotifier masked_notifier; + EventNotifier masked_config_notifier; struct vhost_dev *dev; }; =20 @@ -37,6 +38,7 @@ typedef unsigned long vhost_log_chunk_t; #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t)) #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS) #define VHOST_INVALID_FEATURE_BIT (0xff) +#define VHOST_QUEUE_NUM_CONFIG_INR 0 =20 struct vhost_log { unsigned long long size; @@ -116,6 +118,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev); void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vde= v); +bool vhost_config_pending(struct vhost_dev *hdev); +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool ma= sk); =20 /* Test and clear masked event pending status. * Should be called after unmask to avoid losing events. --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636045052; cv=none; d=zohomail.com; s=zohoarc; b=loTxXxZI8Pto4TO7LMmLrYCcMmigHrDdy9btfK4J2DtIh6AYb3KA6HtocxTygVbBeP5mV8r5sCt7KsHgTw0mDQ4b9iGwb5XBS57nIzGhF/bOD8dvqZxwnolip48uC5em43uE3QKGqJk3VvjM5eVCyc+Q7hjxF6EwhJLe076Tme4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636045052; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qBvndLk8Y7BHZ9LP09jR1kSVwjv3H1BIuMTJHdS7S6g=; b=JLisQc6YJFkmb2H/HNbzOWwmh9jB8DwuZapsFgcGqQl+jil90Pjo0ZLgYTONClxe300hy3coNOuwOIozpITKgyJjWMn237po50xmn1ahjaw/Q0lOlb4GF8lsHkmtBxlRE2F5NzZ5G+hZjX5QzhYLlQ++vDbvhWTr1KLe0YrHPnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636045052716972.7862072480758; Thu, 4 Nov 2021 09:57:32 -0700 (PDT) Received: from localhost ([::1]:39624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig3P-0000a8-MX for importer@patchew.org; Thu, 04 Nov 2021 12:57:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwu-0002xM-Rk for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifws-0005nF-VM for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-ZMo8DLjYNeKo99UOvNfpug-1; Thu, 04 Nov 2021 12:50:45 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 596651927803; Thu, 4 Nov 2021 16:50:44 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6811B19D9F; Thu, 4 Nov 2021 16:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qBvndLk8Y7BHZ9LP09jR1kSVwjv3H1BIuMTJHdS7S6g=; b=bBP6AAxKBSjvBjmNUoCBgF4q+p6AHY3RluelSo1vnQiUtm7AJFVFqiIMH32ufMC58T1Fjg BnrJW2HpWYLxEZ9M7wBqO4Di7EmIQkA1tSuxIGtU/jKTTp/V3Y6I26AAg1YPsUGAFuSJJp X8wgWvo8B+jQV3afrFThKjSktbCgL88= X-MC-Unique: ZMo8DLjYNeKo99UOvNfpug-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 08/10] virtio-net: add support for configure interrupt Date: Fri, 5 Nov 2021 00:48:25 +0800 Message-Id: <20211104164827.21911-9-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636045054877100001 Content-Type: text/plain; charset="utf-8" Add functions to support configure interrupt in virtio_net The functions are config_pending and config_mask, while this input idx is VIRTIO_CONFIG_IRQ_IDX will check the function of configure interrupt. Signed-off-by: Cindy Lu --- hw/net/vhost_net.c | 9 +++++++++ hw/net/virtio-net.c | 4 ++-- include/net/vhost_net.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 0d888f29a6..f328295725 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -457,6 +457,15 @@ void vhost_net_virtqueue_mask(VHostNetState *net, Virt= IODevice *dev, vhost_virtqueue_mask(&net->dev, dev, idx, mask); } =20 +bool vhost_net_config_pending(VHostNetState *net) +{ + return vhost_config_pending(&net->dev); +} + +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mas= k) +{ + vhost_config_mask(&net->dev, dev, mask); +} VHostNetState *get_vhost_net(NetClientState *nc) { VHostNetState *vhost_net =3D 0; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index a15437d550..025a139ff2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3164,7 +3164,7 @@ static bool virtio_net_guest_notifier_pending(VirtIOD= evice *vdev, int idx) NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { - return false; + return vhost_net_config_pending(get_vhost_net(nc->peer)); } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } @@ -3176,9 +3176,9 @@ static void virtio_net_guest_notifier_mask(VirtIODevi= ce *vdev, int idx, NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + vhost_net_config_mask(get_vhost_net(nc->peer), vdev, mask); return; } - vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask); } =20 diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 387e913e4e..fc37498550 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -39,6 +39,8 @@ int vhost_net_set_config(struct vhost_net *net, const uin= t8_t *data, bool vhost_net_virtqueue_pending(VHostNetState *net, int n); void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, int idx, bool mask); +bool vhost_net_config_pending(VHostNetState *net); +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mas= k); int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr); VHostNetState *get_vhost_net(NetClientState *nc); =20 --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636045006; cv=none; d=zohomail.com; s=zohoarc; b=ZFHQ8gj0hnb+qk4VXxxLAddZqh+cxAytnVN0x6bwZeYNNRgnnBTDgzeBnY/xXTt7kZ3Cy3np9MC++kj9PAU7w/LFKML+oe0+S2/3jvO359B3Nzj0xzWChLuEE60lRKSKfUQ7lTn8ZwnA6HU+H6MmkHkSMFNqbos6ARUxDmMAUC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636045006; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=n+COXzMtg0U5vco/wTB+ZT0pGGoa1DFN74TtKmDZ37w=; b=VTX4OEubViwGKDDf2ASM8kVyczceqx4Q7ddJHvxQ6JzflSBxhFpQlanC7k26Z7C78pm2PJRmz8WbBOyn3c9BWRZ3KDEGRkkhQ5TKcTpIy7OGKhQHq6XFlnbiqDBIeHc69vb8vETdtSEOBCrAtlzxGgh6Ar2zmEhp7zE4UWGetDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636045006531412.48308847726025; Thu, 4 Nov 2021 09:56:46 -0700 (PDT) Received: from localhost ([::1]:36530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig2f-0006uc-Fw for importer@patchew.org; Thu, 04 Nov 2021 12:56:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwz-0003HD-S5 for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifwy-0005nu-AZ for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:50:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-EMqt5sNUMz6r6_6hy7osfg-1; Thu, 04 Nov 2021 12:50:48 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3D0D1006AB7; Thu, 4 Nov 2021 16:50:47 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E59EA19723; Thu, 4 Nov 2021 16:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n+COXzMtg0U5vco/wTB+ZT0pGGoa1DFN74TtKmDZ37w=; b=QA8m9Yr3jChS0EYVK9QV7MhaGBBzCzJAR8PHk2jgfFxgE09XRRWbv8FSIQvanOD1NOQEkc FU2jX4x0TUFo75Jq6afMC6kzqz8jM13wK851zGj39w8ciuL/1PA6XcYcDV2C4MgH3VszCP NmQAICOCWHMuTkKFicQ6oK5cWnd3TDw= X-MC-Unique: EMqt5sNUMz6r6_6hy7osfg-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 09/10] virtio-mmio: add support for configure interrupt Date: Fri, 5 Nov 2021 00:48:26 +0800 Message-Id: <20211104164827.21911-10-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636045006882100001 Content-Type: text/plain; charset="utf-8" Add configure interrupt support for virtio-mmio bus. This interrupt will be working while the backend is vhost-vdpa Signed-off-by: Cindy Lu --- hw/virtio/virtio-mmio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 7b3ebca178..2089cb06df 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -673,7 +673,30 @@ static int virtio_mmio_set_guest_notifier(DeviceState = *d, int n, bool assign, =20 return 0; } +static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assi= gn) +{ + VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(d); + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + bool with_irqfd =3D false; + EventNotifier *notifier =3D virtio_config_get_guest_notifier(vdev); + int r =3D 0; =20 + if (assign) { + r =3D event_notifier_init(notifier, 0); + if (r < 0) { + return r; + } + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irq= fd); + } else { + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irq= fd); + event_notifier_cleanup(notifier); + } + if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) { + vdc->guest_notifier_mask(vdev, VIRTIO_CONFIG_IRQ_IDX, !assign); + } + return r; +} static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) { @@ -695,6 +718,10 @@ static int virtio_mmio_set_guest_notifiers(DeviceState= *d, int nvqs, goto assign_error; } } + r =3D virtio_mmio_set_config_guest_notifier(d, assign); + if (r < 0) { + goto assign_error; + } =20 return 0; =20 --=20 2.21.3 From nobody Sun May 19 16:27:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636045270; cv=none; d=zohomail.com; s=zohoarc; b=iLwYd4TtXLPut3fBqwEdnt88BecREQT4BZVBIHLEGY7ctD0GU7Iq8VqQiJt/XwNwSYYXnY/qOc39nstNreV1PZeWZjy02t5B+exkIr8I0jPhDfOLxufdjslRhQ+8IsQmKiGbiXB6nEfXudg92au5a+Ztunxi/6kSgFwbgpZ5TyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636045270; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GtWMixhTHSZa/O7h8aKzYX2C7hGQndOTBhrOocIiKwQ=; b=NsizvWAkbdFFI1LfDuPM/rzboNLhROSccSTqjOKTlUKMpjDkic2aYQkfl3l3/j5fQ1UCpotTYNcQX6yQx7HViXe4xANOAMbLu+nRt16sPt3fieUepFzj7yksruvj/OncY0opOLOwSy8F4PESc/fKGyyfWVjj0nr7tSZcLjqef/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636045270175897.9709635260498; Thu, 4 Nov 2021 10:01:10 -0700 (PDT) Received: from localhost ([::1]:45916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig6u-0004xt-F5 for importer@patchew.org; Thu, 04 Nov 2021 13:01:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifxB-0003Q5-AR for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:51:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifx5-0005oc-AO for qemu-devel@nongnu.org; Thu, 04 Nov 2021 12:51:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-CwjmAGyuP0CucaWcS8oBvQ-1; Thu, 04 Nov 2021 12:50:52 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BE651006AA3; Thu, 4 Nov 2021 16:50:51 +0000 (UTC) Received: from laptop.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CB2019723; Thu, 4 Nov 2021 16:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636044655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GtWMixhTHSZa/O7h8aKzYX2C7hGQndOTBhrOocIiKwQ=; b=WFyJb2MNKLlmclFhVT4xPEGMGlZ6FbzC5Hij9u8eXlYqYtGLkk9wGwfwYG0yW0rqBwvsAl borKZG3l4IzXY8dpe8MZQo57miinBGD7y+Vc+T2XQauOIa+kvqbmETdu/k/gnthXY9e9F/ HMdXQqZxPVTe1EohAygha+MXXO8Th0A= X-MC-Unique: CwjmAGyuP0CucaWcS8oBvQ-1 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, kraxel@redhat.com, dgilbert@redhat.com, stefanha@redhat.com, arei.gonglei@huawei.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v10 10/10] virtio-pci: add support for configure interrupt Date: Fri, 5 Nov 2021 00:48:27 +0800 Message-Id: <20211104164827.21911-11-lulu@redhat.com> In-Reply-To: <20211104164827.21911-1-lulu@redhat.com> References: <20211104164827.21911-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lulu@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.648, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636045274598100001 Content-Type: text/plain; charset="utf-8" Add support for configure interrupt, The process is used kvm_irqfd_assign to set the gsi to kernel. When the configure notifier was signal by host, qemu will inject a msix interrupt to guest Signed-off-by: Cindy Lu --- hw/virtio/virtio-pci.c | 92 ++++++++++++++++++++++++++++++++++++------ hw/virtio/virtio-pci.h | 4 +- 2 files changed, 83 insertions(+), 13 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7201cf3dc1..98fb5493ae 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -727,7 +727,8 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *prox= y, int queue_no, VirtQueue *vq; =20 if (queue_no =3D=3D VIRTIO_CONFIG_IRQ_IDX) { - return -1; + *n =3D virtio_config_get_guest_notifier(vdev); + *vector =3D vdev->config_vector; } else { if (!virtio_queue_get_num(vdev, queue_no)) { return -1; @@ -802,6 +803,10 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *p= roxy, int nvqs) return ret; } =20 +static int kvm_virtio_pci_vector_config_use(VirtIOPCIProxy *proxy) +{ + return kvm_virtio_pci_vector_use_one(proxy, VIRTIO_CONFIG_IRQ_IDX); +} =20 static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy, int queue_no) @@ -839,6 +844,11 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIPro= xy *proxy, int nvqs) } } =20 +static void kvm_virtio_pci_vector_config_release(VirtIOPCIProxy *proxy) +{ + kvm_virtio_pci_vector_release_one(proxy, VIRTIO_CONFIG_IRQ_IDX); +} + static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy, unsigned int queue_no, unsigned int vector, @@ -920,9 +930,17 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, un= signed vector, } vq =3D virtio_vector_next_queue(vq); } - + /* unmask config intr */ + n =3D virtio_config_get_guest_notifier(vdev); + ret =3D virtio_pci_one_vector_unmask(proxy, VIRTIO_CONFIG_IRQ_IDX, vec= tor, + msg, n); + if (ret < 0) { + goto undo_config; + } return 0; - +undo_config: + n =3D virtio_config_get_guest_notifier(vdev); + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n); undo: vq =3D virtio_vector_first_queue(vdev, vector); while (vq && unmasked >=3D 0) { @@ -956,6 +974,8 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsi= gned vector) } vq =3D virtio_vector_next_queue(vq); } + n =3D virtio_config_get_guest_notifier(vdev); + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n); } =20 static void virtio_pci_vector_poll(PCIDevice *dev, @@ -987,6 +1007,34 @@ static void virtio_pci_vector_poll(PCIDevice *dev, msix_set_pending(dev, vector); } } + /* poll the config intr */ + ret =3D virtio_pci_get_notifier(proxy, VIRTIO_CONFIG_IRQ_IDX, ¬ifie= r, + &vector); + if (ret < 0) { + return; + } + if (vector < vector_start || vector >=3D vector_end || + !msix_is_masked(dev, vector)) { + return; + } + if (k->guest_notifier_pending) { + if (k->guest_notifier_pending(vdev, VIRTIO_CONFIG_IRQ_IDX)) { + msix_set_pending(dev, vector); + } + } else if (event_notifier_test_and_clear(notifier)) { + msix_set_pending(dev, vector); + } +} + +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueu= e *vq, + int n, bool assign, + bool with_irqfd) +{ + if (n =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irq= fd); + } else { + virtio_queue_set_guest_notifier_fd_handler(vq, assign, with_irqfd); + } } =20 static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assig= n, @@ -995,17 +1043,25 @@ static int virtio_pci_set_guest_notifier(DeviceState= *d, int n, bool assign, VirtIOPCIProxy *proxy =3D to_virtio_pci_proxy(d); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); - VirtQueue *vq =3D virtio_get_queue(vdev, n); - EventNotifier *notifier =3D virtio_queue_get_guest_notifier(vq); + VirtQueue *vq =3D NULL; + EventNotifier *notifier =3D NULL; + + if (n =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + notifier =3D virtio_config_get_guest_notifier(vdev); + } else { + vq =3D virtio_get_queue(vdev, n); + notifier =3D virtio_queue_get_guest_notifier(vq); + } =20 if (assign) { int r =3D event_notifier_init(notifier, 0); if (r < 0) { return r; } - virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd); + virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, true, with_i= rqfd); } else { - virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd); + virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, false, + with_irqfd); event_notifier_cleanup(notifier); } =20 @@ -1047,6 +1103,7 @@ static int virtio_pci_set_guest_notifiers(DeviceState= *d, int nvqs, bool assign) msix_unset_vector_notifiers(&proxy->pci_dev); if (proxy->vector_irqfd) { kvm_virtio_pci_vector_release(proxy, nvqs); + kvm_virtio_pci_vector_config_release(proxy); g_free(proxy->vector_irqfd); proxy->vector_irqfd =3D NULL; } @@ -1062,7 +1119,11 @@ static int virtio_pci_set_guest_notifiers(DeviceStat= e *d, int nvqs, bool assign) goto assign_error; } } - + r =3D virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, assign, + with_irqfd); + if (r < 0) { + goto config_assign_error; + } /* Must set vector notifier after guest notifier has been assigned */ if ((with_irqfd || k->guest_notifier_mask) && assign) { if (with_irqfd) { @@ -1071,11 +1132,14 @@ static int virtio_pci_set_guest_notifiers(DeviceSta= te *d, int nvqs, bool assign) msix_nr_vectors_allocated(&proxy->pci_dev)); r =3D kvm_virtio_pci_vector_use(proxy, nvqs); if (r < 0) { - goto assign_error; + goto config_assign_error; } } - r =3D msix_set_vector_notifiers(&proxy->pci_dev, - virtio_pci_vector_unmask, + r =3D kvm_virtio_pci_vector_config_use(proxy); + if (r < 0) { + goto config_error; + } + r =3D msix_set_vector_notifiers(&proxy->pci_dev, virtio_pci_vector= _unmask, virtio_pci_vector_mask, virtio_pci_vector_poll); if (r < 0) { @@ -1090,7 +1154,11 @@ notifiers_error: assert(assign); kvm_virtio_pci_vector_release(proxy, nvqs); } - +config_error: + kvm_virtio_pci_vector_config_release(proxy); +config_assign_error: + virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, !assign, + with_irqfd); assign_error: /* We get here on assignment failure. Recover by undoing for VQs 0 .. = n. */ assert(assign); diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 2446dcd9ae..b704acc5a8 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -251,5 +251,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTyp= eInfo *t); * @fixed_queues. */ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); - +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueu= e *vq, + int n, bool assign, + bool with_irqfd); #endif --=20 2.21.3