Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp599421pxb; Thu, 19 Aug 2021 07:03:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPPTRlwY/lGa6tkhDVjou1v7i58DGIuqWlnpi2x0n6GLnqUdBVY+DbFxfEHNkAWHDWhjwx X-Received: by 2002:a05:6638:2384:: with SMTP id q4mr13130671jat.54.1629381792547; Thu, 19 Aug 2021 07:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629381792; cv=none; d=google.com; s=arc-20160816; b=hBxDhPboZdzCgakOQFZR/CILoa5xlgzWQXWgTXCXtWDaNyXZxuObmfUBj6hq0/nt32 7NyOVOk/V/eoMOp6ESQ5XIH2B5iLmQ8VUEmQSyfil/zrOUyzemlcvXAmpR1eTlsVcpS+ IBMczhtVmF2uRU+g5d9bDiYPrhIwbyBZi3v2P334Ns6HEZkCk/S61KSR/fRzKHJQQ6CK NLFmJiNU/EeIVe+Bk4STHgPgc0T3wSIfwxQmlJmEtuwO0fme7M3X2ooBMVlcmwa5JM7D 5CT4fEmFjlu2s6h02OOY+/rtc2Jjvl/4EUDvFsepNedgOgmh+Hzv8yVQ13ShFe3g4Syy jQGQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=4H7t3dGcw4dBJONd4xZXRCqXccSjowURhdhQwcutobw=; b=Xo/+U233hQsP5qG0YSaQ/yCa+7TF/mrK0roxrpLhJUmTyoWXkRhUOcrzkaPw3LOwWx vaRLu+QLBpptLdMEHKRccOvSB6cYvTdmY+A/YFeY4hXZVB1TkaYSh1mtCKLRy1BLKwP5 WncqYrAnqFKku+FOP7/csnVJLWoOrvewOXi0AJS91haM6RvgvCiblOttJXLJOtlu8gkP 4IOcbezHfaslu9OZo0T29y11UPIJnYIdmbyeNs4okOBjeLfEEcdNB9iE/7kq2zDZz/vT tDrhFUBigzcKZdnFHlvnkGH32aKGyIhH0laeDU8kulSVPuy2F/9HHmTHs8jmHmAvEdWt onJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=E3awQcI2; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=U2N2kQVV; 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=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t4si3915083iof.69.2021.08.19.07.03.00; Thu, 19 Aug 2021 07:03:12 -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=@cerno.tech header.s=fm3 header.b=E3awQcI2; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=U2N2kQVV; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240478AbhHSOAj (ORCPT + 99 others); Thu, 19 Aug 2021 10:00:39 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:47525 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240458AbhHSOAh (ORCPT ); Thu, 19 Aug 2021 10:00:37 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id C616F2B005D0; Thu, 19 Aug 2021 09:59:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 19 Aug 2021 10:00:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=4H7t3dGcw4dBJ ONd4xZXRCqXccSjowURhdhQwcutobw=; b=E3awQcI2GOZooP7DCvRTVk/9NubKk DqpuVXMMO9naGANJflM3Do0In7ZpaI/05BYo5aPR+UkUJM2qFtysQRp7d8HodEaM lYUB+tHnk0jmuers0op7NqJ+3fkHvzgL4x3Tm1F/F4ZGzjg6t70bmmnkMq9IX9Kl uzAGpzOj+4a+TEheZxp0MqIQgC4QYDmZM+aAYbE8ffVitE7Ek1zOM3xBsFvlAw1w KVJUREmOoOxCoyBbhTq7m+gz20BzOuhbvnjPbdWAF0m++hUstiQlGsGi9rO4V29A R7XMm1QyVWArP+HzpX90U1bSQNUCm3nhoIwqSrCp77hmbU+JpI7dZucog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=4H7t3dGcw4dBJONd4xZXRCqXccSjowURhdhQwcutobw=; b=U2N2kQVV Zl2m06YaCp2Sf17jJvfGTIcn1h1tYBowXCBk13o5Dh1PUqSDONfomIgA8LWfjTUx WylNqMBmwycmJhTDqWzrQ14SHTntUgnWT6ZKWbG0HPwybzgVHowRmpECB2ZSpOio exM2xsclog3reo+KSIaNGfufxjWPsrH9RWe65YZzEFwpSiGZSPdDqtZwoZBRtjy7 /A2Be+o9k+KkAJHkn8goMaXZ83xKLNuIeugWQ5J49B4BQEnWW4w3WoB41GNfftwP M/ExlsQKVA42cY/cuGcyprkkeNsvthp0lMMUQSh/L1wij0ZQtso30cEVmYk82jTF HmCAWHNKaH+5Vg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrleejgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Aug 2021 09:59:56 -0400 (EDT) From: Maxime Ripard To: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Cc: linux-kernel@vger.kernel.org, Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , Boris Brezillon , linux-rpi-kernel@lists.infradead.org, Hans Verkuil , bcm-kernel-feedback-list@broadcom.com, Emma Anholt , Nicolas Saenz Julienne , Maxime Ripard Subject: [PATCH v3 5/6] drm/vc4: hdmi: Make sure the device is powered with CEC Date: Thu, 19 Aug 2021 15:59:30 +0200 Message-Id: <20210819135931.895976-6-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819135931.895976-1-maxime@cerno.tech> References: <20210819135931.895976-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similarly to what we encountered with the detect hook with DRM, nothing actually prevents any of the CEC callback from being run while the HDMI output is disabled. However, this is an issue since any register access to the controller when it's powered down will result in a silent hang. Let's make sure we run the runtime_pm hooks when the CEC adapter is opened and closed by the userspace to avoid that issue. Fixes: 15b4511a4af6 ("drm/vc4: add HDMI CEC support") Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index bfa35e32052f..53647ce902ae 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1745,8 +1745,14 @@ static int vc4_hdmi_cec_enable(struct cec_adapter *adap) struct vc4_hdmi *vc4_hdmi = cec_get_drvdata(adap); /* clock period in microseconds */ const u32 usecs = 1000000 / CEC_CLOCK_FREQ; - u32 val = HDMI_READ(HDMI_CEC_CNTRL_5); + u32 val; + int ret; + ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); + if (ret) + return ret; + + val = HDMI_READ(HDMI_CEC_CNTRL_5); val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET | VC4_HDMI_CEC_CNT_TO_4700_US_MASK | VC4_HDMI_CEC_CNT_TO_4500_US_MASK); @@ -1789,6 +1795,8 @@ static int vc4_hdmi_cec_disable(struct cec_adapter *adap) HDMI_WRITE(HDMI_CEC_CNTRL_5, HDMI_READ(HDMI_CEC_CNTRL_5) | VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET); + pm_runtime_put(&vc4_hdmi->pdev->dev); + return 0; } -- 2.31.1