Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1340394imm; Wed, 1 Aug 2018 14:17:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpch1JqNtUDd/IP3WC9uSs/wMRBZMVmLmB1/sditbURdCx8a6RwBpPed67ylq0UJSloqWK86 X-Received: by 2002:a17:902:7884:: with SMTP id q4-v6mr28096pll.174.1533158225690; Wed, 01 Aug 2018 14:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533158225; cv=none; d=google.com; s=arc-20160816; b=Utw3xGWZB/SfLYwt57hAAlhi92CktOO6Ekwr+8RcprpKVAODdYpsWHpp1Wo8YV2Z1T cZis1LSxOSh4sKhzLFViN4cM8YY2BlD634F75RTBSjkhODIEx5OO6T/CsuUZClcq2UEd Ox/AS5UbjFMEtUS/xZuKoIS+zuZKPJuUJV8UhgvSgJ9ydAe6XDjW+d+1hrTOZ4SotV4e kziEaIHVadmsBr2Cr8u325oa+jpT3tUKh6sZ9mlNB082fYLaMoKh6Z8a6R7/HFoNfjvu ndRppSs4cBa+f0nCCjKKkavGPNZ6gkCCFM7ezpD1IQDUPi16X7Ct4MK7obcpXX/bLy4Y OaLQ== 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=zvcP3Rb6KUQYJiZysdokjPxTW702hJJNsX8nxqOFudFIQiUjBv6JNdwiQd6V+pK1VT ZknYcWhcHgTSqxI5x/uyjfO8wLoWVtM9eAyz/PVTK+Ic23z/8ARQXs33MBq2//ULHIHT b9FpplFwJDMRHqg1I597MjoJLzq0JlmqfbAO+0+r6ySiBd8qC67q/7M4nSh25BqmGUFA Jx7H5YFzCd7Z1ROyLw6Ek7Y4puxl9ZawImyL8Yu/wEanm4K9c8WVwjTBlyBlUGv8v7Ly O6oPqTAqSeI2jBUQ2F7gipfh6tR8WatsvMZrt/H/cVoWz/i/HTsJ873aWIXpD2Xjd4gm yuIw== 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 h9-v6si18475pfh.240.2018.08.01.14.16.50; Wed, 01 Aug 2018 14:17:05 -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 S1732482AbeHAXD0 (ORCPT + 99 others); Wed, 1 Aug 2018 19:03:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45360 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731650AbeHAXC7 (ORCPT ); Wed, 1 Aug 2018 19:02:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B73F7402243B; Wed, 1 Aug 2018 21:15:17 +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 667532026D68; Wed, 1 Aug 2018 21:15:17 +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 v4 4/8] drm/nouveau: Fix deadlock with fb_helper using new helpers Date: Wed, 1 Aug 2018 17:14:54 -0400 Message-Id: <20180801211459.7731-5-lyude@redhat.com> In-Reply-To: <20180801211459.7731-1-lyude@redhat.com> References: <20180801211459.7731-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 01 Aug 2018 21:15:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 01 Aug 2018 21:15:17 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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