drm/atomic: Wire file_priv through for property changes
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 28 Feb 2019 14:49:09 +0000 (15:49 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 24 Apr 2019 09:30:52 +0000 (11:30 +0200)
We need this to make sure lessees can only connect their
plane/connectors to crtc objects they own. And note that this is
irrespective of whether the lessor is atomic or not, lessor cannot
prevent lessees from enabling atomic.

Cc: stable@vger.kernel.org
Cc: Keith Packard <keithp@keithp.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190228144910.26488-7-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_atomic_uapi.c
drivers/gpu/drm/drm_crtc_internal.h
drivers/gpu/drm/drm_mode_object.c

index ea797d4c82ee4b3bd2f0bf5b4772dd403708abad..77d16f5d4a9aa365e983734c3f9e264374666ece 100644 (file)
@@ -512,8 +512,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
 }
 
 static int drm_atomic_plane_set_property(struct drm_plane *plane,
-               struct drm_plane_state *state, struct drm_property *property,
-               uint64_t val)
+               struct drm_plane_state *state, struct drm_file *file_priv,
+               struct drm_property *property, uint64_t val)
 {
        struct drm_device *dev = plane->dev;
        struct drm_mode_config *config = &dev->mode_config;
@@ -521,7 +521,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
        int ret;
 
        if (property == config->prop_fb_id) {
-               struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
+               struct drm_framebuffer *fb;
+               fb = drm_framebuffer_lookup(dev, file_priv, val);
                drm_atomic_set_fb_for_plane(state, fb);
                if (fb)
                        drm_framebuffer_put(fb);
@@ -537,7 +538,7 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
                        return -EINVAL;
 
        } else if (property == config->prop_crtc_id) {
-               struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val);
+               struct drm_crtc *crtc = drm_crtc_find(dev, file_priv, val);
                return drm_atomic_set_crtc_for_plane(state, crtc);
        } else if (property == config->prop_crtc_x) {
                state->crtc_x = U642I64(val);
@@ -668,14 +669,14 @@ static int drm_atomic_set_writeback_fb_for_connector(
 }
 
 static int drm_atomic_connector_set_property(struct drm_connector *connector,
-               struct drm_connector_state *state, struct drm_property *property,
-               uint64_t val)
+               struct drm_connector_state *state, struct drm_file *file_priv,
+               struct drm_property *property, uint64_t val)
 {
        struct drm_device *dev = connector->dev;
        struct drm_mode_config *config = &dev->mode_config;
 
        if (property == config->prop_crtc_id) {
-               struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val);
+               struct drm_crtc *crtc = drm_crtc_find(dev, file_priv, val);
                return drm_atomic_set_crtc_for_connector(state, crtc);
        } else if (property == config->dpms_property) {
                /* setting DPMS property requires special handling, which
@@ -736,8 +737,10 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
        } else if (property == connector->colorspace_property) {
                state->colorspace = val;
        } else if (property == config->writeback_fb_id_property) {
-               struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
-               int ret = drm_atomic_set_writeback_fb_for_connector(state, fb);
+               struct drm_framebuffer *fb;
+               int ret;
+               fb = drm_framebuffer_lookup(dev, file_priv, val);
+               ret = drm_atomic_set_writeback_fb_for_connector(state, fb);
                if (fb)
                        drm_framebuffer_put(fb);
                return ret;
@@ -934,6 +937,7 @@ out:
 }
 
 int drm_atomic_set_property(struct drm_atomic_state *state,
+                           struct drm_file *file_priv,
                            struct drm_mode_object *obj,
                            struct drm_property *prop,
                            uint64_t prop_value)
@@ -956,7 +960,8 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
                }
 
                ret = drm_atomic_connector_set_property(connector,
-                               connector_state, prop, prop_value);
+                               connector_state, file_priv,
+                               prop, prop_value);
                break;
        }
        case DRM_MODE_OBJECT_CRTC: {
@@ -984,7 +989,8 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
                }
 
                ret = drm_atomic_plane_set_property(plane,
-                               plane_state, prop, prop_value);
+                               plane_state, file_priv,
+                               prop, prop_value);
                break;
        }
        default:
@@ -1354,8 +1360,8 @@ retry:
                                goto out;
                        }
 
-                       ret = drm_atomic_set_property(state, obj, prop,
-                                                     prop_value);
+                       ret = drm_atomic_set_property(state, file_priv,
+                                                     obj, prop, prop_value);
                        if (ret) {
                                drm_mode_object_put(obj);
                                goto out;
index 216f2a9ee3d406e2fed7f21492d1590eef4025f9..0719a235d6cc64ace9a49c5d863921a67ac1c1ca 100644 (file)
@@ -214,6 +214,7 @@ int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
                                     struct drm_connector *connector,
                                     int mode);
 int drm_atomic_set_property(struct drm_atomic_state *state,
+                           struct drm_file *file_priv,
                            struct drm_mode_object *obj,
                            struct drm_property *prop,
                            uint64_t prop_value);
index a9005c1c23848791fce2a6b6a4c9920581341069..f32507e65b79485fc5b0e9cb7963a87c4da9231b 100644 (file)
@@ -451,6 +451,7 @@ static int set_property_legacy(struct drm_mode_object *obj,
 }
 
 static int set_property_atomic(struct drm_mode_object *obj,
+                              struct drm_file *file_priv,
                               struct drm_property *prop,
                               uint64_t prop_value)
 {
@@ -477,7 +478,7 @@ retry:
                                                       obj_to_connector(obj),
                                                       prop_value);
        } else {
-               ret = drm_atomic_set_property(state, obj, prop, prop_value);
+               ret = drm_atomic_set_property(state, file_priv, obj, prop, prop_value);
                if (ret)
                        goto out;
                ret = drm_atomic_commit(state);
@@ -520,7 +521,7 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
                goto out_unref;
 
        if (drm_drv_uses_atomic_modeset(property->dev))
-               ret = set_property_atomic(arg_obj, property, arg->value);
+               ret = set_property_atomic(arg_obj, file_priv, property, arg->value);
        else
                ret = set_property_legacy(arg_obj, property, arg->value);