From patchwork Wed Jul 22 02:03:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 6839091 Return-Path: X-Original-To: patchwork-linux-omap@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 3DE329F1D4 for ; Wed, 22 Jul 2015 02:03:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 23294206E3 for ; Wed, 22 Jul 2015 02:03:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6436F206A2 for ; Wed, 22 Jul 2015 02:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932647AbbGVCDR (ORCPT ); Tue, 21 Jul 2015 22:03:17 -0400 Received: from mail.kernel.org ([198.145.29.136]:35188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754876AbbGVCDN (ORCPT ); Tue, 21 Jul 2015 22:03:13 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9AB0E203ED; Wed, 22 Jul 2015 02:03:11 +0000 (UTC) Received: from mail.kernel.org (host-091-097-100-191.ewe-ip-backbone.de [91.97.100.191]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44A29203E1; Wed, 22 Jul 2015 02:03:10 +0000 (UTC) Date: Wed, 22 Jul 2015 04:03:07 +0200 From: Sebastian Reichel To: Michael Welling Cc: Pavel Machek , Pali =?iso-8859-1?Q?Roh=E1r?= , Tony Lindgren , Ivaylo Dimitrov , Aaro Koskinen , Nishanth Menon , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: linux 4.2-rc1 broken Nokia N900 Message-ID: <20150722020306.GA8379@earth> References: <201507111405.06048@pali> <201507132234.22082@pali> <20150713215232.GA22584@deathray> <201507140002.44119@pali> <20150713223607.GA23001@deathray> <20150714071412.GA12844@pali> <20150720204647.GA11931@deathstar> <20150721093441.GA23241@amd> <20150722001741.GA7950@deathstar> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150722001741.GA7950@deathstar> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Tue, Jul 21, 2015 at 07:17:41PM -0500, Michael Welling wrote: > On Tue, Jul 21, 2015 at 11:34:41AM +0200, Pavel Machek wrote: > > This code has my head spinning. > > I found that the errors do not occur when the driver is built into the kernel. > > I also found that with the patch below the errors go away. > > Not sure if it is acceptible but see if it fixes things on your side. > > > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > index cf8b91b..3164d13 100644 > --- a/drivers/spi/spi.c > +++ b/drivers/spi/spi.c > @@ -1801,11 +1801,11 @@ int spi_setup(struct spi_device *spi) > if (!spi->max_speed_hz) > spi->max_speed_hz = spi->master->max_speed_hz; > > - spi_set_cs(spi, false); > - > if (spi->master->setup) > status = spi->master->setup(spi); > > + spi_set_cs(spi, false); > + > dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d\n", > (int) (spi->mode & (SPI_CPOL | SPI_CPHA)), > (spi->mode & SPI_CS_HIGH) ? "cs_high, " : "", mh. maybe a runtime PM issue? * external abort on non-linefetch: address cannot be accessed, since the module's clocks are disabled * built-in works, module not: built-in is probably a little bit faster (module must not be loaded from filesystem), so that the device has not yet been suspended * Before 4.2, omap2_mcspi_set_cs() was called in the setup routine, which acquired runtime PM * In 4.2, omap2_mcspi_set_cs() seems to be called without a prior pm_runtime_get_sync() * With your workaround, the device has not yet returned to suspend after the runtime PM acquisition in setup() So I suggest trying the following (compile tested only) patch: -- Sebastian Tested-by: Pavel Machek Tested-by: Pali Rohár diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 5867384..f7d9ffd 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -245,6 +245,7 @@ static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable) static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable) { + struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); u32 l; /* The controller handles the inverted chip selects @@ -255,6 +256,8 @@ static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable) enable = !enable; if (spi->controller_state) { + pm_runtime_get_sync(mcspi->dev); + l = mcspi_cached_chconf0(spi); if (enable) @@ -263,6 +266,9 @@ static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable) l |= OMAP2_MCSPI_CHCONF_FORCE; mcspi_write_chconf0(spi, l); + + pm_runtime_mark_last_busy(mcspi->dev); + pm_runtime_put_autosuspend(mcspi->dev); } }