linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@systec-electronic.com>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: ads7846: ads7846_read12_ser is not DMA save
Date: Wed, 4 May 2011 16:02:03 +0200	[thread overview]
Message-ID: <201105041602.03542.alexander.stein@systec-electronic.com> (raw)

Hello,

I just encountered a problem on my ARMv5 (AT91SAM9263 based) board while using 
ads7843 or ads7846 (I replaced it). I tried reading 
/sys/class/hwmon/hwmon0/device/in0_input and got 0 most of the time. Sometimes 
the correct voltage was shown.
After digging a bit in the code I found out that sample (and command for Tx) 
from the following struct gets DMA mapped by the underlying atmel_spi driver 
for SPI Rx-Buffer.

struct ser_req {
	u8			ref_on;
	u8			command;
	u8			ref_off;
	u16			scratch;
	__be16			sample;
	struct spi_message	msg;
	struct spi_transfer	xfer[6];
};

The atmel_spi driver does proper dma_{,un}map_signgle on the Rx and Tx 
buffers. Now when the cache line for scratch is cleared and invalidated and 
the spi subsystem access msg (and maybe xfer) the cache line gets filled 
again, rendering the cache clear and invalidation before as useless.
As the ARMv5 core has 32Byte cache lines I added "char dummy[25];" after 
sample, so the spi structs are in a different cache line.
But this seem only to be a workaround as the cache lines might differ across 
each CPU.
Somebody an idea how to fix this in general?

Regards,
Alexander

             reply	other threads:[~2011-05-04 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04 14:02 Alexander Stein [this message]
2011-05-04 14:17 ` ads7846: ads7846_read12_ser is not DMA save Hennerich, Michael
2011-05-04 15:22   ` [PATCH 1/2] ads7846: Make buffers in ads7846_read12_ser and ads7845_read12_ser " Alexander Stein
2011-05-04 15:49     ` Jonathan Cameron
2011-05-04 15:55       ` Jonathan Cameron
2011-05-04 15:55       ` Alexander Stein
2011-05-04 16:07         ` Jonathan Cameron
2011-05-05  1:31         ` Dmitry Torokhov
2011-05-04 15:22   ` [PATCH 2/2] ads7846: Remove unused variable from struct ads7845_ser_req Alexander Stein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201105041602.03542.alexander.stein@systec-electronic.com \
    --to=alexander.stein@systec-electronic.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).