From patchwork Tue Jan 7 20:27:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 3449821 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67141C02DC for ; Tue, 7 Jan 2014 20:27:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C0352010C for ; Tue, 7 Jan 2014 20:27:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3F70200E8 for ; Tue, 7 Jan 2014 20:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752996AbaAGU1U (ORCPT ); Tue, 7 Jan 2014 15:27:20 -0500 Received: from juliette.telenet-ops.be ([195.130.137.74]:51732 "EHLO juliette.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751114AbaAGU1U (ORCPT ); Tue, 7 Jan 2014 15:27:20 -0500 Received: from ayla.of.borg ([84.193.72.141]) by juliette.telenet-ops.be with bizsmtp id B8TJ1n00e32ts5g068TJKN; Tue, 07 Jan 2014 21:27:18 +0100 Received: from geert (helo=localhost) by ayla.of.borg with local-esmtp (Exim 4.76) (envelope-from ) id 1W0dF8-0008Ro-7z; Tue, 07 Jan 2014 21:27:18 +0100 Date: Tue, 7 Jan 2014 21:27:18 +0100 (CET) From: Geert Uytterhoeven To: linux-spi@vger.kernel.org, linux-sh@vger.kernel.org Subject: spi-rspi I/O errors Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 I was regularly getting I/O errors when using the Renesas RSPI/QSPI driver on r8a7791: m25p80 spi0.0: error -110 reading SR Until I applied the following patch, which re-reads RSPI_SPSR on a time-out, and continues if the condition has become true: Now it prints from time to time: *** rspi->spsr = 0x20, real spsr = 0xa0, wait_mask = 0x80 *** which shows that rspi->spsr (as set from the interrupt handler) didn't have bit 7 set, while RSPI_SPSR does have bit 7 set. So this looks like a race condition in the interrupt handling. I didn't notice any data corruption after the patch. Gr{oetje,eeting}s, Geert --- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 4b31d89e8568..e63e30c500da 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -442,8 +442,13 @@ static int rspi_wait_for_interrupt(struct rspi_data *rspi, u8 wait_mask, rspi->spsr = rspi_read8(rspi, RSPI_SPSR); rspi_enable_irq(rspi, enable_bit); ret = wait_event_timeout(rspi->wait, rspi->spsr & wait_mask, HZ); - if (ret == 0 && !(rspi->spsr & wait_mask)) - return -ETIMEDOUT; + if (ret == 0 && !(rspi->spsr & wait_mask)) { + u8 spsr = rspi_read8(rspi, RSPI_SPSR); + printk("*** rspi->spsr = 0x%02x, real spsr = 0x%02x, wait_mask = 0x%02x ***\n", + rspi->spsr, spsr, wait_mask); + if (!(spsr & wait_mask)) + return -ETIMEDOUT; + } return 0; }