[PATCH 2/2] ASoC: SOF: SND_INTEL_DSP_CONFIG dependency

Takashi Iwai tiwai at suse.de
Sat Jan 23 09:08:37 CET 2021


On Fri, 22 Jan 2021 19:33:27 +0100,
Arnd Bergmann wrote:
> 
> On Fri, Jan 22, 2021 at 4:38 PM Pierre-Louis Bossart
> <pierre-louis.bossart at linux.intel.com> wrote:
> > >> The sof-pci-dev driver fails to link when built into the kernel
> > >> and CONFIG_SND_INTEL_DSP_CONFIG is set to =m:
> > >>
> > >> arm-linux-gnueabi-ld: sound/soc/sof/sof-pci-dev.o: in function `sof_pci_probe':
> > >> sof-pci-dev.c:(.text+0x1c): undefined reference to `snd_intel_dsp_driver_probe'
> > >>
> > >> As a temporary fix, use IS_REACHABLE to prevent the problem from
> > >> happening. A more complete solution is to move this code to
> > >> Intel-specific parts, restructure the drivers and Kconfig as discussed
> > >> with Arnd Bergmann and Takashi Iwai.
> > >>
> > >> Fixes: 82d9d54a6c0e ("ALSA: hda: add Intel DSP configuration / probe code")
> > >> Reported-by: Arnd Bergmann <arnd at arndb.de>
> > >> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
> > >
> > > This might not be good enough.  The code may still refer to the
> > > snd_intel_dsp_probe() symbol even if IS_REACHABLE() is false
> > > (although, practically seen, gcc should optimize it out).
> > >
> > > You need #if IS_REACHABLE() instead of the plain if.
> > > Then you don't need to change the indentation, and the patch will be
> > > eventually smaller, too :)
> >
> > I used the if() on purpose since in the past you mentioned #if/#endif
> > are ugly. There are plenty of other cases in the kernel code where if(
> > IF_REACHABLE(CONFIG_XYZ)) is used...
> 
> Dead-code-elimination in both gcc and clang is reliable for all supported
> versions (there were problems in gcc-4.1 and before), and generally the
> "if (IS_ENABLED())" form is nicer than the "#if IS_ENABLED()" form
> because it produces better compile-time coverage.

Heh, my trust to the compiler isn't that high, but other than that,
it's a matter of taste.  I agree that if() fits often better in
general, especially when the more code is involved.  But, in this
particular case, the covered area is small (hence optimization doesn't
matter) and we want to show it rather clearer as a temporary
workaround (that shall be deleted in the next kernel).  Finally, the
changes needed by #ifdef are smaller.  That's why I suggested #ifdef.

But that's nothing but a bike shed topic, and I don't mind either way
as long as the code really works in all cases.


thanks,

Takashi


More information about the Alsa-devel mailing list