]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommufd: pfn_reader local variables
authorSteve Sistare <steven.sistare@oracle.com>
Fri, 25 Oct 2024 13:11:54 +0000 (06:11 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 28 Oct 2024 16:24:24 +0000 (13:24 -0300)
Add local variables for common sub-expressions needed by a subsequent
patch.  No functional change.

Link: https://patch.msgid.link/r/1729861919-234514-5-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: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/pages.c

index 4206e90cc45196ff32c93bc316537ccbc2c4dc20..9097b25756518694a9d44dd58b105604b75589e7 100644 (file)
@@ -978,6 +978,8 @@ static int pfn_reader_fill_span(struct pfn_reader *pfns)
 {
        struct interval_tree_double_span_iter *span = &pfns->span;
        unsigned long start_index = pfns->batch_end_index;
+       struct pfn_reader_user *user = &pfns->user;
+       unsigned long npages;
        struct iopt_area *area;
        int rc;
 
@@ -1015,10 +1017,9 @@ static int pfn_reader_fill_span(struct pfn_reader *pfns)
                        return rc;
        }
 
-       batch_from_pages(&pfns->batch,
-                        pfns->user.upages +
-                                (start_index - pfns->user.upages_start),
-                        pfns->user.upages_end - start_index);
+       npages = user->upages_end - start_index;
+       start_index -= user->upages_start;
+       batch_from_pages(&pfns->batch, user->upages + start_index, npages);
        return 0;
 }
 
@@ -1092,16 +1093,18 @@ static int pfn_reader_init(struct pfn_reader *pfns, struct iopt_pages *pages,
 static void pfn_reader_release_pins(struct pfn_reader *pfns)
 {
        struct iopt_pages *pages = pfns->pages;
+       struct pfn_reader_user *user = &pfns->user;
 
-       if (pfns->user.upages_end > pfns->batch_end_index) {
-               size_t npages = pfns->user.upages_end - pfns->batch_end_index;
-
+       if (user->upages_end > pfns->batch_end_index) {
                /* Any pages not transferred to the batch are just unpinned */
-               unpin_user_pages(pfns->user.upages + (pfns->batch_end_index -
-                                                     pfns->user.upages_start),
-                                npages);
+
+               unsigned long npages = user->upages_end - pfns->batch_end_index;
+               unsigned long start_index = pfns->batch_end_index -
+                                           user->upages_start;
+
+               unpin_user_pages(user->upages + start_index, npages);
                iopt_pages_sub_npinned(pages, npages);
-               pfns->user.upages_end = pfns->batch_end_index;
+               user->upages_end = pfns->batch_end_index;
        }
        if (pfns->batch_start_index != pfns->batch_end_index) {
                pfn_reader_unpin(pfns);