[drm-intel:for-linux-next-fixes 7/7] drivers/gpu/drm/i915/i915_gem_evict.c:318:3: note: in expansion of macro 'if'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   git://anongit.freedesktop.org/drm-intel for-linux-next-fixes
head:   72872c99b6dbc80362965cd30489c849f0663140
commit: 72872c99b6dbc80362965cd30489c849f0663140 [7/7] drm/i915: Check PIN_NONFAULT overlaps in evict_for_node
config: x86_64-randconfig-x011-201741 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        git checkout 72872c99b6dbc80362965cd30489c849f0663140
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/agp_backend.h:33,
                    from include/drm/drmP.h:35,
                    from drivers/gpu/drm/i915/i915_gem_evict.c:29:
   drivers/gpu/drm/i915/i915_gem_evict.c: In function 'i915_gem_evict_for_node':
   drivers/gpu/drm/i915/i915_gem_evict.c:318:31: error: implicit declaration of function 'i915_vma_has_userfault' [-Werror=implicit-function-declaration]
      if (flags & PIN_NONFAULT && i915_vma_has_userfault(vma)) {
                                  ^
   include/linux/compiler.h:156:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/gpu/drm/i915/i915_gem_evict.c:318:3: note: in expansion of macro 'if'
      if (flags & PIN_NONFAULT && i915_vma_has_userfault(vma)) {
      ^~
   cc1: some warnings being treated as errors

vim +/if +318 drivers/gpu/drm/i915/i915_gem_evict.c

   236	
   237	/**
   238	 * i915_gem_evict_for_vma - Evict vmas to make room for binding a new one
   239	 * @vm: address space to evict from
   240	 * @target: range (and color) to evict for
   241	 * @flags: additional flags to control the eviction algorithm
   242	 *
   243	 * This function will try to evict vmas that overlap the target node.
   244	 *
   245	 * To clarify: This is for freeing up virtual address space, not for freeing
   246	 * memory in e.g. the shrinker.
   247	 */
   248	int i915_gem_evict_for_node(struct i915_address_space *vm,
   249				    struct drm_mm_node *target,
   250				    unsigned int flags)
   251	{
   252		LIST_HEAD(eviction_list);
   253		struct drm_mm_node *node;
   254		u64 start = target->start;
   255		u64 end = start + target->size;
   256		struct i915_vma *vma, *next;
   257		bool check_color;
   258		int ret = 0;
   259	
   260		lockdep_assert_held(&vm->i915->drm.struct_mutex);
   261		GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE));
   262		GEM_BUG_ON(!IS_ALIGNED(end, I915_GTT_PAGE_SIZE));
   263	
   264		trace_i915_gem_evict_node(vm, target, flags);
   265	
   266		/* Retire before we search the active list. Although we have
   267		 * reasonable accuracy in our retirement lists, we may have
   268		 * a stray pin (preventing eviction) that can only be resolved by
   269		 * retiring.
   270		 */
   271		if (!(flags & PIN_NONBLOCK))
   272			i915_gem_retire_requests(vm->i915);
   273	
   274		check_color = vm->mm.color_adjust;
   275		if (check_color) {
   276			/* Expand search to cover neighbouring guard pages (or lack!) */
   277			if (start)
   278				start -= I915_GTT_PAGE_SIZE;
   279	
   280			/* Always look at the page afterwards to avoid the end-of-GTT */
   281			end += I915_GTT_PAGE_SIZE;
   282		}
   283		GEM_BUG_ON(start >= end);
   284	
   285		drm_mm_for_each_node_in_range(node, &vm->mm, start, end) {
   286			/* If we find any non-objects (!vma), we cannot evict them */
   287			if (node->color == I915_COLOR_UNEVICTABLE) {
   288				ret = -ENOSPC;
   289				break;
   290			}
   291	
   292			GEM_BUG_ON(!node->allocated);
   293			vma = container_of(node, typeof(*vma), node);
   294	
   295			/* If we are using coloring to insert guard pages between
   296			 * different cache domains within the address space, we have
   297			 * to check whether the objects on either side of our range
   298			 * abutt and conflict. If they are in conflict, then we evict
   299			 * those as well to make room for our guard pages.
   300			 */
   301			if (check_color) {
   302				if (node->start + node->size == target->start) {
   303					if (node->color == target->color)
   304						continue;
   305				}
   306				if (node->start == target->start + target->size) {
   307					if (node->color == target->color)
   308						continue;
   309				}
   310			}
   311	
   312			if (flags & PIN_NONBLOCK &&
   313			    (i915_vma_is_pinned(vma) || i915_vma_is_active(vma))) {
   314				ret = -ENOSPC;
   315				break;
   316			}
   317	
 > 318			if (flags & PIN_NONFAULT && i915_vma_has_userfault(vma)) {
   319				ret = -ENOSPC;
   320				break;
   321			}
   322	
   323			/* Overlap of objects in the same batch? */
   324			if (i915_vma_is_pinned(vma)) {
   325				ret = -ENOSPC;
   326				if (vma->exec_flags &&
   327				    *vma->exec_flags & EXEC_OBJECT_PINNED)
   328					ret = -EINVAL;
   329				break;
   330			}
   331	
   332			/* Never show fear in the face of dragons!
   333			 *
   334			 * We cannot directly remove this node from within this
   335			 * iterator and as with i915_gem_evict_something() we employ
   336			 * the vma pin_count in order to prevent the action of
   337			 * unbinding one vma from freeing (by dropping its active
   338			 * reference) another in our eviction list.
   339			 */
   340			__i915_vma_pin(vma);
   341			list_add(&vma->evict_link, &eviction_list);
   342		}
   343	
   344		list_for_each_entry_safe(vma, next, &eviction_list, evict_link) {
   345			__i915_vma_unpin(vma);
   346			if (ret == 0)
   347				ret = i915_vma_unbind(vma);
   348		}
   349	
   350		return ret;
   351	}
   352	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux