Skip to contentSkip to conversation

drm/i915/gvt: return the actual aperture size under gvt environment

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

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Weinan Li

author
#0 lore raw

PATCH v3 1/1 drm/i915/gvt: return the actual 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 actual available aperture size exclude the reserved part by balloon.

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

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.

---
 drivers/gpu/drm/i915/i915_gem.c     | 7 +++----
 drivers/gpu/drm/i915/i915_gem_gtt.h | 3 ++-
 drivers/gpu/drm/i915/i915_vgpu.c    | 5 ++++-
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -4
index 84ea249..e84576c 100644
@@ -145,9 +145,8 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)
 	struct i915_ggtt *ggtt = &dev_priv->ggtt;
 	struct drm_i915_gem_get_aperture *args = data;
 	struct i915_vma *vma;
-	size_t pinned;
+	size_t pinned = 0;
 
-	pinned = 0;
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(vma, &ggtt->base.active_list, vm_link)
 		if (i915_vma_is_pinned(vma))
@@ -158,8 +157,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 +2 -1
index fb15684..bdf832d 100644
@@ -255,7 +255,8 @@ 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) */
-
+	/* size addr space reserved by GVT balloon, only used for ggtt */
+	u64 reserved;
 	bool closed;
 
 	struct i915_page_dma scratch_page;
drivers/gpu/drm/i915/i915_vgpu.c +4 -1
index 4ab8a97..58055a9 100644
@@ -183,7 +183,7 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 
 	unsigned long mappable_base, mappable_size, mappable_end;
 	unsigned long unmappable_base, unmappable_size, unmappable_end;
-	int ret;
+	int ret, i;
 
 	if (!intel_vgpu_active(dev_priv))
 		return 0;
@@ -242,6 +242,9 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 			goto err;
 	}
 
+	for (i = 0; i < ARRAY_SIZE(bl_info.space); i++)
+		ggtt->base.reserved += bl_info.space[i].size;
+
 	DRM_INFO("VGT balloon successfully\n");
 	return 0;
 
Signature · 6 lines
1.9.1

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

✓ Fi.CI.BAT: success for drm/i915/gvt: return the actual aperture size under gvt environment (rev3)

== Series Details ==

== Series Details ==

Series: drm/i915/gvt: return the actual aperture size under gvt environment (rev3)
URL : https://patchwork.freedesktop.org/series/22910/
State : success

== Summary ==

Series 22910v3 drm/i915/gvt: return the actual aperture size under gvt environment
https://patchwork.freedesktop.org/api/1.0/series/22910/revisions/3/mbox/

Test drv_module_reload:

        Subgroup basic-reload-final:
                dmesg-warn -> PASS       (fi-skl-6770hq) fdo#100248
Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-uc:
                pass       -> FAIL       (fi-snb-2600) fdo#100007

fdo#100248 https://bugs.freedesktop.org/show_bug.cgi?id=100248
fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:429s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:425s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:573s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:511s
fi-bxt-t5700     total:278  pass:258  dwarn:0   dfail:0   fail:0   skip:20  time:555s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:492s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:477s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:409s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:407s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:420s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:496s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:465s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:458s
fi-kbl-7560u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:564s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:451s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time:569s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:463s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:497s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:433s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:532s
fi-snb-2600      total:278  pass:248  dwarn:0   dfail:0   fail:1   skip:29  time:410s

7f027554339633cb4e6a2d3974510aaef1a9e24c drm-tip: 2017y-05m-02d-18h-48m-28s UTC integration manifest fafe274 drm/i915/gvt: return the actual aperture size under gvt environment

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4604/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Weinan Li

Hi Joonas/Chris, do you have any comments?
I've asked OCL team for this patch, they also agree to use available aperture size for max allocation buffer definition, code confirmation ongoing.

Quoted 97 lines

-----Original Message-----
From: Li, Weinan Z
Sent: Wednesday, May 3, 2017 8:51 AM
To: [email protected]; [email protected]
Cc: Li, Weinan Z <[email protected]>
Subject: [PATCH v3] drm/i915/gvt: return the actual 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 actual available aperture size exclude the reserved part by balloon.

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

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.

---
 drivers/gpu/drm/i915/i915_gem.c     | 7 +++----
 drivers/gpu/drm/i915/i915_gem_gtt.h | 3 ++-
 drivers/gpu/drm/i915/i915_vgpu.c    | 5 ++++-
 3 files changed, 9 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem.c index 84ea249..e84576c 100644

