Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp556264ybk; Fri, 15 May 2020 07:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww5QRcKGnUEP6/yYtcH459Xx+jbvU513I/z92LXZWAfcCw+2rKchnxbfxzG4w9jnJcAKL+ X-Received: by 2002:a17:906:7204:: with SMTP id m4mr3198808ejk.48.1589553810735; Fri, 15 May 2020 07:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589553810; cv=none; d=google.com; s=arc-20160816; b=kwnjdN9rReVV9D7xFH/8aSpNC8wkcQLqO4gV5gFcR1GkMGv3OCbjUR8+mw4fuh0pE6 1+suPdm1za4CxNtZA+9AA2ZrDJnVZ3gCRrUaW35le8GV0o+Rh4QRdqsXt3GMYR3k7ILJ isji3s5xBerBGqMUweAtPQSMGzVjhCEiN9zyO+qfCdixzua6ztn7DYGVmd/OQ8D7nl0Z H9jelw4YeWuh9lYev8W4B2Re+SxJyaw0Ze+DLq4ppXaNYiqm3ar2SDhylQUdw4N1OHcK qrI0GzgXfEM4pHOw9O8xNDccYeXPNx9JVd/Glk9uhst/hy92ltej9pTb666f3zxt8txT 7d/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xC3BfuVLVXbpetdLHEwyGeCiOtiTJsOLluCHF5ZLk6M=; b=Y6D3Q2h0igy3XCREH6N6p8aTdF3jJRznGxQ3dYpNMfXUxWBvkaV26nwfKGCypLBO9R WGo0GwWcYujx2WoYard/ckWNaHRXJoukGgz9WoKldXSJrhIteCmKH6zYO95PjLPElDcq Jg0eKnXu6lnTNJtgG1sm8FT3nlT+DWZ2y4gQ1FxjkbE+oJiHBPKyrnoSVMKBDNU2eAx0 14wlHhRVHQDyk5ookTGg0g2CYSLte04m395bEGM7pL+ok8zlsP3GBVIBA0WZyfQiZCkN S52JEw1LFVA/lghdyI3cVNQf8AaVEXFyUHf+/hS/w0krobBntJ9SSc7JNO4OZA+JYe7G M4nw== 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 t9si1223538edw.135.2020.05.15.07.43.08; Fri, 15 May 2020 07:43:30 -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 S1726213AbgEOOlv (ORCPT + 99 others); Fri, 15 May 2020 10:41:51 -0400 Received: from foss.arm.com ([217.140.110.172]:57118 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbgEOOlv (ORCPT ); Fri, 15 May 2020 10:41:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 99A3F2F; Fri, 15 May 2020 07:41:50 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6099A3F71E; Fri, 15 May 2020 07:41:50 -0700 (PDT) Received: by e110455-lin.cambridge.arm.com (Postfix, from userid 1000) id 24973682B70; Fri, 15 May 2020 15:41:49 +0100 (BST) Date: Fri, 15 May 2020 15:41:49 +0100 From: Liviu Dudau To: Bernard Cc: Brian Starkey , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com Subject: Re: Re:Re: [PATCH v2] drm/arm: fixes pixel clock enabled with wrong format Message-ID: <20200515144149.GN159988@e110455-lin.cambridge.arm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bernard, On Fri, May 08, 2020 at 04:47:17PM +0800, Bernard wrote: > From: "赵军奎" > Date: 2020-04-24 19:37:36 > To: Liviu Dudau > Cc: Brian Starkey ,David Airlie ,Daniel Vetter ,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org,opensource.kernel@vivo.com > Subject: Re:Re: [PATCH v2] drm/arm: fixes pixel clock enabled with wrong format > > > > > From: Liviu Dudau > Date: 2020-04-24 19:09:50 > To: Bernard Zhao > Cc: Brian Starkey ,David Airlie ,Daniel Vetter ,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org,opensource.kernel@vivo.com > Subject: Re: [PATCH v2] drm/arm: fixes pixel clock enabled with wrong format>Hi Bernand, > > > >On Thu, Apr 23, 2020 at 11:35:51PM -0700, Bernard Zhao wrote: > >> 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; > > > >That is the right fix! > > > >> > >> /* 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) > > > >But this is not. We don't need to propagate the error further, just .... > > > >> { > >> 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; > > > > My previous understanding was that when such an exception occurred, it was caught > in the atomic_enable interface, and then disable pixel clock. I am not sure is this ok or > i have to do more register clean operaction. > > >... return here so that we don't call clk_set_rate(); > And for this part, i am a little confused : > 1 clk_set_rate must be set even if format is wrong? > 2 The original code logic shows that If format is not correct, we will not set registers > HDLCD_REG_PIXEL_FORMAT & HDLCD_REG__SELECT, will this bring in > any problems? > 3 if 1 the rate must set & 2 registers above doesn`t matter, then maybe there is no > need to disable pixel clock. > Am i misunderstanding You are right, the pixel format check should not happen inside hdlcd_crtc_atomic_enable() hook, it should be moved into a separate function hdlcd_crtc_atomic_check() and that needs to be hooked into .atomic_check() for hdlcd_crtc_helper_funcs(). If you want to have another go I'll be happy to review and Ack your patch. Best regards, Liviu > > Regards, > Bernard > > >> + 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 > >> > > > >-- > >==================== > >| I would like to | > >| fix the world, | > >| but they're not | > >| giving me the | > > \ source code! / > > --------------- > > ¯\_(ツ)_/¯ > > > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