From patchwork Thu Apr 14 19:19:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 12813944 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 229A8C433EF for ; Thu, 14 Apr 2022 19:21:14 +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=WlOlc4zg8imWTC4a/+eHB8coAsjMAa+q+z5YxLz4QjU=; b=2FGKWqw44O2jnv 3sqe7ohYI6YGTdCqShBxD/5VR16voZ0QDBxSKmmJ2+tyDfceKfFmpQfCyg+xTro04fl9j2vlF1A+L 90YhLKHHekWENMotSQ1mKwLTrT/B/925hTlwKw9RWVCypAr3gNnocwxDsHOBoSiG6hKoTxckxJPVz PpyWIlen92to+xXSD304uHLRLfwg/rhfmC/n7jIgyLMuYb6hJK0Q6qwHpLjdXpxIfPWYa/oFp28Xq xuw6RDZw2vs0x1w3VX0WyWh/8LbZiBpgsSLza7ZRcJ9VipwG6tyIi4/pA1RbjB06NioyoUMn3OXFw ccRPfLJoiYTcB+pqyuAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nf50k-00726j-QP; Thu, 14 Apr 2022 19:20:11 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nf50L-0071w4-M1 for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2022 19:19:48 +0000 Received: by mail-lf1-x135.google.com with SMTP id u7so10757007lfs.8 for ; Thu, 14 Apr 2022 12:19:45 -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=lMGcVfKV8sctWGleZvUOf73V/MSGq5S+Npr1qVNtBaA=; b=HouaAb9VHQFNGxR9MIu6VzU91fVp9m4H9MFuGHWemt2O82W51Jf7w0svknXQnp9eoL Goijg/CjOJm12gw7O79o4tOKKi3VWVpFlGcCExQrgrgWjTLybck87oaBE8839ZFvqsgt PHA9UIv4u9ZIJ0KRv79B8BNi7Ma48plv0i8Ikw6DPDjZOba9itZELQd6iL42ER4Do5KC KnGW1lDf5sUT5lSWC5BOctu4TM3VkGzNie7bvNS2Bn7x53eayd0Dgb1qqP6phAjj3tzd uRuUa2wtuEaXrTf/kpJoJpqL9whQiLU0m+UmApeEsmIl/mWjegT0468noSCexcMl91FI NpKQ== 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=lMGcVfKV8sctWGleZvUOf73V/MSGq5S+Npr1qVNtBaA=; b=MaUGtY2B8I5oP2EAnnMzPjrqlwEJrgMKqEbEd60KxG4hlbeqMufMp0YbhTX2I2mXEI +ZhoC+RRKoMQMJM0GSn5sjqkHL7DFoCDt1pio/xqfVt9WoMaB0GPSHxU86NFfdeUfXSv j9yhP5SJwi3EvMHp8EIcjv+IFV06ubOPMPJo0EJCfMvovFmaCM3EV0Fzy1wgAhvDtF1U hLY3Aj6+OGCzNU+weC0TT+jrK/1PA1j4wzvkk/yaclDiEgoTq3IoXSy8Gsfs/lyZea3t QzEZ89hmo1e44JD9rj5eOLbnyJb0dLhIwBeLNCiAXaWvVPjr8L0kcs3/AlZqzlYphVt4 TrXQ== X-Gm-Message-State: AOAM530CwL1Sx0LWojAtbHFwcJ6bivhoVQAaCNvGe26cARyMgi8Uge3q MQln0nw7P1F0MGDVYx0Uqk4= X-Google-Smtp-Source: ABdhPJyqpKzQq/8peqyhT0SdO2Fz0WkprUG2NmtNhK+vB9NhUMwVEFgX8mPVozIXpha113okS20X4g== X-Received: by 2002:a05:6512:3f97:b0:44a:f67d:7d8 with SMTP id x23-20020a0565123f9700b0044af67d07d8mr2755017lfa.81.1649963984241; Thu, 14 Apr 2022 12:19:44 -0700 (PDT) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id l3-20020a194943000000b0046b928d2795sm85001lfj.67.2022.04.14.12.19.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Apr 2022 12:19:43 -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 , Logan Gunthorpe , David Hildenbrand , Martin Oliveira , Kees Cook , Jean-Philippe Brucker , Julien Grall Subject: [RFC PATCH 5/6] arm/xen: Introduce xen_setup_dma_ops() Date: Thu, 14 Apr 2022 22:19:32 +0300 Message-Id: <1649963973-22879-6-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> References: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220414_121945_790022_E38394D7 X-CRM114-Status: GOOD ( 19.24 ) 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 subsequent patch will add xen-virtio DMA ops case. Also re-use the xen_swiotlb_detect() check on Arm32. Signed-off-by: Oleksandr Tyshchenko --- arch/arm/include/asm/xen/xen-ops.h | 1 + arch/arm/mm/dma-mapping.c | 5 ++--- arch/arm64/include/asm/xen/xen-ops.h | 1 + arch/arm64/mm/dma-mapping.c | 5 ++--- include/xen/arm/xen-ops.h | 13 +++++++++++++ 5 files changed, 19 insertions(+), 6 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..8d2fa24 --- /dev/null +++ b/arch/arm/include/asm/xen/xen-ops.h @@ -0,0 +1 @@ +#include diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 82ffac6..a1bf9dd 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" @@ -2288,8 +2288,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; + xen_setup_dma_ops(dev); #endif 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..8d2fa24 --- /dev/null +++ b/arch/arm64/include/asm/xen/xen-ops.h @@ -0,0 +1 @@ +#include diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 6719f9e..831e673 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) @@ -53,7 +53,6 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 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; + xen_setup_dma_ops(dev); #endif } diff --git a/include/xen/arm/xen-ops.h b/include/xen/arm/xen-ops.h new file mode 100644 index 00000000..621da05 --- /dev/null +++ b/include/xen/arm/xen-ops.h @@ -0,0 +1,13 @@ +/* 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) +{ + if (xen_swiotlb_detect()) + dev->dma_ops = &xen_swiotlb_dma_ops; +} + +#endif /* _ASM_ARM_XEN_OPS_H */