Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7890110ioo; Fri, 3 Jun 2022 16:16:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkcAnSbDYGSigzJ04mx2NSACnFdcp+qeV5jBbr8TXAAgzRSONp5GSkkkRE2IyzRM+QKGUT X-Received: by 2002:a17:907:7f0b:b0:6ff:4502:9c2f with SMTP id qf11-20020a1709077f0b00b006ff45029c2fmr10959974ejc.532.1654298166836; Fri, 03 Jun 2022 16:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654298166; cv=none; d=google.com; s=arc-20160816; b=wqtl2uSmZUiiW1YD7Mf3RJ37UrIImQGEzQRYTZN1lTBlgI8XySniYy0ZtMm92W/aOK jsKVBLPA8JubnsTzUDRi7MeqcyGHfr98HASDkzPwB3AD/ew5Ot4hgt3TWjH1Ja8Pit2g 4qcWLjH0JpBrTzMnR0iPEEyD992um1h58X5WZqZB59D7zOKt/Z4eMKG3suW08zV+tV2q Ssz06d50UuDH+jPmSwFtIWZ6LdVM9yP5yGSRY8+fKZKn3ZZvbqKSURX47Z2TQCiuMdSp NQQOkspYCbA6NBRFgyBQr5mkyvpx5Jjy6iHEEc6THVlX7rfU927/59rIRosMzoCiKCzI MhgQ== 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=/L1IBgi9+X4DxS9TjixiTB4nno95/1qL4aRB/Scae3U=; b=X+yC0HfTzfozrUVCk9c41PguxLbMRltoAOhyO2sGwB0HBJJaDB9lYfbXdXY1T+A2pk Uez1olKqBYBarPEHggXfH9LUz/H38aKGAMda0HIM8DInjdM54HNihTRRgnzmeBxg41Ix jxfIANOpF8RVHfVVFWqxGQixbv85L4B/kclDRGQ87MZq0Rl+CKFnoI9xxPmJ/4IPdjjZ GPAiZT76ae2aIRzhyRFyoTeFMEaKAEuTW8LJNoeaV6ULFI/UjFMNg5LiG8hQM3mSc8E+ mW0xH2WgvbVlGmRw4lBg6xftYSdrPxBYKKe5Kv66icQ5LF7/pLp3kjiV3fLroLu6j8I3 f21g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PdMHt1Dv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k20-20020aa7c394000000b0042defb7235csi8047396edq.202.2022.06.03.16.15.33; Fri, 03 Jun 2022 16:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PdMHt1Dv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238527AbiFBTYX (ORCPT + 99 others); Thu, 2 Jun 2022 15:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234745AbiFBTYU (ORCPT ); Thu, 2 Jun 2022 15:24:20 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 076A2615F for ; Thu, 2 Jun 2022 12:24:19 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id fu3so10343396ejc.7 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=1deuq/5zWxl4EUa3BKgK+cRcB+nmbekWHp2ZzV9oDoEQG5qS2Pc9yockf2aKs1NlIG bQusCqtGtWQ5NleeArt0OwD5W+SuJ6L/gNTeMQj93BVCR0qJ/LHkWtQonfdgA9naJSvp Rg3rVpyFQAq0Te6gkyBqygyWcf1WzZw7Fscpr1HTBHBrfO4m1RwEBTU80VLHwJdj0H8r /02cJgGzOa94uxRjeOzeM2YoxTEaV4e0BzX3UdgKgCj8nsNPDNZwfIpPa4DxvOlnG9IS oY6ji8pvKurtedI23bQm2tsrHz5yyKLmWq9LVljihp3KP56PHkN08TiW3Q1LIR2fvv0j 2Weg== X-Gm-Message-State: AOAM530b7ygkECjLjFnWtL9omX0/g+ta2nkQGQ684sfV1IdThx3Japii L/81bj/RXexu3z9X9CMT3+E= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 */ -- 2.7.4