Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp101049pxv; Tue, 13 Jul 2021 23:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJIJfrA9qphChn75p8JxbucXogAdhWaJUSkR+Oi0HIqAfoWfL9YO07aFhld/QXjMCR1VFD X-Received: by 2002:a05:6638:3181:: with SMTP id z1mr7391243jak.100.1626242770403; Tue, 13 Jul 2021 23:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626242770; cv=none; d=google.com; s=arc-20160816; b=o2QyWeho3B6tULrcGNW/05tUbRMsM0mowH81HkRFnXltRhMO3AK7zg/ZVV63V+m9uS gZ9zDFAvTfUCQl7Qbxd3jbobjh1WfgNsHJZz0RZdHwpTC6gGWevl/gfCf2LDyljLIyYF 5VfkGVsmMFaqZ/mMOBMgleSU2UtNyr9lNrWq9mqqTHKL5GTlSCufmLA9D8/Zt2Z1Ubei iIoamHG3bFUdJzi9diiRdPiVFsi1Q+LVEzwIqXet+hufXJMwSyZFbfMMLYzVDzreYU+R bSe0ntzctymgErqVGCTSi7EIMbBEdM3igY5AHk1+gPfb7ufL1wS3uAY+VXZKNJcF2D8g WuRQ== 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=n3xrLCowHoV9+qyE8ZVGJpCIjAP5+VxK4UkQj5GcY2w=; b=B9gEzaRUh24qKmCu7Uc0W0EzFJry/EWiwjRxnb1Eb8BIbZEQnAC9Rh35R78fNqVy9b EDtt+h3JUNrv5kO/JlIbMSDoTAciTRqmdrjSJ9FCBH78+Ic5p6qnW7lv+Wby+4mYiCWo ihO4mZiyH0HVfksWldqOGAY1WzzC+WnXEIhVo/bM6qzbOaCUzDKiayhAv+ZJl7zpSodV jkTHwmq3w91FleLeGVxOgWN4+xzlTJy2koy54XCjlpTI+FFvdQr/lYw5hkCNyzWsGp0X vUGdqmVNT9MDZESQn3ItpB+lsj2eV9/TW3qx0BCtV9g8FPgqEwHhApS0NC6VXxc5NSfh rIBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=kLFkLuzZ; 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 f4si878884ilu.143.2021.07.13.23.05.49; Tue, 13 Jul 2021 23:06:10 -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=kLFkLuzZ; 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 S237996AbhGNGIJ (ORCPT + 99 others); Wed, 14 Jul 2021 02:08:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237960AbhGNGIJ (ORCPT ); Wed, 14 Jul 2021 02:08:09 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BFF3C0613DD for ; Tue, 13 Jul 2021 23:05:18 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id d9-20020a17090ae289b0290172f971883bso3166929pjz.1 for ; Tue, 13 Jul 2021 23:05:18 -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=n3xrLCowHoV9+qyE8ZVGJpCIjAP5+VxK4UkQj5GcY2w=; b=kLFkLuzZN/EMGHwlQGVS/UYmwM1Jor+xNSxXNx0vwbUEejkcyGW3ZmWZwpiB1TMCi/ X2cTIJGs3M4vgTulRuQtElHfqpwfIWordoE8h7elKxyTNW4Vj/KhFEuk/g+f8IzSVtWR 1IkdCBY3OhNxNLCR8lAti4i9lqmVQ4fX4VV78= 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=n3xrLCowHoV9+qyE8ZVGJpCIjAP5+VxK4UkQj5GcY2w=; b=VQijLV/dJ9Zb0I4rDp9X3lgt3w4FGEPFOoVP1LtjrBXoa3z525DLQ7TUI8xsz8r6Ec JadxY9eMLTHypck5QCGqbCHEWlvQsa+0TxyLcPHZvvxtYa6TicyFGmdwRiPR9YBnX/F8 /5aENoArslRR9S0/+ny+2yjIUQj21QJ/BJNOUYyKrVluV2Zir4Gr7hU0oG0KSFMUTLRT H0+fHnn00mguAUXFVr8UN2Ommbbox6KWqAuqu9FehxFY4hL3+p5SBMBMleZaCTXiznDN o9VXBAcS0o5mJQhQiAJrUzzzspoy54YKG0ViWBHBrMbEn3uYl4s1yP1PeCPwbwMpUsaE xLkg== X-Gm-Message-State: AOAM532D8xbRp0kFoCdvwAgg9Xbirbk5GAjlIR2EcUiablyw3mBdlP1r gpvwe+272GEQMOB6RAxv4qf73w== X-Received: by 2002:a17:902:ff0c:b029:11d:3e9e:41ec with SMTP id f12-20020a170902ff0cb029011d3e9e41ecmr6557656plj.1.1626242717623; Tue, 13 Jul 2021 23:05:17 -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 m19sm4524468pjl.13.2021.07.13.23.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 23:05:17 -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 , Xin Ji , Hsin-Yi Wang , Yu Jiahua , 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] drm/bridge: anx7625: Use pm_runtime_force_{suspend,resume} Date: Wed, 14 Jul 2021 14:01:59 +0800 Message-Id: <20210714060221.1483752-1-pihsun@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-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 and pm_runtime_force_resume to ensure that anx7625 would always be powered off when suspended. Also update the bridge enable hook to always ensure that the anx7625 is powered on before starting DP operations. Fixes: 409776fa3c42 ("drm/bridge: anx7625: add suspend / resume hooks") Signed-off-by: Pi-Hsun Shih --- 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")) Since bridge disable is called indirectly by mediatek-drm driver's suspend, it might happens after anx7625 suspend is called. So a check if the driver is already suspended via pm_runtime_force_suspend is also added, to ensure that the anx7625_dp_stop won't be called when power is off. And also since bridge enable might happens before anx7625 resume is called, a check to that is also added, and would force resume the device in this case. I'm not sure if the approach to fix this is the most appropriate way, since using pm_runtime_force_resume in bridge enable kinda feels hacky to me. I'm open to any suggestions. --- drivers/gpu/drm/bridge/analogix/anx7625.c | 55 +++++++++-------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index a3d82377066b..9d0f5dc88b16 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1559,7 +1559,20 @@ static void anx7625_bridge_enable(struct drm_bridge *bridge) DRM_DEV_DEBUG_DRIVER(dev, "drm enable\n"); - pm_runtime_get_sync(dev); + /* + * The only case where pm_runtime is disabled here is when the function + * is called other driver's resume hook by + * drm_mode_config_helper_resume, but when the pm_runtime_force_resume + * hasn't been called on this device. + * + * pm_runtime_get_sync won't power on anx7625 in this case since we're + * in system resume, so instead we force resume anx7625 to make sure + * the following anx7625_dp_start would succeed. + */ + if (pm_runtime_enabled(dev)) + pm_runtime_get_sync(dev); + else + pm_runtime_force_resume(dev); anx7625_dp_start(ctx); } @@ -1571,9 +1584,10 @@ static void anx7625_bridge_disable(struct drm_bridge *bridge) DRM_DEV_DEBUG_DRIVER(dev, "drm disable\n"); - anx7625_dp_stop(ctx); - - pm_runtime_put_sync(dev); + if (pm_runtime_enabled(dev)) { + anx7625_dp_stop(ctx); + pm_runtime_put_sync(dev); + } } static enum drm_connector_status @@ -1705,38 +1719,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); - } - - 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) }; base-commit: c0d438dbc0b74901f1901d97a6c84f38daa0c831 -- 2.32.0.93.g670b81a890-goog