From patchwork Sat May 7 18:19:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 12842119 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 D620AC433F5 for ; Sat, 7 May 2022 18:20:30 +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=ZdkoJsnYnkTkynGjDh4yL2yJh17bTFbfV1zgWieTlrM=; b=B+kIPK1uYdOZ7s snXXVhihDH79ZpPR/6er/06dAtkuh8J0pGewbn+wzZcxKWvG7C3nuAxf5QTF08vcE15xvmskPZe9n k2UsQobnr6ZM/jpbXRt7uGWBSu+iw1IoWCz9UtzbRq59yzEvq8uLUmSgyvqf5mmPPCN7S1i1/BGVe pDmw7IenkdMywxlOlrKqtmk8H3GN8ohGz4LyrduRj66FrB+oJYrEtbYRzBE1vPaPRzBduNzmbmZ13 aiHduSrpLplc+7nP5YrybeHjZvhZfMZ7PdlgcNS0siyW7sJCLo/w8UJLsYVOc2Jp68R2yiRGO2Pa/ pWfdkvRBDEYk2GZQAmFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnP1a-007vGV-FY; Sat, 07 May 2022 18:19:26 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnP1V-007vCe-Ib for linux-arm-kernel@lists.infradead.org; Sat, 07 May 2022 18:19:23 +0000 Received: by mail-wm1-x32f.google.com with SMTP id p189so6244040wmp.3 for ; Sat, 07 May 2022 11:19:21 -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=JdehnkGLqTKFFqJmno6u7ZfWHrdJGNPcR0+Jk9IE3ng=; b=W2CM1/+K9Zk1Kt7dirJgx2bl5Gzq0zuZnPN5BVRpPATox1liMddFAgkXT9YhMEJKJW 3O660mwRMAf8TC005txxxBgmgrS9oiMeZwotoJPeew+vIvCdOm765wKV5c9x0BQ00/qM lOgnr6KN7alyGkPQQDDUnMJeacpkc2gh1QJmK01mhUdDzdgbsOjUoKte+pU3cJeipEuf YSvs0HkqOPU6wQ5cIxg7hJrG1hxCK2aJ4ZjSYAp3T1krrkp7p1CUCOkmJSjmRJV2FUhp N7Fr3JhClK19P4klrT/48MqsDShlu0CI9z8qoywZr6bhKFckl2kixdga3Z5rYAdM4lNL NeOA== 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=JdehnkGLqTKFFqJmno6u7ZfWHrdJGNPcR0+Jk9IE3ng=; b=Lb5LZV/9gjhn/rdlbBcWEDqwN3ulpaFi3bywAT5ai50/fvy/W5LnbWoRtmd9VbMJZu KylYmZMywHBCtMvZOS178KmFXcbHURGaXcesH2XS38vD4i4gZqoKaanFBu5ucQNGN6JH ZMF7mAlqrTADZviWtLufkcn3qcwVwxYRCtAsc1r9KyN2wFq1wdLp6mYFZloQybEt7o2q A9evu8CmI3tFsg/jfMc+KHJeDmquFub2adoQp1IBADMBY2pHgY1BdhjUD1lRS8NM4nFs XH78PfkGe48vhfOHBsY6s+HIJcl8C9222TtDmQA+1tf2eod+fHn9vqY9BbqljFgh4Q+T 9k9A== X-Gm-Message-State: AOAM5318QhYx0SvOzgdmzqQbZc1SmBcBzPZJbr9UGb3ag3CiWJjj16sJ DD9AvYsJvRcmtLIToGq7TxI= X-Google-Smtp-Source: ABdhPJwcoJACAJIOBQsEykFr9K/bH+BLZEo0MgY60F8IfPkFfRkCVpyNg4ZkPrg0s2ewaX0SV0R9DQ== X-Received: by 2002:a7b:c446:0:b0:394:3293:a88f with SMTP id l6-20020a7bc446000000b003943293a88fmr8943853wmi.22.1651947559848; Sat, 07 May 2022 11:19:19 -0700 (PDT) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b10-20020a5d4d8a000000b0020c5253d8f3sm8198457wru.63.2022.05.07.11.19.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 May 2022 11:19:19 -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 V2 1/7] arm/xen: Introduce xen_setup_dma_ops() Date: Sat, 7 May 2022 21:19:02 +0300 Message-Id: <1651947548-4055-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1651947548-4055-1-git-send-email-olekstysh@gmail.com> References: <1651947548-4055-1-git-send-email-olekstysh@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220507_111921_724833_39653228 X-CRM114-Status: GOOD ( 19.96 ) 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 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 --- 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 */