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=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS 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 0CB18C4360F for ; Thu, 7 Mar 2019 15:29:09 +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 CCE2B20643 for ; Thu, 7 Mar 2019 15:29:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HObfLgDE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCE2B20643 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.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-Type: Content-Transfer-Encoding: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=hXQuJuEGyCejao64GD3HlsfC2p8N2LZZVE1ckHe7gMA=; b=HObfLgDEMfJNPwXcB3Cz++0S8 mer3fw09PjzU1ZeS2sVEzhBd08ibWzN8hnYygBMcnDZH5Ybov5G4Wy69yqbTS+m/eYE4K0uFGHSk2 GwfOq6T70pg7VL9ZK4PxKu0uS+6udJeHE7Q2hBHoAj2Jl6YxaH3hYw7KQEW/hyJdEwCBNtWge6718 QnBl5NonQTljpZiqNUPyEZdU5n05afY+PNlr3nO0h19D0k64wuY3bTWZdRSABKkIHcXt1EQ4tvdM5 KnadrRs68fJFLk4boDSiolZbKtLURGDXreM/5UgXhblUnBSAcfdVXIde7QKo514FVZfVWzNdxqpLk NBiI3cFsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1uxB-0003NL-Qh; Thu, 07 Mar 2019 15:29:01 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1ux8-000335-5h for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2019 15:28:59 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2019 07:26:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,451,1544515200"; d="scan'208";a="121835106" Received: from mylly.fi.intel.com (HELO [10.237.72.61]) ([10.237.72.61]) by orsmga006.jf.intel.com with ESMTP; 07 Mar 2019 07:26:54 -0800 Subject: Re: [PATCH] [RFC] spi: pxa2xx: Do cs if restart the SSP during pxa2xx_spi_transfer_one() To: xiao jin , daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, yanmin.zhang@intel.com References: <20190307072424.18820-1-jin.xiao@intel.com> From: Jarkko Nikula Message-ID: Date: Thu, 7 Mar 2019 17:26:53 +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: <20190307072424.18820-1-jin.xiao@intel.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190307_072858_228620_C844FA61 X-CRM114-Status: GOOD ( 25.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bo Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Is this also related to the regression with d5898e19c0d7 ("spi: pxa2xx: Use core message processing loop") you have found or another issue? Comments below. On 3/7/19 9:24 AM, xiao jin wrote: > The spi-pxa2xx can't read and write data correctly on our board. > The pxa_ssp_type is LPSS_BXT_SSP in our case. > > With more debug we find that it's related to restart the SPP > during pxa2xx_spi_transfer_one(). > > In the normal case the spi_transfer_one_message() calls spi-pxa2xx > cs_assert before transferring one message. After completing the > transfer it calls spi-pxa2xx cs_deassert. The spi-pxa2xx works > well. > > But in some other case pxa2xx_spi_unprepare_transfer() is called > that clears SSCR0_SSE bit before the next transfer. In the next > transfer the spi-pxa2xx driver will restart the SSP as the SSE > bit is cleared. The cs_assert before the SSP restart can't ensure > spi-pxa2xx work well. > > The patch is to do cs again if spi-pxa2xx restar the SSP during > pxa2xx_spi_transfer_one() > Hmm.. please correct me if I'm wrong but pxa2xx_spi_unprepare_transfer() is called always when there is no more messages pending and the spi core should have deasserted the CS already? More below. > Signed-off-by: xiao jin > Signed-off-by: he, bo > --- > drivers/spi/spi-pxa2xx.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c > index 14f4ea59caff..1a2ea46858d9 100644 > --- a/drivers/spi/spi-pxa2xx.c > +++ b/drivers/spi/spi-pxa2xx.c > @@ -928,6 +928,7 @@ static int pxa2xx_spi_transfer_one(struct spi_controller *master, > u32 cr1; > int err; > int dma_mapped; > + bool need_cs_change = false; > > /* Check if we can DMA this transfer */ > if (transfer->len > MAX_DMA_LEN && chip->enable_dma) { > @@ -1056,6 +1057,11 @@ static int pxa2xx_spi_transfer_one(struct spi_controller *master, > if ((pxa2xx_spi_read(drv_data, SSCR0) != cr0) > || (pxa2xx_spi_read(drv_data, SSCR1) & change_mask) > != (cr1 & change_mask)) { > + /* It needs to deassert the chip selection > + * firstly before restart the SPP */ > + need_cs_change = true; > + cs_deassert(spi); > + I think code comes here at the beginning of each transfer so will be hit multiple times before pxa2xx_spi_unprepare_transfer() if SPI message consists of multiple transfers. This makes me wondering if the device driver setting up the "struct spi_transfer" is maybe missing the cs_change flag set for transfers before last one in case HW needs CS toggling between transfers? For instance what following drivers are doing with the cs_change flag: drivers/char/tpm/tpm_tis_spi.c: tpm_tis_spi_transfer() drivers/input/touchscreen/ad7877.c: ad7877_read(), ad7877_read_adc() -- Jarkko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel