From patchwork Tue Mar 21 08:13:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9636171 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 0EE21602CC for ; Tue, 21 Mar 2017 08:14:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F25721FF8F for ; Tue, 21 Mar 2017 08:14:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6CB227F07; Tue, 21 Mar 2017 08:14:17 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham 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 61E561FF8F for ; Tue, 21 Mar 2017 08:14:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 79ABD6E226; Tue, 21 Mar 2017 08:14:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4579F6E21F; Tue, 21 Mar 2017 08:14:06 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id l37so21314526wrc.3; Tue, 21 Mar 2017 01:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QwWm6UlruNNFubKN3E9fv+fBo3y+u1PBJoydJlQeMdU=; b=Q5eInUWolzz+dIWMnICRn68BZ39rOe6wpr4HiwejBYpksx3MGnd9r/lMzKGYjPaEk0 mTDdjE4EHsV7M43sI0zv4eLeFSiUh91oLo+kQ4XhGrsiotA6q0YEzl+zf9YopA4yPyqY aep5/wwGMl53NwWIowc0pXAfGJPeGZAILMifyVjimcHd/e6cu9SKJQ/JbHM59FC3NlCU eo21yd4jwvZ0q1uD1RTd4js8YnkrQ/Wq9XNFwOwSP3NMkHxv5hKEX7Y9udB3LaFG8NwC qqOR84Mg7C4+/RkE9PdDL+a7RTE48vgAf4wF1mfK0vs/1R5pvo3MPwHnGdLTNwcaYdUI y5IQ== 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=QwWm6UlruNNFubKN3E9fv+fBo3y+u1PBJoydJlQeMdU=; b=Gzedzh/Kl2PPTlQyOKVefuY4cUqsqSM4BMJb4raastdL2B3HNkNyou5QzFC109pQZs qlXZjbC5HKOPj0w9j8CSlAfmMb4PIu4D4chptGPbONNB4fOOsVcUFaeVhfGVXM/YW34y kRe3Dvi4xVDbdDaEJb7r0xx2ZK8w8l+whXFWjrnzEMkRqT1DMwluVu4m0D22BU6hTUV7 13UH7aOvkZyVLi47z/TDrbVgZ++0ditcPYbjNmjTMy4Q0pzF7DDcUJRZqYN3vJLlNBxk rwv0nbRHCIxMjKDdHUWmvvD50TFCz0IregvD6FjbXzwUiRqu4W8TD52VduE7Ra/ugrS6 urpg== X-Gm-Message-State: AFeK/H0jfHn7UawyF5eDWZb22qih9dw+QGhJALWwMS70tDDDYFiAOi6ktFmJHfsPcnulmQ== X-Received: by 10.223.147.162 with SMTP id 31mr28093087wrp.133.1490084044753; Tue, 21 Mar 2017 01:14:04 -0700 (PDT) Received: from localhost (port-52488.pppoe.wtnet.de. [46.59.205.174]) by smtp.gmail.com with ESMTPSA id j24sm18490709wrd.36.2017.03.21.01.14.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Mar 2017 01:14:04 -0700 (PDT) From: Thierry Reding To: Daniel Vetter Date: Tue, 21 Mar 2017 09:13:52 +0100 Message-Id: <20170321081358.27237-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170321081358.27237-1-thierry.reding@gmail.com> References: <20170321081358.27237-1-thierry.reding@gmail.com> Cc: John Stultz , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v3 04/10] drm/fb-helper: Push down modeset lock into FB helpers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Move the modeset locking from drivers into FB helpers. Tested-by: John Stultz Signed-off-by: Thierry Reding Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 39 ++++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_dp_mst.c | 3 --- drivers/gpu/drm/radeon/radeon_dp_mst.c | 7 ------ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 17fd98fe4a1f..6af80afc4f40 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -109,8 +109,8 @@ static DEFINE_MUTEX(kernel_fb_helper_lock); for (({ lockdep_assert_held(&(fbh)->dev->mode_config.mutex); }), \ i__ = 0; i__ < (fbh)->connector_count; i__++) -int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, - struct drm_connector *connector) +static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) { struct drm_fb_helper_connector **temp; struct drm_fb_helper_connector *conn; @@ -143,6 +143,20 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, fb_helper->connector_info[fb_helper->connector_count++] = conn; return 0; } + +int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) +{ + int err; + + mutex_lock(&fb_helper->dev->mode_config.mutex); + + err = __drm_fb_helper_add_one_connector(fb_helper, connector); + + mutex_unlock(&fb_helper->dev->mode_config.mutex); + + return err; +} EXPORT_SYMBOL(drm_fb_helper_add_one_connector); /** @@ -172,8 +186,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) mutex_lock(&dev->mode_config.mutex); drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { - ret = drm_fb_helper_add_one_connector(fb_helper, connector); - + ret = __drm_fb_helper_add_one_connector(fb_helper, connector); if (ret) goto fail; } @@ -198,8 +211,8 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); -int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, - struct drm_connector *connector) +static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) { struct drm_fb_helper_connector *fb_helper_connector; int i, j; @@ -227,6 +240,20 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, return 0; } + +int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, + struct drm_connector *connector) +{ + int err; + + mutex_lock(&fb_helper->dev->mode_config.mutex); + + err = __drm_fb_helper_remove_one_connector(fb_helper, connector); + + mutex_unlock(&fb_helper->dev->mode_config.mutex); + + return err; +} EXPORT_SYMBOL(drm_fb_helper_remove_one_connector); static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper) diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c index 094cbdcbcd6d..8336c5c6f45d 100644 --- a/drivers/gpu/drm/i915/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/intel_dp_mst.c @@ -484,15 +484,12 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_connector *connector) { struct intel_connector *intel_connector = to_intel_connector(connector); - struct drm_device *dev = connector->dev; drm_connector_unregister(connector); /* need to nuke the connector */ - drm_modeset_lock_all(dev); intel_connector_remove_from_fbdev(intel_connector); intel_connector->mst_port = NULL; - drm_modeset_unlock_all(dev); drm_connector_unreference(&intel_connector->base); DRM_DEBUG_KMS("\n"); diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c index 7d5ada3980dc..b1855cf0ae7a 100644 --- a/drivers/gpu/drm/radeon/radeon_dp_mst.c +++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c @@ -300,9 +300,7 @@ static void radeon_dp_register_mst_connector(struct drm_connector *connector) struct drm_device *dev = connector->dev; struct radeon_device *rdev = dev->dev_private; - drm_modeset_lock_all(dev); radeon_fb_add_connector(rdev, connector); - drm_modeset_unlock_all(dev); drm_connector_register(connector); } @@ -315,13 +313,8 @@ static void radeon_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct radeon_device *rdev = dev->dev_private; drm_connector_unregister(connector); - /* need to nuke the connector */ - drm_modeset_lock_all(dev); - /* dpms off */ radeon_fb_remove_connector(rdev, connector); - drm_connector_cleanup(connector); - drm_modeset_unlock_all(dev); kfree(connector); DRM_DEBUG_KMS("\n");