From patchwork Thu Aug 13 14:09:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 7008471 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F59CC05AC for ; Thu, 13 Aug 2015 14:09:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48756204F6 for ; Thu, 13 Aug 2015 14:09:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 605D920584 for ; Thu, 13 Aug 2015 14:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752101AbbHMOJe (ORCPT ); Thu, 13 Aug 2015 10:09:34 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:34076 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751906AbbHMOJe (ORCPT ); Thu, 13 Aug 2015 10:09:34 -0400 Received: by labd1 with SMTP id d1so26950419lab.1; Thu, 13 Aug 2015 07:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ibqccy6ESnKQLDKgsSOd9w7fpAnaMraRU0CBev10Xck=; b=pk6LUIljE5gR1LbhMeQoXhM1LOeHh5ig8UpA8X4FZ/6qGBWB71aqP910gvA8jwXPEd fMtJLXdDEqxRboW7lzuSAvigqJIbIDF0Iy1UFSqhb3bS3DfEZRl53d9xPI1g80ujjkKi TG/8xhPQQOzyImHLlc7uSjgCArin2rcEgKgnpK2ghSLYG8Vxc7oGWTh0TVDPIOM8KUoO rqIk1wK5GWcc2onagJBmE0XnMJ9ENwG3OYZ82wsJY281OC0XaHByAy+PHEfECRcEpAiO 6I9IGYKRPOas0kI/V35CM8QGhDxVzgyGKTqhZHoHSFq7peWY2pI6PJPWycpOEcCRiOCy MeIg== X-Received: by 10.152.36.7 with SMTP id m7mr36016115laj.87.1439474972322; Thu, 13 Aug 2015 07:09:32 -0700 (PDT) Received: from localhost.localdomain (194-239-236-19-hotspot.dk.customer.tdc.net. [194.239.236.19]) by smtp.gmail.com with ESMTPSA id bn2sm578770lbc.47.2015.08.13.07.09.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Aug 2015 07:09:31 -0700 (PDT) From: Ricardo Ribalda Delgado To: Mark Brown , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH] spi/spi-xilinx: Fix spurious IRQ ACK on irq mode Date: Thu, 13 Aug 2015 16:09:28 +0200 Message-Id: <1439474968-10260-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ACK of an inexistent IRQ can trigger an spurious IRQ that breaks the txrx logic. This has been observed on axi_quad_spi:3.2 core. This patch only ACKs IRQs that have not been Acknowledge jet. Reported-by: Edward Kigwana Tested-by: Edward Kigwana Signed-off-by: Ricardo Ribalda Delgado --- drivers/spi/spi-xilinx.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 7abf6792cc11..a339c1e9997a 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -249,19 +249,23 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) xspi->tx_ptr = t->tx_buf; xspi->rx_ptr = t->rx_buf; remaining_words = t->len / xspi->bytes_per_word; - reinit_completion(&xspi->done); if (xspi->irq >= 0 && remaining_words > xspi->buffer_size) { + u32 isr; use_irq = true; - xspi->write_fn(XSPI_INTR_TX_EMPTY, - xspi->regs + XIPIF_V123B_IISR_OFFSET); - /* Enable the global IPIF interrupt */ - xspi->write_fn(XIPIF_V123B_GINTR_ENABLE, - xspi->regs + XIPIF_V123B_DGIER_OFFSET); /* Inhibit irq to avoid spurious irqs on tx_empty*/ cr = xspi->read_fn(xspi->regs + XSPI_CR_OFFSET); xspi->write_fn(cr | XSPI_CR_TRANS_INHIBIT, xspi->regs + XSPI_CR_OFFSET); + /* ACK old irqs (if any) */ + isr = xspi->read_fn(xspi->regs + XIPIF_V123B_IISR_OFFSET); + if (isr) + xspi->write_fn(isr, + xspi->regs + XIPIF_V123B_IISR_OFFSET); + /* Enable the global IPIF interrupt */ + xspi->write_fn(XIPIF_V123B_GINTR_ENABLE, + xspi->regs + XIPIF_V123B_DGIER_OFFSET); + reinit_completion(&xspi->done); } while (remaining_words) {