[PATCH] intel_get_llc_size: Small tool to query LLC size

Ben Widawsky
2013-07-10T02:54:53Z

CC: Chad Versace <chad.versace@linux.intel.com>
CC: Bryan Bell <bryan.j.bell@intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
tools/Makefile.am | 1 +
tools/intel_get_llc_size.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
create mode 100644 tools/intel_get_llc_size.c

diff --git a/tools/Makefile.am b/tools/Makefile.am
index 2519169..a064b65 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -9,6 +9,7 @@ bin_PROGRAMS = \
intel_bios_dumper \
intel_bios_reader \
intel_error_decode \
+ intel_get_llc_size \
intel_gpu_top \
intel_gpu_time \
intel_gtt \
diff --git a/tools/intel_get_llc_size.c b/tools/intel_get_llc_size.c
new file mode 100644
index 0000000..bd384d2
--- /dev/null
+++ b/tools/intel_get_llc_size.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2013 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.
+ *
+ */
+
+#include <sys/ioctl.h>
+#include "drmtest.h"
+#include "i915_drm.h"
+
+static int get_llc_size(int fd)
+{
+ struct drm_i915_getparam gp;
+ int size;
+
+ gp.param = I915_PARAM_HAS_LLC;
+ gp.value = &size;
+
+ if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+ return 0;
+
+ return size;
+}
+
+int main(int argc, char **argv)
+{
+ int size, fd = drm_open_any();
+
+ size = get_llc_size(fd);
+
+ if (size == 0)
+ fprintf(stdout, "Doesn't have LLC\n");
+ else if (size == 1)
+ fprintf(stdout, "Kernel is too old to determine LLC size\n");
+ else
+ fprintf(stdout, "LLC size = %dK\n", size>>10);
+
+ return 0;
+}
--
1.8.3.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org