Linux Sound subsystem development
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Mark Brown" <broonie@kernel.org>, "Arnd Bergmann" <arnd@kernel.org>
Cc: "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>,
	"Seppo Ingalsuo" <seppo.ingalsuo@linux.intel.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Brent Lu" <brent.lu@intel.com>,
	sound-open-firmware@alsa-project.org,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH] sound: sof: ioc4-topology: avoid extra dai_params copy
Date: Wed, 07 Aug 2024 17:18:35 +0200	[thread overview]
Message-ID: <d988fe89-104e-46ce-94b7-6754f2c7a455@app.fastmail.com> (raw)
In-Reply-To: <731fa66a-bed7-45fb-9187-a9263612eac4@sirena.org.uk>

On Wed, Aug 7, 2024, at 17:09, Mark Brown wrote:
> On Wed, Aug 07, 2024 at 10:02:27AM +0200, Arnd Bergmann wrote:
>
>> From what I can tell, this was unintentional, as both
>> sof_ipc4_prepare_dai_copier() and sof_ipc4_prepare_copier_module() make a
>> copy for the same purpose, but copying it once has the exact same effect.
>
>> Remove the extra copy and change the direct struct assignment to
>> an explicit memcpy() call to make it clearer to the reader that this
>> is what happens. Note that gcc treats struct assignment as a memcpy()
>> that may be inlined anyway, so the resulting object code is the same.
>
> The effect of the copy is to ensure that if the function fails the
> argument is unmodified - did you do the analysis to check that it's OK
> to modify on error?  Your commit log says "the same purpose" but never
> specifies what that purpose is.

There is always a chance that I misunderstood the code, but
yes, I did understand that the idea is to not modify the
parameters inside of sof_ipc4_prepare_dai_copier.

The only caller is in sof_ipc4_prepare_copier_module(), which
achieves the exact same bit by doing the same:

         /*
          * Use the fe_params as a base for the copier configuration.
          * The ref_params might get updated to reflect what format is
          * supported by the copier on the DAI side.
          *
          * In case of capture the ref_params returned will be used to
          * find the input configuration of the copier.
          */
         memcpy(&ref_params, fe_params, sizeof(ref_params));
         ret = sof_ipc4_prepare_dai_copier(sdev, dai, &ref_params, dir);
         if (ret < 0)
                  return ret;

So when sof_ipc4_prepare_dai_copier() fails, the caller's
local 'ref_params' structure is no longer used anywhere.

     Arnd

  reply	other threads:[~2024-08-07 15:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  8:02 [PATCH] sound: sof: ioc4-topology: avoid extra dai_params copy Arnd Bergmann
2024-08-07  8:37 ` Pierre-Louis Bossart
2024-08-07  8:47   ` Arnd Bergmann
2024-08-07 10:00 ` Mark Brown
2024-08-07 15:09 ` Mark Brown
2024-08-07 15:18   ` Arnd Bergmann [this message]
2024-08-07 16:21     ` Ranjani Sridharan

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=d988fe89-104e-46ce-94b7-6754f2c7a455@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=brent.lu@intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=justinstitt@google.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.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=seppo.ingalsuo@linux.intel.com \
    --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