From patchwork Tue Jun 23 20:45:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 6663081 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E9336C05AF for ; Tue, 23 Jun 2015 20:43:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F361205E3 for ; Tue, 23 Jun 2015 20:43:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D405B2061A for ; Tue, 23 Jun 2015 20:43:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC6786EA67; Tue, 23 Jun 2015 13:43:26 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by gabe.freedesktop.org (Postfix) with ESMTP id F196E6EA62 for ; Tue, 23 Jun 2015 13:43:24 -0700 (PDT) Received: by wicgi11 with SMTP id gi11so28110074wic.0 for ; Tue, 23 Jun 2015 13:43:24 -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=n+MH9k1rjDv4UlIRZSQtaoRxlj1Unk2QqY1ntvmdLWw=; b=a6zzdzb79s/J7LzeEvrLcLhI4br+VytB4gNOd9F3xLXiwgs5+gp9XryCT65wMjBl0L lVtXdsLDuPeAIDp+FqpSk362ceKkOM+Y7HuOfdWpX38/mgYKpNsNdJCgQide2uhzSzjr pXv0yuqF45d/K5DZDp2gTmJY+15bbQ8ONjRDk= 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=n+MH9k1rjDv4UlIRZSQtaoRxlj1Unk2QqY1ntvmdLWw=; b=fYXkTWKAfl5vJbXXF4TyH/lmYDrxfDbk1S0sQpvw1J+2rMwUMI7a+HK649LSs0M52j r7tslqVDq6nvAYbQV9aFShshCb6DSGWBUafNZ1inInpoAYdt+DkTYUcWVZ6KD5wDT1GO Nk69evpe3mZh1r0e6OPJS1wTz9cIuYTCMk26CeKKZnt0A3azh6m4nRK0Qf6X5sm1XHks MmVFYaKED5PLYUOK4gBKpHK/56VKGXYYfkIDslRL5eeHKEdo537ElAGsIiUDPAnva+xZ cQCGKZeT3Swc3s1OoL2Wcn1bF7oP9662Expju7SPZi4dLWyzt31TTZO9sJSR24cyLx3X /zug== X-Gm-Message-State: ALoCoQlDXqfKc/QGLqWkgFHDpKz1tbVj03ryhTGG0c/dutqLedVUXgb7ZOD6SCFd3hwRlecBDUH1 X-Received: by 10.180.88.72 with SMTP id be8mr6785496wib.45.1435092204350; Tue, 23 Jun 2015 13:43:24 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by mx.google.com with ESMTPSA id c2sm34354177wjf.18.2015.06.23.13.43.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jun 2015 13:43:23 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 23 Jun 2015 22:45:55 +0200 Message-Id: <1435092362-31062-5-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435092362-31062-1-git-send-email-daniel.vetter@ffwll.ch> References: <1435092362-31062-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Subject: [Intel-gfx] [PATCH 04/11] drm/fbdev-helper: Grab mode_config.mutex in drm_fb_helper_single_add_all_connectors 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-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is now truly only duct-tape to keep locking checks happy since calling this function when hpd or polling are already enabled is a bug. The fbdev helper can't cope with hotplug changes yet at this point, only after that. Otoh a bit more robustness in this function can't hurt, and with this fbdev can actually cope with hotplug changes. And it's also more consistent with the connector hotadd/remove dp mst needs to do. Therefore document this as new official behavior. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 3630d92c9738..329d08167b77 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -89,8 +89,9 @@ static LIST_HEAD(kernel_fb_helper_list); * connectors to the fbdev, e.g. if some are reserved for special purposes or * not adequate to be used for the fbcon. * - * Since this is part of the initial setup before the fbdev is published, no - * locking is required. + * This function is protected against concurrent connector hotadds/removals + * using drm_fb_helper_add_one_connector() and + * drm_fb_helper_remove_one_connector(). */ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) { @@ -98,6 +99,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) struct drm_connector *connector; int i; + mutex_lock(&dev->mode_config.mutex); drm_for_each_connector(connector, dev) { struct drm_fb_helper_connector *fb_helper_connector; @@ -108,6 +110,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) fb_helper_connector->connector = connector; fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; } + mutex_unlock(&dev->mode_config.mutex); return 0; fail: for (i = 0; i < fb_helper->connector_count; i++) { @@ -115,6 +118,8 @@ fail: fb_helper->connector_info[i] = NULL; } fb_helper->connector_count = 0; + mutex_unlock(&dev->mode_config.mutex); + return -ENOMEM; } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);