From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "open list:NETWORKING DRIVERS (WIRELESS)"
<linux-wireless@vger.kernel.org>,
"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
MANAGEM..." <alsa-devel@alsa-project.org>,
Avri Altman <avri.altman@intel.com>,
Stanislaw Gruszka <sgruszka@redhat.com>,
Jiri Slaby <jirislaby@gmail.com>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Will Deacon <will.deacon@arm.com>,
Jaroslav Kysela <perex@perex.cz>,
"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
Kalle Valo <kvalo@qca.qualcomm.com>,
Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
Luciano Coelho <luciano.coelho@intel.com>,
Wang Long <long.wanglong@huawei.com>,
Richard Fitzgerald <rf@opensource.wolfsonmicro.com>,
Ingo Molnar <mingo@kernel.org>, open list <linux-kernel@vger.>
Subject: Re: [PATCH V3 2/2] debugfs: don't assume sizeof(bool) to be 4 bytes
Date: Tue, 15 Sep 2015 10:13:19 +0100 [thread overview]
Message-ID: <20150915091319.GH11200@ck-lbox> (raw)
In-Reply-To: <27d37898b4be6b9b9f31b90135f8206ca079a868.1442305897.git.viresh.kumar@linaro.org>
On Tue, Sep 15, 2015 at 02:04:59PM +0530, Viresh Kumar wrote:
> Long back 'bool' type used to be a typecast to 'int', but that changed
> in v2.6.19. And that is a typecast to _Bool now, which (mostly) takes
> just a byte. Anyway, the bool type is implementation defined, and better
> we don't assume its size to be 4 bytes or 1.
>
> The problem with current code is that it reads/writes 4 bytes for a
> boolean, which will read/update 3 excess bytes following the boolean
> variable (when sizeof(bool) is 1 byte). And that can lead to hard to fix
> bugs. It was a nightmare cracking this one.
>
> The debugfs code had this bug since the first time it got introduced,
> but was never got caught, strange. Maybe the bool variables (monitored
> by debugfs) were followed by an 'int' or something bigger and the pad
> bytes made sure, we never see this issue.
>
> But the OPP (Operating performance points) library have three booleans
> allocated to contiguous bytes and this bug got hit quite soon (The
> debugfs support for OPP is yet to be merged). It showed up as corruption
> of the debugfs boolean symbols, where Y were becoming N and vice versa.
>
> Fix it properly by changing the last argument of debugfs_create_bool(),
> to type 'bool *' instead of 'u32 *', so that it doesn't depend on sizeof
> bool at all.
>
> That required updates to all user sites as well in a single commit.
> regmap core was also using debugfs_{read|write}_file_bool(), directly
> and variable types were updated for that to be bool as well.
>
> Acked-by: Mark Brown <broonie@kernel.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
For the minor wm_adsp change:
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Thanks,
Charles
next prev parent reply other threads:[~2015-09-15 9:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <9b705747a138c96c26faee5218f7b47403195b28.1442305897.git.viresh.kumar@linaro.org>
2015-09-15 8:34 ` [PATCH V3 2/2] debugfs: don't assume sizeof(bool) to be 4 bytes Viresh Kumar
2015-09-15 9:13 ` Charles Keepax [this message]
2015-09-15 10:37 ` Johannes Berg
2015-09-15 11:04 ` Viresh Kumar
2015-09-15 13:45 ` Steven Rostedt
2015-09-15 14:04 ` Viresh Kumar
2015-09-15 17:38 ` Linus Torvalds
2015-09-15 17:47 ` Steven Rostedt
2015-09-16 7:24 ` Borislav Petkov
2015-09-16 8:02 ` Ingo Molnar
2015-09-15 14:04 ` Steven Rostedt
2015-09-15 14:12 ` Viresh Kumar
2015-09-15 14:29 ` Tejun Heo
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=20150915091319.GH11200@ck-lbox \
--to=ckeepax@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=avri.altman@intel.com \
--cc=bigeasy@linutronix.de \
--cc=catalin.marinas@arm.com \
--cc=emmanuel.grumbach@intel.com \
--cc=jirislaby@gmail.com \
--cc=kvalo@qca.qualcomm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger. \
--cc=linux-mm@kvack.org \
--cc=linux-wireless@vger.kernel.org \
--cc=long.wanglong@huawei.com \
--cc=luciano.coelho@intel.com \
--cc=mingo@kernel.org \
--cc=perex@perex.cz \
--cc=peterz@infradead.org \
--cc=rf@opensource.wolfsonmicro.com \
--cc=sgruszka@redhat.com \
--cc=viresh.kumar@linaro.org \
--cc=will.deacon@arm.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).