<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p style="font-size: 12pt;">Some minor comments as below.</p>
<p style="font-size: 12pt;"><br>
</p>
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;">Reviewed-by: </span>Bruce
Chang <yu.bruce.chang@intel.com></span><br>
<br>
<div style="color: rgb(0, 0, 0);">
<div style="font-size: 12pt;">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Chris Wilson <chris@chris-wilson.co.uk><br>
<b>Sent:</b> Saturday, December 12, 2020 1:43 AM<br>
<b>To:</b> intel-gfx@lists.freedesktop.org<br>
<b>Cc:</b> igt-dev@lists.freedesktop.org; Chris Wilson; Chang, Yu bruce<br>
<b>Subject:</b> [PATCH i-g-t] lib: Pass device fd to gem_mmappable_aperture_size()</font>
<div> </div>
</div>
</div>
<font style="">
<div class="PlainText" style="font-size: 10pt;">In order to find the correct aperture size for the test, we want to pass<br>
the test's device into the query.<br>
<br>
Reported-by: Bruce Chang <yu.bruce.chang@intel.com><br>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk><br>
Cc: Bruce Chang <yu.bruce.chang@intel.com><br>
---<br>
lib/i915/gem_mman.c | 108 +++++++++++++++++++++++++++<br>
lib/i915/gem_mman.h | 6 ++<br>
lib/ioctl_wrappers.c | 116 -----------------------------<br>
lib/ioctl_wrappers.h | 5 --<br>
tests/i915/gem_concurrent_all.c | 12 +--<br>
tests/i915/gem_mmap.c | 4 +-<br>
tests/i915/gem_mmap_gtt.c | 10 +--<br>
tests/i915/gem_pwrite.c | 6 +-<br>
tests/i915/gem_shrink.c | 2 +-<br>
tests/i915/gem_tiled_fence_blits.c | 2 +-<br>
tests/i915/i915_pm_rpm.c | 4 +-<br>
tests/kms_big_fb.c | 2 +-<br>
tests/kms_flip.c | 2 +-<br>
tests/prime_mmap.c | 4 +-<br>
14 files changed, 138 insertions(+), 145 deletions(-)<br>
<br>
diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c<br>
index 93bef2bfc..703c6a5c1 100644<br>
--- a/lib/i915/gem_mman.c<br>
+++ b/lib/i915/gem_mman.c<br>
@@ -27,7 +27,9 @@<br>
#include <errno.h><br>
<br>
#include "igt_core.h"<br>
+#include "igt_device.h"<br>
#include "ioctl_wrappers.h"<br>
+#include "intel_chipset.h"<br>
<br>
#include "gem_mman.h"<br>
<br>
@@ -551,3 +553,109 @@ const struct mmap_offset mmap_offset_types[] = {<br>
{ "uc", I915_MMAP_OFFSET_UC, I915_GEM_DOMAIN_WC },<br>
{},<br>
};<br>
+<br>
+/**<br>
+ * gem_available_aperture_size:<br>
+ * @fd: open i915 drm file descriptor<br>
+ *<br>
+ * Feature test macro to query the kernel for the available gpu aperture size<br>
+ * usable in a batchbuffer.<br>
+ *<br>
+ * Returns: The available gtt address space size.<br>
+ */<br>
+uint64_t gem_available_aperture_size(int fd)<br>
+{<br>
+ struct drm_i915_gem_get_aperture aperture = {<br>
+ aperture.aper_available_size = 256*1024*1024,<br>
+ };<br>
+<br>
+ ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);<br>
+ errno = 0;<br>
+<br>
+ return aperture.aper_available_size;<br>
+}<br>
+<br>
+/**<br>
+ * gem_aperture_size:<br>
+ * @fd: open i915 drm file descriptor<br>
+ *<br>
+ * Feature test macro to query the kernel for the total gpu aperture size.<br>
+ *<br>
+ * Returns: The total gtt address space size.<br>
+ */<br>
+uint64_t gem_aperture_size(int fd)<br>
+{<br>
+ struct drm_i915_gem_context_param p = {<br>
+ .param = 0x3<br>
+ };<br>
<br>
</div>
<div class="PlainText" style="font-size: 10pt;">Understand this is the original code, but it will be more readable to use <span>I915_CONTEXT_PARAM_GTT_SIZE instead of 3.</span></div>
<div class="PlainText" style="font-size: 10pt;"><span><br>
</span></div>
<div class="PlainText" style="font-size: 10pt;">+<br>
+ if (__gem_context_get_param(fd, &p))<br>
+ p.value = gem_global_aperture_size(fd);<br>
+<br>
+ return p.value;<br>
+}<br>
+<br>
+/**<br>
+ * gem_mappable_aperture_size:<br>
+ *<br>
+ * Feature test macro to query the kernel for the mappable gpu aperture size.<br>
+ * This is the area available for GTT memory mappings.<br>
+ *<br>
+ * Returns: The mappable gtt address space size.<br>
+ */<br>
+uint64_t gem_mappable_aperture_size(int fd)<br>
+{<br>
+ struct pci_device *pci_dev = igt_device_get_pci_device(fd);</div>
<div class="PlainText" style="font-size: 10pt;"><br>
</div>
<div class="PlainText" style="font-size: 10pt;"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;">Does it make
sense to eliminate the function intel_get_pci_device() if not being used anymore? But it can be a separate patch.</span></div>
<div class="PlainText" style=""><span style="font-size: 13.3333px;"><br>
</span><span style="font-size: 10pt;">+ int bar;</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+ if (intel_gen(pci_dev->device_id) < 3)</span><br>
<span style="font-size: 10pt;">+ bar = 0;</span><br>
<span style="font-size: 10pt;">+ else</span><br>
<span style="font-size: 10pt;">+ bar = 2;</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+ return pci_dev->regions[bar].size;</span><br>
<span style="font-size: 10pt;">+}</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+/**</span><br>
<span style="font-size: 10pt;">+ * gem_global_aperture_size:</span><br>
<span style="font-size: 10pt;">+ * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">+ *</span><br>
<span style="font-size: 10pt;">+ * Feature test macro to query the kernel for the global gpu aperture size.</span><br>
<span style="font-size: 10pt;">+ * This is the area available for the kernel to perform address translations.</span><br>
<span style="font-size: 10pt;">+ *</span><br>
<span style="font-size: 10pt;">+ * Returns: The gtt address space size.</span><br>
<span style="font-size: 10pt;">+ */</span><br>
<span style="font-size: 10pt;">+uint64_t gem_global_aperture_size(int fd)</span><br>
<span style="font-size: 10pt;">+{</span><br>
<span style="font-size: 10pt;">+ struct drm_i915_gem_get_aperture aperture = {</span><br>
<span style="font-size: 10pt;">+ aperture.aper_size = 256*1024*1024</span><br>
<span style="font-size: 10pt;">+ };</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+ ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);</span><br>
<span style="font-size: 10pt;">+ errno = 0;</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+ return aperture.aper_size;</span><br>
<span style="font-size: 10pt;">+}</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+/**</span><br>
<span style="font-size: 10pt;">+ * gem_available_fences:</span><br>
<span style="font-size: 10pt;">+ * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">+ *</span><br>
<span style="font-size: 10pt;">+ * Feature test macro to query the kernel for the number of available fences</span><br>
<span style="font-size: 10pt;">+ * usable in a batchbuffer. Only relevant for pre-gen4.</span><br>
<span style="font-size: 10pt;">+ *</span><br>
<span style="font-size: 10pt;">+ * Returns: The number of available fences.</span><br>
<span style="font-size: 10pt;">+ */</span><br>
<span style="font-size: 10pt;">+int gem_available_fences(int fd)</span><br>
<span style="font-size: 10pt;">+{</span><br>
<span style="font-size: 10pt;">+ int num_fences = 0;</span><br>
<span style="font-size: 10pt;">+ struct drm_i915_getparam gp = {</span><br>
<span style="font-size: 10pt;">+ gp.param = I915_PARAM_NUM_FENCES_AVAIL,</span><br>
<span style="font-size: 10pt;">+ gp.value = &num_fences,</span><br>
<span style="font-size: 10pt;">+ };</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+ ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));</span><br>
<span style="font-size: 10pt;">+ errno = 0;</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;">+ return num_fences;</span><br>
<span style="font-size: 10pt;">+}</span><br>
<span style="font-size: 10pt;">diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h</span><br>
<span style="font-size: 10pt;">index 2c4a7a00b..ec2899ffe 100644</span><br>
<span style="font-size: 10pt;">--- a/lib/i915/gem_mman.h</span><br>
<span style="font-size: 10pt;">+++ b/lib/i915/gem_mman.h</span><br>
<span style="font-size: 10pt;">@@ -109,5 +109,11 @@ bool gem_has_mmap_offset_type(int fd, const struct mmap_offset *t);</span><br>
<span style="font-size: 10pt;"> (__t)++) \</span><br>
<span style="font-size: 10pt;"> for_each_if(gem_has_mmap_offset_type((fd), (__t)))</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">+uint64_t gem_available_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">+uint64_t gem_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">+uint64_t gem_global_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">+uint64_t gem_mappable_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">+int gem_available_fences(int fd);</span><br>
<span style="font-size: 10pt;">+</span><br>
<span style="font-size: 10pt;"> #endif /* GEM_MMAN_H */</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c</span><br>
<span style="font-size: 10pt;">index 06431ce6c..a928f894f 100644</span><br>
<span style="font-size: 10pt;">--- a/lib/ioctl_wrappers.c</span><br>
<span style="font-size: 10pt;">+++ b/lib/ioctl_wrappers.c</span><br>
<span style="font-size: 10pt;">@@ -782,31 +782,6 @@ bool gem_engine_reset_enabled(int fd)</span><br>
<span style="font-size: 10pt;"> return gem_gpu_reset_type(fd) > 1;</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">-/**</span><br>
<span style="font-size: 10pt;">- * gem_available_fences:</span><br>
<span style="font-size: 10pt;">- * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Feature test macro to query the kernel for the number of available fences</span><br>
<span style="font-size: 10pt;">- * usable in a batchbuffer. Only relevant for pre-gen4.</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Returns: The number of available fences.</span><br>
<span style="font-size: 10pt;">- */</span><br>
<span style="font-size: 10pt;">-int gem_available_fences(int fd)</span><br>
<span style="font-size: 10pt;">-{</span><br>
<span style="font-size: 10pt;">- int num_fences;</span><br>
<span style="font-size: 10pt;">- struct drm_i915_getparam gp;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- memset(&gp, 0, sizeof(gp));</span><br>
<span style="font-size: 10pt;">- gp.param = I915_PARAM_NUM_FENCES_AVAIL;</span><br>
<span style="font-size: 10pt;">- gp.value = &num_fences;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- num_fences = 0;</span><br>
<span style="font-size: 10pt;">- ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));</span><br>
<span style="font-size: 10pt;">- errno = 0;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- return num_fences;</span><br>
<span style="font-size: 10pt;">-}</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;"> bool gem_has_llc(int fd)</span><br>
<span style="font-size: 10pt;"> {</span><br>
<span style="font-size: 10pt;"> int has_llc;</span><br>
<span style="font-size: 10pt;">@@ -929,97 +904,6 @@ uint64_t gem_total_stolen_size(int fd)</span><br>
<span style="font-size: 10pt;"> return aperture.stolen_total_size;</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">-/**</span><br>
<span style="font-size: 10pt;">- * gem_available_aperture_size:</span><br>
<span style="font-size: 10pt;">- * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Feature test macro to query the kernel for the available gpu aperture size</span><br>
<span style="font-size: 10pt;">- * usable in a batchbuffer.</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Returns: The available gtt address space size.</span><br>
<span style="font-size: 10pt;">- */</span><br>
<span style="font-size: 10pt;">-uint64_t gem_available_aperture_size(int fd)</span><br>
<span style="font-size: 10pt;">-{</span><br>
<span style="font-size: 10pt;">- struct drm_i915_gem_get_aperture aperture;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- memset(&aperture, 0, sizeof(aperture));</span><br>
<span style="font-size: 10pt;">- aperture.aper_size = 256*1024*1024;</span><br>
<span style="font-size: 10pt;">- do_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- return aperture.aper_available_size;</span><br>
<span style="font-size: 10pt;">-}</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">-/**</span><br>
<span style="font-size: 10pt;">- * gem_aperture_size:</span><br>
<span style="font-size: 10pt;">- * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Feature test macro to query the kernel for the total gpu aperture size.</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Returns: The total gtt address space size.</span><br>
<span style="font-size: 10pt;">- */</span><br>
<span style="font-size: 10pt;">-uint64_t gem_aperture_size(int fd)</span><br>
<span style="font-size: 10pt;">-{</span><br>
<span style="font-size: 10pt;">- uint64_t aperture_size = 0;</span><br>
<span style="font-size: 10pt;">- struct drm_i915_gem_context_param p;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- memset(&p, 0, sizeof(p));</span><br>
<span style="font-size: 10pt;">- p.param = 0x3;</span><br>
<span style="font-size: 10pt;">- if (__gem_context_get_param(fd, &p) == 0) {</span><br>
<span style="font-size: 10pt;">- aperture_size = p.value;</span><br>
<span style="font-size: 10pt;">- } else {</span><br>
<span style="font-size: 10pt;">- struct drm_i915_gem_get_aperture aperture;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- memset(&aperture, 0, sizeof(aperture));</span><br>
<span style="font-size: 10pt;">- aperture.aper_size = 256*1024*1024;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- do_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);</span><br>
<span style="font-size: 10pt;">- aperture_size = aperture.aper_size;</span><br>
<span style="font-size: 10pt;">- }</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- return aperture_size;</span><br>
<span style="font-size: 10pt;">-}</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">-/**</span><br>
<span style="font-size: 10pt;">- * gem_mappable_aperture_size:</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Feature test macro to query the kernel for the mappable gpu aperture size.</span><br>
<span style="font-size: 10pt;">- * This is the area available for GTT memory mappings.</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Returns: The mappable gtt address space size.</span><br>
<span style="font-size: 10pt;">- */</span><br>
<span style="font-size: 10pt;">-uint64_t gem_mappable_aperture_size(void)</span><br>
<span style="font-size: 10pt;">-{</span><br>
<span style="font-size: 10pt;">- struct pci_device *pci_dev = intel_get_pci_device();</span><br>
<span style="font-size: 10pt;">- int bar;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- if (intel_gen(pci_dev->device_id) < 3)</span><br>
<span style="font-size: 10pt;">- bar = 0;</span><br>
<span style="font-size: 10pt;">- else</span><br>
<span style="font-size: 10pt;">- bar = 2;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- return pci_dev->regions[bar].size;</span><br>
<span style="font-size: 10pt;">-}</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">-/**</span><br>
<span style="font-size: 10pt;">- * gem_global_aperture_size:</span><br>
<span style="font-size: 10pt;">- * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Feature test macro to query the kernel for the global gpu aperture size.</span><br>
<span style="font-size: 10pt;">- * This is the area available for the kernel to perform address translations.</span><br>
<span style="font-size: 10pt;">- *</span><br>
<span style="font-size: 10pt;">- * Returns: The gtt address space size.</span><br>
<span style="font-size: 10pt;">- */</span><br>
<span style="font-size: 10pt;">-uint64_t gem_global_aperture_size(int fd)</span><br>
<span style="font-size: 10pt;">-{</span><br>
<span style="font-size: 10pt;">- struct drm_i915_gem_get_aperture aperture;</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- memset(&aperture, 0, sizeof(aperture));</span><br>
<span style="font-size: 10pt;">- aperture.aper_size = 256*1024*1024;</span><br>
<span style="font-size: 10pt;">- do_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;">- return aperture.aper_size;</span><br>
<span style="font-size: 10pt;">-}</span><br>
<span style="font-size: 10pt;">-</span><br>
<span style="font-size: 10pt;"> /**</span><br>
<span style="font-size: 10pt;"> * gem_has_softpin:</span><br>
<span style="font-size: 10pt;"> * @fd: open i915 drm file descriptor</span><br>
<span style="font-size: 10pt;">diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h</span><br>
<span style="font-size: 10pt;">index b76bea564..07879ae96 100644</span><br>
<span style="font-size: 10pt;">--- a/lib/ioctl_wrappers.h</span><br>
<span style="font-size: 10pt;">+++ b/lib/ioctl_wrappers.h</span><br>
<span style="font-size: 10pt;">@@ -117,12 +117,7 @@ bool gem_uses_full_ppgtt(int fd);</span><br>
<span style="font-size: 10pt;"> int gem_gpu_reset_type(int fd);</span><br>
<span style="font-size: 10pt;"> bool gem_gpu_reset_enabled(int fd);</span><br>
<span style="font-size: 10pt;"> bool gem_engine_reset_enabled(int fd);</span><br>
<span style="font-size: 10pt;">-int gem_available_fences(int fd);</span><br>
<span style="font-size: 10pt;"> uint64_t gem_total_stolen_size(int fd);</span><br>
<span style="font-size: 10pt;">-uint64_t gem_available_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">-uint64_t gem_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">-uint64_t gem_global_aperture_size(int fd);</span><br>
<span style="font-size: 10pt;">-uint64_t gem_mappable_aperture_size(void);</span><br>
<span style="font-size: 10pt;"> bool gem_has_softpin(int fd);</span><br>
<span style="font-size: 10pt;"> bool gem_has_exec_fence(int fd);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c</span><br>
<span style="font-size: 10pt;">index 9ea94125e..da850a104 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/gem_concurrent_all.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/gem_concurrent_all.c</span><br>
<span style="font-size: 10pt;">@@ -1828,7 +1828,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> c->name, s->name, "small");</span><br>
<span style="font-size: 10pt;"> igt_subtest_group {</span><br>
<span style="font-size: 10pt;"> igt_fixture {</span><br>
<span style="font-size: 10pt;">- count = num_buffers(gem_mappable_aperture_size()/4,</span><br>
<span style="font-size: 10pt;">+ count = num_buffers(gem_mappable_aperture_size(fd)/4,</span><br>
<span style="font-size: 10pt;"> s, c, CHECK_RAM);</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> run_modes(name, c, modes, s, count);</span><br>
<span style="font-size: 10pt;">@@ -1839,7 +1839,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> c->name, s->name, "thrash");</span><br>
<span style="font-size: 10pt;"> igt_subtest_group {</span><br>
<span style="font-size: 10pt;"> igt_fixture {</span><br>
<span style="font-size: 10pt;">- count = num_buffers(gem_mappable_aperture_size(),</span><br>
<span style="font-size: 10pt;">+ count = num_buffers(gem_mappable_aperture_size(fd),</span><br>
<span style="font-size: 10pt;"> s, c, CHECK_RAM);</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> run_modes(name, c, modes, s, count);</span><br>
<span style="font-size: 10pt;">@@ -1871,7 +1871,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> c->name, s->name, "shrink");</span><br>
<span style="font-size: 10pt;"> igt_subtest_group {</span><br>
<span style="font-size: 10pt;"> igt_fixture {</span><br>
<span style="font-size: 10pt;">- count = num_buffers(gem_mappable_aperture_size(),</span><br>
<span style="font-size: 10pt;">+ count = num_buffers(gem_mappable_aperture_size(fd),</span><br>
<span style="font-size: 10pt;"> s, c, CHECK_RAM);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> igt_fork_shrink_helper(fd);</span><br>
<span style="font-size: 10pt;">@@ -1887,8 +1887,8 @@ igt_main</span><br>
<span style="font-size: 10pt;"> c->name, s->name, "swap");</span><br>
<span style="font-size: 10pt;"> igt_subtest_group {</span><br>
<span style="font-size: 10pt;"> igt_fixture {</span><br>
<span style="font-size: 10pt;">- if (intel_get_avail_ram_mb() > gem_mappable_aperture_size()/(1024*1024)) {</span><br>
<span style="font-size: 10pt;">- pin_sz = intel_get_avail_ram_mb() - gem_mappable_aperture_size()/(1024*1024);</span><br>
<span style="font-size: 10pt;">+ if (intel_get_avail_ram_mb() > gem_mappable_aperture_size(fd)/(1024*1024)) {</span><br>
<span style="font-size: 10pt;">+ pin_sz = intel_get_avail_ram_mb() - gem_mappable_aperture_size(fd)/(1024*1024);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> igt_debug("Pinning %lld MiB\n", (long long)pin_sz);</span><br>
<span style="font-size: 10pt;"> pin_sz *= 1024 * 1024;</span><br>
<span style="font-size: 10pt;">@@ -1902,7 +1902,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> igt_require(pinned);</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">- count = num_buffers(gem_mappable_aperture_size(),</span><br>
<span style="font-size: 10pt;">+ count = num_buffers(gem_mappable_aperture_size(fd),</span><br>
<span style="font-size: 10pt;"> s, c, CHECK_RAM | CHECK_SWAP);</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> run_modes(name, c, modes, s, count);</span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c</span><br>
<span style="font-size: 10pt;">index 8bad9b14e..60a64c134 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/gem_mmap.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/gem_mmap.c</span><br>
<span style="font-size: 10pt;">@@ -53,10 +53,10 @@ test_huge_bo(int huge)</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> switch (huge) {</span><br>
<span style="font-size: 10pt;"> case -1:</span><br>
<span style="font-size: 10pt;">- huge_object_size = gem_mappable_aperture_size() / 2;</span><br>
<span style="font-size: 10pt;">+ huge_object_size = gem_mappable_aperture_size(fd) / 2;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 0:</span><br>
<span style="font-size: 10pt;">- huge_object_size = gem_mappable_aperture_size() + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;">+ huge_object_size = gem_mappable_aperture_size(fd) + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 1:</span><br>
<span style="font-size: 10pt;"> huge_object_size = gem_aperture_size(fd) + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c</span><br>
<span style="font-size: 10pt;">index 61fbc5bc7..528a7c726 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/gem_mmap_gtt.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/gem_mmap_gtt.c</span><br>
<span style="font-size: 10pt;">@@ -905,7 +905,7 @@ test_huge_bo(int fd, int huge, int tiling)</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> switch (huge) {</span><br>
<span style="font-size: 10pt;"> case -1:</span><br>
<span style="font-size: 10pt;">- size = gem_mappable_aperture_size() / 2;</span><br>
<span style="font-size: 10pt;">+ size = gem_mappable_aperture_size(fd) / 2;</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> /* Power of two fence size, natural fence</span><br>
<span style="font-size: 10pt;"> * alignment, and the guard page at the end</span><br>
<span style="font-size: 10pt;">@@ -920,7 +920,7 @@ test_huge_bo(int fd, int huge, int tiling)</span><br>
<span style="font-size: 10pt;"> size /= 2;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 0:</span><br>
<span style="font-size: 10pt;">- size = gem_mappable_aperture_size() + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;">+ size = gem_mappable_aperture_size(fd) + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> default:</span><br>
<span style="font-size: 10pt;"> size = gem_global_aperture_size(fd) + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;">@@ -1001,13 +1001,13 @@ test_huge_copy(int fd, int huge, int tiling_a, int tiling_b, int ncpus)</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> switch (huge) {</span><br>
<span style="font-size: 10pt;"> case -2:</span><br>
<span style="font-size: 10pt;">- huge_object_size = gem_mappable_aperture_size() / 4;</span><br>
<span style="font-size: 10pt;">+ huge_object_size = gem_mappable_aperture_size(fd) / 4;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case -1:</span><br>
<span style="font-size: 10pt;">- huge_object_size = gem_mappable_aperture_size() / 2;</span><br>
<span style="font-size: 10pt;">+ huge_object_size = gem_mappable_aperture_size(fd) / 2;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 0:</span><br>
<span style="font-size: 10pt;">- huge_object_size = gem_mappable_aperture_size() + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;">+ huge_object_size = gem_mappable_aperture_size(fd) + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 1:</span><br>
<span style="font-size: 10pt;"> huge_object_size = gem_global_aperture_size(fd) + PAGE_SIZE;</span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/gem_pwrite.c b/tests/i915/gem_pwrite.c</span><br>
<span style="font-size: 10pt;">index d2dcc95e8..f76d2bc70 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/gem_pwrite.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/gem_pwrite.c</span><br>
<span style="font-size: 10pt;">@@ -130,7 +130,7 @@ static void test_big_cpu(int fd, int scale, unsigned flags)</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> switch (scale) {</span><br>
<span style="font-size: 10pt;"> case 0:</span><br>
<span style="font-size: 10pt;">- size = gem_mappable_aperture_size() + 4096;</span><br>
<span style="font-size: 10pt;">+ size = gem_mappable_aperture_size(fd) + 4096;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 1:</span><br>
<span style="font-size: 10pt;"> size = gem_global_aperture_size(fd) + 4096;</span><br>
<span style="font-size: 10pt;">@@ -192,7 +192,7 @@ static void test_big_gtt(int fd, int scale, unsigned flags)</span><br>
<span style="font-size: 10pt;"> igt_require(gem_mmap__has_wc(fd));</span><br>
<span style="font-size: 10pt;"> switch (scale) {</span><br>
<span style="font-size: 10pt;"> case 0:</span><br>
<span style="font-size: 10pt;">- size = gem_mappable_aperture_size() + 4096;</span><br>
<span style="font-size: 10pt;">+ size = gem_mappable_aperture_size(fd) + 4096;</span><br>
<span style="font-size: 10pt;"> break;</span><br>
<span style="font-size: 10pt;"> case 1:</span><br>
<span style="font-size: 10pt;"> size = gem_global_aperture_size(fd) + 4096;</span><br>
<span style="font-size: 10pt;">@@ -257,7 +257,7 @@ static void test_random(int fd)</span><br>
<span style="font-size: 10pt;"> gem_require_mmap_wc(fd);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> size = min(intel_get_total_ram_mb() / 2,</span><br>
<span style="font-size: 10pt;">- gem_mappable_aperture_size() + 4096);</span><br>
<span style="font-size: 10pt;">+ gem_mappable_aperture_size(fd) + 4096);</span><br>
<span style="font-size: 10pt;"> intel_require_memory(1, size, CHECK_RAM);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> handle = gem_create(fd, size);</span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c</span><br>
<span style="font-size: 10pt;">index dba62c8fa..023db8c56 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/gem_shrink.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/gem_shrink.c</span><br>
<span style="font-size: 10pt;">@@ -439,7 +439,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> * we expect the shrinker to start purging objects,</span><br>
<span style="font-size: 10pt;"> * and possibly fail.</span><br>
<span style="font-size: 10pt;"> */</span><br>
<span style="font-size: 10pt;">- alloc_size = gem_mappable_aperture_size() / 2;</span><br>
<span style="font-size: 10pt;">+ alloc_size = gem_mappable_aperture_size(fd) / 2;</span><br>
<span style="font-size: 10pt;"> num_processes = 1 + (mem_size / (alloc_size >> 20));</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> igt_info("Using %d processes and %'lluMiB per process\n",</span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/gem_tiled_fence_blits.c b/tests/i915/gem_tiled_fence_blits.c</span><br>
<span style="font-size: 10pt;">index 0a633d91b..28beea898 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/gem_tiled_fence_blits.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/gem_tiled_fence_blits.c</span><br>
<span style="font-size: 10pt;">@@ -225,7 +225,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> gem_require_blitter(fd);</span><br>
<span style="font-size: 10pt;"> gem_require_mappable_ggtt(fd);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">- count = gem_mappable_aperture_size(); /* thrash fences! */</span><br>
<span style="font-size: 10pt;">+ count = gem_mappable_aperture_size(fd); /* thrash fences! */</span><br>
<span style="font-size: 10pt;"> if (count >> 32)</span><br>
<span style="font-size: 10pt;"> count = MAX_32b;</span><br>
<span style="font-size: 10pt;"> count = 3 + count / (1024 * 1024);</span><br>
<span style="font-size: 10pt;">diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c</span><br>
<span style="font-size: 10pt;">index 6d46c320c..6321dd403 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/i915/i915_pm_rpm.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/i915/i915_pm_rpm.c</span><br>
<span style="font-size: 10pt;">@@ -1419,7 +1419,7 @@ static void gem_evict_pwrite_subtest(void)</span><br>
<span style="font-size: 10pt;"> unsigned int num_trash_bos, n;</span><br>
<span style="font-size: 10pt;"> uint32_t buf;</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">- num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1;</span><br>
<span style="font-size: 10pt;">+ num_trash_bos = gem_mappable_aperture_size(drm_fd) / (1024*1024) + 1;</span><br>
<span style="font-size: 10pt;"> trash_bos = malloc(num_trash_bos * sizeof(*trash_bos));</span><br>
<span style="font-size: 10pt;"> igt_assert(trash_bos);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">@@ -1463,7 +1463,7 @@ static bool device_in_pci_d3(void)</span><br>
<span style="font-size: 10pt;"> uint16_t val;</span><br>
<span style="font-size: 10pt;"> int rc;</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">- rc = pci_device_cfg_read_u16(intel_get_pci_device(), &val, 0xd4);</span><br>
<span style="font-size: 10pt;">+ rc = pci_device_cfg_read_u16(igt_device_get_pci_device(drm_fd), &val, 0xd4);</span><br>
<span style="font-size: 10pt;"> igt_assert_eq(rc, 0);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> igt_debug("%s: PCI D3 state=%d\n", __func__, val & 0x3);</span><br>
<span style="font-size: 10pt;">diff --git a/tests/kms_big_fb.c b/tests/kms_big_fb.c</span><br>
<span style="font-size: 10pt;">index 02e9915ba..8794ace08 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/kms_big_fb.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/kms_big_fb.c</span><br>
<span style="font-size: 10pt;">@@ -645,7 +645,7 @@ igt_main</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> data.ram_size = intel_get_total_ram_mb() << 20;</span><br>
<span style="font-size: 10pt;"> data.aper_size = gem_aperture_size(data.drm_fd);</span><br>
<span style="font-size: 10pt;">- data.mappable_size = gem_mappable_aperture_size();</span><br>
<span style="font-size: 10pt;">+ data.mappable_size = gem_mappable_aperture_size(data.drm_fd);</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> igt_info("RAM: %"PRIu64" MiB, GPU address space: %"PRId64" MiB, GGTT mappable size: %"PRId64" MiB\n",</span><br>
<span style="font-size: 10pt;"> data.ram_size >> 20, data.aper_size >> 20,</span><br>
<span style="font-size: 10pt;">diff --git a/tests/kms_flip.c b/tests/kms_flip.c</span><br>
<span style="font-size: 10pt;">index 51b9ac950..0f0565cf6 100755</span><br>
<span style="font-size: 10pt;">--- a/tests/kms_flip.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/kms_flip.c</span><br>
<span style="font-size: 10pt;">@@ -1282,7 +1282,7 @@ static void __run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,</span><br>
<span style="font-size: 10pt;"> /* 256 MB is usually the maximum mappable aperture,</span><br>
<span style="font-size: 10pt;"> * (make it 4x times that to ensure failure) */</span><br>
<span style="font-size: 10pt;"> if (o->flags & TEST_BO_TOOBIG) {</span><br>
<span style="font-size: 10pt;">- bo_size = 4*gem_mappable_aperture_size();</span><br>
<span style="font-size: 10pt;">+ bo_size = 4*gem_mappable_aperture_size(drm_fd);</span><br>
<span style="font-size: 10pt;"> igt_require(bo_size < gem_global_aperture_size(drm_fd));</span><br>
<span style="font-size: 10pt;"> }</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;">diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c</span><br>
<span style="font-size: 10pt;">index 143342410..7c43ced85 100644</span><br>
<span style="font-size: 10pt;">--- a/tests/prime_mmap.c</span><br>
<span style="font-size: 10pt;">+++ b/tests/prime_mmap.c</span><br>
<span style="font-size: 10pt;">@@ -447,8 +447,8 @@ test_aperture_limit(void)</span><br>
<span style="font-size: 10pt;"> char *ptr1, *ptr2;</span><br>
<span style="font-size: 10pt;"> uint32_t handle1, handle2;</span><br>
<span style="font-size: 10pt;"> /* Two buffers the sum of which > mappable aperture */</span><br>
<span style="font-size: 10pt;">- uint64_t size1 = (gem_mappable_aperture_size() * 7) / 8;</span><br>
<span style="font-size: 10pt;">- uint64_t size2 = (gem_mappable_aperture_size() * 3) / 8;</span><br>
<span style="font-size: 10pt;">+ uint64_t size1 = (gem_mappable_aperture_size(fd) * 7) / 8;</span><br>
<span style="font-size: 10pt;">+ uint64_t size2 = (gem_mappable_aperture_size(fd) * 3) / 8;</span><br>
<span style="font-size: 10pt;"> </span><br>
<span style="font-size: 10pt;"> handle1 = gem_create(fd, size1);</span><br>
<span style="font-size: 10pt;"> fill_bo(handle1, BO_SIZE);</span><br>
<span style="font-size: 10pt;">-- </span><br>
<span style="font-size: 10pt;">2.29.2</span><br>
<br>
</div>
</font></div>
</div>
</body>
</html>