gfx: imgv: fix parameter checking for exec cmd IOCTL
authorImre Deak <imre.deak@intel.com>
Thu, 22 Dec 2011 20:48:28 +0000 (22:48 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:29:18 +0000 (12:29 +0300)
As the comment in code suggests the IOCTL accepts only flags specifying
a GPU read or write operation, for all other flags we should return
-EINVAL. The call to psb_ttm_bo_check_placement that would seemingly
check this is actually a no-op in this case. Replace it with an actual
check. While at it, also clean up the preceeding check.

This is also needed by an upcoming patch getting rid of
psb_ttm_bo_check_placement.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/staging/mrst/drv/psb_sgx.c

index 8245e81..74c79a4 100644 (file)
@@ -194,24 +194,18 @@ psb_placement_fence_type(struct ttm_buffer_object *bo,
        */
        struct ttm_fence_object *old_fence;
        uint32_t old_fence_type;
-       struct ttm_placement placement;
+       const uint64_t mask = PSB_GPU_ACCESS_READ | PSB_GPU_ACCESS_WRITE;
 
-       if (unlikely
-           (!(set_val_flags &
-              (PSB_GPU_ACCESS_READ | PSB_GPU_ACCESS_WRITE)))) {
-               DRM_ERROR
-               ("GPU access type (read / write) is not indicated.\n");
+       if (!(set_val_flags & mask)) {
+               DRM_ERROR("GPU access type (read / write) is not indicated.\n");
                return -EINVAL;
        }
 
-       /* User space driver doesn't set any TTM placement flags in set_val_flags or clr_val_flags */
-       placement.num_placement = 0;/* FIXME  */
-       placement.num_busy_placement = 0;
-       placement.fpfn = 0;
-       placement.lpfn = 0;
-       ret = psb_ttm_bo_check_placement(bo, &placement);
-       if (unlikely(ret != 0))
-               return ret;
+       /* The only accepted bits are PSB_GPU_ACCES_{READ,WRITE}. */
+       if ((set_val_flags | clr_val_flags) & ~mask) {
+               DRM_ERROR("invalid set/clear flags\n");
+               return -EINVAL;
+       }
 
        switch (new_fence_class) {
        default: