Re: next-20250813 s390 allyesconfig undefined reference to `stmmac_simple_pm_ops'

From: Arnd Bergmann
Date: Tue Aug 19 2025 - 13:36:01 EST


On Tue, Aug 19, 2025, at 18:00, Alexander Gordeev wrote:
> On Tue, Aug 19, 2025 at 03:07:56PM +0530, Naresh Kamboju wrote:
> CONFIG_PM is not defined on s390 and as result stmmac_simple_pm_ops ends up
> in _DISCARD_PM_OPS(). The below patch fixes the linking, but it is by no
> means a correct solution:
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index 5769165ee5ba..d475a77e4871 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -668,7 +668,7 @@ static struct pci_driver loongson_dwmac_driver = {
> .probe = loongson_dwmac_probe,
> .remove = loongson_dwmac_remove,
> .driver = {
> - .pm = &stmmac_simple_pm_ops,
> + .pm = &__static_stmmac_simple_pm_ops,

The correct solution is to make the PM_SLEEP versions use this

.pm = pm_sleep_ptr(stmmac_simple_pm_ops),

or the corresponding version for the PM_RUNTIME+PM_SLEEP drivers:

.pm = pm_ptr(stmmac_pltfrm_pm_ops),

By convention, the pm_ptr()/pm_sleep_ptr() macro should be
used for any driver using DEFINE_DEV_PM_OPS() or its variants,
though missing that does not produce a warning for non-exported
options and only wastes a few bytes of .data.

> #define _DISCARD_PM_OPS(name, license, ns) \
> - static __maybe_unused const struct dev_pm_ops __static_##name
> + __maybe_unused const struct dev_pm_ops __static_##name

This would cause a lot of link failures elsewhere, since _DISCARD_PM_OPS
needs to ensure the operations are discarded by the compiler, which does
not happen when they are defined as a global symbol.

The idea of making this a 'static __maybe_unused' symbol is that
the actual functions get discarded as well but don't need an individual
__maybe_unused annotation or an #ifdef around them to prevent a
warning for unused symbols.

Arnd