Skip to contentSkip to conversation

drm/i915: Expose LLC size to user space

PATCH Superseded Ben Widawsky 5 participants 24 messages Jul 10, 2013 – Jul 12, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Expose LLC size to user space

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

The excellent comments remain entirely copied from Chad's code.

I've tested this on two platforms, and it seems to perform how I want.

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c |  2 +-
 drivers/gpu/drm/i915/i915_drv.h |  2 ++
 drivers/gpu/drm/i915/i915_gem.c | 53 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index 0e22142..377949e 100644
@@ -974,7 +974,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
 		value = 1;
 		break;
 	case I915_PARAM_HAS_LLC:
-		value = HAS_LLC(dev);
+		value = dev_priv->llc_size;
 		break;
 	case I915_PARAM_HAS_ALIASING_PPGTT:
 		value = dev_priv->mm.aliasing_ppgtt ? 1 : 0;
drivers/gpu/drm/i915/i915_drv.h +2 -0
index c8d6104..43a549d 100644
@@ -1187,6 +1187,8 @@ typedef struct drm_i915_private {
 	/* Old dri1 support infrastructure, beware the dragons ya fools entering
 	 * here! */
 	struct i915_dri1_state dri1;
+
+	size_t llc_size;
 } drm_i915_private_t;
 
 /* Iterate over initialised rings */
drivers/gpu/drm/i915/i915_gem.c +53 -0

65 lines not on this page · raw message

Signature · 6 lines
1.8.3.2

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

PATCH 1/1 intel_get_llc_size: Small tool to query LLC size

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 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
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +57 -0

57 lines not on this page · raw message

Signature · 6 lines
1.8.3.2

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

Re: [PATCH] intel_get_llc_size: Small tool to query LLC size

Quoted 3 lines · Ben Widawsky
CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>

So I think we should run this from igt and check its return value. And since we've had a few bugs with other (currently untested) igt tools, can you please add a new igt_tools testcase which just runs those? I'm thinking of intel_reg_dumper and intel_reg_read (with some render ring register that exists everywhere) on top of running intel_get_llc_size here.

And please also add eLLC size querying.
-Daniel

Quoted 88 lines
---
 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
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +57 -0
new file mode 100644
index 0000000..bd384d2
@@ -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;
+}
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw

Re: [PATCH] intel_get_llc_size: Small tool to query LLC size

Quoted 11 lines · Daniel Vetter
Quoted 3 lines · Ben Widawsky
CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>

So I think we should run this from igt and check its return value. And since we've had a few bugs with other (currently untested) igt tools, can you please add a new igt_tools testcase which just runs those? I'm thinking of intel_reg_dumper and intel_reg_read (with some render ring register that exists everywhere) on top of running intel_get_llc_size here.

What would you like exactly for the check? Just to make sure platforms that should have LLC return a value > 1?

As for testing the other tools, I personally want no involvement with intel_reg_dumper, since I feel maintaining it is a losing effort and would rather see effort put into quick_dump. I'll write tests for reg_read/reg_write though.

Quoted 1 line

And please also add eLLC size querying.

When I see review and signs of those getting merged, I'll gladly do that. For simple, potentially very useful patches, they're sitting around doing nothing for an awfully long time. And, I can no longer easily test them. So poop.

Quoted 95 lines

-Daniel

Quoted 88 lines
---
 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
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +57 -0
new file mode 100644
index 0000000..bd384d2
@@ -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;
+}
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH] intel_get_llc_size: Small tool to query LLC size

Quoted 13 lines · Ben Widawsky
Quoted 11 lines · Daniel Vetter
Quoted 3 lines · Ben Widawsky
CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>

So I think we should run this from igt and check its return value. And since we've had a few bugs with other (currently untested) igt tools, can you please add a new igt_tools testcase which just runs those? I'm thinking of intel_reg_dumper and intel_reg_read (with some render ring register that exists everywhere) on top of running intel_get_llc_size here.

Quoted 2 lines

What would you like exactly for the check? Just to make sure platforms that should have LLC return a value > 1?

Just check that it runs without an non-zero exit code.

Quoted 4 lines

As for testing the other tools, I personally want no involvement with intel_reg_dumper, since I feel maintaining it is a losing effort and would rather see effort put into quick_dump. I'll write tests for reg_read/reg_write though.

Again just checking whether the stuff runs without non-zero exit code. I guess the same holds for quick_dump. As long as we still use reg_dumper for debugging regressions I'd would be imo really good to have a little bit of assurance that it's not completely broken.

Cheers, Daniel

