Received: by 10.223.185.116 with SMTP id b49csp2508702wrg; Mon, 12 Feb 2018 10:41:13 -0800 (PST) X-Google-Smtp-Source: AH8x226JtIVfzJrM453mk1N/OYuVlDhPmE+fzV2zTbpsrAmH9T8N9xeku5zp4NB3R8XsGFyHcaSp X-Received: by 10.99.6.85 with SMTP id 82mr4386012pgg.181.1518460873605; Mon, 12 Feb 2018 10:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518460873; cv=none; d=google.com; s=arc-20160816; b=VsFlwTaMiT5XcRYf0EloYcjzQ+8UkzWfWfEsCIxxXP3mCTJuowXYxhkiAAB7JrFLql YDlTzQRhFJHl0cesuIxYE/NxwhjoTekQrcIDwbPPyn6r/EWqloMtkusm+QBxxDYVG0PG mV+PaJhUtlPCpOVUWsPmmM/iyQPgK539/NYZWM9D/G8n7kk5TnrKuL67JCsPwdVjaG1C ufNQqXPX0rtIY4F2pcw4irjFuCHFkxjR7Xf2rPeHtsRBbq/uJSE7ntj+0dg8wLSrGzCg 7wo4GyV7iTaQeUlecsmPhSoRkPv30aT7Lop29mbkenJkrIoOn4ctz2bGmX1nKJnoDmDI vUQA== 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=xcBYDk9Sv/db7ie8+RWpnO4JaeIINqsMzm0gUdO0msM=; b=QaeZmkDhHfFYY+ccQxjplvvbqDxVQztSEXMmpbST6u+5Ju598C4YWR7hd91JSoGtr7 FCVIKA6mrmcSVEzqaluodGhb0tSFMhlX+VqMW/dEeisDuGoirplXnwKuhvMgbj9zP7Xk gY087Kz6EJ1ullV/+c8SmQUD/gRSkPDdmW++2LzbPF3NgAludalMNOtOi+QXkHuBxcMe FJ5FkyPy+KfUKcyJtqpRnOyaJjmv6QtFgKhExe/Lwx/xe3aQ5bx5f11jrFqyG8HXqjCT WGQqvxPfGn4fdSkz1ceR2XSXxVcecCmwnf498TGbfau7YeUCZ50jhahL1i24bz0nptHy rMPw== 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 a67si44517pgc.151.2018.02.12.10.40.57; Mon, 12 Feb 2018 10:41:13 -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 S1753691AbeBLSkK (ORCPT + 99 others); Mon, 12 Feb 2018 13:40:10 -0500 Received: from bmailout3.hostsharing.net ([176.9.242.62]:40853 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752943AbeBLSkI (ORCPT ); Mon, 12 Feb 2018 13:40:08 -0500 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 bmailout3.hostsharing.net (Postfix) with ESMTPS id 102BD100DEC9C; Mon, 12 Feb 2018 19:40:07 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id A8EA2FC0E; Mon, 12 Feb 2018 19:40:06 +0100 (CET) Date: Mon, 12 Feb 2018 19:40:06 +0100 From: Lukas Wunner To: Chris Wilson Cc: Lyude Paul , Tejun Heo , Lai Jiangshan , Alex Deucher , Dave Airlie , Ben Skeggs , 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 Subject: Re: [Intel-gfx] [PATCH 2/5] drm: Allow determining if current task is output poll worker Message-ID: <20180212184006.GA3862@wunner.de> References: <7831d4f21dde8cd0b1659e393854598995dfb249.1518338788.git.lukas@wunner.de> <1518457571.5319.7.camel@redhat.com> <151845781278.18923.259952134307306444@mail.alporthouse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151845781278.18923.259952134307306444@mail.alporthouse.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 Mon, Feb 12, 2018 at 05:50:12PM +0000, Chris Wilson wrote: > 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. > > > + */ > > > +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? The work_struct exists as long this kthread is working on it. Since this is called by the kthread itself, it is guaranteed to exist. So there's no protection needed. Thanks, Lukas