Skip to contentSkip to conversation

drm/i915/gvt: return the correct usable aperture size under gvt environment

PATCH Superseded Weinan Li 3 participants 4 messages May 10, 2017 – May 12, 2017

Subsystems (2)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Weinan Li

author
#0 lore raw

PATCH v4 1/1 drm/i915/gvt: return the correct usable aperture size under gvt environment

I915_GEM_GET_APERTURE ioctl is used to probe aperture size from userspace. In gvt environment, each vm only use the ballooned part of aperture, so we should return the correct available aperture size exclude the reserved part by balloon.

v2: add 'reserved' in struct i915_address_space to record the reserved size in ggtt.

v3: remain aper_size as total, adjust aper_available_size exclude reserved and pinned. UMD driver need to adjust the max allocation size according to the available aperture size but not total size. KMD return the correct usable aperture size any time.

v4: add onion teardown to balloon and deballoon to make sure the reserved stays correct. Code style refine.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c     | 4 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.h | 1 +
 drivers/gpu/drm/i915/i915_vgpu.c    | 8 +++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -2
index 33fb11c..8d8d9c0 100644
@@ -156,8 +156,8 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)
 	mutex_unlock(&dev->struct_mutex);
 
 	args->aper_size = ggtt->base.total;
-	args->aper_available_size = args->aper_size - pinned;
-
+	args->aper_available_size = args->aper_size -
+		ggtt->base.reserved - pinned;
 	return 0;
 }
 
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
index fb15684..da9aa9f 100644
@@ -255,6 +255,7 @@ struct i915_address_space {
 	struct drm_i915_file_private *file;
 	struct list_head global_link;
 	u64 total;		/* size addr space maps (ex. 2GB for ggtt) */
+	u64 reserved;		/* size addr space reserved */
 
 	bool closed;
 
drivers/gpu/drm/i915/i915_vgpu.c +7 -1
index 4ab8a97..b144cf6 100644
@@ -109,8 +109,10 @@ void intel_vgt_deballoon(struct drm_i915_private *dev_priv)
 	DRM_DEBUG("VGT deballoon.\n");
 
 	for (i = 0; i < 4; i++) {
-		if (bl_info.space[i].allocated)
+		if (bl_info.space[i].allocated) {
+			dev_priv->ggtt->base.reserved -= bl_info.space[i].size;
 			drm_mm_remove_node(&bl_info.space[i]);
+		}
 	}
 
 	memset(&bl_info, 0, sizeof(bl_info));
@@ -216,6 +218,7 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[2].size;
 	}
 
 	if (unmappable_end < ggtt_end) {
@@ -223,6 +226,7 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 					unmappable_end, ggtt_end);
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[3].size;
 	}
 
 	/* Mappable graphic memory ballooning */
@@ -232,6 +236,7 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[0].size;
 	}
 
 	if (mappable_end < ggtt->mappable_end) {
@@ -240,6 +245,7 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[1].size;
 	}
 
 	DRM_INFO("VGT balloon successfully\n");
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

Really sorry, please ignore this mail with wrong patch. Will send the correct one then.

Thanks.
Best Regards.
Weinan, LI

Quoted 116 lines

-----Original Message-----
From: Li, Weinan Z
Sent: Wednesday, May 10, 2017 10:48 AM
To: [email protected]; [email protected]
Cc: Li, Weinan Z <[email protected]>; Chris Wilson <chris@chris- wilson.co.uk>; Joonas Lahtinen <[email protected]>
Subject: [PATCH v4] drm/i915/gvt: return the correct usable aperture size under gvt environment

I915_GEM_GET_APERTURE ioctl is used to probe aperture size from userspace. In gvt environment, each vm only use the ballooned part of aperture, so we should return the correct available aperture size exclude the reserved part by balloon.

v2: add 'reserved' in struct i915_address_space to record the reserved size in ggtt.

v3: remain aper_size as total, adjust aper_available_size exclude reserved and pinned. UMD driver need to adjust the max allocation size according to the available aperture size but not total size. KMD return the correct usable aperture size any time.

v4: add onion teardown to balloon and deballoon to make sure the reserved stays correct. Code style refine.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c     | 4 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.h | 1 +
 drivers/gpu/drm/i915/i915_vgpu.c    | 8 +++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem.c index 33fb11c..8d8d9c0 100644

drivers/gpu/drm/i915/i915_gem.c +2 -2
@@ -156,8 +156,8 @@ int i915_mutex_lock_interruptible(struct drm_device
 *dev)
 	mutex_unlock(&dev->struct_mutex);
 
 	args->aper_size = ggtt->base.total;
