Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4155459imu; Mon, 7 Jan 2019 16:59:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/WYIDyvYwgxz+u1Tu/YKni8r+RZA+0OEbXu6do8LqPgXXzy23AI/E11r0t5PsR9F4aBnBkj X-Received: by 2002:a62:cf02:: with SMTP id b2mr67371029pfg.183.1546909158641; Mon, 07 Jan 2019 16:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546909158; cv=none; d=google.com; s=arc-20160816; b=vn7oS9uIf8z5DkDQeaZfDi8saVxvxcO92dWKa22H1/pdQiMCheTHI8VYaxo1IUpZg5 ZUCZ6yw0IPgYsXY8TxDm4yiRe+Xb/IR+i1HPu5dhH9iuIz1R6KbkExu6jAt7Qf7PlXkj 28eNZ4DNQmmJwHUxOge3tubeU5piPJi+uIZNmmnkCvk5whT0xdAdMQNE4y5b3y2XTWic K5QeamnpFJ+9suOoylv8TZNLAZobO7U1N1kIvm8NDt4dD6si1YfOAii69DBkpwPq1ksY YDf6qSlVGbeUn+7PoUCULwcFZiTPnPBFzXbIUz24TpBk59WpT/uoBEUy5WIr9LbOAHKi v1Sw== 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=b4esQtooas4u+DJpk8jM3Xr7z8OmKySIfvxWFW37tNM=; b=xPbjsemBLGJyn/IdTxp0FWepcYwP4AQpNQ9+/K9Cqcn4LGGKHuoziH1741DG3e7HME aYPjAe95JAZBospfffPO/msiOpQ4LKrj/ZGeB1sI2AZYSer6O0KxsYSLbEMu4Pep/Ff9 zBiITvrzKdGqy+zk0Ke8+X3NRQnWcHkUuIiNjo8NeVfHp4s02zCCmvIRhwufR/mifmyU V0EHqOanoVYfJPr4eHdKDwx0j66Ulwz2b15S+xeWNp+LgO6IWaU0pXugrkdaXnrFnRDj HYa/bDjqzrLtKoAHFKOS4MR3jPvQ7vfPtPob0J8HUvZkQubkhbEIW4EBdUxhuvYAt0FB 6rrg== 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 a8si4992231pgw.380.2019.01.07.16.59.03; Mon, 07 Jan 2019 16:59:18 -0800 (PST) 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 S1727269AbfAHA5w (ORCPT + 99 others); Mon, 7 Jan 2019 19:57:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36860 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727186AbfAHA5v (ORCPT ); Mon, 7 Jan 2019 19:57:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15550C05FF9D; Tue, 8 Jan 2019 00:57:51 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-11.bss.redhat.com [10.20.1.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A44160E3F; Tue, 8 Jan 2019 00:57:49 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Cc: Jerry Zuo , stable@vger.kernel.org, Harry Wentland , Leo Li , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , Tony Cheng , David Francis , Nicholas Kazlauskas , Mikita Lipski , Shirish S , Bhawanpreet Lakha , Anthony Koo , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/amdgpu: Don't ignore rc from drm_dp_mst_topology_mgr_resume() Date: Mon, 7 Jan 2019 19:56:45 -0500 Message-Id: <20190108005651.25967-2-lyude@redhat.com> In-Reply-To: <20190108005651.25967-1-lyude@redhat.com> References: <20190108005651.25967-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Jan 2019 00:57:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org drm_dp_mst_topology_mgr_resume() returns whether or not it managed to find the topology in question after a suspend resume cycle, and the driver is supposed to check this value and disable MST accordingly if it's gone-in addition to sending a hotplug in order to notify userspace that something changed during suspend. Currently, amdgpu just makes the mistake of ignoring the return code from drm_dp_mst_topology_mgr_resume() which means that if a topology was removed in suspend, amdgpu never notices and assumes it's still connected which leads to all sorts of problems. So, fix this by actually checking the rc from drm_dp_mst_topology_mgr_resume(). Also, reformat the rest of the function while we're at it to fix the over-indenting. Signed-off-by: Lyude Paul Cc: Jerry Zuo Cc: # v4.15+ --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 8a626d16e8e3..3f326a2c513b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -699,22 +699,36 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend) { struct amdgpu_dm_connector *aconnector; struct drm_connector *connector; + struct drm_dp_mst_topology_mgr *mgr; + int ret; + bool need_hotplug = false; drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - aconnector = to_amdgpu_dm_connector(connector); - if (aconnector->dc_link->type == dc_connection_mst_branch && - !aconnector->mst_port) { + list_for_each_entry(connector, &dev->mode_config.connector_list, + head) { + aconnector = to_amdgpu_dm_connector(connector); + if (aconnector->dc_link->type != dc_connection_mst_branch || + aconnector->mst_port) + continue; + + mgr = &aconnector->mst_mgr; - if (suspend) - drm_dp_mst_topology_mgr_suspend(&aconnector->mst_mgr); - else - drm_dp_mst_topology_mgr_resume(&aconnector->mst_mgr); - } + if (suspend) { + drm_dp_mst_topology_mgr_suspend(mgr); + } else { + ret = drm_dp_mst_topology_mgr_resume(mgr); + if (ret < 0) { + drm_dp_mst_topology_mgr_set_mst(mgr, false); + need_hotplug = true; + } + } } drm_modeset_unlock(&dev->mode_config.connection_mutex); + + if (need_hotplug) + drm_kms_helper_hotplug_event(dev); } /** -- 2.20.1