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 (Arm)" X-Patchwork-Id: 10422405 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 777A06032C for ; Wed, 23 May 2018 20:52:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 675ED29250 for ; Wed, 23 May 2018 20:52:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C27E29254; Wed, 23 May 2018 20:52:53 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A62F729250 for ; Wed, 23 May 2018 20:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=suusG2x4bKmAOJFnzBmUKoCix+cXuupzfxGfTlRqORQ=; b=B+s lGPB1urcjEtG7jIblHFv2WwIlNDjDO3SGKuAwqkOpz2a33eoAaIxLRpyMLpDneqgiogvPkS9FuWxM H8w0HiffbwX/riTN+haZjz3gVAV8gkyJZkpQk0lrWhcj3C5V7i7UxhcKw8fuVA0IlX/5eTXK4vnl3 WbITfE682j/PuNVGHQwrlAEL+Fx98ejLLImByj6UuTJz2gThkpgFbn4LIZNja6ey0JmbFq45id9tD 9Xi4QxTD2bWXCH/ZJqUeIUMrVdn0fKA9Sao9CWhH8SHEFC1133Bq8MMxM7w5QvzdzZ8zjqqwHJesi 3uDXZmHCpZ97buMNJbXuMmuJZEA92zw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLakQ-00062C-NR; Wed, 23 May 2018 20:52:38 +0000 Received: from mail-yw0-f195.google.com ([209.85.161.195]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLakM-0005zU-Ju; Wed, 23 May 2018 20:52:36 +0000 Received: by mail-yw0-f195.google.com with SMTP id m8-v6so7167330ywd.2; Wed, 23 May 2018 13:52:24 -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=GklCcbBFxtFbY4h85eDqLfPAE5sebSbiTEuqqbRIElgYr4IkBrpsWuH7nfVl1/p6TV cdroZcSeRP5AIycpy9hlSxRBzspdrzjC5zmrlkkNEfEkBAhV0YfRyf9tWvtt44IxMeAu BjU4aZQBIQzNeMF//YMc6QSuWLafdIoARAAz2W9jtr8TwpLfsE7AgR5nHJIkiy+Y7V69 R9fTMmBWt7RBMJB7eEeAryWjufyjZz9SDtGapM6yAUboaT9mOApG2+hbjHqAevPzxKP0 hOPmbbl6yTNAdJdTJpLAKIYtCVpkasU3cvMI5ZmuzAsZv9j7ECci37mGLkHSNe10fnIz SrGg== X-Gm-Message-State: ALKqPwc8YJLOPcJwPrh8TvgAbMTvc5x1NVozQEg1p4YpjftT/ABXCcVO EhW/QedWesYIG3USQRKdBA== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180523_135234_670861_D3C9E746 X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , Florian Fainelli , Scott Branden , Ray Jui , Alexander Graf , linux-spi@vger.kernel.org, Eric Anholt , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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) &