Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3701050pxb; Mon, 24 Jan 2022 15:46:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOzcn5b3CaTLHTcvU0SVxYVIszo6uBt2SCx57sKsxhtX69tMqCke/IAVLvBZyZ6epflKNS X-Received: by 2002:a17:90a:de06:: with SMTP id m6mr685811pjv.196.1643067965348; Mon, 24 Jan 2022 15:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067965; cv=none; d=google.com; s=arc-20160816; b=vUqbAqJNbLPHe3OI07T7JHVnyXSl7BBNmggpP/XvTQXzTYycL5iSpil2FagVm+CQHj XI2h1zvlPiZ+/mUUz6AGIiZeJwvLfsFpR6b71A41P2lc5l1Rkx3+fAEIzStRKsHAa2SY /wpTo91s8Rd+ENrh48cdXThI3y80jF2EBfO5Z7En47pQK0oZfZYBtpcZwXbi/mgVEZw3 I4gS6iz03NBMZgNnaryYZSiAX2XOXsxZ8WWyCRfrtfrwrNq+jaP2oY7EC4n58XJ/FENp TvXxn9xxywRAVA2iXzrsMHPOgFKRBGQa/4rKFcIabam3hyNVHl6adt8bfqrQ+wbMiHpg g6pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ij7QQYed+Fp2QNa1K1NrsO64cveUHuK/Xjep4zW6oQ0=; b=ct+IR0VYmtRDVVvC376ZA6zLWc6tCnPS9Ph0AlIjL+8MONHqyghnmZCCpPpY8kDTia Tx2wsVfkxcWhyuHzt6A5eDPhezDFuj1eh7pSJ6lLGdaQnNslGKRCcBiJSlhc5fza4NJl daatxWM2vX+YxwY8yrh+711Toc4x6QmY2hDH+zAb9VkpPm5Xc0SAMpza8uP7LWe6AsJ0 paCfql4ltC3fqWDfC3GS7OfSPs6SgtRW9clQxIlUmlzaKrmhXAz5OEevPpohtvmjyWmX BxqJ7+zw1xj9HnRfhUSSEFKBAkWYNlCAtHMnrdcR27Cv9/qVUX5SbHGBz/oer/rg41mZ AU0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KlYddX6M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si6054515plg.43.2022.01.24.15.45.51; Mon, 24 Jan 2022 15:46:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KlYddX6M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2360073AbiAXXfx (ORCPT + 99 others); Mon, 24 Jan 2022 18:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382470AbiAXWrt (ORCPT ); Mon, 24 Jan 2022 17:47:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCCAC058CA7; Mon, 24 Jan 2022 13:06:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7A0B3B8105C; Mon, 24 Jan 2022 21:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B18CC340E5; Mon, 24 Jan 2022 21:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058414; bh=euvV2qblln196cQvs0sdoJbEw5S8kf4Gg7n8AGEG8qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KlYddX6MY+4ZHcrDGJRw02u/07UI034w8aMA6ZETUlSN1Dt//pGbEvWFd9jWcR2y7 BRMk/nih7E0mdpDvTnjpt0L7bGrHcZwcwg6jF1yskvyGmha+5Z0Id0nwO0Lzsg4qZw ELmdbMboqqh2AC/KSdzXkzDLNz7ASHVGm+EkOhvk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hector Martin , Mark Brown , Sasha Levin Subject: [PATCH 5.16 0281/1039] spi: Fix incorrect cs_setup delay handling Date: Mon, 24 Jan 2022 19:34:30 +0100 Message-Id: <20220124184134.731725722@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hector Martin [ Upstream commit 95c07247399536f83b89dc60cfe7b279d17e69f6 ] Move the cs_setup delay to the end of spi_set_cs. >From include/linux/spi/spi.h: * @cs_setup: delay to be introduced by the controller after CS is asserted The cs_setup delay needs to happen *after* CS is asserted, that is, at the end of spi_set_cs, not at the beginning. Otherwise we're just delaying before the SPI transaction starts at all, which isn't very useful. No drivers use this right now, but that is likely to change soon with an upcoming Apple SPI HID transport driver. Fixes: 25093bdeb6bc ("spi: implement SW control for CS times") Signed-off-by: Hector Martin Link: https://lore.kernel.org/r/20211210170534.177139-1-marcan@marcan.st Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index fdd530b150a7a..8ba87b7f8f1a8 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -947,12 +947,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) spi->controller->last_cs_enable = enable; spi->controller->last_cs_mode_high = spi->mode & SPI_CS_HIGH; - if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || - !spi->controller->set_cs_timing) { - if (activate) - spi_delay_exec(&spi->cs_setup, NULL); - else - spi_delay_exec(&spi->cs_hold, NULL); + if ((spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || + !spi->controller->set_cs_timing) && !activate) { + spi_delay_exec(&spi->cs_hold, NULL); } if (spi->mode & SPI_CS_HIGH) @@ -994,7 +991,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) || !spi->controller->set_cs_timing) { - if (!activate) + if (activate) + spi_delay_exec(&spi->cs_setup, NULL); + else spi_delay_exec(&spi->cs_inactive, NULL); } } -- 2.34.1