Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4411278pxv; Tue, 20 Jul 2021 03:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxun21qM/5dxC7scYgEMNJdLi0kAkL5x7k/wnNrrGBVGpUBuYnKH64BgJnfquLYWLAaIt/u X-Received: by 2002:a17:907:9152:: with SMTP id l18mr32225629ejs.374.1626775906056; Tue, 20 Jul 2021 03:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626775906; cv=none; d=google.com; s=arc-20160816; b=a5yxPpsTiDX6J086mXUYA1MQjumTIGUwCVb7+FgSnW1C2VvtPpX0+EEziviLLVCRAi hkfULC9KgDx7NkeCBgNF7qJ9CbcC8fGI9/hBFqg/WMYPeCuMyykpFk2UTdAyFpxLuNQ6 MPnb8DGhmKLbt5oghpctAfnzpa2/1EZ0pXGaWYfDS5+KhVQ69u/eIHZfnri54sxTjznf 8+GDWJdJTnRMROwkrkiAErWyFdCi/M6ms3LgxBeCPGDYDyqXJK4uI4Srlrjse/bzD/au VM2ZNlNQZIcv8edR+p3FGBa5nntO3dUa11dX6nvg8QutftfD/G99f11tAjxgturh2Hvc xHzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=E6dvoxU82sdq8hrtHo6MNtrAkdmF4Qfs1QHBwRf0tvA=; b=kW2J4nBD9XWWB7OVdBchNNGmTyUWqZeCpuu43IN+m9AsmIJkBlg4h7q528AhOEjS4L Dz5K2ZUSXGUQN6MZeUYABTO/Uy5PjcLdfspap92zFtiLzSnW9UAbWMd8dqSfX+gramKC CfAu5l2IbXVqfijy9X3ncrhb74ezePmmkgkG35LFiBNhGlC7KihYF9QkZ0Xa98/6m3To bWiz4vIp4ztL/omTXTIoXmx/8u374PtBp9FS8X4xlXx7zxwJptwH88thUcfdphY2Qe85 dbdZxai/xeOCc688FnRn+S4qDkI7JQoxQFfNVyevAzbsyQ+p3UI/ZOO0scHj/EN7e83Q 7xcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=Cp59n2Cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eg42si23053574edb.69.2021.07.20.03.11.22; Tue, 20 Jul 2021 03:11:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=Cp59n2Cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236060AbhGTJ1L (ORCPT + 99 others); Tue, 20 Jul 2021 05:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236395AbhGTJZ6 (ORCPT ); Tue, 20 Jul 2021 05:25:58 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB378C061762 for ; Tue, 20 Jul 2021 03:06:02 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id b2so6622661plx.1 for ; Tue, 20 Jul 2021 03:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E6dvoxU82sdq8hrtHo6MNtrAkdmF4Qfs1QHBwRf0tvA=; b=Cp59n2Cb272AzmErANtJnFMRXbhxIXwpy4y+lZNu4HXwA0rY3ycd0yal8gjH4KS/8B tX7HiQlqzbMpHXvkhj2/8EtDSZVA5KLyTBhW7d8tTrmJmBbNDOWpfkD76197FZBz7zti ydKpQM1bMd+Ia1gvMedLl7LNhCSltVNot4Bc8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E6dvoxU82sdq8hrtHo6MNtrAkdmF4Qfs1QHBwRf0tvA=; b=UMadiT6zY9aCforDIJJGqRohom3deyqym8I0aLNtBcSoZEpbgjcR+Li/PeHxdXAQuJ LhAd9qUkralnI3eicp0ngVBsKU35Jjnxm1KRsxxlAk0J7+YxCI2kgzMbQl7bXVA9VrKD 3/dhcmKTLnLsQuNmQNPHr3zHu0ghVaqrqKmQD5oEqf7J3QkF9VsmhriCXrnXqKfwCfvt zNx5ItESAJVKLi4Bd3fF7TxjYfZgEpu7Sa4sr1H+JN3CQOK8ppzXazF1e5Ymn6va8jHw PmYPbGuK9SPbVHAjEsxXx1YyyWG6TYsPNCvO0ouqFV8Sj5VocXkLmnvxnVbqVngGOnvE mrng== X-Gm-Message-State: AOAM532HsaJNmXM4CgmbXLtTUtlXHZoghLYbvTrN0mL9Rra2eR6O019H 9yrLhbfxxT2gdj+UzFu/2Wf4sA== X-Received: by 2002:a17:90a:4302:: with SMTP id q2mr33210703pjg.189.1626775562319; Tue, 20 Jul 2021 03:06:02 -0700 (PDT) Received: from kafuu-chino.c.googlers.com.com (105.219.229.35.bc.googleusercontent.com. [35.229.219.105]) by smtp.googlemail.com with ESMTPSA id y5sm22843830pfn.87.2021.07.20.03.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 03:06:01 -0700 (PDT) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Tzung-Bi Shih , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Matthias Brugger , Hsin-Yi Wang , Xin Ji , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCH v2] drm/bridge: anx7625: Use pm_runtime_force_{suspend,resume} Date: Tue, 20 Jul 2021 18:05:21 +0800 Message-Id: <20210720100553.2340425-1-pihsun@chromium.org> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use pm_runtime_force_{suspend,resume} as system suspend/resume hook, to ensure that anx7625 is always powered off on suspend. Also add a device link between anx7625 driver and the encoder, to ensure that bridge_disable will be called before suspend. Signed-off-by: Pi-Hsun Shih --- Changes from v1: * Use device link to ensure suspend resume order, instead of manually calling force resume. This is the second approach mentioned in v1 of this patch (https://lore.kernel.org/patchwork/patch/1459569/#1655836). An issue was found that the anx7625 driver won't power off when used as eDP bridge on Asurada board if suspend is entered via VT2. The reason is that in this case, anx7625_suspend won't power off anx7625 (since intp_irq is not set). And anx7625_bridge_disable is only called indirectly by other driver's (mediatek-drm) suspend. pm_runtime_put_sync won't do anything since it's already in system suspend. If not in VT2, the bridge disable is indirectly called when Chrome stops, so anx7625 will be powered off correctly. To fix the issue, the suspend resume hooks are changed to pm_runtime_force_{suspend,resume} to ensure the runtime suspend / resume is always called correctly when system suspend / resume. (Note that IRQ no longer needs to be disabled on suspend after commit f03ab6629c7b ("drm/bridge: anx7625: Make hpd workqueue freezable")) Also adds a stateless device link to ensure that the bridge disable is called before anx7625 is suspended. --- drivers/gpu/drm/bridge/analogix/anx7625.c | 54 +++++++++-------------- drivers/gpu/drm/bridge/analogix/anx7625.h | 1 + 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 7519b7a0f29d..e248f0da2f8b 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1331,6 +1331,8 @@ static void anx7625_bridge_detach(struct drm_bridge *bridge) mipi_dsi_detach(ctx->dsi); mipi_dsi_device_unregister(ctx->dsi); } + if (ctx->link) + device_link_del(ctx->link); } static int anx7625_bridge_attach(struct drm_bridge *bridge, @@ -1355,6 +1357,13 @@ static int anx7625_bridge_attach(struct drm_bridge *bridge, return err; } + ctx->link = device_link_add(bridge->dev->dev, dev, DL_FLAG_STATELESS); + if (!ctx->link) { + DRM_DEV_ERROR(dev, "device link creation failed"); + err = -EINVAL; + goto detach_dsi; + } + if (ctx->pdata.panel_bridge) { err = drm_bridge_attach(bridge->encoder, ctx->pdata.panel_bridge, @@ -1362,13 +1371,22 @@ static int anx7625_bridge_attach(struct drm_bridge *bridge, if (err) { DRM_DEV_ERROR(dev, "Fail to attach panel bridge: %d\n", err); - return err; + goto remove_device_link; } } ctx->bridge_attached = 1; return 0; + +remove_device_link: + device_link_del(ctx->link); +detach_dsi: + if (ctx->dsi) { + mipi_dsi_detach(ctx->dsi); + mipi_dsi_device_unregister(ctx->dsi); + } + return err; } static enum drm_mode_status @@ -1705,39 +1723,9 @@ static int __maybe_unused anx7625_runtime_pm_resume(struct device *dev) return 0; } -static int __maybe_unused anx7625_resume(struct device *dev) -{ - struct anx7625_data *ctx = dev_get_drvdata(dev); - - if (!ctx->pdata.intp_irq) - return 0; - - if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) { - enable_irq(ctx->pdata.intp_irq); - anx7625_runtime_pm_resume(dev); - } - - return 0; -} - -static int __maybe_unused anx7625_suspend(struct device *dev) -{ - struct anx7625_data *ctx = dev_get_drvdata(dev); - - if (!ctx->pdata.intp_irq) - return 0; - - if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) { - anx7625_runtime_pm_suspend(dev); - disable_irq(ctx->pdata.intp_irq); - flush_workqueue(ctx->workqueue); - } - - return 0; -} - static const struct dev_pm_ops anx7625_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(anx7625_suspend, anx7625_resume) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) SET_RUNTIME_PM_OPS(anx7625_runtime_pm_suspend, anx7625_runtime_pm_resume, NULL) }; diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h index 034c3840028f..c941b7a32859 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -385,6 +385,7 @@ struct anx7625_data { struct drm_bridge bridge; u8 bridge_attached; struct mipi_dsi_device *dsi; + struct device_link *link; }; #endif /* __ANX7625_H__ */ base-commit: 3568c2c543e25d1a47bd97a607171511e7d44a45 -- 2.32.0.402.g57bb445576-goog