From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96EC9CA9EAF for ; Thu, 24 Oct 2019 17:13:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59BCE20650 for ; Thu, 24 Oct 2019 17:13:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Yga2aNmR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="MM/18hyC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59BCE20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=seLMSFDhwpWyW0m4iMVAxRZX6JZeQXGF8VAwIN2LRpY=; b=Yga2aNmRAta7wL ZmmK6SZpigZFqLP8Hu3fFmxLB3C+mqSTDE43tCHIDccCzHyFOUWl5qJCQ2lT7OtfN3IRy1I0/U3lT 7fImFYpY1j+cUWACJtZyaA8r8teJH3H+nIfJMtdM3hxmcvXQF81JdX38rJ5eRzux4qP1PloNu/gzO urDR2uh8Q2N5wH/HrVsLSQp3JMhys3gakrPdGUb68i8lkq1HyH+2vQoXWmFlXMoWBnRYsxnjq0g+z M7fynif2zk+4b13nJR9lHaHPNnWWm3cy5Fcn1nmdTDn20aDk1W2IBfeQFkSj9EaM9PJHvIW1zHHmj q2VNYYtgAqMeY7/r3amg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iNgfu-0000Kx-6N; Thu, 24 Oct 2019 17:13:26 +0000 Received: from hqemgate15.nvidia.com ([216.228.121.64]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iNgfp-0000KK-Ri for linux-arm-kernel@lists.infradead.org; Thu, 24 Oct 2019 17:13:23 +0000 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 24 Oct 2019 10:13:30 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 24 Oct 2019 10:13:21 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 24 Oct 2019 10:13:21 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 24 Oct 2019 17:13:20 +0000 Received: from [10.21.133.51] (172.20.13.39) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 24 Oct 2019 17:13:18 +0000 Subject: Re: [PATCH] spi: Fix SPI_CS_HIGH setting when using native and GPIO CS To: Gregory CLEMENT , Mark Brown , , References: <20191018152929.3287-1-gregory.clement@bootlin.com> <87zhhqp4wf.fsf@FE-laptop> From: Jon Hunter Message-ID: <4be58f82-eeb1-83a5-4c83-1e86f3b82769@nvidia.com> Date: Thu, 24 Oct 2019 18:13:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <87zhhqp4wf.fsf@FE-laptop> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1571937210; bh=IGHxywHeWHbvWN/dGZiODRU1Pgz0qNdz6PS2iL/zybc=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=MM/18hyCWxGXMxY6YT9ReV/7/ZgXYKVgBZMHvbH4pc2hpiV43cLaFtS00fWFPWRDL erOSBvWRwITrxAmnu2xrjxMScAx1CyoARtjFmjxmuecIcturc7XchVXhRhRHkK1EhZ RUa/+fsDshDTE0sfaPU98V/ztsOr5bWkKCNLPzlDx2xEQGuwFGCB4vYCaWyOgFVAze b2qg3RWIFVcZwaqmRVm02T8T6xHLsg6CP2Bvz7tZfhgr3LQRfn9Mq1vr652b1mczLM t3YFFCZdh8Yaz054QJzum2+fA47872r3mtNIn1caKFtR/05p0aoV4hRfHuuav11qYR 4tTyid1yiKBpQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191024_101321_916782_44A34F95 X-CRM114-Status: GOOD ( 18.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , stable@vger.kernel.org, Ludovic Desroches , Thomas Petazzoni , linux-tegra , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 24/10/2019 15:57, Gregory CLEMENT wrote: > Hello Jon, > >> On 18/10/2019 16:29, Gregory CLEMENT wrote: >>> When improving the CS GPIO support at core level, the SPI_CS_HIGH >>> has been enabled for all the CS lines used for a given SPI controller. >>> >>> However, the SPI framework allows to have on the same controller native >>> CS and GPIO CS. The native CS may not support the SPI_CS_HIGH, so they >>> should not be setup automatically. >>> >>> With this patch the setting is done only for the CS that will use a >>> GPIO as CS >>> >>> Fixes: f3186dd87669 ("spi: Optionally use GPIO descriptors for CS GPIOs") >>> Cc: >>> Signed-off-by: Gregory CLEMENT >>> --- >>> drivers/spi/spi.c | 18 +++++++++--------- >>> 1 file changed, 9 insertions(+), 9 deletions(-) >>> >>> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c >>> index 5414a10afd65..1b68acc28c8f 100644 >>> --- a/drivers/spi/spi.c >>> +++ b/drivers/spi/spi.c >>> @@ -1880,15 +1880,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, >>> spi->mode |= SPI_3WIRE; >>> if (of_property_read_bool(nc, "spi-lsb-first")) >>> spi->mode |= SPI_LSB_FIRST; >>> - >>> - /* >>> - * For descriptors associated with the device, polarity inversion is >>> - * handled in the gpiolib, so all chip selects are "active high" in >>> - * the logical sense, the gpiolib will invert the line if need be. >>> - */ >>> - if (ctlr->use_gpio_descriptors) >>> - spi->mode |= SPI_CS_HIGH; >>> - else if (of_property_read_bool(nc, "spi-cs-high")) >>> + if (of_property_read_bool(nc, "spi-cs-high")) >>> spi->mode |= SPI_CS_HIGH; >>> >>> /* Device DUAL/QUAD mode */ >>> @@ -1952,6 +1944,14 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, >>> } >>> spi->chip_select = value; >>> >>> + /* >>> + * For descriptors associated with the device, polarity inversion is >>> + * handled in the gpiolib, so all gpio chip selects are "active high" >>> + * in the logical sense, the gpiolib will invert the line if need be. >>> + */ >>> + if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods[spi->chip_select]) >>> + spi->mode |= SPI_CS_HIGH; >>> + >> >> This patch is causing a boot regression on one of our Tegra boards. >> Bisect is pointing to this commit and reverting on top of today's -next >> fixes the problem. >> >> This patch is causing the following NULL pointer crash which I assume is >> because we have not checked if 'ctlr->cs_gpiods' is valid before >> dereferencing ... > > I've just submitted a fixe for it > > https://patchwork.kernel.org/patch/11209839/ Great! Thanks, Jon -- nvpublic _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel