Skip to contentSkip to conversation

drm/i915/gem: Ensure aperture exists before setting domain to GTT

PATCH In review Stuart Summers 4 participants 7 messages Nov 19, 2019 – Nov 20, 2019

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

PATCH 1/1 drm/i915/gem: Ensure aperture exists before setting domain to GTT

mmap_gtt is already covered by a check for aperture presence. Also add the case to the gem_set_domain IOCTL to avoid this path for unsupported platforms.

---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_domain.c +3 -0
index 9aebcf263191..cf1e221fe27a 100644
@@ -112,6 +112,9 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
 
 	assert_object_held(obj);
 
+	if (!i915_ggtt_has_aperture(&i915->ggtt))
+		return -ENODEV;
+
 	ret = i915_gem_object_wait(obj,
 				   I915_WAIT_INTERRUPTIBLE |
 				   (write ? I915_WAIT_ALL : 0),
Signature · 6 lines
2.22.0

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

Quoting Stuart Summers (2019-11-19 21:30:32)

Quoted 3 lines

mmap_gtt is already covered by a check for aperture presence. Also add the case to the gem_set_domain IOCTL to avoid this path for unsupported platforms.

It doesn't harm either, it will just mean in a place where it is neither in the GPU nor in the CPU cache, same as it does today. The additional flushes coming out of a GTT write domain should already be elided.

It is used internally to mean precisely that...

Userspace should already be weaning itself off set-domain altogether. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✗ Fi.CI.BUILD: failure for drm/i915/gem: Ensure aperture exists before setting domain to GTT

In reply to Stuart Summers
== Series Details ==

== Series Details ==

Series: drm/i915/gem: Ensure aperture exists before setting domain to GTT
URL : https://patchwork.freedesktop.org/series/69698/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool

  CHK     include/generated/compile.h
  AR      drivers/gpu/drm/i915/built-in.a
  CC [M]  drivers/gpu/drm/i915/gem/i915_gem_domain.o
drivers/gpu/drm/i915/gem/i915_gem_domain.c: In function ‘i915_gem_object_set_to_gtt_domain’:
drivers/gpu/drm/i915/gem/i915_gem_domain.c:115:31: error: ‘i915’ undeclared (first use in this function); did you mean ‘to_i915’?
  if (!i915_ggtt_has_aperture(&i915->ggtt))
                               ^~~~
                               to_i915

drivers/gpu/drm/i915/gem/i915_gem_domain.c:115:31: note: each undeclared identifier is reported only once for each function it appears in scripts/Makefile.build:265: recipe for target 'drivers/gpu/drm/i915/gem/i915_gem_domain.o' failed
make[4]: *** [drivers/gpu/drm/i915/gem/i915_gem_domain.o] Error 1
scripts/Makefile.build:509: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:509: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:509: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1652: recipe for target 'drivers' failed
make: *** [drivers] Error 2

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

#2 lore raw
In reply to Chris Wilson
Quoted 11 lines · Chris Wilson

Quoting Stuart Summers (2019-11-19 21:30:32)

Quoted 3 lines

mmap_gtt is already covered by a check for aperture presence. Also add the case to the gem_set_domain IOCTL to avoid this path for unsupported platforms.

It doesn't harm either, it will just mean in a place where it is neither
in the GPU nor in the CPU cache, same as it does today. The additional
flushes coming out of a GTT write domain should already be elided.

Quoted 3 lines

It is used internally to mean precisely that...

Userspace should already be weaning itself off set-domain altogether.

But even with the weaning, shouldn't we have these checks in place for safety? Let's say there's some platform issue with the GTT flushes and moving ahead causes the hardware to get in a bad state. Isn't it better to bail early? Let me know if I'm missing something obvious here though.

Thanks,
Stuart

Quoted 1 line

-Chris

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

#3 lore raw

Quoting Summers, Stuart (2019-11-19 22:58:38)

Quoted 14 lines · Chris Wilson
Quoted 13 lines

Quoting Stuart Summers (2019-11-19 21:30:32)

Quoted 3 lines

mmap_gtt is already covered by a check for aperture presence. Also add the case to the gem_set_domain IOCTL to avoid this path for unsupported platforms.

It doesn't harm either, it will just mean in a place where it is neither
in the GPU nor in the CPU cache, same as it does today. The additional
flushes coming out of a GTT write domain should already be elided.

It is used internally to mean precisely that...

Quoted 7 lines
Quoted 1 line

Userspace should already be weaning itself off set-domain altogether.

But even with the weaning, shouldn't we have these checks in place for safety? Let's say there's some platform issue with the GTT flushes and moving ahead causes the hardware to get in a bad state. Isn't it better to bail early? Let me know if I'm missing something obvious here though.

That we use it internally.

It will never be unsafe simply because if the extra flushes don't exist, they don't exist. Just like today!
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

Re: ✗ Fi.CI.BUILD: failure for drm/i915/gem: Ensure aperture exists before setting domain to GTT

In reply to Patchwork
Quoted 12 lines · Patchwork

== Series Details ==

Series: drm/i915/gem: Ensure aperture exists before setting domain to GTT
URL : https://patchwork.freedesktop.org/series/69698/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool

Quoted 8 lines
  CHK     include/generated/compile.h
  AR      drivers/gpu/drm/i915/built-in.a
  CC [M]  drivers/gpu/drm/i915/gem/i915_gem_domain.o

drivers/gpu/drm/i915/gem/i915_gem_domain.c: In function ‘i915_gem_object_set_to_gtt_domain’:
drivers/gpu/drm/i915/gem/i915_gem_domain.c:115:31: error: ‘i915’ undeclared (first use in this function); did you mean ‘to_i915’?
if (!i915_ggtt_has_aperture(&i915->ggtt))

I swear I had this defined above... obviously not. I'll repost if Chris agrees with the approach here.

Thanks,
Stuart

Quoted 19 lines
                               ^~~~
                               to_i915

drivers/gpu/drm/i915/gem/i915_gem_domain.c:115:31: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.build:265: recipe for target 'drivers/gpu/drm/i915/gem/i915_gem_domain.o' failed make[4]: *** [drivers/gpu/drm/i915/gem/i915_gem_domain.o] Error 1 scripts/Makefile.build:509: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2 scripts/Makefile.build:509: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2 scripts/Makefile.build:509: recipe for target 'drivers/gpu' failed make[1]: *** [drivers/gpu] Error 2
Makefile:1652: recipe for target 'drivers' failed
make: *** [drivers] Error 2

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

#6 lore raw
In reply to Stuart Summers
Thank you for the patch! Yet something to improve:

Hi Stuart,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v5.4-rc8 next-20191119]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Stuart-Summers/drm-i915-gem-Ensure-aperture-exists-before-setting-domain-to-GTT/20191120-111351
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-a002-20191120 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.2-10+deb8u1) 4.9.2
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

