From patchwork Tue Jun 7 15:26:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9161651 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 EC32160571 for ; Tue, 7 Jun 2016 15:26:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE1C1264F4 for ; Tue, 7 Jun 2016 15:26:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D30A42723E; Tue, 7 Jun 2016 15:26:50 +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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7002E264F4 for ; Tue, 7 Jun 2016 15:26:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6273C6E7E3; Tue, 7 Jun 2016 15:26:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23E116E7DE; Tue, 7 Jun 2016 15:26:37 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id k184so18709765wme.2; Tue, 07 Jun 2016 08:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EcJY4/une9AeNRCuiy+T5qfn2Unkjg5QOZvDDj7lIqY=; b=B0i4A/LJJ3XF+0DtV5Y6VXKxUFX92VMx34rwnRDoCuNMWM2wRv3wqqMuX2j1y4whnz cVSFWX/8KzGV5H5MfFxINs4TSHYDFBjBpxEDgDi9EqzC0eY0SO41o/fnJ/UPpt72bYQE GYj/fOWa7eP4kg08EqgsIe8oORkWT2ROloVrURtytfZSNudvYB0tmohCIWUofsubqbWX 9wHsX7aZ8nmH36P5fHzZfh/W0NhFFLQllotujalOU8RA/fCb/Ox12zj4TBPBK1rt6E7X 3K/pUTkk5/sEvuZCun7+7bJt9/nEwUHPK8BWK7NhaON22ZrXdMDWMbjtYhsrIHWcmXev 8BJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EcJY4/une9AeNRCuiy+T5qfn2Unkjg5QOZvDDj7lIqY=; b=TRb6SRu7/ydpJfICcQVRmj/PTIuQ1RzTG+BHJ+Q9wXn0zKdBPEDIatVovq7Jur2ELJ HBOn8KsPZw5LA69WTxm6URlTDmyJz8sCH1Lq+XuFEn1oPf6oxG75JQGAtUwu/pTbbbgw LNZSYYHOUKKIyl9NLG1Wdkt62Cef+PDAuBXlkklHh4Vn0GJNAeWVWXvVYuusxGhCr41M qOgxZi44iXxWnGBapAvyBsJOre51AwAvWujh8lDskcWqduhreE6YCr4QWtU+TQdn5HXd QJRiRDv3VXhZc+z2uw9WNiuDmHySWmXv4EVP+gsvlSfMHbgVQyW0jT00wSN9blAtULdS 1PtA== X-Gm-Message-State: ALyK8tLSBNNuGNs2T7ixsl18NA5nrtHaEowY0aO7B4SS/PqoyY+ZfuiB5XPTIXBIiHJ8/A== X-Received: by 10.194.239.100 with SMTP id vr4mr21412452wjc.19.1465313195227; Tue, 07 Jun 2016 08:26:35 -0700 (PDT) Received: from localhost (port-9435.pppoe.wtnet.de. [84.46.36.255]) by smtp.gmail.com with ESMTPSA id y1sm26013779wjl.31.2016.06.07.08.26.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 08:26:34 -0700 (PDT) From: Thierry Reding To: Daniel Vetter Date: Tue, 7 Jun 2016 17:26:20 +0200 Message-Id: <20160607152625.9511-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160607152625.9511-1-thierry.reding@gmail.com> References: <20160607152625.9511-1-thierry.reding@gmail.com> Cc: Boris Brezillon , Joonyoung Shim , Xinliang Liu , Chen Feng , intel-gfx@lists.freedesktop.org, Seung-Woo Kim , Xinwei Kong , dri-devel@lists.freedesktop.org, Inki Dae , Kyungmin Park , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [Intel-gfx] [PATCH v2 4/9] 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. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_fb_helper.c | 59 +++++++++++++++++++++++++--------- drivers/gpu/drm/i915/intel_dp_mst.c | 4 --- drivers/gpu/drm/radeon/radeon_dp_mst.c | 7 ---- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 9afd4208596f..252c7557bdb5 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -95,8 +95,8 @@ static LIST_HEAD(kernel_fb_helper_list); * mmap page writes. */ -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; @@ -129,6 +129,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); /** @@ -155,28 +169,28 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) return 0; mutex_lock(&dev->mode_config.mutex); + drm_for_each_connector(connector, dev) { - ret = drm_fb_helper_add_one_connector(fb_helper, connector); + ret = __drm_fb_helper_add_one_connector(fb_helper, connector); + if (ret) { + for (i = 0; i < fb_helper->connector_count; i++) { + kfree(fb_helper->connector_info[i]); + fb_helper->connector_info[i] = NULL; + } - if (ret) - goto fail; - } - mutex_unlock(&dev->mode_config.mutex); - return 0; -fail: - for (i = 0; i < fb_helper->connector_count; i++) { - kfree(fb_helper->connector_info[i]); - fb_helper->connector_info[i] = NULL; + fb_helper->connector_count = 0; + break; + } } - fb_helper->connector_count = 0; + mutex_unlock(&dev->mode_config.mutex); return ret; } 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; @@ -193,6 +207,7 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, if (i == fb_helper->connector_count) return -EINVAL; + fb_helper_connector = fb_helper->connector_info[i]; drm_connector_unreference(fb_helper_connector->connector); @@ -204,6 +219,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 7a34090cef34..47c3980cb3b9 100644 --- a/drivers/gpu/drm/i915/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/intel_dp_mst.c @@ -477,9 +477,7 @@ static void intel_dp_register_mst_connector(struct drm_connector *connector) { struct intel_connector *intel_connector = to_intel_connector(connector); struct drm_device *dev = connector->dev; - drm_modeset_lock_all(dev); intel_connector_add_to_fbdev(intel_connector); - drm_modeset_unlock_all(dev); drm_connector_register(&intel_connector->base); } @@ -492,10 +490,8 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, intel_connector->unregister(intel_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 de504ea29c06..a4ccaa5af104 100644 --- a/drivers/gpu/drm/radeon/radeon_dp_mst.c +++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c @@ -299,9 +299,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); } @@ -314,13 +312,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");