@@ -2557,88 +2557,31 @@ int vmw_kms_helper_dirty(struct vmw_private *dev_priv,
2557
2557
}
2558
2558
2559
2559
/**
2560
- * vmw_kms_helper_buffer_prepare - Reserve and validate a buffer object before
2561
- * command submission.
2562
- *
2563
- * @dev_priv. Pointer to a device private structure.
2564
- * @buf: The buffer object
2565
- * @interruptible: Whether to perform waits as interruptible.
2566
- * @validate_as_mob: Whether the buffer should be validated as a MOB. If false,
2567
- * The buffer will be validated as a GMR. Already pinned buffers will not be
2568
- * validated.
2569
- *
2570
- * Returns 0 on success, negative error code on failure, -ERESTARTSYS if
2571
- * interrupted by a signal.
2560
+ * vmw_kms_helper_validation_finish - Helper for post KMS command submission
2561
+ * cleanup and fencing
2562
+ * @dev_priv: Pointer to the device-private struct
2563
+ * @file_priv: Pointer identifying the client when user-space fencing is used
2564
+ * @ctx: Pointer to the validation context
2565
+ * @out_fence: If non-NULL, returned refcounted fence-pointer
2566
+ * @user_fence_rep: If non-NULL, pointer to user-space address area
2567
+ * in which to copy user-space fence info
2572
2568
*/
2573
- int vmw_kms_helper_buffer_prepare (struct vmw_private * dev_priv ,
2574
- struct vmw_buffer_object * buf ,
2575
- bool interruptible ,
2576
- bool validate_as_mob ,
2577
- bool for_cpu_blit )
2578
- {
2579
- struct ttm_operation_ctx ctx = {
2580
- .interruptible = interruptible ,
2581
- .no_wait_gpu = false};
2582
- struct ttm_buffer_object * bo = & buf -> base ;
2583
- int ret ;
2584
-
2585
- ttm_bo_reserve (bo , false, false, NULL );
2586
- if (for_cpu_blit )
2587
- ret = ttm_bo_validate (bo , & vmw_nonfixed_placement , & ctx );
2588
- else
2589
- ret = vmw_validation_bo_validate_single (bo , interruptible ,
2590
- validate_as_mob );
2591
- if (ret )
2592
- ttm_bo_unreserve (bo );
2593
-
2594
- return ret ;
2595
- }
2596
-
2597
- /**
2598
- * vmw_kms_helper_buffer_revert - Undo the actions of
2599
- * vmw_kms_helper_buffer_prepare.
2600
- *
2601
- * @res: Pointer to the buffer object.
2602
- *
2603
- * Helper to be used if an error forces the caller to undo the actions of
2604
- * vmw_kms_helper_buffer_prepare.
2605
- */
2606
- void vmw_kms_helper_buffer_revert (struct vmw_buffer_object * buf )
2607
- {
2608
- if (buf )
2609
- ttm_bo_unreserve (& buf -> base );
2610
- }
2611
-
2612
- /**
2613
- * vmw_kms_helper_buffer_finish - Unreserve and fence a buffer object after
2614
- * kms command submission.
2615
- *
2616
- * @dev_priv: Pointer to a device private structure.
2617
- * @file_priv: Pointer to a struct drm_file representing the caller's
2618
- * connection. Must be set to NULL if @user_fence_rep is NULL, and conversely
2619
- * if non-NULL, @user_fence_rep must be non-NULL.
2620
- * @buf: The buffer object.
2621
- * @out_fence: Optional pointer to a fence pointer. If non-NULL, a
2622
- * ref-counted fence pointer is returned here.
2623
- * @user_fence_rep: Optional pointer to a user-space provided struct
2624
- * drm_vmw_fence_rep. If provided, @file_priv must also be provided and the
2625
- * function copies fence data to user-space in a fail-safe manner.
2626
- */
2627
- void vmw_kms_helper_buffer_finish (struct vmw_private * dev_priv ,
2628
- struct drm_file * file_priv ,
2629
- struct vmw_buffer_object * buf ,
2630
- struct vmw_fence_obj * * out_fence ,
2631
- struct drm_vmw_fence_rep __user *
2632
- user_fence_rep )
2633
- {
2634
- struct vmw_fence_obj * fence ;
2569
+ void vmw_kms_helper_validation_finish (struct vmw_private * dev_priv ,
2570
+ struct drm_file * file_priv ,
2571
+ struct vmw_validation_context * ctx ,
2572
+ struct vmw_fence_obj * * out_fence ,
2573
+ struct drm_vmw_fence_rep __user *
2574
+ user_fence_rep )
2575
+ {
2576
+ struct vmw_fence_obj * fence = NULL ;
2635
2577
uint32_t handle ;
2636
2578
int ret ;
2637
2579
2638
- ret = vmw_execbuf_fence_commands (file_priv , dev_priv , & fence ,
2639
- file_priv ? & handle : NULL );
2640
- if (buf )
2641
- vmw_bo_fence_single (& buf -> base , fence );
2580
+ if (file_priv || user_fence_rep || vmw_validation_has_bos (ctx ) ||
2581
+ out_fence )
2582
+ ret = vmw_execbuf_fence_commands (file_priv , dev_priv , & fence ,
2583
+ file_priv ? & handle : NULL );
2584
+ vmw_validation_done (ctx , fence );
2642
2585
if (file_priv )
2643
2586
vmw_execbuf_copy_fence_user (dev_priv , vmw_fpriv (file_priv ),
2644
2587
ret , user_fence_rep , fence ,
@@ -2647,106 +2590,6 @@ void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv,
2647
2590
* out_fence = fence ;
2648
2591
else
2649
2592
vmw_fence_obj_unreference (& fence );
2650
-
2651
- vmw_kms_helper_buffer_revert (buf );
2652
- }
2653
-
2654
-
2655
- /**
2656
- * vmw_kms_helper_resource_revert - Undo the actions of
2657
- * vmw_kms_helper_resource_prepare.
2658
- *
2659
- * @res: Pointer to the resource. Typically a surface.
2660
- *
2661
- * Helper to be used if an error forces the caller to undo the actions of
2662
- * vmw_kms_helper_resource_prepare.
2663
- */
2664
- void vmw_kms_helper_resource_revert (struct vmw_validation_ctx * ctx )
2665
- {
2666
- struct vmw_resource * res = ctx -> res ;
2667
-
2668
- vmw_kms_helper_buffer_revert (ctx -> buf );
2669
- vmw_bo_unreference (& ctx -> buf );
2670
- vmw_resource_unreserve (res , false, NULL , 0 );
2671
- mutex_unlock (& res -> dev_priv -> cmdbuf_mutex );
2672
- }
2673
-
2674
- /**
2675
- * vmw_kms_helper_resource_prepare - Reserve and validate a resource before
2676
- * command submission.
2677
- *
2678
- * @res: Pointer to the resource. Typically a surface.
2679
- * @interruptible: Whether to perform waits as interruptible.
2680
- *
2681
- * Reserves and validates also the backup buffer if a guest-backed resource.
2682
- * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
2683
- * interrupted by a signal.
2684
- */
2685
- int vmw_kms_helper_resource_prepare (struct vmw_resource * res ,
2686
- bool interruptible ,
2687
- struct vmw_validation_ctx * ctx )
2688
- {
2689
- int ret = 0 ;
2690
-
2691
- ctx -> buf = NULL ;
2692
- ctx -> res = res ;
2693
-
2694
- if (interruptible )
2695
- ret = mutex_lock_interruptible (& res -> dev_priv -> cmdbuf_mutex );
2696
- else
2697
- mutex_lock (& res -> dev_priv -> cmdbuf_mutex );
2698
-
2699
- if (unlikely (ret != 0 ))
2700
- return - ERESTARTSYS ;
2701
-
2702
- ret = vmw_resource_reserve (res , interruptible , false);
2703
- if (ret )
2704
- goto out_unlock ;
2705
-
2706
- if (res -> backup ) {
2707
- ret = vmw_kms_helper_buffer_prepare (res -> dev_priv , res -> backup ,
2708
- interruptible ,
2709
- res -> dev_priv -> has_mob ,
2710
- false);
2711
- if (ret )
2712
- goto out_unreserve ;
2713
-
2714
- ctx -> buf = vmw_bo_reference (res -> backup );
2715
- }
2716
- ret = vmw_resource_validate (res , interruptible );
2717
- if (ret )
2718
- goto out_revert ;
2719
- return 0 ;
2720
-
2721
- out_revert :
2722
- vmw_kms_helper_buffer_revert (ctx -> buf );
2723
- out_unreserve :
2724
- vmw_resource_unreserve (res , false, NULL , 0 );
2725
- out_unlock :
2726
- mutex_unlock (& res -> dev_priv -> cmdbuf_mutex );
2727
- return ret ;
2728
- }
2729
-
2730
- /**
2731
- * vmw_kms_helper_resource_finish - Unreserve and fence a resource after
2732
- * kms command submission.
2733
- *
2734
- * @res: Pointer to the resource. Typically a surface.
2735
- * @out_fence: Optional pointer to a fence pointer. If non-NULL, a
2736
- * ref-counted fence pointer is returned here.
2737
- */
2738
- void vmw_kms_helper_resource_finish (struct vmw_validation_ctx * ctx ,
2739
- struct vmw_fence_obj * * out_fence )
2740
- {
2741
- struct vmw_resource * res = ctx -> res ;
2742
-
2743
- if (ctx -> buf || out_fence )
2744
- vmw_kms_helper_buffer_finish (res -> dev_priv , NULL , ctx -> buf ,
2745
- out_fence , NULL );
2746
-
2747
- vmw_bo_unreference (& ctx -> buf );
2748
- vmw_resource_unreserve (res , false, NULL , 0 );
2749
- mutex_unlock (& res -> dev_priv -> cmdbuf_mutex );
2750
2593
}
2751
2594
2752
2595
/**
0 commit comments