From patchwork Thu Oct 29 12:25:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 11866233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1AA8C55178 for ; Thu, 29 Oct 2020 12:26:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22EB920796 for ; Thu, 29 Oct 2020 12:26:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bmtntKxV"; dkim=temperror (0-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="UkmwfPRy"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nwURPV8Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22EB920796 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=G+oSAyjYFnRe1n1WeoMSJweDaSn6GU2YBW89V+4ZJt0=; b=bmtntKxVy20pSQ/Q64BkUeAq/J gKusy6uAVsDS97El1J1EzAplawJnRTyb0KD+RFuWmQ+igLBLDqXBw2FrnE1ohiDfT6Bv0RS9yg6M/ ahU41GYUnPm6HEW1x1WWu0QyzlMAzOOjhLAlxbdKG4xXBKpyK1fADUTQqsILc7Gkvx9Ze3DNBDIQl wy8aVT314H7YgAjqEeWFda3MA7mUho1edriPkjT4eF/bW+B7fNcrMctgwG8F4ILpmTZ9b2y7kj/QI 8lmF7cOGd/KUMteVzBWBMQBy8ez+BvvDfcKv/6y/UyvNsIx410k+LUWxnD9LwvhqM2TaKj/baQUCP WlenuGVg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY6zk-0003Xu-Q8; Thu, 29 Oct 2020 12:25:32 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY6zi-0003Wa-63; Thu, 29 Oct 2020 12:25:31 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id C10F7580518; Thu, 29 Oct 2020 08:25:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 29 Oct 2020 08:25:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=6EQlP+QGHRkogkEJOSa/mjPMd/ dcifzWBOtZuULOoew=; b=UkmwfPRyP8wXV2xeVvohOpniZ95gaqCrurNEPPLw+E koKnJsuFeAVfeJ+GpaBFJozyY7Zli/ezaUB5vb9KLgonu7tDZQ2C6LqRHIq9VMY1 Ge63FSHU8AJ71HfUxzSvVZmyUUzbEbwNjSBjMzNTmqjE85owGuQwHoXn+iVlR/6A Dhxp+Y3oQDnYVhY5peU8G2q/oVeLIJPQFllDmvpTfFGtgJsfLc3gVCL7YRi8O8YM Toyb3ukJ1uQoEAgmij5yNKqe5KbbWX4+J5nbxwyAxN7lVjcpCQYGnsDC8Rp7dZ5d 9Enkp6HD2vDhv8Z8LyRBs/Rbwy2HjU4l63jDLvazl1hA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=6EQlP+QGHRkogkEJO Sa/mjPMd/dcifzWBOtZuULOoew=; b=nwURPV8QTUv/E8jF+ae5gOSFy5eDhC3Tl X6C5Np4UXdsx0s6clCEtpzamipMnUoJCZq+4va3swRHHsCVSf4K+fdx7nFDn/s34 FW2xp5W53GMpYMj/IwVaYZeluvVphMDIaQwjRwmy8QMJ5BBOfxgbs0u4qPEMmsRw p7JLfkceN5PSr6VPT8c5CSaHsl0ZtAMHQ87+r3eWebNNye9Ukdp57OzVQ4Q2so0z nOQxNJ9zYz2dljfHmV/8FsSg14XQRGKZ1Mn0K6BqY8+GwElOFRINqhakpbrBvRnX H5EEq1yBG7H5ujO39QTy9eGOBDc9UrlH4oU7oYCwR+kwQ9V4fzE1g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleefgdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepofgrgihimhgvucft ihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtthgvrh hnpeejffehuddvvddvlefhgeelleffgfeijedvhefgieejtdeiueetjeetfeeukeejgeen ucfkphepledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 6201B3280059; Thu, 29 Oct 2020 08:25:25 -0400 (EDT) From: Maxime Ripard To: Mark Rutland , Rob Herring , Frank Rowand , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Eric Anholt Subject: [PATCH v2 1/2] drm/vc4: hdmi: Make sure our clock rate is within limits Date: Thu, 29 Oct 2020 13:25:21 +0100 Message-Id: <20201029122522.1917579-1-maxime@cerno.tech> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_082530_326221_CAA47D7D X-CRM114-Status: GOOD ( 15.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Tim Gover , Dave Stevenson , dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Phil Elwell , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The HDMI controller cannot go above a certain pixel rate limit depending on the generations, but that limit is only enforced in mode_valid at the moment, which means that we won't advertise modes that exceed that limit, but the userspace is still free to try to setup a mode that would. Implement atomic_check to make sure we check it in that scenario too. Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson --- Changes from v1: - Added that patch to resolve a conflict --- drivers/gpu/drm/vc4/vc4_hdmi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index e8f99e290655..3d0338822cd2 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -760,6 +760,20 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) { } +static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct drm_display_mode *mode = &crtc_state->adjusted_mode; + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); + unsigned long long pixel_rate = mode->clock * 1000; + + if (pixel_rate > vc4_hdmi->variant->max_pixel_clock) + return -EINVAL; + + return 0; +} + static enum drm_mode_status vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder, const struct drm_display_mode *mode) @@ -773,6 +787,7 @@ vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder, } static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = { + .atomic_check = vc4_hdmi_encoder_atomic_check, .mode_valid = vc4_hdmi_encoder_mode_valid, .disable = vc4_hdmi_encoder_disable, .enable = vc4_hdmi_encoder_enable,