From nobody Fri Dec 19 19:55:43 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=1601573151; cv=none; d=zohomail.com; s=zohoarc; b=LjH8nCm03v0ij2BheFZEHX6dKnnmdlNEofrwJf9pALs1UtlrmW26lBe0B80jAdUEm2BKQyJHlh1Zg//Bp2aq+KegNlfJtwom7D1JjdQLxDFyyvUQbhqJv/wuNrvu1FzQHa42wRQIykWWNQcbC07H3vKHEkW0y3QjkUKmJ5u1xC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601573151; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=7v9DMG4y2YQic36rWlYyposJbVK+Y5f+qipPBVV3YB0=; b=DbVf1BFYapYrOGYdBWZ1CCUGgQYYeQOOaxDhZuimtTGWNuZqszhtIqOdQljtbsrL6AjTyE6USdd7sZNDQZwSkypV7en+BUPEqKfCuUj0UVIDOMfEAlI72tzDhJoiN1dSV2LUNn1rCh11WBL//VSkQB+PNw95GntHQJejXSi9BR4= 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 160157315152355.984915488434126; Thu, 1 Oct 2020 10:25:51 -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-205-iuhmd6hZMLK_R9iQYF7IYQ-1; Thu, 01 Oct 2020 13:25:47 -0400 Received: by mail-wr1-f70.google.com with SMTP id b7so2334132wrn.6 for ; Thu, 01 Oct 2020 10:25:47 -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 t202sm964651wmt.14.2020.10.01.10.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 10:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601573150; 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=7v9DMG4y2YQic36rWlYyposJbVK+Y5f+qipPBVV3YB0=; b=Wod3zl8nkToKe8+GHvJbLK5Rg/Wk7TuLsOs/RnmwZCRLOh2ge4d7OIOCrquKI9a8Y3Lv5z w2NhkVOQ9fsmXIfUMDUFU+TN1YIBz+PNMRHxOfjdBw7fJpF85QuxZZO8oG/szE7AzuIYHc yOxcNOvI2qI9Jb33GTfrJ+i6JE+Jdqo= X-MC-Unique: iuhmd6hZMLK_R9iQYF7IYQ-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=7v9DMG4y2YQic36rWlYyposJbVK+Y5f+qipPBVV3YB0=; b=mrhh3gVKmzQtzRgjDcti12mzzCISA7AY6Jyc8It4NAMMHHx393sNQnLayMEJlPOBBX Len9obTMH4XxU6l1AMb+7FOVKuFA7ZjQvSKJA8b+3mQ0KXFjCA3pRsZgDevJwumM7CB9 4YCnFWwFlXpdYW7M4xNLemwCO5MmfQ8vM27TR7CsMYm4WSCGi9vmuu4IkRwSWqzTFGjQ 0nvPFXAt+WJs/zgVVEDMiiNqjWyUv/h1YO9O5gYWk7dfRBeQ+aqQxDHoVumVuDE+BZEa elqbSSHuYOnZJGhPRobslE+EzbW7gQcWLoltVklv6EGUV4jM0HvqgzzfX7pK/kE5jkuO 1ibA== X-Gm-Message-State: AOAM532wp6IPvoininDIG4PQPy3qbbcPSiM5/D8AAC+w2UuKxuPij5ZU Pi2wlMtziWGdjT7llOSYpWRCs8LZX+ADAMkccyP3y5JYPoXPC5PJQ1Et6gSEQLHCBYr6Mle3scp kluJYKzGwb30New== X-Received: by 2002:a1c:408a:: with SMTP id n132mr1013262wma.45.1601573146318; Thu, 01 Oct 2020 10:25:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4MC9kQdd9yQsBPBSvY6hQkXKAQjPlgUSNTJfxBi1lN3ymzU7o++7Mxayaa49BcnFN50Q/tA== X-Received: by 2002:a1c:408a:: with SMTP id n132mr1013255wma.45.1601573146153; Thu, 01 Oct 2020 10:25:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH RESEND v2 05/16] dma: Let dma_memory_rw() propagate MemTxResult Date: Thu, 1 Oct 2020 19:25:08 +0200 Message-Id: <20201001172519.1620782-6-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_rw() 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 | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 37cd9f1121..04687d8825 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -80,12 +80,13 @@ static inline bool dma_memory_valid(AddressSpace *as, MEMTXATTRS_UNSPECIFIED); } =20 -static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len, - DMADirection dir) +static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as, + dma_addr_t addr, + void *buf, dma_addr_t len, + DMADirection dir) { - return (bool)address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, - buf, len, dir =3D=3D DMA_DIRECTION_FROM_= DEVICE); + return address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, + buf, len, dir =3D=3D DMA_DIRECTION_FROM_DEVICE= ); } =20 static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t add= r, @@ -101,9 +102,22 @@ static inline int dma_memory_write_relaxed(AddressSpac= e *as, dma_addr_t addr, DMA_DIRECTION_FROM_DEVICE); } =20 -static inline int dma_memory_rw(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len, - DMADirection dir) +/** + * dma_memory_rw: Read from or write to an address space from DMA controll= er. + * + * 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 + * @buf: buffer with the data transferred + * @len: the number of bytes to read or write + * @dir: indicates the transfer direction + */ +static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, + void *buf, dma_addr_t len, + DMADirection dir) { dma_barrier(as, dir); =20 --=20 2.26.2