[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220708224427.1245-3-nicolinc@nvidia.com>
Date: Fri, 8 Jul 2022 15:44:20 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: <kwankhede@...dia.com>, <corbet@....net>, <hca@...ux.ibm.com>,
<gor@...ux.ibm.com>, <agordeev@...ux.ibm.com>,
<borntraeger@...ux.ibm.com>, <svens@...ux.ibm.com>,
<zhenyuw@...ux.intel.com>, <zhi.a.wang@...el.com>,
<jani.nikula@...ux.intel.com>, <joonas.lahtinen@...ux.intel.com>,
<rodrigo.vivi@...el.com>, <tvrtko.ursulin@...ux.intel.com>,
<airlied@...ux.ie>, <daniel@...ll.ch>, <farman@...ux.ibm.com>,
<mjrosato@...ux.ibm.com>, <pasic@...ux.ibm.com>,
<vneethv@...ux.ibm.com>, <oberpar@...ux.ibm.com>,
<freude@...ux.ibm.com>, <akrowiak@...ux.ibm.com>,
<jjherne@...ux.ibm.com>, <alex.williamson@...hat.com>,
<cohuck@...hat.com>, <jgg@...dia.com>, <kevin.tian@...el.com>,
<hch@...radead.org>
CC: <jchrist@...ux.ibm.com>, <kvm@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-s390@...r.kernel.org>,
<intel-gvt-dev@...ts.freedesktop.org>,
<intel-gfx@...ts.freedesktop.org>,
<dri-devel@...ts.freedesktop.org>, <terrence.xu@...el.com>
Subject: [PATCH v3 02/10] 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@...dia.com>
Tested-by: Terrence Xu <terrence.xu@...el.com>
Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 8c67c9aba82d..7ce7b09aa5b2 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -231,11 +231,9 @@ static void intel_gvt_cleanup_vgpu_type_groups(struct intel_gvt *gvt)
static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
unsigned long size)
{
- int total_pages;
+ int total_pages = DIV_ROUND_UP(size, PAGE_SIZE);
int npage;
- total_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
-
for (npage = 0; npage < total_pages; npage++) {
unsigned long cur_gfn = gfn + npage;
@@ -247,12 +245,11 @@ static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
unsigned long size, struct page **page)
{
+ int total_pages = DIV_ROUND_UP(size, PAGE_SIZE);
unsigned long base_pfn = 0;
- int total_pages;
int npage;
int ret;
- total_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
/*
* We pin the pages one-by-one to avoid allocating a big arrary
* on stack to hold pfns.
--
2.17.1
Powered by blists - more mailing lists