Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2248910ybd; Mon, 24 Jun 2019 03:16:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR/ee9Kbi2jtgWqqpulrhKDbQXTZJlh5edGNO+F3fAs9xcXZ2Om2+Ca6H2OtchOSfLpT91 X-Received: by 2002:a17:902:1102:: with SMTP id d2mr16929391pla.149.1561371408425; Mon, 24 Jun 2019 03:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371408; cv=none; d=google.com; s=arc-20160816; b=Ax0Y5/iev2JkrG3H36DFDjZRhJJpZ8ARkdOc5cwcTIIr3bXjGaEff+v/FJrZbJmsXF 9LBB2vKElFj7+SJMGSS1RpxQqWiAR7uKpu8KcmtsWlOrGM46VSJGvwSfxTwxrG+6WJG5 vFX8bPql+np4uFK73/CNNBOKWQvhThgrn+Wv5zJwmSdNFz4a3E8O/aRFK9t8uiMbCPwr 4YGjuwo5UovdtbLrDY8t05Cz4MoJjZVBeow6bMC0JQx65CWfTpKd3N5bdCYRjCbP4fCk U/pXhzaMpP2de69BFew2Of33it4uYOwQ5ed7pfy8lnJ/dQLmlr64Ln4yX6UAnccgJOOh Um9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X45nB9aIHqkdboRr/R40h5ALIIGJyapirehzk7dtYPY=; b=YTLxetiNeiABKV2NJN8yBKdHBFmQ4H6WvE2C2CtFvxh82kMLpLUgKYpmiPcl8h4j/z ZnIb1YI+ndzLDmAPdu6v/cv1zZx7dRzet0A8aIKGOyy8JUIx5Y+ptQlFfJV8jM7bGFQr B1+rk2qcuI6p3S6b/b8XwFZ5BV9d7xvUXKDs4qUdKZCfJn/+NFi2Tytc1mnOSRNCN3gm IQssJzHifp0wYnblZpgo7fthSl/uRRLu+htEhhU/DWVxuBsQ/idsjCJMqfcq8asYl2f4 4hN5vG5rwDQPYlO+4It/gzHU9XE4u+OPSYrVWez9HZZ2ltI8rhosq7OL8J1AF5dCLFrr IBbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HVnlY6DA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si9903068pgv.81.2019.06.24.03.16.32; Mon, 24 Jun 2019 03:16:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HVnlY6DA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729182AbfFXKQP (ORCPT + 99 others); Mon, 24 Jun 2019 06:16:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:53654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730228AbfFXKQM (ORCPT ); Mon, 24 Jun 2019 06:16:12 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D32DC205ED; Mon, 24 Jun 2019 10:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371371; bh=Y/MYH8fEzOhlLXY1NSLeaKuxk3L/Epd5P+oRdNS6+aU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVnlY6DA4nlDDe8fn1usY5p8SSnXKPKohIoNmT0J2xCnhamWbrFw2AzB8DpaFw9WQ c8LjtNU76uIO0lmg1lfyDTllh1B5flYpub/Sb9AlqSMGUdghtzgfWtsiVG8l8eTVNn zl/vUm25PGpuwi3a1QSrp6fN2rjgvzzsyW0IvCgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Liviu Dudau , Sasha Levin Subject: [PATCH 5.1 071/121] drm/arm/hdlcd: Actually validate CRTC modes Date: Mon, 24 Jun 2019 17:56:43 +0800 Message-Id: <20190624092324.519615127@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit b96151edced4edb6a18aa89a5fa02c7066efff45 ] Rather than allowing any old mode through, then subsequently refusing unmatchable clock rates in atomic_check when it's too late to back out and pick a different mode, let's do that validation up-front where it will cause unsupported modes to be correctly pruned in the first place. This also eliminates an issue whereby a perceived clock rate of 0 would cause atomic disable to fail and prevent the module from being unloaded. Signed-off-by: Robin Murphy Signed-off-by: Liviu Dudau Signed-off-by: Sasha Levin --- drivers/gpu/drm/arm/hdlcd_crtc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c index 0b2b62f8fa3c..ecac6fe0b213 100644 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c @@ -186,20 +186,19 @@ static void hdlcd_crtc_atomic_disable(struct drm_crtc *crtc, clk_disable_unprepare(hdlcd->clk); } -static int hdlcd_crtc_atomic_check(struct drm_crtc *crtc, - struct drm_crtc_state *state) +static enum drm_mode_status hdlcd_crtc_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) { struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc); - struct drm_display_mode *mode = &state->adjusted_mode; long rate, clk_rate = mode->clock * 1000; rate = clk_round_rate(hdlcd->clk, clk_rate); if (rate != clk_rate) { /* clock required by mode not supported by hardware */ - return -EINVAL; + return MODE_NOCLOCK; } - return 0; + return MODE_OK; } static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc, @@ -220,7 +219,7 @@ static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc, } static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = { - .atomic_check = hdlcd_crtc_atomic_check, + .mode_valid = hdlcd_crtc_mode_valid, .atomic_begin = hdlcd_crtc_atomic_begin, .atomic_enable = hdlcd_crtc_atomic_enable, .atomic_disable = hdlcd_crtc_atomic_disable, -- 2.20.1