Quoted 105 lines
Quoted 1 line

And please also add eLLC size querying.

When I see review and signs of those getting merged, I'll gladly do that. For simple, potentially very useful patches, they're sitting around doing nothing for an awfully long time. And, I can no longer easily test them. So poop.

Quoted 95 lines

-Daniel

Quoted 88 lines
---
 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
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +57 -0
new file mode 100644
index 0000000..bd384d2
@@ -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;
+}
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw

Re: [PATCH] intel_get_llc_size: Small tool to query LLC size

Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Ben Widawsky
Quoted 11 lines · Daniel Vetter
Quoted 3 lines · Ben Widawsky
CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>

So I think we should run this from igt and check its return value. And since we've had a few bugs with other (currently untested) igt tools, can you please add a new igt_tools testcase which just runs those? I'm thinking of intel_reg_dumper and intel_reg_read (with some render ring register that exists everywhere) on top of running intel_get_llc_size here.

Quoted 4 lines
Quoted 2 lines

What would you like exactly for the check? Just to make sure platforms that should have LLC return a value > 1?

Just check that it runs without an non-zero exit code.

That doesn't really check the interface works as advertised though. Same for the below.

Quoted 6 lines
Quoted 5 lines

As for testing the other tools, I personally want no involvement with intel_reg_dumper, since I feel maintaining it is a losing effort and would rather see effort put into quick_dump. I'll write tests for reg_read/reg_write though.

Quoted 6 lines

Again just checking whether the stuff runs without non-zero exit code. I guess the same holds for quick_dump. As long as we still use reg_dumper for debugging regressions I'd would be imo really good to have a little bit of assurance that it's not completely broken.

Cheers, Daniel

That's fine... just asking you to volunteer someone else who actually uses that tool for it. I never use reg_dumper, and don't ask others to use it.

Quoted 111 lines
Quoted 106 lines
Quoted 2 lines

And please also add eLLC size querying.

When I see review and signs of those getting merged, I'll gladly do that. For simple, potentially very useful patches, they're sitting around doing nothing for an awfully long time. And, I can no longer easily test them. So poop.

Quoted 95 lines

-Daniel

Quoted 88 lines
---
 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
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +57 -0
new file mode 100644
index 0000000..bd384d2
@@ -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;
+}
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH] intel_get_llc_size: Small tool to query LLC size

Quoted 15 lines · Ben Widawsky
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Ben Widawsky
Quoted 11 lines · Daniel Vetter
Quoted 3 lines · Ben Widawsky
CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>

So I think we should run this from igt and check its return value. And since we've had a few bugs with other (currently untested) igt tools, can you please add a new igt_tools testcase which just runs those? I'm thinking of intel_reg_dumper and intel_reg_read (with some render ring register that exists everywhere) on top of running intel_get_llc_size here.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

What would you like exactly for the check? Just to make sure platforms that should have LLC return a value > 1?

Just check that it runs without an non-zero exit code.

That doesn't really check the interface works as advertised though. Same for the below.

It checks more than nothing and at least in the case of reg IO breakage in the past that was good enough to catch things.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#7 lore raw
In reply to Ben Widawsky
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#8 lore raw
Quoted 12 lines · Chris Wilson
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Chad wrote this originally for mesa. And yes, it's doable from userspace. Chatting with Daniel, we thought maybe other GPU clients might want this info, and so a central place to put the code would be nice, in case there are quirks or anything like that (I've had a particularly hard time figuring out if Xeon really has L3 or not).

So what's a central place? Libdrm, everybody uses that right? You can read /proc/cpuinfo as far as I know, but then you still need to query the HAS_LLC getparam to figure out what kind of L3 (or do your own chipset ID check).

In addition to the centrality argument, I noticed while poking around cpuid in the kernel that it is a vitalized function. I'm not sure what the purpose of this is, but it's something you can't fake in userspace.

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#9 lore raw
Quoted 20 lines · Ben Widawsky
Quoted 12 lines · Chris Wilson
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Chad wrote this originally for mesa. And yes, it's doable from userspace. Chatting with Daniel, we thought maybe other GPU clients might want this info, and so a central place to put the code would be nice, in case there are quirks or anything like that (I've had a particularly hard time figuring out if Xeon really has L3 or not).

Quoted 7 lines

So what's a central place? Libdrm, everybody uses that right? You can read /proc/cpuinfo as far as I know, but then you still need to query the HAS_LLC getparam to figure out what kind of L3 (or do your own chipset ID check).

In addition to the centrality argument, I noticed while poking around cpuid in the kernel that it is a vitalized function. I'm not sure what

That's the last time I let vim tell me I spelled "virtualized" wrong:

cpuid in the kernel that it is a virtualized function

Quoted 10 lines

the purpose of this is, but it's something you can't fake in userspace.

Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#10 lore raw
In reply to Ben Widawsky
Quoted 20 lines · Ben Widawsky
Quoted 12 lines · Chris Wilson
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Chad wrote this originally for mesa. And yes, it's doable from userspace. Chatting with Daniel, we thought maybe other GPU clients might want this info, and so a central place to put the code would be nice, in case there are quirks or anything like that (I've had a particularly hard time figuring out if Xeon really has L3 or not).

Quoted 8 lines

So what's a central place? Libdrm, everybody uses that right? You can read /proc/cpuinfo as far as I know, but then you still need to query the HAS_LLC getparam to figure out what kind of L3 (or do your own chipset ID check).

In addition to the centrality argument, I noticed while poking around cpuid in the kernel that it is a vitalized function. I'm not sure what the purpose of this is, but it's something you can't fake in userspace.

In fact, isn't this functionality already part of arch/x86, and isn't the value already exposed via /proc/cpuinfo?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#11 lore raw
Quoted 26 lines · Chris Wilson
Quoted 25 lines · Ben Widawsky
Quoted 12 lines · Chris Wilson
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Chad wrote this originally for mesa. And yes, it's doable from userspace. Chatting with Daniel, we thought maybe other GPU clients might want this info, and so a central place to put the code would be nice, in case there are quirks or anything like that (I've had a particularly hard time figuring out if Xeon really has L3 or not).

So what's a central place? Libdrm, everybody uses that right? You can read /proc/cpuinfo as far as I know, but then you still need to query the HAS_LLC getparam to figure out what kind of L3 (or do your own chipset ID check).

Quoted 11 lines
Quoted 3 lines

In addition to the centrality argument, I noticed while poking around cpuid in the kernel that it is a vitalized function. I'm not sure what the purpose of this is, but it's something you can't fake in userspace.

In fact, isn't this functionality already part of arch/x86, and isn't the value already exposed via /proc/cpuinfo?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Yes to the /proc/cpuinfo bit (I said that). If the implication is just to use that code, I did a quick search and couldn't find it. I can go back and check again. Assuming it's externally exposed to drivers, I would rather use that.

We still need the HAS_LLC check to differentiate the L3 though.

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#12 lore raw
Quoted 38 lines · Ben Widawsky
Quoted 26 lines · Chris Wilson
Quoted 25 lines · Ben Widawsky
Quoted 12 lines · Chris Wilson
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Chad wrote this originally for mesa. And yes, it's doable from userspace. Chatting with Daniel, we thought maybe other GPU clients might want this info, and so a central place to put the code would be nice, in case there are quirks or anything like that (I've had a particularly hard time figuring out if Xeon really has L3 or not).

So what's a central place? Libdrm, everybody uses that right? You can read /proc/cpuinfo as far as I know, but then you still need to query the HAS_LLC getparam to figure out what kind of L3 (or do your own chipset ID check).

Quoted 11 lines
Quoted 3 lines

In addition to the centrality argument, I noticed while poking around cpuid in the kernel that it is a vitalized function. I'm not sure what the purpose of this is, but it's something you can't fake in userspace.

In fact, isn't this functionality already part of arch/x86, and isn't the value already exposed via /proc/cpuinfo?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 6 lines

Yes to the /proc/cpuinfo bit (I said that). If the implication is just to use that code, I did a quick search and couldn't find it. I can go back and check again. Assuming it's externally exposed to drivers, I would rather use that.

We still need the HAS_LLC check to differentiate the L3 though.

You have to be careful about repurposing PARAM_HAS_LLC though. At the moment it has a dual meaning that the kernel/gpu supports LLC and that we default to placing objects in LLC.

If you must expose cache_size through a param, make it a new one and make it explicit. I would also rather just use a param than parse /proc/cpuinfo (especially as some paranoid setups prevent access to /proc/cpuinfo).

But we really should not be calling cpuid from our driver, that just looks very very ugly, and given cpuid's history will be a maintenance burden.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#13 lore raw
Quoted 46 lines · Chris Wilson
Quoted 38 lines · Ben Widawsky
Quoted 26 lines · Chris Wilson
Quoted 25 lines · Ben Widawsky
Quoted 12 lines · Chris Wilson
Quoted 4 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Just a cpuid query that can already be done more simply from userspace (i.e. with no syscalls)? I was expecting a lot more magic. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

