Pull inteldrm_refcnt out of NINTAGP > 0, otherwise it remains undefined but still used in inteldrm_attachhook():
if (inteldrm_refcnt == 0) { i915_init(); } inteldrm_refcnt++; OK? Index: sys/dev/pci/drm/i915/i915_drv.c =================================================================== RCS file: /cvs/src/sys/dev/pci/drm/i915/i915_drv.c,v retrieving revision 1.142 diff -u -p -r1.142 i915_drv.c --- sys/dev/pci/drm/i915/i915_drv.c 15 Jul 2022 17:57:26 -0000 1.142 +++ sys/dev/pci/drm/i915/i915_drv.c 30 Jul 2022 07:45:48 -0000 @@ -2007,15 +2007,15 @@ static const struct drm_driver driver = #include "intagp.h" -#if NINTAGP > 0 -int intagpsubmatch(struct device *, void *, void *); -int intagp_print(void *, const char *); - /* * some functions are only called once on init regardless of how many times * inteldrm attaches in linux this is handled via module_init()/module_exit() */ int inteldrm_refcnt; + +#if NINTAGP > 0 +int intagpsubmatch(struct device *, void *, void *); +int intagp_print(void *, const char *); int intagpsubmatch(struct device *parent, void *match, void *aux)