Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3357517imm; Tue, 17 Jul 2018 03:32:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcgT00JIAHTx/nWUT+Mmd+SZM0SEX0PV1cd3MsFNQHdUSRM9rKHZxy+Sr685ydccarHwRRd X-Received: by 2002:a17:902:8210:: with SMTP id x16-v6mr1056328pln.307.1531823540657; Tue, 17 Jul 2018 03:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531823540; cv=none; d=google.com; s=arc-20160816; b=zWqcn0lnWdxJ71g5kNP175fuLf8+wQSLLtvn4KxcfAxSVxBDH4QusEEHDIWWaIwWtf q19ZtdoDgBZbgkbXQHGhf8TS5mN2g46iCiwGNRRQWob9HhwCiqhh1NhPr06zgsOgzKJX i9snhG98httBzR3uzCH9Tp2WDR7gX2NdmRGAg7K5X4Ejs+cghYcXypKUvSRWcEfe176/ pFmQDn5d1o+j6ryzSMlUofo7WZd235iLBTZFToa3v5YXCdXQrlOuSdtmpX2pxAwmDZ7O ejybs2lQMblLc+bSD1HBp7XfhDlzEM4hOvoSqJf6EtAYxgh+gC2FF4HOB+jWJR/UEpBv n3+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=v7WjaGkiOkitW/jthfkP4dv2boxizL8q60XvL6+WzXo=; b=c9ODkoxG+CrGUKpuflLbelJCbKkbg/yVOsMHXW7AL2Q7cD+7pJdQ+mQ/u4bqMTr9eD 2n1ZUmXquuOHUMTzh3/qSxtih06RTpzcb1TNB6o8hE5SQmGkMUVl+RW/TmlV0/z1NE6C Z1KXkRt42kn5MYKc6UNFM4njIxWTNXZSDgVnerZV3sxNKaB6w5KYu/zNazUCImbqbZGb AubCE/YH37agm3h02faJJHppoSlzXnbqPA3rA3oH09ZAtrfd7Qsc+pC7dxxyokZeD9J7 u20U1akwHXXGxrEqLbPNaopxvBQb/MWltgO2mIF3rJCKFNTPuAIIbZvuRxbDleKVWr+E ZupQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k18-v6si521497pff.91.2018.07.17.03.32.05; Tue, 17 Jul 2018 03:32:20 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730172AbeGQLD0 (ORCPT + 99 others); Tue, 17 Jul 2018 07:03:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:42156 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729717AbeGQLD0 (ORCPT ); Tue, 17 Jul 2018 07:03:26 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 03:31:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="57497788" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga008.jf.intel.com with SMTP; 17 Jul 2018 03:31:25 -0700 Received: by stinkbox (sSMTP sendmail emulation); Tue, 17 Jul 2018 13:31:24 +0300 Date: Tue, 17 Jul 2018 13:31:24 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Lukas Wunner Cc: Lyude Paul , nouveau@lists.freedesktop.org, Archit Taneja , David Airlie , dri-devel@lists.freedesktop.org, Maarten Lankhorst , linux-kernel@vger.kernel.org, Ben Skeggs Subject: Re: [Nouveau] [PATCH v2 2/3] drm/nouveau: Fix runtime PM leak in nv50_disp_atomic_commit() Message-ID: <20180717103124.GO5565@intel.com> References: <20180712170256.13018-1-lyude@redhat.com> <20180712170256.13018-3-lyude@redhat.com> <20180717073352.GA17459@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180717073352.GA17459@wunner.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 17, 2018 at 09:33:52AM +0200, Lukas Wunner wrote: > On Thu, Jul 12, 2018 at 01:02:53PM -0400, Lyude Paul wrote: > > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c > > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c > > @@ -1878,7 +1878,7 @@ nv50_disp_atomic_commit(struct drm_device *dev, > > nv50_disp_atomic_commit_tail(state); > > > > drm_for_each_crtc(crtc, dev) { > > - if (crtc->state->enable) { > > + if (crtc->state->active) { > > if (!drm->have_disp_power_ref) { > > drm->have_disp_power_ref = true; > > return 0; > > Somewhat tangential comment on this older patch, since you > continue to dig around in the runtime PM area: > > Whenever a crtc is activated or deactivated in nouveau, we iterate > over all crtcs and acquire a runtime PM if a crtc is active and > previously there was no active one, or we drop a ref if none is > active and previously there was an active one. > > For a while now I've been thinking that it would be more straightforward > to acquire a ref whenever a crtc is activated and drop one when a crtc > is deactivated, i.e. hold one ref for every active crtc. That way the > have_disp_power_ref variable as well as the iteration logic could be > removed, leading to a simplification. Just a suggestion anyway. The current code looks somewhat busted anyway. First problem is that it's accessing crtc->state without the appropriate locks held (unless something always pulls in all crtcs to every commit?). Second issue is that the rpm_put() is called without waiting for nonblocking commits to have finished so it looks like you can currentlly remove the power before the hardware has been properly shut down. -- Ville Syrj?l? Intel