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: 130625 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2513318lja; Mon, 5 Mar 2018 02:17:10 -0800 (PST) X-Google-Smtp-Source: AG47ELv2OCtSnKK+Zs2PQyVZ8edh8R5ecYMm4Wr9BkdHmTqE87SRtbnE0vIgtS0/PovCOYZjBjTa X-Received: by 10.101.83.199 with SMTP id z7mr12099965pgr.105.1520245030462; Mon, 05 Mar 2018 02:17:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520245030; cv=none; d=google.com; s=arc-20160816; b=UDexEQLcJqgxkS5TY2ax1pNMUxhUrHGRxBUO0fJzPwZPfetx3nIEDm8dnwylnmCDaS N/NhpSHqvfJx6kd3IkA+sAMaZVHVx3re2J9/sIZYouHMyf8fzDNxmsk0CWbF1q1UQz6j zuIIVaiokFxy/0fH6CXH42WG01aC892zn3k9nwwra6ewYTi0/aA9Ft1uzg9TjHyMW37O vGvlL5IpqlfT7fTQonGTCtDM0wD+G1biWlr1Ky2SitQ18+es/fj6bFnYlzLRNUqyDGkD W56gnvMlhX2dd25WRDEuv6gw/+t21hdtfKYGY5KbYRdOR9Y9AVmg0HGtFPTCxzoqeA5F CmPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=7RyS6yygZkiDCrjt9yVh56RzyulKVb584aIfOqj2XZ8=; b=wKB7vpQLM2MKnXDJiZFBSPUYzKZ/I+vvhTqcxtGStUvdukxJ7/7iuM3yH7hj6vI06u 1bgYxFOSnDzpM46UtJFFbkKz/fhkwC5koOFPWikKQb/Mrx/0Kl7aOZ16k4+lJ2cRqYJQ ki1bYvht4AZBK9v/kyCk4W3DVfqhIrsJPjmK4CBPXboRPFz5/ovaYKMkxOu7UKF1DOsm ibMnLiDxRNQVxM/bThyGxjn9XMm+O9rnpJbv+HuJ+6NRXD+Jgja1AIOjtpjX7IEND/z1 mCyjSBhIDabJpKj7e9pqMLm9A154T43FFVwr1WX2WuRnCJ3ZzndZMvf2o4B4gLZ9miVy eVdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iB0VcUUi; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id w61-v6si9151442plb.733.2018.03.05.02.17.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 02:17:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iB0VcUUi; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 509CF89DFE; Mon, 5 Mar 2018 10:17:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id F24A489DFE for ; Mon, 5 Mar 2018 10:17:07 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id h127so21235304lfg.12 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=OcacAJZ+GTtlO4kwkxB7zYHjJgK5HxfU01HyErwUzXWYClFpPnCexdgcvGn7AInpMN I4Zb+eeiaaruk8FJWbChksfz/nTU8QkfrB37oeES3ldL3ZNdEPbDIiGuWLrwxFhXB2wb AIcHJIH8mpNRCZt8/78uXrMifyNo1RS0hDWu2+ig1zW23SYjUKHiwlMnXiia68+tBQye m1SFxvyVLPmTJff44yaaHt8VGCDVCdKV6AHDbso4FnIQz0mEPE1cvG14nsjQ3wNvC5e8 H32BzCMqEHDQU/xs7lnOhiEsl9wWf2lvnQa/qwRGMMtAdpULuTl63XdWN+NpQEHhwgXu /eUQ== X-Gm-Message-State: AElRT7EXpZVw0v7He2nvz2Zo/VOGVd30xVh1+iagabFKXcpZPbhrK5Ao 79Rto7W6qzHaP62OEJZJBHf/aA== 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liviu Dudau , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }