From: Borislav Petkov <bp@alien8.de>
To: tthayer@altera.com
Cc: robherring2@gmail.com, pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
rob@landley.net, linux@arm.linux.org.uk, dinguyen@altera.com,
dougthompson@xmission.com, grant.likely@linaro.org,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, tthayer.linux@gmail.com
Subject: Re: [PATCHv4 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller
Date: Tue, 13 May 2014 02:12:46 +0200 [thread overview]
Message-ID: <20140513001246.GC5935@pd.tnic> (raw)
In-Reply-To: <1399937817-2202-4-git-send-email-tthayer@altera.com>
On Mon, May 12, 2014 at 06:36:57PM -0500, tthayer@altera.com wrote:
> + ptemp[0] = 0x5A5A5A5A;
> + ptemp[1] = 0xA5A5A5A5;
> + /* Clear the error injection bits */
> + regmap_write(drvdata->mc_vbase, CTLCFG, read_reg);
> + /* Ensure it has been written out */
> + wmb();
> +
> + /*
> + * To trigger the error, we need to read the data back
> + * (the data was written with errors above)
> + * The ACCESS_ONCE macros are used to prevent the
> + * compiler optimizing these reads out.
> + */
> + reg = ACCESS_ONCE(ptemp[0]);
> + read_reg = ACCESS_ONCE(ptemp[1]);
> + /* Force Read */
> + rmb();
Right, I still am a bit unsure about this thing. So sure, we funnel
ptemp through an asm() block which stops the optimizer but we assign the
results to reg and read_reg, i.e. two local variables which aren't used
in this function anymore.
Thus, I don't see what stops the compiler from discarding them along
with the ACCESS_ONCE() reads at some point, when it becomes really
smart. Basically killing
> + reg = ACCESS_ONCE(ptemp[0]);
> + read_reg = ACCESS_ONCE(ptemp[1]);
as they have to effect.
Maybe we can do the reads in asm - this should be pretty safe.
I.e., something like this:
asm volatile("" : "=r" (reg), "=r" (read_reg),
: "0" (ptemp[0]), "1" (ptemp[1]));
and it does it on x86 (did a small test program) by shuffling the values
through registers so we definitely have the reads.
.loc 1 28 0
movl -48(%rbp), %edx # ptemp, D.2240
movl -44(%rbp), %eax # ptemp, D.2240
.loc 1 27 0
movl %edx, -28(%rbp) # reg, reg
movl %eax, -32(%rbp) # read_reg, read_reg
Btw, if you only want to do the reads, you can simply tell gcc to put them in
registers
asm volatile("" :: "r" (ptemp[0]), "r" (ptemp[1]));
and be done with it but I don't know how smart it is with register
allocation so as to recognize that they're already in registers (when
they already are in some registers) and discard the reads.
Fun stuff! :-)
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2014-05-13 0:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 23:36 Addition of EDAC for Altera SoC SDRAM Controller tthayer
[not found] ` <1399937817-2202-1-git-send-email-tthayer-EIB2kfCEclfQT0dZR+AlfA@public.gmane.org>
2014-05-12 23:36 ` [PATCHv4 1/3] dts: socfpga: Add bindings for Altera SoC SDRAM controller tthayer-EIB2kfCEclfQT0dZR+AlfA
2014-05-12 23:36 ` [PATCHv4 2/3] dts: socfpga: Add bindings for Altera SoC SDRAM EDAC tthayer
2014-05-12 23:36 ` [PATCHv4 3/3] edac: altera: Add EDAC support for Altera SoC SDRAM Controller tthayer
2014-05-13 0:12 ` Borislav Petkov [this message]
2014-05-14 13:38 ` Thor Thayer
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=20140513001246.GC5935@pd.tnic \
--to=bp@alien8.de \
--cc=devicetree@vger.kernel.org \
--cc=dinguyen@altera.com \
--cc=dougthompson@xmission.com \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=rob@landley.net \
--cc=robherring2@gmail.com \
--cc=tthayer.linux@gmail.com \
--cc=tthayer@altera.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).