drivers/gpu/drm/i915/i915_gem.c +1 -2
@@ -145,9 +145,8 @@ int i915_mutex_lock_interruptible(struct drm_device
 *dev)
 	struct i915_ggtt *ggtt = &dev_priv->ggtt;
 	struct drm_i915_gem_get_aperture *args = data;
 	struct i915_vma *vma;
-	size_t pinned;
+	size_t pinned = 0;
 
-	pinned = 0;
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(vma, &ggtt->base.active_list, vm_link)
drivers/gpu/drm/i915/i915_gem.c +2 -2
 		if (i915_vma_is_pinned(vma))
@@ -158,8 +157,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 +2 -1
index fb15684..bdf832d 100644
@@ -255,7 +255,8 @@ 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) */
-
+	/* size addr space reserved by GVT balloon, only used for ggtt */
+	u64 reserved;
 	bool closed;
 
 	struct i915_page_dma scratch_page;
drivers/gpu/drm/i915/i915_vgpu.c +1 -1
index 4ab8a97..58055a9 100644
@@ -183,7 +183,7 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
 
 	unsigned long mappable_base, mappable_size, mappable_end;
 	unsigned long unmappable_base, unmappable_size, unmappable_end;
-	int ret;
+	int ret, i;
 
 	if (!intel_vgpu_active(dev_priv))
drivers/gpu/drm/i915/i915_vgpu.c +3 -1
 		return 0;
@@ -242,6 +242,9 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
 			goto err;
 	}
 
+	for (i = 0; i < ARRAY_SIZE(bl_info.space); i++)
+		ggtt->base.reserved += bl_info.space[i].size;
+
 	DRM_INFO("VGT balloon successfully\n");
 	return 0;
 
--
Quoted 1 line

1.9.1

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

maintainer
#3 lore raw
Quoted 3 lines · Weinan Z

Hi Joonas/Chris, do you have any comments?
I've asked OCL team for this patch, they also agree to use available aperture size for max allocation buffer definition, code confirmation ongoing.

The patch title should be corrected to refer to usable aperture size.

Quoted 27 lines
Quoted 27 lines

-----Original Message-----
From: Li, Weinan Z
Sent: Wednesday, May 3, 2017 8:51 AM

Quoted 2 lines
Quoted 2 lines

To: [email protected]; [email protected]
Cc: Li, Weinan Z <[email protected]>

Subject: [PATCH v3] drm/i915/gvt: return the actual 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 actual available aperture size exclude the reserved part by balloon.

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

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.

---
 drivers/gpu/drm/i915/i915_gem.c     | 7 +++----
 drivers/gpu/drm/i915/i915_gem_gtt.h | 3 ++-
 drivers/gpu/drm/i915/i915_vgpu.c    | 5 ++++-

 3 files changed, 9 insertions(+), 6 deletions(-)
Quoted 11 lines

drivers/gpu/drm/i915/i915_gem.c int i915_mutex_lock_interruptible(struct drm_device · line 149

Quoted 11 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem.c index 84ea249..e84576c 100644

drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -145,9 +145,8 @@ int i915_mutex_lock_interruptible(struct drm_device
 *dev)
  	struct i915_ggtt *ggtt = &dev_priv->ggtt;
  	struct drm_i915_gem_get_aperture *args = data;
  	struct i915_vma *vma;
-	size_t pinned;
+	size_t pinned = 0;

Don't do this unrelated change.

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem.c +0 -1
-	pinned = 0;
  	mutex_lock(&dev->struct_mutex);
  	list_for_each_entry(vma, &ggtt->base.active_list, vm_link)
  		if (i915_vma_is_pinned(vma))
@@ -158,8 +157,8 @@ int i915_mutex_lock_interruptible(struct drm_device
 *dev)
  	mutex_unlock(&dev->struct_mutex);
 
Quoted 5 lines

drivers/gpu/drm/i915/i915_gem.c int i915_mutex_lock_interruptible(struct drm_device *dev) · line 161

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +2 -2
  	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;

Wrap the line at '-' mark, just like you would with '+'.

Quoted 14 lines
Quoted 12 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
  	return 0;
  }
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index fb15684..bdf832d 100644
@@ -255,7 +255,8 @@ 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) */

