Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4583820ybg; Mon, 8 Jun 2020 11:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDy8WTUglJmql+Sc/PpSEO8cHCcNhRU+Hch/ImHdW+L/XxUpWGuY6zQ3LAzdgiwJGFcak6 X-Received: by 2002:a17:906:abca:: with SMTP id kq10mr23058330ejb.390.1591640969187; Mon, 08 Jun 2020 11:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591640969; cv=none; d=google.com; s=arc-20160816; b=C+h8QpzQVJTZqXRzty2uw+yZ4OSi8McLd4zhzZ4etgHMN+mMkDOxM0HR3DRNvZX2nf 1aDgQB30P7saLqRY+VchVqwuhlUwUUiukE5RpXzYA8uV4cXTavgiFXb1NqWi6BjXMxbY pZ6cSCnAR27wLLJw5DsBouklebW1ZdeasxrgwL+EBO6mKU1sREilZVpjoM332XM/G9V1 yAx0nEhvGg27CnPP1uCBkxcZA0fj6ZNYcoAVAOD7ezY9ItkeByXs7KvhZSzb1xUn6WmQ uxq2n7/KfU7Wj3amBWEyKe8FCQNdXi3Mh0AbkJaII0Xo3AuCrjYs+st1oquIMrONyJHj uQIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=PHZr0I4+dXbZQ7MhUFs/ejCHNifnLZ1K9XiBRMyx5so=; b=bLyPP8uBhG5nm4oEqW/7n7pfxzJieRPO26AIJ0/1n8VeY0w61yWvaiQaNzvNnRCxOT APpEGPmZFUM4Ku7xXfuPr7AY+smhWeJD45ED/FLNgyHaoqe7W50vIteYwyphYu/L3UQ6 X0Ygu/5pOT1juCE92SYRTvDCaxODrtW/AgBJifiNot12gbZX3Dl6RsiClzcPOnhZK9up HmF+bSTcgVF1ZBdYlXoYA4rxwV0NVmXiCRg12zqOt4iQUGLdoLq/Ve1wyMTqm7DEJTut axJIscRa1T1C5M0qxd2uOINsgAFbCwqXGiGRYm4PyYilrfaDRgMHOeJ6khrhYKU1Fn0D chhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ub15ctup; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n93si5377881edc.552.2020.06.08.11.29.06; Mon, 08 Jun 2020 11:29:29 -0700 (PDT) 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=@kernel.org header.s=default header.b=Ub15ctup; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730285AbgFHPbn (ORCPT + 99 others); Mon, 8 Jun 2020 11:31:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:47392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729754AbgFHPbm (ORCPT ); Mon, 8 Jun 2020 11:31:42 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8750A206D5; Mon, 8 Jun 2020 15:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591630302; bh=ADxBilkyT/EAi/djnjiP2fgYAZUPsNr5v8UV+nTUi7I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ub15ctup9uAJsdoj9tT8dbeZGUxs/erhZLq8nR6hfpoyfT4EhYRftbZWT7cr4LqJl J70OfloxVttWEd00LXh/jwVPRQ2yd+X1T4mrwoovTkLEqim2OEGZkr+gYFxuCeaAfJ 9MVEQvm29WsRmviuekA1KS1TVvMo4eQbqY4RPi2s= Date: Mon, 8 Jun 2020 16:31:39 +0100 From: Mark Brown To: Robin Gong Cc: "mark.rutland@arm.com" , "robh+dt@kernel.org" , "catalin.marinas@arm.com" , "vkoul@kernel.org" , "will.deacon@arm.com" , "shawnguo@kernel.org" , "festevam@gmail.com" , "s.hauer@pengutronix.de" , "martin.fuzzey@flowbird.group" , "u.kleine-koenig@pengutronix.de" , "dan.j.williams@intel.com" , "matthias.schiffer@ew.tq-group.com" , "linux-spi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kernel@pengutronix.de" , dl-linux-imx , "dmaengine@vger.kernel.org" Subject: Re: [PATCH v9 RESEND 01/13] spi: imx: add dma_sync_sg_for_device after fallback from dma Message-ID: <20200608153139.GI4593@sirena.org.uk> References: <1591485677-20533-1-git-send-email-yibin.gong@nxp.com> <1591485677-20533-2-git-send-email-yibin.gong@nxp.com> <20200608143458.GH4593@sirena.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fckbADODYWZD5TdN" Content-Disposition: inline In-Reply-To: X-Cookie: I'm rated PG-34!! User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --fckbADODYWZD5TdN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 08, 2020 at 03:08:45PM +0000, Robin Gong wrote: > > > + if (transfer->rx_sg.sgl) { > > > + struct device *rx_dev = spi->controller->dma_rx->device->dev; > > > + > > > + dma_sync_sg_for_device(rx_dev, transfer->rx_sg.sgl, > > > + transfer->rx_sg.nents, DMA_TO_DEVICE); > > > + } > > > + > > This is confusing - why are we DMA mapping to the device after doing a PIO > > transfer? > 'transfer->rx_sg.sgl' condition check that's the case fallback PIO after DMA transfer > failed. But the spi core still think the buffer should be in 'device' while spi driver > touch it by PIO(CPU), so sync it back to device to ensure all received data flush to DDR. So we sync it back to the device so that we can then do another sync to CPU? TBH I'm a bit surprised that there's a requirement that we explicitly undo a sync and that a redundant double sync in the same direction might be an issue but I've not had a need to care so I'm perfectly prepared to believe there is. At the very least this needs a comment. --fckbADODYWZD5TdN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl7eWdsACgkQJNaLcl1U h9BiKAf/ZmeX9XdQOaPXdXtYXNZ3mBV/poS2CX7LkZVc4oBchvlrK/obnL/5JWU+ 2AVuevWzu2fig/gK6UfPOZUU24ZPvfwwo8obnuU7iUFZ7ynpsDOP+v8nLyc6ROe9 WDdp8hQ7ZXTixJ7p+ww5o30bSWOq2dCuguKM83CSvcB60QxRTPW3s7dClj0wRRLW /YqjHpYK85okEJ7wQk4K+XmgiNOtfGGPImPE6iM7+hVzZORE6j78xFXDRq4XX5TQ WCbjot+/Pb3lOPrlQQ6THR244JuyC9yx5DVeHV0h5tUWA2LWABEBhTE82aYEy1HM RSe4uOS1dRQO+DhKwWD7O75Y0oxYow== =kfaK -----END PGP SIGNATURE----- --fckbADODYWZD5TdN--