diff options
author | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2016-12-06 12:47:17 -0500 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2016-12-07 08:16:55 -0500 |
commit | 35f8cc3b9a92c661e5331d64fdfdedb518891d5c (patch) | |
tree | 4c79cc04e49363fb7614318f9cc390c45e92e6c7 | |
parent | 8f34a548718ebb4becb4f829800552c48284ce9e (diff) |
drm/fence: add drm_crtc_create_fence()
Instead of dealing with crtc details inside drm_atomic.c we should
just export a function that creates a new crtc fence for us and
use that.
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1481046437-18778-1-git-send-email-gustavo@padovan.org
-rw-r--r-- | drivers/gpu/drm/drm_atomic.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 18 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_crtc_internal.h | 2 |
3 files changed, 19 insertions, 17 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 19d7bcb88217..72fa5b20baf1 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c | |||
@@ -1864,20 +1864,6 @@ EXPORT_SYMBOL(drm_atomic_clean_old_fb); | |||
1864 | * helpers and for the DRM event handling for existing userspace. | 1864 | * helpers and for the DRM event handling for existing userspace. |
1865 | */ | 1865 | */ |
1866 | 1866 | ||
1867 | static struct dma_fence *get_crtc_fence(struct drm_crtc *crtc) | ||
1868 | { | ||
1869 | struct dma_fence *fence; | ||
1870 | |||
1871 | fence = kzalloc(sizeof(*fence), GFP_KERNEL); | ||
1872 | if (!fence) | ||
1873 | return NULL; | ||
1874 | |||
1875 | dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock, | ||
1876 | crtc->fence_context, ++crtc->fence_seqno); | ||
1877 | |||
1878 | return fence; | ||
1879 | } | ||
1880 | |||
1881 | struct drm_out_fence_state { | 1867 | struct drm_out_fence_state { |
1882 | s64 __user *out_fence_ptr; | 1868 | s64 __user *out_fence_ptr; |
1883 | struct sync_file *sync_file; | 1869 | struct sync_file *sync_file; |
@@ -1959,7 +1945,7 @@ static int prepare_crtc_signaling(struct drm_device *dev, | |||
1959 | f[*num_fences].out_fence_ptr = fence_ptr; | 1945 | f[*num_fences].out_fence_ptr = fence_ptr; |
1960 | *fence_state = f; | 1946 | *fence_state = f; |
1961 | 1947 | ||
1962 | fence = get_crtc_fence(crtc); | 1948 | fence = drm_crtc_create_fence(crtc); |
1963 | if (!fence) | 1949 | if (!fence) |
1964 | return -ENOMEM; | 1950 | return -ENOMEM; |
1965 | 1951 | ||
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 90931e039731..e75f62cd8a65 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -152,6 +152,8 @@ static void drm_crtc_crc_fini(struct drm_crtc *crtc) | |||
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | 154 | ||
155 | static const struct dma_fence_ops drm_crtc_fence_ops; | ||
156 | |||
155 | static struct drm_crtc *fence_to_crtc(struct dma_fence *fence) | 157 | static struct drm_crtc *fence_to_crtc(struct dma_fence *fence) |
156 | { | 158 | { |
157 | BUG_ON(fence->ops != &drm_crtc_fence_ops); | 159 | BUG_ON(fence->ops != &drm_crtc_fence_ops); |
@@ -177,13 +179,27 @@ static bool drm_crtc_fence_enable_signaling(struct dma_fence *fence) | |||
177 | return true; | 179 | return true; |
178 | } | 180 | } |
179 | 181 | ||
180 | const struct dma_fence_ops drm_crtc_fence_ops = { | 182 | static const struct dma_fence_ops drm_crtc_fence_ops = { |
181 | .get_driver_name = drm_crtc_fence_get_driver_name, | 183 | .get_driver_name = drm_crtc_fence_get_driver_name, |
182 | .get_timeline_name = drm_crtc_fence_get_timeline_name, | 184 | .get_timeline_name = drm_crtc_fence_get_timeline_name, |
183 | .enable_signaling = drm_crtc_fence_enable_signaling, | 185 | .enable_signaling = drm_crtc_fence_enable_signaling, |
184 | .wait = dma_fence_default_wait, | 186 | .wait = dma_fence_default_wait, |
185 | }; | 187 | }; |
186 | 188 | ||
189 | struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) | ||
190 | { | ||
191 | struct dma_fence *fence; | ||
192 | |||
193 | fence = kzalloc(sizeof(*fence), GFP_KERNEL); | ||
194 | if (!fence) | ||
195 | return NULL; | ||
196 | |||
197 | dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock, | ||
198 | crtc->fence_context, ++crtc->fence_seqno); | ||
199 | |||
200 | return fence; | ||
201 | } | ||
202 | |||
187 | /** | 203 | /** |
188 | * drm_crtc_init_with_planes - Initialise a new CRTC object with | 204 | * drm_crtc_init_with_planes - Initialise a new CRTC object with |
189 | * specified primary and cursor planes. | 205 | * specified primary and cursor planes. |
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 33b17d0b127e..cdf6860c9d22 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h | |||
@@ -43,7 +43,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc, | |||
43 | int drm_crtc_register_all(struct drm_device *dev); | 43 | int drm_crtc_register_all(struct drm_device *dev); |
44 | void drm_crtc_unregister_all(struct drm_device *dev); | 44 | void drm_crtc_unregister_all(struct drm_device *dev); |
45 | 45 | ||
46 | extern const struct dma_fence_ops drm_crtc_fence_ops; | 46 | struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc); |
47 | 47 | ||
48 | /* IOCTLs */ | 48 | /* IOCTLs */ |
49 | int drm_mode_getcrtc(struct drm_device *dev, | 49 | int drm_mode_getcrtc(struct drm_device *dev, |