drivers/gpu/drm/i915/i915_gem_gtt.h struct i915_address_space { · line 258

Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
-
+	/* size addr space reserved by GVT balloon, only used for ggtt */

The comment should not be about GVT at all, just any reserved memory.

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
+	u64 reserved;

  bool closed;

<SNIP>

Quoted 8 lines

drivers/gpu/drm/i915/i915_gem_gtt.h int intel_vgt_balloon(struct drm_i915_private · line 248

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +3 -0
@@ -242,6 +242,9 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
  			goto err;
  	}
 
+	for (i = 0; i < ARRAY_SIZE(bl_info.space); i++)
+		ggtt->base.reserved += bl_info.space[i].size;
+

There should be an equal decrease when deballooning is done. And for that to be correct, you need to add proper onion teardown to this function to make sure the count stays correct (can't call deballoon on failure or the count will become negative which will result in huge number marked as reserved).

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 26 lines · Joonas Lahtinen
Quoted 3 lines · Weinan Z

Hi Joonas/Chris, do you have any comments?
I've asked OCL team for this patch, they also agree to use available aperture size for max allocation buffer definition, code confirmation ongoing.

The patch title should be corrected to refer to usable aperture size.

Quoted 19 lines
Quoted 19 lines

-----Original Message-----
From: Li, Weinan Z
Sent: Wednesday, May 3, 2017 8:51 AM

Quoted 2 lines
Quoted 2 lines

To: [email protected]; [email protected]
Cc: Li, Weinan Z <[email protected]>

Subject: [PATCH v3] drm/i915/gvt: return the actual 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 actual available aperture size exclude the reserved part by balloon.

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

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.

Only adjusting aper_available_size prevents the immediate breakage wrt to libdrm_intel, but I'm worried about the fragility of userspace using this. What is it being used for? I doubt this is the right information for them, and generally whether it's a correct assumption by userspace.

What happened to reporting the correct size via CONTEXT_PARAM_GTT_SIZE which doesn't have the same issues with userspace incorrectly using GGTT for PPGTT?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Thanks Chris.

Quoted 36 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Monday, May 8, 2017 8:11 PM
To: Joonas Lahtinen <[email protected]>
Cc: Li, Weinan Z <[email protected]>; [email protected]; intel- [email protected]
Subject: Re: [PATCH v3] drm/i915/gvt: return the actual aperture size under gvt environment

Quoted 4 lines · Joonas Lahtinen
Quoted 3 lines · Weinan Z

Hi Joonas/Chris, do you have any comments?
I've asked OCL team for this patch, they also agree to use available aperture size for max allocation buffer definition, code confirmation

ongoing.

Quoted 13 lines

The patch title should be corrected to refer to usable aperture size.

Quoted 10 lines
Quoted 10 lines

-----Original Message-----
From: Li, Weinan Z
Sent: Wednesday, May 3, 2017 8:51 AM

Quoted 3 lines
Quoted 3 lines

To: [email protected];
[email protected]
Cc: Li, Weinan Z <[email protected]>

Subject: [PATCH v3] drm/i915/gvt: return the actual aperture size under gvt environment

I915_GEM_GET_APERTURE ioctl is used to probe aperture size from

userspace.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

In gvt environment, each vm only use the ballooned part of aperture, so we should return the actual available aperture size exclude the reserved part by balloon.

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

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Only adjusting aper_available_size prevents the immediate breakage wrt to libdrm_intel, but I'm worried about the fragility of userspace using this. What is it being used for? I doubt this is the right information for them, and generally whether it's a correct assumption by userspace.

This issue was found by OCL test in GVT-g Linux guest, actually it uses total aperture size now, but if we adjust the total size, it may impact some other applications that need use total size to check available GTT address(talked in the last mail loop). So I talked with OCL team guys, they also agree to use usable aperture size. For other applications, I am not sure. Any way we should return correct information under GVT-g environment I think.

Quoted 4 lines

What happened to reporting the correct size via CONTEXT_PARAM_GTT_SIZE which doesn't have the same issues with userspace incorrectly using GGTT for PPGTT?

I remove it in this patch, since I haven't found any issues relate to CONTEXT_PARAM_GTT_SIZE so far.

Quoted 4 lines

-Chris

--
Chris Wilson, Intel Open Source Technology Centre

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

#6 lore raw
In reply to Joonas Lahtinen

Thanks Joonas.

Quoted 9 lines

-----Original Message-----
From: Joonas Lahtinen [mailto:[email protected]]
Sent: Monday, May 8, 2017 6:19 PM
To: Li, Weinan Z <[email protected]>; [email protected]; intel- [email protected]
Cc: Chris Wilson <[email protected]>
Subject: Re: [PATCH v3] drm/i915/gvt: return the actual aperture size under gvt environment

Quoted 6 lines
Quoted 3 lines · Weinan Z

Hi Joonas/Chris, do you have any comments?
I've asked OCL team for this patch, they also agree to use available aperture size for max allocation buffer definition, code confirmation ongoing.

The patch title should be corrected to refer to usable aperture size.

Title->return the correct usable aperture size under GVT-g environment

Quoted 66 lines
Quoted 11 lines
Quoted 11 lines

-----Original Message-----
From: Li, Weinan Z
Sent: Wednesday, May 3, 2017 8:51 AM

Quoted 3 lines
Quoted 3 lines

To: [email protected];
[email protected]
Cc: Li, Weinan Z <[email protected]>

Subject: [PATCH v3] drm/i915/gvt: return the actual aperture size under gvt environment

I915_GEM_GET_APERTURE ioctl is used to probe aperture size from

userspace.

Quoted 18 lines
Quoted 18 lines

In gvt environment, each vm only use the ballooned part of aperture, so we should return the actual available aperture size exclude the reserved part by balloon.

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

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.

---
 drivers/gpu/drm/i915/i915_gem.c     | 7 +++----
 drivers/gpu/drm/i915/i915_gem_gtt.h | 3 ++-
 drivers/gpu/drm/i915/i915_vgpu.c    | 5 ++++-

 3 files changed, 9 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/gpu/drm/i915/i915_gem.c int i915_mutex_lock_interruptible(struct drm_device *dev) · line 148

Quoted 12 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem.c index 84ea249..e84576c 100644

drivers/gpu/drm/i915/i915_gem.c +0 -0
@@ -145,9 +145,8 @@ int i915_mutex_lock_interruptible(struct

drm_device
*dev)
  struct i915_ggtt *ggtt = &dev_priv->ggtt; struct drm_i915_gem_get_aperture *args = data; struct i915_vma *vma;

drivers/gpu/drm/i915/i915_gem.c +1 -1
-	size_t pinned;
+	size_t pinned = 0;

Don't do this unrelated change.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +0 -1
-	pinned = 0;

  mutex_lock(&dev->struct_mutex); list_for_each_entry(vma, &ggtt->base.active_list, vm_link) if (i915_vma_is_pinned(vma))

drivers/gpu/drm/i915/i915_gem.c +0 -0
@@ -158,8 +157,8 @@ int i915_mutex_lock_interruptible(struct

drm_device
*dev)
  mutex_unlock(&dev->struct_mutex);

Quoted 5 lines

drivers/gpu/drm/i915/i915_gem.c int i915_mutex_lock_interruptible(struct drm_device *dev) · line 161

Quoted 5 lines

  args->aper_size = ggtt->base.total;

drivers/gpu/drm/i915/i915_gem.c +2 -2
-	args->aper_available_size = args->aper_size - pinned;
-
+	args->aper_available_size = args->aper_size
+			- ggtt->base.reserved - pinned;

Wrap the line at '-' mark, just like you would with '+'.

Quoted 3 lines
Quoted 3 lines

  return 0;
 }

Quoted 13 lines
Quoted 11 lines

drivers/gpu/drm/i915/i915_gem_gtt.h struct i915_address_space { · line 258

Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index fb15684..bdf832d 100644
@@ -255,7 +255,8 @@ 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) */

drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
-
+	/* size addr space reserved by GVT balloon, only used for ggtt */

The comment should not be about GVT at all, just any reserved memory.

+ /* size addr space reserved. */

Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
+	u64 reserved;

  bool closed;

<SNIP>

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
@@ -242,6 +242,9 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
  			goto err;
  	}
 
