From nobody Wed Nov 27 00:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170301276576633.15599011594577; Tue, 19 Dec 2023 11:06:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFfIj-0003qN-B4; Tue, 19 Dec 2023 13:58:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFfIW-0003XK-Rt for qemu-devel@nongnu.org; Tue, 19 Dec 2023 13:58:32 -0500 Received: from gandalf.ozlabs.org ([150.107.74.76]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFfIH-0007AK-DD for qemu-devel@nongnu.org; Tue, 19 Dec 2023 13:58:32 -0500 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4SvmDR2vXjz4xQj; Wed, 20 Dec 2023 05:58:15 +1100 (AEDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4SvmDL5YWyz4xCp; Wed, 20 Dec 2023 05:58:10 +1100 (AEDT) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Peter Maydell , Richard Henderson , Nicholas Piggin , Harsh Prateek Bora , Thomas Huth , Eric Farman , Alex Williamson , Matthew Rosato , Yi Liu , Yi Sun , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 15/47] vfio/container: Implement attach/detach_device Date: Tue, 19 Dec 2023 19:56:11 +0100 Message-ID: <20231219185643.725448-16-clg@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219185643.725448-1-clg@redhat.com> References: <20231219185643.725448-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=150.107.74.76; envelope-from=SRS0=7/MV=H6=redhat.com=clg@ozlabs.org; helo=gandalf.ozlabs.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1703012767469100011 From: Eric Auger No functional change intended. Signed-off-by: Eric Auger Signed-off-by: Yi Liu Signed-off-by: Yi Sun Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 16 ++++++++++++++++ hw/vfio/container.c | 12 +++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 8ef2e7967d6572e3ad3d53d6d5b5d3d0c95301ae..483ba820890460cba0ec7a4ecfe= d72d66433d41e 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1498,3 +1498,19 @@ retry: =20 return info; } + +int vfio_attach_device(char *name, VFIODevice *vbasedev, + AddressSpace *as, Error **errp) +{ + const VFIOIOMMUOps *ops =3D &vfio_legacy_ops; + + return ops->attach_device(name, vbasedev, as, errp); +} + +void vfio_detach_device(VFIODevice *vbasedev) +{ + if (!vbasedev->bcontainer) { + return; + } + vbasedev->bcontainer->ops->detach_device(vbasedev); +} diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 721c0d7375bd1e07f04e33558e8ca3b3f234412d..6bacf38222ad9d95e0589757299= 5e925e46b54dc 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -873,8 +873,8 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Er= ror **errp) * @name and @vbasedev->name are likely to be different depending * on the type of the device, hence the need for passing @name */ -int vfio_attach_device(char *name, VFIODevice *vbasedev, - AddressSpace *as, Error **errp) +static int vfio_legacy_attach_device(const char *name, VFIODevice *vbasede= v, + AddressSpace *as, Error **errp) { int groupid =3D vfio_device_groupid(vbasedev, errp); VFIODevice *vbasedev_iter; @@ -914,14 +914,10 @@ int vfio_attach_device(char *name, VFIODevice *vbased= ev, return ret; } =20 -void vfio_detach_device(VFIODevice *vbasedev) +static void vfio_legacy_detach_device(VFIODevice *vbasedev) { VFIOGroup *group =3D vbasedev->group; =20 - if (!vbasedev->bcontainer) { - return; - } - QLIST_REMOVE(vbasedev, global_next); QLIST_REMOVE(vbasedev, container_next); vbasedev->bcontainer =3D NULL; @@ -933,6 +929,8 @@ void vfio_detach_device(VFIODevice *vbasedev) const VFIOIOMMUOps vfio_legacy_ops =3D { .dma_map =3D vfio_legacy_dma_map, .dma_unmap =3D vfio_legacy_dma_unmap, + .attach_device =3D vfio_legacy_attach_device, + .detach_device =3D vfio_legacy_detach_device, .set_dirty_page_tracking =3D vfio_legacy_set_dirty_page_tracking, .query_dirty_bitmap =3D vfio_legacy_query_dirty_bitmap, }; --=20 2.43.0