[radeon-alex:drm-next-4.18-wip 182/214] drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1571 amdgpu_vm_bo_update() error: we previously assumed 'bo' could be null (see line 1537)

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

 



tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.18-wip
head:   52132fd03504140b4cc58c01b19e82929a03af7a
commit: 7bcfcb8217c6ab4224c7de5074132f2185558b72 [182/214] drm/amdgpu: simplify bo_va list when vm bo update (v2)

smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1571 amdgpu_vm_bo_update() error: we previously assumed 'bo' could be null (see line 1537)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1572 amdgpu_vm_bo_update() warn: variable dereferenced before check 'bo' (see line 1571)

git remote add radeon-alex git://people.freedesktop.org/~agd5f/linux.git
git remote update radeon-alex
git checkout 7bcfcb8217c6ab4224c7de5074132f2185558b72
vim +/bo +1571 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

a14faa65 Christian König 2016-01-25  1489  
a14faa65 Christian König 2016-01-25  1490  /**
d38ceaf9 Alex Deucher    2015-04-20  1491   * amdgpu_vm_bo_update - update all BO mappings in the vm page table
d38ceaf9 Alex Deucher    2015-04-20  1492   *
d38ceaf9 Alex Deucher    2015-04-20  1493   * @adev: amdgpu_device pointer
d38ceaf9 Alex Deucher    2015-04-20  1494   * @bo_va: requested BO and VM object
99e124f4 Christian König 2016-08-16  1495   * @clear: if true clear the entries
d38ceaf9 Alex Deucher    2015-04-20  1496   *
d38ceaf9 Alex Deucher    2015-04-20  1497   * Fill in the page table entries for @bo_va.
d38ceaf9 Alex Deucher    2015-04-20  1498   * Returns 0 for success, -EINVAL for failure.
d38ceaf9 Alex Deucher    2015-04-20  1499   */
d38ceaf9 Alex Deucher    2015-04-20  1500  int amdgpu_vm_bo_update(struct amdgpu_device *adev,
d38ceaf9 Alex Deucher    2015-04-20  1501  			struct amdgpu_bo_va *bo_va,
99e124f4 Christian König 2016-08-16  1502  			bool clear)
d38ceaf9 Alex Deucher    2015-04-20  1503  {
ec681545 Christian König 2017-08-01  1504  	struct amdgpu_bo *bo = bo_va->base.bo;
ec681545 Christian König 2017-08-01  1505  	struct amdgpu_vm *vm = bo_va->base.vm;
d38ceaf9 Alex Deucher    2015-04-20  1506  	struct amdgpu_bo_va_mapping *mapping;
8358dcee Christian König 2016-03-30  1507  	dma_addr_t *pages_addr = NULL;
99e124f4 Christian König 2016-08-16  1508  	struct ttm_mem_reg *mem;
63e0ba40 Christian König 2016-08-16  1509  	struct drm_mm_node *nodes;
4e55eb38 Christian König 2017-09-11  1510  	struct dma_fence *exclusive, **last_update;
457e0fee Christian König 2017-08-22  1511  	uint64_t flags;
7bcfcb82 Junwei Zhang    2018-04-19  1512  	uint32_t mem_type;
d38ceaf9 Alex Deucher    2015-04-20  1513  	int r;
d38ceaf9 Alex Deucher    2015-04-20  1514  
ec681545 Christian König 2017-08-01  1515  	if (clear || !bo_va->base.bo) {
99e124f4 Christian König 2016-08-16  1516  		mem = NULL;
63e0ba40 Christian König 2016-08-16  1517  		nodes = NULL;
99e124f4 Christian König 2016-08-16  1518  		exclusive = NULL;
99e124f4 Christian König 2016-08-16  1519  	} else {
8358dcee Christian König 2016-03-30  1520  		struct ttm_dma_tt *ttm;
8358dcee Christian König 2016-03-30  1521  
ec681545 Christian König 2017-08-01  1522  		mem = &bo_va->base.bo->tbo.mem;
63e0ba40 Christian König 2016-08-16  1523  		nodes = mem->mm_node;
63e0ba40 Christian König 2016-08-16  1524  		if (mem->mem_type == TTM_PL_TT) {
ec681545 Christian König 2017-08-01  1525  			ttm = container_of(bo_va->base.bo->tbo.ttm,
ec681545 Christian König 2017-08-01  1526  					   struct ttm_dma_tt, ttm);
8358dcee Christian König 2016-03-30  1527  			pages_addr = ttm->dma_address;
9ab21462 Christian König 2015-11-30  1528  		}
ec681545 Christian König 2017-08-01  1529  		exclusive = reservation_object_get_excl(bo->tbo.resv);
d38ceaf9 Alex Deucher    2015-04-20  1530  	}
d38ceaf9 Alex Deucher    2015-04-20  1531  
457e0fee Christian König 2017-08-22  1532  	if (bo)
ec681545 Christian König 2017-08-01  1533  		flags = amdgpu_ttm_tt_pte_flags(adev, bo->tbo.ttm, mem);
457e0fee Christian König 2017-08-22  1534  	else
a5f6b5b1 Christian König 2017-01-30  1535  		flags = 0x0;
d38ceaf9 Alex Deucher    2015-04-20  1536  
4e55eb38 Christian König 2017-09-11 @1537  	if (clear || (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv))
                                                              ^^
Checked.

4e55eb38 Christian König 2017-09-11  1538  		last_update = &vm->last_update;
4e55eb38 Christian König 2017-09-11  1539  	else
4e55eb38 Christian König 2017-09-11  1540  		last_update = &bo_va->last_pt_update;
4e55eb38 Christian König 2017-09-11  1541  
3d7d4d3a Christian König 2017-08-23  1542  	if (!clear && bo_va->base.moved) {
3d7d4d3a Christian König 2017-08-23  1543  		bo_va->base.moved = false;
7fc11959 Christian König 2015-07-30  1544  		list_splice_init(&bo_va->valids, &bo_va->invalids);
3d7d4d3a Christian König 2017-08-23  1545  
cb7b6ec2 Christian König 2017-08-15  1546  	} else if (bo_va->cleared != clear) {
7fc11959 Christian König 2015-07-30  1547  		list_splice_init(&bo_va->valids, &bo_va->invalids);
3d7d4d3a Christian König 2017-08-23  1548  	}
7fc11959 Christian König 2015-07-30  1549  
7fc11959 Christian König 2015-07-30  1550  	list_for_each_entry(mapping, &bo_va->invalids, list) {
457e0fee Christian König 2017-08-22  1551  		r = amdgpu_vm_bo_split_mapping(adev, exclusive, pages_addr, vm,
63e0ba40 Christian König 2016-08-16  1552  					       mapping, flags, nodes,
4e55eb38 Christian König 2017-09-11  1553  					       last_update);
d38ceaf9 Alex Deucher    2015-04-20  1554  		if (r)
d38ceaf9 Alex Deucher    2015-04-20  1555  			return r;
d38ceaf9 Alex Deucher    2015-04-20  1556  	}
d38ceaf9 Alex Deucher    2015-04-20  1557  
cb7b6ec2 Christian König 2017-08-15  1558  	if (vm->use_cpu_for_update) {
cb7b6ec2 Christian König 2017-08-15  1559  		/* Flush HDP */
cb7b6ec2 Christian König 2017-08-15  1560  		mb();
69882565 Christian König 2018-01-19  1561  		amdgpu_asic_flush_hdp(adev, NULL);
d6c10f6b Christian König 2015-09-28  1562  	}
d6c10f6b Christian König 2015-09-28  1563  
d38ceaf9 Alex Deucher    2015-04-20  1564  	spin_lock(&vm->status_lock);
7bcfcb82 Junwei Zhang    2018-04-19  1565  	list_del_init(&bo_va->base.vm_status);
eff5a054 Christian König 2018-03-19  1566  
eff5a054 Christian König 2018-03-19  1567  	/* If the BO is not in its preferred location add it back to
eff5a054 Christian König 2018-03-19  1568  	 * the evicted list so that it gets validated again on the
eff5a054 Christian König 2018-03-19  1569  	 * next command submission.
eff5a054 Christian König 2018-03-19  1570  	 */
7bcfcb82 Junwei Zhang    2018-04-19 @1571  	mem_type = bo->tbo.mem.mem_type;
                                                           ^^^^^^^^^^^^^^^^^^^^
7bcfcb82 Junwei Zhang    2018-04-19 @1572  	if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv &&
                                                    ^^
This check doesn't make sense because we dereferenced it on the line
before.

7bcfcb82 Junwei Zhang    2018-04-19  1573  	    !(bo->preferred_domains & amdgpu_mem_type_to_domain(mem_type)))
eff5a054 Christian König 2018-03-19  1574  		list_add_tail(&bo_va->base.vm_status, &vm->evicted);
d38ceaf9 Alex Deucher    2015-04-20  1575  	spin_unlock(&vm->status_lock);
d38ceaf9 Alex Deucher    2015-04-20  1576  
cb7b6ec2 Christian König 2017-08-15  1577  	list_splice_init(&bo_va->invalids, &bo_va->valids);
cb7b6ec2 Christian König 2017-08-15  1578  	bo_va->cleared = clear;
cb7b6ec2 Christian König 2017-08-15  1579  
cb7b6ec2 Christian König 2017-08-15  1580  	if (trace_amdgpu_vm_bo_mapping_enabled()) {
cb7b6ec2 Christian König 2017-08-15  1581  		list_for_each_entry(mapping, &bo_va->valids, list)
cb7b6ec2 Christian König 2017-08-15  1582  			trace_amdgpu_vm_bo_mapping(mapping);
68c62306 Christian König 2017-07-11  1583  	}
68c62306 Christian König 2017-07-11  1584  
d38ceaf9 Alex Deucher    2015-04-20  1585  	return 0;
d38ceaf9 Alex Deucher    2015-04-20  1586  }
d38ceaf9 Alex Deucher    2015-04-20  1587  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux