Page MenuHomeFreeBSD

graphics/nvidia-drm-*-kmod*: Fix build for 13.5, 14.3 and 15.0
ClosedPublic

Authored by junchoon_dec.sakura.ne.jp on Wed, Apr 1, 9:23 AM.
Tags
None
Referenced Files
F151149914: D56214.diff
Mon, Apr 6, 10:43 AM
F151125574: D56214.diff
Mon, Apr 6, 6:27 AM
F151124903: D56214.diff
Mon, Apr 6, 6:20 AM
F151124879: D56214.diff
Mon, Apr 6, 6:19 AM
Unknown Object (File)
Sun, Apr 5, 9:46 PM
Unknown Object (File)
Sat, Apr 4, 4:36 PM
Unknown Object (File)
Sat, Apr 4, 4:36 PM
Unknown Object (File)
Sat, Apr 4, 4:36 PM
Subscribers
None

Details

Summary

Latest upgrade to 595.58.03 caused build failure as of
requirements for a stub function pm_vt_switch_required().

The commit introduced it is not MFC'ed to 13.5-RELEASE,
stable/13, 14.3-RELEASE and 15.0-RELEASE and unlikely
to be done as it's not a security fix, more, stable/13 is going
to be EoL'ed in 1 month.

As this function, defined in sys/compat/linuxkpi/common/linux/pm.h,
is still a blank, stub function even on main, drop the offending line
for affected versions, keeping as-is for versions which has it.

No PORTREVISION bumps, as this is build fix.

Reported by: alt2600@icloud.com
PR: 294096

Diff Detail

Repository
R11 FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

junchoon_dec.sakura.ne.jp created this revision.

Note that simpler patch that blindly removes the offending line without checking OSVERSION is available at PR 294096.

Why are all the bsd.*.mk includes dropped and handled in Makefile.common? I'm not sure why that would be needed, why is the existing REINPLACE_CMD strategy not good enough?

To drop pm_vt_switch_required() only for addected base versions, I've introduced ${OSVERSION} check in graphics/nvidia-drm-kmod/Makefile.common where all affected ports includes directly or indirectly.

This requires splitting includes into bsd.port.pre.mk before handling ${OSVERSION} check and bsd.port.post.mk at the last line and including bsd.port.mk after that is prohibited as seen in Chapter 13.5 of Porter's Handbook.
And here, I wanted to avoid "hey, where is the corresponding bsd.port.post.mk for the bsd.ports.pre.mk?" issues.

This also required additional target, as including bsd.port.pre.mk forcibly terminates previous target (post-patch:).

If blindly dropping pm_vt_switch_required() for all base versions including unaffected 14.4-RELEASE, stable/15 and main is safe enough through Sep. 30, 2026, which is the EoL of 15.0-RELEASE, I'll switch to the simpler patch uploaded at Bug 294096.

The first patch there is the one available here, and the second one is the simpler one.

IMO it's a little awkward rolling the mk includes into Makefile.common like this. Instead could we use REINPLACE_CMD to wrap the pm_vt_switch_required call with a __FreeBSD_version check to hide it when appropriate?

Update diff as per request by ashafer.

Does this look reasonable? Unfortunately I don't have environments of affected branches to test in hand.

Note that the logic for checking version is in reverse with the previous one, as previous one is to remove the offending line for affected branches, while current one is to unhide the offending line only on branches requiring it.

Found 2026Q2 already branched.
So this (or later fix) need to be merged into 2026Q2 as this is for fixing builds.

graphics/nvidia-drm-kmod/Makefile.common
87

Thanks this looks simpler. I believe REINPLACE_CMD will replace whatever it matches, since you match pm_vt_switch_required here I think you have to add it before the #endif you add so it doesn't get dropped?

As for the versions, shouldn't this check just be #if __FreeBSD_version >= 1500504 since all versions below do not have the stub function? If we are at that version or later we can use it if not then we skip it, not sure why we need to check 1403507? Or was the stub MFC'ed to 14 as well?

graphics/nvidia-drm-kmod/Makefile.common
87

Thanks this looks simpler. I believe REINPLACE_CMD will replace whatever it matches, since you match pm_vt_switch_required here I think you have to add it before the #endif you add so it doesn't get dropped?

Here, matching with the whole function, "pm_vt_switch_required(dev->dev, true);". And the RE adds conditional before and "#endif" after the function.
You can see what's changed by comparing the target file after make extract and after make patch.

This function (as a whole) appears only once, and looks like below before and after make patch.

before:

     */
    pm_vt_switch_required(dev->dev, true);
}

after:

*/

#if FreeBSD_version >= 1403507 && FreeBSD_version < 1500000 || __FreeBSD_version >= 1500504

pm_vt_switch_required(dev->dev, true);

#endif

}

As for the versions, shouldn't this check just be #if __FreeBSD_version >= 1500504 since all versions below do not have the stub function? If we are at that version or later we can use it if not then we skip it, not sure why we need to check 1403507? Or was the stub MFC'ed to 14 as well?

Yes.
14.4-RELEASE (releng/14.4) has the stub function as it branched after it MFC'ed into stable/14, while 14.3-RELEASE branched before MFC. Note that I've used nearest __FreeBSD_version bumped after each MFC into stable/14 and stable/15, thus, both has around 10 days of broken window.
OTOH, stable/13 doesn't have this MFC'd, thus, no specific check for it is needed (check for "including and after 1403507" should do the sufficient job). Anyway, stable/13 is EoL'ed in one month.

https://github.com/freebsd/freebsd-src/blob/stable/14/sys/compat/linuxkpi/common/include/linux/pm.h

https://github.com/freebsd/freebsd-src/blob/releng/14.3/sys/compat/linuxkpi/common/include/linux/pm.h

https://github.com/freebsd/freebsd-src/blob/releng/14.4/sys/compat/linuxkpi/common/include/linux/pm.h

https://github.com/freebsd/freebsd-src/blob/stable/13/sys/compat/linuxkpi/common/include/linux/pm.h

https://www.freebsd.org/security/#sup

Seems reasonable then, thanks for addressing this

This revision is now accepted and ready to land.Fri, Apr 3, 3:14 PM