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: 10422401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 64A4060224 for ; Wed, 23 May 2018 20:52:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45CA129252 for ; Wed, 23 May 2018 20:52:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A8E829255; Wed, 23 May 2018 20:52:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82C8629252 for ; Wed, 23 May 2018 20:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934829AbeEWUwZ (ORCPT ); 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-Google-Smtp-Source: AB8JxZoBqwbQDEMoxo0Jh4pfXGdnYhrQn4VO9oG9VTQsrQB9q3m75t/Fgu67HxUWIblHL4UHkrJHlg== 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=20Tr=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 X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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) &