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=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 7F6C8C433DF for ; Thu, 11 Jun 2020 13:40:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54EF620801 for ; Thu, 11 Jun 2020 13:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591882849; bh=cvz/YxFSgXtIw2nOa4VErS/4b3tA507ZBN5/rPyfuu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=QMUftzyxV1z2tpQCqmKSzDNoXVwMEE0zPidYb/vpZphJcwIGSrg2nqXNFCboFc8ZE /axOswGOd0keU8F+87qS0PtGgLMGhcHa3O23UIvco5vjesz/6fon17tIFupUkKDZHr CcASghw7J0rrV2JrxUR/C6X89I3/JPifXF1SWtY8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728059AbgFKNkr (ORCPT ); Thu, 11 Jun 2020 09:40:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbgFKNkp (ORCPT ); Thu, 11 Jun 2020 09:40:45 -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 29B8420760; Thu, 11 Jun 2020 13:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591882844; bh=cvz/YxFSgXtIw2nOa4VErS/4b3tA507ZBN5/rPyfuu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tPXBu1yFAiTRygRf37l3z9KXCEWhdc+r8uUQpZeIFKHSyzX1Mkh762yKf4crAhReV zJrxSPi4Anm1TS+12b60syNQX7ROOtQrR3YNsGEJWPIsUHVt9cRHKxFimUYl/txXap KN+qKdAE2Il8rMK0JhTKm44arnXXf1thA+ajbEfg= Date: Thu, 11 Jun 2020 14:40:42 +0100 From: Mark Brown To: Robin Gong Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, robin.murphy@arm.com, matthias.schiffer@ew.tq-group.com, kernel@pengutronix.de, linux-imx@nxp.com, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 RFC 1/2] spi: introduce fallback to pio Message-ID: <20200611134042.GG4671@sirena.org.uk> References: <1591880310-1813-1-git-send-email-yibin.gong@nxp.com> <1591880310-1813-2-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="iAL9S67WQOXgEPD9" Content-Disposition: inline In-Reply-To: <1591880310-1813-2-git-send-email-yibin.gong@nxp.com> X-Cookie: I like your SNOOPY POSTER!! 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 --iAL9S67WQOXgEPD9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 11, 2020 at 08:58:29PM +0800, Robin Gong wrote: > Add SPI_CONTROLLER_FALLBACK to fallback to pio mode in case dma transfer > failed. > If spi client driver want to enable this feature please set master->flags > with SPI_MASTER_FALLBACK and add master->fallback checking in its can_dma() > as spi-imx.c If we were going to do this I don't see why we'd have a flag for this rather than just doing it unconditionally but... > ret = ctlr->transfer_one(ctlr, msg->spi, xfer); > if (ret < 0) { > + if (ctlr->cur_msg_mapped && > + (ctlr->flags & SPI_CONTROLLER_FALLBACK)) { > + __spi_unmap_msg(ctlr, msg); > + ctlr->fallback = true; > + goto fallback_pio; > + } ...I don't think this can work sensibly - this is going to try PIO if there's *any* error. We might have had some sort of issue during the transfer for example so have some noise on the bus. Like I said on a prior version of this I really think that we need to be figuring out if the DMA controller can support the transaction before we even map the buffer for it, having the controller just randomly fail underneath the consumer just does not sound robust. --iAL9S67WQOXgEPD9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl7iNFkACgkQJNaLcl1U h9Bf+AgAgmNtDbsABzuC2/FdzMOgrJBX+Sol1QlxGnFXxy0CasIDkgkgZFWfFd+f 55Ee2ZOKSfoZIb3+4SPDck6koXnMJVsaBU4NFjuqzc/l3uvgXM7pKdjpnWlcRZaj 9XPGvNv4VqLiGv+HTqbHSRdOuDAN1GZH9SSwJd15fjeZE9xA4bmzN2cT1DcxDJPl fMscBXBBrMIIq9Dqw1lDJuta8vKoaB3y2o1ee4nihNa8OBDL/FdVzgzl7aAiVGS3 I38G2AZRgnZBWf2z+haWsFKMbumjUKmMB2vCjf5U4gI5N3O6iFDMFdEzkHQdTSQS yU4UU7726S05d44UW6lXJgFBMoB0UQ== =Y2mu -----END PGP SIGNATURE----- --iAL9S67WQOXgEPD9-- 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=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no 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 E1F62C433DF for ; Thu, 11 Jun 2020 13:42:15 +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 6B0DA20760 for ; Thu, 11 Jun 2020 13:42:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JnPqMTyE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="tPXBu1yF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B0DA20760 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0XumgQPB19QRoEchA6TwXoS/E9+ZOWydUL7zGqPWLtQ=; b=JnPqMTyEbKTuno6atJFKsOJVa Qh/pIRpAgTyef6R2+OOeNXZwOGkgYL2yM+Id0PaeMZOGXXvg8dz/j4XBTdUDNIo+Tpu7rxkcAu19y e2Gwd26I0iyiWIPfnwPQNA+k/XfHVnsox96W9SM4oIREYn6GVjJxqVBii4w7LSTJLyQD0bCW61uhL 1vlrJI29cL+6us0KZQD4NcoE8DLZkLhI0Sdwbn4XAQNDqJe3BbJPF30w7T87QXwZ0lCbf+bl7BOJD RZWb4czLgLOZZZ8dg5sYpjj2+LT7+dZ4ZJuFPYiF1IwvPaqs8y3J5x+ynke5kmDAb2SgYS5Rf322G alviY/s2A==; 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 1jjNTA-0007gA-WC; Thu, 11 Jun 2020 13:42:13 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jjNRm-0006W8-6v for linux-arm-kernel@lists.infradead.org; Thu, 11 Jun 2020 13:40:48 +0000 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 29B8420760; Thu, 11 Jun 2020 13:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591882844; bh=cvz/YxFSgXtIw2nOa4VErS/4b3tA507ZBN5/rPyfuu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tPXBu1yFAiTRygRf37l3z9KXCEWhdc+r8uUQpZeIFKHSyzX1Mkh762yKf4crAhReV zJrxSPi4Anm1TS+12b60syNQX7ROOtQrR3YNsGEJWPIsUHVt9cRHKxFimUYl/txXap KN+qKdAE2Il8rMK0JhTKm44arnXXf1thA+ajbEfg= Date: Thu, 11 Jun 2020 14:40:42 +0100 From: Mark Brown To: Robin Gong Subject: Re: [PATCH v1 RFC 1/2] spi: introduce fallback to pio Message-ID: <20200611134042.GG4671@sirena.org.uk> References: <1591880310-1813-1-git-send-email-yibin.gong@nxp.com> <1591880310-1813-2-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 In-Reply-To: <1591880310-1813-2-git-send-email-yibin.gong@nxp.com> X-Cookie: I like your SNOOPY POSTER!! User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200611_064046_382624_28DC7EEE X-CRM114-Status: GOOD ( 13.05 ) 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: matthias.schiffer@ew.tq-group.com, shawnguo@kernel.org, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, robin.murphy@arm.com, linux-spi@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============3890953381172460968==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============3890953381172460968== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="iAL9S67WQOXgEPD9" Content-Disposition: inline --iAL9S67WQOXgEPD9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 11, 2020 at 08:58:29PM +0800, Robin Gong wrote: > Add SPI_CONTROLLER_FALLBACK to fallback to pio mode in case dma transfer > failed. > If spi client driver want to enable this feature please set master->flags > with SPI_MASTER_FALLBACK and add master->fallback checking in its can_dma() > as spi-imx.c If we were going to do this I don't see why we'd have a flag for this rather than just doing it unconditionally but... > ret = ctlr->transfer_one(ctlr, msg->spi, xfer); > if (ret < 0) { > + if (ctlr->cur_msg_mapped && > + (ctlr->flags & SPI_CONTROLLER_FALLBACK)) { > + __spi_unmap_msg(ctlr, msg); > + ctlr->fallback = true; > + goto fallback_pio; > + } ...I don't think this can work sensibly - this is going to try PIO if there's *any* error. We might have had some sort of issue during the transfer for example so have some noise on the bus. Like I said on a prior version of this I really think that we need to be figuring out if the DMA controller can support the transaction before we even map the buffer for it, having the controller just randomly fail underneath the consumer just does not sound robust. --iAL9S67WQOXgEPD9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl7iNFkACgkQJNaLcl1U h9Bf+AgAgmNtDbsABzuC2/FdzMOgrJBX+Sol1QlxGnFXxy0CasIDkgkgZFWfFd+f 55Ee2ZOKSfoZIb3+4SPDck6koXnMJVsaBU4NFjuqzc/l3uvgXM7pKdjpnWlcRZaj 9XPGvNv4VqLiGv+HTqbHSRdOuDAN1GZH9SSwJd15fjeZE9xA4bmzN2cT1DcxDJPl fMscBXBBrMIIq9Dqw1lDJuta8vKoaB3y2o1ee4nihNa8OBDL/FdVzgzl7aAiVGS3 I38G2AZRgnZBWf2z+haWsFKMbumjUKmMB2vCjf5U4gI5N3O6iFDMFdEzkHQdTSQS yU4UU7726S05d44UW6lXJgFBMoB0UQ== =Y2mu -----END PGP SIGNATURE----- --iAL9S67WQOXgEPD9-- --===============3890953381172460968== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============3890953381172460968==--