From patchwork Mon Mar 5 10:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 881389 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m4MWYafZ"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iB0VcUUi"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zvwng5lK5z9sYD for ; Mon, 5 Mar 2018 21:17:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=5Hf53Wxs/sL7Qm+pozmkLy1GuPreuQ9plZ3Hj0DfGS8=; b=m4MWYafZ9z4RqD z3VxxGESXvrlwz6TRMBnG8OEVm8+M13Wx6jxxKVPMyIRxRD9mlrWgo8g3Z/S51G8LrC28/K2vj307 4OzTl4TO0dOhGkDm0QSxJunXMIqqKYOeDPu9dx4rQnET1FDqWjvedkZEIUXv4M/gPN4gZjur8KinR ykrj7/uszGvAhn/s9cX9hiZq04syE9rHU+/D684OVYlFZaIvgTuJ2q9wUV33eVwGnk8UiXNoQcVpb eMtOrt8Fk/2lE8XzbhesrDkn2TGKCL1ffSx1b0F43rLgY6prb1UbwK157cIADXZIHnGwCSlBi+H6s QIg3dC42N19kTq/yQgqw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1esnBK-0001Ad-Rn; Mon, 05 Mar 2018 10:17:22 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1esnBG-00018n-LK for linux-arm-kernel@lists.infradead.org; Mon, 05 Mar 2018 10:17:20 +0000 Received: by mail-lf0-x241.google.com with SMTP id o145so22259491lff.0 for ; Mon, 05 Mar 2018 02:17:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ytxJqlLdm6gJQ/vvGOytFWFrXlKD3coh8fL+60F8NQo=; b=iB0VcUUio4l5KbwDREB9Z1aV1SK915QpaDJAsXQ20Sxz2nifTcZB4VCZcg+JZ/ia0X UzWMoG52JFINMaY60UF2FM74a9EK89sY4RRZ+yhpVwMhZ7FRAFa8Ju/Lg5e/i2RBMe8d oWAG9ViCELOJ+Fn8jwaub422vfSvsnpmudbFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ytxJqlLdm6gJQ/vvGOytFWFrXlKD3coh8fL+60F8NQo=; b=VM/unYoVTFCyiC1g9cuD7qk60A9zp0fF9xL5VyqC3oGvFffb8tyw/PS6upHO4p1daV fM6vkxgio4zT9x740w+HRJEtTORJoMjzvF/mWaHLpT4/V/is+qAUrNRe0Rjy9O7O/1eG /GPOmPCwE7HZSQAyPOfsxBtaL5gG2dg4ZkHrUEigNNFeWN8Kf300UVSE6usKBt2LxmUw 159yl88zvJ/BA9wPRsSZlH7dQqhmpKpyc1rWHgog+Qv2XcY6me1nJK/mK9n7oWAliDtr OVdHleYNYBGbJfyMvLlmcCH7CiRTIcyCjidPTdXBHWKn4i3DG2B7BBFGXlKBMYMPPh4s nmwg== X-Gm-Message-State: AElRT7FFz4MnbIr12dkG9raaIk6MzxrHeBgvj4iVlZKRCzEdMtVCjaUA fUd+Xx7va8gHFwHIm56VDf60+Q== X-Google-Smtp-Source: AG47ELuR5UuP8B8KJu4f6sdtaoD+/uL1uyqdYgN04TCP7O32yYF2LnrkkaTT93L/EyiXAdcU9f0mOQ== X-Received: by 10.46.92.7 with SMTP id q7mr9459791ljb.21.1520245026306; Mon, 05 Mar 2018 02:17:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 4sm2627742lje.38.2018.03.05.02.17.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 02:17:05 -0800 (PST) From: Linus Walleij To: Archit Taneja , Andrzej Hajda , Laurent Pinchart Subject: [PATCH] drm/bridge: sii902x: Retry status read after DDI I2C Date: Mon, 5 Mar 2018 11:17:02 +0100 Message-Id: <20180305101702.13441-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180305_021718_711847_8D83D43B X-CRM114-Status: GOOD ( 17.61 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4010:c07:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij , Liviu Dudau , dri-devel@lists.freedesktop.org, Eric Anholt , linux-arm-kernel@lists.infradead.org, =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org The following happens when connection a DVI output driven from the SiI9022 using a DVI-to-VGA adapter plug: i2c i2c-0: sendbytes: NAK bailout. i2c i2c-0: sendbytes: NAK bailout. Then no picture. Apparently the I2C engine inside the SiI9022 is not smart enough to try to fall back to DDC I2C. Or the vendor have not integrated the electronics properly. I don't know which one it is. After this, the I2C bus seems stalled and the first attempt to read the status register fails, and the code returns with negative return value, and the display fails to initialized. Instead, retry status readout five times and continue even if this fails. Tested on the ARM Versatile Express with a DVI-to-VGA connector, it now gives picture. Introduce a helper struct device *dev variable to make the code more readable. Cc: Ville Syrjälä Cc: Liviu Dudau Signed-off-by: Linus Walleij Reviewed-by: Liviu Dudau --- ChangeLog v1->v2: - Found the real problem instead of trying to explicitly shoehorn EDID modes into the error path. --- drivers/gpu/drm/bridge/sii902x.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index b1ab4ab09532..60373d7eb220 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -137,7 +137,9 @@ static int sii902x_get_modes(struct drm_connector *connector) struct sii902x *sii902x = connector_to_sii902x(connector); struct regmap *regmap = sii902x->regmap; u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24; + struct device *dev = &sii902x->i2c->dev; unsigned long timeout; + unsigned int retries; unsigned int status; struct edid *edid; int num = 0; @@ -159,7 +161,7 @@ static int sii902x_get_modes(struct drm_connector *connector) time_before(jiffies, timeout)); if (!(status & SII902X_SYS_CTRL_DDC_BUS_GRTD)) { - dev_err(&sii902x->i2c->dev, "failed to acquire the i2c bus\n"); + dev_err(dev, "failed to acquire the i2c bus\n"); return -ETIMEDOUT; } @@ -179,9 +181,19 @@ static int sii902x_get_modes(struct drm_connector *connector) if (ret) return ret; - ret = regmap_read(regmap, SII902X_SYS_CTRL_DATA, &status); + /* + * Sometimes the I2C bus can stall after failure to use the + * EDID channel. Retry a few times to see if things clear + * up, else continue anyway. + */ + retries = 5; + do { + ret = regmap_read(regmap, SII902X_SYS_CTRL_DATA, + &status); + retries--; + } while (ret && retries); if (ret) - return ret; + dev_err(dev, "failed to read status (%d)\n", ret); ret = regmap_update_bits(regmap, SII902X_SYS_CTRL_DATA, SII902X_SYS_CTRL_DDC_BUS_REQ | @@ -201,7 +213,7 @@ static int sii902x_get_modes(struct drm_connector *connector) if (status & (SII902X_SYS_CTRL_DDC_BUS_REQ | SII902X_SYS_CTRL_DDC_BUS_GRTD)) { - dev_err(&sii902x->i2c->dev, "failed to release the i2c bus\n"); + dev_err(dev, "failed to release the i2c bus\n"); return -ETIMEDOUT; }