Skip to content

Commit 32383c0

Browse files
Steve Sistarejgunthorpe
authored andcommitted
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/[email protected] Signed-off-by: Steve Sistare <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent a2ad1b8 commit 32383c0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/iommu/iommufd/io_pagetable.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ static bool __alloc_iova_check_used(struct interval_tree_span_iter *span,
107107
* Does not return a 0 IOVA even if it is valid.
108108
*/
109109
static int iopt_alloc_iova(struct io_pagetable *iopt, unsigned long *iova,
110-
unsigned long uptr, unsigned long length)
110+
unsigned long addr, unsigned long length)
111111
{
112-
unsigned long page_offset = uptr % PAGE_SIZE;
112+
unsigned long page_offset = addr % PAGE_SIZE;
113113
struct interval_tree_double_span_iter used_span;
114114
struct interval_tree_span_iter allowed_span;
115115
unsigned long max_alignment = PAGE_SIZE;
@@ -122,15 +122,15 @@ static int iopt_alloc_iova(struct io_pagetable *iopt, unsigned long *iova,
122122
return -EOVERFLOW;
123123

124124
/*
125-
* Keep alignment present in the uptr when building the IOVA, this
125+
* Keep alignment present in addr when building the IOVA, which
126126
* increases the chance we can map a THP.
127127
*/
128-
if (!uptr)
128+
if (!addr)
129129
iova_alignment = roundup_pow_of_two(length);
130130
else
131131
iova_alignment = min_t(unsigned long,
132132
roundup_pow_of_two(length),
133-
1UL << __ffs64(uptr));
133+
1UL << __ffs64(addr));
134134

135135
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
136136
max_alignment = HPAGE_SIZE;
@@ -248,6 +248,7 @@ static int iopt_alloc_area_pages(struct io_pagetable *iopt,
248248
int iommu_prot, unsigned int flags)
249249
{
250250
struct iopt_pages_list *elm;
251+
unsigned long start;
251252
unsigned long iova;
252253
int rc = 0;
253254

@@ -267,9 +268,8 @@ static int iopt_alloc_area_pages(struct io_pagetable *iopt,
267268
/* Use the first entry to guess the ideal IOVA alignment */
268269
elm = list_first_entry(pages_list, struct iopt_pages_list,
269270
next);
270-
rc = iopt_alloc_iova(
271-
iopt, dst_iova,
272-
(uintptr_t)elm->pages->uptr + elm->start_byte, length);
271+
start = elm->start_byte + (uintptr_t)elm->pages->uptr;
272+
rc = iopt_alloc_iova(iopt, dst_iova, start, length);
273273
if (rc)
274274
goto out_unlock;
275275
if (IS_ENABLED(CONFIG_IOMMUFD_TEST) &&

0 commit comments

Comments
 (0)