From patchwork Sun Nov 29 02:10:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Larsson X-Patchwork-Id: 7717741 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B05EBBEEE1 for ; Sun, 29 Nov 2015 02:10:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2D33205D8 for ; Sun, 29 Nov 2015 02:10:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E81CC2054E for ; Sun, 29 Nov 2015 02:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752981AbbK2CKT (ORCPT ); Sat, 28 Nov 2015 21:10:19 -0500 Received: from smtp.bredband2.com ([83.219.192.166]:40491 "EHLO smtp.bredband2.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899AbbK2CKS (ORCPT ); Sat, 28 Nov 2015 21:10:18 -0500 Received: from benjamin-desktop.lan (c-ce09e555.03-170-73746f36.cust.bredbandsbolaget.se [85.229.9.206]) (Authenticated sender: ed8153) by smtp.bredband2.com (Postfix) with ESMTPA id 98CF2727C3 for ; Sun, 29 Nov 2015 03:10:16 +0100 (CET) From: Benjamin Larsson To: linux-media@vger.kernel.org Subject: [PATCH 2/3] mn88472: add work around for failing firmware loading Date: Sun, 29 Nov 2015 03:10:15 +0100 Message-Id: <1448763016-10527-2-git-send-email-benjamin@southpole.se> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448763016-10527-1-git-send-email-benjamin@southpole.se> References: <1448763016-10527-1-git-send-email-benjamin@southpole.se> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes the firmware fails to load because of an i2c error. Work around that by adding retry logic. This kind of logic also exist in the binary driver and failures have been observed there also. Thus this seems to be a property of the hardware and a fix like this is needed. Signed-off-by: Benjamin Larsson --- drivers/staging/media/mn88472/mn88472.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index cf2e96b..80c5807 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -282,7 +282,7 @@ static int mn88472_init(struct dvb_frontend *fe) int ret, len, remaining; const struct firmware *fw = NULL; u8 *fw_file = MN88472_FIRMWARE; - unsigned int tmp; + unsigned int tmp, retry_cnt; dev_dbg(&client->dev, "\n"); @@ -330,9 +330,22 @@ static int mn88472_init(struct dvb_frontend *fe) if (len > (dev->i2c_wr_max - 1)) len = dev->i2c_wr_max - 1; + /* I2C transfers during firmware load might fail sometimes, + * just retry in that case. 4 consecutive failures have + * been observed thus a retry limit of 20 is used. + */ + retry_cnt = 20; +retry: ret = regmap_bulk_write(dev->regmap[0], 0xf6, &fw->data[fw->size - remaining], len); if (ret) { + if (retry_cnt) { + dev_dbg(&client->dev, + "i2c error, retry %d triggered\n", retry_cnt); + retry_cnt--; + usleep_range(200, 10000); + goto retry; + } dev_err(&client->dev, "firmware download failed=%d\n", ret); goto firmware_release;