Skip to content

Commit

Permalink
Merge tag 'for-linus-5.13b-rc2-tag' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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
  • Loading branch information
torvalds committed May 16, 2021
2 parents ccb013c + 97729b6 commit f44e58b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
20 changes: 7 additions & 13 deletions arch/arm/xen/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,18 @@ 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;
int rc;

if (!xen_swiotlb_detect())
return 0;
xen_swiotlb_init();

rc = xen_swiotlb_init();
/* we can work with the default swiotlb */
if (rc < 0 && rc != -EEXIST)
return rc;

cflush.op = 0;
cflush.a.dev_bus_addr = 0;
Expand Down
3 changes: 2 additions & 1 deletion arch/arm64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion drivers/xen/gntdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
err = mmu_interval_notifier_insert_locked(
&map->notifier, vma->vm_mm, vma->vm_start,
vma->vm_end - vma->vm_start, &gntdev_mmu_ops);
if (err)
if (err) {
map->vma = NULL;
goto out_unlock_put;
}
}
mutex_unlock(&priv->lock);

Expand Down
5 changes: 5 additions & 0 deletions drivers/xen/swiotlb-xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ int __ref xen_swiotlb_init(void)
int rc = -ENOMEM;
char *start;

if (io_tlb_default_mem != NULL) {
pr_warn("swiotlb buffer already initialized\n");
return -EEXIST;
}

retry:
m_ret = XEN_SWIOTLB_ENOMEM;
order = get_order(bytes);
Expand Down
4 changes: 3 additions & 1 deletion drivers/xen/unpopulated-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ static int fill_list(unsigned int nr_pages)
}

pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
if (!pgmap)
if (!pgmap) {
ret = -ENOMEM;
goto err_pgmap;
}

pgmap->type = MEMORY_DEVICE_GENERIC;
pgmap->range = (struct range) {
Expand Down
15 changes: 14 additions & 1 deletion include/xen/arm/swiotlb-xen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit f44e58b

Please sign in to comment.