From patchwork Fri Sep 4 16:26:18 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: 306137 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 3BF7DC433E2 for ; Fri, 4 Sep 2020 16:27:20 +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 DCEFD20795 for ; Fri, 4 Sep 2020 16:27:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCEFD20795 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]:57588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEEYZ-0007Xy-01 for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 12:27:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEEXo-0006TW-W2 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 12:26:33 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35032 helo=us-smtp-delivery-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 1kEEXn-000699-DU for qemu-devel@nongnu.org; Fri, 04 Sep 2020 12:26:32 -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-379-4OPIJM8qNEy0AEx2SmMTzA-1; Fri, 04 Sep 2020 12:26:28 -0400 X-MC-Unique: 4OPIJM8qNEy0AEx2SmMTzA-1 Received: by mail-wm1-f71.google.com with SMTP id k12so3542771wmj.1 for ; Fri, 04 Sep 2020 09:26:28 -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=wXvwYiip7p7tr6VahU3IzlJqr2MIhqKzvAFhb09t7Wc=; b=g+rMUnwQfaHsY17Lcg5NSk/+gAwJUR63f85QgjSL4p4yTeoA3sJr5Quubr7+qJ7X+h 5PbWYyMjU+kzf4ghYthTDS0/fNgqPiMwlEQfSiF7UOk0Y/Owr3r7qKSUlu0RIO00LsVm uOmVyyQtj7HXyjm2rlEuigtM+H16dQV1WVhkuUm0wMWKw1JIOg+mgWxJE7dIFXOiaHtj tCWHR9r2kQV5j7zu+8FIxwAExv16lFtQQeg+zWHYMMlDWNXcf4KCzeLO1RRaiSFK4qf5 OPVcYNApQOlnY4ntApENeaNVqP+FejkwgfBS08dxAcIG0Xa4KF4oQSnBrkm/jqxO7WLo F27A== X-Gm-Message-State: AOAM531uzWXxbl2RV1JMZoXbqwus84oQqF/zplLDB3CEcDfT9XeBKLO3 1QEnqbGh1jRioJ01lObXoNXYrQKb0HGVOj1dSLsKqH4LhxZTDq28fCJ33ttT4UaNFdU3sT/iRsD 7RM+5Q9WMWDDTuNg= X-Received: by 2002:a1c:2781:: with SMTP id n123mr8263695wmn.27.1599236787558; Fri, 04 Sep 2020 09:26:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUsp0xJqmCy006SprbsF9JgUATGpxhSGRLPQa/+NYA5r3qfG6M5mpK4u3M+q/ff54XBgFZxg== X-Received: by 2002:a1c:2781:: with SMTP id n123mr8263670wmn.27.1599236787342; Fri, 04 Sep 2020 09:26:27 -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 d6sm12157101wrq.67.2020.09.04.09.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 09:26:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/3] pci: Let pci_dma_rw() propagate MemTxResult Date: Fri, 4 Sep 2020 18:26:18 +0200 Message-Id: <20200904162620.657726-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904162620.657726-1-philmd@redhat.com> References: <20200904162620.657726-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.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 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=ham 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" dma_memory_rw() returns a MemTxResult type. Do not discard it, return it to the caller. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index a221dfb3b08..a85b0bc3c44 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -785,8 +785,22 @@ static inline AddressSpace *pci_get_address_space(PCIDevice *dev) return &dev->bus_master_as; } -static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr, - void *buf, dma_addr_t len, DMADirection dir) +/** + * pci_dma_rw: Read from or write to an address space from PCI device. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). + * + * @dev: #PCIDevice doing the memory access + * @addr: address within the #PCIDevice 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 pci_dma_rw(PCIDevice *dev, dma_addr_t addr, + void *buf, dma_addr_t len, + DMADirection dir) { return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir, MEMTXATTRS_UNSPECIFIED); From patchwork Fri Sep 4 16:26:19 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: 274469 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 0740BC433E2 for ; Fri, 4 Sep 2020 16:28:32 +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 ABE47206A5 for ; Fri, 4 Sep 2020 16:28:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABE47206A5 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]:35676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEEZi-0001ip-GG for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 12:28:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEEXw-0006fE-15 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 12:26:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25272 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 1kEEXt-0006CR-Ed for qemu-devel@nongnu.org; Fri, 04 Sep 2020 12:26:39 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-567-cVJQuMAxMfS4wna-CYfL4Q-1; Fri, 04 Sep 2020 12:26:33 -0400 X-MC-Unique: cVJQuMAxMfS4wna-CYfL4Q-1 Received: by mail-wr1-f69.google.com with SMTP id l9so355558wrq.20 for ; Fri, 04 Sep 2020 09:26:33 -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=7MorJJURQDaDxlrOa/frWqZVpJ+3nafUOrcrW8fCBG4=; b=QNDpSks5vhsVJaWbwUpqgzWHRL6Q9To3yK5XCW61LzSLw3xRtKrOnrnSBi1QnZ6N11 Wpw1NAjoL4i3LfBv7lUZMGH30uU9AxQRcZNzMhfLnVLNUHyOF/eO6Xwef4tNktZ/7xfg EOY0zxXlsdlJiMlzDY/WoSVglhGNUNzVMKyt7+QJkTosDWJzzBTOoASve6cEnRYvKzYm 3zY2T3J4d3PAeLkWJH+g+fYiELoCoJ3RG30QJwVCfGeVRFzd2Jkiqp0nJYLbQ5XWlbBF NLY2P3Q3sBPyPcV4ukRZUZeTPSrG2lHwd+aERdj9iSjWPNuDQ28vdn/Vl7RXNjgBzHxz pCIw== X-Gm-Message-State: AOAM532MD2Z/MIFcMQM2PW9+lxQ1hslt6JHJmAiAD0/iFNZDMElU2Z5Z 7ziETMuko7Gh3Yyg+GKIvSPJWrMuSv0IODkHyOTFe1IDZ7114rZuDnR3VAIp4TEWu785uTf4m34 gKzWJrah9vzKhbdk= X-Received: by 2002:adf:e481:: with SMTP id i1mr8266608wrm.391.1599236792191; Fri, 04 Sep 2020 09:26:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEmzW5SG4fPJA2/5E/8QGbSX+oqPle12+QfopfydhbnVfctVEgyenq+cJq2upGf1MgIzQ0Mw== X-Received: by 2002:adf:e481:: with SMTP id i1mr8266589wrm.391.1599236792006; Fri, 04 Sep 2020 09:26:32 -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 q18sm12412399wre.78.2020.09.04.09.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 09:26:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/3] pci: Let pci_dma_read() propagate MemTxResult Date: Fri, 4 Sep 2020 18:26:19 +0200 Message-Id: <20200904162620.657726-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904162620.657726-1-philmd@redhat.com> References: <20200904162620.657726-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=ham 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" pci_dma_rw() returns a MemTxResult type. Do not discard it, return it to the caller. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index a85b0bc3c44..bb57525dffd 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -806,8 +806,20 @@ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dma_addr_t addr, dir, MEMTXATTRS_UNSPECIFIED); } -static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr, - void *buf, dma_addr_t len) +/** + * pci_dma_read: Read from an address space from PCI device. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). Called within RCU critical section. + * + * @dev: #PCIDevice doing the memory access + * @addr: address within the #PCIDevice address space + * @buf: buffer with the data transferred + * @len: length of the data transferred + */ +static inline MemTxResult pci_dma_read(PCIDevice *dev, dma_addr_t addr, + void *buf, dma_addr_t len) { return pci_dma_rw(dev, addr, buf, len, DMA_DIRECTION_TO_DEVICE); } From patchwork Fri Sep 4 16:26:20 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: 306136 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 0341EC43461 for ; Fri, 4 Sep 2020 16:27:33 +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 ADBCE206A5 for ; Fri, 4 Sep 2020 16:27:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADBCE206A5 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]:58820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEEYl-00082i-K2 for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 12:27:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEEXy-0006jA-4N for qemu-devel@nongnu.org; Fri, 04 Sep 2020 12:26:42 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:43013 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 1kEEXw-0006E2-KF for qemu-devel@nongnu.org; Fri, 04 Sep 2020 12:26:41 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-532-_HiUvyFyNJqDWPlxJn9QwA-1; Fri, 04 Sep 2020 12:26:38 -0400 X-MC-Unique: _HiUvyFyNJqDWPlxJn9QwA-1 Received: by mail-wm1-f69.google.com with SMTP id m25so2380826wmi.0 for ; Fri, 04 Sep 2020 09:26:38 -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=GdvdfUi8dGdv0X8iaMX8T8wTAWC4cqEFs01+jCQjKC4=; b=X1Zp5ZCV8LuVeJVYK5RRjddLJDgoIe8z8CucacXLSopZseeh9K//I46Bn8DCHSnMdI nDzAp9VqSOc3HyHOWnXHJ1VldzXWugm/BVhF7H+P1HmPC2lkaM6SiogELDWnUsRe2EXY RzyW4HVMPUz+zPcaSTPYES3f9D/6F6E0TNqIMXKdsTSdvymVpIZ3GGOR9dBvU50AmoxY Zg0ye6idfTvce8lXOv2RLk92muDp51oENf1a8Ij+hA7w1mC5+PnTIReuODILa5FqMkYH ZVZPSLq3Q8BxhvL2NXLOuN1qTjOcjbzq6N1Q7/zNIAIxPOYbYWad6l3/cPIfQJD2Sg8o xgKQ== X-Gm-Message-State: AOAM532yDsAgYsJqOp2FjCx48zDuJxS6lng1X9l/n+mXZbYgSGigWr20 9g6bFzrAGwgLtvIf2B33Ji0pg02CdBzDYZkalNEe32mE+X+sczD9zDOyeqon/MRX3YbyWiI1AVt 66csM7jUVqLGli30= X-Received: by 2002:a1c:7215:: with SMTP id n21mr5323041wmc.154.1599236796732; Fri, 04 Sep 2020 09:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9Qj9qQ2RsQJL+8y+3agMRElI17bTJ7XjUIbySjwHTCX/9+uTnZDOkfoFuyP6BiiHl1SuKXQ== X-Received: by 2002:a1c:7215:: with SMTP id n21mr5323027wmc.154.1599236796567; Fri, 04 Sep 2020 09:26:36 -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 189sm12479473wmb.3.2020.09.04.09.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 09:26:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/3] pci: Let pci_dma_write() propagate MemTxResult Date: Fri, 4 Sep 2020 18:26:20 +0200 Message-Id: <20200904162620.657726-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904162620.657726-1-philmd@redhat.com> References: <20200904162620.657726-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.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 01:57:12 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=ham 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" pci_dma_rw() returns a MemTxResult type. Do not discard it, return it to the caller. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index bb57525dffd..76826e240a9 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -824,8 +824,20 @@ static inline MemTxResult pci_dma_read(PCIDevice *dev, dma_addr_t addr, return pci_dma_rw(dev, addr, buf, len, DMA_DIRECTION_TO_DEVICE); } -static inline int pci_dma_write(PCIDevice *dev, dma_addr_t addr, - const void *buf, dma_addr_t len) +/** + * pci_dma_write: Write to address space from PCI device. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). + * + * @dev: #PCIDevice doing the memory access + * @addr: address within the #PCIDevice address space + * @buf: buffer with the data transferred + * @len: the number of bytes to write + */ +static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, + const void *buf, dma_addr_t len) { return pci_dma_rw(dev, addr, (void *) buf, len, DMA_DIRECTION_FROM_DEVICE); }