From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753331AbcITHqh (ORCPT ); Tue, 20 Sep 2016 03:46:37 -0400 Received: from 212-186-180-163.static.upcbusiness.at ([212.186.180.163]:60362 "EHLO cgate.sperl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751297AbcITHqf (ORCPT ); Tue, 20 Sep 2016 03:46:35 -0400 From: Martin Sperl Subject: Re: [PATCH 1/3] i2c: bcm2835: Fix hang for writing messages larger than 16 bytes To: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= , wsa@the-dreams.de, swarren@wwwdotorg.org, eric@anholt.net References: <1474298777-5858-1-git-send-email-noralf@tronnes.org> Cc: linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org Message-ID: Date: Tue, 20 Sep 2016 08:46:58 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <1474298777-5858-1-git-send-email-noralf@tronnes.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19.09.2016 17:26, Noralf Trønnes wrote: > Writing messages larger than the FIFO size results in a hang, rendering > the machine unusable. This is because the RXD status flag is set on the > first interrupt which results in bcm2835_drain_rxfifo() stealing bytes > from the buffer. The controller continues to trigger interrupts waiting > for the missing bytes, but bcm2835_fill_txfifo() has none to give. I remember having seen similar interrupt issues with the SPI HW-block. > In this situation wait_for_completion_timeout() apparently is unable to > stop the madness. That is because it is a level irq that immediately triggers another interrupt giving no CPU no time to do other (threaded) OS activity - this might be slightly different for multi-core machines... > The BCM2835 ARM Peripherals datasheet has this to say about the flags: > TXD: is set when the FIFO has space for at least one byte of data. > RXD: is set when the FIFO contains at least one byte of data. > TXW: is set during a write transfer and the FIFO is less than full. > RXR: is set during a read transfer and the FIFO is or more full. > > Implementing the logic from the downstream i2c-bcm2708 driver solved > the hang problem. > > Signed-off-by: Noralf Trønnes Reviewed-by: Martin Sperl