Received: by 10.223.185.116 with SMTP id b49csp3790765wrg; Mon, 19 Feb 2018 06:07:38 -0800 (PST) X-Google-Smtp-Source: AH8x224TZofUvko9sbVFVvDSm15LwbQfGZ9acyZdyM1mxNvyaTdMFoTlkntB6HycgoRC87SAxx9V X-Received: by 10.101.82.195 with SMTP id z3mr12644102pgp.308.1519049258677; Mon, 19 Feb 2018 06:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519049258; cv=none; d=google.com; s=arc-20160816; b=pobTitjmMtED8Z1Xm0RCgDUWiRFk3iUoUZeZOXtFAbxl+cnWwGQsgMv5a0NkJUA80S KAyq7vyKhzMyqo1coWjY9xSrlG3u7OrURs7Th2RLOLxp7xIMygsX/VcCJktvZpCTHjlT Twc2nr868HSG07WSsUpXBG84PmY2ORXtUn3X92Sxt7W+kejfnv0kch5w9UhXfmNUA1WA iP7zJNalZiPEI2OOWiHy1E/pjUzIqqhMjU9C6w5POVnrmI0cfSCcH78/UHFDjjeW3YoM ktH2qw9zHujCphKPP8WHDAjtvMCzPCLV1HAILJUpOqJCR1q8N1g2Ygo5ctCVAxutE4G0 GAXQ== 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-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=K+lXP8CdWyw57ee0TzSkryRZXR+5bTHbDJDR2gfaR7o=; b=VvnIndXXWb6eHMWwGkEMZ+c1XDM0+JeEzPUfTxWig4ohpDUtn71mEgaGw/5ciBUKlR Q4PqI8ADCTGscKJAJvvBbwlzlysws4yaNiBrNd2Cly+JPM9ppsD2dSZ1ZjVmzGQ4b2lZ SlWYMNn5u6mxga12d+kL0YALGeh3GaR8p+d/aV935ykSmQwU+URzHfczfpzA4eOTI4ow Qxr/lkHzOGsGbB8tvKUQI3PCRCGsegwrt4SzR1b31k2YfFPA4YoAhiQICEkLopiT3H/Y yOiBvTf7kGJ26eY+1ZnkXUBEugzDYlAhr5tEoHwmbvk91CIA7OLQzsBL3geFazZonMwT I99g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=kisvyORq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si3689554pgr.492.2018.02.19.06.07.23; Mon, 19 Feb 2018 06:07:38 -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; dkim=fail header.i=@ffwll.ch header.s=google header.b=kisvyORq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752805AbeBSOF7 (ORCPT + 99 others); Mon, 19 Feb 2018 09:05:59 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:32952 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751351AbeBSOF5 (ORCPT ); Mon, 19 Feb 2018 09:05:57 -0500 Received: by mail-wm0-f43.google.com with SMTP id x4so15456703wmc.0 for ; Mon, 19 Feb 2018 06:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=K+lXP8CdWyw57ee0TzSkryRZXR+5bTHbDJDR2gfaR7o=; b=kisvyORqYWUe3vLnqSZr3JBa3AQM0Y/S8xOP+Ze5UZqHH1YOrhPdH2Ij1kyq8TCdG8 r6qUMWof+PGrnRODch1DfkgzEEAB+RMYWJ1H1NfGeXqwFfXq2pQ7dSeRsMkNlqhm4jGH F/3fgFe8+eNPoi74+MD8Gi4S7uZQAudeRac+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=K+lXP8CdWyw57ee0TzSkryRZXR+5bTHbDJDR2gfaR7o=; b=I91n/ezCd09/JyPWL/9XE2OtPwycCTjuF1hXKmRVcpiVYyKbkoIyfZWWXtVlPEdMbe lC91zQMwTO/Av2DiAhpZhOU/zbL1YfPJBSrNQPUVNLzbSosu2o5d7VaPPRSPwEQVJCYX d4AwrZ7C5HpmMJToGSIXAnzAlDjhY2SgmAcOFGq/+cesHrYHGF3tbb79I8ZPvFOcKNp5 nV0ZhFLMnHjY8YqMQDLayoccHGHltKTCBzIIg3xxLX1cG5aZAge8AkkyaUDqCmwwmUiO X969ZlU/Az2W/VLIHtbhydtB2Zc9tembq3br1nFa33qEGB0oxzzafIunOs47VPXHto8u 8FIA== X-Gm-Message-State: APf1xPD8y3B50/b5xz6IlzTFsfuFFoOE/95Icz0uE26HY8lOGpCHA/nP iwc5iP0i8puWQ3OdfEFDfOSYXw== X-Received: by 10.80.219.201 with SMTP id s9mr20493639edk.198.1519049156564; Mon, 19 Feb 2018 06:05:56 -0800 (PST) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id l5sm10244054eda.82.2018.02.19.06.05.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Feb 2018 06:05:55 -0800 (PST) Date: Mon, 19 Feb 2018 15:05:53 +0100 From: Daniel Vetter To: Lukas Wunner Cc: Tejun Heo , Lai Jiangshan , Alex Deucher , Dave Airlie , Ben Skeggs , Archit Taneja , Ismo Toijala , nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Liviu Dudau , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Hans de Goede Subject: Re: [Intel-gfx] [Nouveau] [PATCH 0/5] Fix deadlock on runtime suspend in DRM drivers Message-ID: <20180219140553.GA22199@phenom.ffwll.local> Mail-Followup-To: Lukas Wunner , Tejun Heo , Lai Jiangshan , Alex Deucher , Dave Airlie , Ben Skeggs , Archit Taneja , Ismo Toijala , nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Liviu Dudau , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Hans de Goede References: <20180219113443.GU22199@phenom.ffwll.local> <20180219115817.4e5ml4jdh22kbvs4@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180219115817.4e5ml4jdh22kbvs4@wunner.de> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 19, 2018 at 12:58:17PM +0100, Lukas Wunner wrote: > On Mon, Feb 19, 2018 at 12:34:43PM +0100, Daniel Vetter wrote: > > On Sun, Feb 11, 2018 at 10:38:28AM +0100, Lukas Wunner wrote: > > > Fix a deadlock on hybrid graphics laptops that's been present since 2013: > > > > > > DRM drivers poll connectors in 10 sec intervals. The poll worker is > > > stopped on ->runtime_suspend with cancel_delayed_work_sync(). However > > > the poll worker invokes the DRM drivers' ->detect callbacks, which call > > > pm_runtime_get_sync(). If the poll worker starts after runtime suspend > > > has begun, pm_runtime_get_sync() will wait for runtime suspend to finish > > > with the intention of runtime resuming the device afterwards. The result > > > is a circular wait between poll worker and autosuspend worker. > > > > Don't shut down the poll worker when runtime suspending, that' doesn't > > work. If you need the poll work, then that means waking up the gpu every > > few seconds. If you don't need it, then make sure the DRM_CONNECTOR_POLL > > flags are set correctly (you can update them at runtime, the poll worker > > will pick that up). > > > > That should fix the deadlock, and it's how we do it in i915 (where igt in > > CI totally hammers the runtime pm support, and it seems to hold up). > > It would fix the deadlock but it's not an option on dual GPU laptops. > Power consumption of the discrete GPU is massive (9 W on my machine). > > > > > i915, malidp and msm "solved" this issue by not stopping the poll worker > > > on runtime suspend. But this results in the GPU bouncing back and forth > > > between D0 and D3 continuously. That's a total no-go for GPUs which > > > runtime suspend to D3cold since every suspend/resume cycle costs a > > > significant amount of time and energy. (i915 and malidp do not seem > > > to acquire a runtime PM ref in the ->detect callbacks, which seems > > > questionable. msm however does and would also deadlock if it disabled > > > the poll worker on runtime suspend. cc += Archit, Liviu, intel-gfx) > > > > Well, userspace expects hotplug events, even when we runtime suspend > > stuff. Hence waking shit up with polling. Imo ignoring hotplug events is a > > pretty serious policy decision which is ok in the context of > > vga_switcheroo, but not really as an automatic thing. E.g. usb also wakes > > up if you plug something in, even with all the runtime pm stuff enabled. > > Same for sata and everything else. > > On the MacBook Pro, the HPD pin of external DP and HDMI ports goes into > the gmux controller, which sends an interrupt on hotplug even if the GPU > is powered down. > > Apparently Optimus has a similar functionality, cf. 3a6536c51d5d. Yeah, for vga_switcheroo and gmux setups shutting down polling explicitly makes sense. I think ideally we'd stop polling in the gmux handler somehow (maybe by dropping the relevant DRM_CONNECTOR_POLL flags, or outright stopping it all). But not when runtime suspending the entire gpu (e.g. idle system that shuts down the screen and everything, before it decides a few minutes later to do a full system suspend). I also think that this approach would lead to cleaner code, having explicit checks for the (locking) execution context all over the place tends to result in regrets eventually ime. > For the rare cases where an external VGA or DVI-A port is present, I guess > it's reasonable to have the user wake up the machine manually. > > I'm not sure why nouveau polls ports on my laptop, the GK107 only has an > LVDS and three DP ports, need to investigate. Yeah, that'd be good to figure out. The probe helpers should shut down the worker if there's no connector that needs probing. We use that to enable/disable the poll worker when there's a hotplug storm on the irq line. Once that's fixed we can perhaps also untangle the poll-vs-gmux story. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch