[Intel-gfx] [PATCH 2/2] drm/i915: move vma sanity checking into i915_vma_bind

kbuild test robot lkp at intel.com
Sat Dec 3 18:07:33 UTC 2016


Hi Matthew,

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on next-20161202]
[cannot apply to v4.9-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Matthew-Auld/drm-i915-introduce-GEM_WARN_ON/20161203-231346
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/i915/i915_gem_request.h:30:0,
                    from drivers/gpu/drm/i915/i915_gem_timeline.h:30,
                    from drivers/gpu/drm/i915/i915_gem_gtt.h:40,
                    from drivers/gpu/drm/i915/i915_vma.h:32,
                    from drivers/gpu/drm/i915/i915_vma.c:25:
   drivers/gpu/drm/i915/i915_vma.c: In function 'i915_vma_bind':
>> drivers/gpu/drm/i915/i915_gem.h:33:27: error: expected expression before 'do'
    #define GEM_WARN_ON(expr) do { } while (0)
                              ^
>> drivers/gpu/drm/i915/i915_vma.c:179:6: note: in expansion of macro 'GEM_WARN_ON'
     if (GEM_WARN_ON(vma->node.start + vma->node.size < vma->node.start))
         ^~~~~~~~~~~
>> drivers/gpu/drm/i915/i915_gem.h:33:27: error: expected expression before 'do'
    #define GEM_WARN_ON(expr) do { } while (0)
                              ^
   drivers/gpu/drm/i915/i915_vma.c:182:6: note: in expansion of macro 'GEM_WARN_ON'
     if (GEM_WARN_ON(vma->node.start + vma->node.size > vma->vm->total))
         ^~~~~~~~~~~

vim +/GEM_WARN_ON +179 drivers/gpu/drm/i915/i915_vma.c

    19	 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    20	 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    21	 * IN THE SOFTWARE.
    22	 *
    23	 */
    24	 
  > 25	#include "i915_vma.h"
    26	
    27	#include "i915_drv.h"
    28	#include "intel_ringbuffer.h"
    29	#include "intel_frontbuffer.h"
    30	
    31	#include <drm/drm_gem.h>
    32	
    33	static void
    34	i915_vma_retire(struct i915_gem_active *active,
    35			struct drm_i915_gem_request *rq)
    36	{
    37		const unsigned int idx = rq->engine->id;
    38		struct i915_vma *vma =
    39			container_of(active, struct i915_vma, last_read[idx]);
    40		struct drm_i915_gem_object *obj = vma->obj;
    41	
    42		GEM_BUG_ON(!i915_vma_has_active_engine(vma, idx));
    43	
    44		i915_vma_clear_active(vma, idx);
    45		if (i915_vma_is_active(vma))
    46			return;
    47	
    48		list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
    49		if (unlikely(i915_vma_is_closed(vma) && !i915_vma_is_pinned(vma)))
    50			WARN_ON(i915_vma_unbind(vma));
    51	
    52		GEM_BUG_ON(!i915_gem_object_is_active(obj));
    53		if (--obj->active_count)
    54			return;
    55	
    56		/* Bump our place on the bound list to keep it roughly in LRU order
    57		 * so that we don't steal from recently used but inactive objects
    58		 * (unless we are forced to ofc!)
    59		 */
    60		if (obj->bind_count)
    61			list_move_tail(&obj->global_link, &rq->i915->mm.bound_list);
    62	
    63		obj->mm.dirty = true; /* be paranoid  */
    64	
    65		if (i915_gem_object_has_active_reference(obj)) {
    66			i915_gem_object_clear_active_reference(obj);
    67			i915_gem_object_put(obj);
    68		}
    69	}
    70	
    71	static struct i915_vma *
    72	__i915_vma_create(struct drm_i915_gem_object *obj,
    73			  struct i915_address_space *vm,
    74			  const struct i915_ggtt_view *view)
    75	{
    76		struct i915_vma *vma;
    77		struct rb_node *rb, **p;
    78		int i;
    79	
    80		GEM_BUG_ON(vm->closed);
    81	
    82		vma = kmem_cache_zalloc(to_i915(obj->base.dev)->vmas, GFP_KERNEL);
    83		if (vma == NULL)
    84			return ERR_PTR(-ENOMEM);
    85	
    86		INIT_LIST_HEAD(&vma->exec_list);
    87		for (i = 0; i < ARRAY_SIZE(vma->last_read); i++)
    88			init_request_active(&vma->last_read[i], i915_vma_retire);
    89		init_request_active(&vma->last_fence, NULL);
    90		list_add(&vma->vm_link, &vm->unbound_list);
    91		vma->vm = vm;
    92		vma->obj = obj;
    93		vma->size = obj->base.size;
    94	
    95		if (view) {
    96			vma->ggtt_view = *view;
    97			if (view->type == I915_GGTT_VIEW_PARTIAL) {
    98				vma->size = view->params.partial.size;
    99				vma->size <<= PAGE_SHIFT;
   100			} else if (view->type == I915_GGTT_VIEW_ROTATED) {
   101				vma->size =
   102					intel_rotation_info_size(&view->params.rotated);
   103				vma->size <<= PAGE_SHIFT;
   104			}
   105		}
   106	
   107		if (i915_is_ggtt(vm)) {
   108			vma->flags |= I915_VMA_GGTT;
   109			list_add(&vma->obj_link, &obj->vma_list);
   110		} else {
   111			i915_ppgtt_get(i915_vm_to_ppgtt(vm));
   112			list_add_tail(&vma->obj_link, &obj->vma_list);
   113		}
   114	
   115		rb = NULL;
   116		p = &obj->vma_tree.rb_node;
   117		while (*p) {
   118			struct i915_vma *pos;
   119	
   120			rb = *p;
   121			pos = rb_entry(rb, struct i915_vma, obj_node);
   122			if (i915_vma_compare(pos, vm, view) < 0)
   123				p = &rb->rb_right;
   124			else
   125				p = &rb->rb_left;
   126		}
   127		rb_link_node(&vma->obj_node, rb, p);
   128		rb_insert_color(&vma->obj_node, &obj->vma_tree);
   129	
   130		return vma;
   131	}
   132	
   133	struct i915_vma *
   134	i915_vma_create(struct drm_i915_gem_object *obj,
   135			struct i915_address_space *vm,
   136			const struct i915_ggtt_view *view)
   137	{
   138		lockdep_assert_held(&obj->base.dev->struct_mutex);
   139		GEM_BUG_ON(view && !i915_is_ggtt(vm));
   140		GEM_BUG_ON(i915_gem_obj_to_vma(obj, vm, view));
   141	
   142		return __i915_vma_create(obj, vm, view);
   143	}
   144	
   145	/**
   146	 * i915_vma_bind - Sets up PTEs for an VMA in it's corresponding address space.
   147	 * @vma: VMA to map
   148	 * @cache_level: mapping cache level
   149	 * @flags: flags like global or local mapping
   150	 *
   151	 * DMA addresses are taken from the scatter-gather table of this object (or of
   152	 * this VMA in case of non-default GGTT views) and PTE entries set up.
   153	 * Note that DMA addresses are also the only part of the SG table we care about.
   154	 */
   155	int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
   156			  u32 flags)
   157	{
   158		u32 bind_flags;
   159		u32 vma_flags;
   160		int ret;
   161	
   162		if (WARN_ON(flags == 0))
   163			return -EINVAL;
   164	
   165		bind_flags = 0;
   166		if (flags & PIN_GLOBAL)
   167			bind_flags |= I915_VMA_GLOBAL_BIND;
   168		if (flags & PIN_USER)
   169			bind_flags |= I915_VMA_LOCAL_BIND;
   170	
   171		vma_flags = vma->flags & (I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND);
   172		if (flags & PIN_UPDATE)
   173			bind_flags |= vma_flags;
   174		else
   175			bind_flags &= ~vma_flags;
   176		if (bind_flags == 0)
   177			return 0;
   178	
 > 179		if (GEM_WARN_ON(vma->node.start + vma->node.size < vma->node.start))
   180			return -ENODEV;
   181	
   182		if (GEM_WARN_ON(vma->node.start + vma->node.size > vma->vm->total))

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 56838 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20161204/2993abce/attachment-0001.gz>


More information about the Intel-gfx mailing list