From patchwork Mon Nov 30 23:22:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 7731121 Return-Path: X-Original-To: patchwork-dri-devel@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 CA1BCBEEE1 for ; Mon, 30 Nov 2015 23:23:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A8F120660 for ; Mon, 30 Nov 2015 23:23:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 844F720664 for ; Mon, 30 Nov 2015 23:23:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FD766E6F5; Mon, 30 Nov 2015 15:23:03 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 174806E646; Mon, 30 Nov 2015 15:23:01 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 30 Nov 2015 15:22:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,366,1444719600"; d="scan'208";a="863685135" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.207]) by fmsmga002.fm.intel.com with ESMTP; 30 Nov 2015 15:22:58 -0800 Received: from mattrope by mdroper-hswdev with local (Exim 4.84) (envelope-from ) id 1a3Xmc-0003DO-8p; Mon, 30 Nov 2015 15:22:58 -0800 From: Matt Roper To: intel-gfx@lists.freedesktop.org Subject: [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state Date: Mon, 30 Nov 2015 15:22:49 -0800 Message-Id: <1448925769-12324-1-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <565C1BE2.3000607@linux.intel.com> References: <565C1BE2.3000607@linux.intel.com> Cc: Daniel Vetter , dri-devel@lists.freedesktop.org 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 Callers of drm_atomic_helper_duplicate_state() may not have grabbed locks before calling this function. We're not supposed to iterate over connectors without holding connection_mutex (since MST allows new connectors to be spawned at hotplug), so make sure we grab that ourselves before invoking drm_for_each_connector(). Failure to grab this lock would cause us to stumble over the assertion added in commit: commit 7a3f3d6667f5f9ffd1517f6b21d64bbf5312042c Author: Daniel Vetter Date: Thu Jul 9 23:44:28 2015 +0200 drm: Check locking in drm_for_each_connector Cc: Daniel Vetter Cc: Maarten Lankhorst Signed-off-by: Matt Roper Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/drm_atomic_helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 3731a26..e5d0b21 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2478,6 +2478,10 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev, } } + err = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx); + if (err) + goto free; + drm_for_each_connector(conn, dev) { struct drm_connector_state *conn_state;