From nobody Mon Feb 9 17:36:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1599234309; cv=none; d=zohomail.com; s=zohoarc; b=Jjyt7hO4yTwpIfIt284nAxjpTMNBxiVkdmwOjQ8Uy+OCTVPOVFQ2nZNj7Six9oBM1VqwLW1K0PhUEdPlhN2j5zfOzwlo7ep/NvZJS5A3ugXYrI7AIk9rUDV/jUfpxbJfkGcV5EIMvhqEavk0f0vW7GSQln0MijYFGcuM/DVdVIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599234309; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=oVJoRP2NryT9xCjnhEGS3UrNwkpOFjKsKUG8gUNW5dU=; b=huEdkaIfgckv3TSLDGRuob6Rp6v46Bjjc22RPEO96Ef4Ny5bVvPhQjxOuNoGa7/hR3TayKm3t3AlcJR6qdQ35/AzzirsVXBlaF/n2fbDO03a4Pa1SHqviudOvX4RV7Ug7Vv6CjIv7XQcy3M0q7mcFrM+FUDhwPsAKLr7u2BQI78= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1599234309226272.0109151455058; Fri, 4 Sep 2020 08:45:09 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-221-tCJByYP3Nf-8LHAXqjm7lg-1; Fri, 04 Sep 2020 11:45:06 -0400 Received: by mail-wr1-f71.google.com with SMTP id 33so2444868wrk.12 for ; Fri, 04 Sep 2020 08:45:06 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id h186sm12219587wmf.24.2020.09.04.08.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 08:45:04 -0700 (PDT) X-MC-Unique: tCJByYP3Nf-8LHAXqjm7lg-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=oVJoRP2NryT9xCjnhEGS3UrNwkpOFjKsKUG8gUNW5dU=; b=ChBb9MQ+xGityWgchJu2h6qcECoolTwtV2FmAX0SBp5nNPFfatOpXGFyiuEsB2woEj 2Ervd0p6huTTEjDFEdGniDSRpOJieDro0cnO3EJ7jyfLGvPPkHLP1EUllY+Ei1umOOZC /Fira239kB4lyvuOMXVnicN03JISaVA8pvrmPUWJ9MUj/HpkPGS6wJQxfitZ4/CM75TE UnwcbWwAyD1F86N3vtzOjMogeUeLdyPBhTpWdm1adBltt/d/uE85NwmVXbMnLalXEWid mhxpDb2lUtoiVG12P1W9EsnLofxR8421to8kd75TVbFMXH1Hbba9pvROvRCBE7Hr+ngg Islw== X-Gm-Message-State: AOAM533gzN7ZCx2BV7X8qODfRgldIHKo6W474YscNISZv6Kvi9cKKwC+ T8cxep3hY8T5Bs9RmpYCsP4bpCtSW54nHo3TPdeHwLIA6pJrVBNJf9Vg94w32zeaBrpTSy8nCaZ l4KixI0ywc9p1tQ== X-Received: by 2002:a5d:680b:: with SMTP id w11mr8800617wru.73.1599234305475; Fri, 04 Sep 2020 08:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyufkRwrrAmfJTcRurpOYpfOULXd8fYcWxWkpXQQWEklre41SAuhWofKbB563eMWvXpi4NCjA== X-Received: by 2002:a5d:680b:: with SMTP id w11mr8800576wru.73.1599234305213; Fri, 04 Sep 2020 08:45:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Paolo Bonzini Cc: Laszlo Ersek , Marcel Apfelbaum , "Edgar E. Iglesias" , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Mark Cave-Ayland , Jason Wang , Peter Xu , "Michael S. Tsirkin" , Jan Kiszka , Eric Auger , David Gibson , Beniamino Galvani , Andrew Jeffery , Richard Henderson , Joel Stanley , Eduardo Habkost , Alistair Francis , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Snow , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , Andrew Baumann , Peter Chubb , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 04/13] dma: Let dma_memory_set() propagate MemTxResult Date: Fri, 4 Sep 2020 17:44:30 +0200 Message-Id: <20200904154439.643272-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904154439.643272-1-philmd@redhat.com> References: <20200904154439.643272-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable address_space_write() returns a MemTxResult type. Do not discard it, return it to the caller. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang Reviewed-by: Richard Henderson --- include/sysemu/dma.h | 15 ++++++++++++++- dma-helpers.c | 7 ++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 19bc9ad1b69..ad8a3f82f47 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -123,7 +123,20 @@ static inline int dma_memory_write(AddressSpace *as, d= ma_addr_t addr, DMA_DIRECTION_FROM_DEVICE); } =20 -int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_= t len); +/** + * dma_memory_set: Fill memory with a constant byte from DMA controller. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @c: constant byte to fill the memory + * @len: the number of bytes to fill with the constant byte + */ +MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, + uint8_t c, dma_addr_t len); =20 /** * address_space_map: Map a physical memory region into a DMA controller diff --git a/dma-helpers.c b/dma-helpers.c index 41ef24a63b6..4a9e37d6d06 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -1,7 +1,7 @@ /* * DMA helper functions * - * Copyright (c) 2009 Red Hat + * Copyright (c) 2009,2020 Red Hat * * This work is licensed under the terms of the GNU General Public License * (GNU GPL), version 2 or later. @@ -18,14 +18,15 @@ =20 /* #define DEBUG_IOMMU */ =20 -int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_= t len) +MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, + uint8_t c, dma_addr_t len) { dma_barrier(as, DMA_DIRECTION_FROM_DEVICE); =20 #define FILLBUF_SIZE 512 uint8_t fillbuf[FILLBUF_SIZE]; int l; - bool error =3D false; + MemTxResult error =3D MEMTX_OK; =20 memset(fillbuf, c, FILLBUF_SIZE); while (len > 0) { --=20 2.26.2