From patchwork Thu May 3 18:09:44 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: 10378841 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 3CC246037D for ; Thu, 3 May 2018 18:09:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F452920D for ; Thu, 3 May 2018 18:09:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26DAE29211; Thu, 3 May 2018 18:09:49 +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 810CA2920D for ; Thu, 3 May 2018 18:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751121AbeECSJr (ORCPT ); Thu, 3 May 2018 14:09:47 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:44621 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751166AbeECSJr (ORCPT ); Thu, 3 May 2018 14:09:47 -0400 Received: by mail-ot0-f196.google.com with SMTP id g7-v6so21673828otj.11 for ; Thu, 03 May 2018 11:09:47 -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=zd2a/kWDZCGQx42OMBRWF2QliLqXQNMDv7vrXaEFoo4=; b=GHlMkMw/VCh4I9RuT2c+OtG5wYIv++2hotqQJgTsH8dSeV7Nrzq9Emc/gaRpEV9xip 94h5HqWViy2d4GQRz0xB1/M1glbsihkaTZF/AE7ctPuuIRHBZOCjMMtqP94gS5pyfnuB igVP1/+cU8eBgySER5TFd9rvxLCGHOxVvdhOxyqiFHhIFw0IeOoZoJzp6KdCi7kSAXcU EH6GUOVkjZY6KROJYSQtavjmU5YJdRRUyXycn+GarrR2E4PHL1VB/X81uNVoKEgt/3Jp B4pqrjjOq0Hm3UMEOHekrDqb9hD12AwLqxZ7L1RlWSAuuu96MI6NKXRBPIJzgtO9U+GM eFsA== X-Gm-Message-State: ALQs6tDnz/kBpyV+2vIks3C4NFCa8CdMqdmEBQ9e4ABlp7Qx2WGCZGVa BOnDwZqXc0G1lPv2u4RWNw== X-Google-Smtp-Source: AB8JxZo4lRXhvIg+uhthTNiEToggZr2IIHvVouMO76E6499Q0Ao7Ac4CLBtiw8naJHX7/7jOrz1YjQ== X-Received: by 2002:a9d:1a2f:: with SMTP id a44-v6mr14761387ote.275.1525370986687; Thu, 03 May 2018 11:09:46 -0700 (PDT) Received: from xps15.herring.priv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id t202-v6sm4054494oif.57.2018.05.03.11.09.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 11:09:46 -0700 (PDT) From: Rob Herring To: Mark Brown Cc: Alexander Graf , Marc Zyngier , Eric Anholt , 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 Subject: [PATCH] spi: bcm2835aux: ensure interrupts are enabled for shared handler Date: Thu, 3 May 2018 13:09:44 -0500 Message-Id: <20180503180945.3502-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. Shared handlers must check that interrupts are actually enabled before servicing the interrupt. Add a check that the TXEMPTY or IDLE interrupts are enabled. [1] https://patchwork.kernel.org/patch/9781221/ Cc: Alexander Graf Cc: Marc Zyngier Cc: Mark Brown Cc: Eric Anholt 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 Signed-off-by: Rob Herring Reviewed-by: Eric Anholt --- Compile tested only. I'll add something to the related github issue on this and hopefully someone can test and confirm. I'm assuming the 8250 driver can handle shared irqs correctly. Rob 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) &