From nobody Fri Dec 19 18:53:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1601573162; cv=none; d=zohomail.com; s=zohoarc; b=BkbYi4zDyIx0HpK3xYofpz5DIcIF/MfLe4Ykwd8yP/DMFoy7PONYTurFJ5KpEwnELk+JganpWO/IWEXGJ4bGX5T9GiMnSpLe6yvIj9BLguJ19YHoe/yqSP+/MgdFyCFRD6Atmz3Skca8sk0D/9Kb+Qf6b/qaQKI57c0T5WTzYys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601573162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=14wd1LoJqDrIDTmO66J1bZUDTtxJuvJH1RTglxmFjpE=; b=mqYFl8HkyoJfytrADTmogusrFbJwwnyI6Wjz3L49NEb8uIgd7Sow7/meDsYOm2lmzcNwMiiMl1kbeIzkYexBUzJ5PlLU+2ybgKA9QXb2XGnljU7NvvK+nLjMd9CB5c67mhB52nw74oOVRByd4YIhrWg5Xxdo3xLGtM0pVi7KWqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601573162793666.0599711950812; Thu, 1 Oct 2020 10:26:02 -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-476-cXpsWc_OPauFa-7t4HOFdQ-1; Thu, 01 Oct 2020 13:25:57 -0400 Received: by mail-wr1-f70.google.com with SMTP id f18so2320640wrv.19 for ; Thu, 01 Oct 2020 10:25:57 -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 n2sm977308wma.29.2020.10.01.10.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 10:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601573161; 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=14wd1LoJqDrIDTmO66J1bZUDTtxJuvJH1RTglxmFjpE=; b=XzgEuls+D9dnQjGNZKbWx1QKvvo1m9jIzBVLfOVjYg7Q01tcoAKOgadep/vA/mxBsEwl2F 0LAwAShdx8k7TbZNjSTnmqE3nj6GIiv2zNpTpw9AcVtFpgkHiiT3lOQugc0lZxAufm3KPE xNemtAMTZ+z813juGYl1rTNxcK4tNYI= X-MC-Unique: cXpsWc_OPauFa-7t4HOFdQ-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=14wd1LoJqDrIDTmO66J1bZUDTtxJuvJH1RTglxmFjpE=; b=rLWPEAs77EAp79Khz0elFYmtJC3Z8MxVT/du9jbKjzWU7EuvDRPd+YzLhwebrrFGmD YgedjSOIoQDiRDcZNvnNzKt8WAzn23Ke3FT4UfiHcyPVlWFA7zoR/kK0RGVHfNN7sejm nk0fsz07fC6/cffKuzQxJ7GdGem+lbGA2dAcNWU28zBWwnOONk48qwVRogCvswfGTXRF 3MD5b4gEhXc0OKyS5C1hOxhx04IryCBvkfpfcF7Aqp4uh0A9oz7N4bn5VBAi7EgBsLUx e0VKkOT5W2YdHjj8I58KC8K1q+A5VW4ZQcARbGxxYqUDE/SDFcILGsPJ+yiT8bkdeeLD 1IlQ== X-Gm-Message-State: AOAM533s1PlD0g0DlcqdOXtziKsWeuqA7XuN/TSlFij9PtRWplhYn7Qz NyoMF1uegTJvQuLS6EY2bZiFPIISA9skGb/VCyqHrTUGaLZXCSScjACK3EVZFUoL+Fkpq5Wss7c bb9MAPxnuUK6P1w== X-Received: by 2002:a1c:4d12:: with SMTP id o18mr1114872wmh.177.1601573156388; Thu, 01 Oct 2020 10:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzTp+6eot3LZUdkaA24Hp014HJhDuGOas8MQ2FtVbQRG69xK2oop5m0br/4ML+XHsvN0Q5jw== X-Received: by 2002:a1c:4d12:: with SMTP id o18mr1114857wmh.177.1601573156212; Thu, 01 Oct 2020 10:25:56 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH RESEND v2 07/16] dma: Let dma_memory_write() propagate MemTxResult Date: Thu, 1 Oct 2020 19:25:10 +0200 Message-Id: <20201001172519.1620782-8-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) dma_memory_rw_relaxed() 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 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index df170047eb..a052f7bca3 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -96,8 +96,10 @@ static inline MemTxResult dma_memory_read_relaxed(Addres= sSpace *as, return dma_memory_rw_relaxed(as, addr, buf, len, DMA_DIRECTION_TO_DEVI= CE); } =20 -static inline int dma_memory_write_relaxed(AddressSpace *as, dma_addr_t ad= dr, - const void *buf, dma_addr_t len) +static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as, + dma_addr_t addr, + const void *buf, + dma_addr_t len) { return dma_memory_rw_relaxed(as, addr, (void *)buf, len, DMA_DIRECTION_FROM_DEVICE); @@ -143,8 +145,20 @@ static inline MemTxResult dma_memory_read(AddressSpace= *as, dma_addr_t addr, return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); } =20 -static inline int dma_memory_write(AddressSpace *as, dma_addr_t addr, - const void *buf, dma_addr_t len) +/** + * address_space_write: Write to address space 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 + * @buf: buffer with the data transferred + * @len: the number of bytes to write + */ +static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t ad= dr, + const void *buf, dma_addr_t len) { return dma_memory_rw(as, addr, (void *)buf, len, DMA_DIRECTION_FROM_DEVICE); --=20 2.26.2