Skip to content

Commit c27f0a6

Browse files
Steve Sistarejgunthorpe
authored andcommitted
iommufd: pfn_reader local variables
Add local variables for common sub-expressions needed by 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: Kevin Tian <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 99ff06d commit c27f0a6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

drivers/iommu/iommufd/pages.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ static int pfn_reader_fill_span(struct pfn_reader *pfns)
978978
{
979979
struct interval_tree_double_span_iter *span = &pfns->span;
980980
unsigned long start_index = pfns->batch_end_index;
981+
struct pfn_reader_user *user = &pfns->user;
982+
unsigned long npages;
981983
struct iopt_area *area;
982984
int rc;
983985

@@ -1015,10 +1017,9 @@ static int pfn_reader_fill_span(struct pfn_reader *pfns)
10151017
return rc;
10161018
}
10171019

1018-
batch_from_pages(&pfns->batch,
1019-
pfns->user.upages +
1020-
(start_index - pfns->user.upages_start),
1021-
pfns->user.upages_end - start_index);
1020+
npages = user->upages_end - start_index;
1021+
start_index -= user->upages_start;
1022+
batch_from_pages(&pfns->batch, user->upages + start_index, npages);
10221023
return 0;
10231024
}
10241025

@@ -1092,16 +1093,18 @@ static int pfn_reader_init(struct pfn_reader *pfns, struct iopt_pages *pages,
10921093
static void pfn_reader_release_pins(struct pfn_reader *pfns)
10931094
{
10941095
struct iopt_pages *pages = pfns->pages;
1096+
struct pfn_reader_user *user = &pfns->user;
10951097

1096-
if (pfns->user.upages_end > pfns->batch_end_index) {
1097-
size_t npages = pfns->user.upages_end - pfns->batch_end_index;
1098-
1098+
if (user->upages_end > pfns->batch_end_index) {
10991099
/* Any pages not transferred to the batch are just unpinned */
1100-
unpin_user_pages(pfns->user.upages + (pfns->batch_end_index -
1101-
pfns->user.upages_start),
1102-
npages);
1100+
1101+
unsigned long npages = user->upages_end - pfns->batch_end_index;
1102+
unsigned long start_index = pfns->batch_end_index -
1103+
user->upages_start;
1104+
1105+
unpin_user_pages(user->upages + start_index, npages);
11031106
iopt_pages_sub_npinned(pages, npages);
1104-
pfns->user.upages_end = pfns->batch_end_index;
1107+
user->upages_end = pfns->batch_end_index;
11051108
}
11061109
if (pfns->batch_start_index != pfns->batch_end_index) {
11071110
pfn_reader_unpin(pfns);

0 commit comments

Comments
 (0)