Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654089pxb; Mon, 24 Jan 2022 14:32:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsY6/mUJ8oZS6rH6CuHS3t7jORYdwtE8hJ8KYjUQ7i1PO8TjCDUgf4m22qyvexYsMBWdrX X-Received: by 2002:a17:90b:3892:: with SMTP id mu18mr290424pjb.197.1643063524505; Mon, 24 Jan 2022 14:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063524; cv=none; d=google.com; s=arc-20160816; b=T5Rs96I9tHZvjaHcK1kgP+K34D722DqW8KFHNhD8YBk79pfPG5XeGm4HP9EN6G5GIu j0p9OTXEgAt92euLDCHIr+PU50UhGleyY9JdMJZXBnxsAy7yqOoCPq75zpcqW6O7GJ0I gw6Oa1gqOtiW7U5kcB9EHpLzSNHzXOrOUGfjTun38MFFnVOxaR+cgqSbIEMR+v29pWh+ 5o77NcC0MkSIVwgpxjGjTmlZBuB65m1ve9hHaHzUUcq2QegTLUY+uZtuhFqVwbkm4WsN h+66K2/bnOjSe4pC6U2hlvR7PDapMQs2Y5KbnZeZ7B1a03dpP9S7joeC0E1rDjBY2jcH loyQ== 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=vAXe+/zdscTyuNySTCvWp79p+nK7Ms/nUEbY2tTNOdA=; b=DnPIZZNQz/ZmlfjFN6YZsZ4j2YCTIa56+AlivrXPP/1ciIofCIlhgdGOOz0vn8HihQ gVEy6z1UUYrv+kdSbHsXx3pjumXeQhx7E6u5wpxUeggxKMpZd8GPrBFe3KS1JBNpkqj+ SPY2r6O0QN0L3sfGJJuvxHYneWFzw3QMAK80yttm+78vYH2GOxWSSu0xCkRD7aXEC/yi ncNbZXaxeTNlfisE46KbGqw9kUYKw0D3jd6NT4AQQREZ5fVFk04evSF8VHXBoWO1Hq4c aNPYFesVr7CBJGkVb9xJsECc/3tmjNUFAIV69eUP13EEpgoVQI76VZaUJm/irEZtdwhy hdzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1MZOWS2D; 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 y8si10517935pfq.133.2022.01.24.14.31.51; Mon, 24 Jan 2022 14:32:04 -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=1MZOWS2D; 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 S1587259AbiAXW2B (ORCPT + 99 others); Mon, 24 Jan 2022 17:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1454845AbiAXVdy (ORCPT ); Mon, 24 Jan 2022 16:33:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 166D8C075D33; Mon, 24 Jan 2022 12:21:51 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 90114614ED; Mon, 24 Jan 2022 20:21:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F6D8C340E5; Mon, 24 Jan 2022 20:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055710; bh=D0k/8wHfzd2f+CJlNo5H5l4gD1tUJCIVd5hODXTl0kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1MZOWS2DiBsw6aiEmIn3xQBTvxmmzY72VMTxC1zmcV7aB8EE8bpKWEpyOrsHgpRVe 7aKuUuA8fXTDDge39FrOEe83Tj+Nu07j0Ap84z/Q9x/V9uEoVPJf/Q3RFOVBNn9nlT 9JPFgwiyYTcl70hCZxYOrfjcqi1FPItSMuh0h1N8= 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.15 240/846] spi: Fix incorrect cs_setup delay handling Date: Mon, 24 Jan 2022 19:35:57 +0100 Message-Id: <20220124184109.206425661@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 97b5a811bd7f7..a42b9e8521ce0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -868,12 +868,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) @@ -915,7 +912,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