From nobody Mon Nov 25 07:50:19 2024 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=1716353071; cv=none; d=zohomail.com; s=zohoarc; b=mBpLwsZ2yyQxoeFxUaOfQu++KFa0gCd5uY+jP8x4FpstKZiBY21nmxW85IQuEqXqri9qVCL4EufXfs4GfJb+Mcxk9p/UwcJdlHzjDvAE+SdTWWraBzNBL0bFNzNj9CkUfNeQ+dQKUVchKQjb0K3/uX7NfvPrwG90JYOMzA3RRCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353071; 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=+qaTJPuAAh1pIvnmMMSRLg6Xu7ebM2k1rzThp0XrKgw=; b=Kv45fdVaYFCXdAoBCbOWvDWM4LxBxy2lc/IxkYI1KWGZAHhM4TgYmzyCiFG8mge43PoV87CbZgeNI8ERYBToipEAMb87GxVWKeGENkbVZdBsUpDC++Uc1hWabsoGwaNO9r4PU+s2+h8JUHj+4uQa+R0h5rVnXBHmdbxciZUk+bU= 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 1716353071700275.94231560122296; Tue, 21 May 2024 21:44:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doN-0001MW-Me; Wed, 22 May 2024 00:42:47 -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 1s9doL-0001Lg-Hs for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:45 -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 1s9doG-0005sV-9j for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:45 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:37 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352961; x=1747888961; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WpBcaH1Tlocd9yPnXxPOtRYWcAqT14hB+2SW2lvL9mk=; b=MQ9JK5FiidKYOzDguouLu2xFK/laYU0Kamrjz+Ka3lhxJ0DbGj62tP42 I7D78u7L39PA6KBflcUoKcHF0mXb3qQJ1JrxjfsaaAsKDjxM9SBLBN7Yw 3RNwwYBlBIvw4flu9dVuUQaNTIrW85uwm8Fzp788So5iu9TJjlSTVPPKZ iL4h6abI3cSFDXvN2SRu9MoBeoE+P8kwwBHwi6w/qXLuubX+k2vxW5Ryx kh2Sx1ZL0kWvVGJJUvL05bJC04ao5MJxKuqpfdW8Y2bU0l/DCehgqB06V yTQTCN/jl2lLAyiLRGhUOl7EieJNBgwwi2gfGzD/2nA96gKaajcQUiCeZ w==; X-CSE-ConnectionGUID: kH4UBvrVT0O0Ke4knxrlVA== X-CSE-MsgGUID: gn343C2LRKSFyqV9XZM8hA== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994113" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994113" X-CSE-ConnectionGUID: 4FMcqQU0T16SMKwDNrGSlg== X-CSE-MsgGUID: B/RtREqcQpyyd+CL6+yzUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683609" 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 , Gerd Hoffmann Subject: [PATCH v2 01/20] vfio/display: Fix error path in call site of ramfb_setup() Date: Wed, 22 May 2024 12:39:56 +0800 Message-Id: <20240522044015.412951-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SPF_TEMPERROR=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1716353072271100003 vfio_display_dmabuf_init() and vfio_display_region_init() calls ramfb_setup() without checking its return value. So we may run into a situation that vfio_display_probe() succeed but errp is set. This is risky and may lead to assert failure in error_setv(). Cc: Gerd Hoffmann Fixes: b290659fc3d ("hw/vfio/display: add ramfb support") Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/display.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index fe624a6c9b..d28b724102 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -361,6 +361,9 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev= , Error **errp) vdev); if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); + if (!vdev->dpy->ramfb) { + return -EINVAL; + } } vfio_display_edid_init(vdev); return 0; @@ -488,6 +491,9 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev= , Error **errp) vdev); if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); + if (!vdev->dpy->ramfb) { + return -EINVAL; + } } return 0; } --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353078; cv=none; d=zohomail.com; s=zohoarc; b=e0naYgL+bRCutsaMXr1Ve9VCwSX/0suDXQBu1//itLcDWrOU61eY2jilbqcTA8/4EiMWNO6qV15tPZlUzU0MiuGWL7Ue9bzrYkIADcomwQ5Ul5rX9u80AW+NEUF/79zQFS0mw73M0hP8aqgL5rQSx/kSABOZVY6yqlJL9CRT+/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353078; 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=3SplMEvuNpmjkdb03WXfabx39OsNWwMcr+7fkpuIdkg=; b=gPKoN6jylnqi6cKsLSUoamLHOnAiGskhuhDvcBAA54yonUiDBXQX080RclPVotI5zWVmJW87T8BFC3LrN0NTOFy8NInDCFS8QdkbXfSt5nubfJ3QzpV5HtdFmkqyzuEm3JLOy8NY6rw2j/Ni+JDN4z7/6qKkkcEsiUtSL79/jDU= 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 1716353078208237.3065787675465; Tue, 21 May 2024 21:44:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doL-0001Lq-VE; Wed, 22 May 2024 00:42:46 -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 1s9doK-0001LA-Ko for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:44 -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 1s9doH-0005sg-A0 for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:44 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:39 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352962; x=1747888962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nR3/N81fP2lWYnCwoqeFQ8UTmXCJcw0lSyoNyVGiKWY=; b=gE+RCA5GIxsbvvJh5PRSK2nDC0FhtXbTZjsN4XjqxmmpQvKUp/I9WdV3 MZWrrdTgGCwUe2c2FlWCai1LUlMcABgBZAAg7BccaITLf1rg2zaOD6rWM rs2g9Ex7LALKiHJNEVTmXg6rn+3t2HHS/AFGP19Kphu6VWwQgRzEk6yi6 a8bZlQ6wnju2pDC+OeZPfBoodugDiczh09txXVGUTIaDNHA2Xp01xXIMC R9BWTTxmB8WqNnkGiJ301nixDxxjT7slkUqdqQT1ZPtKFfKSDAnYuis3Z 5WE8MeodIiYvBaGNSGv+uVHtoFyA8+VzhuwT+97pitRwwcLwKXODuNtMA Q==; X-CSE-ConnectionGUID: t3ogDDf2RrSBvQl/UgRH9Q== X-CSE-MsgGUID: Qb4J5aNASISGXC9/h3N5kQ== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994119" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994119" X-CSE-ConnectionGUID: 1HjOn4ARQRumKJwJ2rjyiw== X-CSE-MsgGUID: Wa/jqcmkT/OZswNCmxboRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683620" 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 Subject: [PATCH v2 02/20] vfio/display: Make vfio_display_*() return bool Date: Wed, 22 May 2024 12:39:57 +0800 Message-Id: <20240522044015.412951-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353080217100002 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 2 +- hw/vfio/display.c | 20 ++++++++++---------- hw/vfio/pci.c | 3 +-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 92cd62d115..a5ac9efd4b 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -232,7 +232,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, Error **errp); =20 void vfio_display_reset(VFIOPCIDevice *vdev); -int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); +bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); void vfio_display_finalize(VFIOPCIDevice *vdev); =20 extern const VMStateDescription vfio_display_vmstate; diff --git a/hw/vfio/display.c b/hw/vfio/display.c index d28b724102..661e921616 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -348,11 +348,11 @@ static const GraphicHwOps vfio_display_dmabuf_ops =3D= { .ui_info =3D vfio_display_edid_ui_info, }; =20 -static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) { if (!display_opengl) { error_setg(errp, "vfio-display-dmabuf: opengl not available"); - return -1; + return false; } =20 vdev->dpy =3D g_new0(VFIODisplay, 1); @@ -362,11 +362,11 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vd= ev, Error **errp) if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); if (!vdev->dpy->ramfb) { - return -EINVAL; + return false; } } vfio_display_edid_init(vdev); - return 0; + return true; } =20 static void vfio_display_dmabuf_exit(VFIODisplay *dpy) @@ -483,7 +483,7 @@ static const GraphicHwOps vfio_display_region_ops =3D { .gfx_update =3D vfio_display_region_update, }; =20 -static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) { vdev->dpy =3D g_new0(VFIODisplay, 1); vdev->dpy->con =3D graphic_console_init(DEVICE(vdev), 0, @@ -492,10 +492,10 @@ static int vfio_display_region_init(VFIOPCIDevice *vd= ev, Error **errp) if (vdev->enable_ramfb) { vdev->dpy->ramfb =3D ramfb_setup(errp); if (!vdev->dpy->ramfb) { - return -EINVAL; + return false; } } - return 0; + return true; } =20 static void vfio_display_region_exit(VFIODisplay *dpy) @@ -510,7 +510,7 @@ static void vfio_display_region_exit(VFIODisplay *dpy) =20 /* ---------------------------------------------------------------------- = */ =20 -int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp) +bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp) { struct vfio_device_gfx_plane_info probe; int ret; @@ -533,11 +533,11 @@ int vfio_display_probe(VFIOPCIDevice *vdev, Error **e= rrp) =20 if (vdev->display =3D=3D ON_OFF_AUTO_AUTO) { /* not an error in automatic mode */ - return 0; + return true; } =20 error_setg(errp, "vfio: device doesn't support any (known) display met= hod"); - return -1; + return false; } =20 void vfio_display_finalize(VFIOPCIDevice *vdev) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c1adef5cf8..a447013a1d 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3200,8 +3200,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 if (vdev->display !=3D ON_OFF_AUTO_OFF) { - ret =3D vfio_display_probe(vdev, errp); - if (ret) { + if (!vfio_display_probe(vdev, errp)) { goto out_deregister; } } --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353055; cv=none; d=zohomail.com; s=zohoarc; b=GWdm4oDt8xxfU05XsB2Wf4wEmHBbarRrwMZ+9Yj9HdfgPQwAHb3EkTHJis6N3PCLt1ChFx40W4HWVBfTMEwDO093TYZaZzn13gfNkKndaydNgeLCepMPv9fNjDQtnouUuuKOc7W8x7fgjk2itXTzVe/jIKyGM7C2l/wuSAhLmFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353055; h=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=N0C7X2JBXF1WjDlfJ5gT4pjA33s+bpvgv+oZEq6Dz+Q=; b=DXamd15u5Hd5Rm6hqnr8i5uk2YQ3Aw87DRHuiCUX0pkTXJe4jzkEyzt1nVJ/xRqG55g1dtf4DlRxF1IuUFKOEQ6B0ZFTw6wOJCcQJWBdNw78oF3cjf6J3ldwN2zqC4Vh1UG8V6V5cAOAG3gYxfeHCGvZKcpBmL9ANIS2hsI9RGc= 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 1716353055801622.3736839866436; Tue, 21 May 2024 21:44:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doM-0001M9-VQ; Wed, 22 May 2024 00:42:46 -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 1s9doL-0001LW-2k for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:45 -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 1s9doJ-0005sK-Gf for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:44 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:42 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352964; x=1747888964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VtbDG/+t6qft6P8QfUBwDp+iFsdeOGEcKMeRYTvDkGE=; b=AaCh8no2Zh1+2RcZlZLA5hO9owpZPPM+i7DQADY3ip7Z1DCyZdmB3G1y MMxuZN6lIUAfJhF+S41ISzlD8sn4Uu+6h/y0AI5sGLMN82N+f8zv9FmGi VTbET59ZBRvWVQAdOR5yz9NIEtLCRcunQcT9FeWSLbic9AvH4+hMVrxht sIYj8t/+uVv/ypx9bo6llXhbOyXBzpR8yH9UOiChjPi009lWbEpIkY7QB 2w0YRvYfhbUwfl5eUiW8SHeT0AhSNKCoRSiHvM6QpLrGtrfg0qBwv6ZOJ 21PbUztntmq0WffMlwCX94Z9Th81E9uzR8jScC+H76dujWGF1E2ZDQygT A==; X-CSE-ConnectionGUID: /rlMVQiISJa8CC/VEDVN0g== X-CSE-MsgGUID: KRVCo36hR6yPJiLbQt8rOQ== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994123" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994123" X-CSE-ConnectionGUID: 3/K4b9TiRbmtptldQxtE4Q== X-CSE-MsgGUID: lMAfGMS9QAGBIeWL3ckUkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683636" 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 Subject: [PATCH v2 03/20] vfio/helpers: Use g_autofree in vfio_set_irq_signaling() Date: Wed, 22 May 2024 12:39:58 +0800 Message-Id: <20240522044015.412951-4-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353056114100001 Content-Type: text/plain; charset="utf-8" Local pointer irq_set is freed before return from vfio_set_irq_signaling(). Use 'g_autofree' to avoid the g_free() calls. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 47b4096c05..1f3bdd9bf0 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -111,7 +111,7 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int in= dex, int subindex, int action, int fd, Error **errp) { ERRP_GUARD(); - struct vfio_irq_set *irq_set; + g_autofree struct vfio_irq_set *irq_set =3D NULL; int argsz, ret =3D 0; const char *name; int32_t *pfd; @@ -130,7 +130,6 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int in= dex, int subindex, if (ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { ret =3D -errno; } - g_free(irq_set); =20 if (!ret) { return 0; --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353139; cv=none; d=zohomail.com; s=zohoarc; b=lfZOdcyJYLSUNu5x3/c5thqbGFrPK8RJv+XXBPUIuJbPsREuiz0ZJiXef/wiQoDjjzaGrSd7m3DvvnNHUrF7aEkJPr/GXOV68DAVaylTToHKt+hruj13iAFO9F6mJgYhrhHfobFjxVgnYtnPmM87gMM26nCrnjLvaCh4sNexBrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353139; 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=BfFs7iQFj0oksS4imYD4LJOs6gyJhpzJwd36RN0EKrY=; b=TU7gVT95ZMBMoE4wr8cN6tN0ivwHC2gZvkRcVOeJbze+uS9Tra5Geif5R7Wo9fYAmRkd7zgEe3Jhg43B4BhjZnOUYrN8+5wUUuaQG7nGi/qgqDeVdEzNw/oseGJFv1u/WQQl2GWKquaBbs/KGFi8G+Tv55BQdQHOdxU/xGNxkGo= 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 1716353139932526.5621387855597; Tue, 21 May 2024 21:45:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doQ-0001NO-Do; Wed, 22 May 2024 00:42:50 -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 1s9doO-0001Mw-QL; Wed, 22 May 2024 00:42:48 -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 1s9doM-0005sV-Hn; Wed, 22 May 2024 00:42:48 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:46 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352967; x=1747888967; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zORect+qPLw/ECUAOP8vsbUj5srbMv75NkKPd1oMvdc=; b=JL53BZQgOyrgaINLumTV1jaIE/Kx5ZCkLjSYtD1jcGnUXeVScynLGATj cNXlTdcYv/nr287UHXoGShu2wQ9zBzo/HRuw4qQeP9HBEgZe3T7lYYiRd De/dc+uyOQqix/7kGt0js8SCeoRkik+iH7bh5jNuwS4/Fh2OGqXfbzQo4 Jv8SkMGliUSLWcXZkia2CE7oCVWFgff5WLnOzXxUHwHwJjd0EatBisl9m Uaj2SduFQ2/dPyhkyh+ACeaZWM8UWZTYI06Gsm1o5A3pHVskgPjJlgg1r vCTGfWLPO5l5N6hEsgY8Ve+L7ZbrNIkvI9vC08ZojRpmWG6syeYOANcVL Q==; X-CSE-ConnectionGUID: 9KJerqy7TJ6Hi/5pBi/n2Q== X-CSE-MsgGUID: eJz+0HkOQSGincKmYWglkg== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994129" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994129" X-CSE-ConnectionGUID: bTU4G6FuQiCF3AyfWxZbpA== X-CSE-MsgGUID: 6D+aRvS/RDuORxyJwn+yzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683657" 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 , Tony Krowiak , Halil Pasic , Jason Herne , Thomas Huth , Eric Farman , Matthew Rosato , qemu-s390x@nongnu.org (open list:vfio-ap) Subject: [PATCH v2 04/20] vfio/helpers: Make vfio_set_irq_signaling() return bool Date: Wed, 22 May 2024 12:39:59 +0800 Message-Id: <20240522044015.412951-5-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353140511100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 4 ++-- hw/vfio/ap.c | 8 +++---- hw/vfio/ccw.c | 8 +++---- hw/vfio/helpers.c | 18 ++++++---------- hw/vfio/pci.c | 40 ++++++++++++++++++----------------- hw/vfio/platform.c | 18 +++++++--------- 6 files changed, 46 insertions(+), 50 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index b7bb4f5304..b712799caf 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -207,8 +207,8 @@ void vfio_spapr_container_deinit(VFIOContainer *contain= er); void vfio_disable_irqindex(VFIODevice *vbasedev, int index); void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index); void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); -int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, - int action, int fd, Error **errp); +bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, + int action, int fd, Error **errp); void vfio_region_write(void *opaque, hwaddr addr, uint64_t data, unsigned size); uint64_t vfio_region_read(void *opaque, diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index ba653ef70f..d8a9615fee 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -117,8 +117,8 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice = *vapdev, fd =3D event_notifier_get_fd(notifier); qemu_set_fd_handler(fd, fd_read, NULL, vapdev); =20 - if (vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, = fd, - errp)) { + if (!vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER,= fd, + errp)) { qemu_set_fd_handler(fd, NULL, NULL, vapdev); event_notifier_cleanup(notifier); } @@ -141,8 +141,8 @@ static void vfio_ap_unregister_irq_notifier(VFIOAPDevic= e *vapdev, return; } =20 - if (vfio_set_irq_signaling(&vapdev->vdev, irq, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vapdev->vdev, irq, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name); } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 89bb980167..1f578a3c75 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -434,8 +434,8 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevic= e *vcdev, fd =3D event_notifier_get_fd(notifier); qemu_set_fd_handler(fd, fd_read, NULL, vcdev); =20 - if (vfio_set_irq_signaling(vdev, irq, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { + if (!vfio_set_irq_signaling(vdev, irq, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vcdev); event_notifier_cleanup(notifier); } @@ -464,8 +464,8 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, return; } =20 - if (vfio_set_irq_signaling(&vcdev->vdev, irq, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vcdev->vdev, irq, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); } =20 diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 1f3bdd9bf0..9edbc96688 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -107,12 +107,12 @@ static const char *index_to_str(VFIODevice *vbasedev,= int index) } } =20 -int vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, - int action, int fd, Error **errp) +bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, + int action, int fd, Error **errp) { ERRP_GUARD(); g_autofree struct vfio_irq_set *irq_set =3D NULL; - int argsz, ret =3D 0; + int argsz; const char *name; int32_t *pfd; =20 @@ -127,15 +127,11 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int = index, int subindex, pfd =3D (int32_t *)&irq_set->data; *pfd =3D fd; =20 - if (ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - ret =3D -errno; + if (!ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { + return true; } =20 - if (!ret) { - return 0; - } - - error_setg_errno(errp, -ret, "VFIO_DEVICE_SET_IRQS failure"); + error_setg_errno(errp, errno, "VFIO_DEVICE_SET_IRQS failure"); =20 name =3D index_to_str(vbasedev, index); if (name) { @@ -146,7 +142,7 @@ int vfio_set_irq_signaling(VFIODevice *vbasedev, int in= dex, int subindex, error_prepend(errp, "Failed to %s %s eventfd signaling for interrupt ", fd < 0 ? "tear down" : "set up", action_to_str(action)); - return ret; + return false; } =20 /* diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index a447013a1d..358da4497b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -147,10 +147,10 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev,= Error **errp) goto fail_irqfd; } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_UNMASK, - event_notifier_get_fd(&vdev->intx.unmask), - errp)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, = 0, + VFIO_IRQ_SET_ACTION_UNMASK, + event_notifier_get_fd(&vdev->intx.unmask), + errp)) { goto fail_vfio; } =20 @@ -295,8 +295,8 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) fd =3D event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev); =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, = 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->intx.interrupt); return -errno; @@ -590,9 +590,10 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, un= signed int nr, fd =3D event_notifier_get_fd(&vector->interrupt); } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, - VFIO_PCI_MSIX_IRQ_INDEX, nr, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &e= rr)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, + VFIO_PCI_MSIX_IRQ_INDEX, nr, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, + &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.nam= e); } } @@ -634,8 +635,9 @@ static void vfio_msix_vector_release(PCIDevice *pdev, u= nsigned int nr) int32_t fd =3D event_notifier_get_fd(&vector->interrupt); Error *err =3D NULL; =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDE= X, nr, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err))= { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_IND= EX, + nr, VFIO_IRQ_SET_ACTION_TRIGGER, fd, + &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } } @@ -2873,8 +2875,8 @@ static void vfio_register_err_notifier(VFIOPCIDevice = *vdev) fd =3D event_notifier_get_fd(&vdev->err_notifier); qemu_set_fd_handler(fd, vfio_err_notifier_handler, NULL, vdev); =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->err_notifier); @@ -2890,8 +2892,8 @@ static void vfio_unregister_err_notifier(VFIOPCIDevic= e *vdev) return; } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } qemu_set_fd_handler(event_notifier_get_fd(&vdev->err_notifier), @@ -2938,8 +2940,8 @@ static void vfio_register_req_notifier(VFIOPCIDevice = *vdev) fd =3D event_notifier_get_fd(&vdev->req_notifier); qemu_set_fd_handler(fd, vfio_req_notifier_handler, NULL, vdev); =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->req_notifier); @@ -2956,8 +2958,8 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) return; } =20 - if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { + if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } qemu_set_fd_handler(event_notifier_get_fd(&vdev->req_notifier), diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 2bd16096bb..3233ca8691 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -115,18 +115,17 @@ static int vfio_set_trigger_eventfd(VFIOINTp *intp, VFIODevice *vbasedev =3D &intp->vdev->vbasedev; int32_t fd =3D event_notifier_get_fd(intp->interrupt); Error *err =3D NULL; - int ret; =20 qemu_set_fd_handler(fd, (IOHandler *)handler, NULL, intp); =20 - ret =3D vfio_set_irq_signaling(vbasedev, intp->pin, 0, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err); - if (ret) { + if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); qemu_set_fd_handler(fd, NULL, NULL, NULL); + return -EINVAL; } =20 - return ret; + return 0; } =20 /* @@ -355,15 +354,14 @@ static int vfio_set_resample_eventfd(VFIOINTp *intp) int32_t fd =3D event_notifier_get_fd(intp->unmask); VFIODevice *vbasedev =3D &intp->vdev->vbasedev; Error *err =3D NULL; - int ret; =20 qemu_set_fd_handler(fd, NULL, NULL, NULL); - ret =3D vfio_set_irq_signaling(vbasedev, intp->pin, 0, - VFIO_IRQ_SET_ACTION_UNMASK, fd, &err); - if (ret) { + if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, + VFIO_IRQ_SET_ACTION_UNMASK, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); + return -EINVAL; } - return ret; + return 0; } =20 /** --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353028; cv=none; d=zohomail.com; s=zohoarc; b=XPOCAVLOOD/lsJ7cRmE983fqnN7A2XSx6XA49kfaM7yRQPthh/9pDSD0R2EoQwrxE5SuhJN6kCGCwfSNY2uk1Ht5eSMqR0mSSEPLn9Ck2Ld53D9XdrJ6SG3NVLXXmjSqd+AdNoSz6kVZNJqS5M7CYCAEv9xFd8VZ+6Xj0D7QGmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353028; 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=jjutKouCCGY6sAgTWgxrdccYSGOeL7sCLW8BWZICZm0=; b=JwMN1uxrVNF0KEC25yoiFSypCUztqGOR/iLR3r2fryHBNQn4oeMZ9BVYp3vyfBJcCZE5DI8On3EkGRzwdfgWrWr8pxt1g73Z7y320zLapOinKuhzjse746A/TZuu5VH2EppVjgXigSmD8G6PuNRliQPxPpnt5d+MlHKL2vaZXkk= 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 1716353028975124.45459697270803; Tue, 21 May 2024 21:43:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doT-0001OL-Nu; Wed, 22 May 2024 00:42:53 -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 1s9doS-0001Nw-40; Wed, 22 May 2024 00:42:52 -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 1s9doQ-0005sV-AE; Wed, 22 May 2024 00:42:51 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:49 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352971; x=1747888971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JCXGA2f5VRq8cLR58D7Xt/OW8TEieNqwtU9mvtZZxD4=; b=VSFGTwDE2TAb28OCFXXYVGesQf89I6/IQ3bocfIdR5DtzsbRa2vF7ovd JpiKAr4czolmEOFJZNTV0hxs8iYhnVR//gIYxaRNjnWxJhwZ07gckhFLi U6dqVJYKK3wnEWsp0Ih7b6QUUVu1m7HS1qENMCyt4RAtIkh0O2yH52gRW CPoQaDyejyqogKhyk5qjjGRpXi3aYaAGPriTUOXCutHqad4sDc9dH/Pb9 EZQOxQhmRzL5fS9deX5uBdpVtSXlF90DbnLD8oS/0OXf4P7/BMPRB467Z cKD6ZBcna8tENrLV2kR8vCp8iVTpneNkFrrS3qFmeFA1TSADCf/HJi0er Q==; X-CSE-ConnectionGUID: RpJvu+GbR+q0kx6aJam6AQ== X-CSE-MsgGUID: btlSvdDrT62tEOJsf1nIpg== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994135" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994135" X-CSE-ConnectionGUID: RbCUlBoZQcuF2tGZHj6EQg== X-CSE-MsgGUID: C57Vs8dkTZ+iGJ51Qofy1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683683" 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 , Thomas Huth , Tony Krowiak , Halil Pasic , Jason Herne , Eric Farman , Matthew Rosato , qemu-s390x@nongnu.org (open list:S390 general arch...) Subject: [PATCH v2 05/20] vfio/helpers: Make vfio_device_get_name() return bool Date: Wed, 22 May 2024 12:40:00 +0800 Message-Id: <20240522044015.412951-6-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353030400100005 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio/helpers.c | 8 ++++---- hw/vfio/pci.c | 2 +- hw/vfio/platform.c | 5 ++--- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index b712799caf..4cb1ab8645 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -279,7 +279,7 @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcon= tainer, uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp= ); =20 /* Returns 0 on success, or a negative errno. */ -int vfio_device_get_name(VFIODevice *vbasedev, Error **errp); +bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p); void vfio_device_init(VFIODevice *vbasedev, int type, VFIODeviceOps *ops, DeviceState *dev, bool ram_discard); diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index d8a9615fee..c12531a788 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -158,7 +158,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **e= rrp) VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(dev); VFIODevice *vbasedev =3D &vapdev->vdev; =20 - if (vfio_device_get_name(vbasedev, errp) < 0) { + if (!vfio_device_get_name(vbasedev, errp)) { return; } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 1f578a3c75..8850ca17c8 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -588,7 +588,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) } } =20 - if (vfio_device_get_name(vbasedev, errp) < 0) { + if (!vfio_device_get_name(vbasedev, errp)) { return; } =20 diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 9edbc96688..4b079dc383 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -607,7 +607,7 @@ bool vfio_has_region_cap(VFIODevice *vbasedev, int regi= on, uint16_t cap_type) return ret; } =20 -int vfio_device_get_name(VFIODevice *vbasedev, Error **errp) +bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp) { ERRP_GUARD(); struct stat st; @@ -616,7 +616,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) if (stat(vbasedev->sysfsdev, &st) < 0) { error_setg_errno(errp, errno, "no such host device"); error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->sysfsdev); - return -errno; + return false; } /* User may specify a name, e.g: VFIO platform device */ if (!vbasedev->name) { @@ -625,7 +625,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) } else { if (!vbasedev->iommufd) { error_setg(errp, "Use FD passing only with iommufd backend"); - return -EINVAL; + return false; } /* * Give a name with fd so any function printing out vbasedev->name @@ -636,7 +636,7 @@ int vfio_device_get_name(VFIODevice *vbasedev, Error **= errp) } } =20 - return 0; + return true; } =20 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 358da4497b..aad012c348 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2999,7 +2999,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) vdev->host.slot, vdev->host.function); } =20 - if (vfio_device_get_name(vbasedev, errp) < 0) { + if (!vfio_device_get_name(vbasedev, errp)) { return; } =20 diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 3233ca8691..e1a32863d9 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -545,9 +545,8 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) vbasedev->name); } =20 - ret =3D vfio_device_get_name(vbasedev, errp); - if (ret) { - return ret; + if (!vfio_device_get_name(vbasedev, errp)) { + return -EINVAL; } =20 if (!vfio_attach_device(vbasedev->name, vbasedev, --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353029; cv=none; d=zohomail.com; s=zohoarc; b=gBVegSyQP34qq1jgTGo0NMKa2tcZ7sa5doVb36QitfWpzMEmlUJFXRXT8Le1oD8snALer3y959lXuPORC6Eji3X5/VK8gSJwQ2Bji98JpAYDlSNAUPUT83oGUtAF/AR92/E0GAWgrMVDQBhdu7j5EMuSJcO0lMZ8NuIidK8C2mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353029; 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=OAs5NY/JxWZV/ykILFDm1Vhok/3vLm5q25vQLMkaDKA=; b=EgHo6FUJwBGnRrop/ppJxf59ZwA0/ObbsRcFY/RWN6oYX1b+GK4H/bYI4qmsDc0gY8BQebvBUSjxFJo/q4u2qF+YERSzsYqXxgHEBzoSDopwJB2FigAokwSSd/I4ldyEL/J8F7gInoenBPmGDRLNvrhZK1g1CXxHqTG9gAnBpRU= 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 171635302913061.94066489044633; Tue, 21 May 2024 21:43:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doV-0001PF-Ep; Wed, 22 May 2024 00:42:55 -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 1s9doU-0001Or-7N for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:54 -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 1s9doS-0005sV-ED for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:53 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:52 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352973; x=1747888973; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jnonh+R/LPS7uBevdbaTjQz/fEBnZL+cByDlYNJn0F8=; b=GDULGdW78aGL3GNSsh/F7rN6QRZ6R9Pd7u0+0KL+7pNx/uDYRn1iCN6j XrJsJ18Pg0O0i5osu6qY5uhGmBTyzCO18Ng8dL9R/CkVVqS9jsAub+Hor KNagrZ1/jx/r3pDCWL/F6iZ19gGtaubw3mmNEb1Ktvk07IElMsWUuPQCw nwOtk9GnA8lAQ4iCWW8ZB6wGWuwJASRLk2RmhFOYn7FQm63mtWFV4667C VVorN9aUqyb1T8tHpzYJDCgOlbmKF3TyEiFFlD7mFPJwXOhVLtHHj4Mqx jTRcvlfGoAXxIbPqTXdoXxjrRo+Tc2GWiNTTzP42KLECe2udI3DvSFXCR Q==; X-CSE-ConnectionGUID: KE1/MlUjTIyxQnX2vDjHcQ== X-CSE-MsgGUID: i9MYC0DMQfCWnPtXp7/87Q== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994139" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994139" X-CSE-ConnectionGUID: SmQFA0toQ2WH2XJetDwJgw== X-CSE-MsgGUID: yu8cb8SsTL2OrzHVI7BvQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683695" 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 Subject: [PATCH v2 06/20] vfio/platform: Make vfio_populate_device() and vfio_base_device_init() return bool Date: Wed, 22 May 2024 12:40:01 +0800 Message-Id: <20240522044015.412951-7-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353030275100001 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/platform.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index e1a32863d9..a85c199c76 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -441,7 +441,7 @@ static int vfio_platform_hot_reset_multi(VFIODevice *vb= asedev) * @errp: error object * */ -static int vfio_populate_device(VFIODevice *vbasedev, Error **errp) +static bool vfio_populate_device(VFIODevice *vbasedev, Error **errp) { VFIOINTp *intp, *tmp; int i, ret =3D -1; @@ -450,7 +450,7 @@ static int vfio_populate_device(VFIODevice *vbasedev, E= rror **errp) =20 if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) { error_setg(errp, "this isn't a platform device"); - return ret; + return false; } =20 vdev->regions =3D g_new0(VFIORegion *, vbasedev->num_regions); @@ -487,12 +487,11 @@ static int vfio_populate_device(VFIODevice *vbasedev,= Error **errp) irq.flags); intp =3D vfio_init_intp(vbasedev, irq, errp); if (!intp) { - ret =3D -1; goto irq_err; } } } - return 0; + return true; irq_err: timer_del(vdev->mmap_timer); QLIST_FOREACH_SAFE(intp, &vdev->intp_list, next, tmp) { @@ -507,7 +506,7 @@ reg_error: g_free(vdev->regions[i]); } g_free(vdev->regions); - return ret; + return false; } =20 /* specialized functions for VFIO Platform devices */ @@ -527,10 +526,8 @@ static VFIODeviceOps vfio_platform_ops =3D { * fd retrieval, resource query. * Precondition: the device name must be initialized */ -static int vfio_base_device_init(VFIODevice *vbasedev, Error **errp) +static bool vfio_base_device_init(VFIODevice *vbasedev, Error **errp) { - int ret; - /* @fd takes precedence over @sysfsdev which takes precedence over @ho= st */ if (vbasedev->fd < 0 && vbasedev->sysfsdev) { g_free(vbasedev->name); @@ -538,7 +535,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) } else if (vbasedev->fd < 0) { if (!vbasedev->name || strchr(vbasedev->name, '/')) { error_setg(errp, "wrong host device name"); - return -EINVAL; + return false; } =20 vbasedev->sysfsdev =3D g_strdup_printf("/sys/bus/platform/devices/= %s", @@ -546,20 +543,20 @@ static int vfio_base_device_init(VFIODevice *vbasedev= , Error **errp) } =20 if (!vfio_device_get_name(vbasedev, errp)) { - return -EINVAL; + return false; } =20 if (!vfio_attach_device(vbasedev->name, vbasedev, &address_space_memory, errp)) { - return -EINVAL; + return false; } =20 - ret =3D vfio_populate_device(vbasedev, errp); - if (ret) { - vfio_detach_device(vbasedev); + if (vfio_populate_device(vbasedev, errp)) { + return true; } =20 - return ret; + vfio_detach_device(vbasedev); + return false; } =20 /** @@ -576,7 +573,7 @@ static void vfio_platform_realize(DeviceState *dev, Err= or **errp) VFIOPlatformDevice *vdev =3D VFIO_PLATFORM_DEVICE(dev); SysBusDevice *sbdev =3D SYS_BUS_DEVICE(dev); VFIODevice *vbasedev =3D &vdev->vbasedev; - int i, ret; + int i; =20 qemu_mutex_init(&vdev->intp_mutex); =20 @@ -584,9 +581,8 @@ static void vfio_platform_realize(DeviceState *dev, Err= or **errp) vbasedev->sysfsdev : vbasedev->name, vdev->compat); =20 - ret =3D vfio_base_device_init(vbasedev, errp); - if (ret) { - goto out; + if (!vfio_base_device_init(vbasedev, errp)) { + goto init_err; } =20 if (!vdev->compat) { @@ -618,11 +614,9 @@ static void vfio_platform_realize(DeviceState *dev, Er= ror **errp) } sysbus_init_mmio(sbdev, vdev->regions[i]->mem); } -out: - if (!ret) { - return; - } + return; =20 +init_err: if (vdev->vbasedev.name) { error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } else { --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353096; cv=none; d=zohomail.com; s=zohoarc; b=ZP9YnsAiB0Y6quWzx6jwYyTsP6Pt+T3BF9Q87e7P9PSk/dNsacIAotN6fznuLxnvNbZydmRXMA9eAGv2p7UXvEeUPdPlwpYFTNKvec9gLmDGW3QMg2tMKcZBTK4OkzZg9D1iR4J35yngcwsEJNaw4o33Lz9jU7VmPCKmW7GZ+U8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353096; 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=IDjEhB6tA6GGs+wt30uVXvNksnr5O3wST0MbZ85txyQ=; b=lOeDWI1hH7ep5K+6Tz2QqE4sxxj2rEhJaUQJmJkVfzmE6tp0Hstugsk3PwRaXER9LGViLWvhAgElaTzKVVxs/4mpQHiZcDW5tXtGBC1NhIu/jVgRCyCc2bsd0EMNjJvqF4W0ULr+7pOMYGh1dhSn2KIdsCaDJEE+qt1YQV+qxwg= 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 1716353096691390.2922377597058; Tue, 21 May 2024 21:44:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doZ-0001QB-G6; Wed, 22 May 2024 00:42:59 -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 1s9doX-0001PY-T7; Wed, 22 May 2024 00:42:57 -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 1s9doW-0005u5-9G; Wed, 22 May 2024 00:42:57 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:55 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352977; x=1747888977; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tozqz6eV0xU3+zpVgG2ovdlclK14n3ngNUd3Q6FA2xM=; b=m/cRoheGfPmOTTUMb0WWPwtt/3wFSS0U8mMzFsAb+2G2rJpFa53CTKvW WhIN3y5N5Qgp/FSUq48xXdsY5vd0p8U2QrUCXNtRq96v4QjOFgezIlrcK /1LnO9uj7zN+2FLUFB2vaCewk4VUSGp19t1gsmRB5cpdt6j5YE3lfmrZ4 POcVWKuUi5kPjT13CBRWvRFtuOPNlB4kol5e46+X9IOuvS2x7b1OdZYCW o2GH6FDXpg4/P0yrWP6/N7AJYnJVJRITdHBJa5Z/J+/4TDkmoGcqWd1dG dVQ3feEAUx44wm6Y6EIdMWAmNr0+2fwMrA6RFJyMYH+za0pBLPi3VImzs w==; X-CSE-ConnectionGUID: w70PTAvuSGC6vDbd7lT54g== X-CSE-MsgGUID: GktIPAp8SXquJiqZI9dxdg== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994142" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994142" X-CSE-ConnectionGUID: 2OrjmukBQsOXBPFcuHL9HQ== X-CSE-MsgGUID: GRdHtx3ATNCBkM6SDszd6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683707" 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 , Eric Farman , Matthew Rosato , Thomas Huth , qemu-s390x@nongnu.org (open list:vfio-ccw) Subject: [PATCH v2 07/20] vfio/ccw: Make vfio_ccw_get_region() return a bool Date: Wed, 22 May 2024 12:40:02 +0800 Message-Id: <20240522044015.412951-8-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353098262100002 Since vfio_populate_device() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/ccw.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 8850ca17c8..2600e62e37 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -474,7 +474,7 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, event_notifier_cleanup(notifier); } =20 -static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) +static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) { VFIODevice *vdev =3D &vcdev->vdev; struct vfio_region_info *info; @@ -483,7 +483,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) /* Sanity check device */ if (!(vdev->flags & VFIO_DEVICE_FLAGS_CCW)) { error_setg(errp, "vfio: Um, this isn't a vfio-ccw device"); - return; + return false; } =20 /* @@ -493,13 +493,13 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) if (vdev->num_regions < VFIO_CCW_CONFIG_REGION_INDEX + 1) { error_setg(errp, "vfio: too few regions (%u), expected at least %u= ", vdev->num_regions, VFIO_CCW_CONFIG_REGION_INDEX + 1); - return; + return false; } =20 ret =3D vfio_get_region_info(vdev, VFIO_CCW_CONFIG_REGION_INDEX, &info= ); if (ret) { error_setg_errno(errp, -ret, "vfio: Error getting config info"); - return; + return false; } =20 vcdev->io_region_size =3D info->size; @@ -553,7 +553,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) g_free(info); } =20 - return; + return true; =20 out_err: g_free(vcdev->crw_region); @@ -561,7 +561,7 @@ out_err: g_free(vcdev->async_cmd_region); g_free(vcdev->io_region); g_free(info); - return; + return false; } =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) @@ -597,8 +597,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) goto out_attach_dev_err; } =20 - vfio_ccw_get_region(vcdev, &err); - if (err) { + if (!vfio_ccw_get_region(vcdev, &err)) { goto out_region_err; } =20 --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353029; cv=none; d=zohomail.com; s=zohoarc; b=g5D/G3jDDlQkqG12kUMfGHJ0YuIrmHxtbNVk599Nt2wrW7Rp5x2ansLzowIupub+KrOFvDtBpb8xHDRdyxUGVxXboqLuYapLqzkQFaS78VxrgvHAkWYSbabILtXt77fF4Bt9IymrCqMF2E/Z4w7rY7dRUIu0ok0yQszvLqXzO3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353029; 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=VvL0NcOvEDibfJ1emSOK0fG03drA+l8AQovJ1aMQJnI=; b=eCGGGRywQ1hF7MEV/FAocYQaOE43ERQ2jdtTx1QxhsnnELqCWO4dcY2HhPiBOu50FSqBGfxnANFf9yxTvf8yDqXUulhZSp/zQZJ1i4F+QgUI/GWfew7coEbLOHOOGSJLYpXSH20U1LGHBEbFPti5afr8kjeyRakIX4zPW3F9bxA= 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 1716353029212743.0898915548269; Tue, 21 May 2024 21:43:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dob-0001SF-KV; Wed, 22 May 2024 00:43:01 -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 1s9doZ-0001QU-VR for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:59 -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 1s9doY-0005uB-8g for qemu-devel@nongnu.org; Wed, 22 May 2024 00:42:59 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:57 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352978; x=1747888978; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C/A9yvMH2CsXWTC4vyEkxTbhyKMCw2D1NBbb5lb7oFU=; b=BgSi0bnqgi+45P+BmBV/5lXIGyqVrFU4CmeySPMj1hH2mwhTwu0zCNJC U7sEfrvXbV2g7YNyJigJAYuemZzbY5L2QZjdq3eu+6hMbB7PUHHtO+T6M h0TToA5rODOpt2cXdWfZ+S7GVkqH/2WOTHklRwL5Z5AtXCfAbSR4ZgwIB clsCsSOVavD56DZ5OEPBsZlLDXo1dSnW+a9Sf55w3ipvHL7UbEofCTD06 D9dVkbqFAWRoy7qspimchoLyERzlBbyePn9wLRrKDTWTqlwXo+YRfZs2H ObGg4HFmGEoZ7JukkKRwJ7iyBgc16mWgxcWX+UIIA34BeyTFcZMZq0eCZ w==; X-CSE-ConnectionGUID: //6rTQtGRRmZzVoeW3SBmA== X-CSE-MsgGUID: 67fNhA3zT8+qcQX6v3EeEg== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994145" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994145" X-CSE-ConnectionGUID: wl2+Ngo5QI25EXNkwXfBbw== X-CSE-MsgGUID: V49bwSJ2TeK/DS9z+wCTWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683717" 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 Subject: [PATCH v2 08/20] vfio/pci: Make vfio_intx_enable_kvm() return a bool Date: Wed, 22 May 2024 12:40:03 +0800 Message-Id: <20240522044015.412951-9-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353030722100007 Since vfio_intx_enable_kvm() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index aad012c348..12fb534d79 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -116,7 +116,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX); } =20 -static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) { #ifdef CONFIG_KVM int irq_fd =3D event_notifier_get_fd(&vdev->intx.interrupt); @@ -124,7 +124,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) if (vdev->no_kvm_intx || !kvm_irqfds_enabled() || vdev->intx.route.mode !=3D PCI_INTX_ENABLED || !kvm_resamplefds_enabled()) { - return; + return true; } =20 /* Get to a known interrupt state */ @@ -161,7 +161,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) =20 trace_vfio_intx_enable_kvm(vdev->vbasedev.name); =20 - return; + return true; =20 fail_vfio: kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &vdev->intx.interrupt, @@ -171,6 +171,9 @@ fail_irqfd: fail: qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev); vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + return false; +#else + return true; #endif } =20 @@ -226,8 +229,7 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIIN= TxRoute *route) return; } =20 - vfio_intx_enable_kvm(vdev, &err); - if (err) { + if (!vfio_intx_enable_kvm(vdev, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 @@ -302,8 +304,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) return -errno; } =20 - vfio_intx_enable_kvm(vdev, &err); - if (err) { + if (!vfio_intx_enable_kvm(vdev, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353227; cv=none; d=zohomail.com; s=zohoarc; b=iuG5v6AHjMExMphiyxcBVEldXhm7Z29dRpngIcSqFJIcAmnWIuH5wHokXtl4HetuUaH3HjtFQJ29BUushtGg6uhTaOEiIRTWOve8doH/5My2JYqgnYYpHWZ4l34reiUCEEUaBVygo3TdUy4iG0CS+KLeuAhLqoYobeHFkQIWQyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353227; h=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=1cmyLUWaReNKz50dDZlqMcGNwm+pkiOAydnGtcVN1EQ=; b=J9VQrnjpVQHGkcdHvSfjS6YUge4B8w1WLo6Lw2TIjDZdi+BPAHyG6P3PWO3lPF1GMhLcBjf0vTvJiGh8F8nLB+ZgT7ldvL7s+GcrC86DJgd3JGwqCUaWqjtg15ugln7RdIoR9M2mV3htobH7IBjIpJvXNq32UuUZuKY28Znw/gI= 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 1716353227792672.5504451080864; Tue, 21 May 2024 21:47:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dod-0001Su-EZ; Wed, 22 May 2024 00:43:03 -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 1s9dob-0001SS-Pv for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:01 -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 1s9doZ-0005u5-SR for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:01 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:59 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:42:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352980; x=1747888980; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IPQQMAowSOqAwzmnpcrnJJyj8emLMPn2U5wNNY2Yg40=; b=BOBXgIkLwFWr8j8SptRftp64Jv8a1F71GN4UMi+CJXtHRrogklKgvOOw hjF89bczBVQ+0/VVek7N7EmtrDdts5bPTwwEaZ6CE8rIFNTNnuZr7YEFR Fue/UEKWZwKUqRguhw/7K8LxmHwwECUjKxL1t9a+u1rOfFcZq14JC6lZ9 T09pQyj+XMHbA3gIHdZAUXOmEPI44HVsDM3h9JqMFOj2zKw1wun04PI7F mFOJapop9hsDWesaIik2GXYDyty1Ywpg0rxwhMbAGO0Y5k05MVlJp5Cn6 Rx1IUW/8blbO012lFk9NciPsQf9cLTJK1TQHYliTbNEBauqmc5JjkgOXY Q==; X-CSE-ConnectionGUID: D6tF84QWQO6oMLMoh3QD/A== X-CSE-MsgGUID: DHZpG7deQty6sY+tLqHD6Q== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994149" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994149" X-CSE-ConnectionGUID: HC585QCKQrGwDcup6jBBYw== X-CSE-MsgGUID: ZuhnbqoUTuCQZ5rWq8tZUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683726" 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 Subject: [PATCH v2 09/20] vfio/pci: Make vfio_pci_relocate_msix() and vfio_msix_early_setup() return a bool Date: Wed, 22 May 2024 12:40:04 +0800 Message-Id: <20240522044015.412951-10-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353228864100002 Content-Type: text/plain; charset="utf-8" Since vfio_pci_relocate_msix() and vfio_msix_early_setup() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. By this chance, pass errp directly to vfio_msix_early_setup() to avoid calling error_propagate(). Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 12fb534d79..4fb5fd0c9f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1450,13 +1450,13 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevic= e *vdev) } } =20 -static void vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) { int target_bar =3D -1; size_t msix_sz; =20 if (!vdev->msix || vdev->msix_relo =3D=3D OFF_AUTOPCIBAR_OFF) { - return; + return true; } =20 /* The actual minimum size of MSI-X structures */ @@ -1479,7 +1479,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) if (target_bar < 0) { error_setg(errp, "No automatic MSI-X relocation available for " "device %04x:%04x", vdev->vendor_id, vdev->device_i= d); - return; + return false; } } else { target_bar =3D (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0); @@ -1489,7 +1489,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) if (vdev->bars[target_bar].ioport) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "I/O port BAR", target_bar); - return; + return false; } =20 /* Cannot use a BAR in the "shadow" of a 64-bit BAR */ @@ -1497,7 +1497,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) target_bar > 0 && vdev->bars[target_bar - 1].mem64) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "consumed by 64-bit BAR %d", target_bar, target_bar - 1= ); - return; + return false; } =20 /* 2GB max size for 32-bit BARs, cannot double if already > 1G */ @@ -1505,7 +1505,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) !vdev->bars[target_bar].mem64) { error_setg(errp, "Invalid MSI-X relocation BAR %d, " "no space to extend 32-bit BAR", target_bar); - return; + return false; } =20 /* @@ -1540,6 +1540,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) =20 trace_vfio_msix_relo(vdev->vbasedev.name, vdev->msix->table_bar, vdev->msix->table_offset); + return true; } =20 /* @@ -1550,7 +1551,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vde= v, Error **errp) * need to first look for where the MSI-X table lives. So we * unfortunately split MSI-X setup across two functions. */ -static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) { uint8_t pos; uint16_t ctrl; @@ -1562,25 +1563,25 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vd= ev, Error **errp) =20 pos =3D pci_find_capability(&vdev->pdev, PCI_CAP_ID_MSIX); if (!pos) { - return; + return true; } =20 if (pread(fd, &ctrl, sizeof(ctrl), vdev->config_offset + pos + PCI_MSIX_FLAGS) !=3D sizeof(ctrl= )) { error_setg_errno(errp, errno, "failed to read PCI MSIX FLAGS"); - return; + return false; } =20 if (pread(fd, &table, sizeof(table), vdev->config_offset + pos + PCI_MSIX_TABLE) !=3D sizeof(tabl= e)) { error_setg_errno(errp, errno, "failed to read PCI MSIX TABLE"); - return; + return false; } =20 if (pread(fd, &pba, sizeof(pba), vdev->config_offset + pos + PCI_MSIX_PBA) !=3D sizeof(pba)) { error_setg_errno(errp, errno, "failed to read PCI MSIX PBA"); - return; + return false; } =20 ctrl =3D le16_to_cpu(ctrl); @@ -1598,7 +1599,7 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) if (ret < 0) { error_setg_errno(errp, -ret, "failed to get MSI-X irq info"); g_free(msix); - return; + return false; } =20 msix->noresize =3D !!(irq_info.flags & VFIO_IRQ_INFO_NORESIZE); @@ -1630,7 +1631,7 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) error_setg(errp, "hardware reports invalid configuration, " "MSIX PBA outside of specified BAR"); g_free(msix); - return; + return false; } } =20 @@ -1641,7 +1642,7 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) =20 vfio_pci_fixup_msix_region(vdev); =20 - vfio_pci_relocate_msix(vdev, errp); + return vfio_pci_relocate_msix(vdev, errp); } =20 static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) @@ -3130,9 +3131,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 vfio_bars_prepare(vdev); =20 - vfio_msix_early_setup(vdev, &err); - if (err) { - error_propagate(errp, err); + if (!vfio_msix_early_setup(vdev, errp)) { goto error; } =20 --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353298; cv=none; d=zohomail.com; s=zohoarc; b=kgxukUgHvdtQEOBCg7e3VfQ6X4k2M50Ob7eHP14qaMhHuMxMwla5li8uZGJO5oBgY3sRRK0J36orcTxnvcHmb9Hnrr4s7JqPcvGoPI522EhLmevUOfoWiXLuFH8l+Td+z5V54J/Ipc8G1aHiTGX+c2AtXSBeo6pvW6WHoHRQ+u8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353298; h=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=aZE4Ph5Cn4kIiPu4Wbpe7Oxi+OZNeq03025Tjieh4R8=; b=XqWf2x+MkflkDvSreNgkEcWoq4y/msMxDZweHdJ+C5Vv/uj3PJHAymkhJUUkqWjqvCCPuOQwjnLelypUO4BuFRYWI0PTH3PgyB0IGxHTfrETOkkrfZeZ6y0cjqwfXnAFchC/5Z7ywp98tkStKEweJczZgYnH9cKDPV4KH+p2v0U= 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 17163532987861023.7977352995775; Tue, 21 May 2024 21:48:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doh-0001UB-EB; Wed, 22 May 2024 00:43:07 -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 1s9doe-0001TL-Ny for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:04 -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 1s9doc-0005uB-0a for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:04 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:02 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352982; x=1747888982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4vnQ/6Kcq+OwTuoUc/ihEvaXOo4aI1an8bbYY1k+F7A=; b=d30gYit/2ER9/GKgzjYehpRCPE5bD9SejDeL/hdsotdqkLQpe+3oYOZb 14qpcrQEOwLIk1wduWGXS+vtoje7vvhSmHW2ungwO2Vw1iMFf4OlXtIUO n0VwuAfQF2X3nrT1iKvIsEWKONRWUj4dvrGmDrhOfXy7t4seFpFDRhail WghR/71dPmo1EyBjSQYQvHSPaZoC/GOkhKtyotqJ6aXAHFDLw//PENxM3 fuMpWdIAgEKkUMj/KDQwOAent1kt5R089rwQRn8k1qvU0NynKokenLpd9 /+WPCDfzr+a+7Jc5GNV9vEUvjCXfurR5QDmFdj1uQaXVHG+NEC6a4nqed A==; X-CSE-ConnectionGUID: OpC4ehdjSmykOtyASaa/eQ== X-CSE-MsgGUID: xvS3SV5RTNCp42Gx93JAmA== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994151" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994151" X-CSE-ConnectionGUID: yFEdXlSfRCKdVJcLx7kaxQ== X-CSE-MsgGUID: yVQ+vkj6TCG+qC4belZ88Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683732" 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 Subject: [PATCH v2 10/20] vfio/pci: Make vfio_populate_device() return a bool Date: Wed, 22 May 2024 12:40:05 +0800 Message-Id: <20240522044015.412951-11-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353299259100007 Content-Type: text/plain; charset="utf-8" Since vfio_populate_device() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. By this chance, pass errp directly to vfio_populate_device() to avoid calling error_propagate(). Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4fb5fd0c9f..46d3c61859 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2740,7 +2740,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) return 0; } =20 -static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; struct vfio_region_info *reg_info; @@ -2750,18 +2750,18 @@ static void vfio_populate_device(VFIOPCIDevice *vde= v, Error **errp) /* Sanity check device */ if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PCI)) { error_setg(errp, "this isn't a PCI device"); - return; + return false; } =20 if (vbasedev->num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) { error_setg(errp, "unexpected number of io regions %u", vbasedev->num_regions); - return; + return false; } =20 if (vbasedev->num_irqs < VFIO_PCI_MSIX_IRQ_INDEX + 1) { error_setg(errp, "unexpected number of irqs %u", vbasedev->num_irq= s); - return; + return false; } =20 for (i =3D VFIO_PCI_BAR0_REGION_INDEX; i < VFIO_PCI_ROM_REGION_INDEX; = i++) { @@ -2773,7 +2773,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) =20 if (ret) { error_setg_errno(errp, -ret, "failed to get region %d info", i= ); - return; + return false; } =20 QLIST_INIT(&vdev->bars[i].quirks); @@ -2783,7 +2783,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) VFIO_PCI_CONFIG_REGION_INDEX, ®_info); if (ret) { error_setg_errno(errp, -ret, "failed to get config info"); - return; + return false; } =20 trace_vfio_populate_device_config(vdev->vbasedev.name, @@ -2804,7 +2804,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) if (ret) { error_append_hint(errp, "device does not support " "requested feature x-vga\n"); - return; + return false; } } =20 @@ -2821,6 +2821,8 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) "Could not enable error recovery for the device", vbasedev->name); } + + return true; } =20 static void vfio_pci_put_device(VFIOPCIDevice *vdev) @@ -2977,7 +2979,6 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) VFIOPCIDevice *vdev =3D VFIO_PCI(pdev); VFIODevice *vbasedev =3D &vdev->vbasedev; char *subsys; - Error *err =3D NULL; int i, ret; bool is_mdev; char uuid[UUID_STR_LEN]; @@ -3036,9 +3037,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } =20 - vfio_populate_device(vdev, &err); - if (err) { - error_propagate(errp, err); + if (!vfio_populate_device(vdev, errp)) { goto error; } =20 --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353299; cv=none; d=zohomail.com; s=zohoarc; b=kvlHswiuIunoDZwvRzSVbGT4SuFA+Jiq5W/T9x1WvnS79gKzCrit7z/aYwHazIUtD87F21XC9Skz5hmFhJX8RPEMu3sXnPrNHmmGROTvbgOIVx7lVTMpDGhVi2Ixhs70dzUXy6vwHRABLTVeXZCWy4WSK00ozbNrswxAqaR/vXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353299; 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=Gj1kPIFV2gtta4EhIhaRmVG4fBI7lYcy6vvL0rinUGk=; b=bZMw2N+zMFaHdmb/FsLJBvOtDHMca/21+YVqtqcWBjomBlWxA9eaIadcR/oYir2yEO8J27bX8R5u6CD6RtBElXqlF9voQLPiS+Fdw1BhtXCQnwzgVjBt4BCaC34ytbHF+SQqzlNgp2VonlAfSCrBHoAX8TTV/Bl0k3kD8+pyAMg= 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 1716353299845284.3489294994839; Tue, 21 May 2024 21:48:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doj-0001Uu-44; Wed, 22 May 2024 00:43:09 -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 1s9dog-0001TY-1j for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:06 -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 1s9doe-0005u5-Bc for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:05 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:04 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352985; x=1747888985; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=05IaDSHKAn5N1DlE7YBOtpaIa7wa9rMM7eRtIlNK04w=; b=l0mXmcVxzCKcN92aChKH7SZj7LcafBIuhznewOkA2yzqkz0VKIOsskVU 8QClJoKUCIrFc2iirFWLQvPxcUurYe5hmolhWUiuqOdZxRN71kDWYwOg0 kaJOyKGG0vEwqMiA8Xa8RvPfKQ8x40dLkuc0hekFDId0IaG9j/3kTDkbi lsZYpBYj1AJeZXjUK2GVpBlUm1Cw+UrDZiRbZHhm7F+ql2eGtADX3dSyA EGrMdgwex4Frs3YamDg6SQEzLZtrdOSFSpHOA0ZztyBHFuXowHzpJ9T0q JZgGZLqom7D734GnjORNoHlTbCZTAqoeCiI61XY0AnyqpAsoJqE2oPTYW Q==; X-CSE-ConnectionGUID: ZhXxuquXSraSNGfmDdbyoQ== X-CSE-MsgGUID: sgKjiuDpRG+uaL6e2YBvcw== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994169" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994169" X-CSE-ConnectionGUID: Fh4UKSxtSByNbuWFq4pgJg== X-CSE-MsgGUID: +BkCBCpPTm63xyPwM9JeBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683742" 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 Subject: [PATCH v2 11/20] vfio/pci: Make vfio_intx_enable() return bool Date: Wed, 22 May 2024 12:40:06 +0800 Message-Id: <20240522044015.412951-12-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353301298100011 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 46d3c61859..7f35cb8a29 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -261,7 +261,7 @@ static void vfio_irqchip_change(Notifier *notify, void = *data) vfio_intx_update(vdev, &vdev->intx.route); } =20 -static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) { uint8_t pin =3D vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1= ); Error *err =3D NULL; @@ -270,7 +270,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) =20 =20 if (!pin) { - return 0; + return true; } =20 vfio_disable_interrupts(vdev); @@ -292,7 +292,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) ret =3D event_notifier_init(&vdev->intx.interrupt, 0); if (ret) { error_setg_errno(errp, -ret, "event_notifier_init failed"); - return ret; + return false; } fd =3D event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev); @@ -301,7 +301,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->intx.interrupt); - return -errno; + return false; } =20 if (!vfio_intx_enable_kvm(vdev, &err)) { @@ -311,7 +311,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) vdev->interrupt =3D VFIO_INT_INTx; =20 trace_vfio_intx_enable(vdev->vbasedev.name); - return 0; + return true; } =20 static void vfio_intx_disable(VFIOPCIDevice *vdev) @@ -836,8 +836,7 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev) vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); =20 vfio_msi_disable_common(vdev); - vfio_intx_enable(vdev, &err); - if (err) { + if (!vfio_intx_enable(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 @@ -2450,8 +2449,7 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev) Error *err =3D NULL; int nr; =20 - vfio_intx_enable(vdev, &err); - if (err) { + if (!vfio_intx_enable(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 @@ -3194,8 +3192,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) vfio_intx_routing_notifier); vdev->irqchip_change_notifier.notify =3D vfio_irqchip_change; kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier); - ret =3D vfio_intx_enable(vdev, errp); - if (ret) { + if (!vfio_intx_enable(vdev, errp)) { goto out_deregister; } } --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353335; cv=none; d=zohomail.com; s=zohoarc; b=AqOAdeQjw1KVoSajybB4Yo3eOIDGBQhMvu0lLrNRM5TIaGErawTeXEXi3ISvS1AIuk8FQte1gKgdXmfZzxmNfuWGMRHcWkD8bBmBQk8LOvRnM8ErJR4D+5wSP9OwtvZEcyQH+QjD4jfVp5rnUbSQziAVQ9cEz+tsu/oxRSlXxPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353335; 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=VrbNZbvXJo1o4fFH7Ns8q+4egC45B0GWcj61AdDhwX4=; b=XwgG99Oqj1/r5/6sm3oVw2JuGKLDtKo+40htr0F6ua6B4U3t2sVE67oNAFU5FKiEQAMjQAvPZuPFHvtTIqhXy0e6cOWc9F9LjRaGIB4DZBr/IWSHItCDYFK7rKM7wBaYweCtx4+LrJ7Q87DXJyeKdPe3VUus5XEvrj81qCkKke8= 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 1716353335663277.3218760990119; Tue, 21 May 2024 21:48:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dov-0001XA-5s; Wed, 22 May 2024 00:43:21 -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 1s9dot-0001WQ-4f for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:19 -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 1s9dor-0005wI-CU for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:18 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:06 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716352998; x=1747888998; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7eFZrjbfA5oNwZy5OE7kDDJBTgUaqB10QV45V02DIlg=; b=SRDmOiJnRUY69P0NEdUgar0WFCZ3VoOzFG4HV+1WNjNXE9zozDvFnniU ZqmgECIntQxFIi82OwlXBVBGC1LgMSGroMKQT+4B6JRBA4KyAGCfvf8Wn tN370EJx9kcgv5nE7lW635xFdeGzYBbTwLWRdrQZ7UM3K3nngVl6t9yF7 lOtUw0jKBJ3VQozFY2vZLmbrCkpyywvhQGWQrrOh1oHotIwfLs/RZjT9e MmmCjzCXQ19v8gukKhAj5zvOwlq7/lKezEZP5PUhBCAov4RdyFXrmgimB 1Z+4H5Xu7qF3TsH72trrVAVatzzk3fjJj31vcR7J5vjfxk7EqJJGB+kU/ A==; X-CSE-ConnectionGUID: 8lCcwKGvQ6i95knVbtLhuA== X-CSE-MsgGUID: 0OJsuZLKRjOCRxr1N7p2sA== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994173" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994173" X-CSE-ConnectionGUID: exnLu96UQOuDVLpN7Henkw== X-CSE-MsgGUID: ekNCawyETcqSezmqCSgnIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683750" 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 Subject: [PATCH v2 12/20] vfio/pci: Make vfio_populate_vga() return bool Date: Wed, 22 May 2024 12:40:07 +0800 Message-Id: <20240522044015.412951-13-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353337408100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 2 +- hw/vfio/igd.c | 2 +- hw/vfio/pci.c | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index a5ac9efd4b..7914f019d5 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -225,7 +225,7 @@ bool vfio_pci_host_match(PCIHostDeviceAddress *addr, co= nst char *name); int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev, struct vfio_pci_hot_reset_info **info_= p); =20 -int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); +bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); =20 int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, struct vfio_region_info *info, diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index b31ee79c60..ffe57c5954 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -478,7 +478,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) * try to enable it. Probably shouldn't be using legacy mode without = VGA, * but also no point in us enabling VGA if disabled in hardware. */ - if (!(gmch & 0x2) && !vdev->vga && vfio_populate_vga(vdev, &err)) { + if (!(gmch & 0x2) && !vdev->vga && !vfio_populate_vga(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); error_report("IGD device %s failed to enable VGA access, " "legacy mode disabled", vdev->vbasedev.name); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 7f35cb8a29..ab8f74299e 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2670,7 +2670,7 @@ static VFIODeviceOps vfio_pci_ops =3D { .vfio_load_config =3D vfio_pci_load_config, }; =20 -int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp) +bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; struct vfio_region_info *reg_info; @@ -2681,7 +2681,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) error_setg_errno(errp, -ret, "failed getting region info for VGA region index = %d", VFIO_PCI_VGA_REGION_INDEX); - return ret; + return false; } =20 if (!(reg_info->flags & VFIO_REGION_INFO_FLAG_READ) || @@ -2691,7 +2691,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) (unsigned long)reg_info->flags, (unsigned long)reg_info->size); g_free(reg_info); - return -EINVAL; + return false; } =20 vdev->vga =3D g_new0(VFIOVGA, 1); @@ -2735,7 +2735,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev, Error **er= rp) &vdev->vga->region[QEMU_PCI_VGA_IO_LO].mem, &vdev->vga->region[QEMU_PCI_VGA_IO_HI].mem); =20 - return 0; + return true; } =20 static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) @@ -2798,8 +2798,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) g_free(reg_info); =20 if (vdev->features & VFIO_FEATURE_ENABLE_VGA) { - ret =3D vfio_populate_vga(vdev, errp); - if (ret) { + if (!vfio_populate_vga(vdev, errp)) { error_append_hint(errp, "device does not support " "requested feature x-vga\n"); return false; --=20 2.34.1 From nobody Mon Nov 25 07:50:19 2024 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=1716353051; cv=none; d=zohomail.com; s=zohoarc; b=fl41uUCnHmSNY4gb+/TCGgitLpOzg0QzA5GiiE0Y/C4E42bEksRUwpDx2SWo92oTEE6HWWeSwb0HJHiNFNGOxFleyGrXPNwQBgm+l29wLGtZJGwGd5gePI01CHEKFcJTWTMnr/jhENeqXi3jaZ69bVzZJrJl2bsjJTpGy4sexgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353051; 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=18LX5sO3A7IPZX/WuypQsRIpQLUgWlEvaxJKu6qJuQI=; b=oB6S5bmICQGnr1ol4pYzQCnwF3FbCQsv4UP+GKGNuLGxKak7l0oTL1xrjmp5/WaPxTm9oAWDzlPzfBE1sTIcUhWuHn9KfgnjUbscGxJ6iBEsmT9J0I+DGQGN+Wa/2LlBx3bAT1DQSCGgKyLZr9rfEj7CKOYbYojRsmFo8xwcd08= 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 1716353051845772.6379249338779; Tue, 21 May 2024 21:44:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9doz-0001Xv-Ie; Wed, 22 May 2024 00:43:25 -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 1s9dov-0001XC-LT for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:21 -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 1s9dot-0005wM-Ik for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:21 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:08 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353000; x=1747889000; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5v8dt/xhJyMNn8cRvbSEnqVQ+GWt/s2v80ibmKizowo=; b=Zv4aD9LDLtBrLGJ53rslRoCGU+WK9F30aLV+OTfMpY0kWs8JFThrpOmR lStiX65nJ5gJz7Lr/bQlxXixUMD9bfewXUXDmGEqDSu8aOk004IKn1k6R 4/JlVwq99hhGwdYIZhWv8c7hvsJt2Wa47/vJsqQKdS+fFTE7UZ8xvpMXk sxoAqKsYC9Hn16CeBku8N5yVV7PXRCmlCNp5H5VribhVPBel1HVcZ1kCJ XfQctRnx25+0XHQyvaG3I0OH6M7VrpBejrPxYiYGSGeW1Y9m847lmg+l/ fiixegjWAcHQYFOyqjdxaivXkULWiwiP1rEC8lVThPo6Bi1S1IEtDbxsx g==; X-CSE-ConnectionGUID: tcG3vlFOSIu9W5PzpMJoKg== X-CSE-MsgGUID: i8K60yDcSKCrEBnsg2v2Uw== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994179" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994179" X-CSE-ConnectionGUID: g/we5yYSTZWKH/CvYEHgYw== X-CSE-MsgGUID: W3HzLJm2TROFPGZ/teCiig== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683754" 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 Subject: [PATCH v2 13/20] vfio/pci: Make capability related functions return bool Date: Wed, 22 May 2024 12:40:08 +0800 Message-Id: <20240522044015.412951-14-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353052205100003 The functions operating on capability don't have a consistent return style. Below functions are in bool-valued functions style: vfio_msi_setup() vfio_msix_setup() vfio_add_std_cap() vfio_add_capabilities() Below two are integer-valued functions: vfio_add_vendor_specific_cap() vfio_setup_pcie_cap() But the returned integer is only used for check succeed/failure. Change them all to return bool so now all capability related functions follow the coding standand in qapi/error.h to return bool. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 77 ++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index ab8f74299e..c3323912dd 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1339,7 +1339,7 @@ static void vfio_disable_interrupts(VFIOPCIDevice *vd= ev) } } =20 -static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp) +static bool vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp) { uint16_t ctrl; bool msi_64bit, msi_maskbit; @@ -1349,7 +1349,7 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int po= s, Error **errp) if (pread(vdev->vbasedev.fd, &ctrl, sizeof(ctrl), vdev->config_offset + pos + PCI_CAP_FLAGS) !=3D sizeof(ctrl)= ) { error_setg_errno(errp, errno, "failed reading MSI PCI_CAP_FLAGS"); - return -errno; + return false; } ctrl =3D le16_to_cpu(ctrl); =20 @@ -1362,14 +1362,14 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int = pos, Error **errp) ret =3D msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit, &e= rr); if (ret < 0) { if (ret =3D=3D -ENOTSUP) { - return 0; + return true; } error_propagate_prepend(errp, err, "msi_init failed: "); - return ret; + return false; } vdev->msi_cap_size =3D 0xa + (msi_maskbit ? 0xa : 0) + (msi_64bit ? 0x= 4 : 0); =20 - return 0; + return true; } =20 static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev) @@ -1644,7 +1644,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev= , Error **errp) return vfio_pci_relocate_msix(vdev, errp); } =20 -static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) +static bool vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) { int ret; Error *err =3D NULL; @@ -1660,11 +1660,11 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int= pos, Error **errp) if (ret < 0) { if (ret =3D=3D -ENOTSUP) { warn_report_err(err); - return 0; + return true; } =20 error_propagate(errp, err); - return ret; + return false; } =20 /* @@ -1698,7 +1698,7 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int p= os, Error **errp) memory_region_set_enabled(&vdev->pdev.msix_table_mmio, false); } =20 - return 0; + return true; } =20 static void vfio_teardown_msi(VFIOPCIDevice *vdev) @@ -1977,8 +1977,8 @@ static void vfio_pci_disable_rp_atomics(VFIOPCIDevice= *vdev) } } =20 -static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size, - Error **errp) +static bool vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size, + Error **errp) { uint16_t flags; uint8_t type; @@ -1992,7 +1992,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, =20 error_setg(errp, "assignment of PCIe type 0x%x " "devices is not currently supported", type); - return -EINVAL; + return false; } =20 if (!pci_bus_is_express(pci_get_bus(&vdev->pdev))) { @@ -2025,7 +2025,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, } =20 if (pci_bus_is_express(bus)) { - return 0; + return true; } =20 } else if (pci_bus_is_root(pci_get_bus(&vdev->pdev))) { @@ -2063,7 +2063,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, i= nt pos, uint8_t size, * Legacy endpoints don't belong on the root complex. Windows * seems to be happier with devices if we skip the capability. */ - return 0; + return true; } =20 } else { @@ -2099,12 +2099,12 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev,= int pos, uint8_t size, pos =3D pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size, errp); if (pos < 0) { - return pos; + return false; } =20 vdev->pdev.exp.exp_cap =3D pos; =20 - return pos; + return true; } =20 static void vfio_check_pcie_flr(VFIOPCIDevice *vdev, uint8_t pos) @@ -2137,14 +2137,14 @@ static void vfio_check_af_flr(VFIOPCIDevice *vdev, = uint8_t pos) } } =20 -static int vfio_add_vendor_specific_cap(VFIOPCIDevice *vdev, int pos, - uint8_t size, Error **errp) +static bool vfio_add_vendor_specific_cap(VFIOPCIDevice *vdev, int pos, + uint8_t size, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; =20 pos =3D pci_add_capability(pdev, PCI_CAP_ID_VNDR, pos, size, errp); if (pos < 0) { - return pos; + return false; } =20 /* @@ -2156,15 +2156,15 @@ static int vfio_add_vendor_specific_cap(VFIOPCIDevi= ce *vdev, int pos, memset(pdev->cmask + pos + 3, 0, size - 3); } =20 - return pos; + return true; } =20 -static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp) +static bool vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **err= p) { ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; uint8_t cap_id, next, size; - int ret; + bool ret; =20 cap_id =3D pdev->config[pos]; next =3D pdev->config[pos + PCI_CAP_LIST_NEXT]; @@ -2185,9 +2185,8 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint= 8_t pos, Error **errp) * will be changed as we unwind the stack. */ if (next) { - ret =3D vfio_add_std_cap(vdev, next, errp); - if (ret) { - return ret; + if (!vfio_add_std_cap(vdev, next, errp)) { + return false; } } else { /* Begin the rebuild, use QEMU emulated list bits */ @@ -2197,7 +2196,7 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint= 8_t pos, Error **errp) =20 ret =3D vfio_add_virt_caps(vdev, errp); if (ret) { - return ret; + return false; } } =20 @@ -2221,28 +2220,27 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, ui= nt8_t pos, Error **errp) case PCI_CAP_ID_PM: vfio_check_pm_reset(vdev, pos); vdev->pm_cap =3D pos; - ret =3D pci_add_capability(pdev, cap_id, pos, size, errp); + ret =3D pci_add_capability(pdev, cap_id, pos, size, errp) >=3D 0; break; case PCI_CAP_ID_AF: vfio_check_af_flr(vdev, pos); - ret =3D pci_add_capability(pdev, cap_id, pos, size, errp); + ret =3D pci_add_capability(pdev, cap_id, pos, size, errp) >=3D 0; break; case PCI_CAP_ID_VNDR: ret =3D vfio_add_vendor_specific_cap(vdev, pos, size, errp); break; default: - ret =3D pci_add_capability(pdev, cap_id, pos, size, errp); + ret =3D pci_add_capability(pdev, cap_id, pos, size, errp) >=3D 0; break; } =20 - if (ret < 0) { + if (!ret) { error_prepend(errp, "failed to add PCI capability 0x%x[0x%x]@0x%x: ", cap_id, size, pos); - return ret; } =20 - return 0; + return ret; } =20 static int vfio_setup_rebar_ecap(VFIOPCIDevice *vdev, uint16_t pos) @@ -2388,23 +2386,21 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) return; } =20 -static int vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; - int ret; =20 if (!(pdev->config[PCI_STATUS] & PCI_STATUS_CAP_LIST) || !pdev->config[PCI_CAPABILITY_LIST]) { - return 0; /* Nothing to add */ + return true; /* Nothing to add */ } =20 - ret =3D vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST], errp= ); - if (ret) { - return ret; + if (!vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST], errp)) { + return false; } =20 vfio_add_ext_cap(vdev); - return 0; + return true; } =20 void vfio_pci_pre_reset(VFIOPCIDevice *vdev) @@ -3133,8 +3129,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 vfio_bars_register(vdev); =20 - ret =3D vfio_add_capabilities(vdev, errp); - if (ret) { + if (!vfio_add_capabilities(vdev, errp)) { goto out_teardown; } =20 --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353250; cv=none; d=zohomail.com; s=zohoarc; b=lQVk/nyiVdtfItkMio6symstg/TzJ1eThTn0BveDbIli6u6pUnl5XtTY8AiEXp1lH9Ur+VxvudXjSXCkRDa5wKS441PwHQvY5M5Zy2Xce3rD87BeDDe5xPOsZIf7NQWazWLhGpUL/uv1OfG5xOaljoAXhqS37RDAkwjYFm4GJZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353250; 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=TXVp6CP6Gi4F+2sdlT38W8u522QxeRSuonJRK5cTfNc=; b=Nu/BnD4EfIZJFbeHUPndWlp6aqWyI1gETTmjCBZe4wgoGlXxn5p5iH/SITXcpd8jIvP0ugrYtC9pJ8mdfKGgePfKj1zRVUJPVffE9rSFTE6vti1Xqt2rG/F2gAylWW/A1SCkq1zhqnztkOuPdZ4ThFZ6TkKQfJhEyZApZ7T4hm0= 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 1716353250744915.4256195799122; Tue, 21 May 2024 21:47:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dp2-0001ZH-Kw; Wed, 22 May 2024 00:43:28 -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 1s9dox-0001XW-6K for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:23 -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 1s9dov-0005wQ-M3 for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:22 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:11 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353002; x=1747889002; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V8yxZZ1IG6SB5qSxhKY8vL9VI3CH904ht7jW/ItgoVk=; b=Apstu+d/h5xItkNPoZ+NVEKnEvxJifZc1lP03TUoqOn87MdoX9MvT8IV C/LAi6rforeLvXn9lSbrwn7ppsbJ3igL+RK0WttoSxUGx27lMwg6yV8Rl nuZ6rYuFWMZep7CfXJt4TttTMGtJ+sIm3fm98Ez9Pch6G6DjImcd2WJAW D2aoRLf/9aye0v8ON8e3TVRmEJhuEGRZwxm4Zn/jplE/EEvUZ79SyFu6F h06vFH5bQvsfikxQKG8BYXJtVscu0xstpB1Rwiu9HqM/ck/ERDybi9evQ Rpb1BWeZh+aamj3xSwBMJKa4BHf9vJnq035MD7j58Ejo3+zVbGp88f6CZ A==; X-CSE-ConnectionGUID: QtSbz11nT2qwv7bwT39sww== X-CSE-MsgGUID: upAY3MoVQPadDPrv7dT+vg== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994188" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994188" X-CSE-ConnectionGUID: xARcH7zPQoeERv2BGp0WSw== X-CSE-MsgGUID: 1gz4UMVrQuaYBo1QiKy+Xg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683765" 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 Subject: [PATCH v2 14/20] vfio/pci: Use g_autofree for vfio_region_info pointer Date: Wed, 22 May 2024 12:40:09 +0800 Message-Id: <20240522044015.412951-15-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353250976100001 Pointer opregion is freed after vfio_pci_igd_opregion_init(). Use 'g_autofree' to avoid the g_free() calls. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c3323912dd..8379d2284a 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3143,7 +3143,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 if (!vdev->igd_opregion && vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) { - struct vfio_region_info *opregion; + g_autofree struct vfio_region_info *opregion =3D NULL; =20 if (vdev->pdev.qdev.hotplugged) { error_setg(errp, @@ -3162,7 +3162,6 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) } =20 ret =3D vfio_pci_igd_opregion_init(vdev, opregion, errp); - g_free(opregion); if (ret) { goto out_teardown; } --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353296; cv=none; d=zohomail.com; s=zohoarc; b=SH1BEuu9WVuLjIDFeHSAzyxwkoIKLMBwhZ4+uoI92WTaUCyEed4/WrINhoCE+83BiEDr771POJpXlHONrmW8WS4xAarp7pLz/OBBm0RsXzJw6rhxoyoHpsU7/1u+FPtTpZbzekB0G1apT7vYAO08Y8C74h6YbZxYgIHRbwSsHzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353296; 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=suIUG9LHWcrRoc68+mv0ZdPT4m2LnhVzQDoO3oUCvTk=; b=ccRCYbv1Jbc6sjoYWZr5TqgPFslCzmjD9is5UTw0N65/YU5cTSFrYulj4AiDJez9Tsh1ELb4TvFRESYTuZF9+GBIk3pDU4ORiiJrtxo/OgDz+zJ7eLfWQdHnMxLms3SMr/ZSCeGBS+A30QlpTlTJE5VrKHk0BAXCPP++GXF9DG0= 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 1716353296407864.9616925912948; Tue, 21 May 2024 21:48:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dp7-0001Zs-Ax; Wed, 22 May 2024 00:43:33 -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 1s9dp5-0001ZT-6M for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:31 -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 1s9dp3-0005wI-Fk for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:30 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:13 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353010; x=1747889010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dn6e14o4vAD81Eqr3Acm7f/diTt8zZe65YgDglDEtUs=; b=TibGnC3Sy/ObPNrbKaeGvCsWNfLVIWXQvZlvRV8QGWmf0Vw043HdioNj QOwGfA6KndNlxI7GQJjhvWiHx5XSgrXldoS3fVZfkDYTgObjNfXlDoDEe Cme8gjmMAF0M98PvlbVqLgZKS0GCvXmOfBiJK9rMK80aXAsZ5yFR7kEtP NUhoj9wJWSjww8qk/dkYQOm/zX0FpODqUqY7Hwg23r2YJdyTZccEMNB3A hacbaKuBKkNZKQmsqalUAR4I3NBYHys8YfHyZKx/Fsg7nvmFkOKYAa2Nd rKgVDYeyd2JS47CvSYG9+0PB3mCUu0m8I0Ke6Mk8sxCpzqcmYLDM97/KI Q==; X-CSE-ConnectionGUID: pz+1dr53RXmIk+N85VdM4w== X-CSE-MsgGUID: 57WWA//HThKSF9J+EFDwmQ== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994196" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994196" X-CSE-ConnectionGUID: Cgya3eysSHCqT2AG/rtg5g== X-CSE-MsgGUID: ktb9ao4eRJu8hV5bOizDsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683773" 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 Subject: [PATCH v2 15/20] vfio/pci-quirks: Make vfio_pci_igd_opregion_init() return bool Date: Wed, 22 May 2024 12:40:10 +0800 Message-Id: <20240522044015.412951-16-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353297370100003 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 6 +++--- hw/vfio/igd.c | 3 +-- hw/vfio/pci-quirks.c | 8 ++++---- hw/vfio/pci.c | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 7914f019d5..f158681072 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -227,9 +227,9 @@ int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev, =20 bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); =20 -int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, - struct vfio_region_info *info, - Error **errp); +bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + struct vfio_region_info *info, + Error **errp); =20 void vfio_display_reset(VFIOPCIDevice *vdev); bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index ffe57c5954..402fc5ce1d 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -502,8 +502,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) } =20 /* Setup OpRegion access */ - ret =3D vfio_pci_igd_opregion_init(vdev, opregion, &err); - if (ret) { + if (!vfio_pci_igd_opregion_init(vdev, opregion, &err)) { error_append_hint(&err, "IGD legacy mode disabled\n"); error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); goto out; diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 496fd1ee86..ca27917159 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1169,8 +1169,8 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevi= ce *vdev, int nr) * the table and to write the base address of that memory to the ASLS regi= ster * of the IGD device. */ -int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, - struct vfio_region_info *info, Error **errp) +bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + struct vfio_region_info *info, Error **err= p) { int ret; =20 @@ -1181,7 +1181,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, error_setg(errp, "failed to read IGD OpRegion"); g_free(vdev->igd_opregion); vdev->igd_opregion =3D NULL; - return -EINVAL; + return false; } =20 /* @@ -1206,7 +1206,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0); pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0); =20 - return 0; + return true; } =20 /* diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8379d2284a..76a3931dba 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3161,8 +3161,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto out_teardown; } =20 - ret =3D vfio_pci_igd_opregion_init(vdev, opregion, errp); - if (ret) { + if (!vfio_pci_igd_opregion_init(vdev, opregion, errp)) { goto out_teardown; } } --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353030; cv=none; d=zohomail.com; s=zohoarc; b=LIQ2irE299S7GKLbAl+Pf188AiJQ1FV4ZDgrffKwrpRrV+Mk9Q+3dn3t85NDN5fZdzElV+JkOq45/vGVsa2KvYgS23ikNX47ZjiuVI++sIdBbYU64Msj4A4YLSHjYhMK8fCArg+XFwJRK0ddmLmZ29nhMqSt/fSpPFot7pHodaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353030; 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=Vbye1llExIT9GELL+ow07UgHslWOzeZALrT2EE7nzOQ=; b=aIyS/+e8vLu1kn+u++ajAwCWHVYRGRvfYG7qDwdNVM7y8WI9wZ0OsIz6PRFJX+M2trSH/f2GMzLso5hLjcXuO64GGM9L8ZG4Apa8rEFQ1Z4Qw7ZQQ9PR+RRJn1YjWUHVWWdwLvajf5wsFT7PW+rNGJFxio4Qi3a1V0Qn70NNFBw= 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 171635303012721.418638202383818; Tue, 21 May 2024 21:43:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dp9-0001mf-GL; Wed, 22 May 2024 00:43:35 -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 1s9dp8-0001dR-1K for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:34 -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 1s9dp6-0005wM-2x for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:33 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:15 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353012; x=1747889012; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j8T6r/SqLsJM5T4vmX872z0GLXVctTuK/o6SD9aHsJc=; b=Z5dLPpvdI58oRV9VJUDvX1kmrX6AEsyLFGvrKr+jHqT1Td07dQD2piA5 mwSnEl1TCF7bdmYfPbBSOdvlIMFyZ25pqjDwgUBjvoGTCb/+1eGHBNc3w hidp1kdzHm2snW+EbwWieabxSEzUS90i5RzKG0HlMITybYp2gNSQeZ/a5 fk4TbyoalwpjSfVRhK6OBhbKaXqVtPafUD+amqKXrIHsVlCAWsuppDboZ mxas6EC5+wLW8b72Q29MlX/D6LHY/sWSH7Qcqt9d03M63OsazNVcBteYF dMNAD2pO4iA/Kye+TMWc45E0FNwFZ0W4zbZzYxTfZLZhmYOcAmimuQ4+D A==; X-CSE-ConnectionGUID: dHT6AzqGRW6Lq74+PtihIw== X-CSE-MsgGUID: qieofTKSTYaxEm8EGWaB9w== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994205" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994205" X-CSE-ConnectionGUID: 66uclaccSveWwTWAC9Ay8A== X-CSE-MsgGUID: JyHvSufDRpCRD9hVPpXqQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683788" 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 Subject: [PATCH v2 16/20] vfio/pci-quirks: Make vfio_add_*_cap() return bool Date: Wed, 22 May 2024 12:40:11 +0800 Message-Id: <20240522044015.412951-17-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353032060100019 This is to follow the coding standand in qapi/error.h to return bool for bool-valued functions. Include below functions: vfio_add_virt_caps() vfio_add_nv_gpudirect_cap() vfio_add_vmd_shadow_cap() Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.h | 2 +- hw/vfio/pci-quirks.c | 42 +++++++++++++++++++----------------------- hw/vfio/pci.c | 3 +-- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index f158681072..bf67df2fbc 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -212,7 +212,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr); void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr); void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr); void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev); -int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp); +bool vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp); void vfio_quirk_reset(VFIOPCIDevice *vdev); VFIOQuirk *vfio_quirk_alloc(int nr_mem); void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr); diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index ca27917159..39dae72497 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1536,7 +1536,7 @@ static bool is_valid_std_cap_offset(uint8_t pos) pos <=3D (PCI_CFG_SPACE_SIZE - PCI_CAP_SIZEOF)); } =20 -static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp) { ERRP_GUARD(); PCIDevice *pdev =3D &vdev->pdev; @@ -1545,18 +1545,18 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice = *vdev, Error **errp) uint8_t tmp; =20 if (vdev->nv_gpudirect_clique =3D=3D 0xFF) { - return 0; + return true; } =20 if (!vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID)) { error_setg(errp, "NVIDIA GPUDirect Clique ID: invalid device vendo= r"); - return -EINVAL; + return false; } =20 if (pci_get_byte(pdev->config + PCI_CLASS_DEVICE + 1) !=3D PCI_BASE_CLASS_DISPLAY) { error_setg(errp, "NVIDIA GPUDirect Clique ID: unsupported PCI clas= s"); - return -EINVAL; + return false; } =20 /* @@ -1572,7 +1572,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) vdev->config_offset + PCI_CAPABILITY_LIST); if (ret !=3D 1 || !is_valid_std_cap_offset(tmp)) { error_setg(errp, "NVIDIA GPUDirect Clique ID: error getting cap li= st"); - return -EINVAL; + return false; } =20 do { @@ -1590,13 +1590,13 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice = *vdev, Error **errp) pos =3D 0xD4; } else { error_setg(errp, "NVIDIA GPUDirect Clique ID: invalid config space= "); - return -EINVAL; + return false; } =20 ret =3D pci_add_capability(pdev, PCI_CAP_ID_VNDR, pos, 8, errp); if (ret < 0) { error_prepend(errp, "Failed to add NVIDIA GPUDirect cap: "); - return ret; + return false; } =20 memset(vdev->emulated_config_bits + pos, 0xFF, 8); @@ -1608,7 +1608,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) pci_set_byte(pdev->config + pos++, vdev->nv_gpudirect_clique << 3); pci_set_byte(pdev->config + pos, 0); =20 - return 0; + return true; } =20 /* @@ -1629,7 +1629,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *v= dev, Error **errp) */ #define VMD_SHADOW_CAP_VER 1 #define VMD_SHADOW_CAP_LEN 24 -static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev, Error **errp) +static bool vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev, Error **errp) { ERRP_GUARD(); uint8_t membar_phys[16]; @@ -1639,7 +1639,7 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vde= v, Error **errp) vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, 0x467F) || vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, 0x4C3D) || vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, 0x9A0B))) { - return 0; + return true; } =20 ret =3D pread(vdev->vbasedev.fd, membar_phys, 16, @@ -1647,14 +1647,14 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *v= dev, Error **errp) if (ret !=3D 16) { error_report("VMD %s cannot read MEMBARs (%d)", vdev->vbasedev.name, ret); - return -EFAULT; + return false; } =20 ret =3D pci_add_capability(&vdev->pdev, PCI_CAP_ID_VNDR, pos, VMD_SHADOW_CAP_LEN, errp); if (ret < 0) { error_prepend(errp, "Failed to add VMD MEMBAR Shadow cap: "); - return ret; + return false; } =20 memset(vdev->emulated_config_bits + pos, 0xFF, VMD_SHADOW_CAP_LEN); @@ -1664,22 +1664,18 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *v= dev, Error **errp) pci_set_long(vdev->pdev.config + pos, 0x53484457); /* SHDW */ memcpy(vdev->pdev.config + pos + 4, membar_phys, 16); =20 - return 0; + return true; } =20 -int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp) +bool vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp) { - int ret; - - ret =3D vfio_add_nv_gpudirect_cap(vdev, errp); - if (ret) { - return ret; + if (!vfio_add_nv_gpudirect_cap(vdev, errp)) { + return false; } =20 - ret =3D vfio_add_vmd_shadow_cap(vdev, errp); - if (ret) { - return ret; + if (!vfio_add_vmd_shadow_cap(vdev, errp)) { + return false; } =20 - return 0; + return true; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 76a3931dba..35ad9b582f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2194,8 +2194,7 @@ static bool vfio_add_std_cap(VFIOPCIDevice *vdev, uin= t8_t pos, Error **errp) vdev->emulated_config_bits[PCI_CAPABILITY_LIST] =3D 0xff; vdev->emulated_config_bits[PCI_STATUS] |=3D PCI_STATUS_CAP_LIST; =20 - ret =3D vfio_add_virt_caps(vdev, errp); - if (ret) { + if (!vfio_add_virt_caps(vdev, errp)) { return false; } } --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353029; cv=none; d=zohomail.com; s=zohoarc; b=cZT7v3XAB0O9CE9aoh/sL0BQU57pYAxDxlZT4L5nmX+yvTN7+nYbYp0JrCz7oWgKcpGZpKZm46j8ZRE65oJelonabIuO7nKLFBdvtpt7SYuEvMCBrnrBZ5I6fhDslrKmrx1lj6C/vzZ3e2es3TcuTWw3821UC05/4Triz7R9NA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353029; 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=zhPBCKktofhJK+AVTdKcq02t6h9EdJuOnYLASrBedE0=; b=jkeWFmKi1KiPTzG7+IrlgG8af/rvqRNe3xdUI0tqCw/DCwB7/56UWqFUF8TF6y2kPwFhpMLYx2sjj/Td6g8LBTlDDG0K1YSo/lVQrt5HQKc028M52E1xPpWD0RjdLmEsSaQHY/aFdgVfADMSVECc65rg5lX1VpuqNDWPpuZbw8A= 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 1716353029150720.5525863555978; Tue, 21 May 2024 21:43:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dpB-0001zs-TK; Wed, 22 May 2024 00:43:37 -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 1s9dp9-0001p8-L8 for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:35 -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 1s9dp7-0005wQ-Go for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:35 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:17 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353013; x=1747889013; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r1ujOT9wnmzL4Jy0xbnj8LOr9Q4ivRZVm5w7T144XKg=; b=Bs+enfOPnGSJArIRggqiEGdLxeKLcmeMdvv49wWMd2v4/n+2dBjyKyn2 nVBEXM8o4bOdcQnbu4oIY91XMaCN8x6TxnKsBTF8TyrNq7AJpzB3YyUYE szx0MCe1dyouOq1FxS4yQaP8MO2tO2oLBMad92ZHedSAA38yvgjlR+/Je ZjRPnJMw+bUXKzWxMmQ8bYWgxIAVHBNDVL0LdVA1mywVgJKqx79K2KdWX gCdx417OYbE2tx4SIpH4zT3TPD0kmrHi3RIyzciy9P3u6NAU5pA1SC9ou paClis4h67tj/x+bnx2/kKfVGQBgI7UxQYzOJMwhMM1BdfkQxT6lG8fUl Q==; X-CSE-ConnectionGUID: nO8fOkpuRfy7b24YXrGWSA== X-CSE-MsgGUID: 5CWtU9nmSFqeaVFyT1I+4w== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994210" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994210" X-CSE-ConnectionGUID: 1Tf3vL9JQ4Kc2Y4/nZIUog== X-CSE-MsgGUID: 8IjPgqwIQ8mvZp6ikIf7IQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683795" 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 Subject: [PATCH v2 17/20] vfio: Use g_autofree in all call site of vfio_get_region_info() Date: Wed, 22 May 2024 12:40:12 +0800 Message-Id: <20240522044015.412951-18-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353030296100002 There are some exceptions when pointer to vfio_region_info is reused. In that case, the pointed memory is freed manually. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/helpers.c | 7 ++----- hw/vfio/igd.c | 5 ++--- hw/vfio/pci.c | 13 +++---------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 4b079dc383..27ea26aa48 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -343,7 +343,7 @@ static int vfio_setup_region_sparse_mmaps(VFIORegion *r= egion, int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *regio= n, int index, const char *name) { - struct vfio_region_info *info; + g_autofree struct vfio_region_info *info =3D NULL; int ret; =20 ret =3D vfio_get_region_info(vbasedev, index, &info); @@ -376,8 +376,6 @@ int vfio_region_setup(Object *obj, VFIODevice *vbasedev= , VFIORegion *region, } } =20 - g_free(info); - trace_vfio_region_setup(vbasedev->name, index, name, region->flags, region->fd_offset, region->size= ); return 0; @@ -594,14 +592,13 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, ui= nt32_t type, =20 bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe) { - struct vfio_region_info *info =3D NULL; + g_autofree struct vfio_region_info *info =3D NULL; bool ret =3D false; =20 if (!vfio_get_region_info(vbasedev, region, &info)) { if (vfio_get_region_info_cap(info, cap_type)) { ret =3D true; } - g_free(info); } =20 return ret; diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 402fc5ce1d..1e79202f2b 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -367,8 +367,8 @@ static const MemoryRegionOps vfio_igd_index_quirk =3D { =20 void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) { - struct vfio_region_info *rom =3D NULL, *opregion =3D NULL, - *host =3D NULL, *lpc =3D NULL; + g_autofree struct vfio_region_info *rom =3D NULL; + struct vfio_region_info *opregion =3D NULL, *host =3D NULL, *lpc =3D N= ULL; VFIOQuirk *quirk; VFIOIGDQuirk *igd; PCIDevice *lpc_bridge; @@ -609,7 +609,6 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, ggms_mb + gms_mb); =20 out: - g_free(rom); g_free(opregion); g_free(host); g_free(lpc); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 35ad9b582f..74a79bdf61 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -879,7 +879,7 @@ static void vfio_update_msi(VFIOPCIDevice *vdev) =20 static void vfio_pci_load_rom(VFIOPCIDevice *vdev) { - struct vfio_region_info *reg_info; + g_autofree struct vfio_region_info *reg_info =3D NULL; uint64_t size; off_t off =3D 0; ssize_t bytes; @@ -897,8 +897,6 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev) vdev->rom_size =3D size =3D reg_info->size; vdev->rom_offset =3D reg_info->offset; =20 - g_free(reg_info); - if (!vdev->rom_size) { vdev->rom_read_failed =3D true; error_report("vfio-pci: Cannot read device rom at " @@ -2668,7 +2666,7 @@ static VFIODeviceOps vfio_pci_ops =3D { bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; - struct vfio_region_info *reg_info; + g_autofree struct vfio_region_info *reg_info =3D NULL; int ret; =20 ret =3D vfio_get_region_info(vbasedev, VFIO_PCI_VGA_REGION_INDEX, ®= _info); @@ -2685,7 +2683,6 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **e= rrp) error_setg(errp, "unexpected VGA info, flags 0x%lx, size 0x%lx", (unsigned long)reg_info->flags, (unsigned long)reg_info->size); - g_free(reg_info); return false; } =20 @@ -2694,8 +2691,6 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **e= rrp) vdev->vga->fd_offset =3D reg_info->offset; vdev->vga->fd =3D vdev->vbasedev.fd; =20 - g_free(reg_info); - vdev->vga->region[QEMU_PCI_VGA_MEM].offset =3D QEMU_PCI_VGA_MEM_BASE; vdev->vga->region[QEMU_PCI_VGA_MEM].nr =3D QEMU_PCI_VGA_MEM; QLIST_INIT(&vdev->vga->region[QEMU_PCI_VGA_MEM].quirks); @@ -2736,7 +2731,7 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **e= rrp) static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; - struct vfio_region_info *reg_info; + g_autofree struct vfio_region_info *reg_info =3D NULL; struct vfio_irq_info irq_info =3D { .argsz =3D sizeof(irq_info) }; int i, ret =3D -1; =20 @@ -2790,8 +2785,6 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) } vdev->config_offset =3D reg_info->offset; =20 - g_free(reg_info); - if (vdev->features & VFIO_FEATURE_ENABLE_VGA) { if (!vfio_populate_vga(vdev, errp)) { error_append_hint(errp, "device does not support " --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353058; cv=none; d=zohomail.com; s=zohoarc; b=CMvjCq3UOJkiL4UwUpm/X8EUUqOMGClE8YhyHQVXhY/3kje7XIWqbwfu6BGK5riH0X6oP41sT0gcheVDoUeFos9PVuSzYG5yhYUAPJPCB9JTUA/WPVEynMSEq6+guhpXkrxCF1lO2eYrjYYZ6rEMxvLVgMxsHw7qGuKpOW7h9aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353058; h=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=AD4pJnoo7KNtM6/bc0EyIkGkeTvymB7lsNCvNxfrqWI=; b=EQa3iv5+eym+2gMl9HmXkMKNiCvOP4kb9v5jxVMzSXk3DYfcnQL2YT6KKB40G1lcT2W1rosOZe5h3qQl7hL9mujyCNoozBJ0oB4XooJwetkdh15yPaolMx7ch2pbxD4NTZ4YTM+egQ7RxzoJzbwt+M/PJGjJqneSJSCiHq/hnCA= 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 1716353057882356.05636723431076; Tue, 21 May 2024 21:44:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dpJ-0002Ug-Qu; Wed, 22 May 2024 00:43:46 -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 1s9dpH-0002OT-7a for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:43 -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 1s9dpF-0005wI-Gw for qemu-devel@nongnu.org; Wed, 22 May 2024 00:43:42 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:20 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353021; x=1747889021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0mVsJycZ0+yemdLDwZw/Xcikr0NANe2J64lu6LFt2V0=; b=fjIYF4AIRuQWsBJaCHP4M/KKGgKDx0lKEmLslCije84IdJYdyP2H9d/U adSZJcBquEZdr61nQ4fdIgaN+1QPUcbJ2x0gEffSRgYj7uIt8Aa7Yj/hu UewuTdQbgaSxlvl1zqhhI0z300g9mJPF767uwIWqpVsGSCPHAHt0gNAfV 1WyQYckC94hkJYAaGJ14y6vf4s7zJawVq6el70z/Zwga4Y07+YEx0kAG/ m8HC8rbY4a4HFRQx/AFLQnOftvGWlPUXhUQ2kd1Ka0vMMLMBCjmMJEL0i TwcnN8w67XTkHv7DfKf0km1NKfFxEy4GgdVsXEmh04EqocYF1e7Ua+GsL A==; X-CSE-ConnectionGUID: hyWJHSw0SPemiSYeJly3Sw== X-CSE-MsgGUID: GPPuHPhSQniYpj948HNlVQ== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994214" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994214" X-CSE-ConnectionGUID: JyiFn6yCQAmC2Otk6+JDKQ== X-CSE-MsgGUID: DUQHQf+fTsuOqtrTz5AEgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683803" 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 Subject: [PATCH v2 18/20] vfio/igd: Use g_autofree in vfio_probe_igd_bar4_quirk() Date: Wed, 22 May 2024 12:40:13 +0800 Message-Id: <20240522044015.412951-19-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353060143100005 Content-Type: text/plain; charset="utf-8" Pointer opregion, host and lpc are allocated and freed in vfio_probe_igd_bar4_quirk(). Use g_autofree to automatically free them. Signed-off-by: Zhenzhong Duan --- hw/vfio/igd.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 1e79202f2b..d320d032a7 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -368,7 +368,9 @@ static const MemoryRegionOps vfio_igd_index_quirk =3D { void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) { g_autofree struct vfio_region_info *rom =3D NULL; - struct vfio_region_info *opregion =3D NULL, *host =3D NULL, *lpc =3D N= ULL; + g_autofree struct vfio_region_info *opregion =3D NULL; + g_autofree struct vfio_region_info *host =3D NULL; + g_autofree struct vfio_region_info *lpc =3D NULL; VFIOQuirk *quirk; VFIOIGDQuirk *igd; PCIDevice *lpc_bridge; @@ -426,7 +428,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) if ((ret || !rom->size) && !vdev->pdev.romfile) { error_report("IGD device %s has no ROM, legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 /* @@ -437,7 +439,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) error_report("IGD device %s hotplugged, ROM disabled, " "legacy mode disabled", vdev->vbasedev.name); vdev->rom_read_failed =3D true; - goto out; + return; } =20 /* @@ -450,7 +452,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) if (ret) { error_report("IGD device %s does not support OpRegion access," "legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 ret =3D vfio_get_dev_region_info(&vdev->vbasedev, @@ -459,7 +461,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) if (ret) { error_report("IGD device %s does not support host bridge access," "legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 ret =3D vfio_get_dev_region_info(&vdev->vbasedev, @@ -468,7 +470,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) if (ret) { error_report("IGD device %s does not support LPC bridge access," "legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 gmch =3D vfio_pci_read_config(&vdev->pdev, IGD_GMCH, 4); @@ -482,7 +484,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); error_report("IGD device %s failed to enable VGA access, " "legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 /* Create our LPC/ISA bridge */ @@ -490,7 +492,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) if (ret) { error_report("IGD device %s failed to create LPC bridge, " "legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 /* Stuff some host values into the VM PCI host bridge */ @@ -498,14 +500,14 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, i= nt nr) if (ret) { error_report("IGD device %s failed to modify host bridge, " "legacy mode disabled", vdev->vbasedev.name); - goto out; + return; } =20 /* Setup OpRegion access */ if (!vfio_pci_igd_opregion_init(vdev, opregion, &err)) { error_append_hint(&err, "IGD legacy mode disabled\n"); error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); - goto out; + return; } =20 /* Setup our quirk to munge GTT addresses to the VM allocated buffer */ @@ -607,9 +609,4 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) } =20 trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, ggms_mb + gms_mb); - -out: - g_free(opregion); - g_free(host); - g_free(lpc); } --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353284; cv=none; d=zohomail.com; s=zohoarc; b=j/KHmgirTEjpUTQwl8yIq/MrsAtbwdS/aO2fPC2L6h6Hc//AgwsLtG0mF9+uG5FN+BoJ7DzIKUrNA1wPyiZTQ4DOW7gj+8EHvqfDrTqgWhWoSfyiBDIt+vOkv528SjaKbE7j/LiB4j6xODkb97IDhbCkdlCFJpKvcOu6I0rNNJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353284; 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=AJw7B+lAbiMsLFMzsCzsH9Hb7hEjzOT2KhFANnrnTzA=; b=gVKrJVTNw8a2Rn6NUkckYVkC/Dzig8uhi0rzI1ubgkjKYhR6OGgl56ujsXPWaT0HWle+WO/47Q5DdC7mX8YOfgoqgUem0mABImVV+/4EiwnunhFvXwJadZDz3s8mbArv3rpAGsdqhKVhVzdVF8h5PS1iSl8aA2UvUK1zs9Nifoc= 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 1716353284551961.8816717943309; Tue, 21 May 2024 21:48:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dpb-0003DH-47; Wed, 22 May 2024 00:44:03 -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 1s9dpU-0002z9-FR; Wed, 22 May 2024 00:43:56 -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 1s9dpS-0005wM-Q4; Wed, 22 May 2024 00:43:56 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:23 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:20 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353034; x=1747889034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xmbGRIz1xb4wMoX4jBHY9Ji8BqoSSIVbjok4WXnrOz4=; b=MyToYGtWa8/o0S0rMvKje+vly4Y2VZUPGQ5TBp68S1ZNEfJZCEFLASLJ KM7pXPPMxONR8+zJh2F1p0vnp6BfFHz5rnvnCg1W/rkk45GFU/Vtlg/52 /x25kFX0uE8uFMOxDzNxO3Nne8exfK+UKjGjDdSxjsxBiU2Pd5nkCmy6C /umb8QjD8QBODxRNbXVdsk1zQqwuG+hF80E+VBBVRjg7rg4uP9Nr/g46Z /3iGsDJD9KiigkJeba8Kd0PKNwg7LekRtFqPV3ZB6ubqgt1jtBXWukL5b E1FXERzJ5v59AHNyvp2oCKteQpE7HLMh0Spv0zYZamz9wC6B+THSFNFq6 Q==; X-CSE-ConnectionGUID: cMH0IS8WSx6DWuBlv47T5w== X-CSE-MsgGUID: NcP09iLKTtuYd76ifCqHMg== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994218" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994218" X-CSE-ConnectionGUID: B4s/Lw4VRnivmw6/JJC7WA== X-CSE-MsgGUID: 33i6URHjRBu+rVmJ3Qwk6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683809" 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 , Eric Farman , Matthew Rosato , Thomas Huth , qemu-s390x@nongnu.org (open list:vfio-ccw) Subject: [PATCH v2 19/20] vfio/ccw: Drop local @err in vfio_ccw_realize() Date: Wed, 22 May 2024 12:40:14 +0800 Message-Id: <20240522044015.412951-20-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353285359100005 Use @errp to fetch error information directly and drop the local variable @err. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan --- hw/vfio/ccw.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 2600e62e37..168c9e5973 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -574,17 +574,17 @@ static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) =20 static void vfio_ccw_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); S390CCWDevice *cdev =3D S390_CCW_DEVICE(dev); VFIOCCWDevice *vcdev =3D VFIO_CCW(cdev); S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(cdev); VFIODevice *vbasedev =3D &vcdev->vdev; - Error *err =3D NULL; =20 /* Call the class init function for subchannel. */ if (cdc->realize) { - cdc->realize(cdev, vcdev->vdev.sysfsdev, &err); - if (err) { - goto out_err_propagate; + cdc->realize(cdev, vcdev->vdev.sysfsdev, errp); + if (*errp) { + return; } } =20 @@ -597,27 +597,28 @@ static void vfio_ccw_realize(DeviceState *dev, Error = **errp) goto out_attach_dev_err; } =20 - if (!vfio_ccw_get_region(vcdev, &err)) { + if (!vfio_ccw_get_region(vcdev, errp)) { goto out_region_err; } =20 - if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err= )) { + if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, errp= )) { goto out_io_notifier_err; } =20 if (vcdev->crw_region) { if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, - &err)) { + errp)) { goto out_irq_notifier_err; } } =20 - if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &er= r)) { + if (!vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, err= p)) { /* * Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ - error_report_err(err); + error_report_err(*errp); + *errp =3D NULL; } =20 return; @@ -635,8 +636,6 @@ out_attach_dev_err: if (cdc->unrealize) { cdc->unrealize(cdev); } -out_err_propagate: - error_propagate(errp, err); } =20 static void vfio_ccw_unrealize(DeviceState *dev) --=20 2.34.1 From nobody Mon Nov 25 07:50:20 2024 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=1716353288; cv=none; d=zohomail.com; s=zohoarc; b=nitWe+r3nQ+lLgv8F0THiJaSZKyLh0WkZU1B8EXzMizDkCI+xlx1TDyCy5Cnj1R3AR41HaCg4Bq6Xe76Ir2+bQOhE9z5KeibqkHzmbcikxvwEi7oM0Y/1fmcjp1Op1nptW5/iWI+46i6agCdqF1d41spHHOnjesvYg6XJkwA/xU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716353288; h=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=1eIespveF67+ye/k6W3GcS84w89o5YRNQ1bVOyzKdes=; b=RZpyj3y1O0ENj8y0sQAg1pq3vh9kTdGT/y4p5ugPVGmJWpPEEZHaO1FC3LY8fJ5wsNJzKliM3dgDt5hmO1LZZ6kZNlRrDT5S0n9D0TXdBPDsAoA2BFWAYBX86MbMlaOiVkDUWWkRHWdFNX9sBOthBwHuOCh4034e1QDV8NtqkKQ= 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 1716353288971632.3726717687607; Tue, 21 May 2024 21:48:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9dph-0003J8-3V; Wed, 22 May 2024 00:44:09 -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 1s9dpX-00038E-01; Wed, 22 May 2024 00:44:00 -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 1s9dpV-0005wQ-Bx; Wed, 22 May 2024 00:43:58 -0400 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:26 -0700 Received: from unknown (HELO SPR-S2600BT.bj.intel.com) ([10.240.192.124]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 21:43:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716353037; x=1747889037; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NOv++k7YIHXe3mdhvNwiZ7ufitLLfKDDIQWej2awCVw=; b=fVw7hCUnBu2G+HfsDep4vjgpg8bpIElHMXKO+WYcxRyQIbsuLAxBhMA4 1QMwr0g7brivtQe5P6Eh7sNN5OdPfO4C2WWM3ltUKYPZ5IV11RVpQPkkp DdITMfXFUc1N89FcXYQ3x5mXVceaBVOJ06c+ru6bUh0lD5NBGGIrO87Jv 8GHMOy5JtSAwG/QFFOKf2ykzWor46FldPLNUg4S1wUbkFSIYsOV7x0lsG rwgoe2Gb9HJ5MIUCuLo4Xfn6k9UdJU3KHIwGW5xk9nJx6DKuP2tXCHjEw z+a8gdAUE6xTKKs4Jjr5iYfnQTtbQ4NveDryAz/xZeUPAlvxCjfcPsjoJ g==; X-CSE-ConnectionGUID: 76dDk/nkQSWX9waplNIO4g== X-CSE-MsgGUID: uNWP6dFtQ3SWYjkQRXw6oQ== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="23994222" X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="23994222" X-CSE-ConnectionGUID: 8qQ1aQAwRGODSSZ+ui4pQg== X-CSE-MsgGUID: 9ZBqyuXsR06wHAM0pFaxSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,179,1712646000"; d="scan'208";a="33683818" 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 , Eric Farman , Matthew Rosato , Thomas Huth , qemu-s390x@nongnu.org (open list:vfio-ccw) Subject: [PATCH v2 20/20] vfio/ccw: Fix the missed unrealize() call in error path Date: Wed, 22 May 2024 12:40:15 +0800 Message-Id: <20240522044015.412951-21-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522044015.412951-1-zhenzhong.duan@intel.com> References: <20240522044015.412951-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: 1716353289180100001 Content-Type: text/plain; charset="utf-8" When get name failed, we should call unrealize() so that vfio_ccw_realize() is self contained. Fixes: 909a6254eda ("vfio/ccw: Make vfio cdev pre-openable by passing a fil= e handle") Signed-off-by: Zhenzhong Duan --- hw/vfio/ccw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 168c9e5973..161704cd7b 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -589,7 +589,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) } =20 if (!vfio_device_get_name(vbasedev, errp)) { - return; + goto out_unrealize; } =20 if (!vfio_attach_device(cdev->mdevid, vbasedev, @@ -633,6 +633,7 @@ out_region_err: vfio_detach_device(vbasedev); out_attach_dev_err: g_free(vbasedev->name); +out_unrealize: if (cdc->unrealize) { cdc->unrealize(cdev); } --=20 2.34.1