From patchwork Wed May 23 20:52:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 136678 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1361463lji; Wed, 23 May 2018 13:52:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpupFKuS6mBV5vnI4Gok0JHY7K5tNRy/6wGRA7nxI71XZu7JIJzX7qehGdoGLPZmwD/3TvF X-Received: by 2002:a17:902:848b:: with SMTP id c11-v6mr4419995plo.132.1527108746727; Wed, 23 May 2018 13:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527108746; cv=none; d=google.com; s=arc-20160816; b=QLQAw+yjy5DUYo+ogxjZfDSO7azKcMe57c6+U79GLkFAKN0wH6gSGgeOfjzeiCQ6Uk k3e9u2fd+byrqmlYpeoSksH7kldVkvP/YTcFXKi8jgcCKwvfnRJlznly31zqkjwbjCXa JBtfsCrswbZiaF6XlVX85QN2iHgR46ymbBpVU84ygAqRE4hqxMfWZgW2dZbJ898WvS4T LlJDZRcL+eMCPar3BCl6ZVY297NKpVBxqoRbo+5TWn++sFgLpzAKm9fSD/AvM161kJlP ZOvm+6kR98S6/Ea7x4yYXof9Ndz8VJX2RbcHwJ+maBHk2FhZ4iq/NDJvdua4tVGeToUK S8Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Gh80cWwWFNoxZgN42cuzy1DFJ4E5xlReBbEAlw9Dgps=; b=Gi0BmsttGGLEkB+D9mLTM8/L4R8GMa8pBz8P5tFptwoS2N4GIR/G5IPnZ/0VW74sDx lYxYa2MouKT8h1txx0csnj55KQeIFJ5vEHA1gWBITZnI0y6CQ5SNUI01yR1vFpKvNRah HEO6JPxWPY7LgZ+ivA6Pcc/Q70ifIfs3swCujsuCr0QrEgZdrryPB3DH4Y1t3WA6jXLB tmPVcrKDQUCx35JAI6FPdt5CD5RsATQ0FtklOr+3kwKo0qpUIX6wFUWU4pVaRki5bZYy RtrKCC6jsxqFAVEfsT0GACKPT3qoPxK7A0dsZFIrKg1H1coWYKeRrvXHbBMftceHqyxy YGmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2-v6si5420812pgu.48.2018.05.23.13.52.26; Wed, 23 May 2018 13:52:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934829AbeEWUwZ (ORCPT + 1 other); Wed, 23 May 2018 16:52:25 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:41907 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934553AbeEWUwY (ORCPT ); Wed, 23 May 2018 16:52:24 -0400 Received: by mail-yw0-f194.google.com with SMTP id h11-v6so6381010ywc.8 for ; Wed, 23 May 2018 13:52:23 -0700 (PDT) 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; bh=2EncJTzZfnIcc0IcjOSaDevd+rfIAH0sXmavBfKg27I=; b=KQAQZK0IUH4XYuXFcGnpD9cE36Gtl2raoUjHmVkRmHuW+8NY0vW8VUXP8zuCJTPrwz 0xU6Gj+slgIVwVlAkx1b0Af7oOmB2KqYNj58kBU8oIsrhCmBWgp8fdv20zup7U0unwqC bT2Jbav+Jd6AJviDaElzWAAoTagmzZuE/mJq/3kGXl/YOiCcBkKOSs8Q3yyPWO+pnBVB IxKBbpyfzPepgj2ISuzxddSq1DiMyhlPOOgsnp+eEbDK4o+3gma41Wx1GFpqmqu055gw RAPDJQp5ioTZ8Z6ftxz4cpvMtCE6QIDpTIYw092e+QhjLGtbD84VQJg9ALVb2GgLus1J hyPg== X-Gm-Message-State: ALKqPwdJZR4Kdf006FQuHnqSDk/ZbsNTPt5a3QM0mPBPtINZW+Oz/G3u SSkHeiER8/ClHhkouQVWZQ== X-Received: by 2002:a0d:ee82:: with SMTP id x124-v6mr2425814ywe.239.1527108743361; Wed, 23 May 2018 13:52:23 -0700 (PDT) Received: from localhost.localdomain (24-223-123-72.static.usa-companies.net. [24.223.123.72]) by smtp.googlemail.com with ESMTPSA id t79-v6sm8715693ywg.109.2018.05.23.13.52.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 13:52:22 -0700 (PDT) From: Rob Herring To: Mark Brown , Martin Sperl , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Phil Elwell Cc: Alexander Graf , Stefan Wahren , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-spi@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Eric Anholt Subject: [PATCH v2] spi: bcm2835aux: ensure interrupts are enabled for shared handler Date: Wed, 23 May 2018 15:52:20 -0500 Message-Id: <20180523205220.7394-1-robh@kernel.org> X-Mailer: git-send-email 2.17.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The BCM2835 AUX SPI has a shared interrupt line (with AUX UART). Downstream fixes this with an AUX irqchip to demux the IRQ sources and a DT change which breaks compatibility with older kernels. The AUX irqchip was already rejected for upstream[1] and the DT change would break working systems if the DTB is updated to a newer one. The latter issue was brought to my attention by Alex Graf. The root cause however is a bug in the shared handler. A shared handler must correctly identify it actually handled an interrupt. The handler here was processing data whether interrupts were enabled or not. It would return IRQ_HANDLED if there was any data and not only when there was an actual interrupt pending. The result is that another device's IRQ could cause the SPI's IRQ handler to run and process data when the the SPI driver working in polled mode. Fix this by adding a check in the IRQ handler that the TXEMPTY or IDLE interrupts are enabled and always return IRQ_NONE when they are not. [1] https://patchwork.kernel.org/patch/9781221/ Cc: Alexander Graf Cc: Mark Brown Cc: Stefan Wahren Cc: Florian Fainelli Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com Cc: linux-spi@vger.kernel.org Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Reviewed-by: Eric Anholt Signed-off-by: Rob Herring --- Still hoping someone can test this as I have not. v2: - Expand commit message text about shared handler req. and how polled mode causes the problem. drivers/spi/spi-bcm2835aux.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c index 1431cb98fe40..3094d818cf06 100644 --- a/drivers/spi/spi-bcm2835aux.c +++ b/drivers/spi/spi-bcm2835aux.c @@ -184,6 +184,11 @@ static irqreturn_t bcm2835aux_spi_interrupt(int irq, void *dev_id) struct bcm2835aux_spi *bs = spi_master_get_devdata(master); irqreturn_t ret = IRQ_NONE; + /* IRQ may be shared, so return if our interrupts are disabled */ + if (!(bcm2835aux_rd(bs, BCM2835_AUX_SPI_CNTL1) & + (BCM2835_AUX_SPI_CNTL1_TXEMPTY | BCM2835_AUX_SPI_CNTL1_IDLE))) + return ret; + /* check if we have data to read */ while (bs->rx_len && (!(bcm2835aux_rd(bs, BCM2835_AUX_SPI_STAT) &