Skip to content

Commit 2c9e8c0

Browse files
nicolincawilliam
authored andcommitted
drm/i915/gvt: Replace roundup with DIV_ROUND_UP
It's a bit redundant for the maths here using roundup. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Tested-by: Terrence Xu <terrence.xu@intel.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Link: https://lore.kernel.org/r/20220723020256.30081-3-nicolinc@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent e8f9071 commit 2c9e8c0

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/gpu/drm/i915/gvt/kvmgt.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,9 @@ static void intel_gvt_cleanup_vgpu_type_groups(struct intel_gvt *gvt)
231231
static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
232232
unsigned long size)
233233
{
234-
int total_pages;
234+
int total_pages = DIV_ROUND_UP(size, PAGE_SIZE);
235235
int npage;
236236

237-
total_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
238-
239237
for (npage = 0; npage < total_pages; npage++) {
240238
unsigned long cur_gfn = gfn + npage;
241239

@@ -247,12 +245,11 @@ static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
247245
static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
248246
unsigned long size, struct page **page)
249247
{
248+
int total_pages = DIV_ROUND_UP(size, PAGE_SIZE);
250249
unsigned long base_pfn = 0;
251-
int total_pages;
252250
int npage;
253251
int ret;
254252

255-
total_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
256253
/*
257254
* We pin the pages one-by-one to avoid allocating a big arrary
258255
* on stack to hold pfns.

0 commit comments

Comments
 (0)