Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4588021imm; Sun, 22 Jul 2018 00:47:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeGRMlncFY0JoNZsOly/a2VvsqIXd79XUkRhwVNNR4aLgWimZiXoQ17nE6zRh152fCe6NDk X-Received: by 2002:a63:a70f:: with SMTP id d15-v6mr7883183pgf.168.1532245658997; Sun, 22 Jul 2018 00:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532245658; cv=none; d=google.com; s=arc-20160816; b=z5NuFAom9gxQx0T6M/Z6kOWfToZJPOc9nf00cJ9Tjx769vagOuP05mJ0sVATgnA2mO zfzYignXOAvV7MreKTX1LGIMSkJzIReU14FcTzpTOTKGp7gYyuFz8obigc2yDS03C1QS 6nVVCyfWpgUUJ8+caECswA7XCMgvT1tucWDoL7Yh7M40J8W54AmjF6Hyjon627skgRP3 l1w3oEcxPbFMGdcr0zJC2ZGWpKA0k7+v+eeKxxMFv8eEJO6n52Yg/u0xDURmmcYCzHsY x5bxWV1lG73bnsT9zv6snjQ97hRqy2dX2KvjmxZBCl5QwaP3C5Wpms+Kjp2hvDU/tmBz jq6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=rHECGzB163+bosSnbXMfZHAivwJlSh09GfMZNktoiN8=; b=hbMd46wQG9kWnngfSBRT9w8DiR/p8dZW5xNPcCSfydBmHH8k30ZWGzux2eFTIxndgV MC9mxeZg1a69R3tNrQuBApFbN4jvPolH4h0+UFNQJ7tnLK0J51+WKi/d2ziIGSHaUDD0 nsP6Lixmy2S8wEcIdR8MErAEuzMeonY7CnubvYyXWCOlbCr6PG02wEnaZjYzwf1qfct6 MBV7dWreurh1EmM5VA8q1ZDn4pWOQ5JYra9pro4ZfpKxf09wX4UXuz9bmR6+LUnDjGqs 6tn3rc1mUiPYVRjnpr/6qIbkaqYQaslG99GpX5+4tNWkYz+bX0YqErWYUX5ZdBLFEAgC qrkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lbb+xs+6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si5492798plz.479.2018.07.22.00.47.24; Sun, 22 Jul 2018 00:47:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lbb+xs+6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728019AbeGVImU (ORCPT + 99 others); Sun, 22 Jul 2018 04:42:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:43078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727962AbeGVImU (ORCPT ); Sun, 22 Jul 2018 04:42:20 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 4BFE220874; Sun, 22 Jul 2018 07:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532245593; bh=rzuSjcKhoRvujVQq527iGvuu5ykjvTgQM1L8sRz1ouQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Lbb+xs+6sVlo9iFJkmQbY2J4HQOgFeojVzja5hzuvKneKdJQm57kHgBgFHC7yPtxh eBXK5PSeR59H9lAxBCR0KIH6mDz4BjmX215STtVmB4UvKJdRqeoYvwMCjWMoxwFAru 7M8beFdly+t6vT2cAtQnbR1ZGuUjryaLmicpPt4U= Date: Sun, 22 Jul 2018 08:46:29 +0100 From: Jonathan Cameron To: David Lechner Cc: linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] iio: adc: ti-ads7950: allow simultaneous use of buffer and direct mode Message-ID: <20180722084629.3ca9218a@archlinux> In-Reply-To: <20180721193734.6427-3-david@lechnology.com> References: <20180721193734.6427-1-david@lechnology.com> <20180721193734.6427-3-david@lechnology.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 21 Jul 2018 14:37:34 -0500 David Lechner wrote: > This modifies the TI ADS7950 A/DC driver to allow the simultaneous use > of both the triggered buffer and reading channels directly (via in- > kernel API or sysfs). > > The use case for this is on LEGO MINDSTORMS EV3. Two of the voltage > channels are used in-kernel by a power supply driver, which reads the > values using iio_read_channel_processed(). These channels are only read > at a slow rate (<= 1Hz). However, we want to be able to read 12 other > channels at the same time using the triggered buffer at a high rate (>= > 100Hz). > > Signed-off-by: David Lechner One slight quirk I'd missed before. The two new buffers are used for dma and as such need to be in a cacheline separate from anything else that might be corrupted. I've just move them down to below the existing buffers which should accomplish this. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/adc/ti-ads7950.c | 32 ++++++++++++++++++-------------- > 1 file changed, 18 insertions(+), 14 deletions(-) > > diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c > index f08c4de2bd10..eae987bef994 100644 > --- a/drivers/iio/adc/ti-ads7950.c > +++ b/drivers/iio/adc/ti-ads7950.c > @@ -60,6 +60,8 @@ struct ti_ads7950_state { > unsigned int vref_mv; > > unsigned int settings; > + __be16 single_tx; > + __be16 single_rx; > > /* > * DMA (thus cache coherency maintenance) requires the > @@ -287,18 +289,26 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p) > return IRQ_HANDLED; > } > > -static int ti_ads7950_scan_direct(struct ti_ads7950_state *st, unsigned int ch) > +static int ti_ads7950_scan_direct(struct iio_dev *indio_dev, unsigned int ch) > { > + struct ti_ads7950_state *st = iio_priv(indio_dev); > int ret, cmd; > > + mutex_lock(&indio_dev->mlock); > + > cmd = TI_ADS7950_CR_WRITE | TI_ADS7950_CR_CHAN(ch) | st->settings; > - st->tx_buf[0] = cpu_to_be16(cmd); > + st->single_tx = cpu_to_be16(cmd); > > ret = spi_sync(st->spi, &st->scan_single_msg); > if (ret) > - return ret; > + goto out; > + > + ret = be16_to_cpu(st->single_rx); > + > +out: > + mutex_unlock(&indio_dev->mlock); > > - return be16_to_cpu(st->rx_buf[0]); > + return ret; > } > > static int ti_ads7950_get_range(struct ti_ads7950_state *st) > @@ -330,13 +340,7 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev, > > switch (m) { > case IIO_CHAN_INFO_RAW: > - > - ret = iio_device_claim_direct_mode(indio_dev); > - if (ret < 0) > - return ret; > - > - ret = ti_ads7950_scan_direct(st, chan->address); > - iio_device_release_direct_mode(indio_dev); > + ret = ti_ads7950_scan_direct(indio_dev, chan->address); > if (ret < 0) > return ret; > > @@ -402,13 +406,13 @@ static int ti_ads7950_probe(struct spi_device *spi) > * was read at the end of the first transfer. > */ > > - st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; > + st->scan_single_xfer[0].tx_buf = &st->single_tx; > st->scan_single_xfer[0].len = 2; > st->scan_single_xfer[0].cs_change = 1; > - st->scan_single_xfer[1].tx_buf = &st->tx_buf[0]; > + st->scan_single_xfer[1].tx_buf = &st->single_tx; > st->scan_single_xfer[1].len = 2; > st->scan_single_xfer[1].cs_change = 1; > - st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; > + st->scan_single_xfer[2].rx_buf = &st->single_rx; > st->scan_single_xfer[2].len = 2; > > spi_message_init_with_transfers(&st->scan_single_msg,