Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2492615ybe; Tue, 3 Sep 2019 13:49:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuPjLEioEEkndiepdokIRKEes3XUbaywtzincR3tQyJm1QiMA+UwZtxmEawcIH9HfKSNM2 X-Received: by 2002:a63:2807:: with SMTP id o7mr32597318pgo.131.1567543780518; Tue, 03 Sep 2019 13:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567543780; cv=none; d=google.com; s=arc-20160816; b=h/P8FAhumaUk4eUJzShqu5JhLoVv5I53KrN+b2E/Iyr8jg/uWGZtK3JYDuF/a27zTp cRcZkLd3XjzAdccrT1f2xL3VamUhilqf6IlG3F6qgRIWmADPsol71XqSTwkkgGKVHJNh HZ/Javoifm+BxY7aVh1ASE2/A8l7491fp1rY9JdYoM6qTsp56Y5QyatmKYCTZbGIiCKi vs78vqBJk9HjSc6tVNB6eyvlp0O+gYx6Ut5thlpMGPx01VOuqg3E1VxPLxrLBii39GSO FOXWh5hv+X1ElKhKX1IWtQD5lrldKXBFS9RxqrQJ8A3I9jLTaoWnk5Fj2+Z2CImLqtJ9 I02w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EVSejcR2SQQtdRVd6gVUjm+NYWdAQ8GcbWfda9lCZx4=; b=cNh2R+upCn0pDBsHUiryUHmCBXG9ZOp1oRNSfIGhwzZjMEu+YSlYTjkYBYZlIYnEk9 ktZ3PbQOYqCIk1SuG9InffCiV3g4BIR68eBpDE3b1cdPwJIVaA9AWZIHT2ScHNgaqFaF 79DNFsHJqujNc7cMEtr0WqxqX+DRW3sFoGtWhwKZUYzG3z1EB2w79Ityo4TuI8Qyuyg2 xjS6BhAWLfTCxcAZW6L3/41d46YfL5A/O8eM0CzHkTw8rjo0X8brKWtZR07+x/pPHeE9 IchNlkkVyJdfb+saUhAjg6lgQn0UnBhIBi75qIs4r9nan6ABbLEKjNn9nfaJ/eehH61/ A1lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si11245770pgh.371.2019.09.03.13.49.21; Tue, 03 Sep 2019 13:49:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727443AbfICUsN (ORCPT + 99 others); Tue, 3 Sep 2019 16:48:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39836 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfICUsN (ORCPT ); Tue, 3 Sep 2019 16:48:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A39A63018FC5; Tue, 3 Sep 2019 20:48:12 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-34.bss.redhat.com [10.20.1.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EAF51001956; Tue, 3 Sep 2019 20:48:08 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Cc: Juston Li , Imre Deak , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Harry Wentland , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Subject: [PATCH v2 08/27] drm/dp_mst: Remove PDT teardown in drm_dp_destroy_port() and refactor Date: Tue, 3 Sep 2019 16:45:46 -0400 Message-Id: <20190903204645.25487-9-lyude@redhat.com> In-Reply-To: <20190903204645.25487-1-lyude@redhat.com> References: <20190903204645.25487-1-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 03 Sep 2019 20:48:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will allow us to add some locking for port->* members, in particular the PDT and ->connector, which can't be done from drm_dp_destroy_port() since we don't know what locks the caller might be holding. Changes since v2: * Clarify commit message Cc: Juston Li Cc: Imre Deak Cc: Ville Syrjälä Cc: Harry Wentland Cc: Daniel Vetter Signed-off-by: Lyude Paul --- drivers/gpu/drm/drm_dp_mst_topology.c | 40 +++++++++++---------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index f5f1d8b50fb6..af3189df28aa 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -1511,31 +1511,22 @@ static void drm_dp_destroy_port(struct kref *kref) container_of(kref, struct drm_dp_mst_port, topology_kref); struct drm_dp_mst_topology_mgr *mgr = port->mgr; - if (!port->input) { - kfree(port->cached_edid); + /* There's nothing that needs locking to destroy an input port yet */ + if (port->input) { + drm_dp_mst_put_port_malloc(port); + return; + } - /* - * The only time we don't have a connector - * on an output port is if the connector init - * fails. - */ - if (port->connector) { - /* we can't destroy the connector here, as - * we might be holding the mode_config.mutex - * from an EDID retrieval */ + kfree(port->cached_edid); - mutex_lock(&mgr->delayed_destroy_lock); - list_add(&port->next, &mgr->destroy_port_list); - mutex_unlock(&mgr->delayed_destroy_lock); - schedule_work(&mgr->delayed_destroy_work); - return; - } - /* no need to clean up vcpi - * as if we have no connector we never setup a vcpi */ - drm_dp_port_teardown_pdt(port, port->pdt); - port->pdt = DP_PEER_DEVICE_NONE; - } - drm_dp_mst_put_port_malloc(port); + /* + * we can't destroy the connector here, as we might be holding the + * mode_config.mutex from an EDID retrieval + */ + mutex_lock(&mgr->delayed_destroy_lock); + list_add(&port->next, &mgr->destroy_port_list); + mutex_unlock(&mgr->delayed_destroy_lock); + schedule_work(&mgr->delayed_destroy_work); } /** @@ -3998,7 +3989,8 @@ static void drm_dp_tx_work(struct work_struct *work) static inline void drm_dp_delayed_destroy_port(struct drm_dp_mst_port *port) { - port->mgr->cbs->destroy_connector(port->mgr, port->connector); + if (port->connector) + port->mgr->cbs->destroy_connector(port->mgr, port->connector); drm_dp_port_teardown_pdt(port, port->pdt); port->pdt = DP_PEER_DEVICE_NONE; -- 2.21.0