Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2502868imm; Thu, 2 Aug 2018 12:42:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfxHQz99D6cNlo12KxSoQw2LRr6UNJn4EtZ75qUITKvuk+gTxQW31ksnEe/LzQ82ad1ML3y X-Received: by 2002:a17:902:28e4:: with SMTP id f91-v6mr753733plb.70.1533238943540; Thu, 02 Aug 2018 12:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533238943; cv=none; d=google.com; s=arc-20160816; b=tOacoWtCH4N/5rBUmNYHC+1GFxj5rHI+lxnQYWSJwLPzdUSicXLCSnvmxKgGmbSqtB EvW5059AHA/eDm9OqaMpaRbGYOazMj/f4jvBiJldlU3OqJYOcD+AFVHNtKVkKVg9ZmkY 7aleCViakJQFCr98MaDFytYo2F8Qew6Jz8sP3US6c8TuYzbkV5GmUWzEp9V97LL+hlW1 x1lntHSp8hGv9Voh4/CaSSKNSOc+09gbjS4DpQEqWl6+APNbB59mN2e8xGz8rOUQHaCH V+vi5EkafBHVaPyRzBS63jEQqkOTkJ+VR7+CnqMuUir2LaSRoTKcC50wI8YrMyQZfdqx b/mg== 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:message-id:subject:cc :to:from:date:arc-authentication-results; bh=d7RbY1GMNeCUVn06+lNjAAyFVvMSI8Gm6BBzaLgSDKk=; b=Pe50xrvHmlaw2kX5woz+DhVeJqgA7ZPi6XSxLs9ZvUQau2HoXrsX/zsPMPIRb2lqXo aMXgW7Q/Ym6cnuhND2uZpxT237mYkEH3MjyBOru5cJxwITNNjcxTHchfB51cTrbgUQQ9 KJvxWpcbJVJ6qnt4B9u3ZBC2mYS8tAmxz04a2mk8PhEuysuocNCNR0RZN4kGuR5teqNV UVMUfkc5EojIwb5keYe5BfAWQlkz/P3aniQT2s6QmyarEqnG6BrR+BKK88tQJGCnBheu BmZ2vEUaFqhzh/KPXkqzX9fFtiS3wP0gAGvKXglXu+QjDCLIGN3FcAZ4VkkinG7c5wuv Qedg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d192-v6si2639482pga.207.2018.08.02.12.42.08; Thu, 02 Aug 2018 12:42:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbeHBVdR (ORCPT + 99 others); Thu, 2 Aug 2018 17:33:17 -0400 Received: from bmailout2.hostsharing.net ([83.223.90.240]:52075 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbeHBVdR (ORCPT ); Thu, 2 Aug 2018 17:33:17 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id C62342800B3C5; Thu, 2 Aug 2018 21:40:41 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 5570B2FEA6; Thu, 2 Aug 2018 21:40:41 +0200 (CEST) Date: Thu, 2 Aug 2018 21:40:41 +0200 From: Lukas Wunner To: Lyude Paul Cc: nouveau@lists.freedesktop.org, Karol Herbst , Ben Skeggs , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 8/8] drm/nouveau: Call pm_runtime_get_noresume() from hpd handlers Message-ID: <20180802194041.GC6180@wunner.de> References: <20180801211459.7731-1-lyude@redhat.com> <20180801211459.7731-9-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180801211459.7731-9-lyude@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 01, 2018 at 05:14:58PM -0400, Lyude Paul wrote: > We can't and don't need to try resuming the device from our hotplug > handlers, but hotplug events are generally something we'd like to keep > the device awake for whenever possible. So, grab a PM ref safely in our > hotplug handlers using pm_runtime_get_noresume() and mark the device as > busy once we're finished. Patch looks fine in principle, but doesn't seem to be sufficient to fix the following race: 1. runtime_suspend commences 2. user plugs in a display before the runtime_suspend worker disables hotplug interrupts in nouveau_display_fini() 3. hotplug is handled, display is lit up 4. runtime_suspend worker waits for hotplug handler to finish 5. GPU is runtime suspended and the newly plugged in display goes black The call to pm_runtime_mark_last_busy() has no effect in this situation because rpm_suspend() doesn't look at the last_busy variable after the call to rpm_callback(). What's necessary here is that runtime_suspend is aborted and -EBUSY returned. Thanks, Lukas > > Signed-off-by: Lyude Paul > Cc: stable@vger.kernel.org > Cc: Lukas Wunner > Cc: Karol Herbst > --- > drivers/gpu/drm/nouveau/nouveau_connector.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c > index 8409c3f2c3a1..5a8e8c1ad647 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_connector.c > +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c > @@ -1152,6 +1152,11 @@ nouveau_connector_hotplug(struct nvif_notify *notify) > const char *name = connector->name; > struct nouveau_encoder *nv_encoder; > > + /* Resuming the device here isn't possible; but the suspend PM ops > + * will wait for us to finish our work before disabling us so this > + * should be enough > + */ > + pm_runtime_get_noresume(drm->dev->dev); > nv_connector->hpd_task = current; > > if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) { > @@ -1171,6 +1176,9 @@ nouveau_connector_hotplug(struct nvif_notify *notify) > } > > nv_connector->hpd_task = NULL; > + > + pm_runtime_mark_last_busy(drm->dev->dev); > + pm_runtime_put_autosuspend(drm->dev->dev); > return NVIF_NOTIFY_KEEP; > } > > -- > 2.17.1 >