Chad wrote this originally for mesa. And yes, it's doable from userspace. Chatting with Daniel, we thought maybe other GPU clients might want this info, and so a central place to put the code would be nice, in case there are quirks or anything like that (I've had a particularly hard time figuring out if Xeon really has L3 or not).

So what's a central place? Libdrm, everybody uses that right? You can read /proc/cpuinfo as far as I know, but then you still need to query the HAS_LLC getparam to figure out what kind of L3 (or do your own chipset ID check).

Quoted 11 lines
Quoted 3 lines

In addition to the centrality argument, I noticed while poking around cpuid in the kernel that it is a vitalized function. I'm not sure what the purpose of this is, but it's something you can't fake in userspace.

In fact, isn't this functionality already part of arch/x86, and isn't the value already exposed via /proc/cpuinfo?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 6 lines

Yes to the /proc/cpuinfo bit (I said that). If the implication is just to use that code, I did a quick search and couldn't find it. I can go back and check again. Assuming it's externally exposed to drivers, I would rather use that.

We still need the HAS_LLC check to differentiate the L3 though.

Quoted 8 lines

You have to be careful about repurposing PARAM_HAS_LLC though. At the moment it has a dual meaning that the kernel/gpu supports LLC and that we default to placing objects in LLC.

If you must expose cache_size through a param, make it a new one and make it explicit. I would also rather just use a param than parse /proc/cpuinfo (especially as some paranoid setups prevent access to /proc/cpuinfo).

I did a search, and I think my change is backward compatible, but if you want a new param, I don't care.

Quoted 5 lines

But we really should not be calling cpuid from our driver, that just looks very very ugly, and given cpuid's history will be a maintenance burden.
-Chris

Okay, let me try again to find where it is parsed by the arch/x86 code.

Quoted 3 lines
Signature · 2 lines
-- 
Chris Wilson, Intel Open Source Technology Centre
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#14 lore raw
In reply to Ben Widawsky

Looks good,
Can you update the comment? The pdf "Intel Processor Identification and the CPUID Instruction" is no longer available and the description of the CPUID instruction is now in the "Intel 64 and IA32
Architectures Developer's Manual: Vol. 2A -> section 3.2 -> CPUID"

-----Original Message-----
From: Ben Widawsky [mailto:[email protected]]
Sent: Tuesday, July 09, 2013 7:58 PM
To: Intel GFX
Cc: Ben Widawsky; Chad Versace; Bell, Bryan J
Subject: [PATCH] drm/i915: Expose LLC size to user space

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

The excellent comments remain entirely copied from Chad's code.

I've tested this on two platforms, and it seems to perform how I want.

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c |  2 +-  drivers/gpu/drm/i915/i915_drv.h |  2 ++  drivers/gpu/drm/i915/i915_gem.c | 53 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
@@ -974,7 +974,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
 		value = 1;
 		break;
 	case I915_PARAM_HAS_LLC:
-		value = HAS_LLC(dev);
+		value = dev_priv->llc_size;
 		break;
 	case I915_PARAM_HAS_ALIASING_PPGTT:
 		value = dev_priv->mm.aliasing_ppgtt ? 1 : 0; diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c8d6104..43a549d 100644
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -1187,6 +1187,8 @@ typedef struct drm_i915_private {
 	/* Old dri1 support infrastructure, beware the dragons ya fools entering
 	 * here! */
 	struct i915_dri1_state dri1;
+
+	size_t llc_size;
 } drm_i915_private_t;
 
 /* Iterate over initialised rings */
drivers/gpu/drm/i915/i915_gem.c +52 -0

57 lines not on this page · raw message

dev_priv->num_fence_regs = 8;

+ dev_priv->llc_size = get_llc_size(dev);
+
/* Initialize fence registers to zero */
INIT_LIST_HEAD(&dev_priv->mm.fence_list);
i915_gem_restore_fences(dev);
--
1.8.3.2

#15 lore raw
In reply to Ben Widawsky
Quoted 23 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

The excellent comments remain entirely copied from Chad's code.

I've tested this on two platforms, and it seems to perform how I want.

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
  drivers/gpu/drm/i915/i915_dma.c |  2 +-
  drivers/gpu/drm/i915/i915_drv.h |  2 ++
  drivers/gpu/drm/i915/i915_gem.c | 53 +++++++++++++++++++++++++++++++++++++++++
  3 files changed, 56 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index 0e22142..377949e 100644

