All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>, Dan Murphy <dmurphy@ti.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>
Cc: <linux-iio@vger.kernel.org>, <linux-api@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 4/4] iio: health: Add driver for the TI AFE4403 heart monitor
Date: Tue, 2 Feb 2016 11:38:09 -0600	[thread overview]
Message-ID: <56B0E981.5040203@ti.com> (raw)
In-Reply-To: <56ACD24E.3050308@kernel.org>

On 01/30/2016 09:10 AM, Jonathan Cameron wrote:
> On 25/01/16 17:29, Andrew F. Davis wrote:
>> +
>> +static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val)
>> +{
>> +	u8 tx[4] ____cacheline_aligned = {AFE440X_CONTROL0, 0x0, 0x0,
>> +					  AFE440X_CONTROL0_READ};
> hmm. Can you do this on the stack?  Don't think so but maybe I'm wrong..
> The cachline aligned trick relies on the start of the allocation on the
> heap being aligned and then pads to ensure that the element so tagged
> is also aligned appropriately.

I am not sure ether, I think I borrowed this from some example that did
it like this, but I can't find it now. So, I'll change this to be safe.

>> +	u8 rx[3];
>> +	int ret;
> Even if this were possible, ret is in the same cacheline as tx and rx so
> chaos may well occur.
>
> If you really want to avoid having allocations elsewhere, just use
> spi_write_then_read(afe->spi, tx, 4, NULL, 0) and you should be fine
> as spi_write_then_read uses safe bounce buffers.

spi_write_then_read performs a memcpy to the rx buffer, even though
the length is 0 I believe it is still technically undefined behavior,
but it doesn't seem to cause any issues with the current implementation
so I'll do this.

Thanks,
Andrew

WARNING: multiple messages have this Message-ID (diff)
From: "Andrew F. Davis" <afd-l0cyMroinI0@public.gmane.org>
To: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Hartmut Knaack <knaack.h-Mmb7MZpHnFY@public.gmane.org>,
	Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
	Peter Meerwald <pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org>,
	Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v4 4/4] iio: health: Add driver for the TI AFE4403 heart monitor
Date: Tue, 2 Feb 2016 11:38:09 -0600	[thread overview]
Message-ID: <56B0E981.5040203@ti.com> (raw)
In-Reply-To: <56ACD24E.3050308-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

On 01/30/2016 09:10 AM, Jonathan Cameron wrote:
> On 25/01/16 17:29, Andrew F. Davis wrote:
>> +
>> +static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val)
>> +{
>> +	u8 tx[4] ____cacheline_aligned = {AFE440X_CONTROL0, 0x0, 0x0,
>> +					  AFE440X_CONTROL0_READ};
> hmm. Can you do this on the stack?  Don't think so but maybe I'm wrong..
> The cachline aligned trick relies on the start of the allocation on the
> heap being aligned and then pads to ensure that the element so tagged
> is also aligned appropriately.

I am not sure ether, I think I borrowed this from some example that did
it like this, but I can't find it now. So, I'll change this to be safe.

>> +	u8 rx[3];
>> +	int ret;
> Even if this were possible, ret is in the same cacheline as tx and rx so
> chaos may well occur.
>
> If you really want to avoid having allocations elsewhere, just use
> spi_write_then_read(afe->spi, tx, 4, NULL, 0) and you should be fine
> as spi_write_then_read uses safe bounce buffers.

spi_write_then_read performs a memcpy to the rx buffer, even though
the length is 0 I believe it is still technically undefined behavior,
but it doesn't seem to cause any issues with the current implementation
so I'll do this.

Thanks,
Andrew

  reply	other threads:[~2016-02-02 17:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 17:28 [PATCH v4 0/4] iio: AFE4404 Heart Rate Monitor and Bio-Sensing Andrew F. Davis
2016-01-25 17:28 ` Andrew F. Davis
2016-01-25 17:28 ` [PATCH v4 1/4] Documentation: afe4404: Add DT bindings for the AFE4404 heart monitor Andrew F. Davis
2016-01-25 17:28   ` Andrew F. Davis
2016-01-25 20:06   ` Peter Meerwald-Stadler
2016-01-25 20:24     ` Andrew F. Davis
2016-01-25 17:28 ` [PATCH v4 2/4] iio: health: Add driver for the TI " Andrew F. Davis
2016-01-25 17:28   ` Andrew F. Davis
2016-01-25 20:17   ` Peter Meerwald-Stadler
2016-01-25 20:30     ` Andrew F. Davis
2016-01-30 14:59   ` Jonathan Cameron
2016-01-30 14:59     ` Jonathan Cameron
2016-02-02 15:50     ` Andrew F. Davis
2016-02-02 15:50       ` Andrew F. Davis
2016-01-25 17:29 ` [PATCH v4 3/4] Documentation: afe4403: Add DT bindings for the AFE4403 " Andrew F. Davis
2016-01-25 17:29   ` Andrew F. Davis
2016-01-25 17:29 ` [PATCH v4 4/4] iio: health: Add driver for the TI " Andrew F. Davis
2016-01-25 17:29   ` Andrew F. Davis
2016-01-25 20:21   ` Peter Meerwald-Stadler
2016-01-25 20:21     ` Peter Meerwald-Stadler
2016-01-25 20:36     ` Andrew F. Davis
2016-01-25 20:36       ` Andrew F. Davis
2016-01-30 15:10   ` Jonathan Cameron
2016-02-02 17:38     ` Andrew F. Davis [this message]
2016-02-02 17:38       ` Andrew F. Davis

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=56B0E981.5040203@ti.com \
    --to=afd@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.