Received: by 10.223.185.116 with SMTP id b49csp6328537wrg; Wed, 28 Feb 2018 07:39:19 -0800 (PST) X-Google-Smtp-Source: AH8x224akAH1ThIvTeL0KUwoiOAWfTXN4rm4AhOwDr4ubZovPkyqYcwAQaRP7lA46iZ2l/xArYts X-Received: by 2002:a17:902:149:: with SMTP id 67-v6mr18236850plb.73.1519832359561; Wed, 28 Feb 2018 07:39:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519832359; cv=none; d=google.com; s=arc-20160816; b=M4IBWrYfz+u6IWbcRttZQhD5qSfAcdFQJjPYzieQhojBJbIszDoxH/Fgp6VPfFIxxX Dxq83M/TnbZ2pdL1hGY5aGqxaHBwp0msfWFg/phmdKufYXjrCr7Zlu68fIPXmg6f5jVQ uEXWbQqrbb7ZCP2sPSmzIkbJt85OocNZIV+zDP2Y2YH+DWS4Nz5s52Na+UkDuRKRlRoh JBcJCnvICRUx4X0vL1fM16JabWxVWFWk6RZKOyxRFMR0E2yCcDBvy1Zz7ZAhfXKCAWIL 5FzF1cnDV0l0lHs6RG5CHvUgzUU7k8abFzsbQHBVT55jr1TutvMRKU33i80EjLrwoDhL OHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=5bdLjTTapBrJzI81dRLdAbWsS5MqGovfV1dU/ucfk08=; b=bZvlI9axwuoL5MvWuhEf+8Ps8VYOtfDdayQQExlQCopbHOkgXflyEd+jyjX4eM4R6D oIzd/pe1cf5fbNqprTG66i4k822q+zabUhl/8U/pGJ7eDGkhxAbQjL+4hgNVkcHNzLEp W8iF3ST13UA2YCchLZTO0IW/E8F4ViunG5jTucPe8nZ+P+NizcD0GlzKFppyYj/MBjnm dRvfA3Qv4dxwDmLIb5mYeUG0RIyT8V1RbKrmRE6gPyFLtyxczduW/mcOR5vi9jHsxu3p /U18dkJo2dmKrz2i+1mw7ScqOIULxZOjslk3lk5+pU5hrqSTSiEZ0pwjLe9JJVYN7sbS idhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12-v6si1440601plk.518.2018.02.28.07.39.05; Wed, 28 Feb 2018 07:39:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932963AbeB1Pgn (ORCPT + 99 others); Wed, 28 Feb 2018 10:36:43 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:33293 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752773AbeB1PWe (ORCPT ); Wed, 28 Feb 2018 10:22:34 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yf-0006Xb-8a; Wed, 28 Feb 2018 15:22:17 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yd-0008P8-TJ; Wed, 28 Feb 2018 15:22:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Douglas Anderson" , "Jon Hunter" , "Lee Jones" , "Brian Norris" , "Benson Leung" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 036/254] mfd: cros ec: spi: Don't send first message too soon In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jon Hunter commit 15d8374874ded0bec37ef27f8301a6d54032c0e5 upstream. On the Tegra124 Nyan-Big chromebook the very first SPI message sent to the EC is failing. The Tegra SPI driver configures the SPI chip-selects to be active-high by default (and always has for many years). The EC SPI requires an active-low chip-select and so the Tegra chip-select is reconfigured to be active-low when the EC SPI driver calls spi_setup(). The problem is that if the first SPI message to the EC is sent too soon after reconfiguring the SPI chip-select, it fails. The EC SPI driver prevents back-to-back SPI messages being sent too soon by keeping track of the time the last transfer was sent via the variable 'last_transfer_ns'. To prevent the very first transfer being sent too soon, initialise the 'last_transfer_ns' variable after calling spi_setup() and before sending the first SPI message. Signed-off-by: Jon Hunter Reviewed-by: Brian Norris Reviewed-by: Douglas Anderson Acked-by: Benson Leung Signed-off-by: Lee Jones [bwh: Backported to 3.16: use ktime_get_ts() and timespec_to_ns()] Signed-off-by: Ben Hutchings --- --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c @@ -347,6 +347,7 @@ static int cros_ec_spi_probe(struct spi_ struct device *dev = &spi->dev; struct cros_ec_device *ec_dev; struct cros_ec_spi *ec_spi; + struct timespec ts; int err; spi->bits_per_word = 8; @@ -379,6 +380,9 @@ static int cros_ec_spi_probe(struct spi_ ec_dev->din_size = EC_MSG_BYTES + EC_MSG_PREAMBLE_COUNT; ec_dev->dout_size = EC_MSG_BYTES; + ktime_get_ts(&ts); + ec_spi->last_transfer_ns = timespec_to_ns(&ts); + err = cros_ec_register(ec_dev); if (err) { dev_err(dev, "cannot register EC\n");