Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1003949pxb; Fri, 22 Apr 2022 16:30:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzebt0Us7G1HYv95LnkYaviQnceqpMTLlds3d9YuvJfMnnwzjs6jqPqWXVu5x80MI8e4ZTq X-Received: by 2002:a05:6a00:2181:b0:4f6:f1b1:1ba7 with SMTP id h1-20020a056a00218100b004f6f1b11ba7mr7392307pfi.73.1650670237439; Fri, 22 Apr 2022 16:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650670237; cv=none; d=google.com; s=arc-20160816; b=HgqdXyAZYCKzzZrJmRS0BY7z32USyMDh4LW1ofT5NlGebIxgS4L0lJKUalZpHLLdjZ HZFduYQjDGL1cVww+YYj1PoZ6tv6Y8qjA4Ez3d0djz8sQNRJ1mwQUIdWAceHPmL2QTO5 T1YFGMza2mXrpq60UTvFWlkooFqYshcr0ZEKGW4pOitidx00xFZUend1cwTxr5NZxJB+ BFPK5f//5k3Zh/uUhP9g7LaHBLu35df+1xpAM52rMJ5wRRuPbrZP7XKsHHy56odTUgu8 hqB8L4w9VtTxRfV0tOabT8TG5ANO5ybM6K7hAMU0WQc117xtm0vRP66N/erDUre0TAqR Ceng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=iw795dah9B/grka7zo17fc7VJNR3fyP21QMNPZkk8TA=; b=v+Nb0PwualDzgXDM1+R4vvIC1pVjNNz+HORrh8XB9K8VieNIZidSmHYtVwH5ePAL2o VjSStTntPcRO3phJi1F1fZLcO/VXMgLk6ICvDnc4t90QKS5ECQx+oZtzb8NfoTb+VSSe BBic6qYJK4/rNheBw2sQeE5Y8vPrV6G4NnTx+zHY/z1AecZDZde/jbaOBl0dfbWf0tqP 6n3byLuPM1hKP6/xTHNNTQL4JCPtpCVMPPHwl7euUmr8JQ9W+zPy6w0nrlSboDvyPlaD /bpj5Z3A0i8XBSRnoA6KxFOuRWj9gALL3h74s7CWOQAfleAK58S0nUCY/PPDdnkLSAH7 6eGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QohgQHLz; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n16-20020a170902f61000b001584875c092si9976508plg.75.2022.04.22.16.30.21; Fri, 22 Apr 2022 16:30:37 -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=@kernel.org header.s=k20201202 header.b=QohgQHLz; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbiDVXZC (ORCPT + 99 others); Fri, 22 Apr 2022 19:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbiDVXYv (ORCPT ); Fri, 22 Apr 2022 19:24:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A5C1EE88C for ; Fri, 22 Apr 2022 15:59:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 10DFA614BB for ; Fri, 22 Apr 2022 22:59:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81619C385A4; Fri, 22 Apr 2022 22:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650668394; bh=M7V1x3+dW0OrON/J4gjnWwch4NqKEpkTbtbZGq9n8Ds=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=QohgQHLzztT0SIwKMxTyP1z4XMJ5yxThvDyiQXdXw5R9vEhb1vIQoOPFBA4vMDmp7 OMXSxeoQZPdSRsYBxP6lNveMG6mN71h9ljeHiyhlpi/JE8n/ahpBv5rA297OdfD3m8 HHK67H6zwN4EyeCZgH1FN5Uk5vizPpcotPFjYvEbbBSvYm6gGnkuABqm9TF1YeELcW dZxik/y3nacGdEG+7JlHx0QMJgfEE4t/k3UBooyvCEvN3vWl00th8B2WdhSt0OXQy3 GaxYCztJOy1KwmrjIyLwOtFbI06hD3+pGKZrqMWLJyXHiH0diFy04HgYZUZFVIcB/p fhGy9MUJZMx3Q== Date: Fri, 22 Apr 2022 15:59:53 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Oleksandr Tyshchenko cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, 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: Re: [PATCH V1 1/6] arm/xen: Introduce xen_setup_dma_ops() In-Reply-To: <1650646263-22047-2-git-send-email-olekstysh@gmail.com> Message-ID: References: <1650646263-22047-1-git-send-email-olekstysh@gmail.com> <1650646263-22047-2-git-send-email-olekstysh@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Fri, 22 Apr 2022, Oleksandr Tyshchenko wrote: > 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 > --- > 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 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >