Received: by 10.223.185.116 with SMTP id b49csp2458699wrg; Mon, 12 Feb 2018 09:51:44 -0800 (PST) X-Google-Smtp-Source: AH8x226KtvEf3s1arPFab1Z7IELMCpabsqYOpUMlNO0IWLpIvsQx4yaPCmEzGhHtx1ObQaV1R0UD X-Received: by 2002:a17:902:4601:: with SMTP id o1-v6mr1116305pld.210.1518457904351; Mon, 12 Feb 2018 09:51:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518457904; cv=none; d=google.com; s=arc-20160816; b=qgXjiwrgKfzGO0B6KrbGShpPPuWFs5kfqdJu6/qjVAndPYx9T4699ozcs/rSrUMJAo YZ5tNMzmR/Xc19wVg1MJRURRK6lf9NB4UkNs20vXrAZ/U/MhpzVNkw/J2IxEBygw+IBy aist9i1RfNeRtN3LcVOTKUUC/Y7SoMS9sBW1vb5ZRNgB6+wiIwc1M/7UOA/xUGRBxnZa NNCVBr8+wOHYDwjlqH0xu2a3WTtojgZzntSkdL6nCNv8EXsuLITQdOqNcCxDQq0se5yw B8woMITrOjm/2Qh1Z91L8UkpCtBblLWKjBPXwZuIJQLFRxgWpXmb5XQjH0yxhJ2KvliW vmOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:arc-authentication-results; bh=BXFIw9aZVUN9Bz5CK4LC4FVRCuYdYB27ebLuSjfG6ZI=; b=0eIJIpRzD/BRd0MupPzOWLraVfZESEtKZLEwMvFlZr3txrc2S4KUZvLZ7q82aSiquY zPqq7/Ow1xEFNDmb2PYyIT/Z9NdeAZ716M8Om1drNrYwqDqR7Sn9gayNWoEo0wLmlku1 Cc+2B11iDEpSODujqns8UrX7OzE5bahOJ5aD5bTRhtu26h/XhKEFgXlxCtVahqpAFRMS HIvH/C8U+YtkMqxRPQGDppC87UK32B2KKGSGaIP72Wb1LY+wMEUf2bReTwSZ7+/Sbj9R J6nPyTfv+RrDPTprAI9bkULlk+lnetOtOcBoh68jK0Wl+vaKHdeMfzjFHteKbpQ4cI1Q /83g== 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 m187si6573145pfb.291.2018.02.12.09.51.27; Mon, 12 Feb 2018 09:51:44 -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; 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 S1752802AbeBLRuf convert rfc822-to-8bit (ORCPT + 99 others); Mon, 12 Feb 2018 12:50:35 -0500 Received: from mail.fireflyinternet.com ([109.228.58.192]:56583 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751063AbeBLRue (ORCPT ); Mon, 12 Feb 2018 12:50:34 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 10662460-1500050 for multiple; Mon, 12 Feb 2018 17:50:14 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Lyude Paul , "Lukas Wunner" , "Tejun Heo" , "Lai Jiangshan" , "Alex Deucher" , "Dave Airlie" , "Ben Skeggs" From: Chris Wilson In-Reply-To: <1518457571.5319.7.camel@redhat.com> Cc: "Pierre Moreau" , "Archit Taneja" , "Ismo Toijala" , nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "Hans de Goede" , "Peter Wu" References: <7831d4f21dde8cd0b1659e393854598995dfb249.1518338788.git.lukas@wunner.de> <1518457571.5319.7.camel@redhat.com> Message-ID: <151845781278.18923.259952134307306444@mail.alporthouse.com> User-Agent: alot/0.3.6 Subject: Re: [Intel-gfx] [PATCH 2/5] drm: Allow determining if current task is output poll worker Date: Mon, 12 Feb 2018 17:50:12 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lyude Paul (2018-02-12 17:46:11) > On Sun, 2018-02-11 at 10:38 +0100, Lukas Wunner wrote: > > Introduce a helper to determine if the current task is an output poll > > worker. > > > > This allows us to fix a long-standing deadlock in several DRM drivers > > wherein the ->runtime_suspend callback waits for the output poll worker > > to finish and the worker in turn calls a ->detect callback which waits > > for runtime suspend to finish. The ->detect callback is invoked from > > multiple call sites and waiting for runtime suspend to finish is the > > correct thing to do except if it's executing in the context of the > > worker. > > > > Cc: Dave Airlie > > Cc: Ben Skeggs > > Cc: Alex Deucher > > Signed-off-by: Lukas Wunner > > --- > > drivers/gpu/drm/drm_probe_helper.c | 14 ++++++++++++++ > > include/drm/drm_crtc_helper.h | 1 + > > 2 files changed, 15 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_probe_helper.c > > b/drivers/gpu/drm/drm_probe_helper.c > > index 555fbe54d6e2..019881d15ce1 100644 > > --- a/drivers/gpu/drm/drm_probe_helper.c > > +++ b/drivers/gpu/drm/drm_probe_helper.c > > @@ -653,6 +653,20 @@ static void output_poll_execute(struct work_struct > > *work) > > schedule_delayed_work(delayed_work, > > DRM_OUTPUT_POLL_PERIOD); > > } > > > > +/** > > + * drm_kms_helper_is_poll_worker - is %current task an output poll worker? > > + * > > + * Determine if %current task is an output poll worker. This can be used > > + * to select distinct code paths for output polling versus other contexts. > > + */ > For this, it would be worth explicitly noting in the comments herethat this > should be called by DRM drivers in order to prevent racing with hotplug > polling workers, so that new drivers in the future can avoid implementing this > race condition in their driver. > > > +bool drm_kms_helper_is_poll_worker(void) > > +{ > > + struct work_struct *work = current_work(); > > + > > + return work && work->func == output_poll_execute; What ensures that work is accessible? Does this need rcu_read_lock protection or more? -Chris