From patchwork Tue Jul 25 08:01:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9861393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E32066038C for ; Tue, 25 Jul 2017 08:01:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4C5D28429 for ; Tue, 25 Jul 2017 08:01:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9C8328609; Tue, 25 Jul 2017 08:01:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66E2128429 for ; Tue, 25 Jul 2017 08:01:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F19A6E3AA; Tue, 25 Jul 2017 08:01:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 827986E39A for ; Tue, 25 Jul 2017 08:01:33 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id 184so15264384wmo.3 for ; Tue, 25 Jul 2017 01:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZpbMP5G2XGuhW/u/rNPxb9w0IT9RJKYZ0fUU8WbtCIg=; b=jRHIlAFkoURJKKIb1KCUz3zKnRu+OXMT/L5elR35u4zaqAUSPsKYvfLRn1aWBpZ2+c ODODvmedv7xMXoV9l88SqydyimVyTHn4fX88ac0Wf5ZUiL51i/TwCuR6T3YNeIuWM3Nf Ib4oYs/U+hb4nqth2XiJzPRQ8A/Sre3a9e/1Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZpbMP5G2XGuhW/u/rNPxb9w0IT9RJKYZ0fUU8WbtCIg=; b=Ao8IsquUkZnPUIS9CBX8bX5xkV52okmXggG33+DYhOw3+Rlw+Gh89d1Oqo4Z1AieLE GGw1uXMswb6JhZWKAPs65X0YNuXMvVAkWfygQML7xerOUioOTgxk3JP2o/v7Br6NdYDy ppKT22iJNHNTC2ID+HWYKIP6IzhTya1or8692CKJ4opVNdLqZrmDtEs2H1ozWRZlnORv 27K4EdbatcrFj/aIdqTeuOu+OUCajm2NBzap7rTGd7h+ZJXGGdAafT7cDiguKvD5NpXE umDATGacaFHQrJvUdmL7gW6gnB7M1qYzXXrgdDUZ3AiVlRir/rGErhNQe1aN+ex4OF01 Thbw== X-Gm-Message-State: AIVw110VXFr6Qzf0WjgmvKxGju18vy7QnepvB647XOuZybjpMMn7LaOn q+Jefl0bIAUrArs3 X-Received: by 10.28.74.14 with SMTP id x14mr6527153wma.15.1500969691973; Tue, 25 Jul 2017 01:01:31 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5640:0:960b:2678:e223:c1c6]) by smtp.gmail.com with ESMTPSA id j8sm14228384wrj.10.2017.07.25.01.01.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jul 2017 01:01:31 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Subject: [PATCH 2/8] drm: Don't update property values for atomic drivers Date: Tue, 25 Jul 2017 10:01:16 +0200 Message-Id: <20170725080122.20548-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170725080122.20548-1-daniel.vetter@ffwll.ch> References: <20170725080122.20548-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , DRI Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Atomic drivers only use the property value store for immutable (i.e. can't be set by userspace, but the kernel can still adjust it) properties. The only tricky part is the removal of the update in drm_atomic_helper_update_legacy_modeset_state(). This was added in commit 8c10342cb48f3140d9abeadcfd2fa6625d447282 (tag: topic/drm-misc-2015-07-28) Author: Maarten Lankhorst Date: Mon Jul 27 13:24:29 2015 +0200 drm/atomic: Update legacy DPMS state during modesets, v3. by copying it from the i915 code, where it was originally added in commit 68d3472047a572936551f8ff0b6f4016c5a1fdef Author: Daniel Vetter Date: Thu Sep 6 22:08:35 2012 +0200 drm/i915: update dpms property in set_mode for the legacy modeset code. The reason we needed this hack was that i915 didn't yet set DRIVER_ATOMIC, and we checked for that instead of the newer-ish drm_drv_uses_atomic_modeset(), which avoids such troubles. With the correct feature checks this isn't needed anymore at all. Also make sure that drivers don't accidentally get this wrong by making the exported version of drm_object_property_get_value() only work for legacy drivers. Only gma500 uses it anyway. Cc: Maarten Lankhorst Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_atomic_helper.c | 4 --- drivers/gpu/drm/drm_connector.c | 3 +-- drivers/gpu/drm/drm_crtc.c | 2 +- drivers/gpu/drm/drm_mode_object.c | 49 +++++++++++++++++++++++-------------- drivers/gpu/drm/drm_plane.c | 2 +- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 7582bbc5decc..4a960c741e35 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -921,16 +921,12 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, crtc = new_conn_state->crtc; if ((!crtc && old_conn_state->crtc) || (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) { - struct drm_property *dpms_prop = - dev->mode_config.dpms_property; int mode = DRM_MODE_DPMS_OFF; if (crtc && crtc->state->active) mode = DRM_MODE_DPMS_ON; connector->dpms = mode; - drm_object_property_set_value(&connector->base, - dpms_prop, mode); } } diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8072e6e4c62c..349104eadefe 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1225,8 +1225,7 @@ int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, } else if (connector->funcs->set_property) ret = connector->funcs->set_property(connector, property, value); - /* store the property value if successful */ - if (!ret) + if (!ret && drm_drv_uses_atomic_modeset(property->dev)) drm_object_property_set_value(&connector->base, property, value); return ret; } diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 5af25ce5bf7c..7d4fcdd34342 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -736,7 +736,7 @@ int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj, if (crtc->funcs->set_property) ret = crtc->funcs->set_property(crtc, property, value); - if (!ret) + if (!ret && drm_drv_uses_atomic_modeset(property->dev)) drm_object_property_set_value(obj, property, value); return ret; diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index da9a9adbcc98..92743a796bf0 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -233,6 +233,9 @@ int drm_object_property_set_value(struct drm_mode_object *obj, { int i; + WARN_ON(drm_drv_uses_atomic_modeset(property->dev) && + !(property->flags & DRM_MODE_PROP_IMMUTABLE)); + for (i = 0; i < obj->properties->count; i++) { if (obj->properties->properties[i] == property) { obj->properties->values[i] = val; @@ -244,24 +247,7 @@ int drm_object_property_set_value(struct drm_mode_object *obj, } EXPORT_SYMBOL(drm_object_property_set_value); -/** - * drm_object_property_get_value - retrieve the value of a property - * @obj: drm mode object to get property value from - * @property: property to retrieve - * @val: storage for the property value - * - * This function retrieves the softare state of the given property for the given - * property. Since there is no driver callback to retrieve the current property - * value this might be out of sync with the hardware, depending upon the driver - * and property. - * - * Atomic drivers should never call this function directly, the core will read - * out property values through the various ->atomic_get_property callbacks. - * - * Returns: - * Zero on success, error code on failure. - */ -int drm_object_property_get_value(struct drm_mode_object *obj, +int __drm_object_property_get_value(struct drm_mode_object *obj, struct drm_property *property, uint64_t *val) { int i; @@ -284,6 +270,31 @@ int drm_object_property_get_value(struct drm_mode_object *obj, return -EINVAL; } + +/** + * drm_object_property_get_value - retrieve the value of a property + * @obj: drm mode object to get property value from + * @property: property to retrieve + * @val: storage for the property value + * + * This function retrieves the softare state of the given property for the given + * property. Since there is no driver callback to retrieve the current property + * value this might be out of sync with the hardware, depending upon the driver + * and property. + * + * Atomic drivers should never call this function directly, the core will read + * out property values through the various ->atomic_get_property callbacks. + * + * Returns: + * Zero on success, error code on failure. + */ +int drm_object_property_get_value(struct drm_mode_object *obj, + struct drm_property *property, uint64_t *val) +{ + WARN_ON(drm_drv_uses_atomic_modeset(property->dev)); + + return __drm_object_property_get_value(obj, property, val); +} EXPORT_SYMBOL(drm_object_property_get_value); /* helper for getconnector and getproperties ioctls */ @@ -302,7 +313,7 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, continue; if (*arg_count_props > count) { - ret = drm_object_property_get_value(obj, prop, &val); + ret = __drm_object_property_get_value(obj, prop, &val); if (ret) return ret; diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 5dc8c4350602..b4ffd0455200 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -330,7 +330,7 @@ int drm_mode_plane_set_obj_prop(struct drm_plane *plane, if (plane->funcs->set_property) ret = plane->funcs->set_property(plane, property, value); - if (!ret) + if (!ret && drm_drv_uses_atomic_modeset(property->dev)) drm_object_property_set_value(obj, property, value); return ret;