From nobody Mon Feb 9 17:25:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625217906; cv=none; d=zohomail.com; s=zohoarc; b=Pw/a8RwcpcJ7LqqgMYXArFFpjllpjCClckib+HFt1s2YRwdFIO4CFkX1YKB09tOpcraLt3C5/UT3VZPdnLg6p2ZfO8OfaPoRpFu2Nf+abDnnibaI9+0u4DIgi4V1V5kE5ekxK6LPQG8tN9eljAy+8NxDbqeGPsgx4JItVU6SF1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625217906; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2DiP3BDoXXRMG7E5lnGiuw8kLZOvB50ScwR/oV8195s=; b=KHzWlFpYlXx09bk+8KZ2oofhzyaRzlS1NdAaJxGKLgmpmUcb+TjZ72MsgG2465l76ijAF7al09X6K01oufAJpoI5jmQva6FT4MoAm/WuBkjVqRH2UDQVs/rPzCAadMax/JL8zr1RaUkCi7iOXKrunHR+xc4jwB7DoM2LaGRKqmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625217906210751.0264318248065; Fri, 2 Jul 2021 02:25:06 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-oLcUiHdoNgOVmK14wJL9QQ-1; Fri, 02 Jul 2021 05:25:02 -0400 Received: by mail-wr1-f72.google.com with SMTP id g4-20020a5d64e40000b029012469ad3be8so3701778wri.1 for ; Fri, 02 Jul 2021 02:25:01 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.Ascou-CH1 (pop.92-184-108-94.mobile.abo.orange.fr. [92.184.108.94]) by smtp.gmail.com with ESMTPSA id e15sm2537357wrm.60.2021.07.02.02.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 02:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625217905; 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=2DiP3BDoXXRMG7E5lnGiuw8kLZOvB50ScwR/oV8195s=; b=iSGTY6n5J09MNpbWq4kEXmJRzRTdFo5m13YFVLkZJaqjh/LPjU5BeP0lDxRV8wn19MZabg z/i2IQ+tbgfNBuo/MML13AvqVxEg8scZv4IdseTQF5QBPoSgx8Zh69hA92rhEL+Fg5e/KZ 200WIPqu5FdDKZeY+nWjs0QLoPa3kLY= X-MC-Unique: oLcUiHdoNgOVmK14wJL9QQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2DiP3BDoXXRMG7E5lnGiuw8kLZOvB50ScwR/oV8195s=; b=lHpQx9AbjjBNZ3BHMo6slbw9AUFX9gpocZm+NMCBkBUk7dFQ54OjSQgQnTc8jLGXw4 TjOD5B8675AeJsgv1+1xzKsdvVNzBsAgFCdyzjkBliRo07Vyqz+YznUbaC5ChRiCEhTn TRe3tNHnmZ0GnHLu+XpSbo61h6mIlaeNgIpPO33SAtelmUfkWmHIxLRFkeF03mWmzBId OjZFJ4iA5/t5zAQs/flwpDABdBnMFNP8PVBYop4x14hivG8p/2irDM9K4/7GkmBhplb6 UBt8WlCmyAPKU6MsETM9BVDNiM6FOKK4QyxgRJxCNRSC97LszOIaXhgborbiJo6V/xT7 4+7w== X-Gm-Message-State: AOAM530JgiLuIVw6XmOUMN7XRr1x47sd8aJBp2xCuDGqtTVQJE/3RYTl MMcXTT8gWVHW4BzXRIawowKZCkUJsNMT/lzK/0XI3snxUtTVXpYqUo7fDx7lc5XTAH6UWalap+w 1Gb4TuK0Q1Toovw== X-Received: by 2002:a05:600c:1c8b:: with SMTP id k11mr15337757wms.41.1625217900728; Fri, 02 Jul 2021 02:25:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd/h1IWfeKbPXwgQI9YWIVcyNxm+9KYo0T4u5NzIc2NbzpQ+KesS2RpoU641dzQaXk99hpcQ== X-Received: by 2002:a05:600c:1c8b:: with SMTP id k11mr15337740wms.41.1625217900574; Fri, 02 Jul 2021 02:25:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexander Bulekov , Stefan Hajnoczi , Mauro Matteo Cascella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Li Qiang , "Edgar E . Iglesias" Subject: [PATCH v3 4/6] dma: Let dma_memory_rw() take MemTxAttrs argument Date: Fri, 2 Jul 2021 11:24:37 +0200 Message-Id: <20210702092439.989969-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702092439.989969-1-philmd@redhat.com> References: <20210702092439.989969-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1625217907499100001 Let devices specify transaction attributes when calling dma_memory_rw(). Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 3 ++- include/sysemu/dma.h | 11 ++++++----- hw/intc/spapr_xive.c | 3 ++- hw/usb/hcd-ohci.c | 10 ++++++---- softmmu/dma-helpers.c | 3 ++- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6be4e0c460c..252c91686de 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -801,7 +801,8 @@ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dm= a_addr_t addr, void *buf, dma_addr_t len, DMADirection dir) { - return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); + return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, + dir, MEMTXATTRS_UNSPECIFIED); } =20 /** diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 3be803cf3ff..e8ad42226f6 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -121,15 +121,15 @@ static inline MemTxResult dma_memory_write_relaxed(Ad= dressSpace *as, * @buf: buffer with the data transferred * @len: the number of bytes to read or write * @dir: indicates the transfer direction + * @attrs: memory transaction attributes */ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, void *buf, dma_addr_t len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { dma_barrier(as, dir); =20 - return dma_memory_rw_relaxed(as, addr, buf, len, dir, - MEMTXATTRS_UNSPECIFIED); + return dma_memory_rw_relaxed(as, addr, buf, len, dir, attrs); } =20 /** @@ -147,7 +147,8 @@ static inline MemTxResult dma_memory_rw(AddressSpace *a= s, dma_addr_t addr, static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t add= r, void *buf, dma_addr_t len) { - return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); + return dma_memory_rw(as, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); } =20 /** @@ -166,7 +167,7 @@ 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); + DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED= ); } =20 /** diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 89cfa018f59..91e733e74cd 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -1684,7 +1684,8 @@ static target_ulong h_int_esb(PowerPCCPU *cpu, mmio_addr =3D xive->vc_base + xive_source_esb_mgmt(xsrc, lisn) + o= ffset; =20 if (dma_memory_rw(&address_space_memory, mmio_addr, &data, 8, - (flags & SPAPR_XIVE_ESB_STORE))) { + (flags & SPAPR_XIVE_ESB_STORE), + MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to access ESB @0x= %" HWADDR_PRIx "\n", mmio_addr); return H_HARDWARE; diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 1cf2816772c..56e2315c734 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -586,7 +586,8 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td= *td, if (n > len) n =3D len; =20 - if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) { + if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, + n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } if (n =3D=3D len) { @@ -595,7 +596,7 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td= *td, ptr =3D td->be & ~0xfffu; buf +=3D n; if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, - len - n, dir)) { + len - n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } return 0; @@ -613,7 +614,8 @@ static int ohci_copy_iso_td(OHCIState *ohci, if (n > len) n =3D len; =20 - if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) { + if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, + n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } if (n =3D=3D len) { @@ -622,7 +624,7 @@ static int ohci_copy_iso_td(OHCIState *ohci, ptr =3D end_addr & ~0xfffu; buf +=3D n; if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, - len - n, dir)) { + len - n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } return 0; diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 1f07217ad4a..5bf76fff6bd 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -305,7 +305,8 @@ static uint64_t dma_buf_rw(uint8_t *ptr, int32_t len, Q= EMUSGList *sg, while (len > 0) { ScatterGatherEntry entry =3D sg->sg[sg_cur_index++]; int32_t xfer =3D MIN(len, entry.len); - dma_memory_rw(sg->as, entry.base, ptr, xfer, dir); + dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, + MEMTXATTRS_UNSPECIFIED); ptr +=3D xfer; len -=3D xfer; resid -=3D xfer; --=20 2.31.1