From patchwork Mon Mar 4 23:02:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10838777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C76001399 for ; Mon, 4 Mar 2019 23:02:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFE902B79C for ; Mon, 4 Mar 2019 23:02:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E3612B78D; Mon, 4 Mar 2019 23:02:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80A1F2B78D for ; Mon, 4 Mar 2019 23:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726069AbfCDXCl (ORCPT ); Mon, 4 Mar 2019 18:02:41 -0500 Received: from mail-eopbgr720127.outbound.protection.outlook.com ([40.107.72.127]:40640 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726087AbfCDXCk (ORCPT ); Mon, 4 Mar 2019 18:02:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K7aefMXdno+Zzu4ir3v0iZc3XleX/Z6WPXqvsg2pVxc=; b=Z/yjzyBX/R4ZCta3WjrRCLyiP3DltoGT0nbGDZ7O8xkfOg90ebYnVIKhrO7kybLX6LrIQGdvYjS1E94eQXlsqtOIM+JO/yOTYA2HR6sspnJ9ag2xo42wFPhR7OT6v8ISLJ9C5o9Q61Ab5MrkERsYiZmwEyTRaDA+RJnk9CDQKU8= Received: from MWHPR0601MB3708.namprd06.prod.outlook.com (10.167.236.38) by MWHPR0601MB3721.namprd06.prod.outlook.com (10.167.236.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.18; Mon, 4 Mar 2019 23:02:37 +0000 Received: from MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::91d4:ba4b:1424:9452]) by MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::91d4:ba4b:1424:9452%2]) with mapi id 15.20.1665.019; Mon, 4 Mar 2019 23:02:36 +0000 From: Trent Piepho To: "linux-spi@vger.kernel.org" CC: Mark Brown , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Stefan Agner , Trent Piepho Subject: [PATCH] spi: imx: add module parameter to control DMA use Thread-Topic: [PATCH] spi: imx: add module parameter to control DMA use Thread-Index: AQHU0t5bgrZXcUweUUiMXvgf3qsihw== Date: Mon, 4 Mar 2019 23:02:36 +0000 Message-ID: <20190304230220.22374-1-tpiepho@impinj.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR11CA0070.namprd11.prod.outlook.com (2603:10b6:a03:80::47) To MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) authentication-results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.14.5 x-originating-ip: [216.207.205.253] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: aac08b29-9b2c-4806-d6e8-08d6a0f57e12 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:MWHPR0601MB3721; x-ms-traffictypediagnostic: MWHPR0601MB3721: x-microsoft-exchange-diagnostics: 1;MWHPR0601MB3721;20:BYFbJTa/8RrOFHTsZuK+eslxZvEMCNkrUR5OpCVn1beOzhcv+9wa4qBocpBHCZbBkM7mTOu01ZYnDyhqve/VoQTexg+ZtQMXX8gOxL8Pbd5UZDrexyq3ZNQbISBEuVenadcqvnkZINB+b9CwCCEZcJRsLYXCqEp6s3BmHpnmYmc= x-microsoft-antispam-prvs: x-forefront-prvs: 09669DB681 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(346002)(376002)(396003)(39850400004)(366004)(189003)(199004)(26005)(81156014)(102836004)(8676002)(81166006)(3846002)(6116002)(68736007)(97736004)(8936002)(256004)(14444005)(6436002)(6916009)(50226002)(5640700003)(2616005)(2351001)(186003)(1076003)(105586002)(106356001)(476003)(107886003)(486006)(6512007)(305945005)(25786009)(54906003)(478600001)(66066001)(7736002)(14454004)(86362001)(99286004)(2906002)(2501003)(6486002)(71190400001)(53936002)(71200400001)(36756003)(4326008)(6506007)(5660300002)(52116002)(316002)(386003);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR0601MB3721;H:MWHPR0601MB3708.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: HvXNJBWvocYUrcA0flq9a6db5Cmxnkp1+c97DUj1L+DdqL1BS6g5FxV6wM7ttbenDwHvl6/NcbARBILnk7UV8DG2LtWMfju10ij0bjg9EF8SMFcbYpC2CwKHXuITx324isAgDZAw/L43sZTjsII20Bdhk9cJ7wFTbUo0KfYg/gZ7v8RtnqxiEEfpRotleSIfsQebh8ccq5BQkZnrbPAZnaz6+gUCEHZwL9h2CrVsGG4TNZEH0XJTRhdbYav7p7SseqSuPRQmZDd7qG6sbehHXOJpnJHrE9XSai7MKdj/Q14l+UMSqAqUKrtHCtsWStuimrQWkp5X5KiRT0RcOiFB7YydYERjcXh3TXrSgFc634x+khgE7y7z82wm8m5Mav/o+Yez1IO0anIzjaHczLZry3XNhwh8SewoWuSk0WOfcDs= MIME-Version: 1.0 X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-Network-Message-Id: aac08b29-9b2c-4806-d6e8-08d6a0f57e12 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Mar 2019 23:02:36.8104 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3721 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the boolean module parameter "use_dma" to control the use of DMA by the driver. There are about two dozen other drivers with a "use_dma" parameter of some sort. DMA may allow faster and more efficient transfers than using PIO, but it also adds overhead for small transfers. High speed receive operations may be less likely to have issues with FIFO overflow when using DMA than when using PIO. The eCSPI appears to insert a 4 bit pause after each word in DMA mode, not done in PIO mode, which can make DMA transfers 50% slower than PIO. In some cases DMA may be a net win while in others PIO might be. It depends on the application. So allow DMA to be enabled or disabled at the driver level. The default will be to have it enabled when possible. Signed-off-by: Trent Piepho --- drivers/spi/spi-imx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index a81ae29aa68a..09c9a1edb2c6 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -28,6 +28,10 @@ #define DRIVER_NAME "spi_imx" +static bool use_dma = true; +module_param(use_dma, bool, 0644); +MODULE_PARM_DESC(use_dma, "Enable usage of DMA when available (default)"); + #define MXC_CSPIRXDATA 0x00 #define MXC_CSPITXDATA 0x04 #define MXC_CSPICTRL 0x08 @@ -219,6 +223,9 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi, { struct spi_imx_data *spi_imx = spi_master_get_devdata(master); + if (!use_dma) + return false; + if (!master->dma_rx) return false;