Received: by 10.223.176.5 with SMTP id f5csp3462196wra; Mon, 29 Jan 2018 13:33:58 -0800 (PST) X-Google-Smtp-Source: AH8x226K6LMfFo1KuERWbDK1dC+03SD5mfp+otSSlqPZm75vQPAz5PqqlfycvptvcMiQ24bhku7n X-Received: by 10.98.18.10 with SMTP id a10mr28450477pfj.140.1517261638045; Mon, 29 Jan 2018 13:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517261637; cv=none; d=google.com; s=arc-20160816; b=RGZ9JRkIPVqfCRWPMvjzPCD/D6v1EyngyxwXZ0GukeUfN+mmgtNnz+iPlvECg56Xsi 9muERRQAVaqAf/wq9AMckXRnWD/bibkSvulnmFWjgTmNsF7D4SgvNMGQL+JgNXm1rFeL wEBGwgFAeyvohjPzA5b1LOhvOHp9Iko5W1XArIjJfkffMjhApLshr6wkqDWSiQsHthC0 VhaTb3KeQDyUezRKVNq20cRo2CQIfAbx18z4pZQcinpj5FOMWNlA5Jnq7Huc/DbEWCKZ 7F5fZWqo7bVqiLBFRHQWtYSWN00/z7YLHb6mmJrmkObCBveHwo1fyzM1CSilR4F5eFBB kI8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=E6BcT4gmPvMVXKausAIu7GTSPy3uftK2oYPMFfEf9oA=; b=ZXA+U9ZLhJoqICg4elsC23FDY/VhLXpQThYVBhG8vS2ivrM5n61yzCpSQWeqC6gqK7 i6Yyv0roc9I6pfiIYFXk3vkFWqlTc7YEwh/gFuM2KjjTuWH6KAjHopWrNdYg2YdPq7MZ 82zM5lORRmiv64S+D2faz/BWCtjuVeSn3nQJ8zzvwC6Zv+KAv43oSPflJ1mky6qGgEC6 ZbAWiTfIZCHHkPrwkEs/VMRUq9atOYJQHttAuGman1whEKacAepATRF9TdKmrCnMyD48 dMww2v0/QyAhUW9PfOjYuEWXQMMTGYquoFBfPIPHX6NJAKA3C6jzVRzPgv41bHygHkMD q9jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f9Bz/fCV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y128si8075990pgb.55.2018.01.29.13.33.43; Mon, 29 Jan 2018 13:33:57 -0800 (PST) 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=@chromium.org header.s=google header.b=f9Bz/fCV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751739AbeA2Vbf (ORCPT + 99 others); Mon, 29 Jan 2018 16:31:35 -0500 Received: from mail-yb0-f193.google.com ([209.85.213.193]:37166 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751654AbeA2Vbe (ORCPT ); Mon, 29 Jan 2018 16:31:34 -0500 Received: by mail-yb0-f193.google.com with SMTP id p83so3385476yba.4 for ; Mon, 29 Jan 2018 13:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=E6BcT4gmPvMVXKausAIu7GTSPy3uftK2oYPMFfEf9oA=; b=f9Bz/fCVzkqa3yXaM0gWIOLZ85ycw52aPIfBq/MXCrW9baaAQL99P4WsnafH1RjxiA GKDciRHknprYXAWhZtj1N8OfjJDrddguPAz/j0uOdCJ+lxt/HJETG6Z/l+bKk2lMO1ic hYDh+ayP+ImA6rRbty5hEakSjxx5rmMCoGeas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=E6BcT4gmPvMVXKausAIu7GTSPy3uftK2oYPMFfEf9oA=; b=oUv3/8m3r79HFBKp9UoTJRZz65hrSUO8goFjPAlelaBmDCX+ut8qTdlZVN/VwWbbBJ YHeau0IDzjjDy/qgqWZFNSmEjbiXPItFt5SdvSvzL/h55SpyQWfulvaz3DOTk7E6c8W9 KRrOprxf/wdwzaaJPeUaW8ZFa9woAgDZ/JemMk65jE4BVOpV/nNlHGJZZsSLCJVl5yC+ MiGQECfpFfk8lwEcj1JDAaf7zDlz7x8IWkYU11g86+GIrRYBluV7yEmRmQ4B4CGlSID1 q8aPMLKQKPIqZ0GBWv6wRMy6WiA9NpQYEWeHUZcdbZARZeQ2gB5yGAQk3DgWDuDqbgCF x1yA== X-Gm-Message-State: AKwxytfEsbp/cpLdcTolArpCLcucGgzN0sUK/DSUDXomoV8Q88nqrr09 B6iQO44aKMFk4HJPygPfAf3oXQ== X-Received: by 10.37.123.133 with SMTP id w127mr18275367ybc.274.1517261493375; Mon, 29 Jan 2018 13:31:33 -0800 (PST) Received: from localhost ([2620:0:1013:11:d3af:69ac:1964:28e8]) by smtp.gmail.com with ESMTPSA id n6sm4823359ywm.79.2018.01.29.13.31.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Jan 2018 13:31:32 -0800 (PST) Date: Mon, 29 Jan 2018 16:31:32 -0500 From: Sean Paul To: Thierry Escande Cc: Archit Taneja , Inki Dae , Thierry Reding , Sandy Huang , Sean Paul , David Airlie , Tomasz Figa , Haixia Shi , =?iso-8859-1?Q?=D8rjan?= Eide , Zain Wang , Yakir Yang , Lin Huang , Douglas Anderson , Mark Yao , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v2 22/43] drm/bridge: analogix_dp: Check dpcd write/read status Message-ID: <20180129213132.wmkhg45bt24dnuog@art_vandelay> References: <20180126131710.7622-1-thierry.escande@collabora.com> <20180126131710.7622-23-thierry.escande@collabora.com> <20180129211441.juzdm2qggw6igvqj@art_vandelay> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180129211441.juzdm2qggw6igvqj@art_vandelay> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 29, 2018 at 04:14:41PM -0500, Sean Paul wrote: > On Fri, Jan 26, 2018 at 02:16:49PM +0100, Thierry Escande wrote: > > From: Lin Huang > > > > We need to check the dpcd write/read return value to see whether the > > write/read was successful > > > > Cc: Kristian H. Kristensen > > Signed-off-by: Lin Huang > > Signed-off-by: zain wang > > Signed-off-by: Douglas Anderson > > Signed-off-by: Sean Paul > > Signed-off-by: Thierry Escande > > Reviewed-by: Andrzej Hajda > > --- > > drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 181 +++++++++++++++------ > > 1 file changed, 132 insertions(+), 49 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > > index 846574d0dcb0..501f7b4a23d6 100644 > > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > > @@ -160,80 +160,135 @@ int analogix_dp_disable_psr(struct analogix_dp_device *dp) > > } > > EXPORT_SYMBOL_GPL(analogix_dp_disable_psr); > > > > -static bool analogix_dp_detect_sink_psr(struct analogix_dp_device *dp) > > +static int analogix_dp_detect_sink_psr(struct analogix_dp_device *dp) > > { > > unsigned char psr_version; > > + int ret; > > + > > + ret = drm_dp_dpcd_readb(&dp->aux, DP_PSR_SUPPORT, &psr_version); > > + if (ret != 1) { > > + dev_err(dp->dev, "failed to get PSR version, disable it\n"); > > + return ret; > > + } > > > > - drm_dp_dpcd_readb(&dp->aux, DP_PSR_SUPPORT, &psr_version); > > dev_dbg(dp->dev, "Panel PSR version : %x\n", psr_version); > > > > - return (psr_version & DP_PSR_IS_SUPPORTED) ? true : false; > > + dp->psr_enable = (psr_version & DP_PSR_IS_SUPPORTED) ? true : false; > > + > > + return 0; > > } > > > > -static void analogix_dp_enable_sink_psr(struct analogix_dp_device *dp) > > +static int analogix_dp_enable_sink_psr(struct analogix_dp_device *dp) > > { > > unsigned char psr_en; > > + int ret; > > > > /* Disable psr function */ > > - drm_dp_dpcd_readb(&dp->aux, DP_PSR_EN_CFG, &psr_en); > > + ret = drm_dp_dpcd_readb(&dp->aux, DP_PSR_EN_CFG, &psr_en); > > + if (ret != 1) { > > + dev_err(dp->dev, "failed to get psr config\n"); > > + goto end; > > + } > > + > > psr_en &= ~DP_PSR_ENABLE; > > - drm_dp_dpcd_writeb(&dp->aux, DP_PSR_EN_CFG, psr_en); > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_PSR_EN_CFG, psr_en); > > + if (ret != 1) { > > + dev_err(dp->dev, "failed to disable panel psr\n"); > > + goto end; > > + } > > > > /* Main-Link transmitter remains active during PSR active states */ > > psr_en = DP_PSR_MAIN_LINK_ACTIVE | DP_PSR_CRC_VERIFICATION; > > - drm_dp_dpcd_writeb(&dp->aux, DP_PSR_EN_CFG, psr_en); > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_PSR_EN_CFG, psr_en); > > + if (ret != 1) { > > + dev_err(dp->dev, "failed to set panel psr\n"); > > + goto end; > > + } > > > > /* Enable psr function */ > > psr_en = DP_PSR_ENABLE | DP_PSR_MAIN_LINK_ACTIVE | > > DP_PSR_CRC_VERIFICATION; > > - drm_dp_dpcd_writeb(&dp->aux, DP_PSR_EN_CFG, psr_en); > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_PSR_EN_CFG, psr_en); > > + if (ret != 1) { > > + dev_err(dp->dev, "failed to set panel psr\n"); > > + goto end; > > + } > > > > analogix_dp_enable_psr_crc(dp); > > + > > + return 0; > > +end: > > + dev_err(dp->dev, "enable psr fail, force to disable psr\n"); > > + dp->psr_enable = false; > > + > > + return ret; > > } > > > > -static void > > +static int > > analogix_dp_enable_rx_to_enhanced_mode(struct analogix_dp_device *dp, > > bool enable) > > { > > u8 data; > > + int ret; > > > > - drm_dp_dpcd_readb(&dp->aux, DP_LANE_COUNT_SET, &data); > > + ret = drm_dp_dpcd_readb(&dp->aux, DP_LANE_COUNT_SET, &data); > > + if (ret < 0) > > + return ret; > > > > if (enable) > > - drm_dp_dpcd_writeb(&dp->aux, DP_LANE_COUNT_SET, > > - DP_LANE_COUNT_ENHANCED_FRAME_EN | > > - DPCD_LANE_COUNT_SET(data)); > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_LANE_COUNT_SET, > > + DP_LANE_COUNT_ENHANCED_FRAME_EN | > > + DPCD_LANE_COUNT_SET(data)); > > else > > - drm_dp_dpcd_writeb(&dp->aux, DP_LANE_COUNT_SET, > > - DPCD_LANE_COUNT_SET(data)); > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_LANE_COUNT_SET, > > + DPCD_LANE_COUNT_SET(data)); > > + > > + return ret < 0 ? ret : 0; > > } > > > > -static int analogix_dp_is_enhanced_mode_available(struct analogix_dp_device *dp) > > +static int analogix_dp_is_enhanced_mode_available(struct analogix_dp_device *dp, > > + u8 *enhanced_mode_support) > > { > > u8 data; > > - int retval; > > + int ret; > > > > - drm_dp_dpcd_readb(&dp->aux, DP_MAX_LANE_COUNT, &data); > > - retval = DPCD_ENHANCED_FRAME_CAP(data); > > + ret = drm_dp_dpcd_readb(&dp->aux, DP_MAX_LANE_COUNT, &data); > > + if (ret < 0) > > Above we check for ret != 1, so we should probably stay consistent. Same nit > throughout the patch. > > > + return ret; > > > > - return retval; > > + *enhanced_mode_support = DPCD_ENHANCED_FRAME_CAP(data); > > + > > + return 0; > > } > > > > -static void analogix_dp_set_enhanced_mode(struct analogix_dp_device *dp) > > +static int analogix_dp_set_enhanced_mode(struct analogix_dp_device *dp) > > { > > u8 data; > > + int ret; > > + > > + ret = analogix_dp_is_enhanced_mode_available(dp, &data); > > + if (ret < 0) > > + return ret; > > + > > + ret = analogix_dp_enable_rx_to_enhanced_mode(dp, data); > > + if (ret < 0) > > + return ret; > > > > - data = analogix_dp_is_enhanced_mode_available(dp); > > - analogix_dp_enable_rx_to_enhanced_mode(dp, data); > > analogix_dp_enable_enhanced_mode(dp, data); > > + > > + return 0; > > } > > > > -static void analogix_dp_training_pattern_dis(struct analogix_dp_device *dp) > > +static int analogix_dp_training_pattern_dis(struct analogix_dp_device *dp) > > { > > + int retval; > > Above we're replacing retval with ret, however here we introduce retval. > > > + > > analogix_dp_set_training_pattern(dp, DP_NONE); > > > > - drm_dp_dpcd_writeb(&dp->aux, DP_TRAINING_PATTERN_SET, > > - DP_TRAINING_PATTERN_DISABLE); > > + retval = drm_dp_dpcd_writeb(&dp->aux, DP_TRAINING_PATTERN_SET, > > + DP_TRAINING_PATTERN_DISABLE); > > + > > + return retval < 0 ? retval : 0; > > } > > > > static void > > @@ -282,7 +337,11 @@ static int analogix_dp_link_start(struct analogix_dp_device *dp) > > if (retval < 0) > > return retval; > > /* set enhanced mode if available */ > > - analogix_dp_set_enhanced_mode(dp); > > + retval = analogix_dp_set_enhanced_mode(dp); > > + if (retval < 0) { > > + dev_err(dp->dev, "failed to set enhance mode\n"); > > + return retval; > > + } > > > > /* Set TX pre-emphasis to minimum */ > > for (lane = 0; lane < lane_count; lane++) > > @@ -567,10 +626,11 @@ static int analogix_dp_process_equalizer_training(struct analogix_dp_device *dp) > > > > if (!analogix_dp_channel_eq_ok(link_status, link_align, lane_count)) { > > /* traing pattern Set to Normal */ > > - analogix_dp_training_pattern_dis(dp); > > + retval = analogix_dp_training_pattern_dis(dp); > > + if (retval < 0) > > + return retval; > > > > dev_info(dp->dev, "Link Training success!\n"); > > - > > analogix_dp_get_link_bandwidth(dp, ®); > > dp->link_train.link_rate = reg; > > dev_dbg(dp->dev, "final bandwidth = %.2x\n", > > @@ -807,7 +867,6 @@ static int analogix_dp_train_link(struct analogix_dp_device *dp) > > > > static int analogix_dp_config_video(struct analogix_dp_device *dp) > > { > > - int retval = 0; > > int timeout_loop = 0; > > int done_count = 0; > > > > @@ -825,8 +884,9 @@ static int analogix_dp_config_video(struct analogix_dp_device *dp) > > if (analogix_dp_is_slave_video_stream_clock_on(dp) == 0) > > break; > > if (timeout_loop > DP_TIMEOUT_LOOP_COUNT) { > > - dev_err(dp->dev, "Timeout of slave video streamclk ok\n"); > > - return -ETIMEDOUT; > > + dev_warn(dp->dev, > > + "Ignoring timeout of slave video streamclk ok\n"); > > + break; > > This change has sort of snuck in here. It doesn't seem related to the change, > but maybe I'm overlooking something. > Ah, this looks to be reversed in patch 27, hopefully we can rationalize things a bit. Sean > > } > > usleep_range(1000, 1001); > > Unrelated: This is pretty hilarious. > > > } > > @@ -865,30 +925,38 @@ static int analogix_dp_config_video(struct analogix_dp_device *dp) > > usleep_range(1000, 1001); > > } > > > > - if (retval != 0) > > - dev_err(dp->dev, "Video stream is not detected!\n"); > > - > > - return retval; > > + return 0; > > } > > > > -static void analogix_dp_enable_scramble(struct analogix_dp_device *dp, > > - bool enable) > > +static int analogix_dp_enable_scramble(struct analogix_dp_device *dp, > > + bool enable) > > { > > u8 data; > > + int ret; > > > > if (enable) { > > analogix_dp_enable_scrambling(dp); > > > > - drm_dp_dpcd_readb(&dp->aux, DP_TRAINING_PATTERN_SET, &data); > > - drm_dp_dpcd_writeb(&dp->aux, DP_TRAINING_PATTERN_SET, > > + ret = drm_dp_dpcd_readb(&dp->aux, DP_TRAINING_PATTERN_SET, > > + &data); > > + if (ret != 1) > > + return ret; > > + > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_TRAINING_PATTERN_SET, > > (u8)(data & ~DP_LINK_SCRAMBLING_DISABLE)); > > } else { > > analogix_dp_disable_scrambling(dp); > > > > - drm_dp_dpcd_readb(&dp->aux, DP_TRAINING_PATTERN_SET, &data); > > - drm_dp_dpcd_writeb(&dp->aux, DP_TRAINING_PATTERN_SET, > > + ret = drm_dp_dpcd_readb(&dp->aux, DP_TRAINING_PATTERN_SET, > > + &data); > > + if (ret != 1) > > + return ret; > > + > > + ret = drm_dp_dpcd_writeb(&dp->aux, DP_TRAINING_PATTERN_SET, > > (u8)(data | DP_LINK_SCRAMBLING_DISABLE)); > > This should probably be explicitly checked as well, since the inline conditional > in the return isn't checking what the rest of the function is. > > > } > > + > > + return ret < 0 ? ret : 0; > > } > > > > static irqreturn_t analogix_dp_hardirq(int irq, void *arg) > > @@ -943,23 +1011,36 @@ static int analogix_dp_commit(struct analogix_dp_device *dp) > > return ret; > > } > > > > - analogix_dp_enable_scramble(dp, 1); > > + ret = analogix_dp_enable_scramble(dp, 1); > > + if (ret < 0) { > > + dev_err(dp->dev, "can not enable scramble\n"); > > + return ret; > > + } > > > > analogix_dp_init_video(dp); > > ret = analogix_dp_config_video(dp); > > - if (ret) > > + if (ret) { > > dev_err(dp->dev, "unable to config video\n"); > > + return ret; > > + } > > > > /* Safe to enable the panel now */ > > if (dp->plat_data->panel) { > > - if (drm_panel_enable(dp->plat_data->panel)) > > + ret = drm_panel_enable(dp->plat_data->panel); > > + if (ret) { > > DRM_ERROR("failed to enable the panel\n"); > > + return ret; > > + } > > } > > > > - dp->psr_enable = analogix_dp_detect_sink_psr(dp); > > + ret = analogix_dp_detect_sink_psr(dp); > > + if (ret) > > + return ret; > > + > > if (dp->psr_enable) > > - analogix_dp_enable_sink_psr(dp); > > - return 0; > > + ret = analogix_dp_enable_sink_psr(dp); > > + > > + return ret; > > } > > > > /* > > @@ -1186,8 +1267,10 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) > > } > > > > ret = analogix_dp_commit(dp); > > - if (ret) > > + if (ret) { > > + DRM_ERROR("dp commit error, ret = %d\n", ret); > > goto out_dp_init; > > + } > > > > enable_irq(dp->irq); > > return 0; > > -- > > 2.14.1 > > > > -- > Sean Paul, Software Engineer, Google / Chromium OS -- Sean Paul, Software Engineer, Google / Chromium OS