From nobody Fri Dec 19 17:34:27 2025 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=1601573145; cv=none; d=zohomail.com; s=zohoarc; b=TVnUfYH889xlNvLwK/t3EbVl0JZyc/qcz9o9/7RwSYU5WBL6LsgXH4rf9Sh61U1i3++sCjcb6v4hSRrehvRsRpFmj57R1XPcB5NYhfX8lqX00VcNNhYuxgkc1QLfUS2x5NO5NXZf5QZPtuQVXzw9Tw17lDebvLm11hbBdbgkNHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601573145; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=syzgIAtLlC36RSXNl4EdRCuwS9HfcthXywFIirAhFNM=; b=Xj3Zhg01mXs+/xPkLlgaIoB8D2+rFXWn+8pP/n6JuuNas/6WmNI3BGl/wwc+WHkLtWUFJ/dKgKjm3DWVZGCMS0+8M0LZC4sjJQCDh9oodghmlgn54cEcUOKP+WkeL0g6FpDpQOosPFa7VGeihkJgq4g4pzN7K0iiwz1sWx+zhe8= 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) header.from= 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 1601573145640446.60818901620723; Thu, 1 Oct 2020 10:25:45 -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-65-krzPsY8pORyTr2bsB82-iw-1; Thu, 01 Oct 2020 13:25:42 -0400 Received: by mail-wr1-f70.google.com with SMTP id v12so2323678wrm.9 for ; Thu, 01 Oct 2020 10:25:42 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (74.red-83-53-161.dynamicip.rima-tde.net. [83.53.161.74]) by smtp.gmail.com with ESMTPSA id b64sm945627wmh.13.2020.10.01.10.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 10:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601573144; 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=syzgIAtLlC36RSXNl4EdRCuwS9HfcthXywFIirAhFNM=; b=EWPDPvczxu9GEXyhLjQFc6R/IpAJQ7wQh5XgHHf7msTdbsnqNOwBlc/ymig1HXP1nz7A2B KGBQXW+6Z5RMKnxf7FiZUWq0gdKLH3Z2kUWgsIO8f+C5vhGy4IYI2HxGMThXNLVeuDhb3X WhFNIQmVVlSUYBRPWqEeUiok2ggYEo0= X-MC-Unique: krzPsY8pORyTr2bsB82-iw-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=syzgIAtLlC36RSXNl4EdRCuwS9HfcthXywFIirAhFNM=; b=Lty7FtUEC4H6yPq261bGI4Mew/u9OaYNbkrNaSv0EbCyizMY2j3DYk4Vxfoitw/glq vzNjuLrguCFVEPe8NHakoiqB6HQhcMPtrS6P8yxfbhRpTqHTILVo7fgK+nlE+kJY07hW RNCcJWegfy2QeiKlQcm1RtptWcAZUBmr06JejUD+uj1KaGR/NfWXx5v15WwOKw3j1KUO stKnuzJzx5J/ikYoQSPC4CMgauHtUgrc7HktGJh7glxO6DVob7NupHVw0qVQpISCoBh8 5vImu/o3DsaK77053YkQwcjYq3p4VrPJO8gpxrGC0HI4zRgfle4l+2Qei1ojkhaz0mYW bANA== X-Gm-Message-State: AOAM532vUj5j5AZVsw0aZjA24MWz/rsSl1dFZzX9rO2yuIFB11Hl2BZK BVPAG2i+lGrLiIYFHFAZWc8Pq8da48VId8zvfjN33CrIsGAEaX4jcXrgmww9bY+LTMNsDz/jxAx kfsqYwo60rUCdmQ== X-Received: by 2002:adf:f0c7:: with SMTP id x7mr9970697wro.315.1601573141269; Thu, 01 Oct 2020 10:25:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyORzUqm86VflKRIN/MDCkXBpeF2kgb9g6JuA9aFdZahBI9GJjEq3Qii1zONXyEFBJEarPzLQ== X-Received: by 2002:adf:f0c7:: with SMTP id x7mr9970683wro.315.1601573141086; Thu, 01 Oct 2020 10:25:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH RESEND v2 04/16] dma: Let dma_memory_set() propagate MemTxResult Date: Thu, 1 Oct 2020 19:25:07 +0200 Message-Id: <20201001172519.1620782-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001172519.1620782-1-philmd@redhat.com> References: <20201001172519.1620782-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) address_space_write() returns a MemTxResult type. Do not discard it, return it to the caller. Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 c6e12b4c24..37cd9f1121 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 host virtual add= ress. diff --git a/dma-helpers.c b/dma-helpers.c index 41ef24a63b..4a9e37d6d0 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