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: 32032 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1a2rS4-0000Yh-Kw; Sun, 29 Nov 2015 03:10:56 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-7) with esmtp id 1a2rS2-0007OE-13; Sun, 29 Nov 2015 03:10:55 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752981AbbK2CKT (ORCPT + 1 other); 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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.11.29.20317 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1800_1899 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __REFERENCES 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS ' 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;