From: Radu Rendec <radu.rendec@gmail.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: linux-i2c@vger.kernel.org
Subject: Re: [1/2] i2c: ismt: 16-byte align the DMA buffer address
Date: Thu, 04 Jan 2018 15:42:09 +0000 [thread overview]
Message-ID: <1515080529.3062.26.camel@gmail.com> (raw)
In-Reply-To: <20180104134606.GB919@hmswarspite.think-freely.org>
On Thu, 2018-01-04 at 08:46 -0500, Neil Horman wrote:
> On Fri, Aug 18, 2017 at 05:01:27PM +0100, Radu Rendec wrote:
> > Use only a portion of the data buffer for DMA transfers, which is always
> > 16-byte aligned. This makes the DMA buffer address 16-byte aligned and
> > compensates for spurious hardware parity errors that may appear when the
> > DMA buffer address is not 16-byte aligned.
> >
> > The data buffer is enlarged in order to accommodate any possible 16-byte
> > alignment offset and changes the DMA code to only use a portion of the
> > data buffer, which is 16-byte aligned.
> >
> > The symptom of the hardware issue is the same as the one addressed in
> > v3.12-rc2-5-gbf41691 and manifests by transfers failing with EIO, with
> > bit 9 being set in the ERRSTS register.
> >
> > Signed-off-by: Radu Rendec <radu.rendec@gmail.com>
>
> Why not just use the alligned attribute here for buffer?
>
> https://gcc.gnu.org/onlinedocs/gcc-3.3/gcc/Type-Attributes.html
>
> That would save you over allocation when possible and keep you from needing to
> create a private aligned variable.
First of all, thanks for reviewing this!
I believe the aligned() attribute cannot be used here because the whole
ismt_priv structure is dynamically allocated (the allocation is done at
the beginning of the ismt_probe() function).
Even with a statically allocated structure, aligning the whole
structure does not guarantee the alignment of the dma_buffer field,
because the field offset within the structure can change (e.g. if other
fields are added, removed, moved around etc.).
On the other hand, I realized I could have used the PTR_ALIGN macro to
calculate the aligned address. That would probably make the code less
ugly and more intuitive. So I would at least resubmit the patch using
PTR_ALIGN instead of ALIGN and explicit casts - if you agree to the
current solution, of course.
Thanks,
Radu
next prev parent reply other threads:[~2018-01-04 15:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 16:01 [PATCH 0/2] i2c: ismt: align the DMA buffer to avoid parity errors Radu Rendec
2017-08-18 16:01 ` [PATCH 1/2] i2c: ismt: 16-byte align the DMA buffer address Radu Rendec
2017-08-27 14:37 ` Wolfram Sang
2017-08-29 16:37 ` radu.rendec
2018-01-04 13:46 ` [1/2] " Neil Horman
2018-01-04 15:42 ` Radu Rendec [this message]
2018-01-04 16:22 ` Neil Horman
2018-01-04 17:01 ` Radu Rendec
2018-01-05 1:47 ` Neil Horman
2018-01-15 12:33 ` Radu Rendec
2018-01-15 18:53 ` Neil Horman
2018-01-15 19:02 ` Wolfram Sang
2018-01-15 19:53 ` Neil Horman
2017-08-18 16:01 ` [PATCH 2/2] i2c: ismt: dump registers at the end of transactions Radu Rendec
2018-01-04 13:52 ` [2/2] " Neil Horman
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=1515080529.3062.26.camel@gmail.com \
--to=radu.rendec@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
/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).