From patchwork Fri Oct 23 15:19:14 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: 302170 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 D7AE4C4363A for ; Fri, 23 Oct 2020 15:29:29 +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 5CFEB20E65 for ; Fri, 23 Oct 2020 15:29:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hMjB0Fav" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CFEB20E65 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]:45518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz0Q-0005s8-Ms for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:29:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyqv-00014p-WC for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyqs-000099-Cu for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466373; 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=woEn3sc6gXxf1+d8nTxR4+S5Pfst+tMKZK/gRYER+Og=; b=hMjB0Favt5f/wYxcPgUjc8efCWaqu7tOXpvu3YePOCrW65oRCKF5qoezRrFBxsELy6RG3H 8mz19RIIW9jG+kQDtW8rAnYF6oX4gcpbF6DUFzyvjCYMdkjvM4kyIrI6D2WC4XH15+EaqZ 93t35QJhwiReLYTUoWZIUBb3o63q/O4= 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-222-KqStS-i2ORiIrjpOa4UUYQ-1; Fri, 23 Oct 2020 11:19:31 -0400 X-MC-Unique: KqStS-i2ORiIrjpOa4UUYQ-1 Received: by mail-wr1-f70.google.com with SMTP id 2so700557wrd.14 for ; Fri, 23 Oct 2020 08:19:31 -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=woEn3sc6gXxf1+d8nTxR4+S5Pfst+tMKZK/gRYER+Og=; b=U2io50h3kCrM7oVgIbhAyHst8do+yg2XJ4wPdrn1u6C6nGR35NkXfpv0bV65wYfoc8 3OU6HlXJrBXRMXG4XLljCtTD70FRF1/ygu+hqnp2TAaayS5NwGmMiWcGQHsIh3FaCQXh ozLDN/02vA5Hgul8s3zg06WAvqflrCAweLnOmJRZXtDjqtmImw18JnYQaqx6RiZYaGCM jumQPV5cKaRCcm+H1eOXpiKz55q4QhHsRbVMF9O2A+eo6ZbbF5F69wN2XMQsbxsAIW8T mgScKoRNBDSp2s9WqmNuV9lAG/RfAK+McoF5zIMEuAt5wOljZet4HanmOG1+aaCVZcEV pUmg== X-Gm-Message-State: AOAM533zLgvDW9bUd7Zu33eC4PmkgvQ0T+lJC8u4QGQSflkO50CNKiOi D/LmdTQY9gVkIVWTZQ3XBz4u6/TOW7xSReo57v0PdNLfVRKcieZhOv6qcCfxH31EdyyFjK0MPtq a7FrQCee/1gUEKeY= X-Received: by 2002:a7b:c7c9:: with SMTP id z9mr2970315wmk.91.1603466370320; Fri, 23 Oct 2020 08:19:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgsgQv+WrSHRvo7gMkXRybAvm8gaV/Vqvr+EjqJahvToCQ9n2nuHw6FZj8+jSZuavxNDqb9A== X-Received: by 2002:a7b:c7c9:: with SMTP id z9mr2970289wmk.91.1603466370113; Fri, 23 Oct 2020 08:19:30 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id u5sm5123339wru.63.2020.10.23.08.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 01/10] pci: pass along the return value of dma_memory_rw Date: Fri, 23 Oct 2020 17:19:14 +0200 Message-Id: <20201023151923.3243652-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 02:46:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Li Qiang , "Michael S . Tsirkin" , Klaus Jensen , Richard Henderson , Keith Busch , Paolo Bonzini , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Some might actually care about the return value of dma_memory_rw. So let us pass it along instead of ignoring it. There are no existing users of the return value, so this patch should be safe. Signed-off-by: Klaus Jensen Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Acked-by: Keith Busch Message-Id: <20191011070141.188713-2-its@irrelevant.dk> Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 0a59a06b149..f19ffe6b4fe 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -783,8 +783,7 @@ static inline AddressSpace *pci_get_address_space(PCIDevice *dev) static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr, void *buf, dma_addr_t len, DMADirection dir) { - dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); - return 0; + return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); } static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr, From patchwork Fri Oct 23 15:19:15 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: 302171 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 8C915C388F9 for ; Fri, 23 Oct 2020 15:27:48 +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 049BE20E65 for ; Fri, 23 Oct 2020 15:27:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IinAWouy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 049BE20E65 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]:40378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyyo-0003fk-ML for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:27:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyr0-00019W-13 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyqx-00009a-SC for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466378; 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=Bg0ARfy/nreX1sEGkRPdNpsWLKtbHdvINaE794GWGps=; b=IinAWouyWeF2LYIdiluK7KOVLqlEGOuZxqNhiD2EPqgovHQ5KD0c4tANOpdQBTa8O1sA1K RRBYoAYEinHng8bWxsSRHbxXom5vhmvwJvlW06Q6TVK3dFMOS85DH+2CwjHjtKUUNZvi4Y EQB2RYFpd+F7lyRWUzDExB+ft/QPSXY= 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-461-YRvszuRFOEW7KcHQhVVrMw-1; Fri, 23 Oct 2020 11:19:37 -0400 X-MC-Unique: YRvszuRFOEW7KcHQhVVrMw-1 Received: by mail-wr1-f70.google.com with SMTP id t17so699715wrm.13 for ; Fri, 23 Oct 2020 08:19:36 -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=Bg0ARfy/nreX1sEGkRPdNpsWLKtbHdvINaE794GWGps=; b=F91lL5zDRJ/XY3Cg8bQ5ttgrRaIAcKukVcKNqLyj/gG9d1eIvQTDA+Ca0b565X80Bn 35YiVRiwkx8+fMbhcCWZwFw4MtsSZhB7oPDp3mezrexepz2aZ/WinYZhjjajlO4vPULX Y4ZJVzj6+9eoeoH/jJks/EItpMo90dJ8C/1nZJq6cYUKSIWz+E3il0seHJbIkxPFblg/ n645I03GuMSBdXM00DsztE1W1eiJu+8CMiFyptOOAFj1X/7qpBr1jp/PGP3h29vP7XKP 3h/kLCunbCUCbPwBwJPcYaogkN/C8zw+A/Jm/YorTcdC+NuOYin+z+D3BBvgP0Hydtpz c9rg== X-Gm-Message-State: AOAM533E6HfJIjX6Ftd8s/U2aPwn/1XfZEjjsY3bRA6I0mBrVeAoTW5j dxk82TsSMf/lQcrH3Pcvz9f4Wd1tUaCE01l3Cf2ogdyZBl1qC0y2gq3HsHyNwCh71YS/HVv9LZX h7jl2aJT/HmoqWOw= X-Received: by 2002:a05:600c:1149:: with SMTP id z9mr3046885wmz.180.1603466375036; Fri, 23 Oct 2020 08:19:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykkgTDIIxfR6ojyPbFkVPnULp6JstlvtxPH536EGvfoM2VrTaNGtmWDdXzRndSse/Y2fxJwQ== X-Received: by 2002:a05:600c:1149:: with SMTP id z9mr3046868wmz.180.1603466374846; Fri, 23 Oct 2020 08:19:34 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id g4sm3665361wmh.13.2020.10.23.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 02/10] docs/devel/loads-stores: Add regexp for DMA functions Date: Fri, 23 Oct 2020 17:19:15 +0200 Message-Id: <20201023151923.3243652-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 01:44:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé --- docs/devel/loads-stores.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst index 59c1225391c..ee43f5dfee2 100644 --- a/docs/devel/loads-stores.rst +++ b/docs/devel/loads-stores.rst @@ -483,6 +483,8 @@ make sure our existing code is doing things correctly. Regexes for git grep - ``\`` + - ``\`` + - ``\`` ``pci_dma_*`` and ``{ld,st}*_pci_dma`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From patchwork Fri Oct 23 15:19:16 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: 302173 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 068B3C4363A for ; Fri, 23 Oct 2020 15:21:23 +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 5294121D47 for ; Fri, 23 Oct 2020 15:21:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vnv1GYOJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5294121D47 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]:47292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVysb-0002x9-Ax for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:21:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyr5-0001Dv-N3 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyr3-00009w-NZ for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466383; 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=ttvgS+r+18VpM2OBoh4lfYK/eRzxtUcQdupc1VVh/ow=; b=Vnv1GYOJnp7spJsw2DnCHnwzvKS2bxFY9l2Dy0g1QGjPYXUPgQ4nkqdADyu7lTkpl12Dwk rpLktafO7Fj5W7/V4VPNwBwFqTPGlVLbpAoHv8rU2Tv/N22Ovg9vESQeErazSwm4v3UALs LmQ41+E1NnI707TxtRCkmglw9YGM7nM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-468-I7UTSGHDPGaSJkuCsXCTwA-1; Fri, 23 Oct 2020 11:19:41 -0400 X-MC-Unique: I7UTSGHDPGaSJkuCsXCTwA-1 Received: by mail-wm1-f70.google.com with SMTP id v14so573611wmj.6 for ; Fri, 23 Oct 2020 08:19:41 -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=ttvgS+r+18VpM2OBoh4lfYK/eRzxtUcQdupc1VVh/ow=; b=E9za6/hdr1vjPeHbaEUXvAXZXOFDNsQf+Au0KKvmY1MY6k428U9TP/Etw3OMiAKJLk tFByK2mO2t668rIqKuzdKti1dpYvDjzZSdROWNXikJgWZ2jSZUP6IbFTZA6+ZMp7RED7 WpsePUvIis4U6yhzX5ghxUy6jbsZ3LPhk116ciMxVQPOXn3xmJdQ6cddc6b1/o6WDTas OAXR24YdD0Tm5/DXK6jrxNXKke9ytOFQPBBOU3EyReF2tX6Hfb7fhN7KrTJyCPWfcj1T 0d/6SSlCfs/05hEXyd0zgyD61qwPGMgmLHeXSnoVXmuMgGY6j0GCClgtCsz2TYKhoTsO FK0A== X-Gm-Message-State: AOAM530GF+ElQYRcSDXVSDPV/OhAxsb7wCmG7N/zwfoRYQ5mDmILIN4U c2Qc7BmUym1Hufjt8QrpnoEUumjLl8hGxpshFYaBTgF+lzNZXwJyW6g26IaHo4suCztfrOPogLa jzVIWODtowORvOMo= X-Received: by 2002:a1c:49c2:: with SMTP id w185mr2821863wma.70.1603466379995; Fri, 23 Oct 2020 08:19:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmKJiCewP/Mt8BrNai0LshClxUJRKHhdZVFaM0xhEmiieM7Ky/xXkCrumd5nWJ/dEjxHNScA== X-Received: by 2002:a1c:49c2:: with SMTP id w185mr2821852wma.70.1603466379767; Fri, 23 Oct 2020 08:19:39 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id n4sm3566236wrr.91.2020.10.23.08.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 03/10] dma: Document address_space_map/address_space_unmap() prototypes Date: Fri, 23 Oct 2020 17:19:16 +0200 Message-Id: <20201023151923.3243652-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 02:46:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add documentation based on address_space_map / address_space_unmap. Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 80c5bc3e02d..c6e12b4c243 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -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. @@ -125,6 +125,19 @@ static inline int dma_memory_write(AddressSpace *as, dma_addr_t addr, int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t len); +/** + * address_space_map: Map a physical memory region into a host virtual address. + * + * May map a subset of the requested range, given by and returned in @plen. + * May return %NULL and set *@plen to zero(0), if resources needed to perform + * the mapping are exhausted. + * Use only for reads OR writes - not for read-modify-write operations. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @len: pointer to length of buffer; updated on return + * @dir: indicates the transfer direction + */ static inline void *dma_memory_map(AddressSpace *as, dma_addr_t addr, dma_addr_t *len, DMADirection dir) @@ -138,6 +151,20 @@ static inline void *dma_memory_map(AddressSpace *as, return p; } +/** + * address_space_unmap: Unmaps a memory region previously mapped + * by dma_memory_map() + * + * Will also mark the memory as dirty if @dir == %DMA_DIRECTION_FROM_DEVICE. + * @access_len gives the amount of memory that was actually read or written + * by the caller. + * + * @as: #AddressSpace used + * @buffer: host pointer as returned by address_space_map() + * @len: buffer length as returned by address_space_map() + * @dir: indicates the transfer direction + * @access_len: amount of data actually transferred + */ static inline void dma_memory_unmap(AddressSpace *as, void *buffer, dma_addr_t len, DMADirection dir, dma_addr_t access_len) From patchwork Fri Oct 23 15:19:17 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: 270557 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 F082EC388F9 for ; Fri, 23 Oct 2020 15:30:07 +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 6BDB521D47 for ; Fri, 23 Oct 2020 15:30:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="detaxUMK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BDB521D47 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]:47506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz14-0006kM-BS for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:30:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyr9-0001Fz-LB for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyr7-0000AH-Db for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466387; 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=rTl09xtbUfBbJCkrL3LY3kF9JffyPlmRm+1EQw48YxQ=; b=detaxUMK5t0d+EC2NSvwf5bnwRQ1pIprxcSozf53mjmSNrV/+kG9RvKFOVsvQebk/gP9My N7TNM6WpEtOk+IP9Tr5EfRbeGI2vc/gOFSvI7uZHwQH3n7Fo+Z8+WjaVrArDwm38im0GA2 MC1KXrKravpLSNQVxmbeQJZwqG8njVs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-rT0577baP3KmugfMyvsZLA-1; Fri, 23 Oct 2020 11:19:46 -0400 X-MC-Unique: rT0577baP3KmugfMyvsZLA-1 Received: by mail-wr1-f71.google.com with SMTP id i1so692223wrb.18 for ; Fri, 23 Oct 2020 08:19:46 -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=rTl09xtbUfBbJCkrL3LY3kF9JffyPlmRm+1EQw48YxQ=; b=iWwWbZ7Yg0LjOxbTMXc9sJRJyjSpoM2kCCQQ/AsULqcB3SpaeuDh55NC2xICPVpVZE Km82o5GYO0km+0E7em9KHk25XfB2wxkrzb3mwFMSK+PFyWxMKnbIsSYSldgvr5alCbh8 GPWs1GcoxPJTwhUyeuMJg9AluupN6esBZ4GLVrdLM8FFRIZXh+5X03W//I79KMf74xE7 K575LulKfRrPV8oud5Ua6WA3EtsoBfJl9gAX/oeUFMo/qVJeGM8kqckT+3ppp6hXR8Bd y0a4IbFBz9xXWlocOnftFXeLsX6aQ14RkCOAVjdrJ8Zjy0D4NhLRuyjDHrgbCMx7iTy9 3l8Q== X-Gm-Message-State: AOAM533jlV3RWH4zFSBuSgSAm3Hv6p9x6cL1NKj1GZX+NLreEuZWq/Yu Zm5gUZkGCpblobPSwqKaagBP4KyPJo3rptT03WXuGntqNyaIt7k/40AIPd6+gCmflNA3H9BT0nU 3g5SR2SYSUhsARsA= X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr3046061wrt.137.1603466384894; Fri, 23 Oct 2020 08:19:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzHQD34KWlBmSsB30Dvfl+0e1RVMdw1clEaFis9cLCUDtaH2HrgMA67xmlMXiNI9jnbxBMCw== X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr3046038wrt.137.1603466384671; Fri, 23 Oct 2020 08:19:44 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id 14sm4122296wmf.27.2020.10.23.08.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 04/10] dma: Let dma_memory_set() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:17 +0200 Message-Id: <20201023151923.3243652-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 02:46:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Paolo Bonzini , Li Qiang , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- include/sysemu/dma.h | 15 ++++++++++++++- softmmu/dma-helpers.c | 7 ++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index c6e12b4c243..37cd9f11217 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -123,7 +123,20 @@ static inline int dma_memory_write(AddressSpace *as, dma_addr_t addr, DMA_DIRECTION_FROM_DEVICE); } -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); /** * address_space_map: Map a physical memory region into a host virtual address. diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 03c92e0cc60..29001b54595 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/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 @@ /* #define DEBUG_IOMMU */ -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); #define FILLBUF_SIZE 512 uint8_t fillbuf[FILLBUF_SIZE]; int l; - bool error = false; + MemTxResult error = MEMTX_OK; memset(fillbuf, c, FILLBUF_SIZE); while (len > 0) { From patchwork Fri Oct 23 15:19: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: 270555 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 5B505C4363A for ; Fri, 23 Oct 2020 15:33:11 +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 C5A1020E65 for ; Fri, 23 Oct 2020 15:33:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZLHzPQyi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5A1020E65 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]:55736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz41-00024A-Gi for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:33:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyrF-0001OM-MG for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyrC-0000AZ-Hz for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466393; 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=CoRwInsbwjWJV4eBwvCdQEKEOGDOla1790sLaSe2DnU=; b=ZLHzPQyiAEBp4yJBigzEzfpZwJGOQEvaS2hl+A/yLVMYOtW7tfbyxR6qElkr3e4z3/rG7j cktdBDTIL+B46NkQEFqXbUaIpG1/8E+HwQdBuDP0Wk5sfkSPgi1KHDptCvvMQwqA1l/LGC 7ayWAmxY4s5JEFjgbTZsUnUEL5xAnNE= 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-382-q0BSKhC_PVGaUxMMFt7gHg-1; Fri, 23 Oct 2020 11:19:51 -0400 X-MC-Unique: q0BSKhC_PVGaUxMMFt7gHg-1 Received: by mail-wm1-f69.google.com with SMTP id s12so638833wmj.0 for ; Fri, 23 Oct 2020 08:19:50 -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=CoRwInsbwjWJV4eBwvCdQEKEOGDOla1790sLaSe2DnU=; b=kAl41rUG0ytK/gIAtFCHOioxgJFWFwN17+QlYmGQZa8xB8hG5EkuWQTjtYBqt2aJOb vDBcfAxsabP5BXPi45RME+qagSagfolXiRrtQQDLSnykfmSGreHHIdW8ZpJiINpGek6/ eHWAOuKRSzM8U4RZBctXyRnu1wv4mWd/hViLAS44CeEZrWgVbF7PbPhiJAdMJkU43TZg ZXwr59+HvxEsS4T/eapDbq3SuV4jFmUo5vLQlmdSpFE5rBlpUYKcRJn3PMEaWEsEV0iT WOmgJgHXj0qIo8JlJ5WUmyYNf49QElC9J6FmQsMv8SLbEeVGXyjCH3l3EcSGQNSMDlxC XQKg== X-Gm-Message-State: AOAM5317p18qgsjk3YguCkGthM5jpdwcAe7gDce3SO17xLUhrQlHUQLQ eBGVo+hjd9SEIcuBS+iCcvdFAp9w9Ggyuup9K3bdyJU1/AFamjNuvYj7/tIPFw24hRO46jgyddR Peu9pTF8cWXFITSw= X-Received: by 2002:a1c:e244:: with SMTP id z65mr2990316wmg.40.1603466389530; Fri, 23 Oct 2020 08:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhq5VbIMew7MLkdBI+F+y0Hi2/9dY8yxsk4JUBFRYhUOgFeOxVX/r4AcEAgekFfOeNU3DDwA== X-Received: by 2002:a1c:e244:: with SMTP id z65mr2990288wmg.40.1603466389278; Fri, 23 Oct 2020 08:19:49 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id z15sm4028910wrq.24.2020.10.23.08.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 05/10] dma: Let dma_memory_rw() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:18 +0200 Message-Id: <20201023151923.3243652-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 02:46:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Paolo Bonzini , Li Qiang , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 37cd9f11217..04687d8825e 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); } -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 == DMA_DIRECTION_FROM_DEVICE); + return address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, + buf, len, dir == DMA_DIRECTION_FROM_DEVICE); } static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr, @@ -101,9 +102,22 @@ static inline int dma_memory_write_relaxed(AddressSpace *as, dma_addr_t addr, DMA_DIRECTION_FROM_DEVICE); } -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 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 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); From patchwork Fri Oct 23 15:19: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: 302168 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 707A8C388F9 for ; Fri, 23 Oct 2020 15:32: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 C892420760 for ; Fri, 23 Oct 2020 15:32:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MPG0ZtrK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C892420760 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]:53786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz3H-0001Bj-9b for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:32:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyrI-0001V5-9G for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyrG-0000An-FV for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:19:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466397; 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=Vt/p2q5jWxaYevN4DyU5OYfdDbucjx1Cc7x7OfkPzDY=; b=MPG0ZtrKJ51RbiFXelD5W8/V6vO0HFGuGW1l23sJGtTHbGxhw1zT/U/JpmaYQZCf83N79b JkktLE9g3+TJ/TxPFuFBbHceLuxGw1Z0AHa7v4k/W+KvFJJfLGazhWCmeXfO11tCshnDuN NwgyTeyyyMAKeyBohK/bxNfHc8xN2c0= 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-398-nK0KXjOGNXK8xpETuviA5Q-1; Fri, 23 Oct 2020 11:19:55 -0400 X-MC-Unique: nK0KXjOGNXK8xpETuviA5Q-1 Received: by mail-wr1-f69.google.com with SMTP id r8so702843wrp.5 for ; Fri, 23 Oct 2020 08:19:55 -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=Vt/p2q5jWxaYevN4DyU5OYfdDbucjx1Cc7x7OfkPzDY=; b=YLoiYsm6FPSYFCWiKFg0KpDlkEiSkyDcXN0gyVIfuvoqcty1X0ITTXtG421Hs9eGso qcSn+RK9R1f3kp4wPrhleWttBes02wcL7h7eS3GOEXxpyuBaxAAO6qPfj1K7QmK+NULK 8FrbhVZlS5r45vBe09+9LgA6Dcf6qrLYHlY1sF0ddq5noYYfyG77GnaOpJcZqFvjxlOE GM14SnWJaUZ8/N4kLZSiKU9633noWyVSSaRs9x9+lU+CUMYwUgAIMh1HBjZWAVsBpRPV Wo3C2pMQyrwDfVQw/ZKB3haQDjoyWS+NBvMgN9zYVF+Z7qaSjU0DmXVFueXxRz43WbeR Qs5g== X-Gm-Message-State: AOAM532BV4QzwEYm/NBpTZ9C89fufSazUb8LYdgB0hJiH+lPshiHQ127 1LShzsIRugOKR61fSUvbU2d9Y2bcgmVdGgVnx8ZiNMpmx2w63gE+hKpN9fNb7JGZx9GMV2vMnrC 8M/Nw9txqqGZDnWI= X-Received: by 2002:a1c:20d0:: with SMTP id g199mr2991208wmg.38.1603466394223; Fri, 23 Oct 2020 08:19:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwReI7zUQg/Ydu7TguRxjr75zgVDakszRRGDiJJXZmHAdgaafan+AFKtZDYGmqCf+ZgoEa0pQ== X-Received: by 2002:a1c:20d0:: with SMTP id g199mr2991201wmg.38.1603466394077; Fri, 23 Oct 2020 08:19:54 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b15sm3965606wrm.65.2020.10.23.08.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 06/10] dma: Let dma_memory_read() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:19 +0200 Message-Id: <20201023151923.3243652-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 02:46:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Paolo Bonzini , Li Qiang , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé --- 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 04687d8825e..df170047eb3 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); } From patchwork Fri Oct 23 15:19: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: 302169 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 D0D07C4363A for ; Fri, 23 Oct 2020 15:30:36 +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 075D220E65 for ; Fri, 23 Oct 2020 15:30:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VUuaZRsG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 075D220E65 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]:48698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz1W-0007FW-Ve for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:30:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyrN-0001gu-I0 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyrL-0000B9-NY for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466403; 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=E6cKAl65zW1qyY38kdhpIGpdqbKF2puemJ9sAGdpEGk=; b=VUuaZRsGT9AFOZ12UfSJKcxnaPZo0LFcnmdzZRaUqqKEeYw0YDPGwxUXu48eiEkE6dklOw VMjBMIFkKrjLiWJ1lOQ4xBP9LBLw4qZRRXAYlp2hGr/6KuE7IiFGttUv15+obIiOpuA7ZH KcL+JKptRGb0fVb78jhOF44BUsTzkoY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-0F8vc1QsNd6N4lpFzkVixA-1; Fri, 23 Oct 2020 11:20:00 -0400 X-MC-Unique: 0F8vc1QsNd6N4lpFzkVixA-1 Received: by mail-wr1-f71.google.com with SMTP id t17so700067wrm.13 for ; Fri, 23 Oct 2020 08:20:00 -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=E6cKAl65zW1qyY38kdhpIGpdqbKF2puemJ9sAGdpEGk=; b=MdlyfXFxFCotOA9fghaXQ+9jW6SaicpVntVzphcXLo5yDINb1nckm3Cyn0NDNoISLF k/hpH1FtCPySnknFrfJ9Ubm2PERHf1tKNZyhQh8bB2fIHA79pevd8PgJAS5+0vLftv2W ylJR7goSMlstW91JIUU4WYG58NVF9pDfLTL9ndym1fwIuSYAUBn49wxESnInsYz0qhRD lIqpO9oGSqv9JZLtswOxtaYMmVJXv+b5sxnafCKt2xdfZoqvpzhdncOXnKG27h5fO97k iVK6gxoQ4uFP+rylAG8Tg/mdMn9WMls/s/+Ydfq0Q2QT9+DlqUJl6hjzGYXfIKNRyw/+ dhkQ== X-Gm-Message-State: AOAM531LYJPoUc/LE9+4mE4JpnBP0lMBtSnmVh3PE+rqqQguwdPTSPGi YaSjryXx+N87oKJSMyu8zDnhwJbJmtZw+URnd+3EnpAQBXl1ezvEMO0Vxdz4fZXfo8H6uazGBqk 7xsF/rf6bbu8cD7Q= X-Received: by 2002:adf:9f0a:: with SMTP id l10mr3004586wrf.427.1603466398991; Fri, 23 Oct 2020 08:19:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6SANdtk0trnDse1dOiwg/trn2UoCu6ZDnKMlQdgTPRyQdT038mLI5VBv/zvFMpTXeqTn23Q== X-Received: by 2002:adf:9f0a:: with SMTP id l10mr3004564wrf.427.1603466398833; Fri, 23 Oct 2020 08:19:58 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id a127sm4252674wmh.13.2020.10.23.08.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:19:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 07/10] dma: Let dma_memory_write() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:20 +0200 Message-Id: <20201023151923.3243652-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 01:44:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: "Edgar E . Iglesias" , Paolo Bonzini , Li Qiang , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé --- 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 df170047eb3..a052f7bca3f 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -96,8 +96,10 @@ static inline MemTxResult dma_memory_read_relaxed(AddressSpace *as, return dma_memory_rw_relaxed(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); } -static inline int dma_memory_write_relaxed(AddressSpace *as, dma_addr_t addr, - 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); } -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 addr, + const void *buf, dma_addr_t len) { return dma_memory_rw(as, addr, (void *)buf, len, DMA_DIRECTION_FROM_DEVICE); From patchwork Fri Oct 23 15:19:21 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: 302167 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 E893FC4363A for ; Fri, 23 Oct 2020 15:33:46 +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 588C020E65 for ; Fri, 23 Oct 2020 15:33:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eqVHQKaZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 588C020E65 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]:56928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz4a-0002YT-0H for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:33:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyra-0001mQ-6T for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyrS-0000Bi-F6 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466408; 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=RJinNb06Gf0QcNRno4TNgRALIvb6H/vJjFM/EgfOCIw=; b=eqVHQKaZCXrT2G2UUJy1hNEcO2zzLfAogS4zioeKQ2wNNzjWh3gRY1CCRRjJlzDRAmnN8A zZ+2oDvAQOJvLi6ZuG8MXgO/piTHMzoBYVrtLdAtmayjlES+Q21KhJW/qxDtZfF7+mYE1D V4I5iFJM/bYrbUvA1OQwM3GqDobPeJI= 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-493-E5I4AXo5NLuC136TzQbVqA-1; Fri, 23 Oct 2020 11:20:05 -0400 X-MC-Unique: E5I4AXo5NLuC136TzQbVqA-1 Received: by mail-wr1-f69.google.com with SMTP id v5so714662wrr.0 for ; Fri, 23 Oct 2020 08:20:04 -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=RJinNb06Gf0QcNRno4TNgRALIvb6H/vJjFM/EgfOCIw=; b=bfkQGQcoSXRapiom7Q9FEXlAwX8cza4QX3GR2348bktCaAIrXkBy9zv+F02gyyjUAQ aFix5wNlAEY9QXCK5NYSpshpRSB1yDdA69iE00lrFWV3pvSHsBkmzicPH3W7IH3INzfr 5nxUuEyPkWa9pe1jGsgvkyfgEvyTUN2hxf5aUVECthAFtMI47lr/Xf0ZO94HwosQ0gC8 xeDdj6QHIV5kN0jRynKqEOFGeSFRCZxUMmIRxNODILD4XFfPF2QJeM4E3k+KlMcSoKlM Fc+2Rq8brAWtiHhsL8bkT2gGnEG+nNKMLijNAyzpxkFR3TbFxQPbx5dHrqzX104d6ypA MaXQ== X-Gm-Message-State: AOAM531VG71CVlprQ4ds8mnrkzj6eu7BnmhkLOXcdIAJbdRSmFjwiRHz Go5r1KevZVYnFdchwy+gzUwhVOtHEeNSt95r5noBOsAOOj0x/nnGkf3bUoqPFN03CDVdLNS8ww6 kqSAQNF48/IKKeuM= X-Received: by 2002:a1c:f002:: with SMTP id a2mr3025585wmb.129.1603466403590; Fri, 23 Oct 2020 08:20:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxedeCEGIRMyJ+he0rOhNoWB6qoAf5QCSiSC5rcP5S4uAE2bhbhMRIAXFcF1EleEetzVNdGJQ== X-Received: by 2002:a1c:f002:: with SMTP id a2mr3025568wmb.129.1603466403425; Fri, 23 Oct 2020 08:20:03 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id c15sm3622655wmb.27.2020.10.23.08.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:20:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 08/10] pci: Let pci_dma_rw() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:21 +0200 Message-Id: <20201023151923.3243652-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 01:44:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: Paolo Bonzini , Richard Henderson , Li Qiang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Li Qiang Reviewed-by: Richard Henderson 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 f19ffe6b4fe..b8780ea18c1 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -780,8 +780,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); } From patchwork Fri Oct 23 15:19:22 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: 270561 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 E109BC388F9 for ; Fri, 23 Oct 2020 15:24:06 +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 5193D20E65 for ; Fri, 23 Oct 2020 15:24:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c3Ucax8f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5193D20E65 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]:55706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVyvF-0006XQ-2E for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:24:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyre-0001sP-Ne for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyrb-0000C5-Vw for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466412; 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=P62uFdatfvoHDjKgezNY7D79I1KvnGcFbawzNsrJjnU=; b=c3Ucax8f2Qp+D3tQIMg2KfaX8f5Mn+ebUIBIw+hNh4PiiV1lgK+Nh4QvUR0YhBTcgwBfTA Coa8LFT78pf+e/MkaBy815y/vRfvA3rhz42yi6xvB9YvV/p8wfQwhbzoH2589NTWKEk5gL FBz5ojRktFH3FB5U1Af8qfLLIqAJclo= 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-241-irYCGFreNLO2ZBWQf7z_OQ-1; Fri, 23 Oct 2020 11:20:09 -0400 X-MC-Unique: irYCGFreNLO2ZBWQf7z_OQ-1 Received: by mail-wr1-f70.google.com with SMTP id b6so691981wrn.17 for ; Fri, 23 Oct 2020 08:20:09 -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=P62uFdatfvoHDjKgezNY7D79I1KvnGcFbawzNsrJjnU=; b=W9QfZGe/AZ2n//Z1J3YtcG1rpa9jE8WoVYNn3TdA0OF0M4AROV4lSoAvTXUlwMi9Aa 7G+oLJ19OhFY7jI5UTXFe2mxvvbsAJscH4CBNJXVxleYSE3PGkN/ZXKGosH8K15eTVKe Q3TygpZifdH/MlnjCYVVQ193/paH3/KxF6GX/mziPUB61gRu4ReWjXSsh4nu6KjT1Q74 C/0utYQoBrYGjBJW95EhtyBbyE9YzT3VCEgrUZ+B6J3M3caNpOZwOOn1KEY9S5OzPpKW GJt9Za11ofS6iytM7x60e9vOBEqrWnnsMVlSW6Vbnr+H9s2okuT/Rn9aIlG+WqdylDHf Mksw== X-Gm-Message-State: AOAM533XqNRV5YwGMo6Vs0BThgft11H7KYVZ2YzpVn1mZF6Odc8Xk9pV TYhxc3EsRH7gfAVVPZBmHYTjJ2KSbAVVhXEH6Xpo4kQB1umZw/oqKth1smk9gr7UuRTAnwJL/GN mFFkvPyH3QZUQCJM= X-Received: by 2002:adf:e5cf:: with SMTP id a15mr3032806wrn.186.1603466408291; Fri, 23 Oct 2020 08:20:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV+mMAAnr7Gl+DWcBdZ87I3RqG5VLZ1vzVJwsBluZe8J9BnMYzcEsD5Cob2f0tCXT+dbn0KQ== X-Received: by 2002:adf:e5cf:: with SMTP id a15mr3032786wrn.186.1603466408104; Fri, 23 Oct 2020 08:20:08 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id u5sm5127409wru.63.2020.10.23.08.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:20:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 09/10] pci: Let pci_dma_read() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:22 +0200 Message-Id: <20201023151923.3243652-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 01:44:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: Paolo Bonzini , Richard Henderson , Li Qiang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Li Qiang Reviewed-by: Richard Henderson 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 b8780ea18c1..85b5786a5da 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -800,8 +800,20 @@ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dma_addr_t addr, return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); } -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 Oct 23 15:19:23 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: 302166 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 3D5B0C388F9 for ; Fri, 23 Oct 2020 15:35:22 +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 887AD20E65 for ; Fri, 23 Oct 2020 15:35:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ga1Zally" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 887AD20E65 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]:33744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVz64-0004uq-SP for qemu-devel@archiver.kernel.org; Fri, 23 Oct 2020 11:35:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVyrh-0001x3-Tu for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVyrd-0000Eq-Se for qemu-devel@nongnu.org; Fri, 23 Oct 2020 11:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603466416; 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=/0HdXqasuvyDAja4v6/tCFJrk2r3CIc7i9rSuYrUflE=; b=Ga1ZallyO7YE1+ot2JGQ/pFqfIwS3bZeIIXUTQKm9+1XAnfp8zpshe1ETxGPcokgM/1OJK ZHnSTVsDNnE7tWtTyiOBdJa4NygF/PBZdFEWAOf9X2QIS76n5oFM/ll6uGVvYd034RAbXN prlIwzCDPxP/AkNnvxatVU4WCys6CMA= 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-573-fMyDinajMhSRVAsDqlWB-Q-1; Fri, 23 Oct 2020 11:20:14 -0400 X-MC-Unique: fMyDinajMhSRVAsDqlWB-Q-1 Received: by mail-wm1-f71.google.com with SMTP id g71so576087wmg.2 for ; Fri, 23 Oct 2020 08:20:14 -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=/0HdXqasuvyDAja4v6/tCFJrk2r3CIc7i9rSuYrUflE=; b=asStZkl1QOSsYQSFWip0Q4gL3sho6A/x1Mjnl0ab/u5o9T5LFMTcWKNBuP0P4g/MMG ep4cKfhSwZNSkq9OoAqa+/5iNSvbdYnocEH3tKeU6+cgSZch2F1J8ZsU4lI8CWjd3dzA OOD3hwg2ijQhLveaj3pswVxgvCxIlmMp+Ihs9j2nDWGOfK7758eJIN+2qjkIZCVvPmEu L1DIaUE/BrXFBcf6cu31ny7C12czYFTJwvosSgGs6w0GxKXA/9vPR+MqsOd9DUn8gAcI 1VaTJ5Bt/wY4YcZUdkVjfF/O+qJIJzK7klKU6iMliUHJq+xLDwhtm0AP4o0TxP3igB/k XRwQ== X-Gm-Message-State: AOAM530YxFp+bJFFYVzK8KlCKe/AkMDsSyIPYnp7Iny9FL9QkhIByqW6 ymnVai5FvsCAx/EC7iesredNiEfM2W/VlMyYdlmFD2Ngo234KK2kB3LJela4ivUU+OqC0XJoOLz YOTRzM6wEzyAAhIQ= X-Received: by 2002:a5d:554b:: with SMTP id g11mr3203213wrw.370.1603466412958; Fri, 23 Oct 2020 08:20:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIPJBT2WlqaT490gvAUxP6tkPk9PeFFqMFmnUTIRAqD96kS/GgvRZRGw68Z32jpbUhfCX+mg== X-Received: by 2002:a5d:554b:: with SMTP id g11mr3203195wrw.370.1603466412788; Fri, 23 Oct 2020 08:20:12 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id 40sm3981492wrc.46.2020.10.23.08.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 08:20:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH RESEND v3 10/10] pci: Let pci_dma_write() propagate MemTxResult Date: Fri, 23 Oct 2020 17:19:23 +0200 Message-Id: <20201023151923.3243652-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023151923.3243652-1-philmd@redhat.com> References: <20201023151923.3243652-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 01:44:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: Paolo Bonzini , Richard Henderson , Li Qiang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Li Qiang Reviewed-by: Richard Henderson 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 85b5786a5da..dd486cd941a 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -818,8 +818,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); }