From patchwork Thu Jun 2 19:23:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 12868083 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4A2A0CCA47E for ; Thu, 2 Jun 2022 19:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LSRHtj31EnZ5XmhDtJwAXo7LJnhrz2iZkXEmhVsAqNc=; b=BxRqgIaucsoSja NNyrDmElmaVjW1kD+Yd1E6ZZwpj/FZgZ9m9CPt4NfU1rM094liPq07CnWXHYxOXK0cnUyVAh2fqrG +M7gHSpD/QWTJnIWloM7LdNT0sQCghXXUHX0HbK0o4k1N9B3IfUZCcy2YAbkVXwFX5qkupjCOqrJB wXR/ZDS1SjBsO+Q9+kKmLPcF10EDUIlcqYrtBeDmoZA5I6YCSU5f/7V49s6xPANhHzs1KBeCIEqHj PNB62JBPDmFPVISGj4J9pUjV+HgV8Gpcfg6/nvtZSNukeP6aPHhgno9nh6CQ+l9W+yhfFUuV0ofjf QJCHGPssVqKIyf8410SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwqR1-0044Co-FM; Thu, 02 Jun 2022 19:24:43 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwqQf-00440c-3m for linux-arm-kernel@lists.infradead.org; Thu, 02 Jun 2022 19:24:23 +0000 Received: by mail-ej1-x633.google.com with SMTP id y19so11826483ejq.6 for ; Thu, 02 Jun 2022 12:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/L1IBgi9+X4DxS9TjixiTB4nno95/1qL4aRB/Scae3U=; b=PdMHt1DvZ7GZsF7P5quJKwTE1RemEmJBXxcg/aCxYvaydLb4PFeaY8Y6CVo4/M9GgY LNyj2unnT6aDkt+8WZrYPgzMfhGhVS2C2Ofj4o5wz+4WmSS0NbOYsWq+JExbrA7VxMNZ Ig4sZQo92K4+ePFs4E+3BXTSh1I0fUku9zsxxNzN9VD7wEPxoMpdEKttAxh41dbGxpfk aKzfERQE2/K4Vktnpj+ymUwmiqfjIfHIaPZJy9RB8VjwUUQ263jJq7ghMhG+Saaqh8z/ qUljmEwqX5BdWF3vI+z6/YOFY0Dva333dCwiwx/SubCsLzwilyOWqaHsRp9VxXhS5BZD HPGg== 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; bh=/L1IBgi9+X4DxS9TjixiTB4nno95/1qL4aRB/Scae3U=; b=Vsvx0nsT7AVzt2wesoJB5+/p6uofz+eLh8VZV/D9rN0l6rJP5adzSiIuhL8FtxefxE l7WU50hqVuU3iH5R++hluzr4zyEUylSYuRT0kTA6NTPUs2AeJKjXGMkxHSC8qtRRZaHa +8/omuFsIe4n0YTi23U+WTVLnZN57SF+dPwupNJ05jtABeH3rVxa02ElVkGvYLs3zftM NiTl36vrYLolnojzLtRT9sGsedGqU/b9YEZhzZrHY1MMdVctl1xzoX3oVCebfXqbStKR A1+KuVDuoj5HTIwYAVKKYW8ORBDCKhc2au7mtPpOjyqQjaFwX39n5fQLypgEKMKHzurl w8vA== X-Gm-Message-State: AOAM531kFxNjatb9PFCAYWhxMsxGd5y+Rhu/blTicH49vsqJV0Nmpr7M 1pssUkiiy5DTqHYHpLQjobk= X-Google-Smtp-Source: ABdhPJwkE0CY+6aNgdFvX0fyrcHX18bhVxjbK2OvCM9lOWCS4spnr1FzK55RdPxwGJ6AbQ3Ea+5Sgg== X-Received: by 2002:a17:907:2d86:b0:6ff:14d1:b29d with SMTP id gt6-20020a1709072d8600b006ff14d1b29dmr5508138ejc.17.1654197857434; Thu, 02 Jun 2022 12:24:17 -0700 (PDT) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id eg13-20020a056402288d00b0042dce73168csm2938301edb.13.2022.06.02.12.24.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2022 12:24:16 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Russell King , Catalin Marinas , Will Deacon , Boris Ostrovsky , Juergen Gross , Julien Grall , "Michael S. Tsirkin" , Christoph Hellwig Subject: [PATCH V4 1/8] arm/xen: Introduce xen_setup_dma_ops() Date: Thu, 2 Jun 2022 22:23:46 +0300 Message-Id: <1654197833-25362-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1654197833-25362-1-git-send-email-olekstysh@gmail.com> References: <1654197833-25362-1-git-send-email-olekstysh@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220602_122421_213622_985895CC X-CRM114-Status: GOOD ( 20.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Oleksandr Tyshchenko This patch introduces new helper and places it in new header. The helper's purpose is to assign any Xen specific DMA ops in a single place. For now, we deal with xen-swiotlb DMA ops only. The one of the subsequent commits in current series will add xen-grant DMA ops case. Also re-use the xen_swiotlb_detect() check on Arm32. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Stefano Stabellini [For arm64] Acked-by: Catalin Marinas --- Changes RFC -> V1: - update commit description - move commit to the beginning of the series - move #ifdef CONFIG_XEN from dma-mapping.c to xen-ops.h Changes V1 -> V2: - add Stefano's R-b - add missing SPDX-License-Identifier to xen-ops.h Changes V2 -> V3: - add Catalin's A-b Changes V3 -> V4: - no changes --- arch/arm/include/asm/xen/xen-ops.h | 2 ++ arch/arm/mm/dma-mapping.c | 7 ++----- arch/arm64/include/asm/xen/xen-ops.h | 2 ++ arch/arm64/mm/dma-mapping.c | 7 ++----- include/xen/arm/xen-ops.h | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 arch/arm/include/asm/xen/xen-ops.h create mode 100644 arch/arm64/include/asm/xen/xen-ops.h create mode 100644 include/xen/arm/xen-ops.h diff --git a/arch/arm/include/asm/xen/xen-ops.h b/arch/arm/include/asm/xen/xen-ops.h new file mode 100644 index 00000000..7ebb7eb --- /dev/null +++ b/arch/arm/include/asm/xen/xen-ops.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 82ffac6..059cce0 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include "dma.h" #include "mm.h" @@ -2287,10 +2287,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, set_dma_ops(dev, dma_ops); -#ifdef CONFIG_XEN - if (xen_initial_domain()) - dev->dma_ops = &xen_swiotlb_dma_ops; -#endif + xen_setup_dma_ops(dev); dev->archdata.dma_ops_setup = true; } diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h new file mode 100644 index 00000000..7ebb7eb --- /dev/null +++ b/arch/arm64/include/asm/xen/xen-ops.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 6719f9e..6099c81 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -9,9 +9,9 @@ #include #include #include -#include #include +#include void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, enum dma_data_direction dir) @@ -52,8 +52,5 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, if (iommu) iommu_setup_dma_ops(dev, dma_base, dma_base + size - 1); -#ifdef CONFIG_XEN - if (xen_swiotlb_detect()) - dev->dma_ops = &xen_swiotlb_dma_ops; -#endif + xen_setup_dma_ops(dev); } diff --git a/include/xen/arm/xen-ops.h b/include/xen/arm/xen-ops.h new file mode 100644 index 00000000..288deb1 --- /dev/null +++ b/include/xen/arm/xen-ops.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ARM_XEN_OPS_H +#define _ASM_ARM_XEN_OPS_H + +#include + +static inline void xen_setup_dma_ops(struct device *dev) +{ +#ifdef CONFIG_XEN + if (xen_swiotlb_detect()) + dev->dma_ops = &xen_swiotlb_dma_ops; +#endif +} + +#endif /* _ASM_ARM_XEN_OPS_H */