Re: [PATCH] [v2] dpaa: avoid linking objects into multiple modules

From: Arnd Bergmann

Date: Mon Mar 30 2026 - 10:12:45 EST


On Tue, Jul 25, 2023, at 22:59, Vladimir Oltean wrote:
> On Tue, Jul 25, 2023 at 10:39:40PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@xxxxxxxx>
>>
>> Each object file contains information about which module it gets linked
>> into, so linking the same file into multiple modules now causes a warning:

A recent change broke my earlier patch, and I noticed I had this
version sitting in my randconfig tree for multiple years now, so
I refreshed it now, sorry for dropping the ball earlier.

>> scripts/Makefile.build:254: drivers/net/ethernet/freescale/dpaa2/Makefile: dpaa2-mac.o is added to multiple modules: fsl-dpaa2-eth fsl-dpaa2-switch
>> scripts/Makefile.build:254: drivers/net/ethernet/freescale/dpaa2/Makefile: dpmac.o is added to multiple modules: fsl-dpaa2-eth fsl-dpaa2-switch
>>
>> Chang the way that dpaa2 is built by moving the two common files into a
>> separate module with exported symbols instead.
>>
>> To avoid a link failure when the switch driver is built-in, but the dpio driver
>> is a loadable module, add the same dependency in there that exists for
>> the ethernet driver.
>
> Unrelated change should be separate.

This was fixed independently and is gone from v3

> There was a previous attempt at this before, by Alexander Lobakin:
> https://patchwork.kernel.org/project/netdevbpf/patch/20221119225650.1044591-16-alobakin@xxxxx/
>
> but it seems he wasn't persistent enough with it.
>
> Something which I liked better in his proposal was the naming of the
> config option (FSL_DPAA2_MAC) and of the new module (fsl-dpaa2-mac).

I renamed the module, but did not introduce a Kconfig symbol.
The same thing can be done either using Kconfig or Makefile
logic, and I just kept my previous approach here.

>> -obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o
>> +obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o fsl-dpaa2-common.o
>> obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += fsl-dpaa2-ptp.o
>> -obj-$(CONFIG_FSL_DPAA2_SWITCH) += fsl-dpaa2-switch.o
>> +obj-$(CONFIG_FSL_DPAA2_SWITCH) += fsl-dpaa2-switch.o fsl-dpaa2-common.o
>
> I am not completely sure how this works. Can fsl-dpaa2-common appear
> both in obj-y (added by $(CONFIG_FSL_DPAA2_ETH)) and in obj-m (added by
> $(CONFIG_FSL_DPAA2_SWITCH))? Olek proposed the introduction of a new,
> hidden and selectable tristate FSL_DPAA2_MAC. At least I understand how
> that works.

Yes, this is a Kbuild feature: if a module is both obj-y and obj-m, it
is built into the kernel and the second one is dropped. The effect is
exactly equivalent to having a silent Kconfig symbol FSL_DPAA2_MAC
that is selected by both others.

>> +
>> +MODULE_LICENSE("GPL");
>> +MODULE_DESCRIPTION("DPAA2 Ethernet core library");
>
> s/core/MAC/ everywhere

Done.

Arnd