drivers/gpu/drm/i915/i915_dma.c static int i915_getparam(struct drm_device *dev, void *data, · line 980

Quoted 8 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
@@ -974,7 +974,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
  		value = 1;
  		break;
  	case I915_PARAM_HAS_LLC:
-		value = HAS_LLC(dev);
+		value = dev_priv->llc_size;
  		break;
  	case I915_PARAM_HAS_ALIASING_PPGTT:
  		value = dev_priv->mm.aliasing_ppgtt ? 1 : 0;

I would like to see a dedicated param for the llc size. 'has' is always boolean valued, right?

Quoted 60 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
index c8d6104..43a549d 100644
@@ -1187,6 +1187,8 @@ typedef struct drm_i915_private {
  	/* Old dri1 support infrastructure, beware the dragons ya fools entering
  	 * here! */
  	struct i915_dri1_state dri1;
+
+	size_t llc_size;
  } drm_i915_private_t;
 
  /* Iterate over initialised rings */
drivers/gpu/drm/i915/i915_gem.c +39 -0
index af61be8..a070686 100644
@@ -4282,6 +4282,57 @@ i915_gem_lastclose(struct drm_device *dev)
  		DRM_ERROR("failed to idle hardware: %d\n", ret);
  }
 
+/**
+ * Return the size, in bytes, of the CPU L3 cache size. If the CPU has no L3
+ * cache, or if an error occurs in obtaining the cache size, then return 0.
+ * From "Intel Processor Identification and the CPUID Instruction > 5.15
+ * Deterministic Cache Parmaeters (Function 04h)":
+ *    When EAX is initialized to a value of 4, the CPUID instruction returns
+ *    deterministic cache information in the EAX, EBX, ECX and EDX registers.
+ *    This function requires ECX be initialized with an index which indicates
+ *    which cache to return information about. The OS is expected to call this
+ *    function (CPUID.4) with ECX = 0, 1, 2, until EAX[4:0] == 0, indicating no
+ *    more caches. The order in which the caches are returned is not specified
+ *    and may change at Intel's discretion.
+ *
+ * Equation 5-4. Calculating the Cache Size in bytes:
+ *          = (Ways +1) � (Partitions +1) � (Line Size +1) � (Sets +1)
+ *          = (EBX[31:22] +1) � (EBX[21:12] +1) � (EBX[11:0] +1 � (ECX + 1)
+ */
+static size_t get_llc_size(struct drm_device *dev)
+{
+	u8 cnt = 0;
+	unsigned int eax, ebx, ecx, edx;
+
+	if (!HAS_LLC(dev))
+		return 0;
+
+	do {
+		uint32_t cache_level;
+		uint32_t associativity, line_partitions, line_size, sets;
+
+		eax = 4;
+		ecx = cnt;
+		__cpuid(&eax, &ebx, &ecx, &edx);
+
+		cache_level = (eax >> 5) & 0x7;
+		if (cache_level != 3)
+			continue;
+
+		associativity = ((ebx >> 22) & 0x3ff) + 1;
+		line_partitions = ((ebx >> 12) & 0x3ff) + 1;

drivers/gpu/drm/i915/i915_gem.c i915_gem_lastclose(struct drm_device *dev) · line 4333

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +10 -0
+		line_size = (ebx & 0xfff) + 1;
+		sets = ecx + 1;
+
+		return associativity * line_partitions * line_size * sets;
+	} while (eax & 0x1f && ++cnt);
+
+	/* Let user space know we have LLC, but we can't figure it out */
+	DRM_DEBUG_DRIVER("Couldn't find LLC size. Bug?\n");
+	return 1;
+}

This function looks good to me, since I wrote most of it ;)

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

#16 lore raw
Quoted 19 lines · Chad Versace
Quoted 18 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

The excellent comments remain entirely copied from Chad's code.

I've tested this on two platforms, and it seems to perform how I want.

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c |  2 +-
 drivers/gpu/drm/i915/i915_drv.h |  2 ++
 drivers/gpu/drm/i915/i915_gem.c | 53 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
Quoted 16 lines

