Skip to content

Commit f44e58b

Browse files
committed
Merge tag 'for-linus-5.13b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - two patches for error path fixes - a small series for fixing a regression with swiotlb with Xen on Arm * tag 'for-linus-5.13b-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/swiotlb: check if the swiotlb has already been initialized arm64: do not set SWIOTLB_NO_FORCE when swiotlb is required xen/arm: move xen_swiotlb_detect to arm/swiotlb-xen.h xen/unpopulated-alloc: fix error return code in fill_list() xen/gntdev: fix gntdev_mmap() error exit path
2 parents ccb013c + 97729b6 commit f44e58b

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

arch/arm/xen/mm.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,18 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
135135
return;
136136
}
137137

138-
int xen_swiotlb_detect(void)
139-
{
140-
if (!xen_domain())
141-
return 0;
142-
if (xen_feature(XENFEAT_direct_mapped))
143-
return 1;
144-
/* legacy case */
145-
if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
146-
return 1;
147-
return 0;
148-
}
149-
150138
static int __init xen_mm_init(void)
151139
{
152140
struct gnttab_cache_flush cflush;
141+
int rc;
142+
153143
if (!xen_swiotlb_detect())
154144
return 0;
155-
xen_swiotlb_init();
145+
146+
rc = xen_swiotlb_init();
147+
/* we can work with the default swiotlb */
148+
if (rc < 0 && rc != -EEXIST)
149+
return rc;
156150

157151
cflush.op = 0;
158152
cflush.a.dev_bus_addr = 0;

arch/arm64/mm/init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/sizes.h>
4444
#include <asm/tlb.h>
4545
#include <asm/alternative.h>
46+
#include <asm/xen/swiotlb-xen.h>
4647

4748
/*
4849
* We need to be able to catch inadvertent references to memstart_addr
@@ -482,7 +483,7 @@ void __init mem_init(void)
482483
if (swiotlb_force == SWIOTLB_FORCE ||
483484
max_pfn > PFN_DOWN(arm64_dma_phys_limit))
484485
swiotlb_init(1);
485-
else
486+
else if (!xen_swiotlb_detect())
486487
swiotlb_force = SWIOTLB_NO_FORCE;
487488

488489
set_max_mapnr(max_pfn - PHYS_PFN_OFFSET);

drivers/xen/gntdev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
10171017
err = mmu_interval_notifier_insert_locked(
10181018
&map->notifier, vma->vm_mm, vma->vm_start,
10191019
vma->vm_end - vma->vm_start, &gntdev_mmu_ops);
1020-
if (err)
1020+
if (err) {
1021+
map->vma = NULL;
10211022
goto out_unlock_put;
1023+
}
10221024
}
10231025
mutex_unlock(&priv->lock);
10241026

drivers/xen/swiotlb-xen.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ int __ref xen_swiotlb_init(void)
164164
int rc = -ENOMEM;
165165
char *start;
166166

167+
if (io_tlb_default_mem != NULL) {
168+
pr_warn("swiotlb buffer already initialized\n");
169+
return -EEXIST;
170+
}
171+
167172
retry:
168173
m_ret = XEN_SWIOTLB_ENOMEM;
169174
order = get_order(bytes);

drivers/xen/unpopulated-alloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ static int fill_list(unsigned int nr_pages)
3939
}
4040

4141
pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
42-
if (!pgmap)
42+
if (!pgmap) {
43+
ret = -ENOMEM;
4344
goto err_pgmap;
45+
}
4446

4547
pgmap->type = MEMORY_DEVICE_GENERIC;
4648
pgmap->range = (struct range) {

include/xen/arm/swiotlb-xen.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
#ifndef _ASM_ARM_SWIOTLB_XEN_H
33
#define _ASM_ARM_SWIOTLB_XEN_H
44

5-
extern int xen_swiotlb_detect(void);
5+
#include <xen/features.h>
6+
#include <xen/xen.h>
7+
8+
static inline int xen_swiotlb_detect(void)
9+
{
10+
if (!xen_domain())
11+
return 0;
12+
if (xen_feature(XENFEAT_direct_mapped))
13+
return 1;
14+
/* legacy case */
15+
if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
16+
return 1;
17+
return 0;
18+
}
619

720
#endif /* _ASM_ARM_SWIOTLB_XEN_H */

0 commit comments

Comments
 (0)