From patchwork Tue Apr 4 06:16:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96666 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47907qgd; Mon, 3 Apr 2017 23:17:03 -0700 (PDT) X-Received: by 10.84.176.100 with SMTP id u91mr27051023plb.112.1491286623347; Mon, 03 Apr 2017 23:17:03 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m188si16434436pfc.145.2017.04.03.23.17.03; Mon, 03 Apr 2017 23:17:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbdDDGRC (ORCPT + 6 others); Tue, 4 Apr 2017 02:17:02 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:36478 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751046AbdDDGRB (ORCPT ); Tue, 4 Apr 2017 02:17:01 -0400 Received: by mail-pg0-f52.google.com with SMTP id g2so140783057pge.3 for ; Mon, 03 Apr 2017 23:17:01 -0700 (PDT) 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=XzKt85eBRZBaT5V59QdZF5GUAIOTiV5IoT6DLaJkW/U=; b=GED7xeh95EspOjo3H15HiB59iwrezPWZI2fYy55OLOXWeO1rvcoliwnh91jxZgLh9q F8OvJBFtFuRHP2pIOy3WnU9UdlsYtUIWtAeUPt+lhfsSmjUiSDVWJr+vK5EovAZvch7/ 291M0LZmLPOpItwgym5VPI1ZoqvtN5hCrrg90= 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=XzKt85eBRZBaT5V59QdZF5GUAIOTiV5IoT6DLaJkW/U=; b=qouziagEDv+hW2mSBFeIby1d2IXURxNiLCduJpFdAkzOzuDWvVyG+w/vbLaICX7eV7 5JAsSRu59rc1yLrlp+aHWcaGfO/bkLv4GsobwoloVzjMJI+XGNJA504GkY0YAe6b8AhR wRwb3yv+22jckhF0jAqOOwNnlLy6bjGRP7eYs54v7mELuiZFCALEDa/XTSU3A1GRZrHH m+BObiXa09Sv4oz33MCbM5mb6njantiya3Dy4UdU01OKb4iyxezy97o6JrzwydrEgBck SzbvFOaq3AxSlbqQIHQbIipV4sIe8Bh9wLCSxVfhBd7mgvMtUI1nPpxV4mppUX5DDRCU htGA== X-Gm-Message-State: AFeK/H2cDfOvAlAJePVmIMh6jYdu1XwFgHuxyQi93Bux/bFWkZB4de781AFFSHByuw5yurDc X-Received: by 10.98.48.66 with SMTP id w63mr7596468pfw.132.1491286620839; Mon, 03 Apr 2017 23:17:00 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id f81sm29247068pfe.61.2017.04.03.23.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 23:17:00 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 04/33] PCI: iproc: Save host bridge window resource in struct iproc_pcie Date: Tue, 4 Apr 2017 11:46:52 +0530 Message-Id: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bjorn Helgaas The host bridge memory window resource is inserted into the iomem_resource tree and cannot be deallocated until the host bridge itself is removed. Previously, the window was on the stack, which meant the iomem_resource entry pointed into the stack and was corrupted as soon as the probe function returned, which caused memory corruption and errors like this: pcie_iproc_bcma bcma0:8: resource collision: [mem 0x40000000-0x47ffffff] conflicts with PCIe MEM space [mem 0x40000000-0x47ffffff] Move the memory window resource from the stack into struct iproc_pcie so its lifetime matches that of the host bridge. Fixes: c3245a566400 ("PCI: iproc: Request host bridge window resources") Reported-and-tested-by: Rafał Miłecki Signed-off-by: Bjorn Helgaas (cherry picked from commit 6e347b5e05ea2ac4ac467a5a1cfaebb2c7f06f80) Signed-off-by: Amit Pundir --- drivers/pci/host/pcie-iproc-bcma.c | 24 ++++++++++++------------ drivers/pci/host/pcie-iproc-platform.c | 19 ++++++++++--------- drivers/pci/host/pcie-iproc.h | 1 + 3 files changed, 23 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c index 8ce0890..46ca8ed 100644 --- a/drivers/pci/host/pcie-iproc-bcma.c +++ b/drivers/pci/host/pcie-iproc-bcma.c @@ -44,8 +44,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) { struct device *dev = &bdev->dev; struct iproc_pcie *pcie; - LIST_HEAD(res); - struct resource res_mem; + LIST_HEAD(resources); int ret; pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); @@ -62,22 +61,23 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) pcie->base_addr = bdev->addr; - res_mem.start = bdev->addr_s[0]; - res_mem.end = bdev->addr_s[0] + SZ_128M - 1; - res_mem.name = "PCIe MEM space"; - res_mem.flags = IORESOURCE_MEM; - pci_add_resource(&res, &res_mem); + pcie->mem.start = bdev->addr_s[0]; + pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1; + pcie->mem.name = "PCIe MEM space"; + pcie->mem.flags = IORESOURCE_MEM; + pci_add_resource(&resources, &pcie->mem); pcie->map_irq = iproc_pcie_bcma_map_irq; - ret = iproc_pcie_setup(pcie, &res); - if (ret) + ret = iproc_pcie_setup(pcie, &resources); + if (ret) { dev_err(dev, "PCIe controller setup failed\n"); - - pci_free_resource_list(&res); + pci_free_resource_list(&resources); + return ret; + } bcma_set_drvdata(bdev, pcie); - return ret; + return 0; } static void iproc_pcie_bcma_remove(struct bcma_device *bdev) diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index a3de087..7dcaddc 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c @@ -46,7 +46,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct resource reg; resource_size_t iobase = 0; - LIST_HEAD(res); + LIST_HEAD(resources); int ret; of_id = of_match_device(iproc_pcie_of_match_table, dev); @@ -108,23 +108,24 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) pcie->phy = NULL; } - ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); + ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &resources, + &iobase); if (ret) { - dev_err(dev, - "unable to get PCI host bridge resources\n"); + dev_err(dev, "unable to get PCI host bridge resources\n"); return ret; } pcie->map_irq = of_irq_parse_and_map_pci; - ret = iproc_pcie_setup(pcie, &res); - if (ret) + ret = iproc_pcie_setup(pcie, &resources); + if (ret) { dev_err(dev, "PCIe controller setup failed\n"); - - pci_free_resource_list(&res); + pci_free_resource_list(&resources); + return ret; + } platform_set_drvdata(pdev, pcie); - return ret; + return 0; } static int iproc_pcie_pltfm_remove(struct platform_device *pdev) diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index e84d93c..fa42267 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h @@ -68,6 +68,7 @@ struct iproc_pcie { #ifdef CONFIG_ARM struct pci_sys_data sysdata; #endif + struct resource mem; struct pci_bus *root_bus; struct phy *phy; int (*map_irq)(const struct pci_dev *, u8, u8); From patchwork Tue Apr 4 06:16:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96667 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47912qgd; Mon, 3 Apr 2017 23:17:05 -0700 (PDT) X-Received: by 10.84.210.79 with SMTP id z73mr26255771plh.78.1491286625161; Mon, 03 Apr 2017 23:17:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m188si16434436pfc.145.2017.04.03.23.17.05; Mon, 03 Apr 2017 23:17:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752380AbdDDGRE (ORCPT + 6 others); Tue, 4 Apr 2017 02:17:04 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:32814 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751046AbdDDGRD (ORCPT ); Tue, 4 Apr 2017 02:17:03 -0400 Received: by mail-pg0-f41.google.com with SMTP id x125so142531830pgb.0 for ; Mon, 03 Apr 2017 23:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bty6R6DYul67AKn+issoCh5QE2qoeZmvASm1stWPxWQ=; b=d01WXXFal1MfKSYlfe1VQzteZiKn9NAaIchn2t3AfRXDNcgZAzESaMwgT1yqlC1mUW AzYklgMnA/5/bhuDsx6WjWUMPRhHdn2/nYG941bM9/AGPTy1YroyisxBQUg9ux0KneeH e0v6b/pGnw1IulDjmXA28bL6ES/ewMD6frDUg= 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:in-reply-to :references; bh=bty6R6DYul67AKn+issoCh5QE2qoeZmvASm1stWPxWQ=; b=ojnAxBgX6hYusMd8otqI/clRrQ+e6hNEIMz5+8bS9ol7VP+K4KMiLt0tSDhYm2OiIC q6iHHyds3jLcwgLrMO5ae1HnKfwyqll25PkmepaIeyGnPRW5lUf1qzQ8sCdrrzoX1792 maHrLIfKiOSuO+jTzxXkMBU8HivFK9AC6jX0w1xGeFV4ALeg7aQ4UtoDmlMbEv4701rt Q36fBTguOzjm1z9rE/LhvcfJ93+8DpIfxh7plU+KjS/ufBRkjonmHq0mDXTGUh6SIpt3 j1nlz33bIIibxenTLQviZact6CR7BAdtSJmljgWrjl0+YYIxPFmYpYJuEbU0AS4UJ+tK t2Hg== X-Gm-Message-State: AFeK/H2pa8wonq+YKrRTtEJsHCBKzRhuqEH8VX1xE1MyRRbco3gnPu9ZElv3QWbpXS63YodP X-Received: by 10.98.138.80 with SMTP id y77mr292303pfd.183.1491286623035; Mon, 03 Apr 2017 23:17:03 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id f81sm29247068pfe.61.2017.04.03.23.17.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 23:17:02 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, Felix Fietkau , linux-mips@linux-mips.org, James Hogan Subject: [PATCH 05/33] MIPS: Lantiq: Fix cascaded IRQ setup Date: Tue, 4 Apr 2017 11:46:53 +0530 Message-Id: <1491286617-31131-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> References: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Felix Fietkau With the IRQ stack changes integrated, the XRX200 devices started emitting a constant stream of kernel messages like this: [ 565.415310] Spurious IRQ: CAUSE=0x1100c300 This is caused by IP0 getting handled by plat_irq_dispatch() rather than its vectored interrupt handler, which is fixed by commit de856416e714 ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch"). Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ for all MIPS CPU interrupts. Signed-off-by: Felix Fietkau Acked-by: John Crispin Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/15077/ [james.hogan@imgtec.com: tweaked commit message] Signed-off-by: James Hogan (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd) Signed-off-by: Amit Pundir --- arch/mips/lantiq/irq.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c index 8ac0e59..0ddf369 100644 --- a/arch/mips/lantiq/irq.c +++ b/arch/mips/lantiq/irq.c @@ -269,6 +269,11 @@ static void ltq_hw5_irqdispatch(void) DEFINE_HWx_IRQDISPATCH(5) #endif +static void ltq_hw_irq_handler(struct irq_desc *desc) +{ + ltq_hw_irqdispatch(irq_desc_get_irq(desc) - 2); +} + #ifdef CONFIG_MIPS_MT_SMP void __init arch_init_ipiirq(int irq, struct irqaction *action) { @@ -313,23 +318,19 @@ static struct irqaction irq_call = { asmlinkage void plat_irq_dispatch(void) { unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM; - unsigned int i; - - if ((MIPS_CPU_TIMER_IRQ == 7) && (pending & CAUSEF_IP7)) { - do_IRQ(MIPS_CPU_TIMER_IRQ); - goto out; - } else { - for (i = 0; i < MAX_IM; i++) { - if (pending & (CAUSEF_IP2 << i)) { - ltq_hw_irqdispatch(i); - goto out; - } - } + int irq; + + if (!pending) { + spurious_interrupt(); + return; } - pr_alert("Spurious IRQ: CAUSE=0x%08x\n", read_c0_status()); -out: - return; + pending >>= CAUSEB_IP; + while (pending) { + irq = fls(pending) - 1; + do_IRQ(MIPS_CPU_IRQ_BASE + irq); + pending &= ~BIT(irq); + } } static int icu_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) @@ -354,11 +355,6 @@ static const struct irq_domain_ops irq_domain_ops = { .map = icu_map, }; -static struct irqaction cascade = { - .handler = no_action, - .name = "cascade", -}; - int __init icu_of_init(struct device_node *node, struct device_node *parent) { struct device_node *eiu_node; @@ -390,7 +386,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent) mips_cpu_irq_init(); for (i = 0; i < MAX_IM; i++) - setup_irq(i + 2, &cascade); + irq_set_chained_handler(i + 2, ltq_hw_irq_handler); if (cpu_has_vint) { pr_info("Setting up vectored interrupts\n"); From patchwork Tue Apr 4 06:16:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96668 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47922qgd; Mon, 3 Apr 2017 23:17:07 -0700 (PDT) X-Received: by 10.98.77.69 with SMTP id a66mr21895535pfb.4.1491286627023; Mon, 03 Apr 2017 23:17:07 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m188si16434436pfc.145.2017.04.03.23.17.06; Mon, 03 Apr 2017 23:17:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752415AbdDDGRG (ORCPT + 6 others); Tue, 4 Apr 2017 02:17:06 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36510 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbdDDGRF (ORCPT ); Tue, 4 Apr 2017 02:17:05 -0400 Received: by mail-pg0-f42.google.com with SMTP id g2so140784620pge.3 for ; Mon, 03 Apr 2017 23:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9kzwUdPxD7Tmaremnkx0FnAxJcom5K86C8c5v11yIxg=; b=J5ajEieVCZdAgTthFEMrnxTxs3sNsc42O+ZMLDBvGfvwd2v07LvSa05h6add27gDs7 gKO0YAA7PwMLn7JE/7OIC4OakqOiGBe5nd6VnLd+IF/msjsNEEMSTGJRfbEELgY6FJrX ZFtc0Sy97Y/wwUc7LbCbzjx4BbJAwbWyitsRg= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=9kzwUdPxD7Tmaremnkx0FnAxJcom5K86C8c5v11yIxg=; b=dIVv7GJVN2jGywchO2FRbrK62aSpsGHmkqKfRNou2c4wQn6G9DLSV0DhzQubMZFyjR JNDK27mx+boMmS0WLPli+RFnDukC7M5U0/MBpmVi9pKbGspC60MCPxyp7SNM+9/2BSc9 GrxC/446/hJbqDR5Lv5imZYfdF0j8M+O4YUi93NWlJsl2o8zx77yHiR0C/1xqVA+lgMP ArcpOvLXzok24BEnJ5fllHezt7VEXaE8qIBazMG2QKQsal163KhNHZUl/l02uTZ2v9rc kOmK1IuNCO7XEPOGeGFMDjdeeeYvolecPtBhHbjlxDunwidQiJEImdfHPR/GzRQdkkrE RhEA== X-Gm-Message-State: AFeK/H3P2dVXSAfEL0E7HNA6MO4xKrz/8rVyyTPbEXvYB6gVTD6/dcEWifNWUByHDR5fwbgW X-Received: by 10.99.103.193 with SMTP id b184mr1241777pgc.35.1491286625069; Mon, 03 Apr 2017 23:17:05 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id f81sm29247068pfe.61.2017.04.03.23.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 23:17:04 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Wolfram Sang Subject: [PATCH 06/33] i2c: bcm2835: Fix hang for writing messages larger than 16 bytes Date: Tue, 4 Apr 2017 11:46:54 +0530 Message-Id: <1491286617-31131-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> References: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Noralf Trønnes Writing messages larger than the FIFO size results in a hang, rendering the machine unusable. This is because the RXD status flag is set on the first interrupt which results in bcm2835_drain_rxfifo() stealing bytes from the buffer. The controller continues to trigger interrupts waiting for the missing bytes, but bcm2835_fill_txfifo() has none to give. In this situation wait_for_completion_timeout() apparently is unable to stop the madness. The BCM2835 ARM Peripherals datasheet has this to say about the flags: TXD: is set when the FIFO has space for at least one byte of data. RXD: is set when the FIFO contains at least one byte of data. TXW: is set during a write transfer and the FIFO is less than full. RXR: is set during a read transfer and the FIFO is or more full. Implementing the logic from the downstream i2c-bcm2708 driver solved the hang problem. Signed-off-by: Noralf Trønnes Reviewed-by: Eric Anholt Reviewed-by: Martin Sperl Signed-off-by: Wolfram Sang (cherry picked from commit e2474541032db65d02bf88b6a8c2f954654b443f) Signed-off-by: Amit Pundir --- drivers/i2c/busses/i2c-bcm2835.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index d4f3239..f283b71 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -64,6 +64,7 @@ struct bcm2835_i2c_dev { int irq; struct i2c_adapter adapter; struct completion completion; + struct i2c_msg *curr_msg; u32 msg_err; u8 *msg_buf; size_t msg_buf_remaining; @@ -126,14 +127,13 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data) return IRQ_HANDLED; } - if (val & BCM2835_I2C_S_RXD) { - bcm2835_drain_rxfifo(i2c_dev); - if (!(val & BCM2835_I2C_S_DONE)) - return IRQ_HANDLED; - } - if (val & BCM2835_I2C_S_DONE) { - if (i2c_dev->msg_buf_remaining) + if (i2c_dev->curr_msg->flags & I2C_M_RD) { + bcm2835_drain_rxfifo(i2c_dev); + val = bcm2835_i2c_readl(i2c_dev, BCM2835_I2C_S); + } + + if ((val & BCM2835_I2C_S_RXD) || i2c_dev->msg_buf_remaining) i2c_dev->msg_err = BCM2835_I2C_S_LEN; else i2c_dev->msg_err = 0; @@ -141,11 +141,16 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data) return IRQ_HANDLED; } - if (val & BCM2835_I2C_S_TXD) { + if (val & BCM2835_I2C_S_TXW) { bcm2835_fill_txfifo(i2c_dev); return IRQ_HANDLED; } + if (val & BCM2835_I2C_S_RXR) { + bcm2835_drain_rxfifo(i2c_dev); + return IRQ_HANDLED; + } + return IRQ_NONE; } @@ -155,6 +160,7 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev, u32 c; unsigned long time_left; + i2c_dev->curr_msg = msg; i2c_dev->msg_buf = msg->buf; i2c_dev->msg_buf_remaining = msg->len; reinit_completion(&i2c_dev->completion); From patchwork Tue Apr 4 06:16:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96669 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47936qgd; Mon, 3 Apr 2017 23:17:09 -0700 (PDT) X-Received: by 10.99.149.16 with SMTP id p16mr21764688pgd.112.1491286629161; Mon, 03 Apr 2017 23:17:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m188si16434436pfc.145.2017.04.03.23.17.09; Mon, 03 Apr 2017 23:17:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752447AbdDDGRI (ORCPT + 6 others); Tue, 4 Apr 2017 02:17:08 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:32843 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752416AbdDDGRI (ORCPT ); Tue, 4 Apr 2017 02:17:08 -0400 Received: by mail-pg0-f45.google.com with SMTP id x125so142533343pgb.0 for ; Mon, 03 Apr 2017 23:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yI/p3Ge8PF7RcWpNL9syTFN8sRMSFRYur/RDSmIFjwY=; b=ByDKsvkHV7N6esL8WIliiuDZba+hR9hPqAf5033FCKyAv7nrwdvy8ARCYDqhyir5M5 oGnBgD1A/L4sQoJJFuYk2KUeEdgpZPJbEVFnjoPkqWTvImFXRi6pJrPeNORhyuv724y2 Uucs6MV12lDmKg2DIKMLR8q2DFlHukYzGOq6M= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=yI/p3Ge8PF7RcWpNL9syTFN8sRMSFRYur/RDSmIFjwY=; b=Rg8Lx/UTG8Y+exlIoXNfWT2a4SgcvbGJBufTw29r4wyJgorhKDsG5gTjqjpZcl9CXD bHTcduoaXHkISkvox7DVJT35HRU05iNroqkOphPQwEs8Key/oLUdtNyBjwEfBrNSqa4S BzSqldEDu+SzQg5lAL69XP6e768v2jnbo9ltGOX7P9atzRXn/4e7pZEW2ReOqYReP1OI wdzPVUuiHHIO3qKynM7GGCFqf97vb6rM5y4PJl/22e5e/2W9R+Y8eKE6d+mchMINAMbt vx5AUEXeBCyijcwXVw/FJWEyfCasg4im50VxOEibZpCRcldU0Hq+h10BXHHKJk1MA5E+ l5dQ== X-Gm-Message-State: AFeK/H3Q0JDw5MMA0z6WogmH7ZleRMnBTAnIIBASF/wE1o2dY6yzY8H9TqkhIw790qDcbpjd X-Received: by 10.98.59.139 with SMTP id w11mr1176560pfj.230.1491286627150; Mon, 03 Apr 2017 23:17:07 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id f81sm29247068pfe.61.2017.04.03.23.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 23:17:06 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Wolfram Sang Subject: [PATCH 07/33] i2c: bcm2835: Protect against unexpected TXW/RXR interrupts Date: Tue, 4 Apr 2017 11:46:55 +0530 Message-Id: <1491286617-31131-4-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> References: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Noralf Trønnes If an unexpected TXW or RXR interrupt occurs (msg_buf_remaining == 0), the driver has no way to fill/drain the FIFO to stop the interrupts. In this case the controller has to be disabled and the transfer completed to avoid hang. (CLKT | ERR) and DONE interrupts are completed in their own paths, and the controller is disabled in the transfer function after completion. Unite the code paths and do disabling inside the interrupt routine. Clear interrupt status bits in the united completion path instead of trying to do it on every interrupt which isn't necessary. Only CLKT, ERR and DONE can be cleared that way. Add the status value to the error value in case of TXW/RXR errors to distinguish them from the other S_LEN error. Signed-off-by: Noralf Trønnes Reviewed-by: Eric Anholt Signed-off-by: Wolfram Sang (cherry picked from commit d4030d75c7cbb434b2a3e5f6af5065879d2615a5) Signed-off-by: Amit Pundir --- drivers/i2c/busses/i2c-bcm2835.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index f283b71..d2ba1a4 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -50,8 +50,6 @@ #define BCM2835_I2C_S_CLKT BIT(9) #define BCM2835_I2C_S_LEN BIT(10) /* Fake bit for SW error reporting */ -#define BCM2835_I2C_BITMSK_S 0x03FF - #define BCM2835_I2C_CDIV_MIN 0x0002 #define BCM2835_I2C_CDIV_MAX 0xFFFE @@ -111,20 +109,26 @@ static void bcm2835_drain_rxfifo(struct bcm2835_i2c_dev *i2c_dev) } } +/* + * Note about I2C_C_CLEAR on error: + * The I2C_C_CLEAR on errors will take some time to resolve -- if you were in + * non-idle state and I2C_C_READ, it sets an abort_rx flag and runs through + * the state machine to send a NACK and a STOP. Since we're setting CLEAR + * without I2CEN, that NACK will be hanging around queued up for next time + * we start the engine. + */ + static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data) { struct bcm2835_i2c_dev *i2c_dev = data; u32 val, err; val = bcm2835_i2c_readl(i2c_dev, BCM2835_I2C_S); - val &= BCM2835_I2C_BITMSK_S; - bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_S, val); err = val & (BCM2835_I2C_S_CLKT | BCM2835_I2C_S_ERR); if (err) { i2c_dev->msg_err = err; - complete(&i2c_dev->completion); - return IRQ_HANDLED; + goto complete; } if (val & BCM2835_I2C_S_DONE) { @@ -137,21 +141,38 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data) i2c_dev->msg_err = BCM2835_I2C_S_LEN; else i2c_dev->msg_err = 0; - complete(&i2c_dev->completion); - return IRQ_HANDLED; + goto complete; } if (val & BCM2835_I2C_S_TXW) { + if (!i2c_dev->msg_buf_remaining) { + i2c_dev->msg_err = val | BCM2835_I2C_S_LEN; + goto complete; + } + bcm2835_fill_txfifo(i2c_dev); return IRQ_HANDLED; } if (val & BCM2835_I2C_S_RXR) { + if (!i2c_dev->msg_buf_remaining) { + i2c_dev->msg_err = val | BCM2835_I2C_S_LEN; + goto complete; + } + bcm2835_drain_rxfifo(i2c_dev); return IRQ_HANDLED; } return IRQ_NONE; + +complete: + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, BCM2835_I2C_C_CLEAR); + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_S, BCM2835_I2C_S_CLKT | + BCM2835_I2C_S_ERR | BCM2835_I2C_S_DONE); + complete(&i2c_dev->completion); + + return IRQ_HANDLED; } static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev, @@ -181,8 +202,9 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev, time_left = wait_for_completion_timeout(&i2c_dev->completion, BCM2835_I2C_TIMEOUT); - bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, BCM2835_I2C_C_CLEAR); if (!time_left) { + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, + BCM2835_I2C_C_CLEAR); dev_err(i2c_dev->dev, "i2c transfer timed out\n"); return -ETIMEDOUT; } From patchwork Tue Apr 4 06:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96670 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47952qgd; Mon, 3 Apr 2017 23:17:11 -0700 (PDT) X-Received: by 10.98.212.91 with SMTP id u27mr21355186pfl.117.1491286631324; Mon, 03 Apr 2017 23:17:11 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m188si16434436pfc.145.2017.04.03.23.17.11; Mon, 03 Apr 2017 23:17:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752453AbdDDGRK (ORCPT + 6 others); Tue, 4 Apr 2017 02:17:10 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:32861 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752416AbdDDGRK (ORCPT ); Tue, 4 Apr 2017 02:17:10 -0400 Received: by mail-pg0-f45.google.com with SMTP id x125so142534116pgb.0 for ; Mon, 03 Apr 2017 23:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OJiFDfsyOV1PrZSb2b5R31fUn8CXjSJkXlkTLmqQins=; b=Lo/hnJHXyCPP30f6GrLVA7DgWqHNRHEUZbDy+nIE6YVr7C2Xhm82Iqkmtv5KOg/RjN otRtH5nbp+tckyKOyHQ5q3fqDFdijSwYvgm65wOxdqUzOALBcddU869AxPbDTLTg4fC0 yoGidRZjErfe8hAKbF9zIwLozoI3E1S887bdQ= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=OJiFDfsyOV1PrZSb2b5R31fUn8CXjSJkXlkTLmqQins=; b=N2mCzoez3XMp7XT55UIStBTzFaw3azCOuqEaYOlaVWwTpkXFAPmasdbTos8RAEkSAz akdkelxsv6OlmUsuMZf7zb6oPWVSmSbG3jct7MOBnOuDhMZ7C08DGT6XnOef+tT1VO8O 2xTjJ5v7mQi9wDxOiZuywtcBaFSvCfULWLrzQxbnp+OWjm9HrXAak1F3dhL32DQuT57X OdmchPJS7qqxb/167JPUSv6Bb7zXF7c7ReDWgkhUoB6mpzAWSuH1xACZ/sOnQVdEKyQS PSLHOX1vnppwyWFJdTmAL8RT6nzflGVYEB+wxWfIVgycGP8ZW/22L8EufXrajCLg+7Kp RVFA== X-Gm-Message-State: AFeK/H2TRk42iGmhuGd5ivjsPUqeLlByPnlf1wkBVx3NX0byJUtfptGDmSpNA90d3VMJh2D3 X-Received: by 10.99.97.147 with SMTP id v141mr22091560pgb.98.1491286629403; Mon, 03 Apr 2017 23:17:09 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id f81sm29247068pfe.61.2017.04.03.23.17.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 23:17:08 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Wolfram Sang Subject: [PATCH 08/33] i2c: bcm2835: Use dev_dbg logging on transfer errors Date: Tue, 4 Apr 2017 11:46:56 +0530 Message-Id: <1491286617-31131-5-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> References: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Noralf Trønnes Writing to an AT24C32 generates on average 2x i2c transfer errors per 32-byte page write. Which amounts to a lot for a 4k write. This is due to the fact that the chip doesn't respond during it's internal write cycle when the at24 driver tries and retries the next write. Only a handful drivers use dev_err() on transfer error, so switch to dev_dbg() instead. Signed-off-by: Noralf Trønnes Reviewed-by: Eric Anholt Signed-off-by: Wolfram Sang (cherry picked from commit 23c9540b3ad1d7473fe40df80074d0fb0bf04869) Signed-off-by: Amit Pundir --- drivers/i2c/busses/i2c-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index d2ba1a4..54d510a 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -216,7 +216,7 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev, (msg->flags & I2C_M_IGNORE_NAK)) return 0; - dev_err(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err); + dev_dbg(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err); if (i2c_dev->msg_err & BCM2835_I2C_S_ERR) return -EREMOTEIO; From patchwork Tue Apr 4 06:16:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96671 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp47963qgd; Mon, 3 Apr 2017 23:17:13 -0700 (PDT) X-Received: by 10.99.8.67 with SMTP id 64mr17200222pgi.220.1491286633220; Mon, 03 Apr 2017 23:17:13 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m188si16434436pfc.145.2017.04.03.23.17.13; Mon, 03 Apr 2017 23:17:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbdDDGRM (ORCPT + 6 others); Tue, 4 Apr 2017 02:17:12 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:36557 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752416AbdDDGRM (ORCPT ); Tue, 4 Apr 2017 02:17:12 -0400 Received: by mail-pg0-f54.google.com with SMTP id g2so140786933pge.3 for ; Mon, 03 Apr 2017 23:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lRttNU9zl7m+OOHtrXYozdnODA3bc/VkKLtfQ5BIhq8=; b=O/8ZoCkHa7ADkOOrNetgSEW2WdnPcof55GyKyB8xklXX4HGuZ4iDL9IL+UqibAymxI CuOT6uiKw803I8uTayof+e3H214TpQuL62KKXDNxPEwrSmeOuclQIpMtbSe+OTGgGyz1 5e7QS5F0A+jq2uUnJdORtzXKNuXEt093iEbpE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lRttNU9zl7m+OOHtrXYozdnODA3bc/VkKLtfQ5BIhq8=; b=SKBN2Z8RYV3MMRmHKdAP8zckJnfpt+Ka3XmX5WckYnmxCSDqzGwKWQoOxOcPSW1BlA MFniYV9fAriyBNZM9Rz5LWXTXTZyL+OPolUjiSk1urVgKTh0F6OeIxp2UpgVj5jfn9Vq TSNKQE7MY3HUAcJOYNjsFtBRtOOfWes694AeRuTc1EbfbhnHsUSY/UIhxJAcmTIrTj03 buyUv0GC78csY4Mh5SyVbiH/x2mgYPtYVQNqKBfDybBPjTWKLGgUvv7q/2iAOPn8RTt0 S5xqfvURomP8NMOEHySMiI1A8y0WdtDG+WdRVCeYnHBn4plnDsLb1ub17AwQAx4bmQlc We4w== X-Gm-Message-State: AFeK/H2DsdlFeuOEr7G/Vt/1oSJPFJte0blrJy0KZ1HzMLaPjPBOVAlj7DVGmCNL/InXCWnG X-Received: by 10.99.6.66 with SMTP id 63mr21280224pgg.83.1491286631391; Mon, 03 Apr 2017 23:17:11 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id f81sm29247068pfe.61.2017.04.03.23.17.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 23:17:10 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Wolfram Sang Subject: [PATCH 09/33] i2c: bcm2835: Can't support I2C_M_IGNORE_NAK Date: Tue, 4 Apr 2017 11:46:57 +0530 Message-Id: <1491286617-31131-6-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> References: <1491286617-31131-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Noralf Trønnes The controller can't support this flag, so remove it. Documentation/i2c/i2c-protocol states that all of the message is sent: I2C_M_IGNORE_NAK: Normally message is interrupted immediately if there is [NA] from the client. Setting this flag treats any [NA] as [A], and all of message is sent. >From the BCM2835 ARM Peripherals datasheet: The ERR field is set when the slave fails to acknowledge either its address or a data byte written to it. So when the controller doesn't receive an ack, it sets ERR and raises an interrupt. In other words, the whole message is not sent. Signed-off-by: Noralf Trønnes Reviewed-by: Eric Anholt Signed-off-by: Wolfram Sang (cherry picked from commit 8d2cc5cc6ee5c0fc48a96bb29af55fc700f66fdf) Signed-off-by: Amit Pundir --- drivers/i2c/busses/i2c-bcm2835.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index 54d510a..565ef69 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -212,10 +212,6 @@ static int bcm2835_i2c_xfer_msg(struct bcm2835_i2c_dev *i2c_dev, if (likely(!i2c_dev->msg_err)) return 0; - if ((i2c_dev->msg_err & BCM2835_I2C_S_ERR) && - (msg->flags & I2C_M_IGNORE_NAK)) - return 0; - dev_dbg(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err); if (i2c_dev->msg_err & BCM2835_I2C_S_ERR)