Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1478878img; Tue, 19 Mar 2019 08:29:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYo31/t9C42+twNxrCvh9KRAYzbqTZNWutb4K8AkjIHVaKGvt10lR/qczmVzLgmk1KWCEg X-Received: by 2002:a63:6cc1:: with SMTP id h184mr2398167pgc.151.1553009342452; Tue, 19 Mar 2019 08:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553009342; cv=none; d=google.com; s=arc-20160816; b=PWlZ7k/TnMjCnAedurUCR/zyCxC6Xlmx8qUG5XkvmZ8tKllJ6BEUwEsOP/fPmz47Fb JX9ILP1q5GSeq3H6O0atv2rT5n5ZnZ/MRwMWxS1cLaJ4W097BLeGyHs1pQbvoNbLIxYw +89UJ+Krwrgd79LZKVb0jVLhKLRZLimV85zmuUCxEer9gB6b1+l2XgorFDfS4M0N/ROt pFYdsw4q7KYT/UfDQzqq12zmC0a6hDDa3UMaZphvKYjaBR7OeKWgD/1e7uN4zGHKmTud SYrZkAhiucDSAHsYB/EpMHSf4+nioHicq4bwCeJ6WQP2UUSE+jlaxftqKD9RdA7Y8kN9 cYNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=HA53fIKM0xv/c+Hr1s/UvSSMbNOe/ha9LSCnQ3u7CvA=; b=dqk3bCdv1VeEM5pZYrOxzdZpNrOngVPAASE/JADd281+p9ijE5eJZPNpirxeCCqu+w SH/5VvMS8N+SpjACGD0UsnNjZNZPsKOvSd2gRrp2P/UatYV+scE9s2GyZ+OmSnAETsLo e/NKfPq49sWOWVVvQyMzeK6jXuFsGRsjh8y1dnTl1K/KjvnQ7kP8fRdemdpYuf6xHfLq U20u5MY0A8R35h+hjdglPPygM2fVI6PT0iaN2gyQsKj8oysuQSt3T+MZHD0RnYD5GF1L /VhhMA3WdX6TY2OzFIGkS5F85TWP2IbspvgpS6mOJJEDas56IFGjvm5uMP9CgcatR5Y8 NuLA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si11500696pgq.38.2019.03.19.08.28.46; Tue, 19 Mar 2019 08:29:02 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727688AbfCSP1s (ORCPT + 99 others); Tue, 19 Mar 2019 11:27:48 -0400 Received: from mga14.intel.com ([192.55.52.115]:54050 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbfCSP1r (ORCPT ); Tue, 19 Mar 2019 11:27:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 08:27:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,498,1544515200"; d="scan'208";a="143320633" Received: from mylly.fi.intel.com (HELO [10.237.72.176]) ([10.237.72.176]) by orsmga002.jf.intel.com with ESMTP; 19 Mar 2019 08:27:44 -0700 Subject: Re: [PATCH] [RFC] spi: pxa2xx: Do cs if restart the SSP during pxa2xx_spi_transfer_one() To: "Xiao, Jin" , Mark Brown Cc: daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, yanmin.zhang@intel.com, bo.he@intel.com References: <20190307072424.18820-1-jin.xiao@intel.com> <20190307160924.GE6529@sirena.org.uk> <11f165e9-ef53-edb9-cec2-e30ad2b440b5@intel.com> From: Jarkko Nikula Message-ID: <6013a37a-ee24-e371-773c-141a54926239@linux.intel.com> Date: Tue, 19 Mar 2019 17:27:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <11f165e9-ef53-edb9-cec2-e30ad2b440b5@intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jin On 3/8/19 9:28 AM, Xiao, Jin wrote: > > Yes, the spi core has de-asserted the CS before the > pxa2xx_spi_unprepare_transfer(). The problem on my side is that the new > transfer will restart the SSP in pxa2xx_spi_transfer_one(). The spi core > has asserted the CS again before restart the SSP.? In my test the CS > assert before the restart SSP can't ensure the spi transfer working > correctly. > I wanted to ask have you found any other fix or reason than the patches you have sent? I've been trying to debug why the commit d5898e19c0d7 ("spi: pxa2xx: Use core message processing loop") is causing the regression you are seeing. I've been testing this by sending two or more messages each consisting of two 4-byte transfers through the spidev. SPI mode 3 and clock is 1 MHz. I see only slight timing difference between a commit before and at d5898e19c0d7 when the chip select is active. 8ae55af38817: CS act to CLK running ~40 us. CLK idle to CS deact ~26 us d5898e19c0d7: CS act to CLK running ~34 us. CLK idle to CS deact ~18 us There is more difference/variability during the times when the CS is not active between messages. Which is understandable since there happens message passing from userspace, queing, etc. At 8ae55af38817 total time over 2 messages varies from ~600 us to 1200 ~us and at d5898e19c0d7 from ~500 us to 1100 us. Then at v4.19 it goes a bit slover and varies between ~700 to 1600 us. Most probably due some other change than in SPI subsystem as there is not commit either in SPI core or spi-pxa2xx explaining it. Or just some random config change in my kernel configuration between 4.17 and 4.19. What I don't understand why additional CS toggling makes it work for you in case SSP was stopped in pxa2xx_spi_unprepare_transfer() and restarted again in pxa2xx_spi_transfer_one(). This SSP stopping and restarting is not visible in the SPI signals since clock is already stopped when FIFO gets empty. I guess the reason why you are seeing pxa2xx_spi_unprepare_transfer() only called sometimes is that in those cases where it is not called a new SPI message got queued while processing the current one and in other cases queue became empty before new message was queued. In both cases there shouldn't be difference in CS handling. Which makes me scratching my head why additional CS toggling is fixing the issue in case there is SSP restart. And which was due more time elapsed between messages and queue went empty. -- Jarkko