drivers/gpu/drm/i915/i915_dma.c static int i915_getparam(struct drm_device *dev, void *data, · line 980

Quoted 13 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
index 0e22142..377949e 100644
@@ -974,7 +974,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
 		value = 1;
 		break;
 	case I915_PARAM_HAS_LLC:
-		value = HAS_LLC(dev);
+		value = dev_priv->llc_size;
 		break;
 	case I915_PARAM_HAS_ALIASING_PPGTT:
 		value = dev_priv->mm.aliasing_ppgtt ? 1 : 0;

I would like to see a dedicated param for the llc size. 'has' is always boolean valued, right?

Sounds like Chris wants the same anyway, but no. Getparam is always an int. Just the name is, 'has'

Quoted 65 lines
Quoted 65 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
index c8d6104..43a549d 100644
@@ -1187,6 +1187,8 @@ typedef struct drm_i915_private {
 	/* Old dri1 support infrastructure, beware the dragons ya fools entering
 	 * here! */
 	struct i915_dri1_state dri1;
+
+	size_t llc_size;
 } drm_i915_private_t;
 
 /* Iterate over initialised rings */
drivers/gpu/drm/i915/i915_gem.c +43 -0
index af61be8..a070686 100644
@@ -4282,6 +4282,57 @@ i915_gem_lastclose(struct drm_device *dev)
 		DRM_ERROR("failed to idle hardware: %d\n", ret);
 }
 
+/**
+ * Return the size, in bytes, of the CPU L3 cache size. If the CPU has no L3
+ * cache, or if an error occurs in obtaining the cache size, then return 0.
+ * From "Intel Processor Identification and the CPUID Instruction > 5.15
+ * Deterministic Cache Parmaeters (Function 04h)":
+ *    When EAX is initialized to a value of 4, the CPUID instruction returns
+ *    deterministic cache information in the EAX, EBX, ECX and EDX registers.
+ *    This function requires ECX be initialized with an index which indicates
+ *    which cache to return information about. The OS is expected to call this
+ *    function (CPUID.4) with ECX = 0, 1, 2, until EAX[4:0] == 0, indicating no
+ *    more caches. The order in which the caches are returned is not specified
+ *    and may change at Intel's discretion.
+ *
+ * Equation 5-4. Calculating the Cache Size in bytes:
+ *          = (Ways +1) � (Partitions +1) � (Line Size +1) � (Sets +1)
+ *          = (EBX[31:22] +1) � (EBX[21:12] +1) � (EBX[11:0] +1 � (ECX + 1)
+ */
+static size_t get_llc_size(struct drm_device *dev)
+{
+	u8 cnt = 0;
+	unsigned int eax, ebx, ecx, edx;
+
+	if (!HAS_LLC(dev))
+		return 0;
+
+	do {
+		uint32_t cache_level;
+		uint32_t associativity, line_partitions, line_size, sets;
+
+		eax = 4;
+		ecx = cnt;
+		__cpuid(&eax, &ebx, &ecx, &edx);
+
+		cache_level = (eax >> 5) & 0x7;
+		if (cache_level != 3)
+			continue;
+
+		associativity = ((ebx >> 22) & 0x3ff) + 1;
+		line_partitions = ((ebx >> 12) & 0x3ff) + 1;
+		line_size = (ebx & 0xfff) + 1;
+		sets = ecx + 1;
+
+		return associativity * line_partitions * line_size * sets;
Quoted 9 lines

drivers/gpu/drm/i915/i915_gem.c i915_gem_lastclose(struct drm_device *dev) · line 4333

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +6 -0
+	} while (eax & 0x1f && ++cnt);
+
+	/* Let user space know we have LLC, but we can't figure it out */
+	DRM_DEBUG_DRIVER("Couldn't find LLC size. Bug?\n");
+	return 1;
+}

This function looks good to me, since I wrote most of it ;)

Still arguing over whether or not to try to pull it from the x86 core. I tried to get some comment from hpa today , but haven't heard anything yet.

I do agree if we can just take the code from the x86 core it would be best, but AFAICT I'd need to change some code, or do an almost equal amount of logic to determine l2 vs. l3. Thinking about it now though, I suppose I can assume if HAS_LLC, then whatever cache size was obtained during boot is l3... dunno.

Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

PATCH v2 1/1 drm/i915: Expose LLC size to user space

In reply to Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

I've tested this on two platforms, and it seems to perform how I want.

With this patch is a small tool for igt to query the size. This can be used as a reference for DRI clients wishing to query the information.

v2: Update name of the SDM location (Bryan)
Dissent: Use a new param instead of reusing HAS_LLC param (Chris, Chad) Fix unicode multiply symbol (Ben)

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c |  3 +++
 drivers/gpu/drm/i915/i915_drv.h |  2 ++
 drivers/gpu/drm/i915/i915_gem.c | 55 +++++++++++++++++++++++++++++++++++++++++
 include/uapi/drm/i915_drm.h     |  1 +
 4 files changed, 61 insertions(+)
drivers/gpu/drm/i915/i915_dma.c +3 -0
index 0e22142..1224586 100644
@@ -1000,6 +1000,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
 	case I915_PARAM_HAS_EXEC_HANDLE_LUT:
 		value = 1;
 		break;
