* [PATCH 1/2] xen/arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required
@ 2021-05-11 17:41 Stefano Stabellini
2021-05-12 7:26 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Stefano Stabellini @ 2021-05-11 17:41 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, hch, linux-kernel, Stefano Stabellini,
boris.ostrovsky, jgross, catalin.marinas, will, linux-arm-kernel
From: Stefano Stabellini <stefano.stabellini@xilinx.com>
Although SWIOTLB_NO_FORCE is meant to allow later calls to swiotlb_init,
today dma_direct_map_page returns error if SWIOTLB_NO_FORCE.
For now, without a larger overhaul of SWIOTLB_NO_FORCE, the best we can
do is to avoid setting SWIOTLB_NO_FORCE in mem_init when we know that it
is going to be required later (e.g. Xen requires it).
To make xen_swiotlb_detect available to !CONFIG_XEN builds, move it to a
static inline function.
CC: boris.ostrovsky@oracle.com
CC: jgross@suse.com
CC: catalin.marinas@arm.com
CC: will@kernel.org
CC: linux-arm-kernel@lists.infradead.org
Fixes: 2726bf3ff252 ("swiotlb: Make SWIOTLB_NO_FORCE perform no allocation")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
---
arch/arm/xen/mm.c | 12 ------------
arch/arm64/mm/init.c | 3 ++-
include/xen/arm/swiotlb-xen.h | 15 ++++++++++++++-
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c
index f8f07469d259..223b1151fd7d 100644
--- a/arch/arm/xen/mm.c
+++ b/arch/arm/xen/mm.c
@@ -135,18 +135,6 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
return;
}
-int xen_swiotlb_detect(void)
-{
- if (!xen_domain())
- return 0;
- if (xen_feature(XENFEAT_direct_mapped))
- return 1;
- /* legacy case */
- if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
- return 1;
- return 0;
-}
-
static int __init xen_mm_init(void)
{
struct gnttab_cache_flush cflush;
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 16a2b2b1c54d..e55409caaee3 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -43,6 +43,7 @@
#include <linux/sizes.h>
#include <asm/tlb.h>
#include <asm/alternative.h>
+#include <asm/xen/swiotlb-xen.h>
/*
* We need to be able to catch inadvertent references to memstart_addr
@@ -482,7 +483,7 @@ void __init mem_init(void)
if (swiotlb_force == SWIOTLB_FORCE ||
max_pfn > PFN_DOWN(arm64_dma_phys_limit))
swiotlb_init(1);
- else
+ else if (!xen_swiotlb_detect())
swiotlb_force = SWIOTLB_NO_FORCE;
set_max_mapnr(max_pfn - PHYS_PFN_OFFSET);
diff --git a/include/xen/arm/swiotlb-xen.h b/include/xen/arm/swiotlb-xen.h
index 2994fe6031a0..33336ab58afc 100644
--- a/include/xen/arm/swiotlb-xen.h
+++ b/include/xen/arm/swiotlb-xen.h
@@ -2,6 +2,19 @@
#ifndef _ASM_ARM_SWIOTLB_XEN_H
#define _ASM_ARM_SWIOTLB_XEN_H
-extern int xen_swiotlb_detect(void);
+#include <xen/features.h>
+#include <xen/xen.h>
+
+static inline int xen_swiotlb_detect(void)
+{
+ if (!xen_domain())
+ return 0;
+ if (xen_feature(XENFEAT_direct_mapped))
+ return 1;
+ /* legacy case */
+ if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
+ return 1;
+ return 0;
+}
#endif /* _ASM_ARM_SWIOTLB_XEN_H */
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] xen/arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required
2021-05-11 17:41 [PATCH 1/2] xen/arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required Stefano Stabellini
@ 2021-05-12 7:26 ` Christoph Hellwig
2021-05-12 19:55 ` Stefano Stabellini
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2021-05-12 7:26 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel, hch, linux-kernel, Stefano Stabellini,
boris.ostrovsky, jgross, catalin.marinas, will, linux-arm-kernel
> -int xen_swiotlb_detect(void)
> -{
> - if (!xen_domain())
> - return 0;
> - if (xen_feature(XENFEAT_direct_mapped))
> - return 1;
> - /* legacy case */
> - if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
> - return 1;
> - return 0;
> -}
I think this move should be a separate prep patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] xen/arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required
2021-05-12 7:26 ` Christoph Hellwig
@ 2021-05-12 19:55 ` Stefano Stabellini
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Stabellini @ 2021-05-12 19:55 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Stefano Stabellini, xen-devel, linux-kernel, Stefano Stabellini,
boris.ostrovsky, jgross, catalin.marinas, will, linux-arm-kernel
On Wed, 12 May 2021, Christoph Hellwig wrote:
> > -int xen_swiotlb_detect(void)
> > -{
> > - if (!xen_domain())
> > - return 0;
> > - if (xen_feature(XENFEAT_direct_mapped))
> > - return 1;
> > - /* legacy case */
> > - if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
> > - return 1;
> > - return 0;
> > -}
>
> I think this move should be a separate prep patch.
Sure, I can do that
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-12 19:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 17:41 [PATCH 1/2] xen/arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required Stefano Stabellini
2021-05-12 7:26 ` Christoph Hellwig
2021-05-12 19:55 ` Stefano Stabellini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).