From patchwork Fri May 1 23:37:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Wan X-Patchwork-Id: 6313311 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C627A9F1C2 for ; Fri, 1 May 2015 23:38:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E83F82041E for ; Fri, 1 May 2015 23:38:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7EF1320392 for ; Fri, 1 May 2015 23:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750839AbbEAXiF (ORCPT ); Fri, 1 May 2015 19:38:05 -0400 Received: from mail-bl2on0140.outbound.protection.outlook.com ([65.55.169.140]:61029 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750804AbbEAXiE (ORCPT ); Fri, 1 May 2015 19:38:04 -0400 Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; Received: from BLUPRD0210HT002.namprd02.prod.outlook.com (157.56.232.37) by CO2PR0701MB821.namprd07.prod.outlook.com (10.141.246.27) with Microsoft SMTP Server (TLS) id 15.1.148.16; Fri, 1 May 2015 23:37:59 +0000 From: Jane Wan To: , , , , , CC: Jane Wan Subject: [PATCH] Fix an error that can cause fsl espi task blocked for more than 120 seconds Date: Fri, 1 May 2015 16:37:42 -0700 Message-ID: <1430523462-12306-1-git-send-email-Jane.Wan@gainspeed.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Originating-IP: [157.56.232.37] X-ClientProxiedBy: SN1PR07CA0030.namprd07.prod.outlook.com (25.162.170.168) To CO2PR0701MB821.namprd07.prod.outlook.com (10.141.246.27) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR0701MB821; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CO2PR0701MB821; BCL:0; PCL:0; RULEID:; SRVR:CO2PR0701MB821; X-Forefront-PRVS: 0563F2E8B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(50466002)(42186005)(46102003)(50226001)(48376002)(92566002)(19580405001)(50986999)(122386002)(2201001)(47776003)(66066001)(19580395003)(5001770100001)(86362001)(5001920100001)(229853001)(62966003)(5001960100002)(36756003)(87976001)(77156002)(107886002)(77096005)(7059030)(4001450100001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CO2PR0701MB821; H:BLUPRD0210HT002.namprd02.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-OriginatorOrg: gainspeed.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2015 23:37:59.8666 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR0701MB821 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 Incorrect condition is used in spin_event_timeout(). When the TX is done, the SPIE_NF bit in ESPI_SPIE register is set to 1 to indicate the Tx FIFO is not full. If the bit is 0, it indicates the Tx FIFO is full. Due to this error, if the Tx FIFO is full at the beginning, but becomes not full after handling the Rx FIFO (the SPIE_NF bit is set), the spin_event_timeout() returns with timeout occurred. It causes the interrupt handler not to send completion notification to the thread that called wait_for_complete() waiting for the notification. Signed-off-by: Jane Wan --- drivers/spi/spi-fsl-espi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 9011e5d..333d5c2 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -551,9 +551,13 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) /* spin until TX is done */ ret = spin_event_timeout(((events = mpc8xxx_spi_read_reg( - ®_base->event)) & SPIE_NF) == 0, 1000, 0); + ®_base->event)) & SPIE_NF), 1000, 0); if (!ret) { dev_err(mspi->dev, "tired waiting for SPIE_NF\n"); + + /* Clear the SPIE bits */ + mpc8xxx_spi_write_reg(®_base->event, events); + complete(&mspi->done); return; } }