summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/qxl/qxl_fb.c
diff options
context:
space:
mode:
authorGabriel Krisman Bertazi <krisman@collabora.co.uk>2017-02-27 17:43:16 -0300
committerGerd Hoffmann <kraxel@redhat.com>2017-02-28 17:26:08 +0100
commit715a11fabbe6aa01daefc7bef34a08f4933237ce (patch)
tree339d67c1dc7aa4ad326bc67519314748482619f9 /drivers/gpu/drm/qxl/qxl_fb.c
parentaa5b62bac05d4b2bf7e5b3a006fa87625ee7beec (diff)
downloadlinux-715a11fabbe6aa01daefc7bef34a08f4933237ce.tar.gz
linux-715a11fabbe6aa01daefc7bef34a08f4933237ce.tar.bz2
linux-715a11fabbe6aa01daefc7bef34a08f4933237ce.zip
drm: qxl: Consolidate bo reservation when pinning
Every attempt to pin/unpin objects in memory requires qxl_bo_reserve/unreserve calls around the pinning operation to protect the object from concurrent access, which causes that call sequence to be reproduced every place where pinning is needed. In some cases, that sequence was not executed correctly, resulting in potential unprotected pinning operations. This commit encapsulates the reservation inside a new wrapper to make sure it is always handled properly. In cases where reservation must be done beforehand, for some reason, one can use the unprotected version __qxl_bo_pin/unpin. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170227204328.18761-3-krisman@collabora.co.uk Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/qxl/qxl_fb.c')
-rw-r--r--drivers/gpu/drm/qxl/qxl_fb.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 44e0619083fc..35124737666e 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -90,14 +90,10 @@ static struct fb_ops qxlfb_ops = {
static void qxlfb_destroy_pinned_object(struct drm_gem_object *gobj)
{
struct qxl_bo *qbo = gem_to_qxl_bo(gobj);
- int ret;
- ret = qxl_bo_reserve(qbo, false);
- if (likely(ret == 0)) {
- qxl_bo_kunmap(qbo);
- qxl_bo_unpin(qbo);
- qxl_bo_unreserve(qbo);
- }
+ qxl_bo_kunmap(qbo);
+ qxl_bo_unpin(qbo);
+
drm_gem_object_unreference_unlocked(gobj);
}
@@ -148,16 +144,13 @@ static int qxlfb_create_pinned_object(struct qxl_fbdev *qfbdev,
qbo->surf.height = mode_cmd->height;
qbo->surf.stride = mode_cmd->pitches[0];
qbo->surf.format = SPICE_SURFACE_FMT_32_xRGB;
- ret = qxl_bo_reserve(qbo, false);
- if (unlikely(ret != 0))
- goto out_unref;
+
ret = qxl_bo_pin(qbo, QXL_GEM_DOMAIN_SURFACE, NULL);
if (ret) {
- qxl_bo_unreserve(qbo);
goto out_unref;
}
ret = qxl_bo_kmap(qbo, NULL);
- qxl_bo_unreserve(qbo); /* unreserve, will be mmaped */
+
if (ret)
goto out_unref;
@@ -322,12 +315,8 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
out_unref:
if (qbo) {
- ret = qxl_bo_reserve(qbo, false);
- if (likely(ret == 0)) {
- qxl_bo_kunmap(qbo);
- qxl_bo_unpin(qbo);
- qxl_bo_unreserve(qbo);
- }
+ qxl_bo_kunmap(qbo);
+ qxl_bo_unpin(qbo);
}
if (fb && ret) {
drm_gem_object_unreference_unlocked(gobj);