mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-12 07:05:09 -04:00
iommufd: Rename uptr in iopt_alloc_iova()
iopt_alloc_iova() takes a uptr argument but only checks for its alignment. Generalize this to an unsigned address, which can be the offset from the start of a file in a subsequent patch. No functional change. Link: https://patch.msgid.link/r/1729861919-234514-3-git-send-email-steven.sistare@oracle.com Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
committed by
Jason Gunthorpe
parent
a2ad1b8101
commit
32383c085c
@@ -107,9 +107,9 @@ static bool __alloc_iova_check_used(struct interval_tree_span_iter *span,
|
||||
* Does not return a 0 IOVA even if it is valid.
|
||||
*/
|
||||
static int iopt_alloc_iova(struct io_pagetable *iopt, unsigned long *iova,
|
||||
unsigned long uptr, unsigned long length)
|
||||
unsigned long addr, unsigned long length)
|
||||
{
|
||||
unsigned long page_offset = uptr % PAGE_SIZE;
|
||||
unsigned long page_offset = addr % PAGE_SIZE;
|
||||
struct interval_tree_double_span_iter used_span;
|
||||
struct interval_tree_span_iter allowed_span;
|
||||
unsigned long max_alignment = PAGE_SIZE;
|
||||
@@ -122,15 +122,15 @@ static int iopt_alloc_iova(struct io_pagetable *iopt, unsigned long *iova,
|
||||
return -EOVERFLOW;
|
||||
|
||||
/*
|
||||
* Keep alignment present in the uptr when building the IOVA, this
|
||||
* Keep alignment present in addr when building the IOVA, which
|
||||
* increases the chance we can map a THP.
|
||||
*/
|
||||
if (!uptr)
|
||||
if (!addr)
|
||||
iova_alignment = roundup_pow_of_two(length);
|
||||
else
|
||||
iova_alignment = min_t(unsigned long,
|
||||
roundup_pow_of_two(length),
|
||||
1UL << __ffs64(uptr));
|
||||
1UL << __ffs64(addr));
|
||||
|
||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||
max_alignment = HPAGE_SIZE;
|
||||
@@ -248,6 +248,7 @@ static int iopt_alloc_area_pages(struct io_pagetable *iopt,
|
||||
int iommu_prot, unsigned int flags)
|
||||
{
|
||||
struct iopt_pages_list *elm;
|
||||
unsigned long start;
|
||||
unsigned long iova;
|
||||
int rc = 0;
|
||||
|
||||
@@ -267,9 +268,8 @@ static int iopt_alloc_area_pages(struct io_pagetable *iopt,
|
||||
/* Use the first entry to guess the ideal IOVA alignment */
|
||||
elm = list_first_entry(pages_list, struct iopt_pages_list,
|
||||
next);
|
||||
rc = iopt_alloc_iova(
|
||||
iopt, dst_iova,
|
||||
(uintptr_t)elm->pages->uptr + elm->start_byte, length);
|
||||
start = elm->start_byte + (uintptr_t)elm->pages->uptr;
|
||||
rc = iopt_alloc_iova(iopt, dst_iova, start, length);
|
||||
if (rc)
|
||||
goto out_unlock;
|
||||
if (IS_ENABLED(CONFIG_IOMMUFD_TEST) &&
|
||||
|
||||
Reference in New Issue
Block a user