[PATCH] intel: Export GT config attributes
From: Jeff McGee
Update kernel interface with new I915_GETPARAM ioctl entries for
slice total, subslice total, EU total, and threads per EU. Add a
wrapping function for each parameter.
The motivation for this change is that fusing can be used to create
multiple slice, subslice, and EU configuration within the same PCI
ID. CHV is the first such device to do this and thus make an ID-based
lookup table approach unreliable. The best solution is for the kernel
to determine the precise config from fuse registers and share the
required information with userspace. Moving to this approach has the
added benefit of reducing the number of static parameters that
userspace must maintain for current and future devices.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
include/drm/i915_drm.h | 4 +++
intel/intel_bufmgr.h | 5
intel/intel_bufmgr_gem.c | 63
3 files changed, 72 insertions(+)
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 15dd01d..be38adf 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -340,6 +340,10 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
#define I915_PARAM_HAS_WT 27
#define I915_PARAM_CMD_PARSER_VERSION 28
+#define I915_PARAM_SLICE_TOTAL 30
+#define I915_PARAM_SUBSLICE_TOTAL 31
+#define I915_PARAM_EU_TOTAL 32
+#define I915_PARAM_THREADS_PER_EU 33
typedef struct drm_i915_getparam {
int param;
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index be83a56..90e535d 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -264,6 +264,11 @@ int drm_intel_get_reset_stats(drm_intel_context *ctx,
uint32_t *active,
uint32_t *pending);
+int drm_intel_get_slice_total(int fd, unsigned int *slice_total);
+int drm_intel_get_subslice_total(int fd, unsigned int *subslice_total);
+int drm_intel_get_eu_total(int fd, unsigned int *eu_total);
+int drm_intel_get_threads_per_eu(int fd, unsigned int *threads_per_eu);
+
/** @{ Compatibility defines to keep old code building despite the symbol
rename
* from dri_* to drm_intel_*
*/
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 14e92c9..e0b13e7 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -3293,6 +3293,69 @@ drm_intel_reg_read(drm_intel_bufmgr *bufmgr,
return ret;
}
+drm_public int
+drm_intel_get_slice_total(int fd, unsigned int *slice_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ VG_CLEAR(gp);
+ gp.value = (int*)slice_total;
+ gp.param = I915_PARAM_SLICE_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+drm_public int
+drm_intel_get_subslice_total(int fd, unsigned int *subslice_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ VG_CLEAR(gp);
+ gp.value = (int*)subslice_total;
+ gp.param = I915_PARAM_SUBSLICE_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+drm_public int
+drm_intel_get_eu_total(int fd, unsigned int *eu_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ VG_CLEAR(gp);
+ gp.value = (int*)eu_total;
+ gp.param = I915_PARAM_EU_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+drm_public int
+drm_intel_get_threads_per_eu(int fd, unsigned int *threads_per_eu)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ VG_CLEAR(gp);
+ gp.value = (int*)threads_per_eu;
+ gp.param = I915_PARAM_THREADS_PER_EU;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
/**
* Annotate the given bo for use in aub dumping.
--
2.2.0
[PATCH] intel: Export GT config attributes
From: Jeff McGee The motivation for this change is that fusing can be used to create multiple slice, subslice, and EU configuration within the same PCI ID. CHV is the first such device to do this and thus make an ID-based lookup table approach unreliable. The best solution is for the kernel to determine the precise config from fuse registers and share the required information with userspace. Moving to this approach has the added benefit of reducing the number of static parameters that userspace must maintain for current and future devices. The associated kernel patch has been posted to intel-gfx list (no archive link yet). I'm trying to collect feedback from userspace which I hope will be interested in adopting some form of this interface. I am starting with these 4 attributes, but we can add or remove them according to the userspace needs. Please provide any comments. Thanks Jeff McGee (1): intel: Export GT config attributes include/drm/i915_drm.h | 4 +++ intel/intel_bufmgr.h | 5 intel/intel_bufmgr_gem.c | 63 3 files changed, 72 insertions(+) -- 2.2.0
[PATCH] drm/i915: Export total subslice and EU counts
From: Jeff McGee
Setup new I915_GETPARAM ioctl entries for subslice total and
EU total. Userspace drivers need these values when constructing
GPGPU commands. This kernel query method is intended to replace
the PCI ID-based tables that userspace drivers currently maintain.
The kernel driver can employ fuse register reads as needed to
ensure the most accurate determination of GT config attributes.
This first became important with Cherryview in which the config
could differ between devices with the same PCI ID.
The kernel detection of these values is device-specific and not
included in this patch. Because zero is not a valid value for any of
these parameters, a value of zero is interpreted as unknown for the
device. Userspace drivers should continue to maintain ID-based tables
for older devices not supported by the new query method.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
drivers/gpu/drm/i915/i915_dma.c | 10 ++
include/uapi/drm/i915_drm.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 053e178..9350ea2 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -150,6 +150,16 @@ static int i915_getparam(struct drm_device *dev, void
*data,
case I915_PARAM_MMAP_VERSION:
value = 1;
break;
+ case I915_PARAM_SUBSLICE_TOTAL:
+ value = INTEL_INFO(dev)->subslice_total;
+ if (!value)
+ return -ENODEV;
+ break;
+ case I915_PARAM_EU_TOTAL:
+ value = INTEL_INFO(dev)->eu_total;
+ if (!value)
+ return -ENODEV;
+ break;
default:
DRM_DEBUG("Unknown parameter %d\n", param->param);
return -EINVAL;
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 6eed16b..8672efc 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -347,6 +347,8 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
#define I915_PARAM_MMAP_VERSION 30
#define I915_PARAM_HAS_BSD2 31
+#define I915_PARAM_SUBSLICE_TOTAL 32
+#define I915_PARAM_EU_TOTAL 33
typedef struct drm_i915_getparam {
int param;
--
2.3.0
[PATCH] intel: Export total subslice and EU counts
From: Jeff McGee
Update kernel interface with new I915_GETPARAM ioctl entries for
subslice total and EU total. Add a wrapping function for each
parameter. Userspace drivers need these values when constructing
GPGPU commands. This kernel query method is intended to replace
the PCI ID-based tables that userspace drivers currently maintain.
The kernel driver can employ fuse register reads as needed to
ensure the most accurate determination of GT config attributes.
This first became important with Cherryview in which the config
could differ between devices with the same PCI ID.
The kernel detection of these values is device-specific. Userspace
drivers should continue to maintain ID-based tables for older
devices which return ENODEV when using this query.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
include/drm/i915_drm.h | 2 ++
intel/intel_bufmgr.h | 4
intel/intel_bufmgr_gem.c | 31 +++
3 files changed, 37 insertions(+)
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 15dd01d..e34f5b2 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -340,6 +340,8 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
#define I915_PARAM_HAS_WT 27
#define I915_PARAM_CMD_PARSER_VERSION 28
+#define I915_PARAM_SUBSLICE_TOTAL 32
+#define I915_PARAM_EU_TOTAL 33
typedef struct drm_i915_getparam {
int param;
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index be83a56..4b2472e 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -37,6 +37,7 @@
#include
#include
#include
+#include
struct drm_clip_rect;
@@ -264,6 +265,9 @@ int drm_intel_get_reset_stats(drm_intel_context *ctx,
uint32_t *active,
uint32_t *pending);
+int drm_intel_get_subslice_total(int fd, unsigned int *subslice_total);
+int drm_intel_get_eu_total(int fd, unsigned int *eu_total);
+
/** @{ Compatibility defines to keep old code building despite the symbol
rename
* from dri_* to drm_intel_*
*/
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 78875fd..2d77f32 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -3292,6 +3292,37 @@ drm_intel_reg_read(drm_intel_bufmgr *bufmgr,
return ret;
}
+drm_public int
+drm_intel_get_subslice_total(int fd, unsigned int *subslice_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ memclear(gp);
+ gp.value = (int*)subslice_total;
+ gp.param = I915_PARAM_SUBSLICE_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+drm_public int
+drm_intel_get_eu_total(int fd, unsigned int *eu_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ memclear(gp);
+ gp.value = (int*)eu_total;
+ gp.param = I915_PARAM_EU_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
/**
* Annotate the given bo for use in aub dumping.
--
2.3.0
[PATCH] tests/core_getparams: Create new test core_getparams
From: Jeff McGee
New test core_getparams consists of 2 subtests, each one testing
the ability of userspace to query the correct value of a GT config
attribute: subslice total or EU total. drm/i915 implementation of
these queries is required for Cherryview and Gen9+ devices (non-
simulated).
For: VIZ-4636
Signed-off-by: Jeff McGee
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_getparams.c | 145 +
3 files changed, 147 insertions(+)
create mode 100644 tests/core_getparams.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 7b4dd94..39b4e28 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,7 @@
# Please keep sorted alphabetically
core_get_client_auth
core_getclient
+core_getparams
core_getstats
core_getversion
drm_import_export
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 51e8376..999c8f8 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -15,6 +15,7 @@ NOUVEAU_TESTS_M = \
TESTS_progs_M = \
core_get_client_auth \
+ core_getparams \
drv_suspend \
drv_hangman \
gem_bad_reloc \
diff --git a/tests/core_getparams.c b/tests/core_getparams.c
new file mode 100644
index 000..37a4f63
--- /dev/null
+++ b/tests/core_getparams.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Jeff McGee
+ *
+ */
+
+#include
+#include
+#include
+#include "drmtest.h"
+#include "intel_chipset.h"
+#include "intel_bufmgr.h"
+
+int drm_fd;
+int devid;
+
+static void
+init(void)
+{
+ drm_fd = drm_open_any();
+ devid = intel_get_drm_devid(drm_fd);
+}
+
+static void
+deinit(void)
+{
+ close(drm_fd);
+}
+
+static void
+subslice_total(void)
+{
+ unsigned int subslice_total = 0;
+ int ret;
+
+ ret = drm_intel_get_subslice_total(drm_fd, &subslice_total);
+
+ if (ret) {
+ /*
+* These devices are not required to implement the
+* interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert(ret == -ENODEV);
+ igt_info("subslice total: unknown\n");
+ /*
+* All other devices must implement the interface, so
+* fail them if we are here.
+ */
+ } else {
+ igt_assert(ret != EINVAL); /* request not recognized? */
+ igt_assert(ret != ENODEV); /* device not supported? */
+ igt_assert(ret == 0); /* other error? */
+ }
+ } else {
+ /*
+* On success, just make sure the returned count value is
+* non-zero. The validity of the count value for the given
+* device is not checked.
+ */
+ igt_assert(subslice_total != 0);
+ igt_info("subslice total: %u\n", subslice_total);
+ }
+}
+
+static void
+eu_total(void)
+{
+ unsigned int eu_total = 0;
+ int ret;
+
+ ret = drm_intel_get_eu_total(drm_fd, &eu_total);
+
+ if (ret) {
+ /*
+* These devices are not required to implement the
+* interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert(ret == -ENODEV);
+ igt_info("EU total: unknown\n");
+ /*
+* All other devices must implement the interface, so
+* fail them if we are
[PATCH 1/2] Add driver callback for updating device info
From: Jeff McGee
We need to update some fields of the device's cl_device_id
struct at runtime using driver-specific methods. It is best to
group all such updates into a single driver callback to avoid
opening/initing and deiniting/closing the device multiple times.
Signed-off-by: Jeff McGee
---
src/cl_device_id.c | 20 ++--
src/cl_driver.h | 4
src/cl_driver_defs.c | 1 +
src/intel/intel_driver.c | 36
4 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 4e01c9f..fefcef3 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -506,24 +506,8 @@ skl_gt4_break:
ret->profile_sz = strlen(ret->profile) + 1;
}
-#ifdef HAS_USERPTR
- cl_driver dummy = cl_driver_new(NULL);
- cl_buffer_mgr bufmgr = cl_driver_get_bufmgr(dummy);
-
- const size_t sz = 4096;
- void* host_ptr = cl_aligned_malloc(sz, 4096);;
- if (host_ptr != NULL) {
-cl_buffer bo = cl_buffer_alloc_userptr(bufmgr, "CL memory object",
host_ptr, sz, 0);
-if (bo == NULL)
- ret->host_unified_memory = CL_FALSE;
-else
- cl_buffer_unreference(bo);
-cl_free(host_ptr);
- }
- else
-ret->host_unified_memory = CL_FALSE;
- cl_driver_delete(dummy);
-#endif
+ /* Apply any driver-dependent updates to the device info */
+ cl_driver_update_device_info(ret);
struct sysinfo info;
if (sysinfo(&info) == 0) {
diff --git a/src/cl_driver.h b/src/cl_driver.h
index 16f8bba..3f54a27 100644
--- a/src/cl_driver.h
+++ b/src/cl_driver.h
@@ -376,6 +376,10 @@ extern cl_buffer_get_tiling_align_cb
*cl_buffer_get_tiling_align;
typedef int (cl_driver_get_device_id_cb)(void);
extern cl_driver_get_device_id_cb *cl_driver_get_device_id;
+/* Update the device info */
+typedef void (cl_driver_update_device_info_cb)(cl_device_id device);
+extern cl_driver_update_device_info_cb *cl_driver_update_device_info;
+
/**
* cl_khr_gl_sharing.
**/
diff --git a/src/cl_driver_defs.c b/src/cl_driver_defs.c
index 2b68539..9a47210 100644
--- a/src/cl_driver_defs.c
+++ b/src/cl_driver_defs.c
@@ -26,6 +26,7 @@ LOCAL cl_driver_delete_cb *cl_driver_delete = NULL;
LOCAL cl_driver_get_bufmgr_cb *cl_driver_get_bufmgr = NULL;
LOCAL cl_driver_get_ver_cb *cl_driver_get_ver = NULL;
LOCAL cl_driver_get_device_id_cb *cl_driver_get_device_id = NULL;
+LOCAL cl_driver_update_device_info_cb *cl_driver_update_device_info = NULL;
/* Buffer */
LOCAL cl_buffer_alloc_cb *cl_buffer_alloc = NULL;
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index ff0cf27..d61988c 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -754,6 +754,41 @@ static int intel_buffer_set_tiling(cl_buffer bo,
return ret;
}
+static void
+intel_update_device_info(cl_device_id device)
+{
+#ifdef HAS_USERPTR
+ intel_driver_t *driver;
+ const size_t sz = 4096;
+ void *host_ptr;
+
+ driver = intel_driver_new();
+ assert(driver != NULL);
+ if (intel_driver_open(driver, NULL) != CL_SUCCESS) {
+intel_driver_delete(driver);
+return;
+ }
+
+ host_ptr = cl_aligned_malloc(sz, 4096);
+ if (host_ptr != NULL) {
+cl_buffer bo = intel_buffer_alloc_userptr((cl_buffer_mgr)driver->bufmgr,
+ "CL memory object", host_ptr, sz, 0);
+if (bo == NULL)
+ device->host_unified_memory = CL_FALSE;
+else
+ drm_intel_bo_unreference((drm_intel_bo*)bo);
+cl_free(host_ptr);
+ }
+ else
+device->host_unified_memory = CL_FALSE;
+
+ intel_driver_context_destroy(driver);
+ intel_driver_close(driver);
+ intel_driver_terminate(driver);
+ intel_driver_delete(driver);
+#endif
+}
+
LOCAL void
intel_setup_callbacks(void)
{
@@ -762,6 +797,7 @@ intel_setup_callbacks(void)
cl_driver_get_ver = (cl_driver_get_ver_cb *) intel_driver_get_ver;
cl_driver_get_bufmgr = (cl_driver_get_bufmgr_cb *) intel_driver_get_bufmgr;
cl_driver_get_device_id = (cl_driver_get_device_id_cb *) intel_get_device_id;
+ cl_driver_update_device_info = (cl_driver_update_device_info_cb *)
intel_update_device_info;
cl_buffer_alloc = (cl_buffer_alloc_cb *) drm_intel_bo_alloc;
cl_buffer_alloc_userptr = (cl_buffer_alloc_userptr_cb*)
intel_buffer_alloc_userptr;
cl_buffer_set_tiling = (cl_buffer_set_tiling_cb *) intel_buffer_set_tiling;
--
2.3.0
[PATCH 2/2] Query the driver directly for compute units and subslice
From: Jeff McGee
Values of device max compute units and max subslice obtained
directly from the driver should be more accurate than our own
ID-based lookup values. This is particularly important when a
single device ID may encompass more than one configuration. If
the driver cannot provide a valid value for the given device,
we fallback on the ID-based lookup value.
Signed-off-by: Jeff McGee
---
src/intel/intel_driver.c | 16
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index d61988c..d99fea9 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -757,10 +757,8 @@ static int intel_buffer_set_tiling(cl_buffer bo,
static void
intel_update_device_info(cl_device_id device)
{
-#ifdef HAS_USERPTR
intel_driver_t *driver;
- const size_t sz = 4096;
- void *host_ptr;
+ unsigned int eu_total, subslice_total;
driver = intel_driver_new();
assert(driver != NULL);
@@ -769,6 +767,10 @@ intel_update_device_info(cl_device_id device)
return;
}
+#ifdef HAS_USERPTR
+ const size_t sz = 4096;
+ void *host_ptr;
+
host_ptr = cl_aligned_malloc(sz, 4096);
if (host_ptr != NULL) {
cl_buffer bo = intel_buffer_alloc_userptr((cl_buffer_mgr)driver->bufmgr,
@@ -781,12 +783,18 @@ intel_update_device_info(cl_device_id device)
}
else
device->host_unified_memory = CL_FALSE;
+#endif
+
+ /* Prefer driver-queried value if supported */
+ if (!drm_intel_get_eu_total(driver->fd, &eu_total))
+device->max_compute_unit = eu_total;
+ if (!drm_intel_get_subslice_total(driver->fd, &subslice_total))
+device->sub_slice_count = subslice_total;
intel_driver_context_destroy(driver);
intel_driver_close(driver);
intel_driver_terminate(driver);
intel_driver_delete(driver);
-#endif
}
LOCAL void
--
2.3.0
[PATCH v2] drm/i915: Export total subslice and EU counts
From: Jeff McGee
Setup new I915_GETPARAM ioctl entries for subslice total and
EU total. Userspace drivers need these values when constructing
GPGPU commands. This kernel query method is intended to replace
the PCI ID-based tables that userspace drivers currently maintain.
The kernel driver can employ fuse register reads as needed to
ensure the most accurate determination of GT config attributes.
This first became important with Cherryview in which the config
could differ between devices with the same PCI ID.
The kernel detection of these values is device-specific and not
included in this patch. Because zero is not a valid value for any of
these parameters, a value of zero is interpreted as unknown for the
device. Userspace drivers should continue to maintain ID-based tables
for older devices not supported by the new query method.
v2: Increment our I915_GETPARAM indices to fit after REVISION
which was merged ahead of us.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
drivers/gpu/drm/i915/i915_dma.c | 10 ++
include/uapi/drm/i915_drm.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 8e91430..d49ed68 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -153,6 +153,16 @@ static int i915_getparam(struct drm_device *dev, void
*data,
case I915_PARAM_MMAP_VERSION:
value = 1;
break;
+ case I915_PARAM_SUBSLICE_TOTAL:
+ value = INTEL_INFO(dev)->subslice_total;
+ if (!value)
+ return -ENODEV;
+ break;
+ case I915_PARAM_EU_TOTAL:
+ value = INTEL_INFO(dev)->eu_total;
+ if (!value)
+ return -ENODEV;
+ break;
default:
DRM_DEBUG("Unknown parameter %d\n", param->param);
return -EINVAL;
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index b768f3b..8d1be90 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -348,6 +348,8 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_MMAP_VERSION 30
#define I915_PARAM_HAS_BSD2 31
#define I915_PARAM_REVISION 32
+#define I915_PARAM_SUBSLICE_TOTAL 33
+#define I915_PARAM_EU_TOTAL 34
typedef struct drm_i915_getparam {
int param;
--
2.3.0
[PATCH 1/2 v2] intel: Export total subslice and EU counts
From: Jeff McGee
Update kernel interface with new I915_GETPARAM ioctl entries for
subslice total and EU total. Add a wrapping function for each
parameter. Userspace drivers need these values when constructing
GPGPU commands. This kernel query method is intended to replace
the PCI ID-based tables that userspace drivers currently maintain.
The kernel driver can employ fuse register reads as needed to
ensure the most accurate determination of GT config attributes.
This first became important with Cherryview in which the config
could differ between devices with the same PCI ID.
The kernel detection of these values is device-specific. Userspace
drivers should continue to maintain ID-based tables for older
devices which return ENODEV when using this query.
v2: remove unnecessary include of and increment the
I915_GETPARAM indices to match updated kernel patch.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
include/drm/i915_drm.h | 2 ++
intel/intel_bufmgr.h | 3 +++
intel/intel_bufmgr_gem.c | 31 +++
3 files changed, 36 insertions(+)
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 15dd01d..b037e56 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -340,6 +340,8 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
#define I915_PARAM_HAS_WT 27
#define I915_PARAM_CMD_PARSER_VERSION 28
+#define I915_PARAM_SUBSLICE_TOTAL 33
+#define I915_PARAM_EU_TOTAL 34
typedef struct drm_i915_getparam {
int param;
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index be83a56..285919e 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -264,6 +264,9 @@ int drm_intel_get_reset_stats(drm_intel_context *ctx,
uint32_t *active,
uint32_t *pending);
+int drm_intel_get_subslice_total(int fd, unsigned int *subslice_total);
+int drm_intel_get_eu_total(int fd, unsigned int *eu_total);
+
/** @{ Compatibility defines to keep old code building despite the symbol
rename
* from dri_* to drm_intel_*
*/
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index acbfd4a..5a67f53 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -3295,6 +3295,37 @@ drm_intel_reg_read(drm_intel_bufmgr *bufmgr,
return ret;
}
+drm_public int
+drm_intel_get_subslice_total(int fd, unsigned int *subslice_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ memclear(gp);
+ gp.value = (int*)subslice_total;
+ gp.param = I915_PARAM_SUBSLICE_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+drm_public int
+drm_intel_get_eu_total(int fd, unsigned int *eu_total)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ memclear(gp);
+ gp.value = (int*)eu_total;
+ gp.param = I915_PARAM_EU_TOTAL;
+ ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
/**
* Annotate the given bo for use in aub dumping.
--
2.3.0
[PATCH 2/2] configure.ac: bump version to 2.4.60 for release
From: Jeff McGee Signed-off-by: Jeff McGee --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8afee83..278f29b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], -[2.4.59], +[2.4.60], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) -- 2.3.0
[PATCH i-g-t 1/2] tests/core_getparams: Create new test core_getparams
From: Jeff McGee
New test core_getparams consists of 2 subtests, each one testing
the ability of userspace to query the correct value of a GT config
attribute: subslice total or EU total. drm/i915 implementation of
these queries is required for Cherryview and Gen9+ devices (non-
simulated).
For: VIZ-4636
Signed-off-by: Jeff McGee
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_getparams.c | 145 +
3 files changed, 147 insertions(+)
create mode 100644 tests/core_getparams.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 7b4dd94..39b4e28 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,7 @@
# Please keep sorted alphabetically
core_get_client_auth
core_getclient
+core_getparams
core_getstats
core_getversion
drm_import_export
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 51e8376..999c8f8 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -15,6 +15,7 @@ NOUVEAU_TESTS_M = \
TESTS_progs_M = \
core_get_client_auth \
+ core_getparams \
drv_suspend \
drv_hangman \
gem_bad_reloc \
diff --git a/tests/core_getparams.c b/tests/core_getparams.c
new file mode 100644
index 000..37a4f63
--- /dev/null
+++ b/tests/core_getparams.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Jeff McGee
+ *
+ */
+
+#include
+#include
+#include
+#include "drmtest.h"
+#include "intel_chipset.h"
+#include "intel_bufmgr.h"
+
+int drm_fd;
+int devid;
+
+static void
+init(void)
+{
+ drm_fd = drm_open_any();
+ devid = intel_get_drm_devid(drm_fd);
+}
+
+static void
+deinit(void)
+{
+ close(drm_fd);
+}
+
+static void
+subslice_total(void)
+{
+ unsigned int subslice_total = 0;
+ int ret;
+
+ ret = drm_intel_get_subslice_total(drm_fd, &subslice_total);
+
+ if (ret) {
+ /*
+* These devices are not required to implement the
+* interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert(ret == -ENODEV);
+ igt_info("subslice total: unknown\n");
+ /*
+* All other devices must implement the interface, so
+* fail them if we are here.
+ */
+ } else {
+ igt_assert(ret != EINVAL); /* request not recognized? */
+ igt_assert(ret != ENODEV); /* device not supported? */
+ igt_assert(ret == 0); /* other error? */
+ }
+ } else {
+ /*
+* On success, just make sure the returned count value is
+* non-zero. The validity of the count value for the given
+* device is not checked.
+ */
+ igt_assert(subslice_total != 0);
+ igt_info("subslice total: %u\n", subslice_total);
+ }
+}
+
+static void
+eu_total(void)
+{
+ unsigned int eu_total = 0;
+ int ret;
+
+ ret = drm_intel_get_eu_total(drm_fd, &eu_total);
+
+ if (ret) {
+ /*
+* These devices are not required to implement the
+* interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert(ret == -ENODEV);
+ igt_info("EU total: unknown\n");
+ /*
+* All other devices must implement the interface, so
+* fail them if we are
[PATCH i-g-t 2/2] configure: Bump required libdrm version to 2.4.60
From: Jeff McGee tests/core_getparams needs the new libdrm interfaces for querying subslice and EU counts. For: VIZ-4636 Signed-off-by: Jeff McGee --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 16d6a2e..88a1c3d 100644 --- a/configure.ac +++ b/configure.ac @@ -82,7 +82,7 @@ if test "x$GCC" = "xyes"; then fi AC_SUBST(ASSEMBLER_WARN_CFLAGS) -PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.52 libdrm]) +PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.60 libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) PKG_CHECK_MODULES(OVERLAY_XVLIB, [xv x11 xext dri2proto >= 2.6], enable_overlay_xvlib=yes, enable_overlay_xvlib=no) PKG_CHECK_MODULES(OVERLAY_XLIB, [cairo-xlib dri2proto >= 2.6], enable_overlay_xlib=yes, enable_overlay_xlib=no) -- 2.3.0
[PATCH i-g-t 2/2] configure: Bump required libdrm version to 2.4.60
From: Jeff McGee tests/core_getparams needs the new libdrm interfaces for querying subslice and EU counts. For: VIZ-4636 Signed-off-by: Jeff McGee --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 16d6a2e..88a1c3d 100644 --- a/configure.ac +++ b/configure.ac @@ -82,7 +82,7 @@ if test "x$GCC" = "xyes"; then fi AC_SUBST(ASSEMBLER_WARN_CFLAGS) -PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.52 libdrm]) +PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.60 libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) PKG_CHECK_MODULES(OVERLAY_XVLIB, [xv x11 xext dri2proto >= 2.6], enable_overlay_xvlib=yes, enable_overlay_xvlib=no) PKG_CHECK_MODULES(OVERLAY_XLIB, [cairo-xlib dri2proto >= 2.6], enable_overlay_xlib=yes, enable_overlay_xlib=no) -- 2.3.0
[PATCH 2/2 v2] Query the driver directly for compute units and subslice
From: Jeff McGee
Values of device max compute units and max subslice obtained
directly from the driver should be more accurate than our own
ID-based lookup values. This is particularly important when a
single device ID may encompass more than one configuration. If
the driver cannot provide a valid value for the given device,
we fallback on the ID-based lookup value.
This query requires libdrm 2.4.60. For now we will consider
the use of this query to be optional and exclude it from
compilation when building against older libdrm. Later we may
want to consider requiring the query or at least warning
more strongly when it is not supported.
v2: Make feature use conditional on libdrm version (Zhigang).
Signed-off-by: Jeff McGee
---
CMakeLists.txt | 9 +
src/CMakeLists.txt | 10 ++
src/intel/intel_driver.c | 25 +
3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65f2c70..bb03566 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,6 +131,15 @@ IF(DRM_INTEL_FOUND)
ELSE(DRM_INTEL_VERSION VERSION_GREATER 2.4.57)
MESSAGE(STATUS "Disable userptr support")
ENDIF(DRM_INTEL_VERSION VERSION_GREATER 2.4.57)
+ IF(DRM_INTEL_VERSION VERSION_GREATER 2.4.59)
+MESSAGE(STATUS "Enable EU total query support")
+SET(DRM_INTEL_EU_TOTAL "enable")
+MESSAGE(STATUS "Enable subslice total query support")
+SET(DRM_INTEL_SUBSLICE_TOTAL "enable")
+ ELSE(DRM_INTEL_VERSION VERSION_GREATER 2.4.59)
+MESSAGE(STATUS "Disable EU total query support")
+MESSAGE(STATUS "Disable subslice total query support")
+ ENDIF(DRM_INTEL_VERSION VERSION_GREATER 2.4.59)
ELSE(DRM_INTEL_FOUND)
MESSAGE(FATAL_ERROR "Looking for DRM Intel (>= 2.4.52) - not found")
ENDIF(DRM_INTEL_FOUND)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d4181d8..464765f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -118,6 +118,16 @@ SET(CMAKE_CXX_FLAGS "-DHAS_USERPTR ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_USERPTR ${CMAKE_C_FLAGS}")
endif (DRM_INTEL_USERPTR)
+if (DRM_INTEL_EU_TOTAL)
+SET(CMAKE_CXX_FLAGS "-DHAS_EU_TOTAL ${CMAKE_CXX_FLAGS}")
+SET(CMAKE_C_FLAGS "-DHAS_EU_TOTAL ${CMAKE_C_FLAGS}")
+endif (DRM_INTEL_EU_TOTAL)
+
+if (DRM_INTEL_SUBSLICE_TOTAL)
+SET(CMAKE_CXX_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_CXX_FLAGS}")
+SET(CMAKE_C_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_C_FLAGS}")
+endif (DRM_INTEL_SUBSLICE_TOTAL)
+
set(GIT_SHA1 "git_sha1.h")
add_custom_target(${GIT_SHA1} ALL
COMMAND chmod +x ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.sh
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index d61988c..755ab6b 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -757,10 +757,7 @@ static int intel_buffer_set_tiling(cl_buffer bo,
static void
intel_update_device_info(cl_device_id device)
{
-#ifdef HAS_USERPTR
intel_driver_t *driver;
- const size_t sz = 4096;
- void *host_ptr;
driver = intel_driver_new();
assert(driver != NULL);
@@ -769,6 +766,10 @@ intel_update_device_info(cl_device_id device)
return;
}
+#ifdef HAS_USERPTR
+ const size_t sz = 4096;
+ void *host_ptr;
+
host_ptr = cl_aligned_malloc(sz, 4096);
if (host_ptr != NULL) {
cl_buffer bo = intel_buffer_alloc_userptr((cl_buffer_mgr)driver->bufmgr,
@@ -781,12 +782,28 @@ intel_update_device_info(cl_device_id device)
}
else
device->host_unified_memory = CL_FALSE;
+#endif
+
+#ifdef HAS_EU_TOTAL
+ unsigned int eu_total;
+
+ /* Prefer driver-queried max compute units if supported */
+ if (!drm_intel_get_eu_total(driver->fd, &eu_total))
+device->max_compute_unit = eu_total;
+#endif
+
+#ifdef HAS_SUBSLICE_TOTAL
+ unsigned int subslice_total;
+
+ /* Prefer driver-queried subslice count if supported */
+ if (!drm_intel_get_subslice_total(driver->fd, &subslice_total))
+device->sub_slice_count = subslice_total;
+#endif
intel_driver_context_destroy(driver);
intel_driver_close(driver);
intel_driver_terminate(driver);
intel_driver_delete(driver);
-#endif
}
LOCAL void
--
2.3.0
[PATCH i-g-t 2/2] configure: Bump required libdrm version to 2.4.60
From: Jeff McGee tests/core_getparams needs the new libdrm interfaces for querying subslice and EU counts. For: VIZ-4636 Signed-off-by: Jeff McGee --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 16d6a2e..88a1c3d 100644 --- a/configure.ac +++ b/configure.ac @@ -82,7 +82,7 @@ if test "x$GCC" = "xyes"; then fi AC_SUBST(ASSEMBLER_WARN_CFLAGS) -PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.52 libdrm]) +PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.60 libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) PKG_CHECK_MODULES(OVERLAY_XVLIB, [xv x11 xext dri2proto >= 2.6], enable_overlay_xvlib=yes, enable_overlay_xvlib=no) PKG_CHECK_MODULES(OVERLAY_XLIB, [cairo-xlib dri2proto >= 2.6], enable_overlay_xlib=yes, enable_overlay_xlib=no) -- 2.3.0
[PATCH i-g-t v2] tests/core_getparams: Create new test core_getparams
From: Jeff McGee
New test core_getparams consists of 2 subtests, each one testing
the ability of userspace to query the correct value of a GT config
attribute: subslice total or EU total. drm/i915 implementation of
these queries is required for Cherryview and Gen9+ devices (non-
simulated).
v2: Duplicate small amount of new libdrm functionality to avoid
bumping libdrm version requirement (Daniel). Convert some
igt_asserts to the appropriate comparison variants. Add a
test description.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_getparams.c | 167 +
3 files changed, 169 insertions(+)
create mode 100644 tests/core_getparams.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 426cc67..c742308 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,7 @@
# Please keep sorted alphabetically
core_get_client_auth
core_getclient
+core_getparams
core_getstats
core_getversion
drm_import_export
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 51e8376..999c8f8 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -15,6 +15,7 @@ NOUVEAU_TESTS_M = \
TESTS_progs_M = \
core_get_client_auth \
+ core_getparams \
drv_suspend \
drv_hangman \
gem_bad_reloc \
diff --git a/tests/core_getparams.c b/tests/core_getparams.c
new file mode 100644
index 000..2855d06
--- /dev/null
+++ b/tests/core_getparams.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Jeff McGee
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include "drmtest.h"
+#include "intel_chipset.h"
+#include "intel_bufmgr.h"
+
+IGT_TEST_DESCRIPTION("Tests the export of parameters via
DRM_IOCTL_I915_GETPARAM\n");
+
+int drm_fd;
+int devid;
+
+static void
+init(void)
+{
+ drm_fd = drm_open_any();
+ devid = intel_get_drm_devid(drm_fd);
+}
+
+static void
+deinit(void)
+{
+ close(drm_fd);
+}
+
+#define LOCAL_I915_PARAM_SUBSLICE_TOTAL33
+#define LOCAL_I915_PARAM_EU_TOTAL 34
+
+static int
+getparam(int param, int *value)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.value = value;
+ gp.param = param;
+ ret = drmIoctl(drm_fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+static void
+subslice_total(void)
+{
+ unsigned int subslice_total = 0;
+ int ret;
+
+ ret = getparam(I915_PARAM_SUBSLICE_TOTAL, (int*)&subslice_total);
+
+ if (ret) {
+ /*
+* These devices are not required to implement the
+* interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert_eq(ret, -ENODEV);
+ igt_info("subslice total: unknown\n");
+ /*
+* All other devices must implement the interface, so
+* fail them if we are here.
+ */
+ } else {
+ igt_assert_neq(ret, EINVAL); /* request not recognized?
*/
+ igt_assert_neq(ret, ENODEV); /* device not supported? */
+ igt_assert_eq(ret, 0); /* other error? */
+ }
+ } else {
+ /*
+* On success, just make sure the returned count value is
+* non-zero. The validity of the count value for the given
+* device is not checked.
+ */
+ igt_assert_neq(subslice_total, 0);
+ igt_info("subslice total: %u\n", su
[PATCH i-g-t v3] tests/core_getparams: Create new test core_getparams
From: Jeff McGee
New test core_getparams consists of 2 subtests, each one testing
the ability of userspace to query the correct value of a GT config
attribute: subslice total or EU total. drm/i915 implementation of
these queries is required for Cherryview and Gen9+ devices (non-
simulated).
v2: Duplicate small amount of new libdrm functionality to avoid
bumping libdrm version requirement (Daniel). Convert some
igt_asserts to the appropriate comparison variants. Add a
test description.
v3: Actually use the LOCAL GETPARAM defines. Otherwise can't build
against older libdrm as intended by v2.
For: VIZ-4636
Signed-off-by: Jeff McGee
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_getparams.c | 167 +
3 files changed, 169 insertions(+)
create mode 100644 tests/core_getparams.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 426cc67..c742308 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,7 @@
# Please keep sorted alphabetically
core_get_client_auth
core_getclient
+core_getparams
core_getstats
core_getversion
drm_import_export
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 51e8376..999c8f8 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -15,6 +15,7 @@ NOUVEAU_TESTS_M = \
TESTS_progs_M = \
core_get_client_auth \
+ core_getparams \
drv_suspend \
drv_hangman \
gem_bad_reloc \
diff --git a/tests/core_getparams.c b/tests/core_getparams.c
new file mode 100644
index 000..2855d06
--- /dev/null
+++ b/tests/core_getparams.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Jeff McGee
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include "drmtest.h"
+#include "intel_chipset.h"
+#include "intel_bufmgr.h"
+
+IGT_TEST_DESCRIPTION("Tests the export of parameters via
DRM_IOCTL_I915_GETPARAM\n");
+
+int drm_fd;
+int devid;
+
+static void
+init(void)
+{
+ drm_fd = drm_open_any();
+ devid = intel_get_drm_devid(drm_fd);
+}
+
+static void
+deinit(void)
+{
+ close(drm_fd);
+}
+
+#define LOCAL_I915_PARAM_SUBSLICE_TOTAL33
+#define LOCAL_I915_PARAM_EU_TOTAL 34
+
+static int
+getparam(int param, int *value)
+{
+ drm_i915_getparam_t gp;
+ int ret;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.value = value;
+ gp.param = param;
+ ret = drmIoctl(drm_fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ if (ret)
+ return -errno;
+
+ return 0;
+}
+
+static void
+subslice_total(void)
+{
+ unsigned int subslice_total = 0;
+ int ret;
+
+ ret = getparam(LOCAL_I915_PARAM_SUBSLICE_TOTAL, (int*)&subslice_total);
+
+ if (ret) {
+ /*
+* These devices are not required to implement the
+* interface. If they do not, -ENODEV must be returned.
+ */
+ if ((intel_gen(devid) < 8) ||
+ IS_BROADWELL(devid) ||
+ igt_run_in_simulation()) {
+ igt_assert_eq(ret, -ENODEV);
+ igt_info("subslice total: unknown\n");
+ /*
+* All other devices must implement the interface, so
+* fail them if we are here.
+ */
+ } else {
+ igt_assert_neq(ret, EINVAL); /* request not recognized?
*/
+ igt_assert_neq(ret, ENODEV); /* device not supported? */
+ igt_assert_eq(ret, 0); /* other error? */
+ }
+ } else {
+ /*
+* On success, just make sure the returned count value is
+* non-zero. The validity of the count value for the given
+* device is not checked.
+
