Commit 74231041 authored by Zack Rusin's avatar Zack Rusin
Browse files

drm/vmwgfx: Fix some static checker warnings



Fix some minor issues that Coverity spotted in the code. None
of that are serious but they're all valid concerns so fixing
them makes sense.

Signed-off-by: default avatarZack Rusin <zackr@vmware.com>
Reviewed-by: default avatarRoland Scheidegger <sroland@vmware.com>
Reviewed-by: default avatarMartin Krastev <krastevm@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210609172307.131929-5-zackr@vmware.com
parent a12be027
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -435,8 +435,10 @@ int ttm_mem_global_init(struct ttm_mem_global *glob, struct device *dev)

	si_meminfo(&si);

	spin_lock(&glob->lock);
	/* set it as 0 by default to keep original behavior of OOM */
	glob->lower_mem_limit = 0;
	spin_unlock(&glob->lock);

	ret = ttm_mem_init_kernel_zone(glob, &si);
	if (unlikely(ret != 0))
+8 −12
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ static int vmw_binding_scrub_cb(struct vmw_ctx_bindinfo *bi, bool rebind)
 * without checking which bindings actually need to be emitted
 *
 * @cbs: Pointer to the context's struct vmw_ctx_binding_state
 * @bi: Pointer to where the binding info array is stored in @cbs
 * @biv: Pointer to where the binding info array is stored in @cbs
 * @max_num: Maximum number of entries in the @bi array.
 *
 * Scans the @bi array for bindings and builds a buffer of view id data.
@@ -725,11 +725,9 @@ static int vmw_binding_scrub_cb(struct vmw_ctx_bindinfo *bi, bool rebind)
 * contains the command data.
 */
static void vmw_collect_view_ids(struct vmw_ctx_binding_state *cbs,
				 const struct vmw_ctx_bindinfo *bi,
				 const struct vmw_ctx_bindinfo_view *biv,
				 u32 max_num)
{
	const struct vmw_ctx_bindinfo_view *biv =
		container_of(bi, struct vmw_ctx_bindinfo_view, bi);
	unsigned long i;

	cbs->bind_cmd_count = 0;
@@ -838,7 +836,7 @@ static int vmw_emit_set_sr(struct vmw_ctx_binding_state *cbs,
 */
static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
{
	const struct vmw_ctx_bindinfo *loc = &cbs->render_targets[0].bi;
	const struct vmw_ctx_bindinfo_view *loc = &cbs->render_targets[0];
	struct {
		SVGA3dCmdHeader header;
		SVGA3dCmdDXSetRenderTargets body;
@@ -874,7 +872,7 @@ static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
 * without checking which bindings actually need to be emitted
 *
 * @cbs: Pointer to the context's struct vmw_ctx_binding_state
 * @bi: Pointer to where the binding info array is stored in @cbs
 * @biso: Pointer to where the binding info array is stored in @cbs
 * @max_num: Maximum number of entries in the @bi array.
 *
 * Scans the @bi array for bindings and builds a buffer of SVGA3dSoTarget data.
@@ -884,11 +882,9 @@ static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
 * contains the command data.
 */
static void vmw_collect_so_targets(struct vmw_ctx_binding_state *cbs,
				   const struct vmw_ctx_bindinfo *bi,
				   const struct vmw_ctx_bindinfo_so_target *biso,
				   u32 max_num)
{
	const struct vmw_ctx_bindinfo_so_target *biso =
		container_of(bi, struct vmw_ctx_bindinfo_so_target, bi);
	unsigned long i;
	SVGA3dSoTarget *so_buffer = (SVGA3dSoTarget *) cbs->bind_cmd_buffer;

@@ -919,7 +915,7 @@ static void vmw_collect_so_targets(struct vmw_ctx_binding_state *cbs,
 */
static int vmw_emit_set_so_target(struct vmw_ctx_binding_state *cbs)
{
	const struct vmw_ctx_bindinfo *loc = &cbs->so_targets[0].bi;
	const struct vmw_ctx_bindinfo_so_target *loc = &cbs->so_targets[0];
	struct {
		SVGA3dCmdHeader header;
		SVGA3dCmdDXSetSOTargets body;
@@ -1066,7 +1062,7 @@ static int vmw_emit_set_vb(struct vmw_ctx_binding_state *cbs)

static int vmw_emit_set_uav(struct vmw_ctx_binding_state *cbs)
{
	const struct vmw_ctx_bindinfo *loc = &cbs->ua_views[0].views[0].bi;
	const struct vmw_ctx_bindinfo_view *loc = &cbs->ua_views[0].views[0];
	struct {
		SVGA3dCmdHeader header;
		SVGA3dCmdDXSetUAViews body;
@@ -1096,7 +1092,7 @@ static int vmw_emit_set_uav(struct vmw_ctx_binding_state *cbs)

static int vmw_emit_set_cs_uav(struct vmw_ctx_binding_state *cbs)
{
	const struct vmw_ctx_bindinfo *loc = &cbs->ua_views[1].views[0].bi;
	const struct vmw_ctx_bindinfo_view *loc = &cbs->ua_views[1].views[0];
	struct {
		SVGA3dCmdHeader header;
		SVGA3dCmdDXSetCSUAViews body;
+1 −1
Original line number Diff line number Diff line
@@ -516,7 +516,7 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
	struct vmw_cmdbuf_man *man =
		container_of(work, struct vmw_cmdbuf_man, work);
	struct vmw_cmdbuf_header *entry, *next;
	uint32_t dummy;
	uint32_t dummy = 0;
	bool send_fence = false;
	struct list_head restart_head[SVGA_CB_CONTEXT_MAX];
	int i;
+3 −1
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ void vmw_cmdbuf_res_commit(struct list_head *list)
void vmw_cmdbuf_res_revert(struct list_head *list)
{
	struct vmw_cmdbuf_res *entry, *next;
	int ret;

	list_for_each_entry_safe(entry, next, list, head) {
		switch (entry->state) {
@@ -166,7 +167,8 @@ void vmw_cmdbuf_res_revert(struct list_head *list)
			vmw_cmdbuf_res_free(entry->man, entry);
			break;
		case VMW_CMDBUF_RES_DEL:
			drm_ht_insert_item(&entry->man->resources, &entry->hash);
			ret = drm_ht_insert_item(&entry->man->resources, &entry->hash);
			BUG_ON(ret);
			list_del(&entry->head);
			list_add_tail(&entry->head, &entry->man->list);
			entry->state = VMW_CMDBUF_RES_COMMITTED;
+2 −0
Original line number Diff line number Diff line
@@ -2547,6 +2547,8 @@ static int vmw_cmd_dx_so_define(struct vmw_private *dev_priv,

	so_type = vmw_so_cmd_to_type(header->id);
	res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]);
	if (IS_ERR(res))
		return PTR_ERR(res);
	cmd = container_of(header, typeof(*cmd), header);
	ret = vmw_cotable_notify(res, cmd->defined_id);

Loading