Received: by 10.223.185.116 with SMTP id b49csp982472wrg; Sun, 11 Feb 2018 01:41:57 -0800 (PST) X-Google-Smtp-Source: AH8x224vUOnm0AUEWTniEQl4MQ2KK1cYpEXbSMDcS6AZlKdAff4/OSg7DN3WfCQLLuI/JvZXMP+g X-Received: by 10.99.110.7 with SMTP id j7mr5976016pgc.59.1518342117861; Sun, 11 Feb 2018 01:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518342117; cv=none; d=google.com; s=arc-20160816; b=UG6eDXapZL8F5Bfgcc3vKFaIIZ/mPM8mM2AROwmWbVrffv9J5flqAH4bohCcdt2g2j o3jfcoRxeq5kaMakr+zSTIH2nr7Xwwi/UsiKgAsEzy/BPmjQmgptCHI/+gtopTBRXfYN EqRv2ZoP/6L5COvD6QLmMH8uSeIdu/1YLyPAvyYIfYQjatXaXeSQvf2TjGJWXGyW9yXO uksRxd+2PYfE/YizxciNnrznkbJj5+32ueICsk2d1V1+UuqSPDZ9DjHc/dInmAIq7BFt Yu9wQRS4yPcfWFqTVDs9lMwV2ZkJg7tgg8fdx8uOjNTHzc6lobN2bd3VbK4c25an0iig 3ZEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:date:from:references :in-reply-to:message-id:arc-authentication-results; bh=NaVvShGefJr6L+msaClFEV0gIw7j74YybSa3yaQ5OjU=; b=bfAkaXrXoBs7rsAgDU2tQB1I+hyEUG3aFrcUq8+LghX3Q9vFFOSkSr4fkOyZQ7ebAI o73xSnQP3vDpIWVGnb2F3lrVRkiOQ2oK3UY+kdcTOItW665o/XStF5dVz/5OZGArX9vt nCKSrp0qXU5vuV5UeyilBoex7IX5+cPaw3+W6b1HUxItYi4y2T7W1X4KnRZvtTyWPjuK h0WK7lO2NGajAyT92zkd2fSUtbCGjm4rEmQZLLf+A/YHRRx/P3mKWI1AO9pjgfe07StC 6WN4jicP+WL+PGivvjspH/XddcISkxdCBuuw5ItqNvJh8rvhxij1ecGdxeORY7/E5/jr dMoQ== 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 62-v6si678226plb.383.2018.02.11.01.41.44; Sun, 11 Feb 2018 01:41:57 -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 S1753163AbeBKJjg (ORCPT + 99 others); Sun, 11 Feb 2018 04:39:36 -0500 Received: from mailout3.hostsharing.net ([176.9.242.54]:54449 "EHLO mailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753112AbeBKJjc (ORCPT ); Sun, 11 Feb 2018 04:39:32 -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 mailout3.hostsharing.net (Postfix) with ESMTPS id D9D68100B08A9; Sun, 11 Feb 2018 10:39:41 +0100 (CET) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 96FB9603E052; Sun, 11 Feb 2018 10:39:30 +0100 (CET) X-Mailbox-Line: From 7831d4f21dde8cd0b1659e393854598995dfb249 Mon Sep 17 00:00:00 2001 Message-Id: <7831d4f21dde8cd0b1659e393854598995dfb249.1518338788.git.lukas@wunner.de> In-Reply-To: References: From: Lukas Wunner Date: Sun, 11 Feb 2018 10:38:28 +0100 Subject: [PATCH 2/5] drm: Allow determining if current task is output poll worker To: Tejun Heo , Lai Jiangshan , Alex Deucher , Dave Airlie , Ben Skeggs Cc: dri-devel@lists.freedesktop.org, Peter Wu , nouveau@lists.freedesktop.org, Lyude Paul , Hans de Goede , Pierre Moreau , linux-kernel@vger.kernel.org, Ismo Toijala , intel-gfx@lists.freedesktop.org, Liviu Dudau , Archit Taneja Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; +} +EXPORT_SYMBOL(drm_kms_helper_is_poll_worker); + /** * drm_kms_helper_poll_disable - disable output polling * @dev: drm_device diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h index 76e237bd989b..6914633037a5 100644 --- a/include/drm/drm_crtc_helper.h +++ b/include/drm/drm_crtc_helper.h @@ -77,5 +77,6 @@ void drm_kms_helper_hotplug_event(struct drm_device *dev); void drm_kms_helper_poll_disable(struct drm_device *dev); void drm_kms_helper_poll_enable(struct drm_device *dev); +bool drm_kms_helper_is_poll_worker(void); #endif -- 2.15.1