From patchwork Thu Mar 19 05:05:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Knight X-Patchwork-Id: 6046371 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1DB829FB96 for ; Thu, 19 Mar 2015 05:05:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F5732049E for ; Thu, 19 Mar 2015 05:05:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00DDB204B0 for ; Thu, 19 Mar 2015 05:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751004AbbCSFFF (ORCPT ); Thu, 19 Mar 2015 01:05:05 -0400 Received: from mail-qg0-f41.google.com ([209.85.192.41]:33123 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbbCSFFD (ORCPT ); Thu, 19 Mar 2015 01:05:03 -0400 Received: by qgfa8 with SMTP id a8so56676414qgf.0; Wed, 18 Mar 2015 22:05:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=message-id:subject:from:to:cc:date:content-type:mime-version; bh=69WsmKGKCBg8/OBQvThCAg83j8tzP6ldaCdbMd6HXVQ=; b=Jf6yeCd+Nr5dyNziufXex2bNsJgEDaL3my/g0s1JnT4N2icAhYZtye0ImUnN7RgEai ivXXg6l2mebpMALUcZszAHKhnePLDD4kKLP3yhRvJfmx7KjTh4lqZgKprcWley6B8hUg vyeP/G1CEo4qXajp0NxXR+OCe+YWap/bZXpSt2ESbckQXObeftVeNjLyk1CNWkr7wons DF90pKYL6Qrl3V3RrhejUjHDtVrUXnsCqs1SSwVN0cLSnd2dymjXmxTEGLDqEp2GQZcW GVKhuxsA3ZkZ7BzW6oD2UnCvo88W5IadAWQXErySvDIAAJ6XOkB8HHHjLb8BGU8+pom2 Ngww== X-Received: by 10.55.20.5 with SMTP id e5mr67814881qkh.43.1426741502757; Wed, 18 Mar 2015 22:05:02 -0700 (PDT) Received: from [192.168.1.116] (c-98-229-126-42.hsd1.ma.comcast.net. [98.229.126.42]) by mx.google.com with ESMTPSA id o17sm166509qko.49.2015.03.18.22.05.01 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 22:05:01 -0700 (PDT) Message-ID: <1426741501.10003.6.camel@midgaarde> Subject: Patch to parameterize DMA_MIN_BYTES for omap2-mcspi From: Greg Knight To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-omap@vger.kernel.org Date: Thu, 19 Mar 2015 01:05:01 -0400 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, Mark, I've attached a patch which adds a device-tree field "ti,dma-min-bytes" which replaces the macro DMA_MIN_BYTES. Adjusting this field addresses issues we've had where, in our particular use case, the usleep() in the SPI worker thread eats a full 20% of our CPU (AM3359). I opted to implement it as a device-tree parameter and keep the original value (160) as the default, in order to avoid impacting anyone else. The patch is attached. Patches 1-2 are an unrelated McASP change (see my other message). What is the process for getting this upstreamed? Thanks, Greg From 2b51699d1f7f05de45f0f0f065c37da81181f4eb Mon Sep 17 00:00:00 2001 From: Greg Knight Date: Mon, 2 Mar 2015 10:44:21 -0500 Subject: [PATCH 3/3] spi-omap2-mcspi: DMA_MIN_BYTES hashdef => ti,dma-min-bytes device tree option --- drivers/spi/spi-omap2-mcspi.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 70cd418..4ac1f3e 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -117,8 +117,7 @@ struct omap2_mcspi_dma { /* use PIO for small transfers, avoiding DMA setup/teardown overhead and * cache operations; better heuristics consider wordsize and bitrate. */ -#define DMA_MIN_BYTES 160 - +#define DMA_MIN_BYTES_DEFAULT 160 /* * Used for context save and restore, structure members to be updated whenever @@ -141,6 +140,9 @@ struct omap2_mcspi { struct omap2_mcspi_regs ctx; int fifo_depth; unsigned int pin_dir:1; + + /* SPI transfer threshold over which we prefer DMA to PIO */ + unsigned dma_min_bytes; }; struct omap2_mcspi_cs { @@ -1115,7 +1117,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) unsigned count; if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) && - (m->is_dma_mapped || t->len >= DMA_MIN_BYTES)) + (m->is_dma_mapped || t->len >= mcspi->dma_min_bytes)) omap2_mcspi_set_fifo(spi, t, 1); omap2_mcspi_set_enable(spi, 1); @@ -1126,7 +1128,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) + OMAP2_MCSPI_TX0); if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) && - (m->is_dma_mapped || t->len >= DMA_MIN_BYTES)) + (m->is_dma_mapped || t->len >= mcspi->dma_min_bytes)) count = omap2_mcspi_txrx_dma(spi, t); else count = omap2_mcspi_txrx_pio(spi, t); @@ -1216,7 +1218,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, return -EINVAL; } - if (m->is_dma_mapped || len < DMA_MIN_BYTES) + if (m->is_dma_mapped || len < mcspi->dma_min_bytes) continue; if (mcspi_dma->dma_tx && tx_buf != NULL) { @@ -1331,10 +1333,12 @@ static int omap2_mcspi_probe(struct platform_device *pdev) mcspi = spi_master_get_devdata(master); mcspi->master = master; + mcspi->dma_min_bytes = DMA_MIN_BYTES_DEFAULT; match = of_match_device(omap_mcspi_of_match, &pdev->dev); if (match) { u32 num_cs = 1; /* default number of chipselect */ + u32 dma_min_bytes; pdata = match->data; of_property_read_u32(node, "ti,spi-num-cs", &num_cs); @@ -1342,6 +1346,8 @@ static int omap2_mcspi_probe(struct platform_device *pdev) master->bus_num = bus_num++; if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL)) mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; + if (!of_property_read_u32(node, "ti,dma-min-bytes", &dma_min_bytes)) + mcspi->dma_min_bytes = (unsigned) dma_min_bytes; } else { pdata = dev_get_platdata(&pdev->dev); master->num_chipselect = pdata->num_cs; -- 1.9.1