From patchwork Thu Dec 23 11:55:32 2021 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: 12698156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8BCD2C433EF for ; Thu, 23 Dec 2021 12:10:07 +0000 (UTC) Received: from localhost ([::1]:52046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0Mv8-0000ss-ER for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:10:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mhv-0006Am-6m for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:56:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mhs-0000bh-NW for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:56:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260584; 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=DFluRvBp6z9QVaCBe8Ue+D5WXYJ9sfHm6PVL8XfDVUM=; b=IiY0ix8b8hNNbvlIUp807OJwaNtSYXMdiisgsS2RHogIau5kuj/8dd4tXds2lRcKJQZRsf FNwKDhfUcwTJKscMOToCwp/1/1mg9x2nq8cKJaDlNZS3FB5z0kvpT2GuCFSi6Vgjuy+4L9 TEEifZxB44FeTqrp1PYtgBCd6v66/Ww= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-J6zAEB5IOAmipWWUvESePQ-1; Thu, 23 Dec 2021 06:56:23 -0500 X-MC-Unique: J6zAEB5IOAmipWWUvESePQ-1 Received: by mail-wm1-f69.google.com with SMTP id r10-20020a1c440a000000b003456b2594e0so1925069wma.8 for ; Thu, 23 Dec 2021 03:56:22 -0800 (PST) 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=DFluRvBp6z9QVaCBe8Ue+D5WXYJ9sfHm6PVL8XfDVUM=; b=X6TNk1G+F6YwsTBwyyVyjBU7B/L4rdiDqPqfb/k12lJa11UiFnDfHk29QDKgV6yXQm EXHfhAU2C19coZvxwn78RFRGkQxXXIxX/Q7NiUQHA6BSrj3Uu5KWDMCQSZYo1RWILy4t HH3YzoAdQGMpIkTXEv6AUFQAZRvfzb2bs3VTYbVPxWUZpg7KbM8MMvZWh5YQH19vwyEf CRef/ev0dYIP4PM4g9JUZ1+KPlHSrwGCB7VgSABCfels1aGIVw6A7GhT5c27SAsed8pM KfNz0X/w+O7PXUJOgas8t1isVDUgR2GimT+X2qQr2ZxsJoczg+oP2d1/NHXEtLyEUHhl 64LA== X-Gm-Message-State: AOAM532yJQz/jftSUfcbLSaKKSwSdyiFQnBKz8rtWHarcIlE4hFgZB2T F7R/+YE53VnLTwHlfB+PhBU0AqAUQW9oS4z3zRYviBDoqriZwcDZv64Fw6EGylkvIaBBQmVX8uv fNVIfJMyRf5GLqR5Q/ZjMB00lu6RiuSXPX5mWUoRVWeSyRtLWYB32lmh4niKOWqkg X-Received: by 2002:a05:600c:24c:: with SMTP id 12mr1498491wmj.191.1640260581523; Thu, 23 Dec 2021 03:56:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBokRYK6ALM3HGg1JCXxCJgsw/1xEQICWEVfpoFNmRzR/YDKv4JTspeT2MSnEe13aTG1tZmQ== X-Received: by 2002:a05:600c:24c:: with SMTP id 12mr1498440wmj.191.1640260581327; Thu, 23 Dec 2021 03:56:21 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id g1sm4915702wri.103.2021.12.23.03.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:56:20 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 01/23] dma: Let dma_memory_valid() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:32 +0100 Message-Id: <20211223115554.3155328-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , "Edgar E . Iglesias" , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Li Qiang , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Stefan Hajnoczi , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_memory_valid(). Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Message-Id: <20210702092439.989969-2-philmd@redhat.com> --- include/hw/ppc/spapr_vio.h | 2 +- include/sysemu/dma.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 4bea87f39cc..4c45f1579fa 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -91,7 +91,7 @@ static inline void spapr_vio_irq_pulse(SpaprVioDevice *dev) static inline bool spapr_vio_dma_valid(SpaprVioDevice *dev, uint64_t taddr, uint32_t size, DMADirection dir) { - return dma_memory_valid(&dev->as, taddr, size, dir); + return dma_memory_valid(&dev->as, taddr, size, dir, MEMTXATTRS_UNSPECIFIED); } static inline int spapr_vio_dma_read(SpaprVioDevice *dev, uint64_t taddr, diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 3201e7901db..296f3b57c9c 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -73,11 +73,11 @@ static inline void dma_barrier(AddressSpace *as, DMADirection dir) * dma_memory_{read,write}() and check for errors */ static inline bool dma_memory_valid(AddressSpace *as, dma_addr_t addr, dma_addr_t len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { return address_space_access_valid(as, addr, len, dir == DMA_DIRECTION_FROM_DEVICE, - MEMTXATTRS_UNSPECIFIED); + attrs); } static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as, From patchwork Thu Dec 23 11:55:33 2021 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: 12698184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DF85BC433EF for ; Thu, 23 Dec 2021 12:19:53 +0000 (UTC) Received: from localhost ([::1]:48912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N4a-0002J4-Rv for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:19:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MiA-00076Q-KP for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:56:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mi7-0000cs-TZ for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:56:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260599; 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=jlgo6xDtAAtMm1rT3FU1HVvEVWIuXmrKi5ItJcLts/Y=; b=dAhNipthHWSZ4LSM2c+V2iWSmsJ1ASFjXgfgmCtHtavIj2/BFm/NkpQZiDhkFVYEL7Fk56 jU0Yg/yyVYMKLg2JmZ8r7hKXsXusdQ9XyXfNqFm6M+VHZBfKCxrvLCs5/Ftoe2XD/z9sBF Ra1qG4PsazvBpfn0GkYQ0fHq0N5VL4c= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-496-FoUuTvPJP0aKwKe3Qdj7-Q-1; Thu, 23 Dec 2021 06:56:38 -0500 X-MC-Unique: FoUuTvPJP0aKwKe3Qdj7-Q-1 Received: by mail-wm1-f72.google.com with SMTP id e19-20020a05600c4e5300b003458be97976so1855581wmq.7 for ; Thu, 23 Dec 2021 03:56:38 -0800 (PST) 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=jlgo6xDtAAtMm1rT3FU1HVvEVWIuXmrKi5ItJcLts/Y=; b=vcxbw6yktJ4683INKXivAZi0y57qvUb2bZA3UhVW0eWr1Z0FJfstUDezQ5lTKkYYMC V5/JhAQ+N1zQs5IwGLqSqiddVa9+mLlY0WsnFqY6447QmLGaBt4MmX40sZCoiIp4/PMy Rc5785+nQk3GAtdokSTDTIIBKMlE3wn6MoLwQBQBNzPguCp4Ooeo0yY1FGmv7jrlnCGS QP2bcqz6+1F1B/ukhP+iEv21d2u2H5HnGMjGag2hDF8JgwpAE7gfftYbs11dukVAxS/M cIaB1BXwmib1r7xQRh/j2SpZKzNYCRBVBbthnvyrqqhrKRg7h+pvBSAxe+/iGfQeQUCx ZAiA== X-Gm-Message-State: AOAM533ZpJjq6nBorBSq1BpKONpmw8Q0br9M3el/B9BoLAgJJA/55HKT gdaYWIseW0/D7D6GqRCJiVmPShzyQaGpDKuxirfqvSxaH0tKHxoDc4e6g80DJu00maWJqJwdS+Q l94uq8+30hUm9Qd6kYbWsmZsGx8kl4iTzGFizbAT9lwlkJFWOBNO9Ihuns1MeYEYu X-Received: by 2002:a05:6000:2a4:: with SMTP id l4mr1594858wry.460.1640260596873; Thu, 23 Dec 2021 03:56:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+Ey7SUV9I0TKAXOWeswCAbccTjbhckL2lEPtokKvCWMagMH2a6d15O+G84UjKapKM+9469A== X-Received: by 2002:a05:6000:2a4:: with SMTP id l4mr1594799wry.460.1640260596463; Thu, 23 Dec 2021 03:56:36 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id j14sm4775556wrn.88.2021.12.23.03.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:56:36 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 02/23] dma: Let dma_memory_set() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:33 +0100 Message-Id: <20211223115554.3155328-3-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , "Edgar E . Iglesias" , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Li Qiang , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Stefan Hajnoczi , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_memory_set(). Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Message-Id: <20210702092439.989969-3-philmd@redhat.com> --- include/hw/ppc/spapr_vio.h | 3 ++- include/sysemu/dma.h | 3 ++- hw/nvram/fw_cfg.c | 3 ++- softmmu/dma-helpers.c | 5 ++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 4c45f1579fa..c90e74a67dd 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -111,7 +111,8 @@ static inline int spapr_vio_dma_write(SpaprVioDevice *dev, uint64_t taddr, static inline int spapr_vio_dma_set(SpaprVioDevice *dev, uint64_t taddr, uint8_t c, uint32_t size) { - return (dma_memory_set(&dev->as, taddr, c, size) != 0) ? + return (dma_memory_set(&dev->as, taddr, + c, size, MEMTXATTRS_UNSPECIFIED) != 0) ? H_DEST_PARM : H_SUCCESS; } diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 296f3b57c9c..d23516f020a 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -175,9 +175,10 @@ static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t addr, * @addr: address within that address space * @c: constant byte to fill the memory * @len: the number of bytes to fill with the constant byte + * @attrs: memory transaction attributes */ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, - uint8_t c, dma_addr_t len); + uint8_t c, dma_addr_t len, MemTxAttrs attrs); /** * address_space_map: Map a physical memory region into a host virtual address. diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index c06b30de112..f7803fe3c30 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -399,7 +399,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) * tested before. */ if (read) { - if (dma_memory_set(s->dma_as, dma.address, 0, len)) { + if (dma_memory_set(s->dma_as, dma.address, 0, len, + MEMTXATTRS_UNSPECIFIED)) { dma.control |= FW_CFG_DMA_CTL_ERROR; } } diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 7d766a5e89a..1f07217ad4a 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -19,7 +19,7 @@ /* #define DEBUG_IOMMU */ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, - uint8_t c, dma_addr_t len) + uint8_t c, dma_addr_t len, MemTxAttrs attrs) { dma_barrier(as, DMA_DIRECTION_FROM_DEVICE); @@ -31,8 +31,7 @@ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, memset(fillbuf, c, FILLBUF_SIZE); while (len > 0) { l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE; - error |= address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED, - fillbuf, l); + error |= address_space_write(as, addr, attrs, fillbuf, l); len -= l; addr += l; } From patchwork Thu Dec 23 11:55:34 2021 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: 12698176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5A9CAC433F5 for ; Thu, 23 Dec 2021 12:13:53 +0000 (UTC) Received: from localhost ([::1]:59248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0Mym-0006e6-5R for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:13:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MiP-0007Xm-Lc for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:56:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MiM-0000fO-VN for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:56:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260614; 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=KD1bdQAKpfL3b0XM21dLq9IX92qtFC9hzQYY4WdApis=; b=Ojnccz3OCqjcPXsc2EQZs657efYaccJx5yvmYretYCeAQ0yWwQVSbYPuoMqLV4gR25ugLl BFXPvE0tOvBzI+F0IACTQ6TFkEJSxplyi0NyDoCAOoFGvaKxmukW6E+f17astA0QD+T9HR g87WkbAQYmq25HULeEfOCGVnGX8YB3U= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-R6UIgpE2MNmnetfxLLhNNg-1; Thu, 23 Dec 2021 06:56:53 -0500 X-MC-Unique: R6UIgpE2MNmnetfxLLhNNg-1 Received: by mail-wm1-f70.google.com with SMTP id 64-20020a1c0443000000b00345d1448d3aso307310wme.9 for ; Thu, 23 Dec 2021 03:56:53 -0800 (PST) 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=KD1bdQAKpfL3b0XM21dLq9IX92qtFC9hzQYY4WdApis=; b=Ml4HzLoVVlCQtB2gvhy1ZURFPWnBptMIxK9sQhx0kpqRkAizVlZ/yEeOey6k3+Dug/ qmuhD/RNsaz+dspKRcqgCuYwovYsnpmO+ony+7QL8Yev3+91rvFK6Ex1Ozrun7Eo+UWv +7ono9CZOOfbMHS8rAV+yBI2AQ0sG7fQfIZlhz4QJjcF8VbDRRlPdxX2zFSE/Z7Yew8Z 1DlLOo2c3Y8P4+IUsYDF5204zGaMGQAkclENEqD7WP5bcE7d5vCj6HwcI/5IJByD9UJh ImWEVzCJMDHv8winF9aZWITlJjkJKIPCDlqSXG+84Soa4LkeYwzKK1/xFpY9hG8xEDUf 1IBQ== X-Gm-Message-State: AOAM531Re/aURzkK3U3PAMk+4c5lWkSgSPs7Vic4DPitJaJitzVd3Qkk rZxuntGNTDnHRg5Nr/j1ZfYFtHKOJvmFyBifPEaDJaJqkLdDa0MQiMFFRP5a84+IcpEHtPii44W +tWrojnThTFRyFA/GEchBEDOPQswRhSU2+CdzMnZwb3tjwx7k7rC74Ejnqahd35SD X-Received: by 2002:a7b:c397:: with SMTP id s23mr1557503wmj.183.1640260611933; Thu, 23 Dec 2021 03:56:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzu7mXK63Rruez1aXJEdASH8IPRR0dIq17cEOuTuIdV4IcRI4qs6NE2ZCrCWSnYx4KCXywfbA== X-Received: by 2002:a7b:c397:: with SMTP id s23mr1557451wmj.183.1640260611654; Thu, 23 Dec 2021 03:56:51 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id n7sm4764633wms.45.2021.12.23.03.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:56:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 03/23] dma: Let dma_memory_rw_relaxed() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:34 +0100 Message-Id: <20211223115554.3155328-4-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , "Edgar E . Iglesias" , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Li Qiang , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Stefan Hajnoczi , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We will add the MemTxAttrs argument to dma_memory_rw() in the next commit. Since dma_memory_rw_relaxed() is only used by dma_memory_rw(), modify it first in a separate commit to keep the next commit easier to review. Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Message-Id: <20210702092439.989969-4-philmd@redhat.com> --- include/sysemu/dma.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index d23516f020a..3be803cf3ff 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -83,9 +83,10 @@ static inline bool dma_memory_valid(AddressSpace *as, static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, void *buf, dma_addr_t len, - DMADirection dir) + DMADirection dir, + MemTxAttrs attrs) { - return address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, + return address_space_rw(as, addr, attrs, buf, len, dir == DMA_DIRECTION_FROM_DEVICE); } @@ -93,7 +94,9 @@ 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); + return dma_memory_rw_relaxed(as, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); } static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as, @@ -102,7 +105,8 @@ static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as, dma_addr_t len) { return dma_memory_rw_relaxed(as, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE); + DMA_DIRECTION_FROM_DEVICE, + MEMTXATTRS_UNSPECIFIED); } /** @@ -124,7 +128,8 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, { dma_barrier(as, dir); - return dma_memory_rw_relaxed(as, addr, buf, len, dir); + return dma_memory_rw_relaxed(as, addr, buf, len, dir, + MEMTXATTRS_UNSPECIFIED); } /** From patchwork Thu Dec 23 11:55:35 2021 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: 12698177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 910F0C433EF for ; Thu, 23 Dec 2021 12:14:57 +0000 (UTC) Received: from localhost ([::1]:35586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0Mzo-0001Np-JK for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:14:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mil-00088L-81 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mif-0000gp-Ge for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260628; 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=HwK3nqfcp7ajpjlyQIleJtZhiHK+GpsKt7kR5zBRhFA=; b=hHP0jS8zn16Virp3/3lWWGa+oSTFby53t/vaVA3xuUPtZ6kWmN7umZAHpg7gdHF1bFP2Em y+PTN11AKGF6LqE84hf8J0X9XtHW5B4KWM4U4khd6u/eXqGO2Gpr8ZQJb4HhgwIFlPIvby XCEMMgqKTUfa9J4P4+oGHrup4KgFQZY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-fEjaH-LgMiuoUTOCFkJ-vw-1; Thu, 23 Dec 2021 06:57:07 -0500 X-MC-Unique: fEjaH-LgMiuoUTOCFkJ-vw-1 Received: by mail-wr1-f70.google.com with SMTP id h7-20020adfaa87000000b001885269a937so1222961wrc.17 for ; Thu, 23 Dec 2021 03:57:07 -0800 (PST) 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=HwK3nqfcp7ajpjlyQIleJtZhiHK+GpsKt7kR5zBRhFA=; b=MAdxU8B0Ge+Vr4w4paSPzz/MwUDa1Q8AIauoNc14zlAUg2s+5S5eCoxZV7AQQUX52c 6VvNkorLBUx4n1tLOXVi5t0PyKsvvv08YfKbn19/EoVtOROqKV4PjwR3HOUv7S95M2gK pvGQ6MM0M7xt9F/row+CQ/V+Xd//1EO53V2XqQH2a6bU/o7pYbGYWZT9nJ5b5sfOy0Tn KPrZ+vbiZV3i8qFFwNFWJUVbI/tc7jGqENAaS0ET0bI6dUZiv+UToFAodJ9H5YQRvTRS WNRlFUSrdOV6mQNHhET44Qlg+oQHZy9HZp5mvtOn5yRNCIwJM6WnuC4r4k4ABDd1Vmke qjlQ== X-Gm-Message-State: AOAM531iwGqcjV7Wr7b/1I4WJHxxxMxSQBOcDgmf6JVTw1YObiFy6MJ3 odCRN4f8nbdejSbqGGdh4jRcA3uMwMyr/X8xd+tNuxyeh5uu9fPrt/lqG7f4H1xCch3gxVTXdx5 9g30jvrtbELvFuS2ZkxKQ3joSHxg8IsTvKyyS0TOM3BgEIN+MWYTtKga+n+Wy6NsY X-Received: by 2002:a05:600c:198f:: with SMTP id t15mr1263008wmq.154.1640260626450; Thu, 23 Dec 2021 03:57:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpC4AfdLuRVOeZqOp/4uwrhySTDI8YmyN1ZbDx1U0CdC5jvAqSmacuvA9ZC6QN9i4GMsZJKA== X-Received: by 2002:a05:600c:198f:: with SMTP id t15mr1262951wmq.154.1640260626154; Thu, 23 Dec 2021 03:57:06 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id u12sm4746187wrf.60.2021.12.23.03.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:57:05 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/23] dma: Let dma_memory_rw() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:35 +0100 Message-Id: <20211223115554.3155328-5-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , "Edgar E . Iglesias" , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Li Qiang , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Stefan Hajnoczi , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é Acked-by: Stefan Hajnoczi Message-Id: <20210702092439.989969-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, 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); + return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, + dir, MEMTXATTRS_UNSPECIFIED); } /** 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(AddressSpace *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); - return dma_memory_rw_relaxed(as, addr, buf, len, dir, - MEMTXATTRS_UNSPECIFIED); + return dma_memory_rw_relaxed(as, addr, buf, len, dir, attrs); } /** @@ -147,7 +147,8 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, 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); + return dma_memory_rw(as, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); } /** @@ -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); } /** 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 = xive->vc_base + xive_source_esb_mgmt(xsrc, lisn) + offset; 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 = len; - 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 == len) { @@ -595,7 +596,7 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td *td, ptr = td->be & ~0xfffu; buf += 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 = len; - 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 == len) { @@ -622,7 +624,7 @@ static int ohci_copy_iso_td(OHCIState *ohci, ptr = end_addr & ~0xfffu; buf += 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, QEMUSGList *sg, while (len > 0) { ScatterGatherEntry entry = sg->sg[sg_cur_index++]; int32_t xfer = 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 += xfer; len -= xfer; resid -= xfer; From patchwork Thu Dec 23 11:55:36 2021 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: 12698153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C17F7C433EF for ; Thu, 23 Dec 2021 12:05:21 +0000 (UTC) Received: from localhost ([::1]:42924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0MqW-0002bV-SY for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:05:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MjG-0008Ty-BQ for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mj9-0000m8-GD for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260663; 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=RwF7Hydt72MLd+h7tygAE+WQhwLabakzsRCPQMGSHpY=; b=BkNucblYrJzRDhk2XXyDbjWm6NislTaewtIIg04Po6oNsH/xmSuNH22IFUoHKAkvu1Y3Gu JHmz7qg28oqs72j9t/RZH3t5UJBkP1Yi8nzkGNkkI6MOkzq9JSUeZ/XqXAAeyo/0jLRzAM X7TZaFvCG7PtTiR9GaWWe1WbXsoZfFs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-330-tsoVqS5aPYK8fqe39lMNEw-1; Thu, 23 Dec 2021 06:57:24 -0500 X-MC-Unique: tsoVqS5aPYK8fqe39lMNEw-1 Received: by mail-wm1-f70.google.com with SMTP id u10-20020a05600c19ca00b00345b2959e5aso1852299wmq.9 for ; Thu, 23 Dec 2021 03:57:23 -0800 (PST) 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=RwF7Hydt72MLd+h7tygAE+WQhwLabakzsRCPQMGSHpY=; b=7O7CWeOOy3jibrCCUT0QgMd0Lnr6QArubpupf5UnZ8qj/WjveN/TTQ+8cmjy255Qzi N09lVce/alocIkhnMhds0ipiVM8kqu289fcGoQ7oo4O2a8d5+W0EoNvVzpoflR7CloKp MGdFG9th4eQAfp2pieYGb0XYayeLDQEouaZfHGQljzd+c/Pe2JLVKwxKvGdFBM8uys6e MWS9agf9PWj5wNF97rcSlTXXpCrvo4OG9KC/DSS+fwywzPuWu7+irHoCRrBlNHGyXjwC xXfVHDer8FWyN+ZrvmE5enGR0Ce1Bx+FVmxXz4wPgucQKrjg0gH9Na3oste6u9PC4e02 cGew== X-Gm-Message-State: AOAM530R9+T7e7Hqube8xanlVHKy+kqCEl36p1OBfdb2tyP2BXQlChYT c3FgS4EO/5A2uje5cGHj1IFtu8k5Xp2fiZUp06c7pumVhSsylR7iPtrw/Nokb7NZ3fDJaAmPTBp xJRlUZU2oXqVBiGHFoCTlFRL9PDeBe1Po1KQjGi9q2MkZ095jSWviqZiWhE+HjYe/ X-Received: by 2002:a05:6000:2a4:: with SMTP id l4mr1596831wry.460.1640260641924; Thu, 23 Dec 2021 03:57:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQdn1loSY+N3t/8sy9L/YOA/kPkeGNsK5O1OLQtGKhhtZ9U3yPlMXNAnZh9m1LK6Hhs+ASBg== X-Received: by 2002:a05:6000:2a4:: with SMTP id l4mr1596734wry.460.1640260640713; Thu, 23 Dec 2021 03:57:20 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id u23sm4247553wmc.7.2021.12.23.03.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:57:20 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/23] dma: Let dma_memory_read/write() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:36 +0100 Message-Id: <20211223115554.3155328-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , "Edgar E . Iglesias" , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Li Qiang , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Stefan Hajnoczi , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_memory_read() or dma_memory_write(). Patch created mechanically using spatch with this script: @@ expression E1, E2, E3, E4; @@ ( - dma_memory_read(E1, E2, E3, E4) + dma_memory_read(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED) | - dma_memory_write(E1, E2, E3, E4) + dma_memory_write(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED) ) Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Message-Id: <20210702092439.989969-6-philmd@redhat.com> --- v4: Merged conflict in hw/dma/pl330.c --- include/hw/ppc/spapr_vio.h | 6 ++++-- include/sysemu/dma.h | 20 ++++++++++++-------- hw/arm/musicpal.c | 13 +++++++------ hw/arm/smmu-common.c | 3 ++- hw/arm/smmuv3.c | 14 +++++++++----- hw/core/generic-loader.c | 3 ++- hw/dma/pl330.c | 12 ++++++++---- hw/dma/sparc32_dma.c | 16 ++++++++++------ hw/dma/xlnx-zynq-devcfg.c | 6 ++++-- hw/dma/xlnx_dpdma.c | 10 ++++++---- hw/i386/amd_iommu.c | 16 +++++++++------- hw/i386/intel_iommu.c | 28 +++++++++++++++++----------- hw/ide/macio.c | 2 +- hw/intc/xive.c | 7 ++++--- hw/misc/bcm2835_property.c | 3 ++- hw/misc/macio/mac_dbdma.c | 10 ++++++---- hw/net/allwinner-sun8i-emac.c | 18 ++++++++++++------ hw/net/ftgmac100.c | 25 ++++++++++++++++--------- hw/net/imx_fec.c | 32 ++++++++++++++++++++------------ hw/net/npcm7xx_emc.c | 20 ++++++++++++-------- hw/nvram/fw_cfg.c | 9 ++++++--- hw/pci-host/pnv_phb3.c | 5 +++-- hw/pci-host/pnv_phb3_msi.c | 9 ++++++--- hw/pci-host/pnv_phb4.c | 5 +++-- hw/sd/allwinner-sdhost.c | 14 ++++++++------ hw/sd/sdhci.c | 35 ++++++++++++++++++++++------------- hw/usb/hcd-dwc2.c | 8 ++++---- hw/usb/hcd-ehci.c | 6 ++++-- hw/usb/hcd-ohci.c | 18 +++++++++++------- hw/usb/hcd-xhci.c | 18 +++++++++++------- 30 files changed, 241 insertions(+), 150 deletions(-) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index c90e74a67dd..5d2ea8e6656 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -97,14 +97,16 @@ static inline bool spapr_vio_dma_valid(SpaprVioDevice *dev, uint64_t taddr, static inline int spapr_vio_dma_read(SpaprVioDevice *dev, uint64_t taddr, void *buf, uint32_t size) { - return (dma_memory_read(&dev->as, taddr, buf, size) != 0) ? + return (dma_memory_read(&dev->as, taddr, + buf, size, MEMTXATTRS_UNSPECIFIED) != 0) ? H_DEST_PARM : H_SUCCESS; } static inline int spapr_vio_dma_write(SpaprVioDevice *dev, uint64_t taddr, const void *buf, uint32_t size) { - return (dma_memory_write(&dev->as, taddr, buf, size) != 0) ? + return (dma_memory_write(&dev->as, taddr, + buf, size, MEMTXATTRS_UNSPECIFIED) != 0) ? H_DEST_PARM : H_SUCCESS; } diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index e8ad42226f6..522682bf386 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -143,12 +143,14 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr, * @addr: address within that address space * @buf: buffer with the data transferred * @len: length of the data transferred + * @attrs: memory transaction attributes */ static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len) + void *buf, dma_addr_t len, + MemTxAttrs attrs) { return dma_memory_rw(as, addr, buf, len, - DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); + DMA_DIRECTION_TO_DEVICE, attrs); } /** @@ -162,12 +164,14 @@ static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr, * @addr: address within that address space * @buf: buffer with the data transferred * @len: the number of bytes to write + * @attrs: memory transaction attributes */ static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t addr, - const void *buf, dma_addr_t len) + const void *buf, dma_addr_t len, + MemTxAttrs attrs) { return dma_memory_rw(as, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED); + DMA_DIRECTION_FROM_DEVICE, attrs); } /** @@ -239,7 +243,7 @@ static inline void dma_memory_unmap(AddressSpace *as, dma_addr_t addr) \ { \ uint##_bits##_t val; \ - dma_memory_read(as, addr, &val, (_bits) / 8); \ + dma_memory_read(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIED); \ return _end##_bits##_to_cpu(val); \ } \ static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ @@ -247,20 +251,20 @@ static inline void dma_memory_unmap(AddressSpace *as, uint##_bits##_t val) \ { \ val = cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8); \ + dma_memory_write(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIED); \ } static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr) { uint8_t val; - dma_memory_read(as, addr, &val, 1); + dma_memory_read(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); return val; } static inline void stb_dma(AddressSpace *as, dma_addr_t addr, uint8_t val) { - dma_memory_write(as, addr, &val, 1); + dma_memory_write(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); } DEFINE_LDST_DMA(uw, w, 16, le); diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index 2d612cc0c9b..2680ec55b5a 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -185,13 +185,13 @@ static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr, cpu_to_le16s(&desc->buffer_size); cpu_to_le32s(&desc->buffer); cpu_to_le32s(&desc->next); - dma_memory_write(dma_as, addr, desc, sizeof(*desc)); + dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); } static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr, mv88w8618_rx_desc *desc) { - dma_memory_read(dma_as, addr, desc, sizeof(*desc)); + dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); le32_to_cpus(&desc->cmdstat); le16_to_cpus(&desc->bytes); le16_to_cpus(&desc->buffer_size); @@ -215,7 +215,7 @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size) eth_rx_desc_get(&s->dma_as, desc_addr, &desc); if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) { dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header, - buf, size); + buf, size, MEMTXATTRS_UNSPECIFIED); desc.bytes = size + s->vlan_header; desc.cmdstat &= ~MP_ETH_RX_OWN; s->cur_rx[i] = desc.next; @@ -241,13 +241,13 @@ static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr, cpu_to_le16s(&desc->bytes); cpu_to_le32s(&desc->buffer); cpu_to_le32s(&desc->next); - dma_memory_write(dma_as, addr, desc, sizeof(*desc)); + dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); } static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr, mv88w8618_tx_desc *desc) { - dma_memory_read(dma_as, addr, desc, sizeof(*desc)); + dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); le32_to_cpus(&desc->cmdstat); le16_to_cpus(&desc->res); le16_to_cpus(&desc->bytes); @@ -269,7 +269,8 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index) if (desc.cmdstat & MP_ETH_TX_OWN) { len = desc.bytes; if (len < 2048) { - dma_memory_read(&s->dma_as, desc.buffer, buf, len); + dma_memory_read(&s->dma_as, desc.buffer, buf, len, + MEMTXATTRS_UNSPECIFIED); qemu_send_packet(qemu_get_queue(s->nic), buf, len); } desc.cmdstat &= ~MP_ETH_TX_OWN; diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 0459850a93d..e09b9c13b74 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -193,7 +193,8 @@ static int get_pte(dma_addr_t baseaddr, uint32_t index, uint64_t *pte, dma_addr_t addr = baseaddr + index * sizeof(*pte); /* TODO: guarantee 64-bit single-copy atomicity */ - ret = dma_memory_read(&address_space_memory, addr, pte, sizeof(*pte)); + ret = dma_memory_read(&address_space_memory, addr, pte, sizeof(*pte), + MEMTXATTRS_UNSPECIFIED); if (ret != MEMTX_OK) { info->type = SMMU_PTW_ERR_WALK_EABT; diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 01b60bee495..3b43368be0f 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -102,7 +102,8 @@ static inline MemTxResult queue_read(SMMUQueue *q, void *data) { dma_addr_t addr = Q_CONS_ENTRY(q); - return dma_memory_read(&address_space_memory, addr, data, q->entry_size); + return dma_memory_read(&address_space_memory, addr, data, q->entry_size, + MEMTXATTRS_UNSPECIFIED); } static MemTxResult queue_write(SMMUQueue *q, void *data) @@ -110,7 +111,8 @@ static MemTxResult queue_write(SMMUQueue *q, void *data) dma_addr_t addr = Q_PROD_ENTRY(q); MemTxResult ret; - ret = dma_memory_write(&address_space_memory, addr, data, q->entry_size); + ret = dma_memory_write(&address_space_memory, addr, data, q->entry_size, + MEMTXATTRS_UNSPECIFIED); if (ret != MEMTX_OK) { return ret; } @@ -285,7 +287,8 @@ static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf, trace_smmuv3_get_ste(addr); /* TODO: guarantee 64-bit single-copy atomicity */ - ret = dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf)); + ret = dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf), + MEMTXATTRS_UNSPECIFIED); if (ret != MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "Cannot fetch pte at address=0x%"PRIx64"\n", addr); @@ -306,7 +309,8 @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid, trace_smmuv3_get_cd(addr); /* TODO: guarantee 64-bit single-copy atomicity */ - ret = dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf)); + ret = dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf), + MEMTXATTRS_UNSPECIFIED); if (ret != MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "Cannot fetch pte at address=0x%"PRIx64"\n", addr); @@ -411,7 +415,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, l1ptr = (dma_addr_t)(strtab_base + l1_ste_offset * sizeof(l1std)); /* TODO: guarantee 64-bit single-copy atomicity */ ret = dma_memory_read(&address_space_memory, l1ptr, &l1std, - sizeof(l1std)); + sizeof(l1std), MEMTXATTRS_UNSPECIFIED); if (ret != MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "Could not read L1PTR at 0X%"PRIx64"\n", l1ptr); diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index d14f932eea2..9a24ffb8806 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -57,7 +57,8 @@ static void generic_loader_reset(void *opaque) if (s->data_len) { assert(s->data_len < sizeof(s->data)); - dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len); + dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len, + MEMTXATTRS_UNSPECIFIED); } } diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c index 0cb46191c19..31ce01b7c57 100644 --- a/hw/dma/pl330.c +++ b/hw/dma/pl330.c @@ -1111,7 +1111,8 @@ static inline const PL330InsnDesc *pl330_fetch_insn(PL330Chan *ch) uint8_t opcode; int i; - dma_memory_read(ch->parent->mem_as, ch->pc, &opcode, 1); + dma_memory_read(ch->parent->mem_as, ch->pc, &opcode, 1, + MEMTXATTRS_UNSPECIFIED); for (i = 0; insn_desc[i].size; i++) { if ((opcode & insn_desc[i].opmask) == insn_desc[i].opcode) { return &insn_desc[i]; @@ -1125,7 +1126,8 @@ static inline void pl330_exec_insn(PL330Chan *ch, const PL330InsnDesc *insn) uint8_t buf[PL330_INSN_MAXSIZE]; assert(insn->size <= PL330_INSN_MAXSIZE); - dma_memory_read(ch->parent->mem_as, ch->pc, buf, insn->size); + dma_memory_read(ch->parent->mem_as, ch->pc, buf, insn->size, + MEMTXATTRS_UNSPECIFIED); insn->exec(ch, buf[0], &buf[1], insn->size - 1); } @@ -1189,7 +1191,8 @@ static int pl330_exec_cycle(PL330Chan *channel) if (q != NULL && q->len <= pl330_fifo_num_free(&s->fifo)) { int len = q->len - (q->addr & (q->len - 1)); - dma_memory_read(s->mem_as, q->addr, buf, len); + dma_memory_read(s->mem_as, q->addr, buf, len, + MEMTXATTRS_UNSPECIFIED); trace_pl330_exec_cycle(q->addr, len); if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { pl330_hexdump(buf, len); @@ -1220,7 +1223,8 @@ static int pl330_exec_cycle(PL330Chan *channel) fifo_res = pl330_fifo_get(&s->fifo, buf, len, q->tag); } if (fifo_res == PL330_FIFO_OK || q->z) { - dma_memory_write(s->mem_as, q->addr, buf, len); + dma_memory_write(s->mem_as, q->addr, buf, len, + MEMTXATTRS_UNSPECIFIED); trace_pl330_exec_cycle(q->addr, len); if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { pl330_hexdump(buf, len); diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index 03bc500878f..0ef13c5e9a8 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -81,11 +81,11 @@ void ledma_memory_read(void *opaque, hwaddr addr, addr |= s->dmaregs[3]; trace_ledma_memory_read(addr, len); if (do_bswap) { - dma_memory_read(&is->iommu_as, addr, buf, len); + dma_memory_read(&is->iommu_as, addr, buf, len, MEMTXATTRS_UNSPECIFIED); } else { addr &= ~1; len &= ~1; - dma_memory_read(&is->iommu_as, addr, buf, len); + dma_memory_read(&is->iommu_as, addr, buf, len, MEMTXATTRS_UNSPECIFIED); for(i = 0; i < len; i += 2) { bswap16s((uint16_t *)(buf + i)); } @@ -103,7 +103,8 @@ void ledma_memory_write(void *opaque, hwaddr addr, addr |= s->dmaregs[3]; trace_ledma_memory_write(addr, len); if (do_bswap) { - dma_memory_write(&is->iommu_as, addr, buf, len); + dma_memory_write(&is->iommu_as, addr, buf, len, + MEMTXATTRS_UNSPECIFIED); } else { addr &= ~1; len &= ~1; @@ -114,7 +115,8 @@ void ledma_memory_write(void *opaque, hwaddr addr, for(i = 0; i < l; i += 2) { tmp_buf[i >> 1] = bswap16(*(uint16_t *)(buf + i)); } - dma_memory_write(&is->iommu_as, addr, tmp_buf, l); + dma_memory_write(&is->iommu_as, addr, tmp_buf, l, + MEMTXATTRS_UNSPECIFIED); len -= l; buf += l; addr += l; @@ -148,7 +150,8 @@ void espdma_memory_read(void *opaque, uint8_t *buf, int len) IOMMUState *is = (IOMMUState *)s->iommu; trace_espdma_memory_read(s->dmaregs[1], len); - dma_memory_read(&is->iommu_as, s->dmaregs[1], buf, len); + dma_memory_read(&is->iommu_as, s->dmaregs[1], buf, len, + MEMTXATTRS_UNSPECIFIED); s->dmaregs[1] += len; } @@ -158,7 +161,8 @@ void espdma_memory_write(void *opaque, uint8_t *buf, int len) IOMMUState *is = (IOMMUState *)s->iommu; trace_espdma_memory_write(s->dmaregs[1], len); - dma_memory_write(&is->iommu_as, s->dmaregs[1], buf, len); + dma_memory_write(&is->iommu_as, s->dmaregs[1], buf, len, + MEMTXATTRS_UNSPECIFIED); s->dmaregs[1] += len; } diff --git a/hw/dma/xlnx-zynq-devcfg.c b/hw/dma/xlnx-zynq-devcfg.c index e33112b6f0e..f5ad1a0d22c 100644 --- a/hw/dma/xlnx-zynq-devcfg.c +++ b/hw/dma/xlnx-zynq-devcfg.c @@ -161,12 +161,14 @@ static void xlnx_zynq_devcfg_dma_go(XlnxZynqDevcfg *s) btt = MIN(btt, dmah->dest_len); } DB_PRINT("reading %x bytes from %x\n", btt, dmah->src_addr); - dma_memory_read(&address_space_memory, dmah->src_addr, buf, btt); + dma_memory_read(&address_space_memory, dmah->src_addr, buf, btt, + MEMTXATTRS_UNSPECIFIED); dmah->src_len -= btt; dmah->src_addr += btt; if (loopback && (dmah->src_len || dmah->dest_len)) { DB_PRINT("writing %x bytes from %x\n", btt, dmah->dest_addr); - dma_memory_write(&address_space_memory, dmah->dest_addr, buf, btt); + dma_memory_write(&address_space_memory, dmah->dest_addr, buf, btt, + MEMTXATTRS_UNSPECIFIED); dmah->dest_len -= btt; dmah->dest_addr += btt; } diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c index 967548abd31..2d7eae72cd2 100644 --- a/hw/dma/xlnx_dpdma.c +++ b/hw/dma/xlnx_dpdma.c @@ -652,7 +652,7 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, uint8_t channel, } if (dma_memory_read(&address_space_memory, desc_addr, &desc, - sizeof(DPDMADescriptor))) { + sizeof(DPDMADescriptor), MEMTXATTRS_UNSPECIFIED)) { s->registers[DPDMA_EISR] |= ((1 << 1) << channel); xlnx_dpdma_update_irq(s); s->operation_finished[channel] = true; @@ -708,7 +708,8 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, uint8_t channel, if (dma_memory_read(&address_space_memory, source_addr[0], &s->data[channel][ptr], - line_size)) { + line_size, + MEMTXATTRS_UNSPECIFIED)) { s->registers[DPDMA_ISR] |= ((1 << 12) << channel); xlnx_dpdma_update_irq(s); DPRINTF("Can't get data.\n"); @@ -736,7 +737,8 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, uint8_t channel, if (dma_memory_read(&address_space_memory, source_addr[frag], &(s->data[channel][ptr]), - fragment_len)) { + fragment_len, + MEMTXATTRS_UNSPECIFIED)) { s->registers[DPDMA_ISR] |= ((1 << 12) << channel); xlnx_dpdma_update_irq(s); DPRINTF("Can't get data.\n"); @@ -754,7 +756,7 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, uint8_t channel, DPRINTF("update the descriptor with the done flag set.\n"); xlnx_dpdma_desc_set_done(&desc); dma_memory_write(&address_space_memory, desc_addr, &desc, - sizeof(DPDMADescriptor)); + sizeof(DPDMADescriptor), MEMTXATTRS_UNSPECIFIED); } if (xlnx_dpdma_desc_completion_interrupt(&desc)) { diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 91fe34ae589..4d13d8e6973 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -181,7 +181,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *evt) } if (dma_memory_write(&address_space_memory, s->evtlog + s->evtlog_tail, - evt, AMDVI_EVENT_LEN)) { + evt, AMDVI_EVENT_LEN, MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_evntlog_fail(s->evtlog, s->evtlog_tail); } @@ -376,7 +376,8 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd) } if (extract64(cmd[0], 0, 1)) { if (dma_memory_write(&address_space_memory, addr, &data, - AMDVI_COMPLETION_DATA_SIZE)) { + AMDVI_COMPLETION_DATA_SIZE, + MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_completion_wait_fail(addr); } } @@ -502,7 +503,7 @@ static void amdvi_cmdbuf_exec(AMDVIState *s) uint64_t cmd[2]; if (dma_memory_read(&address_space_memory, s->cmdbuf + s->cmdbuf_head, - cmd, AMDVI_COMMAND_SIZE)) { + cmd, AMDVI_COMMAND_SIZE, MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_command_read_fail(s->cmdbuf, s->cmdbuf_head); amdvi_log_command_error(s, s->cmdbuf + s->cmdbuf_head); return; @@ -836,7 +837,7 @@ static bool amdvi_get_dte(AMDVIState *s, int devid, uint64_t *entry) uint32_t offset = devid * AMDVI_DEVTAB_ENTRY_SIZE; if (dma_memory_read(&address_space_memory, s->devtab + offset, entry, - AMDVI_DEVTAB_ENTRY_SIZE)) { + AMDVI_DEVTAB_ENTRY_SIZE, MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_dte_get_fail(s->devtab, offset); /* log error accessing dte */ amdvi_log_devtab_error(s, devid, s->devtab + offset, 0); @@ -881,7 +882,8 @@ static inline uint64_t amdvi_get_pte_entry(AMDVIState *s, uint64_t pte_addr, { uint64_t pte; - if (dma_memory_read(&address_space_memory, pte_addr, &pte, sizeof(pte))) { + if (dma_memory_read(&address_space_memory, pte_addr, + &pte, sizeof(pte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_get_pte_hwerror(pte_addr); amdvi_log_pagetab_error(s, devid, pte_addr, 0); pte = 0; @@ -1048,7 +1050,7 @@ static int amdvi_get_irte(AMDVIState *s, MSIMessage *origin, uint64_t *dte, trace_amdvi_ir_irte(irte_root, offset); if (dma_memory_read(&address_space_memory, irte_root + offset, - irte, sizeof(*irte))) { + irte, sizeof(*irte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_ir_err("failed to get irte"); return -AMDVI_IR_GET_IRTE; } @@ -1108,7 +1110,7 @@ static int amdvi_get_irte_ga(AMDVIState *s, MSIMessage *origin, uint64_t *dte, trace_amdvi_ir_irte(irte_root, offset); if (dma_memory_read(&address_space_memory, irte_root + offset, - irte, sizeof(*irte))) { + irte, sizeof(*irte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_ir_err("failed to get irte_ga"); return -AMDVI_IR_GET_IRTE; } diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index f584449d8d1..5b865ac08c0 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -569,7 +569,8 @@ static int vtd_get_root_entry(IntelIOMMUState *s, uint8_t index, dma_addr_t addr; addr = s->root + index * sizeof(*re); - if (dma_memory_read(&address_space_memory, addr, re, sizeof(*re))) { + if (dma_memory_read(&address_space_memory, addr, + re, sizeof(*re), MEMTXATTRS_UNSPECIFIED)) { re->lo = 0; return -VTD_FR_ROOT_TABLE_INV; } @@ -602,7 +603,8 @@ static int vtd_get_context_entry_from_root(IntelIOMMUState *s, } addr = addr + index * ce_size; - if (dma_memory_read(&address_space_memory, addr, ce, ce_size)) { + if (dma_memory_read(&address_space_memory, addr, + ce, ce_size, MEMTXATTRS_UNSPECIFIED)) { return -VTD_FR_CONTEXT_TABLE_INV; } @@ -639,8 +641,8 @@ static uint64_t vtd_get_slpte(dma_addr_t base_addr, uint32_t index) assert(index < VTD_SL_PT_ENTRY_NR); if (dma_memory_read(&address_space_memory, - base_addr + index * sizeof(slpte), &slpte, - sizeof(slpte))) { + base_addr + index * sizeof(slpte), + &slpte, sizeof(slpte), MEMTXATTRS_UNSPECIFIED)) { slpte = (uint64_t)-1; return slpte; } @@ -704,7 +706,8 @@ static int vtd_get_pdire_from_pdir_table(dma_addr_t pasid_dir_base, index = VTD_PASID_DIR_INDEX(pasid); entry_size = VTD_PASID_DIR_ENTRY_SIZE; addr = pasid_dir_base + index * entry_size; - if (dma_memory_read(&address_space_memory, addr, pdire, entry_size)) { + if (dma_memory_read(&address_space_memory, addr, + pdire, entry_size, MEMTXATTRS_UNSPECIFIED)) { return -VTD_FR_PASID_TABLE_INV; } @@ -728,7 +731,8 @@ static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUState *s, index = VTD_PASID_TABLE_INDEX(pasid); entry_size = VTD_PASID_ENTRY_SIZE; addr = addr + index * entry_size; - if (dma_memory_read(&address_space_memory, addr, pe, entry_size)) { + if (dma_memory_read(&address_space_memory, addr, + pe, entry_size, MEMTXATTRS_UNSPECIFIED)) { return -VTD_FR_PASID_TABLE_INV; } @@ -2275,7 +2279,8 @@ static bool vtd_get_inv_desc(IntelIOMMUState *s, uint32_t dw = s->iq_dw ? 32 : 16; dma_addr_t addr = base_addr + offset * dw; - if (dma_memory_read(&address_space_memory, addr, inv_desc, dw)) { + if (dma_memory_read(&address_space_memory, addr, + inv_desc, dw, MEMTXATTRS_UNSPECIFIED)) { error_report_once("Read INV DESC failed."); return false; } @@ -2308,8 +2313,9 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) dma_addr_t status_addr = inv_desc->hi; trace_vtd_inv_desc_wait_sw(status_addr, status_data); status_data = cpu_to_le32(status_data); - if (dma_memory_write(&address_space_memory, status_addr, &status_data, - sizeof(status_data))) { + if (dma_memory_write(&address_space_memory, status_addr, + &status_data, sizeof(status_data), + MEMTXATTRS_UNSPECIFIED)) { trace_vtd_inv_desc_wait_write_fail(inv_desc->hi, inv_desc->lo); return false; } @@ -3120,8 +3126,8 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index, } addr = iommu->intr_root + index * sizeof(*entry); - if (dma_memory_read(&address_space_memory, addr, entry, - sizeof(*entry))) { + if (dma_memory_read(&address_space_memory, addr, + entry, sizeof(*entry), MEMTXATTRS_UNSPECIFIED)) { error_report_once("%s: read failed: ind=0x%x addr=0x%" PRIx64, __func__, index, addr); return -VTD_FR_IR_ROOT_INVAL; diff --git a/hw/ide/macio.c b/hw/ide/macio.c index b03d401ceb5..f08318cf97f 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -97,7 +97,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) /* Non-block ATAPI transfer - just copy to RAM */ s->io_buffer_size = MIN(s->io_buffer_size, io->len); dma_memory_write(&address_space_memory, io->addr, s->io_buffer, - s->io_buffer_size); + s->io_buffer_size, MEMTXATTRS_UNSPECIFIED); io->len = 0; ide_atapi_cmd_ok(s); m->dma_active = false; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 190194d27f8..f15f98588a7 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1246,8 +1246,8 @@ void xive_end_queue_pic_print_info(XiveEND *end, uint32_t width, Monitor *mon) uint64_t qaddr = qaddr_base + (qindex << 2); uint32_t qdata = -1; - if (dma_memory_read(&address_space_memory, qaddr, &qdata, - sizeof(qdata))) { + if (dma_memory_read(&address_space_memory, qaddr, + &qdata, sizeof(qdata), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to read EQ @0x%" HWADDR_PRIx "\n", qaddr); return; @@ -1311,7 +1311,8 @@ static void xive_end_enqueue(XiveEND *end, uint32_t data) uint32_t qdata = cpu_to_be32((qgen << 31) | (data & 0x7fffffff)); uint32_t qentries = 1 << (qsize + 10); - if (dma_memory_write(&address_space_memory, qaddr, &qdata, sizeof(qdata))) { + if (dma_memory_write(&address_space_memory, qaddr, + &qdata, sizeof(qdata), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to write END data @0x%" HWADDR_PRIx "\n", qaddr); return; diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index 73941bdae97..76ea511d53d 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -69,7 +69,8 @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) break; case 0x00010003: /* Get board MAC address */ resplen = sizeof(s->macaddr.a); - dma_memory_write(&s->dma_as, value + 12, s->macaddr.a, resplen); + dma_memory_write(&s->dma_as, value + 12, s->macaddr.a, resplen, + MEMTXATTRS_UNSPECIFIED); break; case 0x00010004: /* Get board serial */ qemu_log_mask(LOG_UNIMP, diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index e220f1a9277..efcc02609fd 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -94,7 +94,7 @@ static void dbdma_cmdptr_load(DBDMA_channel *ch) DBDMA_DPRINTFCH(ch, "dbdma_cmdptr_load 0x%08x\n", ch->regs[DBDMA_CMDPTR_LO]); dma_memory_read(&address_space_memory, ch->regs[DBDMA_CMDPTR_LO], - &ch->current, sizeof(dbdma_cmd)); + &ch->current, sizeof(dbdma_cmd), MEMTXATTRS_UNSPECIFIED); } static void dbdma_cmdptr_save(DBDMA_channel *ch) @@ -104,7 +104,7 @@ static void dbdma_cmdptr_save(DBDMA_channel *ch) le16_to_cpu(ch->current.xfer_status), le16_to_cpu(ch->current.res_count)); dma_memory_write(&address_space_memory, ch->regs[DBDMA_CMDPTR_LO], - &ch->current, sizeof(dbdma_cmd)); + &ch->current, sizeof(dbdma_cmd), MEMTXATTRS_UNSPECIFIED); } static void kill_channel(DBDMA_channel *ch) @@ -371,7 +371,8 @@ static void load_word(DBDMA_channel *ch, int key, uint32_t addr, return; } - dma_memory_read(&address_space_memory, addr, ¤t->cmd_dep, len); + dma_memory_read(&address_space_memory, addr, ¤t->cmd_dep, len, + MEMTXATTRS_UNSPECIFIED); if (conditional_wait(ch)) goto wait; @@ -403,7 +404,8 @@ static void store_word(DBDMA_channel *ch, int key, uint32_t addr, return; } - dma_memory_write(&address_space_memory, addr, ¤t->cmd_dep, len); + dma_memory_write(&address_space_memory, addr, ¤t->cmd_dep, len, + MEMTXATTRS_UNSPECIFIED); if (conditional_wait(ch)) goto wait; diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c index ff611f18fbd..ecc0245fe8a 100644 --- a/hw/net/allwinner-sun8i-emac.c +++ b/hw/net/allwinner-sun8i-emac.c @@ -350,7 +350,8 @@ static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s, FrameDescriptor *desc, uint32_t phys_addr) { - dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc)); + dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); } static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s, @@ -402,7 +403,8 @@ static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s, FrameDescriptor *desc, uint32_t phys_addr) { - dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc)); + dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); } static bool allwinner_sun8i_emac_can_receive(NetClientState *nc) @@ -460,7 +462,8 @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc, << RX_DESC_STATUS_FRM_LEN_SHIFT; } - dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes); + dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes, + MEMTXATTRS_UNSPECIFIED); allwinner_sun8i_emac_flush_desc(s, &desc, s->rx_desc_curr); trace_allwinner_sun8i_emac_receive(s->rx_desc_curr, desc.addr, desc_bytes); @@ -512,7 +515,8 @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) desc.status |= TX_DESC_STATUS_LENGTH_ERR; break; } - dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, bytes); + dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, + bytes, MEMTXATTRS_UNSPECIFIED); packet_bytes += bytes; desc.status &= ~DESC_STATUS_CTL; allwinner_sun8i_emac_flush_desc(s, &desc, s->tx_desc_curr); @@ -634,7 +638,8 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset, break; case REG_TX_CUR_BUF: /* Transmit Current Buffer */ if (s->tx_desc_curr != 0) { - dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc)); + dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc), + MEMTXATTRS_UNSPECIFIED); value = desc.addr; } else { value = 0; @@ -647,7 +652,8 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset, break; case REG_RX_CUR_BUF: /* Receive Current Buffer */ if (s->rx_desc_curr != 0) { - dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc)); + dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc), + MEMTXATTRS_UNSPECIFIED); value = desc.addr; } else { value = 0; diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 25685ba3a95..83ef0a783e7 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -453,7 +453,8 @@ static void do_phy_ctl(FTGMAC100State *s) static int ftgmac100_read_bd(FTGMAC100Desc *bd, dma_addr_t addr) { - if (dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd))) { + if (dma_memory_read(&address_space_memory, addr, + bd, sizeof(*bd), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read descriptor @ 0x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -473,7 +474,8 @@ static int ftgmac100_write_bd(FTGMAC100Desc *bd, dma_addr_t addr) lebd.des1 = cpu_to_le32(bd->des1); lebd.des2 = cpu_to_le32(bd->des2); lebd.des3 = cpu_to_le32(bd->des3); - if (dma_memory_write(&address_space_memory, addr, &lebd, sizeof(lebd))) { + if (dma_memory_write(&address_space_memory, addr, + &lebd, sizeof(lebd), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to write descriptor @ 0x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -554,7 +556,8 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring, len = sizeof(s->frame) - frame_size; } - if (dma_memory_read(&address_space_memory, bd.des3, ptr, len)) { + if (dma_memory_read(&address_space_memory, bd.des3, + ptr, len, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read packet @ 0x%x\n", __func__, bd.des3); s->isr |= FTGMAC100_INT_AHB_ERR; @@ -1030,20 +1033,24 @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf, bd.des1 = lduw_be_p(buf + 14) | FTGMAC100_RXDES1_VLANTAG_AVAIL; if (s->maccr & FTGMAC100_MACCR_RM_VLAN) { - dma_memory_write(&address_space_memory, buf_addr, buf, 12); - dma_memory_write(&address_space_memory, buf_addr + 12, buf + 16, - buf_len - 16); + dma_memory_write(&address_space_memory, buf_addr, buf, 12, + MEMTXATTRS_UNSPECIFIED); + dma_memory_write(&address_space_memory, buf_addr + 12, + buf + 16, buf_len - 16, + MEMTXATTRS_UNSPECIFIED); } else { - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + dma_memory_write(&address_space_memory, buf_addr, buf, + buf_len, MEMTXATTRS_UNSPECIFIED); } } else { bd.des1 = 0; - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len, + MEMTXATTRS_UNSPECIFIED); } buf += buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, - crc_ptr, 4 - size); + crc_ptr, 4 - size, MEMTXATTRS_UNSPECIFIED); crc_ptr += 4 - size; } diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 9c7035bc948..0db9aaf76a0 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -387,19 +387,22 @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val) static void imx_fec_read_bd(IMXFECBufDesc *bd, dma_addr_t addr) { - dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); trace_imx_fec_read_bd(addr, bd->flags, bd->length, bd->data); } static void imx_fec_write_bd(IMXFECBufDesc *bd, dma_addr_t addr) { - dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); } static void imx_enet_read_bd(IMXENETBufDesc *bd, dma_addr_t addr) { - dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); trace_imx_enet_read_bd(addr, bd->flags, bd->length, bd->data, bd->option, bd->status); @@ -407,7 +410,8 @@ static void imx_enet_read_bd(IMXENETBufDesc *bd, dma_addr_t addr) static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) { - dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); } static void imx_eth_update(IMXFECState *s) @@ -474,7 +478,8 @@ static void imx_fec_do_tx(IMXFECState *s) len = ENET_MAX_FRAME_SIZE - frame_size; s->regs[ENET_EIR] |= ENET_INT_BABT; } - dma_memory_read(&address_space_memory, bd.data, ptr, len); + dma_memory_read(&address_space_memory, bd.data, ptr, len, + MEMTXATTRS_UNSPECIFIED); ptr += len; frame_size += len; if (bd.flags & ENET_BD_L) { @@ -555,7 +560,8 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) len = ENET_MAX_FRAME_SIZE - frame_size; s->regs[ENET_EIR] |= ENET_INT_BABT; } - dma_memory_read(&address_space_memory, bd.data, ptr, len); + dma_memory_read(&address_space_memory, bd.data, ptr, len, + MEMTXATTRS_UNSPECIFIED); ptr += len; frame_size += len; if (bd.flags & ENET_BD_L) { @@ -1103,11 +1109,12 @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, buf_len += size - 4; } buf_addr = bd.data; - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len, + MEMTXATTRS_UNSPECIFIED); buf += buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, - crc_ptr, 4 - size); + crc_ptr, 4 - size, MEMTXATTRS_UNSPECIFIED); crc_ptr += 4 - size; } bd.flags &= ~ENET_BD_E; @@ -1210,8 +1217,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, */ const uint8_t zeros[2] = { 0 }; - dma_memory_write(&address_space_memory, buf_addr, - zeros, sizeof(zeros)); + dma_memory_write(&address_space_memory, buf_addr, zeros, + sizeof(zeros), MEMTXATTRS_UNSPECIFIED); buf_addr += sizeof(zeros); buf_len -= sizeof(zeros); @@ -1220,11 +1227,12 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, shift16 = false; } - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len, + MEMTXATTRS_UNSPECIFIED); buf += buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, - crc_ptr, 4 - size); + crc_ptr, 4 - size, MEMTXATTRS_UNSPECIFIED); crc_ptr += 4 - size; } bd.flags &= ~ENET_BD_E; diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c index 545b2b74108..9a2328935c1 100644 --- a/hw/net/npcm7xx_emc.c +++ b/hw/net/npcm7xx_emc.c @@ -200,7 +200,8 @@ static void emc_update_irq_from_reg_change(NPCM7xxEMCState *emc) static int emc_read_tx_desc(dma_addr_t addr, NPCM7xxEMCTxDesc *desc) { - if (dma_memory_read(&address_space_memory, addr, desc, sizeof(*desc))) { + if (dma_memory_read(&address_space_memory, addr, desc, + sizeof(*desc), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read descriptor @ 0x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -221,7 +222,7 @@ static int emc_write_tx_desc(const NPCM7xxEMCTxDesc *desc, dma_addr_t addr) le_desc.status_and_length = cpu_to_le32(desc->status_and_length); le_desc.ntxdsa = cpu_to_le32(desc->ntxdsa); if (dma_memory_write(&address_space_memory, addr, &le_desc, - sizeof(le_desc))) { + sizeof(le_desc), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to write descriptor @ 0x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -231,7 +232,8 @@ static int emc_write_tx_desc(const NPCM7xxEMCTxDesc *desc, dma_addr_t addr) static int emc_read_rx_desc(dma_addr_t addr, NPCM7xxEMCRxDesc *desc) { - if (dma_memory_read(&address_space_memory, addr, desc, sizeof(*desc))) { + if (dma_memory_read(&address_space_memory, addr, desc, + sizeof(*desc), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read descriptor @ 0x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -252,7 +254,7 @@ static int emc_write_rx_desc(const NPCM7xxEMCRxDesc *desc, dma_addr_t addr) le_desc.reserved = cpu_to_le32(desc->reserved); le_desc.nrxdsa = cpu_to_le32(desc->nrxdsa); if (dma_memory_write(&address_space_memory, addr, &le_desc, - sizeof(le_desc))) { + sizeof(le_desc), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to write descriptor @ 0x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -366,7 +368,8 @@ static void emc_try_send_next_packet(NPCM7xxEMCState *emc) buf = malloced_buf; } - if (dma_memory_read(&address_space_memory, next_buf_addr, buf, length)) { + if (dma_memory_read(&address_space_memory, next_buf_addr, buf, + length, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read packet @ 0x%x\n", __func__, next_buf_addr); emc_set_mista(emc, REG_MISTA_TXBERR); @@ -551,10 +554,11 @@ static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) buf_addr = rx_desc.rxbsa; emc->regs[REG_CRXBSA] = buf_addr; - if (dma_memory_write(&address_space_memory, buf_addr, buf, len) || + if (dma_memory_write(&address_space_memory, buf_addr, buf, + len, MEMTXATTRS_UNSPECIFIED) || (!(emc->regs[REG_MCMDR] & REG_MCMDR_SPCRC) && - dma_memory_write(&address_space_memory, buf_addr + len, crc_ptr, - 4))) { + dma_memory_write(&address_space_memory, buf_addr + len, + crc_ptr, 4, MEMTXATTRS_UNSPECIFIED))) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Bus error writing packet\n", __func__); emc_set_mista(emc, REG_MISTA_RXBERR); diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index f7803fe3c30..9b91b15cb08 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -357,7 +357,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) dma_addr = s->dma_addr; s->dma_addr = 0; - if (dma_memory_read(s->dma_as, dma_addr, &dma, sizeof(dma))) { + if (dma_memory_read(s->dma_as, dma_addr, + &dma, sizeof(dma), MEMTXATTRS_UNSPECIFIED)) { stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), FW_CFG_DMA_CTL_ERROR); return; @@ -419,7 +420,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) */ if (read) { if (dma_memory_write(s->dma_as, dma.address, - &e->data[s->cur_offset], len)) { + &e->data[s->cur_offset], len, + MEMTXATTRS_UNSPECIFIED)) { dma.control |= FW_CFG_DMA_CTL_ERROR; } } @@ -427,7 +429,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) if (!e->allow_write || len != dma.length || dma_memory_read(s->dma_as, dma.address, - &e->data[s->cur_offset], len)) { + &e->data[s->cur_offset], len, + MEMTXATTRS_UNSPECIFIED)) { dma.control |= FW_CFG_DMA_CTL_ERROR; } else if (e->write_cb) { e->write_cb(e->callback_opaque, s->cur_offset, len); diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c index 9c4451ca0d1..c6e7871ecbf 100644 --- a/hw/pci-host/pnv_phb3.c +++ b/hw/pci-host/pnv_phb3.c @@ -715,7 +715,8 @@ static bool pnv_phb3_resolve_pe(PnvPhb3DMASpace *ds) bus_num = pci_bus_num(ds->bus); addr = rtt & PHB_RTT_BASE_ADDRESS_MASK; addr += 2 * ((bus_num << 8) | ds->devfn); - if (dma_memory_read(&address_space_memory, addr, &rte, sizeof(rte))) { + if (dma_memory_read(&address_space_memory, addr, &rte, + sizeof(rte), MEMTXATTRS_UNSPECIFIED)) { phb3_error(ds->phb, "Failed to read RTT entry at 0x%"PRIx64, addr); /* Set error bits ? fence ? ... */ return false; @@ -794,7 +795,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds, hwaddr addr, /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce, - sizeof(tce))) { + sizeof(tce), MEMTXATTRS_UNSPECIFIED)) { phb3_error(phb, "Failed to read TCE at 0x%"PRIx64, taddr); return; } diff --git a/hw/pci-host/pnv_phb3_msi.c b/hw/pci-host/pnv_phb3_msi.c index 099d2092a2c..8bcbc2cc4f3 100644 --- a/hw/pci-host/pnv_phb3_msi.c +++ b/hw/pci-host/pnv_phb3_msi.c @@ -53,7 +53,8 @@ static bool phb3_msi_read_ive(PnvPHB3 *phb, int srcno, uint64_t *out_ive) return false; } - if (dma_memory_read(&address_space_memory, ive_addr, &ive, sizeof(ive))) { + if (dma_memory_read(&address_space_memory, ive_addr, + &ive, sizeof(ive), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "Failed to read IVE at 0x%" PRIx64, ive_addr); return false; @@ -73,7 +74,8 @@ static void phb3_msi_set_p(Phb3MsiState *msi, int srcno, uint8_t gen) return; } - if (dma_memory_write(&address_space_memory, ive_addr + 4, &p, 1)) { + if (dma_memory_write(&address_space_memory, ive_addr + 4, + &p, 1, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "Failed to write IVE (set P) at 0x%" PRIx64, ive_addr); } @@ -89,7 +91,8 @@ static void phb3_msi_set_q(Phb3MsiState *msi, int srcno) return; } - if (dma_memory_write(&address_space_memory, ive_addr + 5, &q, 1)) { + if (dma_memory_write(&address_space_memory, ive_addr + 5, + &q, 1, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "Failed to write IVE (set Q) at 0x%" PRIx64, ive_addr); } diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 40b793201a3..1fbf7328f5a 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -891,7 +891,8 @@ static bool pnv_phb4_resolve_pe(PnvPhb4DMASpace *ds) bus_num = pci_bus_num(ds->bus); addr = rtt & PHB_RTT_BASE_ADDRESS_MASK; addr += 2 * PCI_BUILD_BDF(bus_num, ds->devfn); - if (dma_memory_read(&address_space_memory, addr, &rte, sizeof(rte))) { + if (dma_memory_read(&address_space_memory, addr, &rte, + sizeof(rte), MEMTXATTRS_UNSPECIFIED)) { phb_error(ds->phb, "Failed to read RTT entry at 0x%"PRIx64, addr); /* Set error bits ? fence ? ... */ return false; @@ -961,7 +962,7 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds, hwaddr addr, /* Grab the TCE address */ taddr = base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) << 3); if (dma_memory_read(&address_space_memory, taddr, &tce, - sizeof(tce))) { + sizeof(tce), MEMTXATTRS_UNSPECIFIED)) { phb_error(ds->phb, "Failed to read TCE at 0x%"PRIx64, taddr); return; } diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c index 9166d6638de..de5bc49e68f 100644 --- a/hw/sd/allwinner-sdhost.c +++ b/hw/sd/allwinner-sdhost.c @@ -311,7 +311,8 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s, uint8_t buf[1024]; /* Read descriptor */ - dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); + dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); if (desc->size == 0) { desc->size = klass->max_desc_size; } else if (desc->size > klass->max_desc_size) { @@ -337,23 +338,24 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s, /* Write to SD bus */ if (is_write) { dma_memory_read(&s->dma_as, - (desc->addr & DESC_SIZE_MASK) + num_done, - buf, buf_bytes); + (desc->addr & DESC_SIZE_MASK) + num_done, buf, + buf_bytes, MEMTXATTRS_UNSPECIFIED); sdbus_write_data(&s->sdbus, buf, buf_bytes); /* Read from SD bus */ } else { sdbus_read_data(&s->sdbus, buf, buf_bytes); dma_memory_write(&s->dma_as, - (desc->addr & DESC_SIZE_MASK) + num_done, - buf, buf_bytes); + (desc->addr & DESC_SIZE_MASK) + num_done, buf, + buf_bytes, MEMTXATTRS_UNSPECIFIED); } num_done += buf_bytes; } /* Clear hold flag and flush descriptor */ desc->status &= ~DESC_STATUS_HOLD; - dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc)); + dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); return num_done; } diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index c9dc065cc52..e0bbc903446 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -616,8 +616,8 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->blkcnt--; } } - dma_memory_write(s->dma_as, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count - begin); + dma_memory_write(s->dma_as, s->sdmasysad, &s->fifo_buffer[begin], + s->data_count - begin, MEMTXATTRS_UNSPECIFIED); s->sdmasysad += s->data_count - begin; if (s->data_count == block_size) { s->data_count = 0; @@ -637,8 +637,8 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->data_count = block_size; boundary_count -= block_size - begin; } - dma_memory_read(s->dma_as, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count - begin); + dma_memory_read(s->dma_as, s->sdmasysad, &s->fifo_buffer[begin], + s->data_count - begin, MEMTXATTRS_UNSPECIFIED); s->sdmasysad += s->data_count - begin; if (s->data_count == block_size) { sdbus_write_data(&s->sdbus, s->fifo_buffer, block_size); @@ -670,9 +670,11 @@ static void sdhci_sdma_transfer_single_block(SDHCIState *s) if (s->trnmod & SDHC_TRNS_READ) { sdbus_read_data(&s->sdbus, s->fifo_buffer, datacnt); - dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt); + dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt, + MEMTXATTRS_UNSPECIFIED); } else { - dma_memory_read(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt); + dma_memory_read(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt, + MEMTXATTRS_UNSPECIFIED); sdbus_write_data(&s->sdbus, s->fifo_buffer, datacnt); } s->blkcnt--; @@ -694,7 +696,8 @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) hwaddr entry_addr = (hwaddr)s->admasysaddr; switch (SDHC_DMA_TYPE(s->hostctl1)) { case SDHC_CTRL_ADMA2_32: - dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2)); + dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), + MEMTXATTRS_UNSPECIFIED); adma2 = le64_to_cpu(adma2); /* The spec does not specify endianness of descriptor table. * We currently assume that it is LE. @@ -705,7 +708,8 @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) dscr->incr = 8; break; case SDHC_CTRL_ADMA1_32: - dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1)); + dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1), + MEMTXATTRS_UNSPECIFIED); adma1 = le32_to_cpu(adma1); dscr->addr = (hwaddr)(adma1 & 0xFFFFF000); dscr->attr = (uint8_t)extract32(adma1, 0, 7); @@ -717,10 +721,13 @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) } break; case SDHC_CTRL_ADMA2_64: - dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1); - dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2); + dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1, + MEMTXATTRS_UNSPECIFIED); + dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2, + MEMTXATTRS_UNSPECIFIED); dscr->length = le16_to_cpu(dscr->length); - dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8); + dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8, + MEMTXATTRS_UNSPECIFIED); dscr->addr = le64_to_cpu(dscr->addr); dscr->attr &= (uint8_t) ~0xC0; dscr->incr = 12; @@ -785,7 +792,8 @@ static void sdhci_do_adma(SDHCIState *s) } dma_memory_write(s->dma_as, dscr.addr, &s->fifo_buffer[begin], - s->data_count - begin); + s->data_count - begin, + MEMTXATTRS_UNSPECIFIED); dscr.addr += s->data_count - begin; if (s->data_count == block_size) { s->data_count = 0; @@ -810,7 +818,8 @@ static void sdhci_do_adma(SDHCIState *s) } dma_memory_read(s->dma_as, dscr.addr, &s->fifo_buffer[begin], - s->data_count - begin); + s->data_count - begin, + MEMTXATTRS_UNSPECIFIED); dscr.addr += s->data_count - begin; if (s->data_count == block_size) { sdbus_write_data(&s->sdbus, s->fifo_buffer, block_size); diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c index e1d96acf7ec..8755e9cbb0a 100644 --- a/hw/usb/hcd-dwc2.c +++ b/hw/usb/hcd-dwc2.c @@ -272,8 +272,8 @@ static void dwc2_handle_packet(DWC2State *s, uint32_t devadr, USBDevice *dev, if (pid != USB_TOKEN_IN) { trace_usb_dwc2_memory_read(hcdma, tlen); - if (dma_memory_read(&s->dma_as, hcdma, - s->usb_buf[chan], tlen) != MEMTX_OK) { + if (dma_memory_read(&s->dma_as, hcdma, s->usb_buf[chan], tlen, + MEMTXATTRS_UNSPECIFIED) != MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_read failed\n", __func__); } @@ -328,8 +328,8 @@ babble: if (pid == USB_TOKEN_IN) { trace_usb_dwc2_memory_write(hcdma, actual); - if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], - actual) != MEMTX_OK) { + if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], actual, + MEMTXATTRS_UNSPECIFIED) != MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_write failed\n", __func__); } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 6caa7ac6c28..33a8a377bd9 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -383,7 +383,8 @@ static inline int get_dwords(EHCIState *ehci, uint32_t addr, } for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { - dma_memory_read(ehci->as, addr, buf, sizeof(*buf)); + dma_memory_read(ehci->as, addr, buf, sizeof(*buf), + MEMTXATTRS_UNSPECIFIED); *buf = le32_to_cpu(*buf); } @@ -405,7 +406,8 @@ static inline int put_dwords(EHCIState *ehci, uint32_t addr, for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { uint32_t tmp = cpu_to_le32(*buf); - dma_memory_write(ehci->as, addr, &tmp, sizeof(tmp)); + dma_memory_write(ehci->as, addr, &tmp, sizeof(tmp), + MEMTXATTRS_UNSPECIFIED); } return num; diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 56e2315c734..a93d6b2e988 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -452,7 +452,8 @@ static inline int get_dwords(OHCIState *ohci, addr += ohci->localmem_base; for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { - if (dma_memory_read(ohci->as, addr, buf, sizeof(*buf))) { + if (dma_memory_read(ohci->as, addr, + buf, sizeof(*buf), MEMTXATTRS_UNSPECIFIED)) { return -1; } *buf = le32_to_cpu(*buf); @@ -471,7 +472,8 @@ static inline int put_dwords(OHCIState *ohci, for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { uint32_t tmp = cpu_to_le32(*buf); - if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) { + if (dma_memory_write(ohci->as, addr, + &tmp, sizeof(tmp), MEMTXATTRS_UNSPECIFIED)) { return -1; } } @@ -488,7 +490,8 @@ static inline int get_words(OHCIState *ohci, addr += ohci->localmem_base; for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { - if (dma_memory_read(ohci->as, addr, buf, sizeof(*buf))) { + if (dma_memory_read(ohci->as, addr, + buf, sizeof(*buf), MEMTXATTRS_UNSPECIFIED)) { return -1; } *buf = le16_to_cpu(*buf); @@ -507,7 +510,8 @@ static inline int put_words(OHCIState *ohci, for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) { uint16_t tmp = cpu_to_le16(*buf); - if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) { + if (dma_memory_write(ohci->as, addr, + &tmp, sizeof(tmp), MEMTXATTRS_UNSPECIFIED)) { return -1; } } @@ -537,8 +541,8 @@ static inline int ohci_read_iso_td(OHCIState *ohci, static inline int ohci_read_hcca(OHCIState *ohci, dma_addr_t addr, struct ohci_hcca *hcca) { - return dma_memory_read(ohci->as, addr + ohci->localmem_base, - hcca, sizeof(*hcca)); + return dma_memory_read(ohci->as, addr + ohci->localmem_base, hcca, + sizeof(*hcca), MEMTXATTRS_UNSPECIFIED); } static inline int ohci_put_ed(OHCIState *ohci, @@ -572,7 +576,7 @@ static inline int ohci_put_hcca(OHCIState *ohci, return dma_memory_write(ohci->as, addr + ohci->localmem_base + HCCA_WRITEBACK_OFFSET, (char *)hcca + HCCA_WRITEBACK_OFFSET, - HCCA_WRITEBACK_SIZE); + HCCA_WRITEBACK_SIZE, MEMTXATTRS_UNSPECIFIED); } /* Read/Write the contents of a TD from/to main memory. */ diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index e01700039b1..ed2b9ea456e 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -487,7 +487,7 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci, dma_addr_t addr, assert((len % sizeof(uint32_t)) == 0); - dma_memory_read(xhci->as, addr, buf, len); + dma_memory_read(xhci->as, addr, buf, len, MEMTXATTRS_UNSPECIFIED); for (i = 0; i < (len / sizeof(uint32_t)); i++) { buf[i] = le32_to_cpu(buf[i]); @@ -507,7 +507,7 @@ static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr, for (i = 0; i < n; i++) { tmp[i] = cpu_to_le32(buf[i]); } - dma_memory_write(xhci->as, addr, tmp, len); + dma_memory_write(xhci->as, addr, tmp, len, MEMTXATTRS_UNSPECIFIED); } static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport) @@ -618,7 +618,7 @@ static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v) ev_trb.status, ev_trb.control); addr = intr->er_start + TRB_SIZE*intr->er_ep_idx; - dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE); + dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE, MEMTXATTRS_UNSPECIFIED); intr->er_ep_idx++; if (intr->er_ep_idx >= intr->er_size) { @@ -679,7 +679,8 @@ static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRing *ring, XHCITRB *trb, while (1) { TRBType type; - dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE); + dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE, + MEMTXATTRS_UNSPECIFIED); trb->addr = ring->dequeue; trb->ccs = ring->ccs; le64_to_cpus(&trb->parameter); @@ -726,7 +727,8 @@ static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring) while (1) { TRBType type; - dma_memory_read(xhci->as, dequeue, &trb, TRB_SIZE); + dma_memory_read(xhci->as, dequeue, &trb, TRB_SIZE, + MEMTXATTRS_UNSPECIFIED); le64_to_cpus(&trb.parameter); le32_to_cpus(&trb.status); le32_to_cpus(&trb.control); @@ -781,7 +783,8 @@ static void xhci_er_reset(XHCIState *xhci, int v) xhci_die(xhci); return; } - dma_memory_read(xhci->as, erstba, &seg, sizeof(seg)); + dma_memory_read(xhci->as, erstba, &seg, sizeof(seg), + MEMTXATTRS_UNSPECIFIED); le32_to_cpus(&seg.addr_low); le32_to_cpus(&seg.addr_high); le32_to_cpus(&seg.size); @@ -2397,7 +2400,8 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx) /* TODO: actually implement real values here */ bw_ctx[0] = 0; memset(&bw_ctx[1], 80, xhci->numports); /* 80% */ - dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx)); + dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx), + MEMTXATTRS_UNSPECIFIED); return CC_SUCCESS; } From patchwork Thu Dec 23 11:55:37 2021 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: 12698181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 85007C433EF for ; Thu, 23 Dec 2021 12:18:04 +0000 (UTC) Received: from localhost ([::1]:42328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N2p-0006B0-Ce for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:18:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mj7-0008Op-FM for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mj5-0000ks-Fd for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260658; 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=JlHtEDNchl3mn6IN4VTMeHX5PZJU77q/cfu6ijIqzmY=; b=hJQmQWIbMWu3N663X0PbGStwVaN3HU8ZAAJWyhhtks+XQf2AMV1++xLZ+rE1pLUM8pbReR /rkQhJIpPQCsTYOzgfBbOObbLtUAzKNDGoSqUorTgXYn/3xNWS9Pul2FqtKn7kcrIjt5Z1 GSvbLFX9gByUjUabFDI/Uw9YrJECTq4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-393-z_golRABMYqoq8KD-03HxA-1; Thu, 23 Dec 2021 06:57:37 -0500 X-MC-Unique: z_golRABMYqoq8KD-03HxA-1 Received: by mail-wm1-f72.google.com with SMTP id n31-20020a05600c501f00b00345b15f5e15so1871751wmr.3 for ; Thu, 23 Dec 2021 03:57:37 -0800 (PST) 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=JlHtEDNchl3mn6IN4VTMeHX5PZJU77q/cfu6ijIqzmY=; b=E2An/i//cB41oxSuK/5uOGHAenc55F0vJxSv+8CCKlHvnVs7WmdXxZXj8qxNDVg6B8 CyNyKHg7IJk4AqgjBWqtFNDOYlBkqAWyeIanTr3jCfT0cxxMSchcyq0PDY7zU4A45yL2 ZzVQSTZUrwBNTgVDW8OB8FbODw2on6ja/vHURwqSWRPvPDSf37ggzbh0G2VWAk0isA1D IdVru1JMRVXDYVaUdWZde/IsuBNQBW4F0rx0P800AN7PquorYrCIwsiAtE8YgmWuAlek CvldLS/A4AzkQ9QMnZ/5aHICAmaUXhUEyKJkdAbgeu0DinCCmNBNGIwOaVhISKBs179w eZ8A== X-Gm-Message-State: AOAM530CCRSNvoPkMjQs6KcxEkam8l/Cl2u+UEs/u0sKypVWHGgwMtfZ yIuxqmj8c0QrOFU3g1p5vZkUkhv8fNUnD7/p1uCB0k9K/3Oz7NF2BDWLikTtaNUpvEZWmv2qsRx NlsBcJcJ8t4yBGa9D2QHdN8ucN9338Wb+Wm9aIZ5wEHxkJAGboixtPC0xTHanqOd8 X-Received: by 2002:a05:6000:1ac9:: with SMTP id i9mr1470558wry.531.1640260656078; Thu, 23 Dec 2021 03:57:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2odW8+cHbNw40desh9u11A2zmSKk2WtuGp/wX3MfWh5yu32srGB6BOu1wbMWVJtpX+ZACyQ== X-Received: by 2002:a05:6000:1ac9:: with SMTP id i9mr1470497wry.531.1640260655713; Thu, 23 Dec 2021 03:57:35 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id s8sm5491683wra.9.2021.12.23.03.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:57:35 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/23] dma: Let dma_memory_map() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:37 +0100 Message-Id: <20211223115554.3155328-7-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , "Edgar E . Iglesias" , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Li Qiang , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Stefan Hajnoczi , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_memory_map(). Patch created mechanically using spatch with this script: @@ expression E1, E2, E3, E4; @@ - dma_memory_map(E1, E2, E3, E4) + dma_memory_map(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED) Reviewed-by: Richard Henderson Reviewed-by: Li Qiang Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Message-Id: <20210702092439.989969-7-philmd@redhat.com> --- include/hw/pci/pci.h | 3 ++- include/sysemu/dma.h | 5 +++-- hw/display/virtio-gpu.c | 10 ++++++---- hw/hyperv/vmbus.c | 8 +++++--- hw/ide/ahci.c | 8 +++++--- hw/usb/libhw.c | 3 ++- hw/virtio/virtio.c | 6 ++++-- softmmu/dma-helpers.c | 3 ++- 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 4383f1c95e0..1acefc2a4c3 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -875,7 +875,8 @@ static inline void *pci_dma_map(PCIDevice *dev, dma_addr_t addr, { void *buf; - buf = dma_memory_map(pci_get_address_space(dev), addr, plen, dir); + buf = dma_memory_map(pci_get_address_space(dev), addr, plen, dir, + MEMTXATTRS_UNSPECIFIED); return buf; } diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 522682bf386..97ff6f29f8c 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -202,16 +202,17 @@ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr, * @addr: address within that address space * @len: pointer to length of buffer; updated on return * @dir: indicates the transfer direction + * @attrs: memory attributes */ static inline void *dma_memory_map(AddressSpace *as, dma_addr_t addr, dma_addr_t *len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { hwaddr xlen = *len; void *p; p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE, - MEMTXATTRS_UNSPECIFIED); + attrs); *len = xlen; return p; } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index d78b9700c7d..c6dc818988c 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -814,8 +814,9 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, do { len = l; - map = dma_memory_map(VIRTIO_DEVICE(g)->dma_as, - a, &len, DMA_DIRECTION_TO_DEVICE); + map = dma_memory_map(VIRTIO_DEVICE(g)->dma_as, a, &len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!map) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for" " element %d\n", __func__, e); @@ -1252,8 +1253,9 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size, for (i = 0; i < res->iov_cnt; i++) { hwaddr len = res->iov[i].iov_len; res->iov[i].iov_base = - dma_memory_map(VIRTIO_DEVICE(g)->dma_as, - res->addrs[i], &len, DMA_DIRECTION_TO_DEVICE); + dma_memory_map(VIRTIO_DEVICE(g)->dma_as, res->addrs[i], &len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!res->iov[i].iov_base || len != res->iov[i].iov_len) { /* Clean up the half-a-mapping we just created... */ diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index dbce3b35fba..8aad29f1bb2 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -373,7 +373,8 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *buf, uint32_t len) maddr = (iter->gpadl->gfns[idx] << TARGET_PAGE_BITS) | off_in_page; - iter->map = dma_memory_map(iter->as, maddr, &mlen, iter->dir); + iter->map = dma_memory_map(iter->as, maddr, &mlen, iter->dir, + MEMTXATTRS_UNSPECIFIED); if (mlen != pgleft) { dma_memory_unmap(iter->as, iter->map, mlen, iter->dir, 0); iter->map = NULL; @@ -490,7 +491,8 @@ int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *iov, goto err; } - iov[ret_cnt].iov_base = dma_memory_map(sgl->as, a, &l, dir); + iov[ret_cnt].iov_base = dma_memory_map(sgl->as, a, &l, dir, + MEMTXATTRS_UNSPECIFIED); if (!l) { ret = -EFAULT; goto err; @@ -566,7 +568,7 @@ static vmbus_ring_buffer *ringbuf_map_hdr(VMBusRingBufCommon *ringbuf) dma_addr_t mlen = sizeof(*rb); rb = dma_memory_map(ringbuf->as, ringbuf->rb_addr, &mlen, - DMA_DIRECTION_FROM_DEVICE); + DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED); if (mlen != sizeof(*rb)) { dma_memory_unmap(ringbuf->as, rb, mlen, DMA_DIRECTION_FROM_DEVICE, 0); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index a94c6e26fb0..8e77ddb660f 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -249,7 +249,8 @@ static void map_page(AddressSpace *as, uint8_t **ptr, uint64_t addr, dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len); } - *ptr = dma_memory_map(as, addr, &len, DMA_DIRECTION_FROM_DEVICE); + *ptr = dma_memory_map(as, addr, &len, DMA_DIRECTION_FROM_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (len < wanted && *ptr) { dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len); *ptr = NULL; @@ -939,7 +940,8 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, /* map PRDT */ if (!(prdt = dma_memory_map(ad->hba->as, prdt_addr, &prdt_len, - DMA_DIRECTION_TO_DEVICE))){ + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED))){ trace_ahci_populate_sglist_no_map(ad->hba, ad->port_no); return -1; } @@ -1301,7 +1303,7 @@ static int handle_cmd(AHCIState *s, int port, uint8_t slot) tbl_addr = le64_to_cpu(cmd->tbl_addr); cmd_len = 0x80; cmd_fis = dma_memory_map(s->as, tbl_addr, &cmd_len, - DMA_DIRECTION_TO_DEVICE); + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); if (!cmd_fis) { trace_handle_cmd_badfis(s, port); return -1; diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c index 9c33a1640f7..f350eae443d 100644 --- a/hw/usb/libhw.c +++ b/hw/usb/libhw.c @@ -36,7 +36,8 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl) while (len) { dma_addr_t xlen = len; - mem = dma_memory_map(sgl->as, base, &xlen, dir); + mem = dma_memory_map(sgl->as, base, &xlen, dir, + MEMTXATTRS_UNSPECIFIED); if (!mem) { goto err; } diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ea7c079fb04..e11a8a0dbab 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1306,7 +1306,8 @@ static bool virtqueue_map_desc(VirtIODevice *vdev, unsigned int *p_num_sg, iov[num_sg].iov_base = dma_memory_map(vdev->dma_as, pa, &len, is_write ? DMA_DIRECTION_FROM_DEVICE : - DMA_DIRECTION_TO_DEVICE); + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!iov[num_sg].iov_base) { virtio_error(vdev, "virtio: bogus descriptor or out of resources"); goto out; @@ -1355,7 +1356,8 @@ static void virtqueue_map_iovec(VirtIODevice *vdev, struct iovec *sg, sg[i].iov_base = dma_memory_map(vdev->dma_as, addr[i], &len, is_write ? DMA_DIRECTION_FROM_DEVICE : - DMA_DIRECTION_TO_DEVICE); + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!sg[i].iov_base) { error_report("virtio: error trying to map MMIO memory"); exit(1); diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 5bf76fff6bd..3c06a2feddd 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -143,7 +143,8 @@ static void dma_blk_cb(void *opaque, int ret) while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; - mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); + mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir, + MEMTXATTRS_UNSPECIFIED); /* * Make reads deterministic in icount mode. Windows sometimes issues * disk read requests with overlapping SGs. It leads From patchwork Thu Dec 23 11:55:38 2021 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: 12698157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BBCDEC433EF for ; Thu, 23 Dec 2021 12:12:18 +0000 (UTC) Received: from localhost ([::1]:55148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0MxF-0003TB-M2 for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:12:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MjN-00005S-Nd for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MjL-0000oc-A9 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:57:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260674; 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=kqGVMoeSLIS0R7ecXiNgtt0tJfscA56QNYUlD07YLQc=; b=iBoaIZM1xH9aS0lmLku49FOpdDkQ76WOt88s7M4n2vyDTVZ1L6ixXlfU8A2YjzNtfc6lFn WL9GuRO557pkpOxjumPfGrrbZxrPgotKbKBFyD5GSQvn+W1HU9DsXqrhvjwoZ+agUng5Hj ZCtsLQXu6dybniworpCQTjkidsER9hs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-599-6R1Mrua0ONmmwOmRjRKODQ-1; Thu, 23 Dec 2021 06:57:54 -0500 X-MC-Unique: 6R1Mrua0ONmmwOmRjRKODQ-1 Received: by mail-wm1-f70.google.com with SMTP id d4-20020a05600c34c400b00345d5d47d54so635875wmq.6 for ; Thu, 23 Dec 2021 03:57:53 -0800 (PST) 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=kqGVMoeSLIS0R7ecXiNgtt0tJfscA56QNYUlD07YLQc=; b=eYIozL7xI08AzpqKSw0cK+mUTvh00W7SgBrNED04NfMcdOSmSuBep0E72sxLlASp8u 3NFE887wM33Sp4ujQ0phjr1z9iOg/4uTspZj3WKgfl4R90rTeFTAQkBQNWuQ38eeMqf5 WX9M5AwDfRWg6D5vH1KATz2e3Dym6Mw6/hbd3nOEpCfAxiFLEMFjbeWfHB1iyOC12lmb luoluS5sFjiYQDjD7GBE0egjD4/b888bHpnQv2ikYONIMV1034EByrOL2tL2HUTlIkzv WAKHZTlIhMHthtHhLF2xG4hhM/DYMb/Y8EetP435AVaGzhAPaftlQbrBwo7S/rOPZJFG w9/w== X-Gm-Message-State: AOAM5300RIoL9fFSax5SJ+tICo1PH6katHVNSQT7wk18dtqlJTDSamMq 9U8rhLLR21a7wHEXh9vEMjYCcEuCMP8ZaEmirBrtKkAcNhwsdRDFJ6Xzs2/r2k/UFRC0AP4yMIg g+EaQBnXmJPNY8t3zg0i+LYseyjJMnV7kGi8zqhmeDHuIt2HekqVrE8XSE8fG/d+x X-Received: by 2002:a5d:59af:: with SMTP id p15mr1567071wrr.422.1640260672476; Thu, 23 Dec 2021 03:57:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkSWpPuScdr/sDyE1pWGinW5+okcN0PSBP+85J0cs057/gOU1XT2/F6hUrVg/EjjW0bVzoHA== X-Received: by 2002:a5d:59af:: with SMTP id p15mr1567016wrr.422.1640260672201; Thu, 23 Dec 2021 03:57:52 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id az15sm4220456wmb.47.2021.12.23.03.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:57:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 07/23] dma: Have dma_buf_rw() take a void pointer Date: Thu, 23 Dec 2021 12:55:38 +0100 Message-Id: <20211223115554.3155328-8-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" DMA operations are run on any kind of buffer, not arrays of uint8_t. Convert dma_buf_rw() to take a void pointer argument to save us pointless casts to uint8_t *. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- softmmu/dma-helpers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 3c06a2feddd..09e29997ee5 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -294,9 +294,10 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk, } -static uint64_t dma_buf_rw(uint8_t *ptr, int32_t len, QEMUSGList *sg, +static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, DMADirection dir) { + uint8_t *ptr = buf; uint64_t resid; int sg_cur_index; From patchwork Thu Dec 23 11:55:39 2021 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: 12698185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1011EC433F5 for ; Thu, 23 Dec 2021 12:21:09 +0000 (UTC) Received: from localhost ([::1]:52498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N5o-0004l3-2b for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:21:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mjc-0000jn-JB for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MjZ-0000qS-QJ for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260689; 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=4MZDcjrRTlV4xDeU9/QkaMx4+S9qLpo1jo/kWB7g2uY=; b=gABiCVqSYTjcUMj9mp7tvvO5HVkBdNYKyfIB9OMmUxY8KU4+JIND/R7YKgraE4x1kvn7vb OCWZsfVvc3RUjpAzr9tarhPlcKfO7gyXQvKh6RGaPn7SXhsKB5CZqC+YdeFQzySEuJAjK0 rqqmwWJCLGqtTM84yBEC6VowH4h1Itc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-142-paakuewPNfqP3agTxEcUvA-1; Thu, 23 Dec 2021 06:58:08 -0500 X-MC-Unique: paakuewPNfqP3agTxEcUvA-1 Received: by mail-wm1-f71.google.com with SMTP id a203-20020a1c7fd4000000b0034574187420so4543136wmd.5 for ; Thu, 23 Dec 2021 03:58:08 -0800 (PST) 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=4MZDcjrRTlV4xDeU9/QkaMx4+S9qLpo1jo/kWB7g2uY=; b=7UqvQs0xfxSur0m9js0PaWwQZWB/VzspFqHjNNZjy9Iq3nk9E/XJjwMtccrOyse8yE h/Nmli0gtuJW9/c2KsKxgWplGeIj3zNVEv11m4E7uAI80o8SXplCPjkLzFO0NPyCQD99 uFkNygg7hcRtw6L8w/zMSPo524DkOQcZBzXlhN8bmAoXHyFVFEnq6ky0pJ9/bYuTewcf oSfk8bIx9C/mPdxL6uqsj5qXOxT0m2Wm0DaQaJRAOYofGP5SoCieAlxos0D+inpQy55y N3u9tO2uDZZaJTLeAeSvMmsq2Y5M7AxTDghorRke9uwDAFWGKzsG8kp4hkDTZP+bbCnu jMkg== X-Gm-Message-State: AOAM532Z+cxfjEUmQ2A0NpO7tOlSM1+a+oQCOc8jwvIYwT7MGfHRS/gB Vs9nfrjcJJQ/4GTQN5KVCvngsvfHXGRqk1EABuH5yKHxq6oRBMhyKMV22Se0/yre4FheeiCuvma vs/ezOeifNFRkl7bfuA0uMGbOcXWxFONkUUmbIOYc5JA7/PUvqYak9abdBcHwtqrT X-Received: by 2002:adf:f985:: with SMTP id f5mr1539787wrr.14.1640260686831; Thu, 23 Dec 2021 03:58:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxA4cNRWKqaNRPfPCkDahQPJhOFZX/1ksH6nhn80QsBvQaBrYXHasYAPCxsZWNpOBY1YHVQCA== X-Received: by 2002:adf:f985:: with SMTP id f5mr1539734wrr.14.1640260686553; Thu, 23 Dec 2021 03:58:06 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id q13sm4553548wrr.64.2021.12.23.03.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:58:06 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 08/23] dma: Have dma_buf_read() / dma_buf_write() take a void pointer Date: Thu, 23 Dec 2021 12:55:39 +0100 Message-Id: <20211223115554.3155328-9-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" DMA operations are run on any kind of buffer, not arrays of uint8_t. Convert dma_buf_read/dma_buf_write functions to take a void pointer argument and save us pointless casts to uint8_t *. Remove this pointless casts in the megasas device model. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 4 ++-- hw/scsi/megasas.c | 22 +++++++++++----------- softmmu/dma-helpers.c | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 97ff6f29f8c..0d5b836013d 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -302,8 +302,8 @@ BlockAIOCB *dma_blk_read(BlockBackend *blk, BlockAIOCB *dma_blk_write(BlockBackend *blk, QEMUSGList *sg, uint64_t offset, uint32_t align, BlockCompletionFunc *cb, void *opaque); -uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg); -uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); +uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg); +uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg); void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, QEMUSGList *sg, enum BlockAcctType type); diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 8f357841004..dc28302f96d 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -848,7 +848,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) MFI_INFO_PDMIX_SATA | MFI_INFO_PDMIX_LD); - cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); return MFI_STAT_OK; } @@ -878,7 +878,7 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd) info.disable_preboot_cli = 1; info.cluster_disable = 1; - cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); return MFI_STAT_OK; } @@ -899,7 +899,7 @@ static int megasas_dcmd_get_bios_info(MegasasState *s, MegasasCmd *cmd) info.expose_all_drives = 1; } - cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); return MFI_STAT_OK; } @@ -910,7 +910,7 @@ static int megasas_dcmd_get_fw_time(MegasasState *s, MegasasCmd *cmd) fw_time = cpu_to_le64(megasas_fw_time()); - cmd->iov_size -= dma_buf_read((uint8_t *)&fw_time, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&fw_time, dcmd_size, &cmd->qsg); return MFI_STAT_OK; } @@ -937,7 +937,7 @@ static int megasas_event_info(MegasasState *s, MegasasCmd *cmd) info.shutdown_seq_num = cpu_to_le32(s->shutdown_event); info.boot_seq_num = cpu_to_le32(s->boot_event); - cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); return MFI_STAT_OK; } @@ -1006,7 +1006,7 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) info.size = cpu_to_le32(offset); info.count = cpu_to_le32(num_pd_disks); - cmd->iov_size -= dma_buf_read((uint8_t *)&info, offset, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, offset, &cmd->qsg); return MFI_STAT_OK; } @@ -1172,7 +1172,7 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + resid = dma_buf_read(&info, dcmd_size, &cmd->qsg); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; } @@ -1221,7 +1221,7 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) info.size = dcmd_size; trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + resid = dma_buf_read(&info, dcmd_size, &cmd->qsg); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; } @@ -1390,7 +1390,7 @@ static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd) ld_offset += sizeof(struct mfi_ld_config); } - cmd->iov_size -= dma_buf_read((uint8_t *)data, info->size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(data, info->size, &cmd->qsg); return MFI_STAT_OK; } @@ -1420,7 +1420,7 @@ static int megasas_dcmd_get_properties(MegasasState *s, MegasasCmd *cmd) info.ecc_bucket_leak_rate = cpu_to_le16(1440); info.expose_encl_devices = 1; - cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); return MFI_STAT_OK; } @@ -1465,7 +1465,7 @@ static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd) dcmd_size); return MFI_STAT_INVALID_PARAMETER; } - dma_buf_write((uint8_t *)&info, dcmd_size, &cmd->qsg); + dma_buf_write(&info, dcmd_size, &cmd->qsg); trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size); return MFI_STAT_OK; } diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 09e29997ee5..7f37548394e 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -317,12 +317,12 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, return resid; } -uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg) +uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg) { return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE); } -uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg) +uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg) { return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE); } From patchwork Thu Dec 23 11:55:40 2021 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: 12698183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A012CC433EF for ; Thu, 23 Dec 2021 12:19:44 +0000 (UTC) Received: from localhost ([::1]:48368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N4R-0001wj-LR for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:19:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mjn-00014f-0E for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mjk-0000s7-6c for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260699; 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=6ClHQDmTSxQ/cumSM1yZjo1Fs51nTIVwwLPVpnYX4XM=; b=LDGu42JJjTXk95e2zEEvfPIluhOWTz/f2VvPwUdcsPEKGC9KrxrNMR5xfwzHrnViXFitgM huX39skq0kQw+ytnIMUIyhpZ9KBGTepcvrWFb/lM7WW1K7HLZXVUUmKNK3hesjWGtr8vV8 iHMOYV/wMeekBCcYkEb8yTbAgnGqTBw= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-n5u9VM9gP9SCM9ml-CJArg-1; Thu, 23 Dec 2021 06:58:18 -0500 X-MC-Unique: n5u9VM9gP9SCM9ml-CJArg-1 Received: by mail-wr1-f69.google.com with SMTP id d13-20020adf9b8d000000b001a2aa837f8dso1224768wrc.3 for ; Thu, 23 Dec 2021 03:58:18 -0800 (PST) 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=6ClHQDmTSxQ/cumSM1yZjo1Fs51nTIVwwLPVpnYX4XM=; b=lD0bqq8N1enGe8DGTwGJuP7CasOd+xY2A1HV0z5XlxqZxICoZvfzbjgdjUNQGTggGt BVh5f7RrwhezID9b432vsRj/aXQNl2CPxYsDX9qgRTlxh71bNmw2KQSWsb0N4B6jwLx8 LiOWQ5/uwDg/E6HGMthBpzUH+K+RtmkPxnGsSwwc5cuZixF2mtP51R7qDBAi68n04PWI Oh5EHhz28DkYkCg1LQpywD6w61LWH/u+kIBAcV3i43kN8GWoRipOm9a1ZigbflSHs9O3 dK/qKYb6RrHosZCuM6wpOVzUXPuYN2qwXLGz3hieKCUoawWVyqPq3ZOCj+jX6TprTtEs RFqQ== X-Gm-Message-State: AOAM5325P2u033Io/c70bXDGsktt7VOM6tzRpG9wo4rrdOVNZ6IOdjL4 VntH3CkTtrvywy9SX0dV7Jn9oqcc4gXoJxlTRfSsxwVdT6abY6h/FB5ZuZopY3jpUnI9vk72ax+ YMAIL7daYqZjv9FgNNhqCKJ1ZwOjuT55nPeF+ZF1/mQYXYZbJwg7+otPHahx7hyem X-Received: by 2002:a05:6000:1b03:: with SMTP id f3mr1586601wrz.58.1640260697146; Thu, 23 Dec 2021 03:58:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6LSqx1lAlM4+O12ZG1CQBNVmSMJr77+J1lVAQwAJwQDWGU/cO4bMwt8j/YsG4wFiR5IFe5A== X-Received: by 2002:a05:6000:1b03:: with SMTP id f3mr1586546wrz.58.1640260696852; Thu, 23 Dec 2021 03:58:16 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id k31sm4610764wms.21.2021.12.23.03.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:58:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/23] dma: Let pci_dma_rw() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:40 +0100 Message-Id: <20211223115554.3155328-10-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling pci_dma_rw(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 10 ++++++---- hw/audio/intel-hda.c | 3 ++- hw/scsi/esp-pci.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 1acefc2a4c3..a751ab5a75d 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -806,10 +806,10 @@ static inline AddressSpace *pci_get_address_space(PCIDevice *dev) */ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dma_addr_t addr, void *buf, dma_addr_t len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, - dir, MEMTXATTRS_UNSPECIFIED); + dir, attrs); } /** @@ -827,7 +827,8 @@ static inline MemTxResult pci_dma_rw(PCIDevice *dev, dma_addr_t addr, 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); + return pci_dma_rw(dev, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); } /** @@ -845,7 +846,8 @@ static inline MemTxResult pci_dma_read(PCIDevice *dev, dma_addr_t addr, 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); + return pci_dma_rw(dev, addr, (void *) buf, len, + DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED); } #define PCI_DMA_DEFINE_LDST(_l, _s, _bits) \ diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 8ce9df64e3e..fb3d34a4a0c 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -427,7 +427,8 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, dprint(d, 3, "dma: entry %d, pos %d/%d, copy %d\n", st->be, st->bp, st->bpl[st->be].len, copy); - pci_dma_rw(&d->pci, st->bpl[st->be].addr + st->bp, buf, copy, !output); + pci_dma_rw(&d->pci, st->bpl[st->be].addr + st->bp, buf, copy, !output, + MEMTXATTRS_UNSPECIFIED); st->lpib += copy; st->bp += copy; buf += copy; diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index dac054aeed4..1792f84cea6 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -280,7 +280,7 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, len = pci->dma_regs[DMA_WBC]; } - pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir); + pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir, MEMTXATTRS_UNSPECIFIED); /* update status registers */ pci->dma_regs[DMA_WBC] -= len; From patchwork Thu Dec 23 11:55:41 2021 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: 12698190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 19CB5C433F5 for ; Thu, 23 Dec 2021 12:24:44 +0000 (UTC) Received: from localhost ([::1]:33606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N9G-0002m8-Uu for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:24:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mjx-0001WI-3O for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mjv-0000tB-A9 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260710; 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=cIMQ6+5zcOJyU3/jxVV3Bhh/HwifxZgqMUUJxuhYIK8=; b=V3MSy1KQMcCauM9AUhG4DD3p/YiReRdQ64IQMI8Nxjg6Hoel/22Qsb7niA8FtpbH0uee2C npsONPjs3NCVwWUyjqE9+iKx1bcW8+hFtdpDgTVAqhlvWOG9tZSeqnWeJh8SvNb50lFbXx 278nE6g5z9ahCuStp1LVy5vKlUPW0jY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-hOCtPbPCNKKxMHkMVSAL4A-1; Thu, 23 Dec 2021 06:58:30 -0500 X-MC-Unique: hOCtPbPCNKKxMHkMVSAL4A-1 Received: by mail-wm1-f72.google.com with SMTP id r8-20020a05600c35c800b00345bfa31160so1892392wmq.0 for ; Thu, 23 Dec 2021 03:58:29 -0800 (PST) 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=cIMQ6+5zcOJyU3/jxVV3Bhh/HwifxZgqMUUJxuhYIK8=; b=QCH8yr6CpQGzyq9rD+tvvupnicuIK2rP1zjC3bw4Q3d6p1QpBfSafaPTajvLzSIdtd PtddIdqquz37eFxkSBgptP3dYukv9PWjci8/6l235uA6xc4X4OVoeMAXfPzTf9bNb8xh rP2/ApFwr8erlx2ueKGzj8yM97kKWXk1ysHc83WkTvXC+8drO0HBq4J50TuNhDnMSQj9 hH2xvNvUgv8XlryeReSMLMP3KwX53Z0cqLTYlORdMLV7aWoHbd9+CACH7ZiAZDTHsjw5 cP2JkZwkm005tmyjp+VJ1mWSOM2SGyzXU9oDyll5Rr4QyVplmPCSFqj4D7o+h2QOC2RP y1gQ== X-Gm-Message-State: AOAM533zv68UmKGvRwCnJ6hpkH1KKUXyrl8Liur5LBxQ590QKqwybBdU pfPHe10MW4eMzlJa+lzhkG9IXEFpvjNp9PHSUxnnR2MOiBV+klxGdIFrsT3e83RHGlSH8pMplRE gGSwecbGOCDwOchhkn+ZsVQmNUxoRTGapOpis+OGrnOhLGOLVUty0+COl9J9kLm6r X-Received: by 2002:a7b:cd0e:: with SMTP id f14mr1453693wmj.3.1640260707566; Thu, 23 Dec 2021 03:58:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLg7ZBmot/JWFarBL1366EEW2gjsu8I9BPhoO0enF42tjxKy/3erccjpOE4zYy85mbwd1wfA== X-Received: by 2002:a7b:cd0e:: with SMTP id f14mr1453641wmj.3.1640260707375; Thu, 23 Dec 2021 03:58:27 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id l13sm5229854wrs.73.2021.12.23.03.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:58:26 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 10/23] dma: Let dma_buf_rw() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:41 +0100 Message-Id: <20211223115554.3155328-11-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_buf_rw(). Keep the default MEMTXATTRS_UNSPECIFIED in the 2 callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- softmmu/dma-helpers.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 7f37548394e..fa81d2b386c 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -295,7 +295,7 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk, static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { uint8_t *ptr = buf; uint64_t resid; @@ -307,8 +307,7 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, while (len > 0) { ScatterGatherEntry entry = sg->sg[sg_cur_index++]; int32_t xfer = MIN(len, entry.len); - dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, - MEMTXATTRS_UNSPECIFIED); + dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs); ptr += xfer; len -= xfer; resid -= xfer; @@ -319,12 +318,14 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg) { - return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE); + return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE, + MEMTXATTRS_UNSPECIFIED); } uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg) { - return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE); + return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); } void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, From patchwork Thu Dec 23 11:55:42 2021 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: 12698197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 56408C433F5 for ; Thu, 23 Dec 2021 12:29:33 +0000 (UTC) Received: from localhost ([::1]:41212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NDw-00082z-58 for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:29:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MkA-0001hj-He for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mk6-0000ui-E5 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260721; 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=gjVcgLU0BnvWgwNGKBTyX6uz4VKITDXHkj90FQKH/Ds=; b=b0qoaVkz3L7YKfi58A+6Ch8J0A3IP0bkvEjogTiDDADsd6Fnk8SouZnb6Zdqhz5w3CCBm0 mHPy1cul/SnAbjjR1gtds5HyEcw/MxlyXDm5TuTJKHxhx91FiwnlzTT/W18Vc5FyHQzO5+ T/SKACQopDASr11PaCK26kUtfFhi6DU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-mgIrceFyMTqqpW4gbpsRmQ-1; Thu, 23 Dec 2021 06:58:40 -0500 X-MC-Unique: mgIrceFyMTqqpW4gbpsRmQ-1 Received: by mail-wr1-f71.google.com with SMTP id s23-20020adf9797000000b001a24674f0f7so1222346wrb.9 for ; Thu, 23 Dec 2021 03:58:40 -0800 (PST) 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=gjVcgLU0BnvWgwNGKBTyX6uz4VKITDXHkj90FQKH/Ds=; b=QYkzGzVc6FYSAF+19DhblfgpjDDdqfgl3bMRmnkfqkMNjMJ3b4LdE2cP4HHMrA6gXT sz/3F24IRAftAVPMCF7VcJVWtvnI19gBS1V2apvlumsQoOMOG7iQuY3YQqvYIjF2iXcg /K7lU/nm+4CWB5aAt3QHvKPAML/AUVgNM81i1FDEJYVCu0tTrzKcSoALMxjPLiiqLAnd bA4ABw+OOiH+0czD4wA0lpbePu72DwK+Zuf7wdw+zLXOK57QvQWat0dFO/zH1R5fIJaX 95spgS677CZYXN0gc39e0xnnNJXFNBuS6TDLYX56vZMMVL8pkw6YpGC9L9LbJVNbQPxP Fkrg== X-Gm-Message-State: AOAM533estM73HMGG2/zeJmCSGiWoEm6V/5YOTbbVzohdUzfW5it2buH FJffrWsMDpFZa9CCqCBxz8GAeO2ont7MSXkv9QxGAP5mIJuTrOqxv6XDC30Vj9m4qhe/XYRBXlA 9AcUReyY59Bv2PIP6B9kNYUhllSN1rzLyOUDEAbhVQWiPThfCnxPdvtwUUCYto8EG X-Received: by 2002:a5d:6989:: with SMTP id g9mr1503534wru.12.1640260718958; Thu, 23 Dec 2021 03:58:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBFwsZIXFfAblixbF8BoDE4+EiE/hnMHk6jR/7GpOkCKFeYGbesya6UFj3EsKgkD884hiAXA== X-Received: by 2002:a5d:6989:: with SMTP id g9mr1503479wru.12.1640260718678; Thu, 23 Dec 2021 03:58:38 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id bd8sm4281783wmb.44.2021.12.23.03.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:58:38 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/23] dma: Let dma_buf_write() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:42 +0100 Message-Id: <20211223115554.3155328-12-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_buf_write(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 2 +- hw/ide/ahci.c | 6 ++++-- hw/nvme/ctrl.c | 3 ++- hw/scsi/megasas.c | 2 +- hw/scsi/scsi-bus.c | 2 +- softmmu/dma-helpers.c | 5 ++--- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 0d5b836013d..e3dd74a9c4f 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -303,7 +303,7 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk, QEMUSGList *sg, uint64_t offset, uint32_t align, BlockCompletionFunc *cb, void *opaque); uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg); -uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg); +uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, QEMUSGList *sg, enum BlockAcctType type); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 8e77ddb660f..079d2977f23 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1381,8 +1381,10 @@ static void ahci_pio_transfer(const IDEDMA *dma) has_sglist ? "" : "o"); if (has_sglist && size) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; + if (is_write) { - dma_buf_write(s->data_ptr, size, &s->sg); + dma_buf_write(s->data_ptr, size, &s->sg, attrs); } else { dma_buf_read(s->data_ptr, size, &s->sg); } @@ -1479,7 +1481,7 @@ static int ahci_dma_rw_buf(const IDEDMA *dma, bool is_write) if (is_write) { dma_buf_read(p, l, &s->sg); } else { - dma_buf_write(p, l, &s->sg); + dma_buf_write(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); } /* free sglist, update byte count */ diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 5f573c417b3..e1a531d5d6c 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1146,10 +1146,11 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, uint8_t *ptr, uint32_t len, assert(sg->flags & NVME_SG_ALLOC); if (sg->flags & NVME_SG_DMA) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; uint64_t residual; if (dir == NVME_TX_DIRECTION_TO_DEVICE) { - residual = dma_buf_write(ptr, len, &sg->qsg); + residual = dma_buf_write(ptr, len, &sg->qsg, attrs); } else { residual = dma_buf_read(ptr, len, &sg->qsg); } diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index dc28302f96d..da1c88167ee 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -1465,7 +1465,7 @@ static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd) dcmd_size); return MFI_STAT_INVALID_PARAMETER; } - dma_buf_write(&info, dcmd_size, &cmd->qsg); + dma_buf_write(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size); return MFI_STAT_OK; } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 77325d8cc7a..64a506a3975 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1423,7 +1423,7 @@ void scsi_req_data(SCSIRequest *req, int len) if (req->cmd.mode == SCSI_XFER_FROM_DEV) { req->resid = dma_buf_read(buf, len, req->sg); } else { - req->resid = dma_buf_write(buf, len, req->sg); + req->resid = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); } scsi_req_continue(req); } diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index fa81d2b386c..2f1a241b81a 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -322,10 +322,9 @@ uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg) MEMTXATTRS_UNSPECIFIED); } -uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg) +uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) { - return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE, - MEMTXATTRS_UNSPECIFIED); + return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE, attrs); } void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, From patchwork Thu Dec 23 11:55:43 2021 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: 12698200 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6DE61C433EF for ; Thu, 23 Dec 2021 12:32:17 +0000 (UTC) Received: from localhost ([::1]:48898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NGZ-0004wU-5P for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:32:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MkM-0001tR-AP for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MkJ-0000xo-Un for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:58:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260734; 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=QvhGQ7ni8djSAeJQKRJ8D/v7/Iobbm1EjIUqX2bC7Rw=; b=PtWDrHgnuOnJRSh98MZ420nC6DNp2r+BW8FVLOAGlRpMgd5I8osIxDBr9zSs6Kf0P4fm9s GPBYEXGReJeWPutkkLfv9vhRRBw27eWgFDFabr1UqygIGnuoKH5N8hvtPKzWk+O9eDg98C /9QCuURqiy0ovkDIlWpFZGm1cF5tjv0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134-eLrtoxVkMR2b85sayZkA3w-1; Thu, 23 Dec 2021 06:58:53 -0500 X-MC-Unique: eLrtoxVkMR2b85sayZkA3w-1 Received: by mail-wr1-f71.google.com with SMTP id v18-20020a5d5912000000b001815910d2c0so1224933wrd.1 for ; Thu, 23 Dec 2021 03:58:53 -0800 (PST) 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=QvhGQ7ni8djSAeJQKRJ8D/v7/Iobbm1EjIUqX2bC7Rw=; b=27ylYUzCj+BF9UUfj5d1DYEhCGWF4q1dGGKRW97t/GpXEN9XQFSuXsbOLwVVtaDUAG dmyFfu8a7ZAaKGXotRN5SDemMCUTOer3JhHcSXf08VR526nLNdO5Sr/QdPPM5+1RpawI 46FZVEZljp2ytyFNldea0mqgTt7+2mkAgPZ0yNl0rYjv4sHiLc8FCt/X/Q5n9LFS3SPg FnjUlhk0MMFuCp82Hyu0y7FJQ1uh7TDRyUFlXNLl3Uc2FjRhh77TPUE3L1kCqVa71RPB liy5AxqbRLLTOncJxkM76VTl+ndPfpsuoiyZN+ickzjIWD+nwstNHokxExrABKcwAf8r FF+A== X-Gm-Message-State: AOAM533Q3cTsIFHN9YyZ5fXBXBaKin/qftY/aGXVlEURbYJwD1ujMDby uPfFj5qeThY0CV27kUdCoFFjJSZD7W61NAZ+TykjRoprMVu2xg83ca5Kqa+p8r811W/tjK35+CT 1F4KjzZ7/8giDmhdXaWLKy7sY3ybG5nCPn6MyZg6T+c1L2g81e2cOzw5kBDbuTHoi X-Received: by 2002:adf:c182:: with SMTP id x2mr1570784wre.646.1640260732055; Thu, 23 Dec 2021 03:58:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEF2YmrIC2McauXzIIDHkMe0pi0Zddo8iJsQQQxKSrm0B6dybhy/E1ac8DsfLcJGFXfQpi/Q== X-Received: by 2002:adf:c182:: with SMTP id x2mr1570729wre.646.1640260731702; Thu, 23 Dec 2021 03:58:51 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id az15sm4222751wmb.47.2021.12.23.03.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:58:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 12/23] dma: Let dma_buf_read() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:43 +0100 Message-Id: <20211223115554.3155328-13-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling dma_buf_read(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 2 +- hw/ide/ahci.c | 4 ++-- hw/nvme/ctrl.c | 2 +- hw/scsi/megasas.c | 24 ++++++++++++------------ hw/scsi/scsi-bus.c | 2 +- softmmu/dma-helpers.c | 5 ++--- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index e3dd74a9c4f..fd8f16003dd 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -302,7 +302,7 @@ BlockAIOCB *dma_blk_read(BlockBackend *blk, BlockAIOCB *dma_blk_write(BlockBackend *blk, QEMUSGList *sg, uint64_t offset, uint32_t align, BlockCompletionFunc *cb, void *opaque); -uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg); +uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 079d2977f23..205dfdc6622 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1386,7 +1386,7 @@ static void ahci_pio_transfer(const IDEDMA *dma) if (is_write) { dma_buf_write(s->data_ptr, size, &s->sg, attrs); } else { - dma_buf_read(s->data_ptr, size, &s->sg); + dma_buf_read(s->data_ptr, size, &s->sg, attrs); } } @@ -1479,7 +1479,7 @@ static int ahci_dma_rw_buf(const IDEDMA *dma, bool is_write) } if (is_write) { - dma_buf_read(p, l, &s->sg); + dma_buf_read(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); } else { dma_buf_write(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); } diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index e1a531d5d6c..462f79a1f60 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1152,7 +1152,7 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, uint8_t *ptr, uint32_t len, if (dir == NVME_TX_DIRECTION_TO_DEVICE) { residual = dma_buf_write(ptr, len, &sg->qsg, attrs); } else { - residual = dma_buf_read(ptr, len, &sg->qsg); + residual = dma_buf_read(ptr, len, &sg->qsg, attrs); } if (unlikely(residual)) { diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index da1c88167ee..fe36de10a21 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -848,7 +848,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) MFI_INFO_PDMIX_SATA | MFI_INFO_PDMIX_LD); - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -878,7 +878,7 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd) info.disable_preboot_cli = 1; info.cluster_disable = 1; - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -899,7 +899,7 @@ static int megasas_dcmd_get_bios_info(MegasasState *s, MegasasCmd *cmd) info.expose_all_drives = 1; } - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -910,7 +910,7 @@ static int megasas_dcmd_get_fw_time(MegasasState *s, MegasasCmd *cmd) fw_time = cpu_to_le64(megasas_fw_time()); - cmd->iov_size -= dma_buf_read(&fw_time, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&fw_time, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -937,7 +937,7 @@ static int megasas_event_info(MegasasState *s, MegasasCmd *cmd) info.shutdown_seq_num = cpu_to_le32(s->shutdown_event); info.boot_seq_num = cpu_to_le32(s->boot_event); - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -1006,7 +1006,7 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) info.size = cpu_to_le32(offset); info.count = cpu_to_le32(num_pd_disks); - cmd->iov_size -= dma_buf_read(&info, offset, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, offset, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -1100,7 +1100,7 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, info->connected_port_bitmap = 0x1; info->device_speed = 1; info->link_speed = 1; - resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg); + resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - resid; cmd->iov_buf = NULL; @@ -1172,7 +1172,7 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read(&info, dcmd_size, &cmd->qsg); + resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; } @@ -1221,7 +1221,7 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) info.size = dcmd_size; trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read(&info, dcmd_size, &cmd->qsg); + resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; } @@ -1271,7 +1271,7 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, info->ld_config.span[0].num_blocks = info->size; info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id); - resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg); + resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - resid; cmd->iov_buf = NULL; @@ -1390,7 +1390,7 @@ static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd) ld_offset += sizeof(struct mfi_ld_config); } - cmd->iov_size -= dma_buf_read(data, info->size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(data, info->size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } @@ -1420,7 +1420,7 @@ static int megasas_dcmd_get_properties(MegasasState *s, MegasasCmd *cmd) info.ecc_bucket_leak_rate = cpu_to_le16(1440); info.expose_encl_devices = 1; - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg); + cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); return MFI_STAT_OK; } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 64a506a3975..2b5e9dca311 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1421,7 +1421,7 @@ void scsi_req_data(SCSIRequest *req, int len) buf = scsi_req_get_buf(req); if (req->cmd.mode == SCSI_XFER_FROM_DEV) { - req->resid = dma_buf_read(buf, len, req->sg); + req->resid = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); } else { req->resid = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); } diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index 2f1a241b81a..a391773c296 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -316,10 +316,9 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, return resid; } -uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg) +uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) { - return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE, - MEMTXATTRS_UNSPECIFIED); + return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE, attrs); } uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) From patchwork Thu Dec 23 11:55:44 2021 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: 12698258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D7B3CC433EF for ; Thu, 23 Dec 2021 12:34:44 +0000 (UTC) Received: from localhost ([::1]:57436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NIx-0002Ke-QU for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:34:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MkV-0002JB-Jq for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60231) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MkS-000128-Th for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260744; 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=XDiu/1Y9UJG/Mr1Uyi7hIwmLFqroGRXmqVVQxLYL8lo=; b=DunWXpyQXMTV/4mQqD1DDJzBJakmxkBn7Fyb2iNkuXl0t+ixDUhVpucdYdW72kpwxI9IOz HGYHQ9ISiOpqlGxsqBZHWlxV9OUke004sQ/bvaburE4FiveucyM20edQCEI0xWdHJcJde+ s9n0KxL1QdqlOaHvBtI2yNn0h431fiE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-7DSmB5YjO5ubMEtO9jFL1w-1; Thu, 23 Dec 2021 06:59:03 -0500 X-MC-Unique: 7DSmB5YjO5ubMEtO9jFL1w-1 Received: by mail-wm1-f72.google.com with SMTP id ay41-20020a05600c1e2900b00345a568e6b2so1865697wmb.4 for ; Thu, 23 Dec 2021 03:59:03 -0800 (PST) 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=XDiu/1Y9UJG/Mr1Uyi7hIwmLFqroGRXmqVVQxLYL8lo=; b=EGXy2HG6zrHTn5lq6luHcKLJ/OE46ma29lFA+rsYPgQgG/fgyKmkI/+HP0qi87m5D+ a1lVf57nHGbYQ3M4ll9jqXuBuMgiKblU3gIwasRFTCwoAwwLjdoRHHrwtXqHZfAtFgdl +UvODtkCKG6+D4a6Aufp95qVwHelZRmr/j8uxU0tZ+cW7zfHuQXpbXuAkxTdRada2TwC jx1/dhIJhIfTq1s16mmuJQNqwW68pJ1B2Wd8KtJLnZqefbhOFU6CPfhK5kQb3xcGj47w 6ynVbZFRdrdA+ae7B/312YdDpha8XS2IJJ5KUsSYEZe6sHMd4xEyfloiCURYdl34uyBu j91w== X-Gm-Message-State: AOAM531RFGU9pGkskufsZmVOJlI2gedGBtSJu4yx+Ia0gFT3n27zMZ05 S/ZxGQrdzywoOIKh+eZy5PDbLcBuvOJLFRBtY/zrO4ozUkkQwOpLZqlonJklt2KKxGEOwY4DTyE CrrkNF3WluSWj/8/knqsQMTpIFrcfUAa9NkjDIaWotn1kgWe1NgTwADxaObZ8ZZJ7 X-Received: by 2002:a5d:64c6:: with SMTP id f6mr1468900wri.711.1640260741524; Thu, 23 Dec 2021 03:59:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnxPoqDT/k37moPDRccV+te9B75XwO+CkBI4dcJ0VLH0B//Q3K/CRWOZpRQ4Wm2X9u03Wvfg== X-Received: by 2002:a5d:64c6:: with SMTP id f6mr1468844wri.711.1640260741252; Thu, 23 Dec 2021 03:59:01 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id j13sm8693839wmq.11.2021.12.23.03.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:59:00 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 13/23] dma: Let dma_buf_rw() propagate MemTxResult Date: Thu, 23 Dec 2021 12:55:44 +0100 Message-Id: <20211223115554.3155328-14-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini 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. Since dma_buf_rw() was previously returning the QEMUSGList size not consumed, add an extra argument where this size can be stored. Update the 2 callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- softmmu/dma-helpers.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index a391773c296..b0be1564797 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -294,12 +294,14 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk, } -static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, - DMADirection dir, MemTxAttrs attrs) +static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residp, + QEMUSGList *sg, DMADirection dir, + MemTxAttrs attrs) { uint8_t *ptr = buf; uint64_t resid; int sg_cur_index; + MemTxResult res = MEMTX_OK; resid = sg->size; sg_cur_index = 0; @@ -307,23 +309,34 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, while (len > 0) { ScatterGatherEntry entry = sg->sg[sg_cur_index++]; int32_t xfer = MIN(len, entry.len); - dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs); + res |= dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs); ptr += xfer; len -= xfer; resid -= xfer; } - return resid; + if (residp) { + *residp = resid; + } + return res; } uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) { - return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE, attrs); + uint64_t resid; + + dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_FROM_DEVICE, attrs); + + return resid; } uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) { - return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE, attrs); + uint64_t resid; + + dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_TO_DEVICE, attrs); + + return resid; } void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, From patchwork Thu Dec 23 11:55:45 2021 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: 12698189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6C3C3C433F5 for ; Thu, 23 Dec 2021 12:24:07 +0000 (UTC) Received: from localhost ([::1]:59166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N8g-0000zw-GQ for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:24:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mkl-0002q1-O3 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mkd-00015d-L3 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260755; 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=/EYBW+febHIYQTHlOkEync8IzdNbwI6kyRotYTo3Vg0=; b=SvaQIYf5TRj6u9Oil+Bs+IUFvTSPxYYLsG2N4C0iTFU64SKsdNitAj85VLMqHOeDuW5Rtg +mWlZaDZJuLaMaakIIYNW0bNoYMZnLY0d0KOZqXZXJ0YZXN2oaiPMCyzyQGgfN5xxxOM65 U19jBvIqCBRZIhQD3aVx6FXY+G9Y+rI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-178-rbOucN81Oc2tzwVXapC5AA-1; Thu, 23 Dec 2021 06:59:14 -0500 X-MC-Unique: rbOucN81Oc2tzwVXapC5AA-1 Received: by mail-wr1-f71.google.com with SMTP id j26-20020adfb31a000000b001a2356afd4fso1211581wrd.21 for ; Thu, 23 Dec 2021 03:59:14 -0800 (PST) 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=/EYBW+febHIYQTHlOkEync8IzdNbwI6kyRotYTo3Vg0=; b=yYRifQQs7esUGksFOlxVlvHjXgr93jyb2xeBU4ZzEvkW6pFDUjwRPD0dUwBHyeS5pp EisttGjVljCAzLlQHXeBv7BIU83XKw/C5rlGvGIzldRDLqBcqS6SJtLg1+b3qQ+gIK5a QegS1eZov/BInt+Uvt0IYAh33NgLjp/kMLjYh3mV28OTrEeN0V7Ep49ms7in3GswqJr2 0QNqIrzrh+9yTtXSRh9XUGX55tmX79z9PbfsXa2iupQRPf89L61hSTsL6KzPm5e3vWj9 RGi2VfZ1vndItXavoF6p3565BVyGkJMWF55rdAOPXN6wafGHJe2O9zSz8nEL/Yz06Fzd KlBg== X-Gm-Message-State: AOAM533NglE9/lBUM4snsupN9k8eW9Q6qJMou0kKiCSEGrYxKY+MiB9J YU+oLI1H4NvHD5P81fVcF0VezsLYUEaU0GgQAr4Roey4QpcbNeho6VFzHFftCaQ/htZLSpUggt+ k6rf1wj0+yHg4HYEBxTxHlQy/+LL5MjP9AlYCFeAjbKykPn+7cuAlOlcLiNEqKnoF X-Received: by 2002:a5d:6d8a:: with SMTP id l10mr1535612wrs.276.1640260752865; Thu, 23 Dec 2021 03:59:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaRgJ51599I7DyCet8+Ut1sWRqjVByW/7JuTQpWOL9QU1mMnGXmWnpqwB8ASUCZjGA5dgpXw== X-Received: by 2002:a5d:6d8a:: with SMTP id l10mr1535541wrs.276.1640260752403; Thu, 23 Dec 2021 03:59:12 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id h204sm4790919wmh.33.2021.12.23.03.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:59:12 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 14/23] dma: Let dma_buf_read() / dma_buf_write() propagate MemTxResult Date: Thu, 23 Dec 2021 12:55:45 +0100 Message-Id: <20211223115554.3155328-15-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since the previous commit, dma_buf_rw() returns a MemTxResult type. Do not discard it, return it to the caller. Since both dma_buf_read/dma_buf_write functions were previously returning the QEMUSGList size not consumed, add an extra argument where the unconsummed size can be stored. Update the few callers. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 6 ++++-- hw/ide/ahci.c | 8 ++++---- hw/nvme/ctrl.c | 4 ++-- hw/scsi/megasas.c | 48 ++++++++++++++++++++++++++++++------------- hw/scsi/scsi-bus.c | 4 ++-- softmmu/dma-helpers.c | 18 ++++++---------- 6 files changed, 52 insertions(+), 36 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index fd8f16003dd..d11c1d794f9 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -302,8 +302,10 @@ BlockAIOCB *dma_blk_read(BlockBackend *blk, BlockAIOCB *dma_blk_write(BlockBackend *blk, QEMUSGList *sg, uint64_t offset, uint32_t align, BlockCompletionFunc *cb, void *opaque); -uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); -uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs); +MemTxResult dma_buf_read(void *ptr, int32_t len, uint64_t *residp, + QEMUSGList *sg, MemTxAttrs attrs); +MemTxResult dma_buf_write(void *ptr, int32_t len, uint64_t *residp, + QEMUSGList *sg, MemTxAttrs attrs); void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, QEMUSGList *sg, enum BlockAcctType type); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 205dfdc6622..0c7d31ceada 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1384,9 +1384,9 @@ static void ahci_pio_transfer(const IDEDMA *dma) const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; if (is_write) { - dma_buf_write(s->data_ptr, size, &s->sg, attrs); + dma_buf_write(s->data_ptr, size, NULL, &s->sg, attrs); } else { - dma_buf_read(s->data_ptr, size, &s->sg, attrs); + dma_buf_read(s->data_ptr, size, NULL, &s->sg, attrs); } } @@ -1479,9 +1479,9 @@ static int ahci_dma_rw_buf(const IDEDMA *dma, bool is_write) } if (is_write) { - dma_buf_read(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(p, l, NULL, &s->sg, MEMTXATTRS_UNSPECIFIED); } else { - dma_buf_write(p, l, &s->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_write(p, l, NULL, &s->sg, MEMTXATTRS_UNSPECIFIED); } /* free sglist, update byte count */ diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 462f79a1f60..fa410a179a6 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1150,9 +1150,9 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, uint8_t *ptr, uint32_t len, uint64_t residual; if (dir == NVME_TX_DIRECTION_TO_DEVICE) { - residual = dma_buf_write(ptr, len, &sg->qsg, attrs); + dma_buf_write(ptr, len, &residual, &sg->qsg, attrs); } else { - residual = dma_buf_read(ptr, len, &sg->qsg, attrs); + dma_buf_read(ptr, len, &residual, &sg->qsg, attrs); } if (unlikely(residual)) { diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index fe36de10a21..87101705d01 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -738,6 +738,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) size_t dcmd_size = sizeof(info); BusChild *kid; int num_pd_disks = 0; + uint64_t resid; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -848,7 +849,8 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) MFI_INFO_PDMIX_SATA | MFI_INFO_PDMIX_LD); - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -856,6 +858,7 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd) { struct mfi_defaults info; size_t dcmd_size = sizeof(struct mfi_defaults); + uint64_t resid; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -878,7 +881,8 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd) info.disable_preboot_cli = 1; info.cluster_disable = 1; - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -886,6 +890,7 @@ static int megasas_dcmd_get_bios_info(MegasasState *s, MegasasCmd *cmd) { struct mfi_bios_data info; size_t dcmd_size = sizeof(info); + uint64_t resid; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -899,7 +904,8 @@ static int megasas_dcmd_get_bios_info(MegasasState *s, MegasasCmd *cmd) info.expose_all_drives = 1; } - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -907,10 +913,12 @@ static int megasas_dcmd_get_fw_time(MegasasState *s, MegasasCmd *cmd) { uint64_t fw_time; size_t dcmd_size = sizeof(fw_time); + uint64_t resid; fw_time = cpu_to_le64(megasas_fw_time()); - cmd->iov_size -= dma_buf_read(&fw_time, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&fw_time, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -930,6 +938,7 @@ static int megasas_event_info(MegasasState *s, MegasasCmd *cmd) { struct mfi_evt_log_state info; size_t dcmd_size = sizeof(info); + uint64_t resid; memset(&info, 0, dcmd_size); @@ -937,7 +946,8 @@ static int megasas_event_info(MegasasState *s, MegasasCmd *cmd) info.shutdown_seq_num = cpu_to_le32(s->shutdown_event); info.boot_seq_num = cpu_to_le32(s->boot_event); - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -967,6 +977,7 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) size_t dcmd_size = sizeof(info); BusChild *kid; uint32_t offset, dcmd_limit, num_pd_disks = 0, max_pd_disks; + uint64_t resid; memset(&info, 0, dcmd_size); offset = 8; @@ -1006,7 +1017,8 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) info.size = cpu_to_le32(offset); info.count = cpu_to_le32(num_pd_disks); - cmd->iov_size -= dma_buf_read(&info, offset, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, offset, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -1100,7 +1112,9 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, info->connected_port_bitmap = 0x1; info->device_speed = 1; info->link_speed = 1; - resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(cmd->iov_buf, dcmd_size, &resid, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - resid; cmd->iov_buf = NULL; @@ -1172,7 +1186,7 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd) info.ld_count = cpu_to_le32(num_ld_disks); trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; } @@ -1221,7 +1235,7 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd) info.size = dcmd_size; trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks); - resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); cmd->iov_size = dcmd_size - resid; return MFI_STAT_OK; } @@ -1232,9 +1246,10 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, struct mfi_ld_info *info = cmd->iov_buf; size_t dcmd_size = sizeof(struct mfi_ld_info); uint8_t cdb[6]; - ssize_t len, resid; + ssize_t len; uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF); uint64_t ld_size; + uint64_t resid; if (!cmd->iov_buf) { cmd->iov_buf = g_malloc0(dcmd_size); @@ -1271,7 +1286,8 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, info->ld_config.span[0].num_blocks = info->size; info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id); - resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(cmd->iov_buf, dcmd_size, &resid, &cmd->qsg, + MEMTXATTRS_UNSPECIFIED); g_free(cmd->iov_buf); cmd->iov_size = dcmd_size - resid; cmd->iov_buf = NULL; @@ -1316,6 +1332,7 @@ static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd) struct mfi_config_data *info; int num_pd_disks = 0, array_offset, ld_offset; BusChild *kid; + uint64_t resid; if (cmd->iov_size > 4096) { return MFI_STAT_INVALID_PARAMETER; @@ -1390,7 +1407,8 @@ static int megasas_dcmd_cfg_read(MegasasState *s, MegasasCmd *cmd) ld_offset += sizeof(struct mfi_ld_config); } - cmd->iov_size -= dma_buf_read(data, info->size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(data, info->size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -1398,6 +1416,7 @@ static int megasas_dcmd_get_properties(MegasasState *s, MegasasCmd *cmd) { struct mfi_ctrl_props info; size_t dcmd_size = sizeof(info); + uint64_t resid; memset(&info, 0x0, dcmd_size); if (cmd->iov_size < dcmd_size) { @@ -1420,7 +1439,8 @@ static int megasas_dcmd_get_properties(MegasasState *s, MegasasCmd *cmd) info.ecc_bucket_leak_rate = cpu_to_le16(1440); info.expose_encl_devices = 1; - cmd->iov_size -= dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(&info, dcmd_size, &resid, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + cmd->iov_size -= resid; return MFI_STAT_OK; } @@ -1465,7 +1485,7 @@ static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd) dcmd_size); return MFI_STAT_INVALID_PARAMETER; } - dma_buf_write(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); + dma_buf_write(&info, dcmd_size, NULL, &cmd->qsg, MEMTXATTRS_UNSPECIFIED); trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size); return MFI_STAT_OK; } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 2b5e9dca311..34cf41796bb 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1421,9 +1421,9 @@ void scsi_req_data(SCSIRequest *req, int len) buf = scsi_req_get_buf(req); if (req->cmd.mode == SCSI_XFER_FROM_DEV) { - req->resid = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_read(buf, len, &req->resid, req->sg, MEMTXATTRS_UNSPECIFIED); } else { - req->resid = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED); + dma_buf_write(buf, len, &req->resid, req->sg, MEMTXATTRS_UNSPECIFIED); } scsi_req_continue(req); } diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c index b0be1564797..498303157e9 100644 --- a/softmmu/dma-helpers.c +++ b/softmmu/dma-helpers.c @@ -321,22 +321,16 @@ static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residp, return res; } -uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) +MemTxResult dma_buf_read(void *ptr, int32_t len, uint64_t *residp, + QEMUSGList *sg, MemTxAttrs attrs) { - uint64_t resid; - - dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_FROM_DEVICE, attrs); - - return resid; + return dma_buf_rw(ptr, len, residp, sg, DMA_DIRECTION_FROM_DEVICE, attrs); } -uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs) +MemTxResult dma_buf_write(void *ptr, int32_t len, uint64_t *residp, + QEMUSGList *sg, MemTxAttrs attrs) { - uint64_t resid; - - dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_TO_DEVICE, attrs); - - return resid; + return dma_buf_rw(ptr, len, residp, sg, DMA_DIRECTION_TO_DEVICE, attrs); } void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, From patchwork Thu Dec 23 11:55:46 2021 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: 12698268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5B5D1C433EF for ; Thu, 23 Dec 2021 12:38:43 +0000 (UTC) Received: from localhost ([::1]:39836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NMo-000165-Fx for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:38:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mkt-0003HJ-K5 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mkr-00018L-JL for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260768; 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=NSopmSWVqanwbnplx6qNpP3mtJv+WIiHHgiOwpgcpF4=; b=YJFxS2foWMiGtljxyngGAEBGJ7kpMjni30Jte/xHzWHJbjXuCYaOdA0to+oQ/LIJKz8xle UTCPaLQZrCBJJ39F/lmoOiv3xXs3QHxidHDFcECRh4hj3hggcLApgrhyBbq5mwS3Ymbpsq JyjYCtxirizLiDg74Uav939XpC7V+Sk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-160-4bsE9F6YNNSs8nTZ47y7tw-1; Thu, 23 Dec 2021 06:59:27 -0500 X-MC-Unique: 4bsE9F6YNNSs8nTZ47y7tw-1 Received: by mail-wr1-f69.google.com with SMTP id l13-20020adfbd8d000000b001a23a990dbfso1224303wrh.5 for ; Thu, 23 Dec 2021 03:59:26 -0800 (PST) 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=NSopmSWVqanwbnplx6qNpP3mtJv+WIiHHgiOwpgcpF4=; b=Y23m8ZRca8J2Us5V8OyiRcM5GhY+23k4AcIJGrlrgmriJtSxTvLzO1EwNBwzl7MnWg 4azCC8wgCzIX12ccP4CpOY4miZI82xJ0L+RyP6COCoqwqyQx9N7cyBBoANDrlc14DzaL xI+N1QRoeIu37SkyHyMEBFujOYOR5Gqf8s1TZxZaBrhb6LeaunsC3T7epcfKehw8x95G c9lWFVxKCM8FUJ98JrkLXlUAMGpF+hKacMaIsHJ8DvqkcftlZ+wJgCSHPq8Gwi+zydF6 GSLOneAYMbzmVw52BianByDb+LkJKlG5FyHGWDmZ7kAuieADVf+NelD65eCrObmlWrRo xHXA== X-Gm-Message-State: AOAM532Wj4R9g7Yzr5cH4g2V2q6TK4xwFM3mPfcYsF3qby95evfbf4BQ L39XkpX4pLZ0O+jPGFVufY5TbFd8DJ4LeClwafLQt//9T2w1SRsQ8oSCyAR/5vxZ/k9iOMonbYm GTGLfTvoC1C8Chg4dDd5C4T38UMyimBWXD1TkSncOl340KBxoJOfxhPMsxUt0r2tr X-Received: by 2002:a7b:ca54:: with SMTP id m20mr1476119wml.127.1640260765617; Thu, 23 Dec 2021 03:59:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyn3Nwd76HLINri1ov2M1AHMbGhwDHxRznSJYVEH9ul28NBykc+7yxxHc0RMh8AndmXoGH1gg== X-Received: by 2002:a7b:ca54:: with SMTP id m20mr1476066wml.127.1640260765351; Thu, 23 Dec 2021 03:59:25 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id z5sm4578810wru.87.2021.12.23.03.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:59:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 15/23] dma: Let st*_dma() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:46 +0100 Message-Id: <20211223115554.3155328-16-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling st*_dma(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Richard Henderson Reviewed-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 3 ++- include/hw/ppc/spapr_vio.h | 12 ++++++++---- include/sysemu/dma.h | 10 ++++++---- hw/nvram/fw_cfg.c | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index a751ab5a75d..d07e9707b48 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -859,7 +859,8 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, static inline void st##_s##_pci_dma(PCIDevice *dev, \ dma_addr_t addr, uint##_bits##_t val) \ { \ - st##_s##_dma(pci_get_address_space(dev), addr, val); \ + st##_s##_dma(pci_get_address_space(dev), addr, val, \ + MEMTXATTRS_UNSPECIFIED); \ } PCI_DMA_DEFINE_LDST(ub, b, 8); diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 5d2ea8e6656..e87f8e6f596 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -118,10 +118,14 @@ static inline int spapr_vio_dma_set(SpaprVioDevice *dev, uint64_t taddr, H_DEST_PARM : H_SUCCESS; } -#define vio_stb(_dev, _addr, _val) (stb_dma(&(_dev)->as, (_addr), (_val))) -#define vio_sth(_dev, _addr, _val) (stw_be_dma(&(_dev)->as, (_addr), (_val))) -#define vio_stl(_dev, _addr, _val) (stl_be_dma(&(_dev)->as, (_addr), (_val))) -#define vio_stq(_dev, _addr, _val) (stq_be_dma(&(_dev)->as, (_addr), (_val))) +#define vio_stb(_dev, _addr, _val) \ + (stb_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) +#define vio_sth(_dev, _addr, _val) \ + (stw_be_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) +#define vio_stl(_dev, _addr, _val) \ + (stl_be_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) +#define vio_stq(_dev, _addr, _val) \ + (stq_be_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) #define vio_ldq(_dev, _addr) (ldq_be_dma(&(_dev)->as, (_addr))) int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq); diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index d11c1d794f9..ebbc0501681 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -249,10 +249,11 @@ static inline void dma_memory_unmap(AddressSpace *as, } \ static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ dma_addr_t addr, \ - uint##_bits##_t val) \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ { \ val = cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIED); \ + dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ } static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr) @@ -263,9 +264,10 @@ static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr) return val; } -static inline void stb_dma(AddressSpace *as, dma_addr_t addr, uint8_t val) +static inline void stb_dma(AddressSpace *as, dma_addr_t addr, + uint8_t val, MemTxAttrs attrs) { - dma_memory_write(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); + dma_memory_write(as, addr, &val, 1, attrs); } DEFINE_LDST_DMA(uw, w, 16, le); diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 9b91b15cb08..e5f3c981841 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -360,7 +360,7 @@ static void fw_cfg_dma_transfer(FWCfgState *s) if (dma_memory_read(s->dma_as, dma_addr, &dma, sizeof(dma), MEMTXATTRS_UNSPECIFIED)) { stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), - FW_CFG_DMA_CTL_ERROR); + FW_CFG_DMA_CTL_ERROR, MEMTXATTRS_UNSPECIFIED); return; } @@ -446,7 +446,7 @@ static void fw_cfg_dma_transfer(FWCfgState *s) } stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), - dma.control); + dma.control, MEMTXATTRS_UNSPECIFIED); trace_fw_cfg_read(s, 0); } From patchwork Thu Dec 23 11:55:47 2021 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: 12698274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 69EC4C433EF for ; Thu, 23 Dec 2021 12:49:32 +0000 (UTC) Received: from localhost ([::1]:49140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NXH-00008y-HJ for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:49:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MlA-00040B-F2 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Ml3-0001An-Op for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260781; 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=ftwXgHnQRoZowrvTRk4Xx2aE6O9/FjV/sJjIF9qzyOM=; b=TeK5gcJTFYoCmIYFW08lXV7ueWEeB0+OwRbcNVjb3rhcqQl4EneEvj8EY98XWX0rk5f1P3 UPlQ6BAsOJ0se98ryEeGfQOz5X4WO1bbzhIKb61VP3SSiZs8CrzJwZ80tc9w+9WjE/qQ0l OjrMuA0BlRaTPjm7E1JgLeW4tC0EMFQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134-zhsUQrcuPmijI-X-qHn-6w-1; Thu, 23 Dec 2021 06:59:40 -0500 X-MC-Unique: zhsUQrcuPmijI-X-qHn-6w-1 Received: by mail-wm1-f72.google.com with SMTP id 187-20020a1c02c4000000b003335872db8dso1943430wmc.2 for ; Thu, 23 Dec 2021 03:59:40 -0800 (PST) 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=ftwXgHnQRoZowrvTRk4Xx2aE6O9/FjV/sJjIF9qzyOM=; b=nE2rlnFirqeC8K5oQrFaCtvDg0hSzq8Yo70d3K/tP0QtM0BilzOG74UDjM2laYl34b e+S4mbMKgCeOW4uuGi/SOdImeNypztb8gSm/p6/hcPyNgatfQ3SAGsQqriREqAcLFcUp nUHugbnypKVoa3j4JpSaGv/4O/oCNvy16YFDrj4GHNfBN6/75H9l+gEfiQU1I2agMJ/a +/y2zT1cEL4yVkRdTijdiVZz/6i8Daqp7NZzovlDqRqttJLYG+9x8eSzpDc4FMMlE3Qd wgLrNJ6EJ8T31xGSKiFGQPPrN/HBzoeULqBTClPxsovhAtPO47wwL21juLXS1hDA6cm8 nQFA== X-Gm-Message-State: AOAM533pItY2Bq8kyndRtht3RA/etQAjjrAgvVXAmKnkkNAgdsbmo38O xvRuq7TumBE2/52yaZU5phMfka7M2mo13ySdYzn3wH2ozZ/66mz6JpDCS+xa9FfEK31+fZrY0DS gYNlbV9TlGe5veRvWfaBQRYWDcN4WNABJWJfg/d6oRCh0s8SYhhB8jnoW9MSTkPhB X-Received: by 2002:adf:d1c5:: with SMTP id b5mr1519311wrd.177.1640260778508; Thu, 23 Dec 2021 03:59:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3RYShAZiqz5f6PCfPJ8NH7hoS9j2wFZo+e+5yyk/2KLGEc76Ly6K40LkflzX1JkLhKDSW2Q== X-Received: by 2002:adf:d1c5:: with SMTP id b5mr1519252wrd.177.1640260778196; Thu, 23 Dec 2021 03:59:38 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id o38sm2299342wms.11.2021.12.23.03.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:59:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 16/23] dma: Let ld*_dma() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:47 +0100 Message-Id: <20211223115554.3155328-17-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling ld*_dma(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Richard Henderson Reviewed-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 3 ++- include/hw/ppc/spapr_vio.h | 3 ++- include/sysemu/dma.h | 11 ++++++----- hw/intc/pnv_xive.c | 7 ++++--- hw/usb/hcd-xhci.c | 6 +++--- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index d07e9707b48..0613308b1b6 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -854,7 +854,8 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, static inline uint##_bits##_t ld##_l##_pci_dma(PCIDevice *dev, \ dma_addr_t addr) \ { \ - return ld##_l##_dma(pci_get_address_space(dev), addr); \ + return ld##_l##_dma(pci_get_address_space(dev), addr, \ + MEMTXATTRS_UNSPECIFIED); \ } \ static inline void st##_s##_pci_dma(PCIDevice *dev, \ dma_addr_t addr, uint##_bits##_t val) \ diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index e87f8e6f596..d2ec9b0637f 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -126,7 +126,8 @@ static inline int spapr_vio_dma_set(SpaprVioDevice *dev, uint64_t taddr, (stl_be_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) #define vio_stq(_dev, _addr, _val) \ (stq_be_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) -#define vio_ldq(_dev, _addr) (ldq_be_dma(&(_dev)->as, (_addr))) +#define vio_ldq(_dev, _addr) \ + (ldq_be_dma(&(_dev)->as, (_addr), MEMTXATTRS_UNSPECIFIED)) int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq); diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index ebbc0501681..f3cf60d222d 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -241,10 +241,11 @@ static inline void dma_memory_unmap(AddressSpace *as, #define DEFINE_LDST_DMA(_lname, _sname, _bits, _end) \ static inline uint##_bits##_t ld##_lname##_##_end##_dma(AddressSpace *as, \ - dma_addr_t addr) \ + dma_addr_t addr, \ + MemTxAttrs attrs) \ { \ uint##_bits##_t val; \ - dma_memory_read(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIED); \ + dma_memory_read(as, addr, &val, (_bits) / 8, attrs); \ return _end##_bits##_to_cpu(val); \ } \ static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ @@ -253,14 +254,14 @@ static inline void dma_memory_unmap(AddressSpace *as, MemTxAttrs attrs) \ { \ val = cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ + dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ } -static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr) +static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, MemTxAttrs attrs) { uint8_t val; - dma_memory_read(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); + dma_memory_read(as, addr, &val, 1, attrs); return val; } diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index ad43483612e..d9249bbc0c1 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -172,7 +172,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, /* Get the page size of the indirect table. */ vsd_addr = vsd & VSD_ADDRESS_MASK; - vsd = ldq_be_dma(&address_space_memory, vsd_addr); + vsd = ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -195,7 +195,8 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, /* Load the VSD we are looking for, if not already done */ if (vsd_idx) { vsd_addr = vsd_addr + vsd_idx * XIVE_VSD_SIZE; - vsd = ldq_be_dma(&address_space_memory, vsd_addr); + vsd = ldq_be_dma(&address_space_memory, vsd_addr, + MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -542,7 +543,7 @@ static uint64_t pnv_xive_vst_per_subpage(PnvXive *xive, uint32_t type) /* Get the page size of the indirect table. */ vsd_addr = vsd & VSD_ADDRESS_MASK; - vsd = ldq_be_dma(&address_space_memory, vsd_addr); + vsd = ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index ed2b9ea456e..d960b814587 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2062,7 +2062,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); - poctx = ldq_le_dma(xhci->as, dcbaap + 8 * slotid); + poctx = ldq_le_dma(xhci->as, dcbaap + 8 * slotid, MEMTXATTRS_UNSPECIFIED); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); @@ -3437,8 +3437,8 @@ static int usb_xhci_post_load(void *opaque, int version_id) if (!slot->addressed) { continue; } - slot->ctx = - xhci_mask64(ldq_le_dma(xhci->as, dcbaap + 8 * slotid)); + slot->ctx = xhci_mask64(ldq_le_dma(xhci->as, dcbaap + 8 * slotid, + MEMTXATTRS_UNSPECIFIED)); xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx)); slot->uport = xhci_lookup_uport(xhci, slot_ctx); if (!slot->uport) { From patchwork Thu Dec 23 11:55:48 2021 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: 12698191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 67388C433EF for ; Thu, 23 Dec 2021 12:26:30 +0000 (UTC) Received: from localhost ([::1]:36002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NAu-0004O1-3N for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:26:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MlL-0004a4-06 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33195) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MlJ-0001E8-8t for qemu-devel@nongnu.org; Thu, 23 Dec 2021 06:59:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260795; 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=AccLfnY/B/12ZHLoZ2OU6IixKvcUVx9674CliXPrEJo=; b=Yt0Q84EV+TTM+tQVeUw2MrHn1uzPEocDodtyvb3D7/3ESa19XGN4WSPeLcKwLLurDhKEKe ebBJU4EDAP2vR+X/bA39GExlMsrHIPOESLDf2N0ztqdEBl2uoIGglzwW5Zu0NVmSPpuB/B 7rWorTQoUaNM99aS4K3Nm2Ano2fhdtI= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-489-0a5GKM3pPQiS0Jor_R9Cbw-1; Thu, 23 Dec 2021 06:59:54 -0500 X-MC-Unique: 0a5GKM3pPQiS0Jor_R9Cbw-1 Received: by mail-wm1-f69.google.com with SMTP id m19-20020a05600c4f5300b00345cb6e8dd4so1669783wmq.3 for ; Thu, 23 Dec 2021 03:59:54 -0800 (PST) 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=AccLfnY/B/12ZHLoZ2OU6IixKvcUVx9674CliXPrEJo=; b=hijEEsQMf/eWr5QbDEQ/XpWifR2cayaWU9rEBILWiQtAPxfQUZCyo2JMezT9l2qKD+ hAv46eSOTCambMsL5c4sBIBkw7pUAnBuW0m3XWjitzidSKjYWmInovJuwryG0vaqYjPv XJ+dzIkYZZLyIWxvWbjsBFz3oZt0UUUU1vnyp2/vkb3diQLKsewkas9HE+/UubiRArsT MTy7zm8/sADVbWgzTPevu0GHCEQS5V2BksdaLiFOGizS0G8VAWKtajy1fnohbBwgP0uT PepWoDey0vYi+1WnN6K9sBuHfTltLpv35RyMDRqe+uH/tvVUGp/y7FSLOuOoSiv5SFwL RbtA== X-Gm-Message-State: AOAM531Gq53vG5Np4TewVmnlTdT50fAeiDEx1QLngw18KTvtE7SnajXW B8ziwgwsYFS6PkXdZ5hiyyIfWmVB+wADV8uN5UaJJ6zkbIDljQqTNK0IJZX1xcoWbd7ka1FlE4r /2nXBTKAHRc/jJ6kezmzFXHKCnracDpQe5tyvMvohyCBJnu+G5A7bLNYhE70vHSEq X-Received: by 2002:a05:600c:1f18:: with SMTP id bd24mr1593871wmb.174.1640260793203; Thu, 23 Dec 2021 03:59:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/oJ4qDHZs1qmUK48d0flpcHtTo7uhZOdN58vL8y6w/JcRg0Kb4wZpKSYPbM+SK/9h+ecGLw== X-Received: by 2002:a05:600c:1f18:: with SMTP id bd24mr1593821wmb.174.1640260793042; Thu, 23 Dec 2021 03:59:53 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id i4sm7759112wmd.34.2021.12.23.03.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:59:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 17/23] dma: Let st*_dma() propagate MemTxResult Date: Thu, 23 Dec 2021 12:55:48 +0100 Message-Id: <20211223115554.3155328-18-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" dma_memory_write() returns a MemTxResult type. Do not discard it, return it to the caller. Reviewed-by: Richard Henderson Reviewed-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/dma.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index f3cf60d222d..725e8e90f88 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -248,13 +248,13 @@ static inline void dma_memory_unmap(AddressSpace *as, dma_memory_read(as, addr, &val, (_bits) / 8, attrs); \ return _end##_bits##_to_cpu(val); \ } \ - static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ - dma_addr_t addr, \ - uint##_bits##_t val, \ - MemTxAttrs attrs) \ - { \ - val = cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ + static inline MemTxResult st##_sname##_##_end##_dma(AddressSpace *as, \ + dma_addr_t addr, \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ + { \ + val = cpu_to_##_end##_bits(val); \ + return dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ } static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, MemTxAttrs attrs) @@ -265,10 +265,10 @@ static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, MemTxAttrs att return val; } -static inline void stb_dma(AddressSpace *as, dma_addr_t addr, - uint8_t val, MemTxAttrs attrs) +static inline MemTxResult stb_dma(AddressSpace *as, dma_addr_t addr, + uint8_t val, MemTxAttrs attrs) { - dma_memory_write(as, addr, &val, 1, attrs); + return dma_memory_write(as, addr, &val, 1, attrs); } DEFINE_LDST_DMA(uw, w, 16, le); From patchwork Thu Dec 23 11:55:49 2021 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: 12698182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D0A54C433F5 for ; Thu, 23 Dec 2021 12:18:08 +0000 (UTC) Received: from localhost ([::1]:42790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0N2u-0006Uu-0I for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:18:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MlW-0004ky-KB for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MlU-0001Hb-B2 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260807; 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=vdLtyGiJkeMl3td5q47AwY8bpcOEYnDZ2ZEG37vZDgg=; b=TT6FXCqRNiDKhyUlvMGlEbUbkirZ8STVuymUXAga32CdHQXbOYBxp6UAI/WNNx1oFYFAIz IlbUDZjf5Is4gVOVjXboMomNxSstXXnmkC0x9vyKju5csFJMsuTmRQu/sQi7W3cAo/Gj+6 EzRtNh3PgPrzU5aIF5Jbi4YOtYDkg5A= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-VDjI0YK0N1OiZlIGsBNB9Q-1; Thu, 23 Dec 2021 07:00:06 -0500 X-MC-Unique: VDjI0YK0N1OiZlIGsBNB9Q-1 Received: by mail-wm1-f69.google.com with SMTP id b75-20020a1c804e000000b0034569bde713so4533018wmd.9 for ; Thu, 23 Dec 2021 04:00:06 -0800 (PST) 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=vdLtyGiJkeMl3td5q47AwY8bpcOEYnDZ2ZEG37vZDgg=; b=Q2bKpUtcTaqFuOTktH9WpWt3uLpQuiWgiGo+kyKyRl620/peDYr14Mm4s1MJ29LBWn fP9OEP/lkybKKnpCXn3YXdkwLZbgbrTKI4y1rUXoC8SjZNDzoeMU93uh+LRyks5ZDINT sKQmLZnLhuZNjVa9asow6zJ5ABB5Y/wnarbHnvNEMLHH+AbacwOzhBgZiW0hdxzFH0Qq bJ6/j+JwaskNB/PW/rNVzLmnbtIpXTQmMWoJaqWC2j8YqjAHLyiUhj9NK8NNlw0M1Zh0 H1X/045JbBEck//d/9tLr4H0o5rH3SRR9tiZo/0ZwavuFs2Ru86t4G+92jzFwSb7GuDm FZ0g== X-Gm-Message-State: AOAM532z/R0lmdL03XXQ9ylFO2EzHXydTJOb5seN13BeJARVfXGwosaZ fzQ8abrSIq6XABILAr/R4Ewbss+uml/Aqf1UWajt3c5xGO3yiUXjZVuH+YZfbs6nH5U75LYUaP6 VPSLDjgzbjKkO+YnEDN3QfamT6LTXbSo2SGte0gCXEuGWMmNUrOgGfQspiTs8Y2lr X-Received: by 2002:a5d:650f:: with SMTP id x15mr1501835wru.57.1640260805510; Thu, 23 Dec 2021 04:00:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfBj7801Rym+T0NHjEcotQhjhXR9GQW60PbxXO5gjfhMFkT7gYMQ53oDZDV6oIaoYlKafFNw== X-Received: by 2002:a5d:650f:: with SMTP id x15mr1501781wru.57.1640260805125; Thu, 23 Dec 2021 04:00:05 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id s1sm7657694wmh.35.2021.12.23.03.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:00:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 18/23] dma: Let ld*_dma() propagate MemTxResult Date: Thu, 23 Dec 2021 12:55:49 +0100 Message-Id: <20211223115554.3155328-19-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" dma_memory_read() returns a MemTxResult type. Do not discard it, return it to the caller. Update the few callers. Reviewed-by: Richard Henderson Reviewed-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 6 ++++-- include/hw/ppc/spapr_vio.h | 6 +++++- include/sysemu/dma.h | 25 ++++++++++++------------- hw/intc/pnv_xive.c | 8 ++++---- hw/usb/hcd-xhci.c | 7 ++++--- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 0613308b1b6..8c5f2ed5054 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -854,8 +854,10 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, static inline uint##_bits##_t ld##_l##_pci_dma(PCIDevice *dev, \ dma_addr_t addr) \ { \ - return ld##_l##_dma(pci_get_address_space(dev), addr, \ - MEMTXATTRS_UNSPECIFIED); \ + uint##_bits##_t val; \ + ld##_l##_dma(pci_get_address_space(dev), addr, &val, \ + MEMTXATTRS_UNSPECIFIED); \ + return val; \ } \ static inline void st##_s##_pci_dma(PCIDevice *dev, \ dma_addr_t addr, uint##_bits##_t val) \ diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index d2ec9b0637f..7eae1a48478 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -127,7 +127,11 @@ static inline int spapr_vio_dma_set(SpaprVioDevice *dev, uint64_t taddr, #define vio_stq(_dev, _addr, _val) \ (stq_be_dma(&(_dev)->as, (_addr), (_val), MEMTXATTRS_UNSPECIFIED)) #define vio_ldq(_dev, _addr) \ - (ldq_be_dma(&(_dev)->as, (_addr), MEMTXATTRS_UNSPECIFIED)) + ({ \ + uint64_t _val; \ + ldq_be_dma(&(_dev)->as, (_addr), &_val, MEMTXATTRS_UNSPECIFIED); \ + _val; \ + }) int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq); diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 725e8e90f88..e6776586613 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -240,14 +240,15 @@ static inline void dma_memory_unmap(AddressSpace *as, } #define DEFINE_LDST_DMA(_lname, _sname, _bits, _end) \ - static inline uint##_bits##_t ld##_lname##_##_end##_dma(AddressSpace *as, \ - dma_addr_t addr, \ - MemTxAttrs attrs) \ - { \ - uint##_bits##_t val; \ - dma_memory_read(as, addr, &val, (_bits) / 8, attrs); \ - return _end##_bits##_to_cpu(val); \ - } \ + static inline MemTxResult ld##_lname##_##_end##_dma(AddressSpace *as, \ + dma_addr_t addr, \ + uint##_bits##_t *pval, \ + MemTxAttrs attrs) \ + { \ + MemTxResult res = dma_memory_read(as, addr, pval, (_bits) / 8, attrs); \ + _end##_bits##_to_cpus(pval); \ + return res; \ + } \ static inline MemTxResult st##_sname##_##_end##_dma(AddressSpace *as, \ dma_addr_t addr, \ uint##_bits##_t val, \ @@ -257,12 +258,10 @@ static inline void dma_memory_unmap(AddressSpace *as, return dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ } -static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, MemTxAttrs attrs) +static inline MemTxResult ldub_dma(AddressSpace *as, dma_addr_t addr, + uint8_t *val, MemTxAttrs attrs) { - uint8_t val; - - dma_memory_read(as, addr, &val, 1, attrs); - return val; + return dma_memory_read(as, addr, val, 1, attrs); } static inline MemTxResult stb_dma(AddressSpace *as, dma_addr_t addr, diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index d9249bbc0c1..bb207514f2d 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -172,7 +172,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, /* Get the page size of the indirect table. */ vsd_addr = vsd & VSD_ADDRESS_MASK; - vsd = ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECIFIED); + ldq_be_dma(&address_space_memory, vsd_addr, &vsd, MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -195,8 +195,8 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, /* Load the VSD we are looking for, if not already done */ if (vsd_idx) { vsd_addr = vsd_addr + vsd_idx * XIVE_VSD_SIZE; - vsd = ldq_be_dma(&address_space_memory, vsd_addr, - MEMTXATTRS_UNSPECIFIED); + ldq_be_dma(&address_space_memory, vsd_addr, &vsd, + MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -543,7 +543,7 @@ static uint64_t pnv_xive_vst_per_subpage(PnvXive *xive, uint32_t type) /* Get the page size of the indirect table. */ vsd_addr = vsd & VSD_ADDRESS_MASK; - vsd = ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECIFIED); + ldq_be_dma(&address_space_memory, vsd_addr, &vsd, MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index d960b814587..da5a4072107 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2062,7 +2062,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); - poctx = ldq_le_dma(xhci->as, dcbaap + 8 * slotid, MEMTXATTRS_UNSPECIFIED); + ldq_le_dma(xhci->as, dcbaap + 8 * slotid, &poctx, MEMTXATTRS_UNSPECIFIED); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); @@ -3429,6 +3429,7 @@ static int usb_xhci_post_load(void *opaque, int version_id) uint32_t slot_ctx[4]; uint32_t ep_ctx[5]; int slotid, epid, state; + uint64_t addr; dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); @@ -3437,8 +3438,8 @@ static int usb_xhci_post_load(void *opaque, int version_id) if (!slot->addressed) { continue; } - slot->ctx = xhci_mask64(ldq_le_dma(xhci->as, dcbaap + 8 * slotid, - MEMTXATTRS_UNSPECIFIED)); + ldq_le_dma(xhci->as, dcbaap + 8 * slotid, &addr, MEMTXATTRS_UNSPECIFIED); + slot->ctx = xhci_mask64(addr); xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx)); slot->uport = xhci_lookup_uport(xhci, slot_ctx); if (!slot->uport) { From patchwork Thu Dec 23 11:55:50 2021 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: 12698281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1B6F0C433F5 for ; Thu, 23 Dec 2021 12:53:51 +0000 (UTC) Received: from localhost ([::1]:60554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NbR-00081C-Ua for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:53:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mlk-0004mq-HH for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mlh-0001LU-PK for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260821; 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=oOieGHzt55TTLrMgE6y82ndRao5o7/HgB++E/ZPWN8c=; b=EKSjXu0QeGv4YzU7mCLzsDXkOIGWDTZpoFcYKvkxpeElbGU7vJV70yiELo1ZA7hcGE6fTO EhwKywe+9EVMV8DvTGh47WXLHgLkgzkFXh3HhOtHysPU9+BFhYCv7m2JaACB4t7YKeIbcc DhJecQXWlhmnyASejYWBmCR4j4gOgOY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-41J2rQQPMFqOuCxGtcxPdw-1; Thu, 23 Dec 2021 07:00:20 -0500 X-MC-Unique: 41J2rQQPMFqOuCxGtcxPdw-1 Received: by mail-wm1-f70.google.com with SMTP id z13-20020a05600c0a0d00b003457d6619f8so1882244wmp.1 for ; Thu, 23 Dec 2021 04:00:19 -0800 (PST) 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=oOieGHzt55TTLrMgE6y82ndRao5o7/HgB++E/ZPWN8c=; b=7YFgn3DkEyQbM4NOfKsNlpsBskSOkTRJDlB/ps19ByDacdlJ5lUn7IiwtfWTNKbeRJ 5wgcnSoJGROQAU3DO9+lrq6Rw/9TgB1HP7ZcELG19TDM2vjxRJe00KFkwP7QBUABMgjp yMVF4jZqpZg6lRHwtm4pOYrycFBNB3D4Ps0vBKXSjfQoH9nuDkYCtg0Ry8rLYgAwHujS Mvj2PosxpNdVdTrjhpqNdbkknC0mPiEBgkaSNob/y3CCWMMpYbfEZexS3WYiUTGuglOJ pUVc6tppNDDd+Hm/YscjrBQeQOL1bX0bFIjOd1B0yi9WJntA5gfNO36g9qfRjXw65QXa s/Xw== X-Gm-Message-State: AOAM530cwFB26w40z3raFnUUMf+hdZSO5/7BqF857+PBeEVhmr3i2Law fGc8RXvIQKco3oqbBb0Q2xsfn8rxymXde/XUZIvRxPeGW8+rlmkQz531Z/BVPAXsE2I2aWvhswk dgxXYm+0mY/Lb6laj9b+FN/NveBgnW231r2ANWqI91nRBUQ0btVirAOcW3p64IRF8 X-Received: by 2002:adf:dc12:: with SMTP id t18mr1594677wri.566.1640260818982; Thu, 23 Dec 2021 04:00:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGfYn4yd0fXb5c1xYbseXF9g+iDrur+UWaKtsUx6dlZQeu/i7TrlfCzyVN9bsHr2TL9HY27w== X-Received: by 2002:adf:dc12:: with SMTP id t18mr1594625wri.566.1640260818723; Thu, 23 Dec 2021 04:00:18 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id s189sm9632538wme.0.2021.12.23.04.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:00:18 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 19/23] hw/scsi/megasas: Use uint32_t for reply queue head/tail values Date: Thu, 23 Dec 2021 12:55:50 +0100 Message-Id: <20211223115554.3155328-20-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" While the reply queue values fit in 16-bit, they are accessed as 32-bit: 661: s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa); 662: s->reply_queue_head %= MEGASAS_MAX_FRAMES; 663: s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa); 664: s->reply_queue_tail %= MEGASAS_MAX_FRAMES; Having: 41:#define MEGASAS_MAX_FRAMES 2048 /* Firmware limit at 65535 */ In order to update the ld/st*_pci_dma() API to pass the address of the value to access, it is simpler to have the head/tail declared as 32-bit values. Replace the uint16_t by uint32_t, wasting 4 bytes in the MegasasState structure. Acked-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/megasas.c | 4 ++-- hw/scsi/trace-events | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 87101705d01..266c3d38003 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -109,8 +109,8 @@ struct MegasasState { uint64_t reply_queue_pa; void *reply_queue; uint16_t reply_queue_len; - uint16_t reply_queue_head; - uint16_t reply_queue_tail; + uint32_t reply_queue_head; + uint32_t reply_queue_tail; uint64_t consumer_pa; uint64_t producer_pa; diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index 92d5b40f892..ae8551f2797 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -42,18 +42,18 @@ mptsas_config_sas_phy(void *dev, int address, int port, int phy_handle, int dev_ # megasas.c megasas_init_firmware(uint64_t pa) "pa 0x%" PRIx64 " " -megasas_init_queue(uint64_t queue_pa, int queue_len, uint64_t head, uint64_t tail, uint32_t flags) "queue at 0x%" PRIx64 " len %d head 0x%" PRIx64 " tail 0x%" PRIx64 " flags 0x%x" +megasas_init_queue(uint64_t queue_pa, int queue_len, uint32_t head, uint32_t tail, uint32_t flags) "queue at 0x%" PRIx64 " len %d head 0x%" PRIx32 " tail 0x%" PRIx32 " flags 0x%x" megasas_initq_map_failed(int frame) "scmd %d: failed to map queue" megasas_initq_mapped(uint64_t pa) "queue already mapped at 0x%" PRIx64 megasas_initq_mismatch(int queue_len, int fw_cmds) "queue size %d max fw cmds %d" megasas_qf_mapped(unsigned int index) "skip mapped frame 0x%x" megasas_qf_new(unsigned int index, uint64_t frame) "frame 0x%x addr 0x%" PRIx64 megasas_qf_busy(unsigned long pa) "all frames busy for frame 0x%lx" -megasas_qf_enqueue(unsigned int index, unsigned int count, uint64_t context, unsigned int head, unsigned int tail, int busy) "frame 0x%x count %d context 0x%" PRIx64 " head 0x%x tail 0x%x busy %d" -megasas_qf_update(unsigned int head, unsigned int tail, unsigned int busy) "head 0x%x tail 0x%x busy %d" +megasas_qf_enqueue(unsigned int index, unsigned int count, uint64_t context, uint32_t head, uint32_t tail, unsigned int busy) "frame 0x%x count %d context 0x%" PRIx64 " head 0x%" PRIx32 " tail 0x%" PRIx32 " busy %u" +megasas_qf_update(uint32_t head, uint32_t tail, unsigned int busy) "head 0x%" PRIx32 " tail 0x%" PRIx32 " busy %u" megasas_qf_map_failed(int cmd, unsigned long frame) "scmd %d: frame %lu" megasas_qf_complete_noirq(uint64_t context) "context 0x%" PRIx64 " " -megasas_qf_complete(uint64_t context, unsigned int head, unsigned int tail, int busy) "context 0x%" PRIx64 " head 0x%x tail 0x%x busy %d" +megasas_qf_complete(uint64_t context, uint32_t head, uint32_t tail, int busy) "context 0x%" PRIx64 " head 0x%" PRIx32 " tail 0x%" PRIx32 " busy %u" megasas_frame_busy(uint64_t addr) "frame 0x%" PRIx64 " busy" megasas_unhandled_frame_cmd(int cmd, uint8_t frame_cmd) "scmd %d: MFI cmd 0x%x" megasas_handle_scsi(const char *frame, int bus, int dev, int lun, void *sdev, unsigned long size) "%s dev %x/%x/%x sdev %p xfer %lu" From patchwork Thu Dec 23 11:55:51 2021 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: 12698198 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AB9C0C433F5 for ; Thu, 23 Dec 2021 12:29:45 +0000 (UTC) Received: from localhost ([::1]:41832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NE8-000055-Jp for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:29:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mlz-0004vr-GI for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mlx-0001R4-9k for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260835; 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=9pReE1QJ5vxBRMRDloIuGc8yeeo3MgjkQ39UWuGBPOY=; b=RBwwbjlhFo+Q8shguLRHnCtBBxMHErq1LNDudc98l91R8K4EtCzDlzg618Cj8sQwJep2YC GYVJoHypiA5ShOC2ytSiKGbDlXu1Wd+iFKlxhK1SzSzPwe1gEp8wbP54nFtdmrX98n2nMe etEhacYE2HAFiw3tfGiG6vCNsCYC1r4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-94xg_yp8OjeJA1B53SktcA-1; Thu, 23 Dec 2021 07:00:34 -0500 X-MC-Unique: 94xg_yp8OjeJA1B53SktcA-1 Received: by mail-wm1-f71.google.com with SMTP id j207-20020a1c23d8000000b00345b181302eso4563338wmj.1 for ; Thu, 23 Dec 2021 04:00:34 -0800 (PST) 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=9pReE1QJ5vxBRMRDloIuGc8yeeo3MgjkQ39UWuGBPOY=; b=w9zNVKeQ89AbJbUqdRRnmKVpkgqIaiiiFafbgUkEXH0fCPZXX3BBwAOeYMiKKi1esU 9U2tRXvI7HKIWG4G++VEJZRYXG04yChn0qOTgl+MOBG7xXpc5vU57TaxDQburJ9y+UbN rwXyiY3SVWw16iZ2m5cgY4ZVNByZA+4Rq9Hj1+TiziMdVkMxa4PlycAfLxazCvrMPOKT /0wlfpTnSojYw9JqexnkKGaISpOitSGMqtmAOWRUTrRYfXsusI5+E8TkCbiMRf/jEr/a CcTWZkv3p7jSXPPxE1Z2TKveilxnHb6J18A/rRakqNDTsguSX034iD9isDXW93Lmn2Vj jNIA== X-Gm-Message-State: AOAM530M5nQTB92spv4QROqu+bfukH/Uymllg4On/wn7XvXkOyOYU+fF wV56PP3wEN9ORh25s5y2Ue3vfChA77SxU6634X9KcAM77Fasd6G8n79xR1TBVY8u/cn6+O9WODn dqMZjKzi6bZhIL9UHUkLC1ombvJ7nDaNqk/4zfoVH+2r2mSjDZQnbSi9CZrw/O6Sk X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr1584960wrg.31.1640260832954; Thu, 23 Dec 2021 04:00:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/DQ1hWR9qyFgUiRX1uFPfeDojVvudgj5ZvN6Va5wfFpZgZ/IESAYpz2iKee/YDWNEagse0A== X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr1584902wrg.31.1640260832570; Thu, 23 Dec 2021 04:00:32 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id w6sm4601783wrs.52.2021.12.23.04.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:00:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 20/23] pci: Let st*_pci_dma() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:51 +0100 Message-Id: <20211223115554.3155328-21-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling st*_pci_dma(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 11 ++++++----- hw/audio/intel-hda.c | 10 ++++++---- hw/net/eepro100.c | 29 ++++++++++++++++++----------- hw/net/tulip.c | 18 ++++++++++-------- hw/scsi/megasas.c | 15 ++++++++++----- hw/scsi/vmw_pvscsi.c | 3 ++- 6 files changed, 52 insertions(+), 34 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 8c5f2ed5054..9f51ef2c3c2 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -859,11 +859,12 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, MEMTXATTRS_UNSPECIFIED); \ return val; \ } \ - static inline void st##_s##_pci_dma(PCIDevice *dev, \ - dma_addr_t addr, uint##_bits##_t val) \ - { \ - st##_s##_dma(pci_get_address_space(dev), addr, val, \ - MEMTXATTRS_UNSPECIFIED); \ + static inline void st##_s##_pci_dma(PCIDevice *dev, \ + dma_addr_t addr, \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ + { \ + st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \ } PCI_DMA_DEFINE_LDST(ub, b, 8); diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index fb3d34a4a0c..3309ae0ea18 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -345,6 +345,7 @@ static void intel_hda_corb_run(IntelHDAState *d) static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t response) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d = container_of(bus, IntelHDAState, codecs); hwaddr addr; @@ -367,8 +368,8 @@ static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t res ex = (solicited ? 0 : (1 << 4)) | dev->cad; wp = (d->rirb_wp + 1) & 0xff; addr = intel_hda_addr(d->rirb_lbase, d->rirb_ubase); - stl_le_pci_dma(&d->pci, addr + 8*wp, response); - stl_le_pci_dma(&d->pci, addr + 8*wp + 4, ex); + stl_le_pci_dma(&d->pci, addr + 8 * wp, response, attrs); + stl_le_pci_dma(&d->pci, addr + 8 * wp + 4, ex, attrs); d->rirb_wp = wp; dprint(d, 2, "%s: [wp 0x%x] response 0x%x, extra 0x%x\n", @@ -394,6 +395,7 @@ static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t res static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, uint8_t *buf, uint32_t len) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d = container_of(bus, IntelHDAState, codecs); hwaddr addr; @@ -428,7 +430,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, st->be, st->bp, st->bpl[st->be].len, copy); pci_dma_rw(&d->pci, st->bpl[st->be].addr + st->bp, buf, copy, !output, - MEMTXATTRS_UNSPECIFIED); + attrs); st->lpib += copy; st->bp += copy; buf += copy; @@ -451,7 +453,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, if (d->dp_lbase & 0x01) { s = st - d->st; addr = intel_hda_addr(d->dp_lbase & ~0x01, d->dp_ubase); - stl_le_pci_dma(&d->pci, addr + 8*s, st->lpib); + stl_le_pci_dma(&d->pci, addr + 8 * s, st->lpib, attrs); } dprint(d, 3, "dma: --\n"); diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 16e95ef9cc9..83c4431b1ad 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -700,6 +700,8 @@ static void set_ru_state(EEPRO100State * s, ru_state_t state) static void dump_statistics(EEPRO100State * s) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; + /* Dump statistical data. Most data is never changed by the emulation * and always 0, so we first just copy the whole block and then those * values which really matter. @@ -707,16 +709,18 @@ static void dump_statistics(EEPRO100State * s) */ pci_dma_write(&s->dev, s->statsaddr, &s->statistics, s->stats_size); stl_le_pci_dma(&s->dev, s->statsaddr + 0, - s->statistics.tx_good_frames); + s->statistics.tx_good_frames, attrs); stl_le_pci_dma(&s->dev, s->statsaddr + 36, - s->statistics.rx_good_frames); + s->statistics.rx_good_frames, attrs); stl_le_pci_dma(&s->dev, s->statsaddr + 48, - s->statistics.rx_resource_errors); + s->statistics.rx_resource_errors, attrs); stl_le_pci_dma(&s->dev, s->statsaddr + 60, - s->statistics.rx_short_frame_errors); + s->statistics.rx_short_frame_errors, attrs); #if 0 - stw_le_pci_dma(&s->dev, s->statsaddr + 76, s->statistics.xmt_tco_frames); - stw_le_pci_dma(&s->dev, s->statsaddr + 78, s->statistics.rcv_tco_frames); + stw_le_pci_dma(&s->dev, s->statsaddr + 76, + s->statistics.xmt_tco_frames, attrs); + stw_le_pci_dma(&s->dev, s->statsaddr + 78, + s->statistics.rcv_tco_frames, attrs); missing("CU dump statistical counters"); #endif } @@ -833,6 +837,7 @@ static void set_multicast_list(EEPRO100State *s) static void action_command(EEPRO100State *s) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; /* The loop below won't stop if it gets special handcrafted data. Therefore we limit the number of iterations. */ unsigned max_loop_count = 16; @@ -911,7 +916,7 @@ static void action_command(EEPRO100State *s) } /* Write new status. */ stw_le_pci_dma(&s->dev, s->cb_address, - s->tx.status | ok_status | STATUS_C); + s->tx.status | ok_status | STATUS_C, attrs); if (bit_i) { /* CU completed action. */ eepro100_cx_interrupt(s); @@ -937,6 +942,7 @@ static void action_command(EEPRO100State *s) static void eepro100_cu_command(EEPRO100State * s, uint8_t val) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; cu_state_t cu_state; switch (val) { case CU_NOP: @@ -986,7 +992,7 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val) /* Dump statistical counters. */ TRACE(OTHER, logout("val=0x%02x (dump stats)\n", val)); dump_statistics(s); - stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa005); + stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa005, attrs); break; case CU_CMD_BASE: /* Load CU base. */ @@ -997,7 +1003,7 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val) /* Dump and reset statistical counters. */ TRACE(OTHER, logout("val=0x%02x (dump stats and reset)\n", val)); dump_statistics(s); - stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa007); + stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa007, attrs); memset(&s->statistics, 0, sizeof(s->statistics)); break; case CU_SRESUME: @@ -1612,6 +1618,7 @@ static ssize_t nic_receive(NetClientState *nc, const uint8_t * buf, size_t size) * - Magic packets should set bit 30 in power management driver register. * - Interesting packets should set bit 29 in power management driver register. */ + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; EEPRO100State *s = qemu_get_nic_opaque(nc); uint16_t rfd_status = 0xa000; #if defined(CONFIG_PAD_RECEIVED_FRAMES) @@ -1726,9 +1733,9 @@ static ssize_t nic_receive(NetClientState *nc, const uint8_t * buf, size_t size) TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n", rfd_command, rx.link, rx.rx_buf_addr, rfd_size)); stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset + - offsetof(eepro100_rx_t, status), rfd_status); + offsetof(eepro100_rx_t, status), rfd_status, attrs); stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset + - offsetof(eepro100_rx_t, count), size); + offsetof(eepro100_rx_t, count), size, attrs); /* Early receive interrupt not supported. */ #if 0 eepro100_er_interrupt(s); diff --git a/hw/net/tulip.c b/hw/net/tulip.c index ca69f7ea5e1..1f2c79dd58b 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -86,16 +86,18 @@ static void tulip_desc_read(TULIPState *s, hwaddr p, static void tulip_desc_write(TULIPState *s, hwaddr p, struct tulip_descriptor *desc) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; + if (s->csr[0] & CSR0_DBO) { - stl_be_pci_dma(&s->dev, p, desc->status); - stl_be_pci_dma(&s->dev, p + 4, desc->control); - stl_be_pci_dma(&s->dev, p + 8, desc->buf_addr1); - stl_be_pci_dma(&s->dev, p + 12, desc->buf_addr2); + stl_be_pci_dma(&s->dev, p, desc->status, attrs); + stl_be_pci_dma(&s->dev, p + 4, desc->control, attrs); + stl_be_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs); + stl_be_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs); } else { - stl_le_pci_dma(&s->dev, p, desc->status); - stl_le_pci_dma(&s->dev, p + 4, desc->control); - stl_le_pci_dma(&s->dev, p + 8, desc->buf_addr1); - stl_le_pci_dma(&s->dev, p + 12, desc->buf_addr2); + stl_le_pci_dma(&s->dev, p, desc->status, attrs); + stl_le_pci_dma(&s->dev, p + 4, desc->control, attrs); + stl_le_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs); + stl_le_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs); } } diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 266c3d38003..65451d34e64 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -168,14 +168,16 @@ static void megasas_frame_set_cmd_status(MegasasState *s, unsigned long frame, uint8_t v) { PCIDevice *pci = &s->parent_obj; - stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, cmd_status), v); + stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, cmd_status), + v, MEMTXATTRS_UNSPECIFIED); } static void megasas_frame_set_scsi_status(MegasasState *s, unsigned long frame, uint8_t v) { PCIDevice *pci = &s->parent_obj; - stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, scsi_status), v); + stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, scsi_status), + v, MEMTXATTRS_UNSPECIFIED); } static inline const char *mfi_frame_desc(unsigned int cmd) @@ -542,6 +544,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, static void megasas_complete_frame(MegasasState *s, uint64_t context) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; PCIDevice *pci_dev = PCI_DEVICE(s); int tail, queue_offset; @@ -555,10 +558,12 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) */ if (megasas_use_queue64(s)) { queue_offset = s->reply_queue_head * sizeof(uint64_t); - stq_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, context); + stq_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, + context, attrs); } else { queue_offset = s->reply_queue_head * sizeof(uint32_t); - stl_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, context); + stl_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, + context, attrs); } s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa); trace_megasas_qf_complete(context, s->reply_queue_head, @@ -572,7 +577,7 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) s->reply_queue_head = megasas_next_index(s, tail, s->fw_cmds); trace_megasas_qf_update(s->reply_queue_head, s->reply_queue_tail, s->busy); - stl_le_pci_dma(pci_dev, s->producer_pa, s->reply_queue_head); + stl_le_pci_dma(pci_dev, s->producer_pa, s->reply_queue_head, attrs); /* Notify HBA */ if (msix_enabled(pci_dev)) { trace_megasas_msix_raise(0); diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index cd76bd67ab7..59c3e8ba048 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -55,7 +55,8 @@ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field))) #define RS_SET_FIELD(m, field, val) \ (stl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ - (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), val)) + (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), val, \ + MEMTXATTRS_UNSPECIFIED)) struct PVSCSIClass { PCIDeviceClass parent_class; From patchwork Thu Dec 23 11:55:52 2021 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: 12698199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 22A9CC433EF for ; Thu, 23 Dec 2021 12:31:13 +0000 (UTC) Received: from localhost ([::1]:47718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NFY-000489-54 for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:31:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MmE-0005S1-PJ for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MmB-0001UC-O2 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:00:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260851; 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=DBPP1EiSKr7NPlc65W5DPicfsUwIYcUriP04xIPwWVo=; b=KF2Hnwr65JV1HwuW6cfBMppddVg3QyL0YRZFF4Phss6zm+LoFBQA7odQ2rT2xVggejBt11 SGVwgXA3pk/8VYswR4dZQl5IuV/S6gCD2uKvY8R13TOHghXt7Fp9M1/6Kc8x5/npQINXuc kTTDuMmSuPwxmeLim87uxkvk6WBqy3Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-5m6z8bOrOPyRfhtdAuqOSg-1; Thu, 23 Dec 2021 07:00:50 -0500 X-MC-Unique: 5m6z8bOrOPyRfhtdAuqOSg-1 Received: by mail-wm1-f70.google.com with SMTP id v190-20020a1cacc7000000b003456d598510so4547886wme.6 for ; Thu, 23 Dec 2021 04:00:50 -0800 (PST) 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=DBPP1EiSKr7NPlc65W5DPicfsUwIYcUriP04xIPwWVo=; b=sykHOJY+S3YTcYuejSeK1OyLQMql8gVF2Jl/5TxS2wQNDEsEI/t6Q6EHzx5X8X61VD mgMkEhH6hwwDcVgHbRTTKpaS0ASDlDgQ/1fRX12TrOUAPlqGvDt4yAl2/mzlA3v+/G8o fEEHuqfJmzMKt2ss8iKLV/4T8DYPG/XRJwvCHT2u1HNif12n8+fhcqcbjHq3eh6Lslwn sK0P6HJZ6ek+1OT5Kzb6CKZ69Z+gLnBR001t+2SYGOyz8kd3Otk6rmUA4K5Bjvgv6eZH +06De7b0KnKGbkaeLcNoMsULLvk66t2dFsd0TFZVMqVB1iUlqfGT5xyI5sfkFAO2JK9r r7mA== X-Gm-Message-State: AOAM532suT5lElgs2EcAXh9lINCQ/QKWOXlR/kM/8DJ6/nqR1SGuRbZd N8Do0UY9pzQX8RlRay5G+HHRnvBCZd2E/r5oER1wb31QYyb8z+3OGHY4wCSGb2PO0EFYrKk8Lxa 4n22LBNY3pCP0W7O+g+ygpW5FXQIG0dwB0vj7qo+HAWDYgvUWn7mFmkxe8Whf7yGI X-Received: by 2002:adf:d841:: with SMTP id k1mr1632817wrl.396.1640260848605; Thu, 23 Dec 2021 04:00:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3x4bEjyITPOZYC9xFTlLr/8oRH55HegaMaa82awicTJ93Fzb1rX+4CUPeSc+/f+NROOKS2g== X-Received: by 2002:adf:d841:: with SMTP id k1mr1632747wrl.396.1640260848169; Thu, 23 Dec 2021 04:00:48 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id x8sm7654513wmj.44.2021.12.23.04.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:00:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 21/23] pci: Let ld*_pci_dma() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:52 +0100 Message-Id: <20211223115554.3155328-22-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let devices specify transaction attributes when calling ld*_pci_dma(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 6 +++--- hw/audio/intel-hda.c | 2 +- hw/net/eepro100.c | 19 +++++++++++++------ hw/net/tulip.c | 18 ++++++++++-------- hw/scsi/megasas.c | 16 ++++++++++------ hw/scsi/mptsas.c | 10 ++++++---- hw/scsi/vmw_pvscsi.c | 3 ++- hw/usb/hcd-xhci.c | 1 + 8 files changed, 46 insertions(+), 29 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 9f51ef2c3c2..7a46c1fa226 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -852,11 +852,11 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, #define PCI_DMA_DEFINE_LDST(_l, _s, _bits) \ static inline uint##_bits##_t ld##_l##_pci_dma(PCIDevice *dev, \ - dma_addr_t addr) \ + dma_addr_t addr, \ + MemTxAttrs attrs) \ { \ uint##_bits##_t val; \ - ld##_l##_dma(pci_get_address_space(dev), addr, &val, \ - MEMTXATTRS_UNSPECIFIED); \ + ld##_l##_dma(pci_get_address_space(dev), addr, &val, attrs); \ return val; \ } \ static inline void st##_s##_pci_dma(PCIDevice *dev, \ diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 3309ae0ea18..e34b7ab0e92 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -335,7 +335,7 @@ static void intel_hda_corb_run(IntelHDAState *d) rp = (d->corb_rp + 1) & 0xff; addr = intel_hda_addr(d->corb_lbase, d->corb_ubase); - verb = ldl_le_pci_dma(&d->pci, addr + 4*rp); + verb = ldl_le_pci_dma(&d->pci, addr + 4 * rp, MEMTXATTRS_UNSPECIFIED); d->corb_rp = rp; dprint(d, 2, "%s: [rp 0x%x] verb 0x%08x\n", __func__, rp, verb); diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 83c4431b1ad..eb82e9cb118 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -737,6 +737,7 @@ static void read_cb(EEPRO100State *s) static void tx_command(EEPRO100State *s) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; uint32_t tbd_array = s->tx.tbd_array_addr; uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff; /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */ @@ -772,11 +773,14 @@ static void tx_command(EEPRO100State *s) /* Extended Flexible TCB. */ for (; tbd_count < 2; tbd_count++) { uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, - tbd_address); + tbd_address, + attrs); uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, - tbd_address + 4); + tbd_address + 4, + attrs); uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, - tbd_address + 6); + tbd_address + 6, + attrs); tbd_address += 8; TRACE(RXTX, logout ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n", @@ -792,9 +796,12 @@ static void tx_command(EEPRO100State *s) } tbd_address = tbd_array; for (; tbd_count < s->tx.tbd_count; tbd_count++) { - uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, tbd_address); - uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, tbd_address + 4); - uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6); + uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, tbd_address, + attrs); + uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, tbd_address + 4, + attrs); + uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6, + attrs); tbd_address += 8; TRACE(RXTX, logout ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n", diff --git a/hw/net/tulip.c b/hw/net/tulip.c index 1f2c79dd58b..c76e4868f73 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -70,16 +70,18 @@ static const VMStateDescription vmstate_pci_tulip = { static void tulip_desc_read(TULIPState *s, hwaddr p, struct tulip_descriptor *desc) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; + if (s->csr[0] & CSR0_DBO) { - desc->status = ldl_be_pci_dma(&s->dev, p); - desc->control = ldl_be_pci_dma(&s->dev, p + 4); - desc->buf_addr1 = ldl_be_pci_dma(&s->dev, p + 8); - desc->buf_addr2 = ldl_be_pci_dma(&s->dev, p + 12); + desc->status = ldl_be_pci_dma(&s->dev, p, attrs); + desc->control = ldl_be_pci_dma(&s->dev, p + 4, attrs); + desc->buf_addr1 = ldl_be_pci_dma(&s->dev, p + 8, attrs); + desc->buf_addr2 = ldl_be_pci_dma(&s->dev, p + 12, attrs); } else { - desc->status = ldl_le_pci_dma(&s->dev, p); - desc->control = ldl_le_pci_dma(&s->dev, p + 4); - desc->buf_addr1 = ldl_le_pci_dma(&s->dev, p + 8); - desc->buf_addr2 = ldl_le_pci_dma(&s->dev, p + 12); + desc->status = ldl_le_pci_dma(&s->dev, p, attrs); + desc->control = ldl_le_pci_dma(&s->dev, p + 4, attrs); + desc->buf_addr1 = ldl_le_pci_dma(&s->dev, p + 8, attrs); + desc->buf_addr2 = ldl_le_pci_dma(&s->dev, p + 12, attrs); } } diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 65451d34e64..f93c34c4201 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -202,7 +202,9 @@ static uint64_t megasas_frame_get_context(MegasasState *s, unsigned long frame) { PCIDevice *pci = &s->parent_obj; - return ldq_le_pci_dma(pci, frame + offsetof(struct mfi_frame_header, context)); + return ldq_le_pci_dma(pci, + frame + offsetof(struct mfi_frame_header, context), + MEMTXATTRS_UNSPECIFIED); } static bool megasas_frame_is_ieee_sgl(MegasasCmd *cmd) @@ -534,7 +536,8 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, s->busy++; if (s->consumer_pa) { - s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa); + s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa, + MEMTXATTRS_UNSPECIFIED); } trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context, s->reply_queue_head, s->reply_queue_tail, s->busy); @@ -565,14 +568,14 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) stl_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, context, attrs); } - s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa); + s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa, attrs); trace_megasas_qf_complete(context, s->reply_queue_head, s->reply_queue_tail, s->busy); } if (megasas_intr_enabled(s)) { /* Update reply queue pointer */ - s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa); + s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa, attrs); tail = s->reply_queue_head; s->reply_queue_head = megasas_next_index(s, tail, s->fw_cmds); trace_megasas_qf_update(s->reply_queue_head, s->reply_queue_tail, @@ -637,6 +640,7 @@ static void megasas_abort_command(MegasasCmd *cmd) static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; PCIDevice *pcid = PCI_DEVICE(s); uint32_t pa_hi, pa_lo; hwaddr iq_pa, initq_size = sizeof(struct mfi_init_qinfo); @@ -675,9 +679,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) pa_lo = le32_to_cpu(initq->pi_addr_lo); pa_hi = le32_to_cpu(initq->pi_addr_hi); s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo; - s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa); + s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa, attrs); s->reply_queue_head %= MEGASAS_MAX_FRAMES; - s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa); + s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa, attrs); s->reply_queue_tail %= MEGASAS_MAX_FRAMES; flags = le32_to_cpu(initq->flags); if (flags & MFI_QUEUE_FLAG_CONTEXT64) { diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index f6c77655443..ac9f4dfcd2a 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -172,14 +172,15 @@ static const int mpi_request_sizes[] = { static dma_addr_t mptsas_ld_sg_base(MPTSASState *s, uint32_t flags_and_length, dma_addr_t *sgaddr) { + const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; PCIDevice *pci = (PCIDevice *) s; dma_addr_t addr; if (flags_and_length & MPI_SGE_FLAGS_64_BIT_ADDRESSING) { - addr = ldq_le_pci_dma(pci, *sgaddr + 4); + addr = ldq_le_pci_dma(pci, *sgaddr + 4, attrs); *sgaddr += 12; } else { - addr = ldl_le_pci_dma(pci, *sgaddr + 4); + addr = ldl_le_pci_dma(pci, *sgaddr + 4, attrs); *sgaddr += 8; } return addr; @@ -203,7 +204,7 @@ static int mptsas_build_sgl(MPTSASState *s, MPTSASRequest *req, hwaddr addr) dma_addr_t addr, len; uint32_t flags_and_length; - flags_and_length = ldl_le_pci_dma(pci, sgaddr); + flags_and_length = ldl_le_pci_dma(pci, sgaddr, MEMTXATTRS_UNSPECIFIED); len = flags_and_length & MPI_SGE_LENGTH_MASK; if ((flags_and_length & MPI_SGE_FLAGS_ELEMENT_TYPE_MASK) != MPI_SGE_FLAGS_SIMPLE_ELEMENT || @@ -234,7 +235,8 @@ static int mptsas_build_sgl(MPTSASState *s, MPTSASRequest *req, hwaddr addr) break; } - flags_and_length = ldl_le_pci_dma(pci, next_chain_addr); + flags_and_length = ldl_le_pci_dma(pci, next_chain_addr, + MEMTXATTRS_UNSPECIFIED); if ((flags_and_length & MPI_SGE_FLAGS_ELEMENT_TYPE_MASK) != MPI_SGE_FLAGS_CHAIN_ELEMENT) { return MPI_IOCSTATUS_INVALID_SGL; diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 59c3e8ba048..33e16f91116 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -52,7 +52,8 @@ #define RS_GET_FIELD(m, field) \ (ldl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ - (m)->rs_pa + offsetof(struct PVSCSIRingsState, field))) + (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), \ + MEMTXATTRS_UNSPECIFIED)) #define RS_SET_FIELD(m, field, val) \ (stl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), val, \ diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index da5a4072107..14bdb896768 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3440,6 +3440,7 @@ static int usb_xhci_post_load(void *opaque, int version_id) } ldq_le_dma(xhci->as, dcbaap + 8 * slotid, &addr, MEMTXATTRS_UNSPECIFIED); slot->ctx = xhci_mask64(addr); + xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx)); slot->uport = xhci_lookup_uport(xhci, slot_ctx); if (!slot->uport) { From patchwork Thu Dec 23 11:55:53 2021 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: 12698257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DB21BC433F5 for ; Thu, 23 Dec 2021 12:34:23 +0000 (UTC) Received: from localhost ([::1]:55756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NIc-0001Bl-QP for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:34:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MmZ-00064V-Rt for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:01:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0MmP-0001aq-47 for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:01:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260864; 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=Xe1vuKIn+V7zfO3YKXmpVrbFyeoxlWXQr1Mcr+LUv2s=; b=OduHoNVKM5lUpZHODOYsMjk3X7aKJwtxxNnMoKozvh0wDjtY8lsfTQq32ToFqEZ8Xw6u0X ilV+jxdo0iTZbEARA7Sc2gMgZn8NDULNpKBL8p1fOIrVWSVNkADHCoEp/IwmhSnHfow4fK mWuNPFVfD0PmH2J56e00hUsolUiae6M= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-xzFU0Un5M5qliWCTf_1Gqg-1; Thu, 23 Dec 2021 07:01:03 -0500 X-MC-Unique: xzFU0Un5M5qliWCTf_1Gqg-1 Received: by mail-wm1-f69.google.com with SMTP id a69-20020a1c7f48000000b00345d3d135caso757201wmd.7 for ; Thu, 23 Dec 2021 04:01:03 -0800 (PST) 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=Xe1vuKIn+V7zfO3YKXmpVrbFyeoxlWXQr1Mcr+LUv2s=; b=TXlnj3bQUP0jq6T48LhSlTnfQWFPkgOpz71xgGzWty2nMAbzCf1EQbbLk/reKuG/ED 3FUOBS5UBBmxH6YHtwi8dwqY1CSGKf7UljrZXcSJe+koPX/EUaxkPH7Yk2MEJ/ZosVID 93tvZLNJdHQFY4JhAVXZYZJ8NtwhZYzxyb6gla2YDz67E5vpj13msMEIzISF8lOOX66B fdCR4uKjq/woJSLKxWPbSS3QzaWSb51ZrbhS6BfhXVgvatsjLgjJozmv0HQ4gzrKX/y/ cy2PSX+P43nNA8xOTkIdVCBcs78WFilWEsfu/afNhbaIzm1FprwBEmxpjOP1WoBVXnVD Gp0w== X-Gm-Message-State: AOAM530zTi48+Lg2Zd0gpMhpqvmh+dVvgYF9Mhe+MRbUezjFFbgADeMp QVHCMUDT7q/m69AMSZCBGOT/Eo6u+6PKwoePyiXc1F6Jg/PTuqQLcsQXGclO+cODRY9Sbv0vws4 o7Dl1l8j36hJoATsieVOs+qiy1GHhPkAFcUF7eUJsIJbVXtpfpol9SlS3IZFb0ivU X-Received: by 2002:a7b:cbc3:: with SMTP id n3mr1580247wmi.90.1640260862086; Thu, 23 Dec 2021 04:01:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlrOWfzUgzbU2x0aJm7EBIoyyeAl+mK7+LF+Bv/edFZaK9HYzsPmOF85+Vj2bXFjyAXF+glQ== X-Received: by 2002:a7b:cbc3:: with SMTP id n3mr1580192wmi.90.1640260861824; Thu, 23 Dec 2021 04:01:01 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id l2sm4925992wrs.43.2021.12.23.04.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:01:01 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 22/23] pci: Let st*_pci_dma() propagate MemTxResult Date: Thu, 23 Dec 2021 12:55:53 +0100 Message-Id: <20211223115554.3155328-23-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" st*_dma() returns a MemTxResult type. Do not discard it, return it to the caller. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 7a46c1fa226..c90cecc85c0 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -859,12 +859,12 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, ld##_l##_dma(pci_get_address_space(dev), addr, &val, attrs); \ return val; \ } \ - static inline void st##_s##_pci_dma(PCIDevice *dev, \ - dma_addr_t addr, \ - uint##_bits##_t val, \ - MemTxAttrs attrs) \ + static inline MemTxResult st##_s##_pci_dma(PCIDevice *dev, \ + dma_addr_t addr, \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ { \ - st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \ + return st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \ } PCI_DMA_DEFINE_LDST(ub, b, 8); From patchwork Thu Dec 23 11:55:54 2021 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: 12698260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A27ACC433EF for ; Thu, 23 Dec 2021 12:37:11 +0000 (UTC) Received: from localhost ([::1]:36062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0NLK-0006xR-Et for qemu-devel@archiver.kernel.org; Thu, 23 Dec 2021 07:37:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mmf-00067K-Oi for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:01:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60281) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Mmc-0001cP-LZ for qemu-devel@nongnu.org; Thu, 23 Dec 2021 07:01:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260878; 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=BZC8tfHy3WSbpiqDLZ5c3lPSNjnKLmWgO/7ewjz5hi0=; b=F46FimdcjJUZnskzs23WuaKtDuQMf8h8+qSgIRFN1GPra4SN0dmFZOC41ls3tvoavBOmEz C6DAysSu60JJMJ7tQzDQxJ6vUmPwJbjZPwL/N/7blxnNjp1ZVAVi0WPAyXmVsCfXNayVMk GoWUCwLKzyQSPTAOfeBzF59C6jQl3o0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404--zoP9OjOOYCBAEGA3vydyg-1; Thu, 23 Dec 2021 07:01:17 -0500 X-MC-Unique: -zoP9OjOOYCBAEGA3vydyg-1 Received: by mail-wr1-f70.google.com with SMTP id h12-20020adfa4cc000000b001a22dceda69so1215171wrb.16 for ; Thu, 23 Dec 2021 04:01:16 -0800 (PST) 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=BZC8tfHy3WSbpiqDLZ5c3lPSNjnKLmWgO/7ewjz5hi0=; b=Da07NMPRf1gcJjJH52jd83z6q8rsORmNzpJQNonTLb4IWe567E7oMfTfdWhucEWo60 Dnj0gQq5Gxm5IuqbynaDRCrxpk5VK6jozepXL9L6Vip0art+voQ1ryU1D7t+wvuq1Co4 hSCufg1YFpY1Whsr3Qd3slhFj5D3K0QcCAML6flXDl3fXCED3PBV8++LSUCkTzdUQSBx MaSf/xdCe6cJTiZVD24ksoRUU+4Ps8wk/Ucg3bxbB221k1vof+GcqHpDWV88BoY2sQXQ teAkZCujj0NYh0wvIHLY8UascACy+hOxyWlTp28GzdeehW53GhG4Vo56RWrZ3Uz+rXBK zX1g== X-Gm-Message-State: AOAM533IeuzJd9JCJ1Llz6AmsbqnQiJNly7NRKq2ZuyUPT6FRzI1EjNZ F0FecPQH9X6PrU4gnY/mxbVTV9rrLXfb19WyUYRIGpm6AXRWSEr7aA/0wWPvpRoHa06QUJpXDUH i/G+OfcXswwqtBEODXzLSY1rEAJhH0MPkydXzXg+K1BkKchQEbQSZLOQv+ovyi6k8 X-Received: by 2002:a05:6000:1545:: with SMTP id 5mr1626722wry.438.1640260875463; Thu, 23 Dec 2021 04:01:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0ZGZvRo+57kUsKr7pNjACll+XAsuQh5o8lCmPbYqhx5o13/FIG5gHw4WPtGn4YvKKzkquEw== X-Received: by 2002:a05:6000:1545:: with SMTP id 5mr1626638wry.438.1640260874931; Thu, 23 Dec 2021 04:01:14 -0800 (PST) Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id l36sm9514934wms.16.2021.12.23.04.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:01:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 23/23] pci: Let ld*_pci_dma() propagate MemTxResult Date: Thu, 23 Dec 2021 12:55:54 +0100 Message-Id: <20211223115554.3155328-24-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , Bin Meng , David Hildenbrand , Peter Xu , Gerd Hoffmann , Klaus Jensen , "Edgar E. Iglesias" , Sven Schnelle , Hannes Reinecke , qemu-block@nongnu.org, Daniel Henrique Barboza , Havard Skinnemoen , Joel Stanley , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Alistair Francis , Richard Henderson , Greg Kurz , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Keith Busch , John Snow , David Gibson , Eduardo Habkost , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Tyrone Ting , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" ld*_dma() returns a MemTxResult type. Do not discard it, return it to the caller. Update the few callers. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 17 ++++++++--------- hw/audio/intel-hda.c | 2 +- hw/net/eepro100.c | 25 ++++++++++--------------- hw/net/tulip.c | 16 ++++++++-------- hw/scsi/megasas.c | 21 ++++++++++++--------- hw/scsi/mptsas.c | 16 +++++++++++----- hw/scsi/vmw_pvscsi.c | 16 ++++++++++------ 7 files changed, 60 insertions(+), 53 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c90cecc85c0..5b36334a28a 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -850,15 +850,14 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED); } -#define PCI_DMA_DEFINE_LDST(_l, _s, _bits) \ - static inline uint##_bits##_t ld##_l##_pci_dma(PCIDevice *dev, \ - dma_addr_t addr, \ - MemTxAttrs attrs) \ - { \ - uint##_bits##_t val; \ - ld##_l##_dma(pci_get_address_space(dev), addr, &val, attrs); \ - return val; \ - } \ +#define PCI_DMA_DEFINE_LDST(_l, _s, _bits) \ + static inline MemTxResult ld##_l##_pci_dma(PCIDevice *dev, \ + dma_addr_t addr, \ + uint##_bits##_t *val, \ + MemTxAttrs attrs) \ + { \ + return ld##_l##_dma(pci_get_address_space(dev), addr, val, attrs); \ + } \ static inline MemTxResult st##_s##_pci_dma(PCIDevice *dev, \ dma_addr_t addr, \ uint##_bits##_t val, \ diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index e34b7ab0e92..2b55d521503 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -335,7 +335,7 @@ static void intel_hda_corb_run(IntelHDAState *d) rp = (d->corb_rp + 1) & 0xff; addr = intel_hda_addr(d->corb_lbase, d->corb_ubase); - verb = ldl_le_pci_dma(&d->pci, addr + 4 * rp, MEMTXATTRS_UNSPECIFIED); + ldl_le_pci_dma(&d->pci, addr + 4 * rp, &verb, MEMTXATTRS_UNSPECIFIED); d->corb_rp = rp; dprint(d, 2, "%s: [rp 0x%x] verb 0x%08x\n", __func__, rp, verb); diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index eb82e9cb118..679f52f80f1 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -769,18 +769,16 @@ static void tx_command(EEPRO100State *s) } else { /* Flexible mode. */ uint8_t tbd_count = 0; + uint32_t tx_buffer_address; + uint16_t tx_buffer_size; + uint16_t tx_buffer_el; + if (s->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) { /* Extended Flexible TCB. */ for (; tbd_count < 2; tbd_count++) { - uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, - tbd_address, - attrs); - uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, - tbd_address + 4, - attrs); - uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, - tbd_address + 6, - attrs); + ldl_le_pci_dma(&s->dev, tbd_address, &tx_buffer_address, attrs); + lduw_le_pci_dma(&s->dev, tbd_address + 4, &tx_buffer_size, attrs); + lduw_le_pci_dma(&s->dev, tbd_address + 6, &tx_buffer_el, attrs); tbd_address += 8; TRACE(RXTX, logout ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n", @@ -796,12 +794,9 @@ static void tx_command(EEPRO100State *s) } tbd_address = tbd_array; for (; tbd_count < s->tx.tbd_count; tbd_count++) { - uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, tbd_address, - attrs); - uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, tbd_address + 4, - attrs); - uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6, - attrs); + ldl_le_pci_dma(&s->dev, tbd_address, &tx_buffer_address, attrs); + lduw_le_pci_dma(&s->dev, tbd_address + 4, &tx_buffer_size, attrs); + lduw_le_pci_dma(&s->dev, tbd_address + 6, &tx_buffer_el, attrs); tbd_address += 8; TRACE(RXTX, logout ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n", diff --git a/hw/net/tulip.c b/hw/net/tulip.c index c76e4868f73..d5b6cc5ee69 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -73,15 +73,15 @@ static void tulip_desc_read(TULIPState *s, hwaddr p, const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; if (s->csr[0] & CSR0_DBO) { - desc->status = ldl_be_pci_dma(&s->dev, p, attrs); - desc->control = ldl_be_pci_dma(&s->dev, p + 4, attrs); - desc->buf_addr1 = ldl_be_pci_dma(&s->dev, p + 8, attrs); - desc->buf_addr2 = ldl_be_pci_dma(&s->dev, p + 12, attrs); + ldl_be_pci_dma(&s->dev, p, &desc->status, attrs); + ldl_be_pci_dma(&s->dev, p + 4, &desc->control, attrs); + ldl_be_pci_dma(&s->dev, p + 8, &desc->buf_addr1, attrs); + ldl_be_pci_dma(&s->dev, p + 12, &desc->buf_addr2, attrs); } else { - desc->status = ldl_le_pci_dma(&s->dev, p, attrs); - desc->control = ldl_le_pci_dma(&s->dev, p + 4, attrs); - desc->buf_addr1 = ldl_le_pci_dma(&s->dev, p + 8, attrs); - desc->buf_addr2 = ldl_le_pci_dma(&s->dev, p + 12, attrs); + ldl_le_pci_dma(&s->dev, p, &desc->status, attrs); + ldl_le_pci_dma(&s->dev, p + 4, &desc->control, attrs); + ldl_le_pci_dma(&s->dev, p + 8, &desc->buf_addr1, attrs); + ldl_le_pci_dma(&s->dev, p + 12, &desc->buf_addr2, attrs); } } diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index f93c34c4201..efcd8e3035e 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -202,9 +202,12 @@ static uint64_t megasas_frame_get_context(MegasasState *s, unsigned long frame) { PCIDevice *pci = &s->parent_obj; - return ldq_le_pci_dma(pci, - frame + offsetof(struct mfi_frame_header, context), - MEMTXATTRS_UNSPECIFIED); + uint64_t val; + + ldq_le_pci_dma(pci, frame + offsetof(struct mfi_frame_header, context), + &val, MEMTXATTRS_UNSPECIFIED); + + return val; } static bool megasas_frame_is_ieee_sgl(MegasasCmd *cmd) @@ -536,8 +539,8 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, s->busy++; if (s->consumer_pa) { - s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa, - MEMTXATTRS_UNSPECIFIED); + ldl_le_pci_dma(pcid, s->consumer_pa, &s->reply_queue_tail, + MEMTXATTRS_UNSPECIFIED); } trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context, s->reply_queue_head, s->reply_queue_tail, s->busy); @@ -568,14 +571,14 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) stl_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, context, attrs); } - s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa, attrs); + ldl_le_pci_dma(pci_dev, s->consumer_pa, &s->reply_queue_tail, attrs); trace_megasas_qf_complete(context, s->reply_queue_head, s->reply_queue_tail, s->busy); } if (megasas_intr_enabled(s)) { /* Update reply queue pointer */ - s->reply_queue_tail = ldl_le_pci_dma(pci_dev, s->consumer_pa, attrs); + ldl_le_pci_dma(pci_dev, s->consumer_pa, &s->reply_queue_tail, attrs); tail = s->reply_queue_head; s->reply_queue_head = megasas_next_index(s, tail, s->fw_cmds); trace_megasas_qf_update(s->reply_queue_head, s->reply_queue_tail, @@ -679,9 +682,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) pa_lo = le32_to_cpu(initq->pi_addr_lo); pa_hi = le32_to_cpu(initq->pi_addr_hi); s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo; - s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa, attrs); + ldl_le_pci_dma(pcid, s->producer_pa, &s->reply_queue_head, attrs); s->reply_queue_head %= MEGASAS_MAX_FRAMES; - s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa, attrs); + ldl_le_pci_dma(pcid, s->consumer_pa, &s->reply_queue_tail, attrs); s->reply_queue_tail %= MEGASAS_MAX_FRAMES; flags = le32_to_cpu(initq->flags); if (flags & MFI_QUEUE_FLAG_CONTEXT64) { diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index ac9f4dfcd2a..5181b0c0b0d 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -177,10 +177,16 @@ static dma_addr_t mptsas_ld_sg_base(MPTSASState *s, uint32_t flags_and_length, dma_addr_t addr; if (flags_and_length & MPI_SGE_FLAGS_64_BIT_ADDRESSING) { - addr = ldq_le_pci_dma(pci, *sgaddr + 4, attrs); + uint64_t addr64; + + ldq_le_pci_dma(pci, *sgaddr + 4, &addr64, attrs); + addr = addr64; *sgaddr += 12; } else { - addr = ldl_le_pci_dma(pci, *sgaddr + 4, attrs); + uint32_t addr32; + + ldl_le_pci_dma(pci, *sgaddr + 4, &addr32, attrs); + addr = addr32; *sgaddr += 8; } return addr; @@ -204,7 +210,7 @@ static int mptsas_build_sgl(MPTSASState *s, MPTSASRequest *req, hwaddr addr) dma_addr_t addr, len; uint32_t flags_and_length; - flags_and_length = ldl_le_pci_dma(pci, sgaddr, MEMTXATTRS_UNSPECIFIED); + ldl_le_pci_dma(pci, sgaddr, &flags_and_length, MEMTXATTRS_UNSPECIFIED); len = flags_and_length & MPI_SGE_LENGTH_MASK; if ((flags_and_length & MPI_SGE_FLAGS_ELEMENT_TYPE_MASK) != MPI_SGE_FLAGS_SIMPLE_ELEMENT || @@ -235,8 +241,8 @@ static int mptsas_build_sgl(MPTSASState *s, MPTSASRequest *req, hwaddr addr) break; } - flags_and_length = ldl_le_pci_dma(pci, next_chain_addr, - MEMTXATTRS_UNSPECIFIED); + ldl_le_pci_dma(pci, next_chain_addr, &flags_and_length, + MEMTXATTRS_UNSPECIFIED); if ((flags_and_length & MPI_SGE_FLAGS_ELEMENT_TYPE_MASK) != MPI_SGE_FLAGS_CHAIN_ELEMENT) { return MPI_IOCSTATUS_INVALID_SGL; diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 33e16f91116..4d9969f3b16 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -50,10 +50,10 @@ #define PVSCSI_MAX_CMD_DATA_WORDS \ (sizeof(PVSCSICmdDescSetupRings)/sizeof(uint32_t)) -#define RS_GET_FIELD(m, field) \ - (ldl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ +#define RS_GET_FIELD(pval, m, field) \ + ldl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), \ - MEMTXATTRS_UNSPECIFIED)) + pval, MEMTXATTRS_UNSPECIFIED) #define RS_SET_FIELD(m, field, val) \ (stl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), val, \ @@ -249,10 +249,11 @@ pvscsi_ring_cleanup(PVSCSIRingInfo *mgr) static hwaddr pvscsi_ring_pop_req_descr(PVSCSIRingInfo *mgr) { - uint32_t ready_ptr = RS_GET_FIELD(mgr, reqProdIdx); + uint32_t ready_ptr; uint32_t ring_size = PVSCSI_MAX_NUM_PAGES_REQ_RING * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; + RS_GET_FIELD(&ready_ptr, mgr, reqProdIdx); if (ready_ptr != mgr->consumed_ptr && ready_ptr - mgr->consumed_ptr < ring_size) { uint32_t next_ready_ptr = @@ -323,8 +324,11 @@ pvscsi_ring_flush_cmp(PVSCSIRingInfo *mgr) static bool pvscsi_ring_msg_has_room(PVSCSIRingInfo *mgr) { - uint32_t prodIdx = RS_GET_FIELD(mgr, msgProdIdx); - uint32_t consIdx = RS_GET_FIELD(mgr, msgConsIdx); + uint32_t prodIdx; + uint32_t consIdx; + + RS_GET_FIELD(&prodIdx, mgr, msgProdIdx); + RS_GET_FIELD(&consIdx, mgr, msgConsIdx); return (prodIdx - consIdx) < (mgr->msg_len_mask + 1); }