From patchwork Mon Jan 15 17:33:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10165083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CAC1960245 for ; Mon, 15 Jan 2018 17:34:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B429B201BD for ; Mon, 15 Jan 2018 17:34:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8E2E205AF; Mon, 15 Jan 2018 17:34:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCAA4201BD for ; Mon, 15 Jan 2018 17:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbeAOReN (ORCPT ); Mon, 15 Jan 2018 12:34:13 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:60380 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752419AbeAOReM (ORCPT ); Mon, 15 Jan 2018 12:34:12 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180115173410euoutp02ee296d5f7ff96c0b0138c0bd6043bf01~KDDYKrTJ00542005420euoutp02L; Mon, 15 Jan 2018 17:34:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180115173410euoutp02ee296d5f7ff96c0b0138c0bd6043bf01~KDDYKrTJ00542005420euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516037650; bh=bXaRxhXyPgcZQLzkHKtFIIO+6P7fA8D41b2U5LKJ8iw=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=oSVQF+y+PhBNTZfuCLGcX7lyO0+b6+Y8xe9xk/7y1kXEcOieWaC1bmYm/CJSQG005 23myCFtHMeAhTzCBtRzzpHUcueKE0K96P93uKvqgK8qzfyL4zAqbQs+d2qPDD/0yHS N/5/lOH9+mwEquS2gvJ2/zRu8L5fMoxWvQzhqb+4= Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180115173409eucas1p2e6f38df2b0bd3b023fc88baecfe63d7d~KDDXPn2Ve0678706787eucas1p2B; Mon, 15 Jan 2018 17:34:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id F4.09.12867.116EC5A5; Mon, 15 Jan 2018 17:34:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180115173409eucas1p14248e60263dabb683ccd457fd89d4e69~KDDWfbUEd3071730717eucas1p1X; Mon, 15 Jan 2018 17:34:09 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-17-5a5ce611bffb Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 1E.B9.18832.016EC5A5; Mon, 15 Jan 2018 17:34:08 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P2L00H20Y4QIA10@eusync4.samsung.com>; Mon, 15 Jan 2018 17:34:08 +0000 (GMT) From: Andrzej Hajda To: Archit Taneja , Laurent Pinchart Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 3/3] drm/bridge/sii8620: fix loops in EDID fetch logic Date: Mon, 15 Jan 2018 18:33:57 +0100 Message-id: <20180115173357.31067-4-a.hajda@samsung.com> X-Mailer: git-send-email 2.15.1 In-reply-to: <20180115173357.31067-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsWy7djPc7qCz2KiDD6fUbK4te4cq0VTx1tW i40z1rNaXPn6ns2ic+ISdosZ5/cxWaw9cpfdgd3jcl8vk8fsjpmsHve7jzN59G1ZxejxeZNc AGsUl01Kak5mWWqRvl0CV8aaq9uYCpbwV+xfdZaxgbGDp4uRk0NCwETi9P15zBC2mMSFe+vZ uhi5OIQEljJKtH9vYgRJCAl8ZpR4tTUepuF6y06oomWMEr9eHmeFcP4zSvybO4sNpIpNQFPi 7+abYLaIQJLE6XMfwDqYBS4xSrw+2Q02VljATWLxoR+sIDaLgKrE00mPWLoYOTh4BSwkJi6C 2iYvMWFLEwuIzSlgKdFw4CcLyBwJgR42iSkXPrFDFLlInD/RwQJhC0u8Or4FKi4j0dlxkAmi oZtR4lP/CXYIZwrQqR9mQH1tLXH4+EWwK5gF+CQmbZvODHKFhACvREebEESJh8T0nbOZIGxH idnrD7BDvNzDKDH5Vw/7BEbpBYwMqxhFUkuLc9NTi431ihNzi0vz0vWS83M3MQKj9fS/4592 MH49YXWIUYCDUYmH12JbTJQQa2JZcWXuIUYJDmYlEd7GYKAQb0piZVVqUX58UWlOavEhRmkO FiVxXtuotkghgfTEktTs1NSC1CKYLBMHp1QDY0Fkbd7jDjXJl1VcB0487ZPgX+JR0TVn23OF I8du/UjXm3YooCdj9dmFJcbi5z9Knfdf5FGyw2bzFduY+OuvWW9tveL2cGZlxsSOBz9uJEft /bZ89TIR86jmmR9WFc+KXPvyxtrp5d+C997Yq33Zaem7/COb3u2UPvcr3uBYZqDjHYGNYVYZ oelKLMUZiYZazEXFiQBj/Rr30gIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t/xa7oCz2KiDD5csbG4te4cq0VTx1tW i40z1rNaXPn6ns2ic+ISdosZ5/cxWaw9cpfdgd3jcl8vk8fsjpmsHve7jzN59G1ZxejxeZNc AGsUl01Kak5mWWqRvl0CV8aaq9uYCpbwV+xfdZaxgbGDp4uRk0NCwETiestONghbTOLCvfVA NheHkMASRokrvyYwQjiNTBIrG1ewg1SxCWhK/N18E6xDRCBJYuPDQywgRcwCVxgl2r91gRUJ C7hJLD70gxXEZhFQlXg66RFQEQcHr4CFxMRF8RDb5CUmbGliAbE5BSwlGg78BLOFgEoWbpjA NoGRdwEjwypGkdTS4tz03GJDveLE3OLSvHS95PzcTYzAoNp27OfmHYyXNgYfYhTgYFTi4bXY FhMlxJpYVlyZe4hRgoNZSYS3MRgoxJuSWFmVWpQfX1Sak1p8iFGag0VJnLd3z+pIIYH0xJLU 7NTUgtQimCwTB6dUA6OjBveT6ouM2n1BamYzvrPvqbxmJXR6VkNBjYiQ+LfOmxmnQiP9vymp 3g1U5955TjPtgGBpnU4+X0J89Oq9qR72G5zVSi87Ttp6QKIku//bYvNuX0ubNSVrvJ2jNque ZpubbhRaoM1h/LxzrsyVu02b3NfJ38ti7ikUMPbuikz/fXaDsZuaEktxRqKhFnNRcSIADvsH +SYCAAA= X-CMS-MailID: 20180115173409eucas1p14248e60263dabb683ccd457fd89d4e69 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180115173409eucas1p14248e60263dabb683ccd457fd89d4e69 X-RootMTR: 20180115173409eucas1p14248e60263dabb683ccd457fd89d4e69 References: <20180115173357.31067-1-a.hajda@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Function should constantly check if cable is connected and finish in finite time. Signed-off-by: Andrzej Hajda Tested-by: Marek Szyprowski Reviewed-by: Maciej Purski --- drivers/gpu/drm/bridge/sil-sii8620.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c index 7c46847fef18..f65e14836c0e 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -801,6 +801,7 @@ static void sii8620_burst_rx_all(struct sii8620 *ctx) static void sii8620_fetch_edid(struct sii8620 *ctx) { u8 lm_ddc, ddc_cmd, int3, cbus; + unsigned long timeout; int fetched, i; int edid_len = EDID_LENGTH; u8 *edid; @@ -850,23 +851,31 @@ static void sii8620_fetch_edid(struct sii8620 *ctx) REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK ); - do { - int3 = sii8620_readb(ctx, REG_INTR3); + int3 = 0; + timeout = jiffies + msecs_to_jiffies(200); + for (;;) { cbus = sii8620_readb(ctx, REG_CBUS_STATUS); - - if (int3 & BIT_DDC_CMD_DONE) - break; - - if (!(cbus & BIT_CBUS_STATUS_CBUS_CONNECTED)) { + if (~cbus & BIT_CBUS_STATUS_CBUS_CONNECTED) { + kfree(edid); + edid = NULL; + goto end; + } + if (int3 & BIT_DDC_CMD_DONE) { + if (sii8620_readb(ctx, REG_DDC_DOUT_CNT) + >= FETCH_SIZE) + break; + } else { + int3 = sii8620_readb(ctx, REG_INTR3); + } + if (time_is_before_jiffies(timeout)) { + ctx->error = -ETIMEDOUT; + dev_err(ctx->dev, "timeout during EDID read\n"); kfree(edid); edid = NULL; goto end; } - } while (1); - - sii8620_readb(ctx, REG_DDC_STATUS); - while (sii8620_readb(ctx, REG_DDC_DOUT_CNT) < FETCH_SIZE) usleep_range(10, 20); + } sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE); if (fetched + FETCH_SIZE == EDID_LENGTH) {