linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Mathias Duckeck <m.duckeck@kunbus.de>,
	Phil Elwell <phil@raspberrypi.org>,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 2/3] iio: dac: Add Texas Instruments 8/10/12-bit 2/4-channel DAC driver
Date: Sun, 22 Oct 2017 11:48:54 +0200	[thread overview]
Message-ID: <20171022094854.GA30715@wunner.de> (raw)
In-Reply-To: <20171021203308.15ad9c1a@archlinux>

On Sat, Oct 21, 2017 at 08:33:08PM +0100, Jonathan Cameron wrote:
> On Tue, 17 Oct 2017 12:42:00 +0200 Lukas Wunner <lukas@wunner.de> wrote:
> > +struct ti_dac_chip {
> > +	struct mutex lock;
> > +	struct regulator *vref;
> > +	struct spi_message mesg;
> > +	struct spi_transfer xfer;
> > +	u8 buf[2] ____cacheline_aligned;
> 
> I missed this the first time.  The whole point of the fun
> of ____cacheline_aligned is to ensure nothing shares a
> cacheline with the buffer used for DMA.  We take care
> when allocating these private structures that this
> will be true, but it relies on nothing that might be
> changed during dma being after the buffer.
> 
> Simple reordering fix so I'll do it whilst applying.

TBH I was a bit confused about how to achieve proper cacheline
alignment.  My limited understanding of the slab allocator is
that it neither guarantees that an allocation begins on a cacheline
nor that no another allocation immediately starts after it.

However taking a closer look at iio_device_alloc() I realize now
that it implicitly takes care of both by inserting the necessary
padding.  Neat.  I was already wondering why the IIO subsystem
takes this somewhat unusual approach to allocate the private struct
behind struct iio_dev, instead of letting the driver embed it
within its private struct and use container_of() to yield the
private struct corresponding to a struct iio_dev, as most other
subsystems do.  But that explains it.

Thanks,

Lukas

  reply	other threads:[~2017-10-22  9:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 10:42 [PATCH v2 0/3] Texas Instruments 8/10/12-bit 2/4-channel DAC driver Lukas Wunner
2017-10-17 10:42 ` [PATCH v2 2/3] iio: dac: Add " Lukas Wunner
2017-10-21 19:33   ` Jonathan Cameron
2017-10-22  9:48     ` Lukas Wunner [this message]
2017-10-26 15:35       ` Jonathan Cameron
2017-10-17 10:42 ` [PATCH v2 1/3] dt-bindings: iio: dac: ti-dac082s085: Document new driver Lukas Wunner
2017-10-21 19:27   ` Jonathan Cameron
2017-10-17 10:42 ` [PATCH v2 3/3] iio: dac: ti-dac082s085: Read chip spec from device table Lukas Wunner
2017-10-21 19:38   ` Jonathan Cameron

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=20171022094854.GA30715@wunner.de \
    --to=lukas@wunner.de \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=m.duckeck@kunbus.de \
    --cc=phil@raspberrypi.org \
    --cc=pmeerw@pmeerw.net \
    /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).