Skip to content

Commit 7423104

Browse files
committed
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: Zack Rusin <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Martin Krastev <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent a12be02 commit 7423104

File tree

10 files changed

+33
-22
lines changed

10 files changed

+33
-22
lines changed

drivers/gpu/drm/vmwgfx/ttm_memory.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,10 @@ int ttm_mem_global_init(struct ttm_mem_global *glob, struct device *dev)
435435

436436
si_meminfo(&si);
437437

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

441443
ret = ttm_mem_init_kernel_zone(glob, &si);
442444
if (unlikely(ret != 0))

drivers/gpu/drm/vmwgfx/vmwgfx_binding.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ static int vmw_binding_scrub_cb(struct vmw_ctx_bindinfo *bi, bool rebind)
715715
* without checking which bindings actually need to be emitted
716716
*
717717
* @cbs: Pointer to the context's struct vmw_ctx_binding_state
718-
* @bi: Pointer to where the binding info array is stored in @cbs
718+
* @biv: Pointer to where the binding info array is stored in @cbs
719719
* @max_num: Maximum number of entries in the @bi array.
720720
*
721721
* 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)
725725
* contains the command data.
726726
*/
727727
static void vmw_collect_view_ids(struct vmw_ctx_binding_state *cbs,
728-
const struct vmw_ctx_bindinfo *bi,
728+
const struct vmw_ctx_bindinfo_view *biv,
729729
u32 max_num)
730730
{
731-
const struct vmw_ctx_bindinfo_view *biv =
732-
container_of(bi, struct vmw_ctx_bindinfo_view, bi);
733731
unsigned long i;
734732

735733
cbs->bind_cmd_count = 0;
@@ -838,7 +836,7 @@ static int vmw_emit_set_sr(struct vmw_ctx_binding_state *cbs,
838836
*/
839837
static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
840838
{
841-
const struct vmw_ctx_bindinfo *loc = &cbs->render_targets[0].bi;
839+
const struct vmw_ctx_bindinfo_view *loc = &cbs->render_targets[0];
842840
struct {
843841
SVGA3dCmdHeader header;
844842
SVGA3dCmdDXSetRenderTargets body;
@@ -874,7 +872,7 @@ static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
874872
* without checking which bindings actually need to be emitted
875873
*
876874
* @cbs: Pointer to the context's struct vmw_ctx_binding_state
877-
* @bi: Pointer to where the binding info array is stored in @cbs
875+
* @biso: Pointer to where the binding info array is stored in @cbs
878876
* @max_num: Maximum number of entries in the @bi array.
879877
*
880878
* 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)
884882
* contains the command data.
885883
*/
886884
static void vmw_collect_so_targets(struct vmw_ctx_binding_state *cbs,
887-
const struct vmw_ctx_bindinfo *bi,
885+
const struct vmw_ctx_bindinfo_so_target *biso,
888886
u32 max_num)
889887
{
890-
const struct vmw_ctx_bindinfo_so_target *biso =
891-
container_of(bi, struct vmw_ctx_bindinfo_so_target, bi);
892888
unsigned long i;
893889
SVGA3dSoTarget *so_buffer = (SVGA3dSoTarget *) cbs->bind_cmd_buffer;
894890

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

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

10971093
static int vmw_emit_set_cs_uav(struct vmw_ctx_binding_state *cbs)
10981094
{
1099-
const struct vmw_ctx_bindinfo *loc = &cbs->ua_views[1].views[0].bi;
1095+
const struct vmw_ctx_bindinfo_view *loc = &cbs->ua_views[1].views[0];
11001096
struct {
11011097
SVGA3dCmdHeader header;
11021098
SVGA3dCmdDXSetCSUAViews body;

drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
516516
struct vmw_cmdbuf_man *man =
517517
container_of(work, struct vmw_cmdbuf_man, work);
518518
struct vmw_cmdbuf_header *entry, *next;
519-
uint32_t dummy;
519+
uint32_t dummy = 0;
520520
bool send_fence = false;
521521
struct list_head restart_head[SVGA_CB_CONTEXT_MAX];
522522
int i;

drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,16 @@ void vmw_cmdbuf_res_commit(struct list_head *list)
159159
void vmw_cmdbuf_res_revert(struct list_head *list)
160160
{
161161
struct vmw_cmdbuf_res *entry, *next;
162+
int ret;
162163

163164
list_for_each_entry_safe(entry, next, list, head) {
164165
switch (entry->state) {
165166
case VMW_CMDBUF_RES_ADD:
166167
vmw_cmdbuf_res_free(entry->man, entry);
167168
break;
168169
case VMW_CMDBUF_RES_DEL:
169-
drm_ht_insert_item(&entry->man->resources, &entry->hash);
170+
ret = drm_ht_insert_item(&entry->man->resources, &entry->hash);
171+
BUG_ON(ret);
170172
list_del(&entry->head);
171173
list_add_tail(&entry->head, &entry->man->list);
172174
entry->state = VMW_CMDBUF_RES_COMMITTED;

drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,8 @@ static int vmw_cmd_dx_so_define(struct vmw_private *dev_priv,
25472547

25482548
so_type = vmw_so_cmd_to_type(header->id);
25492549
res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]);
2550+
if (IS_ERR(res))
2551+
return PTR_ERR(res);
25502552
cmd = container_of(header, typeof(*cmd), header);
25512553
ret = vmw_cotable_notify(res, cmd->defined_id);
25522554

drivers/gpu/drm/vmwgfx/vmwgfx_mob.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,13 @@ static void vmw_mob_pt_setup(struct vmw_mob *mob,
507507
{
508508
unsigned long num_pt_pages = 0;
509509
struct ttm_buffer_object *bo = mob->pt_bo;
510-
struct vmw_piter save_pt_iter;
510+
struct vmw_piter save_pt_iter = {0};
511511
struct vmw_piter pt_iter;
512512
const struct vmw_sg_table *vsgt;
513513
int ret;
514514

515+
BUG_ON(num_data_pages == 0);
516+
515517
ret = ttm_bo_reserve(bo, false, true, NULL);
516518
BUG_ON(ret != 0);
517519

drivers/gpu/drm/vmwgfx/vmwgfx_msg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,15 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
162162
/* HB port can't access encrypted memory. */
163163
if (hb && !mem_encrypt_active()) {
164164
unsigned long bp = channel->cookie_high;
165+
u32 channel_id = (channel->channel_id << 16);
165166

166167
si = (uintptr_t) msg;
167168
di = channel->cookie_low;
168169

169170
VMW_PORT_HB_OUT(
170171
(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
171172
msg_len, si, di,
172-
VMWARE_HYPERVISOR_HB | (channel->channel_id << 16) |
173+
VMWARE_HYPERVISOR_HB | channel_id |
173174
VMWARE_HYPERVISOR_OUT,
174175
VMW_HYPERVISOR_MAGIC, bp,
175176
eax, ebx, ecx, edx, si, di);
@@ -217,14 +218,15 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply,
217218
/* HB port can't access encrypted memory */
218219
if (hb && !mem_encrypt_active()) {
219220
unsigned long bp = channel->cookie_low;
221+
u32 channel_id = (channel->channel_id << 16);
220222

221223
si = channel->cookie_high;
222224
di = (uintptr_t) reply;
223225

224226
VMW_PORT_HB_IN(
225227
(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
226228
reply_len, si, di,
227-
VMWARE_HYPERVISOR_HB | (channel->channel_id << 16),
229+
VMWARE_HYPERVISOR_HB | channel_id,
228230
VMW_HYPERVISOR_MAGIC, bp,
229231
eax, ebx, ecx, edx, si, di);
230232

drivers/gpu/drm/vmwgfx/vmwgfx_resource.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ static void vmw_resource_release(struct kref *kref)
114114
container_of(kref, struct vmw_resource, kref);
115115
struct vmw_private *dev_priv = res->dev_priv;
116116
int id;
117+
int ret;
117118
struct idr *idr = &dev_priv->res_idr[res->func->res_type];
118119

119120
spin_lock(&dev_priv->resource_lock);
@@ -122,7 +123,8 @@ static void vmw_resource_release(struct kref *kref)
122123
if (res->backup) {
123124
struct ttm_buffer_object *bo = &res->backup->base;
124125

125-
ttm_bo_reserve(bo, false, false, NULL);
126+
ret = ttm_bo_reserve(bo, false, false, NULL);
127+
BUG_ON(ret);
126128
if (vmw_resource_mob_attached(res) &&
127129
res->func->unbind != NULL) {
128130
struct ttm_validate_buffer val_buf;
@@ -1001,7 +1003,9 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)
10011003
if (res->backup) {
10021004
vbo = res->backup;
10031005

1004-
ttm_bo_reserve(&vbo->base, interruptible, false, NULL);
1006+
ret = ttm_bo_reserve(&vbo->base, interruptible, false, NULL);
1007+
if (ret)
1008+
goto out_no_validate;
10051009
if (!vbo->base.pin_count) {
10061010
ret = ttm_bo_validate
10071011
(&vbo->base,

drivers/gpu/drm/vmwgfx/vmwgfx_so.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ const SVGACOTableType vmw_so_cotables[] = {
539539
[vmw_so_ds] = SVGA_COTABLE_DEPTHSTENCIL,
540540
[vmw_so_rs] = SVGA_COTABLE_RASTERIZERSTATE,
541541
[vmw_so_ss] = SVGA_COTABLE_SAMPLER,
542-
[vmw_so_so] = SVGA_COTABLE_STREAMOUTPUT
542+
[vmw_so_so] = SVGA_COTABLE_STREAMOUTPUT,
543+
[vmw_so_max]= SVGA_COTABLE_MAX
543544
};
544545

545546

drivers/gpu/drm/vmwgfx/vmwgfx_validation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,13 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)
586586
container_of(entry->base.bo, typeof(*vbo), base);
587587

588588
if (entry->cpu_blit) {
589-
struct ttm_operation_ctx ctx = {
589+
struct ttm_operation_ctx ttm_ctx = {
590590
.interruptible = intr,
591591
.no_wait_gpu = false
592592
};
593593

594594
ret = ttm_bo_validate(entry->base.bo,
595-
&vmw_nonfixed_placement, &ctx);
595+
&vmw_nonfixed_placement, &ttm_ctx);
596596
} else {
597597
ret = vmw_validation_bo_validate_single
598598
(entry->base.bo, intr, entry->as_mob);

0 commit comments

Comments
 (0)