Quoted 8 lines
Quoted 3 lines

drivers/gpu/drm/i915/i915_gem_gtt.h int intel_vgt_balloon(struct drm_i915_private · line 248

Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +3 -0
+	for (i = 0; i < ARRAY_SIZE(bl_info.space); i++)
+		ggtt->base.reserved += bl_info.space[i].size;
+

There should be an equal decrease when deballooning is done. And for that to be correct, you need to add proper onion teardown to this function to make sure the count stays correct (can't call deballoon on failure or the count will become negative which will result in huge number marked as reserved).

Oh, that's my fault. Should add clean up in intel_vgt_deballoon(). @@ -114,6 +114,7 @@ void intel_vgt_deballoon(struct drm_i915_private *dev_priv)

        }

        memset(&bl_info, 0, sizeof(bl_info));

+ dev_priv->ggtt.reserved = 0;
}
Since if any steps in intel_vgt_balloon() fail, it will deal as error and run intel_vgt_deballoon() for clean up, no partial success happen.
So we only calculate the reserved when balloon success, it can ensure it's correct.

Quoted 6 lines

Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation

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

maintainer
#7 lore raw
Quoted 20 lines · Weinan Z
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/i915_vgpu.c +0 -0
@@ -242,6 +242,9 @@ int intel_vgt_balloon(struct drm_i915_private
 *dev_priv)
  			goto err;
  	}
 
Quoted 8 lines
Quoted 3 lines

drivers/gpu/drm/i915/i915_vgpu.c int intel_vgt_balloon(struct drm_i915_private *dev_priv) · line 247

Quoted 3 lines
drivers/gpu/drm/i915/i915_vgpu.c +3 -0
+	for (i = 0; i < ARRAY_SIZE(bl_info.space); i++)
+		ggtt->base.reserved += bl_info.space[i].size;
+

There should be an equal decrease when deballooning is done. And for that to be correct, you need to add proper onion teardown to this function to make sure the count stays correct (can't call deballoon on failure or the count will become negative which will result in huge number marked as reserved).

Oh, that's my fault. Should add clean up in intel_vgt_deballoon().

(quoted diff) +1 -0
@@ -114,6 +114,7 @@ void intel_vgt_deballoon(struct drm_i915_private *dev_priv)
         }
 
         memset(&bl_info, 0, sizeof(bl_info));
+       dev_priv->ggtt.reserved = 0;
 }
Quoted 3 lines

Since if any steps in intel_vgt_balloon() fail, it will deal as error and run intel_vgt_deballoon() for clean up, no partial success happen.
So we only calculate the reserved when balloon success, it can ensure it's correct.

Onion teardown should be used according to kernel coding style, there's really no excuse not to.

Just add to the ggtt->base.reserved in increments, and remove in increments during teardown or in the deballoon function. ggtt.reserved is not exclusively for GVT-g to use, so you can't simply zero it. There needs to be incremental additions and substractions as objects are added and removed for the variable to stay general.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw
Quoted 40 lines

-----Original Message-----
From: Joonas Lahtinen [mailto:[email protected]]
Sent: Tuesday, May 9, 2017 8:36 PM
To: Li, Weinan Z <[email protected]>; [email protected]; intel- [email protected]
Cc: Chris Wilson <[email protected]>
Subject: Re: [PATCH v3] drm/i915/gvt: return the actual aperture size under gvt environment

Quoted 6 lines · Weinan Z
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -0
@@ -242,6 +242,9 @@ int intel_vgt_balloon(struct

drm_i915_private
*dev_priv)
  goto err;
  }

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

drivers/gpu/drm/i915/i915_vgpu.c int intel_vgt_balloon(struct drm_i915_private *dev_priv) · line 247

Quoted 3 lines
drivers/gpu/drm/i915/i915_vgpu.c +3 -0
+	for (i = 0; i < ARRAY_SIZE(bl_info.space); i++)
+		ggtt->base.reserved += bl_info.space[i].size;
+

There should be an equal decrease when deballooning is done. And for that to be correct, you need to add proper onion teardown to this function to make sure the count stays correct (can't call deballoon on failure or the count will become negative which will result in huge

number marked as reserved).

Quoted 8 lines

Oh, that's my fault. Should add clean up in intel_vgt_deballoon().

(quoted diff) +1 -0
@@ -114,6 +114,7 @@ void intel_vgt_deballoon(struct drm_i915_private
 *dev_priv)
         }
 
         memset(&bl_info, 0, sizeof(bl_info));
+       dev_priv->ggtt.reserved = 0;
 }
Quoted 4 lines

Since if any steps in intel_vgt_balloon() fail, it will deal as error and run
intel_vgt_deballoon() for clean up, no partial success happen. So we only calculate the reserved when balloon success, it can ensure it's

correct.

Quoted 8 lines

Onion teardown should be used according to kernel coding style, there's really no excuse not to.

Just add to the ggtt->base.reserved in increments, and remove in increments during teardown or in the deballoon function. ggtt.reserved is not exclusively for GVT-g to use, so you can't simply zero it. There needs to be incremental additions and substractions as objects are added and removed for the variable to stay general.

Got it, I will refine it and send as patch v4.

Quoted 6 lines

Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation

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