diff mbox

[03/11] drm: Retain reference to blob properties in lookup

Message ID 1432298094-22239-4-git-send-email-daniels@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Stone May 22, 2015, 12:34 p.m. UTC
When we look up a blob property, make sure we retain a reference to the
blob for the lifetime.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Tested-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/drm_crtc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Daniel Vetter May 22, 2015, 2:11 p.m. UTC | #1
On Fri, May 22, 2015 at 01:34:46PM +0100, Daniel Stone wrote:
> When we look up a blob property, make sure we retain a reference to the
> blob for the lifetime.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Tested-by: Sean Paul <seanpaul@chromium.org>
> ---
>  drivers/gpu/drm/drm_crtc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 7e5085f..da2b117 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -4661,7 +4661,9 @@ bool drm_property_change_valid_get(struct drm_property *property,
>  		for (i = 0; i < property->num_values; i++)
>  			valid_mask |= (1ULL << property->values[i]);
>  		return !(value & ~valid_mask);
> -	} else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) {
> +	} else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB) ||
> +		   (drm_property_type_is(property, DRM_MODE_PROP_OBJECT) &&
> +		    property->values[0] == DRM_MODE_OBJECT_BLOB)) {
>  		struct drm_property_blob *blob;
>  
>  		if (value == 0)
> @@ -4709,6 +4711,8 @@ void drm_property_change_valid_put(struct drm_property *property,
>  	if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) {
>  		if (property->values[0] == DRM_MODE_OBJECT_FB)
>  			drm_framebuffer_unreference(obj_to_fb(ref));
> +		else if (property->values[0] == DRM_MODE_OBJECT_BLOB)
> +			drm_property_unreference_blob(obj_to_blob(ref));

Hm why this? I know it's a bit inconsistent that for all the other atomic
obj props we use DRM_MODE_PROP_OBJ, but for blobs we have a special one. I
guess I'll see the reason later on, but without more details I'd vote to
not subsume props under the generic PROP_OBJECT.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 7e5085f..da2b117 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4661,7 +4661,9 @@  bool drm_property_change_valid_get(struct drm_property *property,
 		for (i = 0; i < property->num_values; i++)
 			valid_mask |= (1ULL << property->values[i]);
 		return !(value & ~valid_mask);
-	} else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) {
+	} else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB) ||
+		   (drm_property_type_is(property, DRM_MODE_PROP_OBJECT) &&
+		    property->values[0] == DRM_MODE_OBJECT_BLOB)) {
 		struct drm_property_blob *blob;
 
 		if (value == 0)
@@ -4709,6 +4711,8 @@  void drm_property_change_valid_put(struct drm_property *property,
 	if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) {
 		if (property->values[0] == DRM_MODE_OBJECT_FB)
 			drm_framebuffer_unreference(obj_to_fb(ref));
+		else if (property->values[0] == DRM_MODE_OBJECT_BLOB)
+			drm_property_unreference_blob(obj_to_blob(ref));
 	}
 }