From nobody Tue May 7 02:48:13 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=1658645784; cv=none; d=zohomail.com; s=zohoarc; b=YmIFen1i5DrkUXxDaNluyTNdqu9KhRDIkGwzp9mhaXnBm3/A+TnqeRmYVXXOiNV7jRZRSRdAQg/E6ca0EeW3pz/oXelMD7xPaVBs0LdVaI5OOQEpKUIXB1aXnvJfUcW80sn3Q7cUfxyArJ08bVdfOzJfatbJxr1BN71YXKtqq84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658645784; h=Content-Transfer-Encoding:Cc: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=i6mN44fkdddLIPK1oj9Nw2c5VmWN2IOoaODCpqqcQhk=; b=JotF3+for4asE817Fk0Kf4pzLrmB/wFAgPUx5NjJhzzFbwvQRmjXFt75VZhQrjkDpBtrPKdseQKTzjNbEX11flm/EHmk4MPg7ZkD6KXZm2SSmM6i/Go4HlFDUzvEgu+4pVwjDnCgpfemphJwv4Ek5mbl5aO9a0aJfnexLnYBYCM= 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 1658645784584441.3471225012977; Sat, 23 Jul 2022 23:56:24 -0700 (PDT) Received: from localhost ([::1]:40070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVXL-0004Gr-HF for importer@patchew.org; Sun, 24 Jul 2022 02:56:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVMV-0004Pv-9D for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVMT-0003N7-Gj for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:10 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-227-2YibO4R7MFeVlfWVL4ghQA-1; Sun, 24 Jul 2022 02:45:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 200A6280048C; Sun, 24 Jul 2022 06:45:05 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E9F91415118; Sun, 24 Jul 2022 06:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i6mN44fkdddLIPK1oj9Nw2c5VmWN2IOoaODCpqqcQhk=; b=B/cOOfCShNK1NVXv//or1vlIqQGtP9R6jthZ5qekuHZo2Pq4UTw42rh9Ecl4VPDZ839OkO Lh88+37SzS7FwZDCWXF6ZQjydLeAaTbrGELclYqZOCgqPIiVICVSUrtENgPHvbOc0srON0 r65J27fiB74537HVJxqsuQCD/qwD50E= X-MC-Unique: 2YibO4R7MFeVlfWVL4ghQA-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 01/10] virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX Date: Sun, 24 Jul 2022 14:44:45 +0800 Message-Id: <20220724064454.875882-2-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658645785523100001 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 | 15 +++++++++++++++ hw/net/virtio-net.c | 20 ++++++++++++++++++-- hw/virtio/vhost-user-fs.c | 16 ++++++++++++++++ hw/virtio/vhost-vsock-common.c | 16 ++++++++++++++++ hw/virtio/virtio-crypto.c | 16 ++++++++++++++++ include/hw/virtio/virtio.h | 3 +++ 6 files changed, 84 insertions(+), 2 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 3340ef9e5f..8454514da5 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -485,6 +485,13 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vd= ev, int idx) { VhostUserGPU *g =3D VHOST_USER_GPU(vdev); =20 + /* Add the check for configure interrupt, we use VIRTIO_CONFIG_IRQ_IDX= -1 + * as the Marco of configure interrupt, If this driver does not + * support, the function will just return false + */ + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&g->vhost->dev, idx); } =20 @@ -493,6 +500,14 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev,= int idx, bool mask) { VhostUserGPU *g =3D VHOST_USER_GPU(vdev); =20 + /* Add the check for configure interrupt,Here use VIRTIO_CONFIG_IRQ_ID= X -1 + * as the Marco of configure interrupt, If this driver does not + * support, the function will return + */ + + 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 dd0d056fde..b6d36b034c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3215,6 +3215,14 @@ static bool virtio_net_guest_notifier_pending(VirtIO= Device *vdev, int idx) } else { nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); } + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return false + */ + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } =20 @@ -3238,8 +3246,16 @@ static void virtio_net_guest_notifier_mask(VirtIODev= ice *vdev, int idx, } else { nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); } - vhost_net_virtqueue_mask(get_vhost_net(nc->peer), - vdev, idx, mask); + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + 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 e513e4fdda..806c7680f0 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -161,6 +161,14 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev= , int idx, { VHostUserFS *fs =3D VHOST_USER_FS(vdev); =20 + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask); } =20 @@ -168,6 +176,14 @@ static bool vuf_guest_notifier_pending(VirtIODevice *v= dev, int idx) { VHostUserFS *fs =3D VHOST_USER_FS(vdev); =20 + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + 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 7394818e00..37a20ffe8a 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -125,6 +125,14 @@ static void vhost_vsock_common_guest_notifier_mask(Vir= tIODevice *vdev, int idx, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask); } =20 @@ -133,6 +141,14 @@ static bool vhost_vsock_common_guest_notifier_pending(= VirtIODevice *vdev, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + 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 c1243c3f93..fbf37e140d 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1139,6 +1139,14 @@ static void virtio_crypto_guest_notifier_mask(VirtIO= Device *vdev, int idx, =20 assert(vcrypto->vhost_started); =20 + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask); } =20 @@ -1149,6 +1157,14 @@ static bool virtio_crypto_guest_notifier_pending(Vir= tIODevice *vdev, int idx) =20 assert(vcrypto->vhost_started); =20 + /* Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 + * as the Marco of configure interrupt's IDX, If this driver does not + * support, the function will return + */ + + 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 db1c0ddf6b..e985ef133f 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -68,6 +68,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.34.3 From nobody Tue May 7 02:48:13 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=1658645481; cv=none; d=zohomail.com; s=zohoarc; b=NhuEvxO0IC9rP+1xpmisOCngqpQ/kT1BFRxMxSycpd2XSdczyaOzGc0ONTLFWFWmxCRZkvHn80gmAtPlwgWBcCVZWCp8VArFoFatSOxg8qr4eniE91BYe8iOyBjVsy+lNPDPaHAIj62QiIzfM4RwQlZ9mmLzS0/Jzi4Q3CiYhvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658645481; h=Content-Transfer-Encoding:Cc: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=XLZKXyKfm8tsNxQ0vGS/PE1Z2pYbzuD8+wZhFLcNMJ8=; b=AuaDFbJR2cOkQeVjr9LiqFDLTBIq3qEM81ifc3LYrOsfFHFKaQPpS7JXnhoSCTr/62gszXSXq3fmaPIkvWImxmHfjC6CVsEkPcC+u3cv/6+0MI1xvlH7oyj4CGv6srvQA+PwrO/h5oflfR3PRGvZ6ohL89qMIYcH+MKM4V0QDDs= 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 1658645481938520.3538752438697; Sat, 23 Jul 2022 23:51:21 -0700 (PDT) Received: from localhost ([::1]:60198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVSM-0006zL-9u for importer@patchew.org; Sun, 24 Jul 2022 02:51:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVMc-0004Q3-TY for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVMb-0003NT-2n for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:18 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-356-qgdVXipBOdCWUjkujGEa2w-1; Sun, 24 Jul 2022 02:45:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 882EC185A7A4; Sun, 24 Jul 2022 06:45:09 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id B92C41415118; Sun, 24 Jul 2022 06:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XLZKXyKfm8tsNxQ0vGS/PE1Z2pYbzuD8+wZhFLcNMJ8=; b=P5RKruq+wLZVZaFPXsJQVPq+ruNwaKYRIG34RXFAhacGtbB+htfQc+wSM/gwOShnKZEuWh YvHuvXJ1tRFtLzfkc014McapJwypEy86jvn2n8Xe5GBzvBHLKz0VB7+C5BtdvfC+kgryzb oqy4QglBRlCNTEowmim3TQhDDRvQjW4= X-MC-Unique: qgdVXipBOdCWUjkujGEa2w-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 02/10] virtio-pci: decouple notifier from interrupt process Date: Sun, 24 Jul 2022 14:44:46 +0800 Message-Id: <20220724064454.875882-3-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658645484336100001 Content-Type: text/plain; charset="utf-8" To reuse the notifier process. We add the virtio_pci_get_notifier to get the notifier and vector. The INPUT for this function is IDX, The OUTPUT is the 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 45327f0b31..ea56677f7a 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -706,29 +706,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) { @@ -737,12 +749,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; } @@ -754,7 +769,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; @@ -770,7 +785,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); } @@ -784,12 +803,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; } @@ -797,21 +820,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 @@ -838,14 +860,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); @@ -856,7 +879,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 @@ -866,6 +889,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) { @@ -874,7 +898,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; } @@ -890,7 +915,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); @@ -903,15 +929,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); } @@ -927,19 +955,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.34.3 From nobody Tue May 7 02:48:13 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=1658646180; cv=none; d=zohomail.com; s=zohoarc; b=bF7iPaC7Trdo2jCDgBAh+F6WWwt7rAx7/nz+78T7/KrXOGeYpm5JOPGRNtHndO/BWDJaabexNQK0+H3Z4jHhlU0slTfJUBkcduT3yce9X2q+O7fNcBYHILquEGM9WLrBPOPvyqETXeFiqG8uWfKCCAFH2hlqPxtNU4L2UqfL/0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658646180; h=Content-Transfer-Encoding:Cc: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=WVIi9dzhn3h/iAAgcP0FAieppLfNZ4JMv2CqHEQoiD0=; b=MTWv31HjZR9IN5WJEyJ8ndvSkDQGXugy1s9QjyfMlsxSM2QMQEIGSnBJur1NUngkWrJPW0e708IVSDLWHIkhAhbv9GaAc6dX3P0cRpzsOg3Oa08u9wrsa/AzdswtmlfPIgrDixra2OqVShI/zDxyUvz2z24RQSzpEvmCILEjEhY= 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 1658646180021210.15409641032068; Sun, 24 Jul 2022 00:03:00 -0700 (PDT) Received: from localhost ([::1]:47564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVdh-0001G2-DC for importer@patchew.org; Sun, 24 Jul 2022 03:02:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVMe-0004QH-CX for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVMc-0003Oh-Kz for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-595-nNrZPRTwPHuPm426NfauSQ-1; Sun, 24 Jul 2022 02:45:14 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1B42185A79C; Sun, 24 Jul 2022 06:45:13 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DB1C1415118; Sun, 24 Jul 2022 06:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WVIi9dzhn3h/iAAgcP0FAieppLfNZ4JMv2CqHEQoiD0=; b=HHJFRJNJvKIA8Cm0RNLZnPPsT9jVp8MnQCnuByuvivJIy6RUtGKboznI2ozbAyiYvihuWV UYVOCEEcJWLNvdugCfKianhQjv6d5ESy3MbR/ACVgiGmvjqa26U4f3wBgpp4CWbCK5DO8U SUKjI+m4eUuEKjirERjimMMlrLxnLHw= X-MC-Unique: nNrZPRTwPHuPm426NfauSQ-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 03/10] virtio-pci: decouple the single vector from the interrupt process Date: Sun, 24 Jul 2022 14:44:47 +0800 Message-Id: <20220724064454.875882-4-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658646181422100001 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. We add new function kvm_virtio_pci_vector_use_one and _release_one. These functions are used for the single vector, the whole process will finish in the loop with vq number. 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 ea56677f7a..4362dab725 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]; @@ -742,87 +741,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.34.3 From nobody Tue May 7 02:48:13 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=1658646579; cv=none; d=zohomail.com; s=zohoarc; b=UOdMDtaerhER2iP8PLTq143dcp3PCJRpBiw1jfY/almR9TVeCwbVGyL9YN+k2lKfi9+OqUqGStRt2rTeWt/FbI7GLfxC7Ak/hPZNlEo6vvl3Qupk0LQbkJRqBpIgyz4VrmM4qh/E7CFcqYR2bNBqsS6DLkcvDNFsj8/OhV4rRGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658646579; h=Content-Transfer-Encoding:Cc: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=mYg1jvI6tjkFfFk0fOxA+wuPT1k9GhFHFQlHY8fqSCw=; b=etnPS95tJckam1lgOGFEJ0yQ4CMt8vhAOtF+H9CpEvpA0JtC/+ub4+EoOHwGL2DGQioHeAkGwMShDGKLUzpmTdIb3D1apAP54wdy0WI9rFyOzyKaFDJFvd7IGZkctWDFs/cDPTsE8D3C/6Z+x3Rk3ljyTek9EciBcybvkFCVaqQ= 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 1658646579563277.5807392593689; Sun, 24 Jul 2022 00:09:39 -0700 (PDT) Received: from localhost ([::1]:54706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVkA-0006S6-0X for importer@patchew.org; Sun, 24 Jul 2022 03:09:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVN7-0004dt-I0 for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVN4-0003PN-DV for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:47 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-xK7moIYZOMaDnY9uW8eO2Q-1; Sun, 24 Jul 2022 02:45:40 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 01E8E8037B5; Sun, 24 Jul 2022 06:45:40 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B17C492CA2; Sun, 24 Jul 2022 06:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mYg1jvI6tjkFfFk0fOxA+wuPT1k9GhFHFQlHY8fqSCw=; b=DA8qANGn5RdzKPbMEz2UmYjWDgEnwG0fC++sek6liXfpMEAay6aEON5GZxpCgfIY0GMR9c 5OYXsf95ida7NS2RUju97TgH7k5eCuUeZx+mEGiQ9AhtI4gPbmzkKuoiec9jhTlYFFp+Ie x8/JeyBIjKRNRkUOC4t2bwgmYtoSuHE= X-MC-Unique: xK7moIYZOMaDnY9uW8eO2Q-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 04/10] vhost: introduce new VhostOps vhost_set_config_call Date: Sun, 24 Jul 2022 14:44:48 +0800 Message-Id: <20220724064454.875882-5-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658646580315100001 Content-Type: text/plain; charset="utf-8" This patch introduces new VhostOps vhost_set_config_call. This function allows the qemu to set the config event fd to kernel driver. 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 eab46d7f0b..c5ab49051e 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -128,6 +128,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; @@ -174,6 +176,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.34.3 From nobody Tue May 7 02:48:13 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=1658645519; cv=none; d=zohomail.com; s=zohoarc; b=Nv6QSIo75QACNn21jEVLoo+kipBWUojLT2OaPuCVEwlpmSIaPkwz1nShPlf7dTPHAXSEi5rFReXKboVDacZsXqwUk7BBJPoMpUD1xG+dvETDYtPFbSpbYYYzErJsLI5hyvB2E4CQwXWBIMonQTnhNvYb3ja18+a157Hmg1c5I0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658645519; h=Content-Transfer-Encoding:Cc: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=0R8/o/H//w+Em8yVHPk0aLYQdVGAy+AfVTjew+q36VM=; b=CW6f4zwoU4J867hMxbOkQm2xesMp0zkZ510LqvycO7N9+XUf3yPa6xPzYkCKvah3q1ilgCCwZRmWyLIUFuaWE+1ce6N1AU/TGU20zyjLyjrPRK/cljRjYpA9uSMAgumcTvFVsJHdnmY4Swvq8WBVPr40PjUk50UH0zmTzbDVfUQ= 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 1658645519712115.50120477079497; Sat, 23 Jul 2022 23:51:59 -0700 (PDT) Received: from localhost ([::1]:60986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVT4-0007Xd-A7 for importer@patchew.org; Sun, 24 Jul 2022 02:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVN8-0004g7-AA for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVN6-0003PY-QH for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-522-3EhtIzzDNkCwMfpXLNdvDQ-1; Sun, 24 Jul 2022 02:45:44 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B4678001EA; Sun, 24 Jul 2022 06:45:44 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A88C492CA2; Sun, 24 Jul 2022 06:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0R8/o/H//w+Em8yVHPk0aLYQdVGAy+AfVTjew+q36VM=; b=Cr1ZriydiG3T1lvOsrzNQ+hhIZh+ZC4eNB1fDOB7hL9naUftD6ONv413UrSU0rbEfafJOt MFsDBaJIpxmERY+s0u0S0KBJ9ELt/tT5mqvxAiDLwvU5cBpJurVbViR1HkFmRBwYtkJn9Z 8objTE0Za33kpCPS+6xfcj1wuVPalKo= X-MC-Unique: 3EhtIzzDNkCwMfpXLNdvDQ-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 05/10] vhost-vdpa: add support for config interrupt Date: Sun, 24 Jul 2022 14:44:49 +0800 Message-Id: <20220724064454.875882-6-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658645521451100001 Content-Type: text/plain; charset="utf-8" Add new call back function in vhost-vdpa, The function vhost_set_config_call can 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 | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 20af2e7ebd..1f510ba86e 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -58,6 +58,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 291cd19054..da8413c9fd 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -744,6 +744,13 @@ static int vhost_vdpa_set_vring_ready(struct vhost_dev= *dev) return 0; } =20 +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); +} + static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *c= onfig, uint32_t config_len) { @@ -1322,4 +1329,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.34.3 From nobody Tue May 7 02:48:13 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=1658645799; cv=none; d=zohomail.com; s=zohoarc; b=NSwmpggSkUSVAmjovliKmHFyco7gDywfrPf6MT89x5Q0FHPN4iwVPahlJZbzBXqy10rCVTkHsVQ/gNt0Tqxtb5yO4BeHqCHsMgzCSPZWQKKdK84E/jQZpiWvD51hWpDjG5PZC3Vl7iKDUBmBMH7S1ES1Xl9geggmPIm+tVeLr/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658645799; h=Content-Transfer-Encoding:Cc: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=H1KSQDFw0wKLEGkuP4wLTrs17GepD794izZHkM03jG4=; b=SOEDJG8TGjmKKL/fuPLQ9BFBF82rA9kYwjjJioloo//E0VfWVPLTRbHtBObeJXQW6y42bXscL0VfhZM9+RAsQ69uFITW0KxA6HGyMBxrcDJ+zDLvYzYX8DR83VUmZ9DKIwyAs7TzNP7JN2fVkBWj84PNbbsH8/adOSL7GPJio0k= 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 1658645799018753.0083389579704; Sat, 23 Jul 2022 23:56:39 -0700 (PDT) Received: from localhost ([::1]:40982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVXY-0004z9-RF for importer@patchew.org; Sun, 24 Jul 2022 02:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNC-0004lu-7Q for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNA-0003Pk-7m for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:53 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-F2DrVIV4M3mdB5stsS0EqA-1; Sun, 24 Jul 2022 02:45:49 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D1FE68001EA; Sun, 24 Jul 2022 06:45:48 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F493492CA2; Sun, 24 Jul 2022 06:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645151; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H1KSQDFw0wKLEGkuP4wLTrs17GepD794izZHkM03jG4=; b=W/dr+w4OhBqWBxOtsymaXmNrv8ZqkzBxhcCpPS4cLmzrkt+Yl5HZNdWoGANk79Sh5UmoY4 sTm4axyFzO+xwdqZPyOu9f9tOyy5/lgtyzu7FjuwrYiElGGeukA9dBb1mQJNYac8r+vui7 47r832vTFyhnuTfisO4ORNAvIO2y5xM= X-MC-Unique: F2DrVIV4M3mdB5stsS0EqA-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 06/10] virtio: add support for configure interrupt Date: Sun, 24 Jul 2022 14:44:50 +0800 Message-Id: <20220724064454.875882-7-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658645799450100001 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 5d607aeaa0..ab1b46ae28 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3521,7 +3521,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) { @@ -3538,6 +3545,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; @@ -3618,6 +3642,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 e985ef133f..a7b8cebb60 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -113,6 +113,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + EventNotifier config_notifier; }; =20 struct VirtioDeviceClass { @@ -327,6 +328,9 @@ void virtio_queue_aio_attach_host_notifier_no_poll(Virt= Queue *vq, AioContext *ct void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx); VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector); VirtQueue *virtio_vector_next_queue(VirtQueue *vq); +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev); +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev, + bool assign, bool with_ir= qfd); =20 static inline void virtio_add_feature(uint64_t *features, unsigned int fbi= t) { --=20 2.34.3 From nobody Tue May 7 02:48:13 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=1658646228; cv=none; d=zohomail.com; s=zohoarc; b=bGUyOcww5C5rH+cm3RidEimav81LG6UxVShRkD4aIXW7jKm6wLwMpaf6lckHag5kUnz/GOTHk16K4QwQY+LjmxDF9aoOcWTyOx4ot5fCcTEcRbM1z5GC0nwpnY+4sOSQcLkdg9f8VrnRac+d+bI/46YtIh3p0MAXB9j7AvNAu1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658646228; h=Content-Transfer-Encoding:Cc: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=oRu8AIzOUJBaLnDj6qqh50rHCDucqt8y2AAF1zCpofM=; b=UlCYlWbfgSccc0+++Gj3H1k2v21y6TF/xcKhixKf5GlcUuzkD5J5LkS7zUtekXUxffI21dCoqxn2nAwNyQ7Wvu/EXSHN7folUkWuD8rygHyY8nlKeTEixCyr+w90P8fwZz294ImtKUyo4aACS0CgfBXXuR7WZTSAS3wNJJipRiA= 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 1658646228407901.4034003889328; Sun, 24 Jul 2022 00:03:48 -0700 (PDT) Received: from localhost ([::1]:48364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVeV-0001wL-0a for importer@patchew.org; Sun, 24 Jul 2022 03:03:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNF-0004q0-7V for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVND-0003Pw-Hs for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:45:56 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-pj3JL2ZrM2OshIle55lPfw-1; Sun, 24 Jul 2022 02:45:53 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4721285A581; Sun, 24 Jul 2022 06:45:53 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 765B4492CA2; Sun, 24 Jul 2022 06:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oRu8AIzOUJBaLnDj6qqh50rHCDucqt8y2AAF1zCpofM=; b=X8IT7j+E4/O57OhPFVOHLTtPyWX33Xjwx3Az7tYZoQ+IBKacqUkVV4RzoJQhdtRxKpAZK2 HfHeFYUUTnWVPzWeQyH06uhvzy/7I1cS3/jCNPqcN/RVUTRM1aNCxCv69UrzUBRy4ozIf2 x/3/r3mAkdINo2oMY7pzzYm56v6Inxs= X-MC-Unique: pj3JL2ZrM2OshIle55lPfw-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 07/10] vhost: add support for configure interrupt Date: Sun, 24 Jul 2022 14:44:51 +0800 Message-Id: <20220724064454.875882-8-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658646229428100001 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. Signed-off-by: Cindy Lu --- hw/virtio/vhost.c | 78 ++++++++++++++++++++++++++++++++++++++- include/hw/virtio/vhost.h | 4 ++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..4479b4c94a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1590,7 +1590,68 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vi= rtIODevice *vdev, int n, file.index =3D hdev->vhost_ops->vhost_get_vq_index(hdev, n); r =3D hdev->vhost_ops->vhost_set_vring_call(hdev, &file); if (r < 0) { - VHOST_OPS_DEBUG(r, "vhost_set_vring_call failed"); + error_report("vhost_set_vring_call failed %d", -r); + } +} + +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) { + error_report("vhost_set_config_call failed %d", -r); + } +} + +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); + } } } =20 @@ -1807,6 +1868,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 @@ -1839,6 +1910,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); @@ -1864,6 +1936,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); @@ -1881,6 +1956,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; vdev->vhost_started =3D false; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..3b336a15e3 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -30,6 +30,7 @@ struct vhost_virtqueue { unsigned used_size; EventNotifier masked_notifier; EventNotifier error_notifier; + EventNotifier masked_config_notifier; struct vhost_dev *dev; }; =20 @@ -38,6 +39,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; @@ -161,6 +163,8 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, = VirtIODevice *vdev); * Disable direct notifications to vhost device. */ 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 /** * vhost_dev_start() - start the vhost device --=20 2.34.3 From nobody Tue May 7 02:48:13 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=1658645554; cv=none; d=zohomail.com; s=zohoarc; b=cy8PjBpTFgvkS3nEXeA9YZo7E2KslgjFqF0846vNatAPJ4LXS1p2x5QOZaVyfsIzSimrlbHGX45lAlVquLMxDui0yt42NVENFzMf9/Pf0QTK7Lrfv8uwRdTe2GZoMBM3KT6OKcA+7uXp6OmqYrmM2YV5JaRmmVkxFLgCR6e2yuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658645554; h=Content-Transfer-Encoding:Cc: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=WQcSdTzse/x1hiQ+3PG9rxsElwrN+D1MAEjeF1WVIWc=; b=D/xXwdkafl9jXGlVkLEYBlJDPgJvB4zxwdlPKnukriSwfsKgGz7vbD+iy0jaXV1Hq2Hd78snhYTtDGQnY++asVu9jm/d/eaBJDhKbgJPaRhA+QsxB6obBeFfbWmOY8OrkXJH62o5KTg6kMrxpiSBtY98xbgEi6g1F6+uhrjeFZE= 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 1658645554251870.8138579400115; Sat, 23 Jul 2022 23:52:34 -0700 (PDT) Received: from localhost ([::1]:33342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVTd-0007wb-2u for importer@patchew.org; Sun, 24 Jul 2022 02:52:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNg-00057H-3L for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:46:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNe-0003S6-9N for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:46:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-266-OL0zxRyvNOSeWriNqRfq-g-1; Sun, 24 Jul 2022 02:46:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD739811E7A; Sun, 24 Jul 2022 06:46:19 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74DA740357BA; Sun, 24 Jul 2022 06:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WQcSdTzse/x1hiQ+3PG9rxsElwrN+D1MAEjeF1WVIWc=; b=VbTsXfZuiQAl5omi5LNuAhAxYQjdGB+X0Pn73vWqaBAEwF2ViOCGtBfD2VNw0tfrWC2qD/ ZFECUFbsLg8V7hvt9r56dtwnPER85hrnANFsJWbANZU3hroHIQsESFBHeLu84lGkSMYUc9 cH0ROhn7GDPfqAS1lSoRDYHUpox2wAU= X-MC-Unique: OL0zxRyvNOSeWriNqRfq-g-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 08/10] virtio-net: add support for configure interrupt Date: Sun, 24 Jul 2022 14:44:52 +0800 Message-Id: <20220724064454.875882-9-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658645555570100001 Content-Type: text/plain; charset="utf-8" Add functions to support configure interrupt in virtio_net Add the functions to support vhost_net_config_pending and vhost_net_config_mask. 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 ccac5b7a64..273a8d8ab7 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -459,6 +459,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 b6d36b034c..f4a2c6b981 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3221,7 +3221,7 @@ static bool virtio_net_guest_notifier_pending(VirtIOD= evice *vdev, int idx) */ =20 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); } @@ -3252,9 +3252,9 @@ static void virtio_net_guest_notifier_mask(VirtIODevi= ce *vdev, int idx, */ =20 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.34.3 From nobody Tue May 7 02:48:13 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=1658645827; cv=none; d=zohomail.com; s=zohoarc; b=S69+2eNVp9dCeNL6nxsM+JU/AFVb7SlXo9VerrBGLZbXQNhV0RYDH0VjibTG8moiZpfnQJCtac/7hVYDfSUgftCUjPX1fvXAV4bg4v9jM4HmKdQy5M4DfhehaMYdUTUtpjyaRMbXt88hnnVWKdyMZrO17k5oTYy7WgXjCeHU1AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658645827; h=Content-Transfer-Encoding:Cc: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=MGoo6xtwgs7hXpbVUHEof+Ihaf7fPTu33nQzpjv+Qbs=; b=NmtgfiRXyag3zLItmJzD0BJerdgEPf85rFYmB8JwJA9Y6HrlS6B1bQ6omnGpNjy7WQGhNeE+vm5sB9Atr6LFRbKBtZBxyIazFnbZ6pu/kpK8wKH/LcDIJk49GfD9sCtw5kp6ZE2HM3TAd3Ij2QOaDEPDJNKPzGmlsyOetvKACFg= 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 1658645827239325.4183961767351; Sat, 23 Jul 2022 23:57:07 -0700 (PDT) Received: from localhost ([::1]:41550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVY2-0005MD-66 for importer@patchew.org; Sun, 24 Jul 2022 02:57:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNl-0005Ar-U8 for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:46:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNk-0003SS-Em for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:46:29 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-JJ9Ik2UTMSCZUDfZfCvc7g-1; Sun, 24 Jul 2022 02:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5312E3C02B7C; Sun, 24 Jul 2022 06:46:24 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81905404E4B5; Sun, 24 Jul 2022 06:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MGoo6xtwgs7hXpbVUHEof+Ihaf7fPTu33nQzpjv+Qbs=; b=WQ7F1ZPjQj1iCRjiLufEpF+kMbk/q/FrHsa4OYnlfte4TmUkqVBjEzeKiVJZzaiFre+zYj yeacGf2DzgP2zD5lXRfWVbnOFPoSIKF1sz32xETnUQHBSWurETtrH+4aR2ap3x8sWNmAMM zrcpGY+8/pvYEcZTUdhqSbhbeAkDZSE= X-MC-Unique: JJ9Ik2UTMSCZUDfZfCvc7g-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 09/10] virtio-mmio: add support for configure interrupt Date: Sun, 24 Jul 2022 14:44:53 +0800 Message-Id: <20220724064454.875882-10-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658645827520100001 Content-Type: text/plain; charset="utf-8" Add configure interrupt support in virtio-mmio bus. add function to set configure guest notifier. 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 d240efef97..103260ec15 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -670,7 +670,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, + bool with_irqfd) +{ + VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(d); + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + 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) { @@ -692,6 +715,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, with_irqfd); + if (r < 0) { + goto assign_error; + } =20 return 0; =20 --=20 2.34.3 From nobody Tue May 7 02:48:13 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=1658646262; cv=none; d=zohomail.com; s=zohoarc; b=EpZMne2xxCxORrpgdDS9HsWuuMdEvE3IkxkyiQsiGTcS6RqF/SA2elidGDKMIM+hYD7mnV66nV7Q6Fqm+5BwIESxpscXl3zqfoy1IchNDHKyRT42icAbk4EsXgbpgo0/R8CXyJMZ/LE7q+5FAaowpgMnRMZEoFEzq3imRGef3J0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658646262; h=Content-Transfer-Encoding:Cc: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=TDMHIvdzp3QucS/3oNUqw+QHWcyOw2mZPVShezzh+0M=; b=dSqvR3xZtqdQJSKCJc5CU/KgKimaAxVd0op6itYS4+AwuM28wKcjLyTBPocHbpvdyqGH6q+5MFCMq4iOCPNrJ8B94jdJk9xJmNe9pF/AJU3TZZlNfDbNwDWvoTGflJTTcT/Y0J/hO4P5QUAaFZYrbKbj7FL3llFbqeznyNM97c0= 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 1658646262269262.9686812392895; Sun, 24 Jul 2022 00:04:22 -0700 (PDT) Received: from localhost ([::1]:49098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFVf0-0002RH-QI for importer@patchew.org; Sun, 24 Jul 2022 03:04:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNr-0005CA-AC for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:46:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFVNp-0003Se-7U for qemu-devel@nongnu.org; Sun, 24 Jul 2022 02:46:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643-pwGdnxukMtKyTIFKg7YQSQ-1; Sun, 24 Jul 2022 02:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD643803520; Sun, 24 Jul 2022 06:46:28 +0000 (UTC) Received: from server.redhat.com (ovpn-12-73.pek2.redhat.com [10.72.12.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBEC340D2962; Sun, 24 Jul 2022 06:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658645192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TDMHIvdzp3QucS/3oNUqw+QHWcyOw2mZPVShezzh+0M=; b=h5eSwukvT1D3Ik1ropCbvuE6xgaeBBXdzbUwTZinGokGr+hiPidMUFEy1aQyIrOCwNoKtk E9uvY9H7+9O0mhoUgK7xGpbevZs4ggpJUiHe2Cl2WQWoOIbIetLZ6JrsE6jGqburZxbldT rMjWZwIl9BnFHFpcw8YPbx+7I+O3oHY= X-MC-Unique: pwGdnxukMtKyTIFKg7YQSQ-1 From: Cindy Lu To: qemu-devel@nongnu.org, lulu@redhat.com Cc: Stefan Hajnoczi , virtio-fs@redhat.com, "Dr. David Alan Gilbert" , Gerd Hoffmann , Jason Wang , "Gonglei (Arei)" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH v15 10/10] virtio-pci: add support for configure interrupt Date: Sun, 24 Jul 2022 14:44:54 +0800 Message-Id: <20220724064454.875882-11-lulu@redhat.com> In-Reply-To: <20220724064454.875882-1-lulu@redhat.com> References: <20220724064454.875882-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1658646263631100001 Content-Type: text/plain; charset="utf-8" Add process to handle the configure interrupt, The function's logic is the same with vq interrupt.Add extra process to check the configure interrupt Signed-off-by: Cindy Lu --- hw/virtio/virtio-pci.c | 110 ++++++++++++++++++++++++++++----- include/hw/virtio/virtio-pci.h | 4 +- 2 files changed, 96 insertions(+), 18 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4362dab725..17e87ebccc 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -729,7 +729,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; @@ -789,7 +790,7 @@ undo: } return ret; } -static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) +static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs) { int queue_no; int ret =3D 0; @@ -804,6 +805,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) @@ -828,7 +833,7 @@ static void kvm_virtio_pci_vector_release_one(VirtIOPCI= Proxy *proxy, kvm_virtio_pci_vq_vector_release(proxy, vector); } =20 -static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) +static void kvm_virtio_pci_vector_vq_release(VirtIOPCIProxy *proxy, int nv= qs) { int queue_no; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); @@ -841,6 +846,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, @@ -922,9 +932,19 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, un= signed vector, } vq =3D virtio_vector_next_queue(vq); } - + /* unmask config intr */ + if (vector =3D=3D vdev->config_vector) { + n =3D virtio_config_get_guest_notifier(vdev); + ret =3D virtio_pci_one_vector_unmask(proxy, VIRTIO_CONFIG_IRQ_IDX,= vector, + 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) { @@ -958,6 +978,11 @@ static void virtio_pci_vector_mask(PCIDevice *dev, uns= igned vector) } vq =3D virtio_vector_next_queue(vq); } + + if (vector =3D=3D vdev->config_vector) { + 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, @@ -989,6 +1014,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, @@ -997,17 +1050,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 @@ -1048,7 +1109,8 @@ static int virtio_pci_set_guest_notifiers(DeviceState= *d, int nvqs, bool assign) if ((proxy->vector_irqfd || k->guest_notifier_mask) && !assign) { msix_unset_vector_notifiers(&proxy->pci_dev); if (proxy->vector_irqfd) { - kvm_virtio_pci_vector_release(proxy, nvqs); + kvm_virtio_pci_vector_vq_release(proxy, nvqs); + kvm_virtio_pci_vector_config_release(proxy); g_free(proxy->vector_irqfd); proxy->vector_irqfd =3D NULL; } @@ -1064,20 +1126,28 @@ static int virtio_pci_set_guest_notifiers(DeviceSta= te *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) { proxy->vector_irqfd =3D g_malloc0(sizeof(*proxy->vector_irqfd) * msix_nr_vectors_allocated(&proxy->pci_dev)); - r =3D kvm_virtio_pci_vector_use(proxy, nvqs); + r =3D kvm_virtio_pci_vector_vq_use(proxy, nvqs); + if (r < 0) { + goto config_assign_error; + } + r =3D kvm_virtio_pci_vector_config_use(proxy); if (r < 0) { - goto assign_error; + goto config_error; } } - r =3D msix_set_vector_notifiers(&proxy->pci_dev, - virtio_pci_vector_unmask, + + 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,9 +1160,15 @@ static int virtio_pci_set_guest_notifiers(DeviceStat= e *d, int nvqs, bool assign) notifiers_error: if (with_irqfd) { assert(assign); - kvm_virtio_pci_vector_release(proxy, nvqs); + kvm_virtio_pci_vector_vq_release(proxy, nvqs); } - +config_error: + if (with_irqfd) { + 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/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 2446dcd9ae..b704acc5a8 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/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.34.3