From nobody Mon Feb 9 18:44:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1640912176; cv=none; d=zohomail.com; s=zohoarc; b=CkqnqFfxJDET1ITsOGznQlG+r1SrH+jVYIt1kgL/ldSGWIFDaEioP3M3SrPZ3k5rIPfVrMKkm91K2fcT9EnmogdnJUDFIDeuFxK79T2F5oIyMFoKrb0l0Rxk78VQSpg5ZRAMEF1OgjXQf2qDhNOgThzkkuzFeiPV7+TsUzr3mEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640912176; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=dhtB8Rb0RJXvMfRyBEm0cUWmMJM45WEukPox89NA3XE=; b=Wt7Wo76h9UdVv63tDeYHKfU2QkAEs18Zg28y3tkI20PzhDafw3onEYtfTvBpVDaAEIUmt8Xd+a2b9zl78vsh0c0C2WXTcT2IkGBtB+pF0zUNjgG2CIF17EcWEOd8rWfzS/ZhNiADJUd6U58YuxmyAnhMx82IhT1h62OHcfTcwsc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1640912176216405.1026066221; Thu, 30 Dec 2021 16:56:16 -0800 (PST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647--1TA7_3LPEmBQbTdUbK4Jw-1; Thu, 30 Dec 2021 19:56:14 -0500 Received: by mail-ed1-f69.google.com with SMTP id s12-20020a50ab0c000000b003efdf5a226fso18011568edc.10 for ; Thu, 30 Dec 2021 16:56:14 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (26.red-83-50-86.dynamicip.rima-tde.net. [83.50.86.26]) by smtp.gmail.com with ESMTPSA id mp9sm8066408ejc.106.2021.12.30.16.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Dec 2021 16:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640912175; 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=dhtB8Rb0RJXvMfRyBEm0cUWmMJM45WEukPox89NA3XE=; b=Di8slJy1V+nqbIg+RpQ/TwwmHzQhBQXQY16DmXkssSdFaQZ02g3MG2oJ3HpXGAb/fMArJV /L6vVj/BDKFFE+sJ65Z7YjiWLpRn6p5PqLLDzEllXm2nB3kmiYDCWxpahEKIeo7OA/7KQp RkI4CUJxLlDKUJ4F8vlP4UmU3Bfl1mI= X-MC-Unique: -1TA7_3LPEmBQbTdUbK4Jw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dhtB8Rb0RJXvMfRyBEm0cUWmMJM45WEukPox89NA3XE=; b=UoC5hf3sStzjBBECojC4ZBtnQKgoum9SVhAr0wKFLByfnufFNUC0z1TRlADGW9q1rB e5al5S8X1wyfANJQMfhMWHxQOPmG8xSYMyIQBHDhPK+cLBcUr7JuTzYYXPEp+7TaLRLv 4JpUonFnyYpzWynzVpghJL/5Ip+0LOrn7z0G/4Unng9p/G40BsoqukWJevqsoI5ClPAJ fbCWhk+SZmFwqE7qFMKzieku9Ob1Cz4BsJgorrAYu59kvXH996hZsl0lq2iKoR57Z372 2FOKLqQDk7Ezcw7rUR4BKT8fwH8DndXTiwqXRVt8+W7EsS/0QdmuY7tNvL0UdB4CxpdE pXtA== X-Gm-Message-State: AOAM532ZevlDeV9jK94NWE4MJkqqPSw9pDece+a//QLudLUIZiHVhlwL kdfcKxTINOkcJIr7aGeHUTx80YipZXMBFpsKOV8JkFMtFdJ9eBrurzvjdNkjPpLktFHEkgs34wY qUsDcivyPmTuB4w== X-Received: by 2002:a17:906:d554:: with SMTP id cr20mr26300868ejc.356.1640912173158; Thu, 30 Dec 2021 16:56:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyK14Pqs0BBiVLQujaqWUNCKPuQIepLlNEhmUZCYTdUNe8gMVCpxUfD8MzMRtr0r+PfPcXcmQ== X-Received: by 2002:a17:906:d554:: with SMTP id cr20mr26300854ejc.356.1640912172952; Thu, 30 Dec 2021 16:56:12 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Li Qiang , "Edgar E . Iglesias" , Stefan Hajnoczi Subject: [PULL 05/22] dma: Let dma_memory_rw() take MemTxAttrs argument Date: Fri, 31 Dec 2021 01:55:29 +0100 Message-Id: <20211231005546.723396-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211231005546.723396-1-philmd@redhat.com> References: <20211231005546.723396-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: 1640912179205000001 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 Acked-by: Stefan Hajnoczi Message-Id: <20211223115554.3155328-5-philmd@redhat.com> --- 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 e7cdf2d5ec5..4383f1c95e0 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -808,7 +808,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 4ec659b93e1..eae95c716f1 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.33.1