Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1612226pxb; Fri, 1 Oct 2021 14:55:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBtTWTiPXy6X2ZdhR+fQbRplLAk80KYA/kYElsyrYrQgv8D0yU5AvF5O3L7z8w7Ki+fKsf X-Received: by 2002:a17:90b:4c8a:: with SMTP id my10mr15624489pjb.49.1633125316115; Fri, 01 Oct 2021 14:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633125316; cv=none; d=google.com; s=arc-20160816; b=vBf8EYRYZQiwaH3mdnBtGzZIOniEllqgoLRbOlf6r26rCU5i/xMXDZjfaTiSWv/nv3 lrZGePZ5mSU6IwRElH8zGkkboedq3vVaPY0WQCHrSUlh2zla+EHW8Q032hhNePF69v+t A21ECeKpwiTY/fT0WBg/YsqFPyiZp5J1NSWY4uCHvZ2QoNxCzVgKcuC5Ml/u4DbxhAsN 6b2RVH3ZpShT3gYvlI+2cKBKIAzLcFy2FbFGEXWJeWLtuLtAFrIYNhUuqCDi+usDtuE5 Mekcv8k94s871afVGYtz/brAJblVDARjdB5q9PBE0ow/cuL58/WFYXs1FYQ0op1/aNxB 8W2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=NL7Ui4pDzKD6Cqfc/rSld3tguEIwYPG7fUSYDal4DEY=; b=s4KIERWJpkLh4KcwV294OO2Aui7TqMOjoamRd7YJIDIKcm0N+Pgb/BsjzUkwSTCO5g xwh9YVkpxKER3esOmyC2qhsMcHd1qMcqlRuodf1OiAGhxGb5p2H0zavFvZYPbw8fV9gM qa5jBrULzruUmGoIUEwTGXox6rN0Hl0eHCEQQppzGbbqAkhTrMUn3f0+SxQaUB/SXFcF Yi/fLb0MvYrvd7JfB4vo0vh5A4vwVgg2BAg1nlRnggR4dcetYqqBPQg8vdYLt0XTEk0Q nvewbyF3jzs1xfaRKgKwk1tLHoRTaghfwMmmN0SCXCgzW0CsYvOvmf82n2a411P0obO0 RASw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=m5z3+8aU; 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=pass (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 w20si9933869pga.457.2021.10.01.14.55.02; Fri, 01 Oct 2021 14:55:16 -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=pass header.i=@chromium.org header.s=google header.b=m5z3+8aU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbhJAVwD (ORCPT + 99 others); Fri, 1 Oct 2021 17:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhJAVwC (ORCPT ); Fri, 1 Oct 2021 17:52:02 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44CBAC06177E for ; Fri, 1 Oct 2021 14:50:18 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id t4so7172461plo.0 for ; Fri, 01 Oct 2021 14:50: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=NL7Ui4pDzKD6Cqfc/rSld3tguEIwYPG7fUSYDal4DEY=; b=m5z3+8aUGB1/aVqhdvcvLjWaweeugGKaJ2xm3YgW2o29YhTbamwXAXZg7cLIQD1tCZ fvN2Q8ZX5iSk4zKhCdWb49sctlPcBg+q1vWgc1vYwKqU9r/8vkuzpBrHdzDf921Ezfiv q5Lh1OIAONXX9dSbdT7CpFkVidsPqatUSsulg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NL7Ui4pDzKD6Cqfc/rSld3tguEIwYPG7fUSYDal4DEY=; b=7KuJV1npxVQQQT9k8fYOhh96VFgGxa5TyNMa8kI2OmSd+fb/OwNoCSyswWJH0RWpCS rHNLQfeSbhxncNsiyseGUo2YeKqvpboLThe+56QBbXMva2W4drV40OBoOwbGKuoOOrwI fEAGNl+AdHaU3JMU6/uXZhCgjkEEGgnvXv0/gkI7Ar0/bNZXDtExW47Xftv0QG7RJpVX Y8BMPyZbhj4YegOG3qdClWirWszTESTb6pq83X2a4w3gfsv4Rag+yXMXUa7nIWXFHv0y misZZ/TYwdaQdQhSNYW5KMSrx9Azof+WU5NYmy/2FdIvPY3SRw4vxCX5V5NGEdZ3ya36 Up2A== X-Gm-Message-State: AOAM530kih5XSyXQzFmQF++OInfe/kv4SrgCdtPUma2oAdSV6kXAjE49 drWVx2O+AA9Lixe2JZJ/gBYwww== X-Received: by 2002:a17:90a:16:: with SMTP id 22mr22720079pja.25.1633125017619; Fri, 01 Oct 2021 14:50:17 -0700 (PDT) Received: from localhost ([2620:15c:202:201:1e7d:5e91:4390:d04b]) by smtp.gmail.com with UTF8SMTPSA id d5sm6405749pjs.53.2021.10.01.14.50.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Oct 2021 14:50:17 -0700 (PDT) From: Brian Norris To: Andrzej Hajda , Neil Armstrong Cc: Sean Paul , Jonas Karlman , linux-kernel@vger.kernel.org, Jernej Skrabec , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Brian Norris , stable@vger.kernel.org, Tomeu Vizoso Subject: [PATCH v2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX Date: Fri, 1 Oct 2021 14:42:55 -0700 Message-Id: <20211001144212.v2.1.I773a08785666ebb236917b0c8e6c05e3de471e75@changeid> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the display is not enable()d, then we aren't holding a runtime PM reference here. Thus, it's easy to accidentally cause a hang, if user space is poking around at /dev/drm_dp_aux0 at the "wrong" time. Let's get the panel and PM state right before trying to talk AUX. Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code") Cc: Cc: Tomeu Vizoso Signed-off-by: Brian Norris --- Changes in v2: - Fix spelling in Subject - DRM_DEV_ERROR() -> drm_err() - Propagate errors from un-analogix_dp_prepare_panel() .../drm/bridge/analogix/analogix_dp_core.c | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index b7d2e4449cfa..6fc46ac93ef8 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -1632,8 +1632,27 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { struct analogix_dp_device *dp = to_dp(aux); + int ret, ret2; - return analogix_dp_transfer(dp, msg); + ret = analogix_dp_prepare_panel(dp, true, false); + if (ret) { + drm_err(dp->drm_dev, "Failed to prepare panel (%d)\n", ret); + return ret; + } + + pm_runtime_get_sync(dp->dev); + ret = analogix_dp_transfer(dp, msg); + pm_runtime_put(dp->dev); + + ret2 = analogix_dp_prepare_panel(dp, false, false); + if (ret2) { + drm_err(dp->drm_dev, "Failed to unprepare panel (%d)\n", ret2); + /* Prefer the analogix_dp_transfer() error, if it exists. */ + if (!ret) + ret = ret2; + } + + return ret; } struct analogix_dp_device * -- 2.33.0.800.g4c38ced690-goog