Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5865294ioo; Wed, 1 Jun 2022 14:26:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPVVDdQZt4rDX/1Z1Y/aKhxfRpz+F3EpuT414Gtolf1b3igraN7WrTIzxFY5KsLRIOBYlV X-Received: by 2002:a17:902:e94e:b0:154:3a4:c5e8 with SMTP id b14-20020a170902e94e00b0015403a4c5e8mr1409941pll.19.1654118767778; Wed, 01 Jun 2022 14:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654118767; cv=none; d=google.com; s=arc-20160816; b=xbLR4tyzSw4wRIiJoPkJqg6sL3xzOaZRyY7LVrOWO7XN6x4EorIF5DnYquogJlo2J2 Lf/xvN4eT0h3JZDhpUBc7P9n+dwmrD9YASDxNam6G4r+60aXYlRnlflWRqAmrMWTjQpd q+r8GrkQmz2ZnSmJc7uUwVcjkH7ZIElFx+/AOi5hDzYJPuz+e6azwiVVvYfQjAtbJPUE iUBlvXnxRys5TNirydI5BWWfsDtf+n3K1asUEfp6L37OFSbqC6GFbghwyGmwkFDbviFq Y7ebZJbesAZiifCgH2BZEItMokvAMW3a7vpADtuQUfrlu3bN/V5OSck9I7NZzvtm8MIc aqvw== 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=bgYTJywCKcz2eZ3BdKiVmZnlK+gFcRjkQ0C/gcc8wL0=; b=BK37h7PboDcacNHqC2Bf4QiUYV8oc1MK4M83OnY+RMEDzTCW2/nB7XkZ2fhOUL5/c5 QYl++tlLXAfry3mPpKo3AoRNffN37WLmL/oRS77qYLeUL6lDyO5UF5cFfvIkFyoRk4t5 fLN0B/0nlQzmKoP6B2/pSBojFQmmOKD4NQlMFnCc6fNwDfYwuLo00RqLt3B+P/q2QiPP DLJFp6mpqlyNJ/H3ywr7JQnI55+1LhxSCtRmH1JLqxWMGI+reDfSh0I4/5Vxc09dbXjX UiBJVf2jy4xgAN1EEBDvwc2mvsLVdEl3BTNwADDq3nC/WxEPkc4dkwgULbsH7InN/Vx9 gAnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WPbadUUF; 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 l6-20020a170902f68600b00153b2d164fbsi4471480plg.259.2022.06.01.14.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:26:07 -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=WPbadUUF; 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 B70BD3082E3; Wed, 1 Jun 2022 13:16:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239491AbiE3VBB (ORCPT + 99 others); Mon, 30 May 2022 17:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243205AbiE3VAb (ORCPT ); Mon, 30 May 2022 17:00:31 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C9891587 for ; Mon, 30 May 2022 14:00:28 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id p4so18488561lfg.4 for ; Mon, 30 May 2022 14:00:28 -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=bgYTJywCKcz2eZ3BdKiVmZnlK+gFcRjkQ0C/gcc8wL0=; b=WPbadUUFeZwVP4k9WAfhTLe83VpVBG119TgUz++U+jcFCuUBznYGsIC2lzKm27XdmH yXFP5yObX14uURGpzK7F5mfOnsgB0r/BmzpoUM+jVBTGg80yZgw9XLdeLfgwp9ErLoVW Q1TnTWrqcB0sDwHHSjrR/52HWB1qz43VoDo1QHHh9ceNvr40y+w6erOOroKP7WNK9jCV dGTfhe/dXDLi/T7GIkeydYCCaMf+TjgeRFjPvJnOV+kHivKBp/t3pH1T36Vqg8+3uxjR MnAy+xzObuU1AJa9GbSqXq88uHtnxJw/NER+9Xb7clISz49J9BSIQt8o8DWDArCwlTH1 WvpQ== 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=bgYTJywCKcz2eZ3BdKiVmZnlK+gFcRjkQ0C/gcc8wL0=; b=78bJ8QPLiX73IvOZR+uYOefDZKCEij+TSTaEtfJ0TrNZ1WmWzGnlFbifklCNNHuZ/2 VGqdrQPDcPBlx5BK1chUaSjfS/ivZYX/78Vm9LHXODuv0BVFEKWyBHwhZHDc2wTtJLE4 xp9vAx9Bza38s6HtSYJTNLEhrseX58akZJIsXfozvt2bHcmXbLen4+fZ9a4QJrLxnSKg kfbEneglMR/USUEdE4BeHSNRH4JoFqH5JuNHk+fmHuv8EuhXY1NY8g7ZSUYSbnRoDy0X zN5NPv96pDAWWaLO5dxhA6UVnffRvRiz30OWGmwiSqlSzhAV/N0XfJ0MX1t8W/Wr8hX0 68OA== X-Gm-Message-State: AOAM533TjJfIrsqN6vy2DbfQML4NWqaPrSX9WBdQIxDfbVsbWeQWbCDN ptKBW30BlE93kG4bSdrdHn4qKjPNmm4= X-Received: by 2002:a05:6512:20c9:b0:477:cc4f:b816 with SMTP id u9-20020a05651220c900b00477cc4fb816mr38993759lfr.521.1653944426468; Mon, 30 May 2022 14:00:26 -0700 (PDT) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id k21-20020a2ea275000000b0025550e2693asm581541ljm.38.2022.05.30.14.00.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2022 14:00:26 -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 V3 1/8] arm/xen: Introduce xen_setup_dma_ops() Date: Tue, 31 May 2022 00:00:10 +0300 Message-Id: <1653944417-17168-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1653944417-17168-1-git-send-email-olekstysh@gmail.com> References: <1653944417-17168-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,T_SCC_BODY_TEXT_LINE 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 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 --- 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 */ -- 2.7.4