Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp853908pxb; Fri, 22 Apr 2022 12:40:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy634bYXde6XVFXK5A7tDMnZEss6TCO1PJVcip4oBnN1unjC+8sxtEnaO6B3MHsLbXR84E8 X-Received: by 2002:a17:902:704b:b0:15c:42fb:e5b with SMTP id h11-20020a170902704b00b0015c42fb0e5bmr3890122plt.79.1650656408427; Fri, 22 Apr 2022 12:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650656408; cv=none; d=google.com; s=arc-20160816; b=NGZyBT3DpL9vrvKStMmGrWswvgvOY58mTe36cXynL1OlwMbS3+BnrL8UczePz5MBAY UhdATrjkUteLEV34Pe+6Pxh6Q9hJ3o5zJIfUrTIaSNo5LMRJAxl1zK2vtCInip3EzMFb U88pKoQGniRCtUL6fy3YmhOA7DL+dR+wDU0SKb8UOHGzGQPzNRHvdQ4bo1MayYDuav0S KzTGjvhlMH7La82cQalwchE3X6DuenVHjwQHiUR6GUOxFylVzNJRQMj0P748nOZuuRRM Pgp3wjsqV7tZy8lm/aej05QClP+33SCEjK1A98Db3Tx9+d4mgwlrZC5mU1+AwP2v0Vkg dI5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=GMgjzuq0mtE7dfPwrz9iyN7XiqhJI/kKUBmloz8CHVM=; b=y0GS2LBEBjDMqf+HC5bBaETy5xbasFlj/FFVsEHFaSfr+4wuZcERAnbfkcy1L0fFHi AgtZGj2ZrUmXYGbx/Fl9iDtYDSW0iqL9KFiMT+vpVfDJcgCpo+lWUka9Dd3rE9S6hRW2 ezKOmLVOSH1nnNkR7rsnAMzWdkWqmxYC72a2ybYARRXuZrb6evrFzpEJ7awcuOFbXaPK ez7B7uLGlaG7bBWebyXi7mYWFJOA9p94rnrony/sBOrH+s0hoCl8W//FkrPvrlze07E6 3J/WWAf5BVaVDqOnpBA9IC3JtdMfb1nBic+YI9LA04a5lpCSKVQ75oOYyyC9tQkYtM78 e6+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TvogOFhS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mw14-20020a17090b4d0e00b001cbbe65273csi9790613pjb.161.2022.04.22.12.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TvogOFhS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7310C131354; Fri, 22 Apr 2022 11:45:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1449900AbiDVQyf (ORCPT + 99 others); Fri, 22 Apr 2022 12:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1449876AbiDVQyR (ORCPT ); Fri, 22 Apr 2022 12:54:17 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A02AA5F8E9 for ; Fri, 22 Apr 2022 09:51:22 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id h11so10370612ljb.2 for ; Fri, 22 Apr 2022 09:51:22 -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=GMgjzuq0mtE7dfPwrz9iyN7XiqhJI/kKUBmloz8CHVM=; b=TvogOFhSkVoEFDDp2UyFM5JT+iRsMeAsMM/Ir0HL2o1J+3AsH38OlCvt5oXs8CCV0S xnxUElm53fIFEcmFNvNSvMmmh4juZ3+WxRoQAU7gWAgnSyXTv4uRTElLcGlojn+w9rdF qDNCuB/K5KxRpOUO1ACvBknXeQucuqYZcVPZzxDWH6TcyWGUucHe6OwZ+exVVrxtH5Wa xzdueEOQxmDYRx+fspEs14YJcnhc7fM4o0YNvW4kICFGZc/ebzCbRgyaUk87mgH3Hb+/ GgKojJu/EjHmouEBcVqfsA7l9jnJtbGlyY8Cf/h0HXmwLUzvJ+uSw/3SbFoXbhRUvmTW BPAA== 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=GMgjzuq0mtE7dfPwrz9iyN7XiqhJI/kKUBmloz8CHVM=; b=gKd/6Pydx2dTPUW8gSE2TKeHozpE1LErkO8S+VycOZq9DlV7vBrttJ5Rf183AgRndY qzM/fD5bSDcfCI+eGDnek6tY6AG3oX+NNg4FvBS+W6go1OaqOxuaxcFfQMIX7jF/iYdW GynFFj1H3a8mP2IxLuZfqTu2ApHRhSDShJ5H881UVBGtxs7rMl54PsmCkeoQAW+J/q7j GhrYWLAwEc5EQKM7EZbDDJkYEB2PmgcTQTvCxyGZkw+fO89xUQwUzxLIQGojsu2XBD4s jlK6NB7xijrQqyJL1dYtCTNVeP4UjJ/QRsSJt/Zbg6LTXgN5IkFImbHamwXMCEZY9U5D Dqiw== X-Gm-Message-State: AOAM532Yd3vUBh2cgdknxkkX3EeZfCyqI1AmdHG/6eZyHhTW2obF4tKY +UxYB613TrFRGwpmuUWaUl8= X-Received: by 2002:a2e:8659:0:b0:24d:b379:4cc0 with SMTP id i25-20020a2e8659000000b0024db3794cc0mr3390687ljj.289.1650646279861; Fri, 22 Apr 2022 09:51:19 -0700 (PDT) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id n2-20020a056512310200b0046e2f507a3asm279742lfb.167.2022.04.22.09.51.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2022 09:51: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 , Logan Gunthorpe , David Hildenbrand , Martin Oliveira , Kees Cook , Jean-Philippe Brucker , Julien Grall , "Michael S. Tsirkin" , Christoph Hellwig Subject: [PATCH V1 1/6] arm/xen: Introduce xen_setup_dma_ops() Date: Fri, 22 Apr 2022 19:50:58 +0300 Message-Id: <1650646263-22047-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1650646263-22047-1-git-send-email-olekstysh@gmail.com> References: <1650646263-22047-1-git-send-email-olekstysh@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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 --- arch/arm/include/asm/xen/xen-ops.h | 1 + arch/arm/mm/dma-mapping.c | 7 ++----- arch/arm64/include/asm/xen/xen-ops.h | 1 + arch/arm64/mm/dma-mapping.c | 7 ++----- include/xen/arm/xen-ops.h | 15 +++++++++++++++ 5 files changed, 21 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..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..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..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..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 */ -- 2.7.4