Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4561264imm; Mon, 30 Jul 2018 17:42:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcucTAHxlZcZQcORb8wpIPO5wRqIyYkgI330C+WdQm4720H2gpxL8DGSix5kpWSewKPpAbO X-Received: by 2002:a62:5dd7:: with SMTP id n84-v6mr20129944pfj.68.1532997722004; Mon, 30 Jul 2018 17:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532997721; cv=none; d=google.com; s=arc-20160816; b=co+KSTERDby4QbsTzo2T0Rvmu7HAx0OZOaQ1KdSJug6VUlCGT6a8xbfKFOKMqFmFdd J37rTuxwT7wjiho3B5Pk+29NZNnPRiefV5DCOso+bo22qcW35pcsVWMWJK8Qon1n//yL 9QTvOY4Tr5Nw0aFCYjbiRLi6vpTe7wj46wlOjqam/talc/WUITUfaLFfzSPAvN65QLPB FhgOAH5tWudoXogPBsCOpkB+sGveaAKypAOyq8jWjLpu0xY3Ar9glHyU1ZUVJ1+X0vU9 DgHfnl/DsbUBD+G0iH+N4077UGuFExB+O+5WfSw3U2SlqvIbpVt8cVZYBSOCMe/sawd/ euiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=nrXxb3tc/jLRfrriZAwd4HEJBk0LT2xqelP3BFwPqGo=; b=YmPoc2BBdTc1BGrByDNqoKXAEtCiKHOEkJ2+E4IUE4RmTBdOEN1vUF1HMb/07a45QN 7dU0MhfNO/y08+Xrn49TOC3niixEWJqBq6aYRreShX8FKHxcdFuS5baX3k4lcTE2yEZn SrLqtohYzuZJ/G7+DFVvNXdO+bgfOMds7NhzTwsOAXZNSijbhFjPKnS6Mj3gwRQTzhwW L+fUkWMEXyOAti6bzYOJUOm0HMPgQmM/GdO/IauDbn8aM1jao1rMHcNDWVqADkQTJrNd 4YZuzneQAs/q7g7boWtXx08NTvqdjVaRbsSxaxhtQJVfPJ0nJFpgsdX3/uUBREDw8Omf v/RQ== 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 m32-v6si11127453pgl.622.2018.07.30.17.41.47; Mon, 30 Jul 2018 17:42:01 -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 S1732254AbeGaCRj (ORCPT + 99 others); Mon, 30 Jul 2018 22:17:39 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55598 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732191AbeGaCRi (ORCPT ); Mon, 30 Jul 2018 22:17:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 182287DAC7; Tue, 31 Jul 2018 00:40:05 +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 BB86D16875; Tue, 31 Jul 2018 00:40:04 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org Cc: stable@vger.kernel.org, Lukas Wunner , Karol Herbst , Ben Skeggs , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/8] drm/nouveau: Fix deadlock with fb_helper using new helpers Date: Mon, 30 Jul 2018 20:39:49 -0400 Message-Id: <20180731003954.19962-5-lyude@redhat.com> In-Reply-To: <20180731003954.19962-1-lyude@redhat.com> References: <20180731003954.19962-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 31 Jul 2018 00:40:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 31 Jul 2018 00:40:05 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lyude@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This removes the potential of deadlocking with fb_helper entirely by preventing it from handling hotplugs during the runtime suspend process as early as possible in the suspend process. If it turns out this is not possible, due to some fb_helper action having been queued up before we got a time to disable hotplugging, we simply return -EBUSY so that the runtime PM core attempts autosuspending the device again once fb_helper isn't doing anything. This fixes one of the issues causing deadlocks on runtime suspend/resume with nouveau on my P50. Signed-off-by: Lyude Paul Cc: stable@vger.kernel.org Cc: Lukas Wunner Cc: Karol Herbst --- drivers/gpu/drm/nouveau/nouveau_drm.c | 8 ++++++++ drivers/gpu/drm/nouveau/nouveau_fbcon.c | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index ee2546db09c9..d47cb5b2af98 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -836,6 +836,14 @@ nouveau_pmops_runtime_suspend(struct device *dev) return -EBUSY; } + /* There's no way for us to stop fb_helper work in reaction to + * hotplugs later in the RPM process. First off: we don't want to, + * fb_helper should be able to keep the GPU awake. Second off: it is + * capable of grabbing basically any lock in existence. + */ + if (!drm_fb_helper_suspend_hotplug(drm_dev->fb_helper)) + return -EBUSY; + nouveau_switcheroo_optimus_dsm(); ret = nouveau_do_suspend(drm_dev, true); pci_save_state(pdev); diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 85c1f10bc2b6..963ba630fd04 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c @@ -466,6 +466,7 @@ nouveau_fbcon_set_suspend_work(struct work_struct *work) console_unlock(); if (state == FBINFO_STATE_RUNNING) { + drm_fb_helper_resume_hotplug(drm->dev->fb_helper); pm_runtime_mark_last_busy(drm->dev->dev); pm_runtime_put_sync(drm->dev->dev); } -- 2.17.1