From nobody Mon Feb 9 11:30:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007435; cv=none; d=zohomail.com; s=zohoarc; b=HYuMqqlc32kCFSTJfrDRsvm7ST8jxn8UlMIppbq0K9FdOsdcRPev+X1/2L4ExOBucz1I2F2VbHZSeKG2T4DqX2X6DePtDqoP60kGu1842ZHiENLkmyPFDeTp0udgFxMRyGK7QuOCaOshIX/nopFuDW0YPXDvlgeOoaDxIPHXwcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007435; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=BLUXN20BzQb65Tw0XnXxFwIHnX33CB3JX+3UEsxfFO14gVQ/8vbaJCEDTur9i0d1fHkquOMTpPmmaI2cjitKMUP5upWnBN5HCTKfuH6kGhr3Q5wXUJARsuOpkFJ89hv1nBHCH1J3ABMetaxnioNKKWihR0jcc0mZiCx+XRRKnVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16300074352964.888137769732907; Thu, 26 Aug 2021 12:50:35 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-334-GS6mS5L5O_a1F9fS6xXHaw-1; Thu, 26 Aug 2021 15:50:30 -0400 Received: by mail-wr1-f70.google.com with SMTP id b7-20020a5d4d87000000b001575d1053d2so1187771wru.23 for ; Thu, 26 Aug 2021 12:50:30 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id q11sm9152016wmc.41.2021.08.26.12.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=JeTZiWZfHl1rROcUHR3xwAzHbe/kB6t0gHaqBOFdu8GB0DbZo+m1yHKv/xu7/Ti9abLkLF j4ONI3oQdIWQdH42lqwPFEUFeO9mYJfsQrQ+zjEiad7RloOwkStGBWaCeaDUQ6CEVcuJn/ fwQAwSf0X/x7Mq/nrX7Od7prVimdMWo= X-MC-Unique: GS6mS5L5O_a1F9fS6xXHaw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=TqQ2ttyFCqU/UzMkq4He9Fo+hR48veUd+M41ZGuFd9ORD8VEy6ykQhMLiAZe7ggWh8 +h85Kzopp2KhOQ6bCPQ+yyBytrZrqsLutoICklTHAbYDjkcHctlCSd02wp6VQ3OMs8LK 6k2ggIyiHVstaTtkMTEzQZbLqp/+BCj6S0w2GVWWdGaZWrsSkv/Gi9XJV0hFR98kCCOI 7PrB0+sXjWaX14O7hVtAkZJTP63GeLROwhDEhCrowyJj3tAosKdt7VZnhMYbgQsDL789 3uoMF8emM17JkJpDCziZpWEVj00ZbxbV8SF7O7bQ4xuXTSeBQCIwqk9E0mUAl4O0iKNa +3oA== X-Gm-Message-State: AOAM5306O+rbM6vc0/i9jrjwSugd/tCb6WJ970QSofFzijWuQIbAag5k Lf3PvLC8y1L1MtkGGZ/NP22R8TvX32b5GaSsaoUDevZ0bDP7bN09WkVZtWx1uD1/Lc3+l7UEnCr bl2h0KPws9NgVJQ== X-Received: by 2002:a1c:29c3:: with SMTP id p186mr5259850wmp.22.1630007429678; Thu, 26 Aug 2021 12:50:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhY56nY8acJv336t+w5OxTG8jgsWTSeozY/XtH4noR1liRtVoYV69/WBsw2kOvcNGHblDT6Q== X-Received: by 2002:a1c:29c3:: with SMTP id p186mr5259838wmp.22.1630007429532; Thu, 26 Aug 2021 12:50:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric Subject: [PATCH v2 03/11] util/vfio-helpers: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD Date: Thu, 26 Aug 2021 21:50:06 +0200 Message-Id: <20210826195014.2180369-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826195014.2180369-1-philmd@redhat.com> References: <20210826195014.2180369-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007436443100001 Simplify qemu_vfio_dma_[un]map() handlers by replacing a pair of qemu_mutex_lock/qemu_mutex_unlock calls by the WITH_QEMU_LOCK_GUARD macro. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- util/vfio-helpers.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 1d149136299..d956866b4e9 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -735,7 +735,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, assert(QEMU_PTR_IS_ALIGNED(host, qemu_real_host_page_size)); assert(QEMU_IS_ALIGNED(size, qemu_real_host_page_size)); trace_qemu_vfio_dma_map(s, host, size, temporary, iova); - qemu_mutex_lock(&s->lock); + QEMU_LOCK_GUARD(&s->lock); mapping =3D qemu_vfio_find_mapping(s, host, &index); if (mapping) { iova0 =3D mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->h= ost); @@ -778,7 +778,6 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, *iova =3D iova0; } out: - qemu_mutex_unlock(&s->lock); return ret; } =20 @@ -813,14 +812,12 @@ void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host) } =20 trace_qemu_vfio_dma_unmap(s, host); - qemu_mutex_lock(&s->lock); + QEMU_LOCK_GUARD(&s->lock); m =3D qemu_vfio_find_mapping(s, host, &index); if (!m) { - goto out; + return; } qemu_vfio_undo_mapping(s, m, NULL); -out: - qemu_mutex_unlock(&s->lock); } =20 static void qemu_vfio_reset(QEMUVFIOState *s) --=20 2.31.1