From patchwork Wed Sep 19 19:23:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10606385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D41BC112B for ; Wed, 19 Sep 2018 19:24:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C17D32CBCF for ; Wed, 19 Sep 2018 19:24:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BED292CC04; Wed, 19 Sep 2018 19:24:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8841A2CC95 for ; Wed, 19 Sep 2018 19:23:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEFEB6E0AB; Wed, 19 Sep 2018 19:23:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id BEF4A6E0AB for ; Wed, 19 Sep 2018 19:23:49 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 13826444-1500050 for multiple; Wed, 19 Sep 2018 20:23:41 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 19 Sep 2018 20:23:40 +0100 Message-Id: <20180919192341.11157-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] drm/i915/fbdev: Use an ordinary worker to avoid async deadlock X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We try to avoid a deadlock of synchronizing the async fbdev task by skipping the synchronisation from the async worker, but that prevents us from using an async worker for the device probe. As we have our own barrier and do not rely on the global async flush, we can simply replace the async task with an explicit worker. References: 366e39b4d2c5 ("drm/i915: Tear down fbdev if initialization fails") Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/intel_drv.h | 3 +-- drivers/gpu/drm/i915/intel_fbdev.c | 35 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index bf1c38728a59..5a07fae3578b 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -25,7 +25,6 @@ #ifndef __INTEL_DRV_H__ #define __INTEL_DRV_H__ -#include #include #include #include @@ -207,8 +206,8 @@ struct intel_fbdev { struct intel_framebuffer *fb; struct i915_vma *vma; unsigned long vma_flags; - async_cookie_t cookie; int preferred_bpp; + struct work_struct work; }; struct intel_encoder { diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c index f99332972b7a..5e17efae7efd 100644 --- a/drivers/gpu/drm/i915/intel_fbdev.c +++ b/drivers/gpu/drm/i915/intel_fbdev.c @@ -24,7 +24,6 @@ * David Airlie */ -#include #include #include #include @@ -666,6 +665,16 @@ static void intel_fbdev_suspend_worker(struct work_struct *work) true); } +static void intel_fbdev_initial_config(struct work_struct *work) +{ + struct intel_fbdev *ifbdev = container_of(work, typeof(*ifbdev), work); + + /* Due to peculiar init order wrt to hpd handling this is separate. */ + if (drm_fb_helper_initial_config(&ifbdev->helper, + ifbdev->preferred_bpp)) + intel_fbdev_unregister(to_i915(ifbdev->helper.dev)); +} + int intel_fbdev_init(struct drm_device *dev) { struct drm_i915_private *dev_priv = to_i915(dev); @@ -679,6 +688,8 @@ int intel_fbdev_init(struct drm_device *dev) if (ifbdev == NULL) return -ENOMEM; + INIT_WORK(&ifbdev->work, intel_fbdev_initial_config); + drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs); if (!intel_fbdev_init_bios(dev, ifbdev)) @@ -698,16 +709,6 @@ int intel_fbdev_init(struct drm_device *dev) return 0; } -static void intel_fbdev_initial_config(void *data, async_cookie_t cookie) -{ - struct intel_fbdev *ifbdev = data; - - /* Due to peculiar init order wrt to hpd handling this is separate. */ - if (drm_fb_helper_initial_config(&ifbdev->helper, - ifbdev->preferred_bpp)) - intel_fbdev_unregister(to_i915(ifbdev->helper.dev)); -} - void intel_fbdev_initial_config_async(struct drm_device *dev) { struct intel_fbdev *ifbdev = to_i915(dev)->fbdev; @@ -715,17 +716,16 @@ void intel_fbdev_initial_config_async(struct drm_device *dev) if (!ifbdev) return; - ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev); + schedule_work(&ifbdev->work); } static void intel_fbdev_sync(struct intel_fbdev *ifbdev) { - if (!ifbdev->cookie) + if (!READ_ONCE(ifbdev->work.func)) return; - /* Only serialises with all preceding async calls, hence +1 */ - async_synchronize_cookie(ifbdev->cookie + 1); - ifbdev->cookie = 0; + flush_work(&ifbdev->work); + ifbdev->work.func = NULL; } void intel_fbdev_unregister(struct drm_i915_private *dev_priv) @@ -736,8 +736,7 @@ void intel_fbdev_unregister(struct drm_i915_private *dev_priv) return; cancel_work_sync(&dev_priv->fbdev_suspend_work); - if (!current_is_async()) - intel_fbdev_sync(ifbdev); + intel_fbdev_sync(ifbdev); drm_fb_helper_unregister_fbi(&ifbdev->helper); }