@@ -12656,6 +12656,42 @@ static void add_rps_boost_after_vblank(struct drm_crtc *crtc,
12656
12656
add_wait_queue (drm_crtc_vblank_waitqueue (crtc ), & wait -> wait );
12657
12657
}
12658
12658
12659
+ static int intel_plane_pin_fb (struct intel_plane_state * plane_state )
12660
+ {
12661
+ struct intel_plane * plane = to_intel_plane (plane_state -> base .plane );
12662
+ struct drm_i915_private * dev_priv = to_i915 (plane -> base .dev );
12663
+ struct drm_framebuffer * fb = plane_state -> base .fb ;
12664
+ struct i915_vma * vma ;
12665
+
12666
+ if (plane -> id == PLANE_CURSOR &&
12667
+ INTEL_INFO (dev_priv )-> cursor_needs_physical ) {
12668
+ struct drm_i915_gem_object * obj = intel_fb_obj (fb );
12669
+ const int align = intel_cursor_alignment (dev_priv );
12670
+
12671
+ return i915_gem_object_attach_phys (obj , align );
12672
+ }
12673
+
12674
+ vma = intel_pin_and_fence_fb_obj (fb ,
12675
+ plane_state -> base .rotation ,
12676
+ intel_plane_uses_fence (plane_state ),
12677
+ & plane_state -> flags );
12678
+ if (IS_ERR (vma ))
12679
+ return PTR_ERR (vma );
12680
+
12681
+ plane_state -> vma = vma ;
12682
+
12683
+ return 0 ;
12684
+ }
12685
+
12686
+ static void intel_plane_unpin_fb (struct intel_plane_state * old_plane_state )
12687
+ {
12688
+ struct i915_vma * vma ;
12689
+
12690
+ vma = fetch_and_zero (& old_plane_state -> vma );
12691
+ if (vma )
12692
+ intel_unpin_fb_vma (vma , old_plane_state -> flags );
12693
+ }
12694
+
12659
12695
/**
12660
12696
* intel_prepare_plane_fb - Prepare fb for usage on plane
12661
12697
* @plane: drm plane to prepare for
@@ -12730,23 +12766,7 @@ intel_prepare_plane_fb(struct drm_plane *plane,
12730
12766
return ret ;
12731
12767
}
12732
12768
12733
- if (plane -> type == DRM_PLANE_TYPE_CURSOR &&
12734
- INTEL_INFO (dev_priv )-> cursor_needs_physical ) {
12735
- const int align = intel_cursor_alignment (dev_priv );
12736
-
12737
- ret = i915_gem_object_attach_phys (obj , align );
12738
- } else {
12739
- struct i915_vma * vma ;
12740
-
12741
- vma = intel_pin_and_fence_fb_obj (fb ,
12742
- new_state -> rotation ,
12743
- intel_plane_uses_fence (to_intel_plane_state (new_state )),
12744
- & to_intel_plane_state (new_state )-> flags );
12745
- if (!IS_ERR (vma ))
12746
- to_intel_plane_state (new_state )-> vma = vma ;
12747
- else
12748
- ret = PTR_ERR (vma );
12749
- }
12769
+ ret = intel_plane_pin_fb (to_intel_plane_state (new_state ));
12750
12770
12751
12771
i915_gem_object_wait_priority (obj , 0 , I915_PRIORITY_DISPLAY );
12752
12772
@@ -12790,15 +12810,12 @@ void
12790
12810
intel_cleanup_plane_fb (struct drm_plane * plane ,
12791
12811
struct drm_plane_state * old_state )
12792
12812
{
12793
- struct i915_vma * vma ;
12813
+ struct drm_i915_private * dev_priv = to_i915 ( plane -> dev ) ;
12794
12814
12795
12815
/* Should only be called after a successful intel_prepare_plane_fb()! */
12796
- vma = fetch_and_zero (& to_intel_plane_state (old_state )-> vma );
12797
- if (vma ) {
12798
- mutex_lock (& plane -> dev -> struct_mutex );
12799
- intel_unpin_fb_vma (vma , to_intel_plane_state (old_state )-> flags );
12800
- mutex_unlock (& plane -> dev -> struct_mutex );
12801
- }
12816
+ mutex_lock (& dev_priv -> drm .struct_mutex );
12817
+ intel_plane_unpin_fb (to_intel_plane_state (old_state ));
12818
+ mutex_unlock (& dev_priv -> drm .struct_mutex );
12802
12819
}
12803
12820
12804
12821
int
@@ -13084,7 +13101,6 @@ intel_legacy_cursor_update(struct drm_plane *plane,
13084
13101
struct intel_plane * intel_plane = to_intel_plane (plane );
13085
13102
struct drm_framebuffer * old_fb ;
13086
13103
struct drm_crtc_state * crtc_state = crtc -> state ;
13087
- struct i915_vma * old_vma , * vma ;
13088
13104
13089
13105
/*
13090
13106
* When crtc is inactive or there is a modeset pending,
@@ -13143,28 +13159,9 @@ intel_legacy_cursor_update(struct drm_plane *plane,
13143
13159
if (ret )
13144
13160
goto out_free ;
13145
13161
13146
- if (INTEL_INFO (dev_priv )-> cursor_needs_physical ) {
13147
- int align = intel_cursor_alignment (dev_priv );
13148
-
13149
- ret = i915_gem_object_attach_phys (intel_fb_obj (fb ), align );
13150
- if (ret ) {
13151
- DRM_DEBUG_KMS ("failed to attach phys object\n" );
13152
- goto out_unlock ;
13153
- }
13154
- } else {
13155
- vma = intel_pin_and_fence_fb_obj (fb ,
13156
- new_plane_state -> rotation ,
13157
- false,
13158
- & to_intel_plane_state (new_plane_state )-> flags );
13159
- if (IS_ERR (vma )) {
13160
- DRM_DEBUG_KMS ("failed to pin object\n" );
13161
-
13162
- ret = PTR_ERR (vma );
13163
- goto out_unlock ;
13164
- }
13165
-
13166
- to_intel_plane_state (new_plane_state )-> vma = vma ;
13167
- }
13162
+ ret = intel_plane_pin_fb (to_intel_plane_state (new_plane_state ));
13163
+ if (ret )
13164
+ goto out_unlock ;
13168
13165
13169
13166
old_fb = old_plane_state -> fb ;
13170
13167
@@ -13184,10 +13181,7 @@ intel_legacy_cursor_update(struct drm_plane *plane,
13184
13181
intel_plane -> disable_plane (intel_plane , to_intel_crtc (crtc ));
13185
13182
}
13186
13183
13187
- old_vma = fetch_and_zero (& to_intel_plane_state (old_plane_state )-> vma );
13188
- if (old_vma )
13189
- intel_unpin_fb_vma (old_vma ,
13190
- to_intel_plane_state (old_plane_state )-> flags );
13184
+ intel_plane_unpin_fb (to_intel_plane_state (old_plane_state ));
13191
13185
13192
13186
out_unlock :
13193
13187
mutex_unlock (& dev_priv -> drm .struct_mutex );
0 commit comments