Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4197516pxu; Tue, 20 Oct 2020 10:29:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmQGrWVRzcp+OcB/JjBd/DUZJlPM4z+lIlcE9UQe6satpoZB2c0gJIlQdCb+8Pmxwa0PYV X-Received: by 2002:a17:906:7113:: with SMTP id x19mr4254803ejj.59.1603214987456; Tue, 20 Oct 2020 10:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603214987; cv=none; d=google.com; s=arc-20160816; b=e8ySZ8ySLNOLaEDHkzze4Atki8rNUndg2WskIhydZ4RbWGBBpbpZcTAN7uXr1tN3GZ DuA1ZXqe0nOm2P0cI+qS7zdxiaRboLczZaYH9RM++O6mBzahi9l09DZawTy4/hjBhSXP nwE08uRBEL5UXi1d2BEL1TXtAhTr8wpE97BZUehaZnaCrYcGOja5OsVj17cZcrhC2OHD C/Anwxf7BGyZ5dulMWtsVoSG50wL1ct21b3pLHKle/znr+58nCF5cRwZcfthN0V2ozEC LMdCu/358WceMHYwHpUopJArGH8xe5APwproN06gcfOEHh0SRtmjez3+5M645O+2fhIe Tt+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:mime-version:message-id:date :subject:cc:to:from; bh=k0OpCwKOIS1mzOf9rDffepCbD0hVHg+ZBxopLq0hOT0=; b=l3Jmr3VjvXidNVWHQHvl3QukNS8Wd/geLFOYVnkluaYuyrVQKohsGNvP/wIqKhRawi IepMLiSqLHFVfHCeB5dlOoWjnE76fqXDQW7BKeejO51FC6ax6Va0x60sq418FKbHCYto l01G/V15dHPiwh7/Cmk2j/BaWYqnIxh5dEfoskS2Cj7Dv22T16Me/Klhwa/L/jYAYNtz jDGvBwayVLg5UuX8QETqfijEJafyNfle+JvxhqVN5OZEDepZFzU0RJ8w5l5t+vyq4eTA 4NWSoStD96GuyX9APp/g2RVIKrSQCnEJCp9XgXureUBuoSDGpuXwrJDcgUoDJUyzcQIo NILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=msQieKyH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si1675562edh.611.2020.10.20.10.29.24; Tue, 20 Oct 2020 10:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=msQieKyH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725773AbgJTEDR (ORCPT + 99 others); Tue, 20 Oct 2020 00:03:17 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:17794 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgJTEDR (ORCPT ); Tue, 20 Oct 2020 00:03:17 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 19 Oct 2020 21:01:44 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 20 Oct 2020 04:03:16 +0000 Received: from skomatineni-linux.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Tue, 20 Oct 2020 04:03:16 +0000 From: Sowjanya Komatineni To: , , , CC: , , Subject: [PATCH v1] i2c: tegra: Fix i2c_writesl() to use writel() instead of writesl() Date: Mon, 19 Oct 2020 21:03:54 -0700 Message-ID: <1603166634-13639-1-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603166504; bh=k0OpCwKOIS1mzOf9rDffepCbD0hVHg+ZBxopLq0hOT0=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:X-NVConfidentiality: MIME-Version:Content-Type; b=msQieKyHswBsMpmzAhUyhwrV5hazjv2iGfCMdcVaXmfLWmKaAFqarqmmRaHim6pWs 9X94Mx2vHymB0IfZcIvOAoIAp76+PFnbktb0uOcUEwCSSELvoZj2u6FgHxxAsLGENl dXQhXIKj6oLi3VDiwqWbku/9nms2fcrr6WSaNla8EuAHTF/EClR+hfeEOeuXsyxrbY u/mdUaEMed9caeh59PuuTrbiK5AjIp/0hZs/7bXw+D0ILTTtvB1DEijE+4tjJ2i8Si RrKLbzi5FDhy07SNMzFqjY9xGNkBOrVaXTwClJVp2hi/7jjq9XV/PFaTPbdDVMavJY sOO46WV/ufKOg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org VI I2C don't have DMA support and uses PIO mode all the time. Current driver uses writesl() to fill TX FIFO based on available empty slots and with this seeing strange silent hang during any I2C register access after filling TX FIFO with 8 words. Using writel() followed by i2c_readl() in a loop to write all words to TX FIFO instead of using writesl() helps for large transfers in PIO mode. So, this patch updates i2c_writesl() API to use writel() in a loop instead of writesl(). Signed-off-by: Sowjanya Komatineni --- drivers/i2c/busses/i2c-tegra.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 6f08c0c..274bf3a 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -333,10 +333,13 @@ static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, unsigned int reg) return readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); } -static void i2c_writesl(struct tegra_i2c_dev *i2c_dev, void *data, +static void i2c_writesl(struct tegra_i2c_dev *i2c_dev, u32 *data, unsigned int reg, unsigned int len) { - writesl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len); + while (len--) { + writel(*data++, i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); + i2c_readl(i2c_dev, I2C_INT_STATUS); + } } static void i2c_readsl(struct tegra_i2c_dev *i2c_dev, void *data, @@ -811,7 +814,7 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) i2c_dev->msg_buf_remaining = buf_remaining; i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD; - i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); + i2c_writesl(i2c_dev, (u32 *)buf, I2C_TX_FIFO, words_to_transfer); buf += words_to_transfer * BYTES_PER_FIFO_WORD; } -- 2.7.4