Skip to content

Commit

Permalink
vfio: powerpc/spapr: Use it_page_size
Browse files Browse the repository at this point in the history
This makes use of the it_page_size from the iommu_table struct
as page size can differ.

This replaces missing IOMMU_PAGE_SHIFT macro in commented debug code
as recently introduced IOMMU_PAGE_XXX macros do not include
IOMMU_PAGE_SHIFT.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
[aw: for the vfio related changes]
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Alexey Kardashevskiy authored and Michael Ellerman committed Jun 11, 2015
1 parent e432bc7 commit 00663d4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions drivers/vfio/vfio_iommu_spapr_tce.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int tce_iommu_enable(struct tce_container *container)
* enforcing the limit based on the max that the guest can map.
*/
down_write(&current->mm->mmap_sem);
npages = (tbl->it_size << IOMMU_PAGE_SHIFT_4K) >> PAGE_SHIFT;
npages = (tbl->it_size << tbl->it_page_shift) >> PAGE_SHIFT;
locked = current->mm->locked_vm + npages;
lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
if (locked > lock_limit && !capable(CAP_IPC_LOCK)) {
Expand Down Expand Up @@ -120,7 +120,7 @@ static void tce_iommu_disable(struct tce_container *container)

down_write(&current->mm->mmap_sem);
current->mm->locked_vm -= (container->tbl->it_size <<
IOMMU_PAGE_SHIFT_4K) >> PAGE_SHIFT;
container->tbl->it_page_shift) >> PAGE_SHIFT;
up_write(&current->mm->mmap_sem);
}

Expand Down Expand Up @@ -215,7 +215,7 @@ static long tce_iommu_build(struct tce_container *container,
tce, ret);
break;
}
tce += IOMMU_PAGE_SIZE_4K;
tce += IOMMU_PAGE_SIZE(tbl);
}

if (ret)
Expand Down Expand Up @@ -260,8 +260,8 @@ static long tce_iommu_ioctl(void *iommu_data,
if (info.argsz < minsz)
return -EINVAL;

info.dma32_window_start = tbl->it_offset << IOMMU_PAGE_SHIFT_4K;
info.dma32_window_size = tbl->it_size << IOMMU_PAGE_SHIFT_4K;
info.dma32_window_start = tbl->it_offset << tbl->it_page_shift;
info.dma32_window_size = tbl->it_size << tbl->it_page_shift;
info.flags = 0;

if (copy_to_user((void __user *)arg, &info, minsz))
Expand Down Expand Up @@ -291,8 +291,8 @@ static long tce_iommu_ioctl(void *iommu_data,
VFIO_DMA_MAP_FLAG_WRITE))
return -EINVAL;

if ((param.size & ~IOMMU_PAGE_MASK_4K) ||
(param.vaddr & ~IOMMU_PAGE_MASK_4K))
if ((param.size & ~IOMMU_PAGE_MASK(tbl)) ||
(param.vaddr & ~IOMMU_PAGE_MASK(tbl)))
return -EINVAL;

/* iova is checked by the IOMMU API */
Expand All @@ -307,8 +307,8 @@ static long tce_iommu_ioctl(void *iommu_data,
return ret;

ret = tce_iommu_build(container, tbl,
param.iova >> IOMMU_PAGE_SHIFT_4K,
tce, param.size >> IOMMU_PAGE_SHIFT_4K);
param.iova >> tbl->it_page_shift,
tce, param.size >> tbl->it_page_shift);

iommu_flush_tce(tbl);

Expand All @@ -334,17 +334,17 @@ static long tce_iommu_ioctl(void *iommu_data,
if (param.flags)
return -EINVAL;

if (param.size & ~IOMMU_PAGE_MASK_4K)
if (param.size & ~IOMMU_PAGE_MASK(tbl))
return -EINVAL;

ret = iommu_tce_clear_param_check(tbl, param.iova, 0,
param.size >> IOMMU_PAGE_SHIFT_4K);
param.size >> tbl->it_page_shift);
if (ret)
return ret;

ret = tce_iommu_clear(container, tbl,
param.iova >> IOMMU_PAGE_SHIFT_4K,
param.size >> IOMMU_PAGE_SHIFT_4K);
param.iova >> tbl->it_page_shift,
param.size >> tbl->it_page_shift);
iommu_flush_tce(tbl);

return ret;
Expand Down

0 comments on commit 00663d4

Please sign in to comment.