Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp275911ybz; Thu, 23 Apr 2020 23:39:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKQR/WNt1KBCAD4o/n6wHDmXOK0X2bHxE9mjgAwhfpiLT2R6uQu0mft+AWXjy6YW2Y2n6sT X-Received: by 2002:aa7:df8d:: with SMTP id b13mr673207edy.145.1587710339842; Thu, 23 Apr 2020 23:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587710339; cv=none; d=google.com; s=arc-20160816; b=svxT83kiHbrWxfMXJ7dVfOSxhw1rS5nBQgYBytNSCTxltDVPcz6WEl6KDC87W48aew igAVLHXbFH8rUrzoFNBOIi98h4RhzwPibiI04L7WwPnJmJ7LsydgYarisAzsAOl4Jqu1 9o+Bc7AxenwiuSSnT7q7W0RfUO8M59OHXP6RGpwA1Qwya6DUu7oIZR5icnQ5a5wi75YB +RKqH1glSJ8abBrTE82WrfbMRwslMJiUWWh6UcyC20uox60lt7lS8sLeUakVxUf2oADw 0uiOtFUxLb+vWN+RxyigRZJ5hrFfFZA0l9ykutNmj0JQsWmt2ZK31zZQWrW5zx9uuUYn mqXA== 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 :message-id:date:subject:cc:to:from; bh=k+vbXxMZYVQrbZIr20Pso+CRzZsxwxF5HOwCo0+PNVQ=; b=vX2phxUU2yS3zp5sMb0thKsVrn+Du8CqvmfFdeC83XKP7scrqQTkomwkpMhxLbjRga P2NGvXICwfO2B5lVam7V9C+08/JP5speVjXC3RbbmqB4TkTNm3fNAwDajZmKW9Vxp5pZ a+aNKsD1g76xEYqH85ED5aVwfhx+TK3+TxN/uX6fZDINDmeAU/e2uo5kBzjT++41G+pg 26qnkOVpGRjCpWZuE5AJJ4sWT7YJ/7IpS80JTT3UdwSbNKDEH4UrTYG+kpZLTgbNI67U Ks+s/w2p5x8EC8MTnZ/fburKf8EfyM031+uyXL85WcLtRpYlb9VTveDCb/qrTOjAxABX AQbw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m2si2528685ejk.483.2020.04.23.23.38.36; Thu, 23 Apr 2020 23:38:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726386AbgDXGgV (ORCPT + 99 others); Fri, 24 Apr 2020 02:36:21 -0400 Received: from mail-m17613.qiye.163.com ([59.111.176.13]:16337 "EHLO mail-m17613.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725868AbgDXGgV (ORCPT ); Fri, 24 Apr 2020 02:36:21 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by mail-m17613.qiye.163.com (Hmail) with ESMTPA id C0A69482514; Fri, 24 Apr 2020 14:36:12 +0800 (CST) From: Bernard Zhao To: Liviu Dudau , Brian Starkey , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH v2] drm/arm: fixes pixel clock enabled with wrong format Date: Thu, 23 Apr 2020 23:35:51 -0700 Message-Id: <20200424063551.14336-1-bernard@vivo.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZTlVOS01CQkJCTUJPQ0lPSVlXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PxQ6Ijo*PTg*HlYTM0IQNSIQ HBQaCSJVSlVKTkNMTEpLSkxNS09IVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSElPTTcG X-HM-Tid: 0a71aae69f0d93bakuwsc0a69482514 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pixel clock is still enabled when the format is wrong. no error branch handle, and also some register is not set in this case, e.g: HDLCD_REG__SELECT. Maybe we should disable this clock and throw an warn message when this happened. With this change, the code maybe a bit more readable. Signed-off-by: Bernard Zhao Changes since V1: *add format error handle, if format is not correct, throw an warning message and disable this clock. Link for V1: *https://lore.kernel.org/patchwork/patch/1228501/ --- drivers/gpu/drm/arm/hdlcd_crtc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c index af67fefed38d..f3945dee2b7d 100644 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c @@ -96,7 +96,7 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc) } if (WARN_ON(!format)) - return 0; + return -EINVAL; /* HDLCD uses 'bytes per pixel', zero means 1 byte */ btpp = (format->bits_per_pixel + 7) / 8; @@ -125,7 +125,7 @@ static int hdlcd_set_pxl_fmt(struct drm_crtc *crtc) return 0; } -static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc) +static int hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc); struct drm_display_mode *m = &crtc->state->adjusted_mode; @@ -162,9 +162,10 @@ static void hdlcd_crtc_mode_set_nofb(struct drm_crtc *crtc) err = hdlcd_set_pxl_fmt(crtc); if (err) - return; + return err; clk_set_rate(hdlcd->clk, m->crtc_clock * 1000); + return 0; } static void hdlcd_crtc_atomic_enable(struct drm_crtc *crtc, @@ -173,7 +174,11 @@ static void hdlcd_crtc_atomic_enable(struct drm_crtc *crtc, struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc); clk_prepare_enable(hdlcd->clk); - hdlcd_crtc_mode_set_nofb(crtc); + if (hdlcd_crtc_mode_set_nofb(crtc)) { + DRM_DEBUG_KMS("Invalid format, pixel clock enable failed!\n"); + clk_disable_unprepare(hdlcd->clk); + return; + } hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1); drm_crtc_vblank_on(crtc); } -- 2.26.2