From patchwork Fri Sep 4 15:44:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 758D0C433E2 for ; Fri, 4 Sep 2020 15:51:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33A542074D for ; Fri, 4 Sep 2020 15:51:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33A542074D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDzo-0003Ts-9X for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 11:51:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEDu0-0001Za-R7 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 11:45:24 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27308 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kEDty-0007Yo-4q for qemu-devel@nongnu.org; Fri, 04 Sep 2020 11:45:24 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-30IpRLZvO2ykYEFKrln_Mg-1; Fri, 04 Sep 2020 11:45:18 -0400 X-MC-Unique: 30IpRLZvO2ykYEFKrln_Mg-1 Received: by mail-wm1-f71.google.com with SMTP id x81so2323162wmg.8 for ; Fri, 04 Sep 2020 08:45:17 -0700 (PDT) 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=ZKu32NjwGavdXRIU1N5tUoqjwLuYO41YyQt79mWEprg=; b=UiGFlsYJOWlAYnJ2XQLY7JIJubJkoJoQHZW8JkLqa3OnkeGDIF28yh9/XVisuAnlcG h6oFASLYldM9ttHCHSMiV4dps/jb5PJGBrZzIOrvGKqmG1XVx4acmZaiiPLQzVHfwWQS KQxYNohhJ3IPyN8/m/oSAh+PuH5c3GUhZD+D79fRrklzsZLsQEI3yyHbUTl9+ImnvOKI ZICKdR6Nr20jFeNQG95fWceKHUs35qqj1RnDZ/UPa6FNTq77Bzbgi/oYHvvYHFwNoCvM ZxBI8PFYZrFMYf/CwLzVfXiR33onN1zL+O7qZrrarf2aJG5wOPKvrBcar9z/HQzVPoQc o3fA== X-Gm-Message-State: AOAM533zzss07yV2ATaNVO5z7JMTgOYuvODCAFJ4jgBZUNU4H8JUyJ24 uEqh+ETvCnz8AUlgkX76Vhq/sAS08oaiI0nGgg+H9o/YkIqUFyBO4uKnbNaBJZ5aG9BJbIVeU82 /h86Yx+NhnYQSLqo= X-Received: by 2002:a05:600c:2053:: with SMTP id p19mr8173818wmg.50.1599234316737; Fri, 04 Sep 2020 08:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1NIGcHfhX+nU2pn1CtiWuzxIG2c0hCBCjyt9EdYJLodE++4yx4FX32BYRNC1HzUMpH9nOaw== X-Received: by 2002:a05:600c:2053:: with SMTP id p19mr8173787wmg.50.1599234316558; Fri, 04 Sep 2020 08:45:16 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id b76sm12067956wme.45.2020.09.04.08.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 08:45:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Paolo Bonzini Subject: [PATCH 06/13] dma: Let dma_memory_read() propagate MemTxResult Date: Fri, 4 Sep 2020 17:44:32 +0200 Message-Id: <20200904154439.643272-7-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 Received-SPF: pass client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:58:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Joel Stanley , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Alistair Francis , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , John Snow , Richard Henderson , Andrew Jeffery , Laszlo Ersek , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Andrew Baumann , qemu-ppc@nongnu.org, Peter Chubb Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" dma_memory_rw_relaxed() returns a MemTxResult type. Do not discard it, return it to the caller. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang --- include/sysemu/dma.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 661d7d0ca88..2961a96ad67 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -89,8 +89,9 @@ static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as, buf, len, dir == DMA_DIRECTION_FROM_DEVICE); } -static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len) +static inline MemTxResult dma_memory_read_relaxed(AddressSpace *as, + dma_addr_t addr, + void *buf, dma_addr_t len) { return dma_memory_rw_relaxed(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); } @@ -124,8 +125,20 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, return dma_memory_rw_relaxed(as, addr, buf, len, dir); } -static inline int dma_memory_read(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len) +/** + * dma_memory_read: Read from an address space from DMA controller. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). Called within RCU critical section. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + * @len: length of the data transferred + */ +static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr, + void *buf, dma_addr_t len) { return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); }