-	args->aper_available_size = args->aper_size - pinned;
-
+	args->aper_available_size = args->aper_size -
+		ggtt->base.reserved - pinned;
 	return 0;
 }
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
index fb15684..da9aa9f 100644
@@ -255,6 +255,7 @@ struct i915_address_space {
 	struct drm_i915_file_private *file;
 	struct list_head global_link;
 	u64 total;		/* size addr space maps (ex. 2GB for ggtt) */
+	u64 reserved;		/* size addr space reserved */
 
 	bool closed;
 
drivers/gpu/drm/i915/i915_vgpu.c +3 -1
index 4ab8a97..b144cf6 100644
@@ -109,8 +109,10 @@ void intel_vgt_deballoon(struct drm_i915_private
 *dev_priv)
 	DRM_DEBUG("VGT deballoon.\n");
 
 	for (i = 0; i < 4; i++) {
-		if (bl_info.space[i].allocated)
+		if (bl_info.space[i].allocated) {
+			dev_priv->ggtt->base.reserved -= bl_info.space[i].size;
 			drm_mm_remove_node(&bl_info.space[i]);
+		}
 	}
 
drivers/gpu/drm/i915/i915_vgpu.c +1 -0
 	memset(&bl_info, 0, sizeof(bl_info));
@@ -216,6 +218,7 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
 
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[2].size;
 	}
 
drivers/gpu/drm/i915/i915_vgpu.c +1 -0
 	if (unmappable_end < ggtt_end) {
@@ -223,6 +226,7 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
 					unmappable_end, ggtt_end);
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[3].size;
 	}
 

/* Mappable graphic memory ballooning */ @@ -232,6 +236,7 @@ int
intel_vgt_balloon(struct drm_i915_private *dev_priv)

drivers/gpu/drm/i915/i915_vgpu.c +1 -0
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[0].size;
 	}
 
 	if (mappable_end < ggtt->mappable_end) { @@ -240,6 +245,7 @@ int

intel_vgt_balloon(struct drm_i915_private *dev_priv)

drivers/gpu/drm/i915/i915_vgpu.c +1 -1
 		if (ret)
 			goto err;
+		ggtt->base.reserved += bl_info.space[1].size;
 	}
 
 	DRM_INFO("VGT balloon successfully\n");
--
Quoted 1 line

1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✗ Fi.CI.BAT: failure for drm/i915/gvt: return the correct usable aperture size under gvt environment

In reply to Weinan Li
== Series Details ==

== Series Details ==

Series: drm/i915/gvt: return the correct usable aperture size under gvt environment
URL : https://patchwork.freedesktop.org/series/24206/
State : failure

== Summary ==

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  CC [M]  drivers/gpu/drm/i915/i915_vgpu.o
drivers/gpu/drm/i915/i915_vgpu.c: In function ‘intel_vgt_deballoon’:
drivers/gpu/drm/i915/i915_vgpu.c:113:18: error: invalid type argument of ‘->’ (have ‘struct i915_ggtt’)
    dev_priv->ggtt->base.reserved -= bl_info.space[i].size;
                  ^

scripts/Makefile.build:294: recipe for target 'drivers/gpu/drm/i915/i915_vgpu.o' failed make[4]: *** [drivers/gpu/drm/i915/i915_vgpu.o] Error 1 scripts/Makefile.build:553: recipe for target 'drivers/gpu/drm/i915' failed make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:553: recipe for target 'drivers/gpu/drm' failed make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:553: recipe for target 'drivers/gpu' failed make[1]: *** [drivers/gpu] Error 2
Makefile:1002: recipe for target 'drivers' failed
make: *** [drivers] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Weinan Li
reproduce:

Hi Weinan,

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v4.11 next-20170511]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Weinan-Li/drm-i915-gvt-return-the-correct-usable-aperture-size-under-gvt-environment/20170511-170356
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/gpu//drm/i915/i915_vgpu.c: In function 'intel_vgt_deballoon':

>> drivers/gpu//drm/i915/i915_vgpu.c:113:18: error: invalid type argument of '->' (have 'struct i915_ggtt')
       dev_priv->ggtt->base.reserved -= bl_info.space[i].size;
                     ^~

vim +113 drivers/gpu//drm/i915/i915_vgpu.c

97 * @dev_priv: i915 device private data
98 *
99 * This function is called to deallocate the ballooned-out graphic memory, when
100 * driver is unloaded or when ballooning fails.
101 */
102 void intel_vgt_deballoon(struct drm_i915_private *dev_priv)
103 {
104 int i;
105
106 if (!intel_vgpu_active(dev_priv))
107 return;
108
109 DRM_DEBUG("VGT deballoon.\n");
110
111 for (i = 0; i < 4; i++) {
112 if (bl_info.space[i].allocated) {

 > 113				dev_priv->ggtt->base.reserved -= bl_info.space[i].size;

114 drm_mm_remove_node(&bl_info.space[i]);
115 }
116 }
117
118 memset(&bl_info, 0, sizeof(bl_info));
119 }
120
121 static int vgt_balloon_space(struct i915_ggtt *ggtt,

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx