From nobody Mon Feb 9 11:33:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1630566044; cv=none; d=zohomail.com; s=zohoarc; b=ZlQESgDdwA1/G+XA0tnFz9qY3UgDvKG4937FPttMvKVSaP4RZX0GLjRp2/jyn8gRaBWjoweZs6uHqWtG22zvttTGiU7RHj5RZ3n1cOZhTEbfBeQnOcfLd2rYDpGv7d42G4pVynDkyJkRuWwrJY04dz3qYf6ULKzWNOySRE/h8kM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566044; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=PRk9hq4YYCHwYOeq1/gk6vXaUjKRR/znzmXZWr7watUoGDjf9ZrAsiBuOEJgQXP2xs8fez3gZTSP7Lc8+p3zMk/zXXPff0LWZmztjx7poOc385PffE9d8UKCbvY7X7lDFDCAJZ6v/8MCLBj2cYabqMFe4hYrUaOWSOx94G6GZCA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630566044522989.1485798773921; Thu, 2 Sep 2021 00:00:44 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-UKuU1N3-M-mr0erjUDo0Wg-1; Thu, 02 Sep 2021 03:00:42 -0400 Received: by mail-wr1-f69.google.com with SMTP id v18-20020adfe2920000b029013bbfb19640so208541wri.17 for ; Thu, 02 Sep 2021 00:00:42 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id r10sm932883wrc.85.2021.09.02.00.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566043; 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=SZHsT8bjzscam71LE8G4RXCK+ybUkvjHxFNnXSIdPcmB7r2VinrSYoF21X5gU+t+rji1Jp qfTgvtZTXEVpbG0Aw3cAnH2R8ym/ClW+oW8VIqFSo97up2s2wbrA6YjZZiCnyoM+rNB7q1 FJqoR69pVMOcNxVsIz5ShWmPdXhOx9g= X-MC-Unique: UKuU1N3-M-mr0erjUDo0Wg-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=NrstceqjqsaunMCvVtk1Ue7koKzy3G9Zbuugqzdw8iKWJbWi06HSKgoB+8oDUvsMRc WgCCmu6QyISnt6jsJoCEbO55mD9P+WwgmIbJLxvdERiDpfaqDJO2IKWkZubSbSSDDTcS 3bIro3H9uOUpXK/413dXeNSP3AlnyNLiNOF1ujlO3aBZPH7x067RltUNSboi9iSzPSSe mpoUc40+Q9AVuofGhznYaQ0Uyp4Jh31vDCbvcCH5uE925NPAe6KSvU/uROTjAIBSp5VU tEC5aha21AnkeafSN9IPvB0/3zfCm406vJXdwG51hB7oYWqm5UjtvvDp13Ujb4ELmYR7 rO8Q== X-Gm-Message-State: AOAM5328rwjDcmro+GG8n8SunwagEVMPLaGZFka+1+m+day4Gr1m09tD gLDKlvykBdZ5NLSec30Rm37K3EAzIVhk8lECvZ06xw8bFc28/TMxF8XnESrX0gbMJ3QVdi909gf kfcz0ic4ygi/I5w== X-Received: by 2002:a1c:20d7:: with SMTP id g206mr1612453wmg.153.1630566041126; Thu, 02 Sep 2021 00:00:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrJvsaNZnkBJWlG0OQYz1GUol6cYXAcSs8Fw2UXZXajEbYv+fWiTNPrnI6L8LhiEwKU5B70w== X-Received: by 2002:a1c:20d7:: with SMTP id g206mr1612426wmg.153.1630566040915; Thu, 02 Sep 2021 00:00:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 03/11] util/vfio-helpers: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD Date: Thu, 2 Sep 2021 09:00:17 +0200 Message-Id: <20210902070025.197072-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566046600100001 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