From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43560C433F5 for ; Fri, 15 Apr 2022 22:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356269AbiDOWFG (ORCPT ); Fri, 15 Apr 2022 18:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356256AbiDOWFE (ORCPT ); Fri, 15 Apr 2022 18:05:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36693AA67 for ; Fri, 15 Apr 2022 15:02:34 -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 41E39621FA for ; Fri, 15 Apr 2022 22:02:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E20BCC385A5; Fri, 15 Apr 2022 22:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650060153; bh=PeF6Zc0nAV5VY/+eiewggzupF5+3PeXMBsC5arnyfGg=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=ZonlUzR62i2dx/H/zmKML/zbXZLoU8bNTM3Qo+bpEHOIhO/tl1vChpFxc9FnNP7tI iBrLaRmWNGkok98HLRW8srCFNX3xB7D1iWQIOgVUcV8UkQ277gin7i1//XVYoKSh45 aRQ4+ryHCPnZ2fAzxeGFqksQQsvOdKw1nuio5BBDTGrma/qwnv5GiYuI0i5X7csc9r 0gNi+/kkolFIBJqlZnMu1kI/DPk6O1MPcvIOY7eNNR3H5HVRMadEBHjhYdnCb2DIkm H9QclxzfOEk+uBt3Cn9nvDI6q/6E8InTJypsEJFNEZcel7WomzKZfHLtMTWMymCF/i /k3KqskBJ6ayg== Date: Fri, 15 Apr 2022 15:02:32 -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 Subject: Re: [RFC PATCH 5/6] arm/xen: Introduce xen_setup_dma_ops() In-Reply-To: <1649963973-22879-6-git-send-email-olekstysh@gmail.com> Message-ID: References: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> <1649963973-22879-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 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 subsequent patch will add xen-virtio DMA ops case. > > Also re-use the xen_swiotlb_detect() check on Arm32. Thanks for the patch, this is good to have in any case. I would move it to the beginning of the series. > Signed-off-by: Oleksandr Tyshchenko > --- > arch/arm/include/asm/xen/xen-ops.h | 1 + > arch/arm/mm/dma-mapping.c | 5 ++--- > arch/arm64/include/asm/xen/xen-ops.h | 1 + > arch/arm64/mm/dma-mapping.c | 5 ++--- > include/xen/arm/xen-ops.h | 13 +++++++++++++ > 5 files changed, 19 insertions(+), 6 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..a1bf9dd 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" > @@ -2288,8 +2288,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; > + xen_setup_dma_ops(dev); > #endif You can take this opportunity to also remove the #ifdef, by providing an empty stub implemention of xen_setup_dma_ops for the !CONFIG_XEN case. > 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..831e673 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) > @@ -53,7 +53,6 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, > 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; > + xen_setup_dma_ops(dev); > #endif same here > } > diff --git a/include/xen/arm/xen-ops.h b/include/xen/arm/xen-ops.h > new file mode 100644 > index 00000000..621da05 > --- /dev/null > +++ b/include/xen/arm/xen-ops.h > @@ -0,0 +1,13 @@ > +/* 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) > +{ > + if (xen_swiotlb_detect()) > + dev->dma_ops = &xen_swiotlb_dma_ops; > +} > + > +#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 >