drivers/gpu/drm/i915/gem/i915_gem_domain.c: In function 'i915_gem_object_set_to_gtt_domain':

>> drivers/gpu/drm/i915/gem/i915_gem_domain.c:114:31: error: 'i915' undeclared (first use in this function)
     if (!i915_ggtt_has_aperture(&i915->ggtt))
                                  ^

drivers/gpu/drm/i915/gem/i915_gem_domain.c:114:31: note: each undeclared identifier is reported only once for each function it appears in

vim +/i915 +114 drivers/gpu/drm/i915/gem/i915_gem_domain.c

    98	
    99	/**
   100	 * Moves a single object to the GTT read, and possibly write domain.
   101	 * @obj: object to act on
   102	 * @write: ask for write access or read only
   103	 *
   104	 * This function returns when the move is complete, including waiting on
   105	 * flushes to occur.
   106	 */
   107	int
   108	i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
   109	{
   110		int ret;
   111	
   112		assert_object_held(obj);
   113	
 > 114		if (!i915_ggtt_has_aperture(&i915->ggtt))
   115			return -ENODEV;
   116	
   117		ret = i915_gem_object_wait(obj,
   118					   I915_WAIT_INTERRUPTIBLE |
   119					   (write ? I915_WAIT_ALL : 0),
   120					   MAX_SCHEDULE_TIMEOUT);

121 if (ret)
122 return ret;
123
124 if (obj->write_domain == I915_GEM_DOMAIN_GTT)
125 return 0;
126
127 /* Flush and acquire obj->pages so that we are coherent through
128 * direct access in memory with previous cached writes through
129 * shmemfs and that our cache domain tracking remains valid.
130 * For example, if the obj->filp was moved to swap without us
131 * being notified and releasing the pages, we would mistakenly
132 * continue to assume that the obj remained out of the CPU cached
133 * domain.
134 */
135 ret = i915_gem_object_pin_pages(obj);
136 if (ret)
137 return ret;
138
139 i915_gem_object_flush_write_domain(obj, ~I915_GEM_DOMAIN_GTT);
140
141 /* Serialise direct access to this object with the barriers for
142 * coherent writes from the GPU, by effectively invalidating the
143 * GTT domain upon first access.
144 */
145 if ((obj->read_domains & I915_GEM_DOMAIN_GTT) == 0)
146 mb();
147
148 /* It should now be out of any other write domains, and we can update
149 * the domain values for our changes.
150 */
151 GEM_BUG_ON((obj->write_domain & ~I915_GEM_DOMAIN_GTT) != 0);
152 obj->read_domains |= I915_GEM_DOMAIN_GTT;
153 if (write) {
154 obj->read_domains = I915_GEM_DOMAIN_GTT;
155 obj->write_domain = I915_GEM_DOMAIN_GTT;
156 obj->mm.dirty = true;
157 }
158
159 i915_gem_object_unpin_pages(obj);
160 return 0;
161 }
162

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation