From: Krzysztof Kozlowski <krzk@kernel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: sound-open-firmware@alsa-project.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 00/14] ASoC: Constify local snd_sof_dsp_ops
Date: Mon, 22 Apr 2024 21:45:22 +0200 [thread overview]
Message-ID: <138ac465-1576-4e86-a05d-63f8acc6fb70@kernel.org> (raw)
In-Reply-To: <d046d195-6fa3-4c52-bc5f-3e5e763bc692@linux.intel.com>
On 22/04/2024 17:52, Pierre-Louis Bossart wrote:
>
>
> On 4/22/24 00:43, Krzysztof Kozlowski wrote:
>> On 15/04/2024 16:19, Pierre-Louis Bossart wrote:
>>>
>>>> The core code does not modify the 'struct snd_sof_dsp_ops' passed via
>>>> pointer in various places, so this can be made pointer to const.
>>>
>>> The structure itself is NOT always const - the initialization itself
>>> does have platform-specific changes, so what do we really gain from all
>>> this?
>>
>> In the context of these patches, the structure is *always* const. In
>> other drivers, it is not, but they are not really relevant here.
>>
>>>
>>> some commit messages say the code is "a bit safer", but I personally
>>> find the 'const' more confusing since the information that the structure
>>> can be modified during initialization is lost.
>>
>> Functions which take some data and do not modify it are easier to read
>> if the pointed data is marked as const. Then it is obvious that
>> functions for example is re-entrant. Or that it does not affect the
>> state of other devices/core structures.
>>
>> Additionally, the static data is safer when is const, because it cannot
>> be used in some attacks.
>
> agree, but here you are marking as 'const' non-static data.
What do you mean? Entire point of this patchset is for static and global
data. Which patches are you reviewing?
>
>> I really do not understand which information you lost here? Core does
>> not change the ops, so the data should be passed as const as often as
>> possible. If anyone wants to write a driver which does not use static
>> ops, but somehow dynamically allocated and changed, nothing stops him.
>> This patch did not make it less readable/doable.
>>
>> The point is that these ops do not differ from other ops or some other
>> driver-passed structures, which we have around 100 already in checkpatch.
>
> I am so old that I remember times where we had to put things in ROM.
> That's what 'const' means to me: a dedicated memory space for immutable
> values.
There are multiple reasons and benefits for const, like compiler
optimization, code readability (meaning) up to security improvements,
e.g. by some GCC plugins or marking rodata as really non-writeable, so
closing some ways of exploits. There are many opportunities here, even
if they are not yet enabled.
>
> that's a different interpretation to the 'software' view you're
> describing. "this structure will not modified by this function" is not
> the same thing as "this structure CANNOT be modified".
Yes, but can we please discuss specific patchset then? Patches which
change pointers to const have one "interpretation". Patches which modify
static or global data have another.
>
> I am not going to lay on the tracks, if Mark wants to apply the patches
> that's fine. I just wanted to highlight that the reason we did not use
> 'const' was that the data is dynamically allocated/modified and not
> constant at all.
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-04-22 19:45 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-14 18:47 [PATCH 00/14] ASoC: Constify local snd_sof_dsp_ops Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 01/14] ASoC: SOF: debug: " Krzysztof Kozlowski
2024-04-26 2:09 ` Mark Brown
2024-04-26 7:58 ` Krzysztof Kozlowski
2024-04-26 8:00 ` Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 02/14] ASoC: SOF: ipc3: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 03/14] ASoC: SOF: pcm: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 04/14] ASoC: SOF: Constify stored pointer to snd_sof_dsp_ops Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 05/14] ASoC: SOF: intel: pci-tng: Constify snd_sof_dsp_ops Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 06/14] ASoC: SOF: intel: hda: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 07/14] ASoC: SOF: amd: acp: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 08/14] ASoC: SOF: imx8: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 09/14] ASoC: SOF: imx8m: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 10/14] ASoC: SOF: imx8ulp: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 11/14] ASoC: SOF: intel: bdw: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 12/14] ASoC: SOF: intel: byt: " Krzysztof Kozlowski
2024-04-14 18:47 ` [PATCH 13/14] ASoC: SOF: mediatek: mt8186: " Krzysztof Kozlowski
2024-04-15 10:49 ` AngeloGioacchino Del Regno
2024-04-14 18:47 ` [PATCH 14/14] ASoC: SOF: mediatek: mt8195: " Krzysztof Kozlowski
2024-04-15 10:49 ` AngeloGioacchino Del Regno
2024-04-15 14:19 ` [PATCH 00/14] ASoC: Constify local snd_sof_dsp_ops Pierre-Louis Bossart
2024-04-22 5:43 ` Krzysztof Kozlowski
2024-04-22 15:52 ` Pierre-Louis Bossart
2024-04-22 19:45 ` Krzysztof Kozlowski [this message]
2024-04-22 20:42 ` Pierre-Louis Bossart
2024-04-22 20:47 ` Krzysztof Kozlowski
2024-04-22 21:24 ` Pierre-Louis Bossart
2024-04-23 9:42 ` Krzysztof Kozlowski
2024-04-23 15:57 ` Pierre-Louis Bossart
2024-04-23 16:06 ` Krzysztof Kozlowski
2024-04-25 16:12 ` Pierre-Louis Bossart
2024-05-01 13:43 ` Mark Brown
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=138ac465-1576-4e86-a05d-63f8acc6fb70@kernel.org \
--to=krzk@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kai.vehmanen@linux.intel.com \
--cc=kernel@pengutronix.de \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-sound@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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