From nobody Tue Feb 10 06:07:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1715064401; cv=none; d=zohomail.com; s=zohoarc; b=AxIDwZZ55tNmCkS+gCxFNjpac932D4mpZHip4GghdyF28PkQ+l2LJkoCQ4LYslfklIz4DMe2F5t5EOp6rDCao36ERVLFCx8+0bEGgd+Zv1fMWcmbIzKCqVdJfvAJZZ8o8OUWVolDAIVFmI1TmXkwDwaZh6yY6oLPlcoJaxS7RqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715064401; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zk7l8RrmFbNj2vWYKvez2hpistvC0XU0HzBq9GCrxsg=; b=jWz4SlNunaOOahJGhfSVSSLsSt8NHDkmrDc4XriLeNUUkYQV5h8f1mZEHSYoEjUXw4zegXE77kZLowKN7Z+eWW1LeF+tHu03xZ52Jb1FlvXLabMF+aT0LG3vprvm6TLHhZ06JgfhZyWrbXlQ+pcT9/GWTkGC0PkHVcDXqwKC360= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=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 1715064401632598.3333389746932; Mon, 6 May 2024 23:46:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4EZw-0003Nf-8x; Tue, 07 May 2024 02:45:32 -0400 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 1s4EZt-0003MS-2q; Tue, 07 May 2024 02:45:29 -0400 Received: from mgamail.intel.com ([192.198.163.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4EZr-0005Ee-1S; Tue, 07 May 2024 02:45:28 -0400 Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 23:45:25 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 23:45:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715064327; x=1746600327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fr2V/QTY5Uvx5YftWpQRTt6S3xGiOTCE5jGwZtbQdsU=; b=fiidDAv9+HykJmFHcnfnh69OL21pG8JjPmYhZ8UmTiEavxCjKq4qOyPU JravKaMoaCFBmNZLI/lWoCbYP/drn1Hymnpoqc28tXm3v6nKchlA4R3EV QLxdVta7uCewkngzzEGxEFpOEQorYuyornpqOma3j6qlv7YnMeVYUuwkC EJTsY36e2nzKAaIQxulefDfaT4pFkLx32Py1q+uDje2WSRTiOktfvHX85 gsewzf+SBccZTK3vgeweO5pw9WOYUFMbVdki2BMpFoIsHvuvwnCcLnxxh zyBZMHs9P851EWwNjYxDk7nPNCakUixFh8PxDwYFovInf0n6S7NH5ozG5 w==; X-CSE-ConnectionGUID: 1bSqa3PaSXmWWyyHGpUb3g== X-CSE-MsgGUID: t7AG60xSQHeusECym9lPMg== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22240250" X-IronPort-AV: E=Sophos;i="6.07,260,1708416000"; d="scan'208";a="22240250" X-CSE-ConnectionGUID: IhIgOb1yRqumB+oXQPqczg== X-CSE-MsgGUID: 9S4wHYRaQpauabDbvHWNXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,260,1708416000"; d="scan'208";a="28407526" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, chao.p.peng@intel.com, Zhenzhong Duan , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , qemu-ppc@nongnu.org (open list:sPAPR (pseries)) Subject: [PATCH v2 05/11] vfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool Date: Tue, 7 May 2024 14:42:46 +0800 Message-Id: <20240507064252.457884-6-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507064252.457884-1-zhenzhong.duan@intel.com> References: <20240507064252.457884-1-zhenzhong.duan@intel.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=192.198.163.10; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.581, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1715064403757100003 Make VFIOIOMMUClass::add_window() and its wrapper function vfio_container_add_section_window() return bool. This is to follow the coding standand to return bool if 'Error **' is used to pass error. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-container-base.h | 12 ++++++------ hw/vfio/common.c | 2 +- hw/vfio/container-base.c | 8 ++++---- hw/vfio/spapr.c | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 68539e3bed..e96cda78c8 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -76,9 +76,9 @@ int vfio_container_dma_map(VFIOContainerBase *bcontainer, int vfio_container_dma_unmap(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, IOMMUTLBEntry *iotlb); -int vfio_container_add_section_window(VFIOContainerBase *bcontainer, - MemoryRegionSection *section, - Error **errp); +bool vfio_container_add_section_window(VFIOContainerBase *bcontainer, + MemoryRegionSection *section, + Error **errp); void vfio_container_del_section_window(VFIOContainerBase *bcontainer, MemoryRegionSection *section); int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, @@ -131,9 +131,9 @@ struct VFIOIOMMUClass { int (*pci_hot_reset)(VFIODevice *vbasedev, bool single); =20 /* SPAPR specific */ - int (*add_window)(VFIOContainerBase *bcontainer, - MemoryRegionSection *section, - Error **errp); + bool (*add_window)(VFIOContainerBase *bcontainer, + MemoryRegionSection *section, + Error **errp); void (*del_window)(VFIOContainerBase *bcontainer, MemoryRegionSection *section); void (*release)(VFIOContainerBase *bcontainer); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 890d30910e..9f1f2e19f7 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -585,7 +585,7 @@ static void vfio_listener_region_add(MemoryListener *li= stener, return; } =20 - if (vfio_container_add_section_window(bcontainer, section, &err)) { + if (!vfio_container_add_section_window(bcontainer, section, &err)) { goto fail; } =20 diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 913ae49077..98d71b3144 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -31,12 +31,12 @@ int vfio_container_dma_unmap(VFIOContainerBase *bcontai= ner, return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb); } =20 -int vfio_container_add_section_window(VFIOContainerBase *bcontainer, - MemoryRegionSection *section, - Error **errp) +bool vfio_container_add_section_window(VFIOContainerBase *bcontainer, + MemoryRegionSection *section, + Error **errp) { if (!bcontainer->ops->add_window) { - return 0; + return true; } =20 return bcontainer->ops->add_window(bcontainer, section, errp); diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 148b257c9c..47b040f1bc 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -323,7 +323,7 @@ static int vfio_spapr_create_window(VFIOContainer *cont= ainer, return 0; } =20 -static int +static bool vfio_spapr_container_add_section_window(VFIOContainerBase *bcontainer, MemoryRegionSection *section, Error **errp) @@ -351,13 +351,13 @@ vfio_spapr_container_add_section_window(VFIOContainer= Base *bcontainer, error_setg(errp, "Container %p can't map guest IOVA region" " 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end); - return -EINVAL; + return false; } - return 0; + return true; } =20 if (container->iommu_type !=3D VFIO_SPAPR_TCE_v2_IOMMU) { - return 0; + return true; } =20 /* For now intersections are not allowed, we may relax this later */ @@ -373,14 +373,14 @@ vfio_spapr_container_add_section_window(VFIOContainer= Base *bcontainer, section->offset_within_address_space + int128_get64(section->size) - 1, hostwin->min_iova, hostwin->max_iova); - return -EINVAL; + return false; } } =20 ret =3D vfio_spapr_create_window(container, section, &pgsize); if (ret) { error_setg_errno(errp, -ret, "Failed to create SPAPR window"); - return ret; + return false; } =20 vfio_host_win_add(scontainer, section->offset_within_address_space, @@ -406,14 +406,14 @@ vfio_spapr_container_add_section_window(VFIOContainer= Base *bcontainer, "vfio: failed GROUP_SET_SPAPR_TCE for= " "KVM VFIO device %d and group fd %d", param.tablefd, param.groupfd); - return -errno; + return false; } trace_vfio_spapr_group_attach(param.groupfd, param.tablefd= ); } } } #endif - return 0; + return true; } =20 static void --=20 2.34.1