Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6043486ybh; Wed, 7 Aug 2019 16:11:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBM6+weeZ4sSx2blVHVbZDu58Eigvk7luscZbK04/sqZhewKZUGLGyW+pfvGbYBuWnCxZA X-Received: by 2002:a17:90a:214e:: with SMTP id a72mr893391pje.0.1565219513551; Wed, 07 Aug 2019 16:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565219513; cv=none; d=google.com; s=arc-20160816; b=yK94vyyPPEL/tvADKW5hiaZ6nzsBQMMF3TKPIVs8g25rOum3V8VBar/oYvTYnvfc+1 1Yxy0KddCpDXb3JoaKT0a1pHTwAg0/WnLCLUdKHc+Tqnzi49rI1ugMJiFchsPipjvhZi QniZl8B0aal4OzDGSCQVmNG0Huk+W2Yx/kT46Kob3SSVWUyLOLZsxvDRWZ4mSF94n1RI 9JH37WGEXo1gM09n5QPB2TDU4UhEmpXgBFAEzfqBeXgdCHdg3/jJzim+8rnJYXVof6dY SN4Z8IlKwJiqIRpGwsD5rgkIJmrwUedcV3sTKc+Bnf3V3imquybf0ZmjYrRQIVH6IuBb ZW+A== 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 :user-agent:organization:references:in-reply-to:date:cc:to:reply-to :from:subject:message-id; bh=UET7SY8fA8PxxfxiGjhHIWC769osh0HwkIUA8kcq50A=; b=cVbedzB7LQ0nfoA6505Re5f1wuAio6/QpAieiSHLlmWynCC6+zOdvPVMZu1j1Dr227 boP6hZWUCJI7MRvzIwaEQlMwrUiT4OH/ihMDSSo/eW0nWFXoZq3EMHECxGZqYBUDgNiz R7Ssf6DpUNKvHcEDQkKwPdnh+qqufjNEXOMEbzBmuCzK7Z5J0Gcrd7nx7x9hGfSz9dWy KWhm4vewC7kbk7fhAeNV8D62rDNbjpvkPf6pm/h66b4NhkOlCx1Y3oaaH3jMMx3iz6ND NsRPavwXeAWVXzNu/B6SKq8siDdbeemqAY0ilRCr9mOgHUqDq9aE9wWAcMMxc3kbNesG C8WA== 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 x4si48932912pln.70.2019.08.07.16.11.37; Wed, 07 Aug 2019 16:11:53 -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 S2389007AbfHGXJu (ORCPT + 99 others); Wed, 7 Aug 2019 19:09:50 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:42270 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730045AbfHGXJu (ORCPT ); Wed, 7 Aug 2019 19:09:50 -0400 Received: by mail-qt1-f194.google.com with SMTP id t12so1602301qtp.9 for ; Wed, 07 Aug 2019 16:09:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc:date :in-reply-to:references:organization:user-agent:mime-version :content-transfer-encoding; bh=UET7SY8fA8PxxfxiGjhHIWC769osh0HwkIUA8kcq50A=; b=fZg43sYUUc9YWVSpf1REeIlVU0dNJrpIOsBTHTAGW3LePtdisOcmBCgaM5hJHpL4Jp I92ssLwIQBhijjvDQH/Tnn0z8izsMHCYesDmqTZ4TistoX4Vr2XOEW3bpCZkj6o0NrGo zfTt3ngoqhlWLOAS09hSDjQA8Ph445QgpBsWVJRFaNhOPHHlkve6ZWonf9Q39b7LW4WE cByVjVjLzx5vAhuIXwbTRlu+UHlRGJ9VgELWy4jceEGx2Uinr5HXhE2TAOZEwUwR1ChL VzlLzbvlfQiVpJ8ZJQlMkfEDagk6KhNbF5W8yijsxeP52Sfdb3LjmyxMkjujELO92da1 e5tg== X-Gm-Message-State: APjAAAXUWZWw7WQe5Q0KDHm2FiQGpGg4hNBYm6lN5aJdhawJojASWmRu hpwncAeZmffQHj4XcviBTszsJVtNy0U= X-Received: by 2002:ac8:1750:: with SMTP id u16mr10024185qtk.90.1565219389278; Wed, 07 Aug 2019 16:09:49 -0700 (PDT) Received: from whitewolf.lyude.net (static-173-76-190-23.bstnma.ftas.verizon.net. [173.76.190.23]) by smtp.gmail.com with ESMTPSA id z19sm41926894qkg.28.2019.08.07.16.09.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 16:09:48 -0700 (PDT) Message-ID: <2a454d971a6c2bc3da730333aacaa420ecddefd6.camel@redhat.com> Subject: Re: [PATCH 1/2] drm/nouveau/dispnv04: Grab/put runtime PM refs on DPMS on/off From: Lyude Paul Reply-To: lyude@redhat.com To: Ilia Mirkin , nouveau , Ben Skeggs , David Airlie , dri-devel , LKML Cc: Daniel Vetter Date: Wed, 07 Aug 2019 19:09:47 -0400 In-Reply-To: References: <20190807213304.9255-1-lyude@redhat.com> <20190807213304.9255-2-lyude@redhat.com> <20190807215508.GK7444@phenom.ffwll.local> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-08-07 at 19:06 -0400, Ilia Mirkin wrote: > On Wed, Aug 7, 2019 at 5:55 PM Daniel Vetter wrote: > > On Wed, Aug 07, 2019 at 05:33:00PM -0400, Lyude Paul wrote: > > > The code claims to grab a runtime PM ref when at least one CRTC is > > > active, but that's not actually the case as we grab a runtime PM ref > > > whenever a CRTC is enabled regardless of it's DPMS state. Meaning that > > > we can end up keeping the GPU awake when there are no screens enabled, > > > something we don't really want to do. > > > > > > Note that we fixed this same issue for nv50 a while ago in: > > > > > > commit e5d54f193572 ("drm/nouveau/drm/nouveau: Fix runtime PM leak in > > > nv50_disp_atomic_commit()") > > > > > > Since we're about to remove nouveau_drm->have_disp_power_ref in the next > > > commit, let's also simplify the RPM code here while we're at it: grab a > > > ref during a modeset, grab additional RPM refs for each CRTC enabled by > > > said modeset, and drop an RPM ref for each CRTC disabled by said > > > modeset. This allows us to keep the GPU awake whenever screens are > > > turned on, without needing to use nouveau_drm->have_disp_power_ref. > > > > > > Signed-off-by: Lyude Paul > > > --- > > > drivers/gpu/drm/nouveau/dispnv04/crtc.c | 18 ++++-------------- > > > 1 file changed, 4 insertions(+), 14 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c > > > b/drivers/gpu/drm/nouveau/dispnv04/crtc.c > > > index f22f01020625..08ad8e3b9cd2 100644 > > > --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c > > > +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c > > > @@ -183,6 +183,10 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode) > > > return; > > > > > > nv_crtc->last_dpms = mode; > > > + if (mode == DRM_MODE_DPMS_ON) > > > + pm_runtime_get_noresume(dev->dev); > > > + else > > > + pm_runtime_put_noidle(dev->dev); > > > > it's after we filter out duplicate operations, so that part looks good. > > But not all of nouveau's legacy helper crtc callbacks go throuh ->dpms I > > think: nv_crtc_disable doesn't, and crtc helpers use that in preference > > over ->dpms in some cases. > > > > I think the only way to actually hit that path is if you switch an active > > connector from an active CRTC to an inactive one. This implicitly disables > > the crtc (well, should, nv_crtc_disable doesn't seem to shut down hw), and > > I think would leak your runtime PM reference here. At least temporarily. > > > > No idea how to best fix that. Aside from "use atomic" :-) > > Not sure if this is relevant to the discussion at hand, but I'd like > to point out that dispnv04 is for pre-nv50 things, which definitely > didn't support any kind of ACPI-based runtime suspend. I thought it was really suspicious that such an old chipset had any kind of runtime PM, but didn't question the code lol. I guess a more appropriate patch would be to just remove runtime PM support entirely for pre-nv50. Will respin soon and do this. > > -ilia