+	case I915_PARAM_LLC_SIZE:
+		value = dev_priv->llc_size;
+		break;
 	default:
 		DRM_DEBUG("Unknown parameter %d\n", param->param);
 		return -EINVAL;
drivers/gpu/drm/i915/i915_drv.h +2 -0
index c8d6104..43a549d 100644
@@ -1187,6 +1187,8 @@ typedef struct drm_i915_private {
 	/* Old dri1 support infrastructure, beware the dragons ya fools entering
 	 * here! */
 	struct i915_dri1_state dri1;
+
+	size_t llc_size;
 } drm_i915_private_t;
 
 /* Iterate over initialised rings */
drivers/gpu/drm/i915/i915_gem.c +55 -0

67 lines not on this page · raw message

include/uapi/drm/i915_drm.h +1 -0
index 923ed7f..c54559e 100644
@@ -310,6 +310,7 @@ typedef struct drm_i915_irq_wait {
 #define I915_PARAM_HAS_PINNED_BATCHES	 24
 #define I915_PARAM_HAS_EXEC_NO_RELOC	 25
 #define I915_PARAM_HAS_EXEC_HANDLE_LUT   26
+#define I915_PARAM_LLC_SIZE		 27
 
 typedef struct drm_i915_getparam {
 	int param;
Signature · 1 line
1.8.3.2
#18 lore raw

PATCH 1/2 intel_get_llc_size: Small tool to query LLC size

v2: Use the new param

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 tools/Makefile.am          |  1 +
 tools/intel_get_llc_size.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 tools/intel_get_llc_size.c
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +58 -0

58 lines not on this page · raw message

Signature · 6 lines
1.8.3.2

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

PATCH 2/2 tests: Basic tools tester

v2: Remove the reg write test because it breaks pre gen5 Add the llc size param test

---
 tests/Makefile.am |  1 +
 tests/drm_lib.sh  |  4 ++++
 tests/tools_test  | 21 +++++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100755 tests/tools_test
tests/Makefile.am +1 -0
index a422899..ccc97b8 100644
@@ -115,6 +115,7 @@ TESTS_scripts_M = \
 
 TESTS_scripts = \
 	test_rte_check \
+	tools_test \
 	debugfs_reader \
 	debugfs_emon_crash \
 	sysfs_l3_parity \
tests/drm_lib.sh +4 -0
index 5ca815b..5975b58 100755
@@ -4,6 +4,10 @@ die() {
 	exit 1
 }
 
+do_or_die() {
+	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit -1)
+}
+
 if [ -d /debug/dri ] ; then
 	debugfs_path=/debug/dri
 fi
tests/tools_test new file +21 -0
new file mode 100755
index 0000000..17f7822
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Test some of the most critical tools we have accidentally broken before.
+# TODO: Possibly make tests parse output
+
+whoami | grep -q root || ( echo ERROR: not running as root; exit 1 )
+
+SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
+. $SOURCE_DIR/drm_lib.sh
+
+# ARB_MODE has existed for many gens. It differs per gen, but should be safe to
+# read regardless
+do_or_die "$SOURCE_DIR/../tools/intel_reg_read 0x4030"
+
+do_or_die "$SOURCE_DIR/../tools/intel_reg_dumper"
+
+do_or_die "$SOURCE_DIR/../tools/intel_get_llc_size"
+
+# TODO: Add more tests
+
+exit 0
+
Signature · 1 line
1.8.3.2
#20 lore raw

Re: [PATCH 1/2] intel_get_llc_size: Small tool to query LLC size

In reply to Ben Widawsky
Quoted 74 lines · Ben Widawsky

v2: Use the new param

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
  tools/Makefile.am          |  1 +
  tools/intel_get_llc_size.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 59 insertions(+)

create mode 100644 tools/intel_get_llc_size.c

tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +45 -0
new file mode 100644
index 0000000..498e252
@@ -0,0 +1,58 @@
+/*
+ * 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"
+
+#define LOCAL__I915_PARAM_LLC_SIZE 27
+static int get_llc_size(int fd)
+{
+	struct drm_i915_getparam gp;
+	int size;
+
+	gp.param = LOCAL__I915_PARAM_LLC_SIZE;
+	gp.value = &size;
+
+	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+		return 0;
+
+	return size;
+}
+
+int main(int argc, char **argv)
+{

tools/intel_get_llc_size.c line 55

Quoted 10 lines
tools/intel_get_llc_size.c new file +10 -0
+	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);

This if-tree looks wrong. If the kernel doesn't know about I915_PARAM_LLC_SIZE, the ioctl returns -1, and get_llc_size() returns 0, and the if-tree prints the wrong error.

How about making get_llc_size() return -1 on error? Or am I missing something here?

tools/intel_get_llc_size.c line 42

Quoted 4 lines
tools/intel_get_llc_size.c new file +3 -0
+
+	return 0;
+}

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

#21 lore raw

Re: [PATCH 1/2] intel_get_llc_size: Small tool to query LLC size

Quoted 90 lines · Chad Versace
Quoted 74 lines · Ben Widawsky

v2: Use the new param

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
---
 tools/Makefile.am          |  1 +
 tools/intel_get_llc_size.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 tools/intel_get_llc_size.c
tools/Makefile.am +1 -0
index 2519169..a064b65 100644
@@ -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 			\
tools/intel_get_llc_size.c new file +45 -0
new file mode 100644
index 0000000..498e252
@@ -0,0 +1,58 @@
+/*
+ * 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"
+
+#define LOCAL__I915_PARAM_LLC_SIZE 27
+static int get_llc_size(int fd)
+{
+	struct drm_i915_getparam gp;
+	int size;
+
+	gp.param = LOCAL__I915_PARAM_LLC_SIZE;
+	gp.value = &size;
+
+	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+		return 0;
+
+	return size;
+}
+
+int main(int argc, char **argv)
+{

tools/intel_get_llc_size.c line 55

Quoted 10 lines
tools/intel_get_llc_size.c new file +10 -0
+	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);

This if-tree looks wrong. If the kernel doesn't know about I915_PARAM_LLC_SIZE, the ioctl returns -1, and get_llc_size() returns 0, and the if-tree prints the wrong error.

Quoted 2 lines

How about making get_llc_size() return -1 on error? Or am I missing something here?

Looks like the tool needed updating after the last param change and I missed it. It should have been correct before (though in the case of no HAS_LLC param it was also bad). Your suggestion is the right thing to do.

If Daniel decides to merge the kernel patch, I will fix this.

Quoted 10 lines

tools/intel_get_llc_size.c line 42

Quoted 5 lines
tools/intel_get_llc_size.c new file +3 -0
+
+	return 0;
+}

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

Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw
In reply to Ben Widawsky
Quoted 5 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

Quoted 8 lines

I've tested this on two platforms, and it seems to perform how I want.

With this patch is a small tool for igt to query the size. This can be used as a reference for DRI clients wishing to query the information.

v2: Update name of the SDM location (Bryan)
Dissent: Use a new param instead of reusing HAS_LLC param (Chris, Chad) Fix unicode multiply symbol (Ben)

Shrug. I still dislike calling it LLC_SIZE since it is actually L3_SIZE. For very similar reasons, easily finding out L2 size would be useful, as would L4.

drivers/gpu/drm/i915/i915_drv.h typedef struct drm_i915_private { · line 1191

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
index c8d6104..43a549d 100644
@@ -1187,6 +1187,8 @@ typedef struct drm_i915_private {
 	/* Old dri1 support infrastructure, beware the dragons ya fools entering
 	 * here! */
 	struct i915_dri1_state dri1;
+
+	size_t llc_size;

Don't put it below the dungeons, it will be tainted. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Reviewed-by on v2 1/1
#23 lore raw
In reply to Ben Widawsky
Quoted 17 lines · Ben Widawsky

The algorithm/information was originally written by Chad, though I changed the control flow, and I think his original code had a couple of bugs, though I didn't look very hard before rewriting. That could have also been different interpretations of the spec.

I've tested this on two platforms, and it seems to perform how I want.

With this patch is a small tool for igt to query the size. This can be used as a reference for DRI clients wishing to query the information.

v2: Update name of the SDM location (Bryan)
Dissent: Use a new param instead of reusing HAS_LLC param (Chris, Chad) Fix unicode multiply symbol (Ben)

CC Chad Versace <[email protected]>
CC Bryan Bell <[email protected]>
Quoted 6 lines
---
  drivers/gpu/drm/i915/i915_dma.c |  3 +++
  drivers/gpu/drm/i915/i915_drv.h |  2 ++
  drivers/gpu/drm/i915/i915_gem.c | 55 +++++++++++++++++++++++++++++++++++++++++
  include/uapi/drm/i915_drm.h     |  1 +
  4 files changed, 61 insertions(+)

As long as this is tested and returns the same as L3 in /proc/cpuinfo, this patch is