From patchwork Mon May 30 21:00:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 12864968 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 C80ECC433F5 for ; Mon, 30 May 2022 21:02:15 +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=HO2m9cTk479toH4PHti6ABtszz80T4R49rvY0l9QFvo=; b=SkWg3GhJ5yLvN0 Hdb6uzh0I0cnzYhmjndnV5ha7iWODAJzgEkDwD0WA78iHrfUWefYDFDy6kXfKb31od8qbkjAv+16n tuUJ24ACeffdWj+rvwSQKkc0kjTaFynnJ9l+llzY387Esc0ichIvYM5dfqeMbf7aDT3Nv0/BF11/s dNd+pGYR0uQXlYMYilPA13fjCa1X4+y3xnFR7eXmVEjfIqrK9wq6lLMg8DvJ2e4l9zVe7T615St3T 80iS4MRPi4ZBAyKrcdZCDyemPIY7hiwoxWDv6Cy0jE74dwgM9u+YHTiIZCMKoeI3K3ZnFRCnEQwGI JHh930ha7I8s67KlIyMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvmVd-008IuI-2O; Mon, 30 May 2022 21:01:05 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvmV5-008IhF-UR for linux-arm-kernel@lists.infradead.org; Mon, 30 May 2022 21:00:36 +0000 Received: by mail-lf1-x133.google.com with SMTP id u30so18408482lfm.9 for ; Mon, 30 May 2022 14:00:27 -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=7irzWhw4rwD42lhWOD/5de/AKP87H3iLDxl7K/ZU9RTOggoA6GH1cnTBm0CVGD9C3E jQycHFNYXzl1neTfpXInGsukVMwznojj0TrPJJlgu09a/F18mEfev1AWvKJXMrycWqp/ abOzRo3nNTyRDcgetuEbg6sjF/ds6/QlAfwxnbUGObxoRCBEwPUMpbNxAq1WO4xLycgZ d4daU/1On10tza+AN9YhOA7CeR27P9yQzueuM/WpgWf/MQXOaIekMt8J3CPUv0Hv6fjX /4syhpKgmaEOu/8aFjpdhnar6I1l8gDwvjIRG55GqQHsauIYrRqV3TkfrSXFOMBqK3BL CIdw== X-Gm-Message-State: AOAM530UIi74heicG1xD+Zvsu4hKQfExwMgIkwQbqTQESPcDn+a852+x WKkAtlHLAz5spbVX1d3TScY= X-Google-Smtp-Source: ABdhPJxg9WbJjJF17bN45E1W6bO0HJs4dzI7IisXFVPM5nHpQcExbUbGQhg/zR9oTx50h6uUKqfR1w== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220530_140032_048797_CD21CE4E X-CRM114-Status: GOOD ( 20.66 ) 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 [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 */