Re: [PATCH 00/79] Cleanup unused headers reported by clangd

Matthew Brost
2026-01-14T05:33:23Z

On Wed, Jan 14, 2026 at 06:02:57AM +0100, Raag Jadav wrote:
> On Tue, Jan 13, 2026 at 07:46:19PM -0800, Matthew Brost wrote:
> > On Tue, Jan 13, 2026 at 04:36:08PM -0800, Matt Roper wrote:
> > > On Tue, Jan 13, 2026 at 04:10:39PM -0800, Matthew Brost wrote:
> > > > On Tue, Jan 13, 2026 at 03:03:05PM -0800, Matt Roper wrote:
> > > > > clangd[1] helpfully flags #include's of headers that aren't being
> > > > > directly used by the file including them. In most cases we can either
> > > > > drop those #include statements or replace them with a more targeted
> > > > > include (such as xe_gt.h to xe_gt_types.h). Let's drop/simplify a bunch
> > > > > of the unnecessary includes in our driver's .c files; this may help
> > > > > speed up partial rebuilds for developers since the build system won't
> > > > > see as many false dependencies.
> > > > >
> > > >
> > > > Yes, header situation isn't great.
> > > >
> > > > > There's more header-related cleanup that could be done (e.g., some of
> > > > > our headers incorrectly include other headers they don't need), but that
> > > > > can wait for a follow-up series; this one is already long enough.
> > > > >
> > > > >
> > > > > [1] https://clangd.llvm.org/
> > > > >
> > > >
> > > > Once we get the headers into better shape can we get clangd in CI?
> > > > Without that a year from we will need another huge series of fixes to
> > > > undo all the mistakes we've made in the last year.
> > >
> > > clangd is a language server intended to talk to plugins in editors
> > > (e.g., I just set it up in neovim); I don't think clangd specifically
> > > can be used in a CI-like setup. However clang-tidy is a standalone lint
> > > tool that I think could be configured to print out the same kinds of
> > > warnings (the "misc-include-cleaner" check seems to be the one for this
> > > case), although I haven't tried it myself.
> > >
> >
> > Ok - for the series:
> > Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> >
> > I'd personaly prefer this squashed into one patch as 79 patches is a
> > lot, maybe Rodrigo, Thomas, Dave, and Sima have a different preference?
>
> Our CI doesn't test for other archs and we might risk breaking upstream
> builds.
>

That's a good point which I didn't consider. I believe there are lists
which will pick up other archs / kernel test robot though. I do think
the risk is quite low of breaking other builds though given these are Xe
related clean ups - once you start messing with core header that have
platform defines it gets risker. Also if we break something - not say we
should aim for that - community will step in and send us fix.

Matt

> I tried to dive[1] into some core headers but the situation seems
> impossible now. So fully agree, better to clean-up before the debt
> piles up.
>
> [1] https://lore.kernel.org/dri-devel/2342b516-2c6e-42e5-b4f4-579b280823ba@app.fastmail.com/
>
> Raag
>
> > > > > Matt Roper (79):
> > > > > drm/xe: Cleanup headers in xe_bb.c
> > > > > drm/xe: Drop unused header in xe_bo.c
> > > > > drm/xe: Cleanup headers in xe_devcoredump.c
> > > > > drm/xe: Drop unused header in xe_device.c
> > > > > drm/xe: Drop unused header in xe_exec.c
> > > > > drm/xe: Cleanup headers in xe_execlist.c
> > > > > drm/xe: Drop unused headers in xe_exec_queue.c
> > > > > drm/xe: Simplify headers in xe_ggtt.c
> > > > > drm/xe: Cleanup headers in xe_gsc_debugfs.c
> > > > > drm/xe: Simplify header in xe_gsc_proxy.c
> > > > > drm/xe: Drop unused headers in xe_gsc_submit.c
> > > > > drm/xe: Drop unused headers in xe_gt.c
> > > > > drm/xe: Cleanup headers in xe_gt_clock.c
> > > > > drm/xe: Drop unused header in xe_gt_debugfs.c
> > > > > drm/xe: Drop unused header in xe_gt_idle.c
> > > > > drm/xe: Drop unused header in xe_gt_mcr.c
> > > > > drm/xe: Drop unused headers in xe_gt_sriov_pf_config.c
> > > > > drm/xe: Drop unused header in xe_gt_sriov_pf_debugfs.c
> > > > > drm/xe: Simplify header in xe_gt_sriov_pf_migration.c
> > > > > drm/xe: Drop unused header in xe_gt_sriov_pf_policy.c
> > > > > drm/xe: Cleanup headers in xe_gt_sriov_pf_service.c
> > > > > drm/xe: Drop unused header in xe_gt_sriov_vf.c
> > > > > drm/xe: Simplify header in xe_gt_stats.c
> > > > > drm/xe: Simplify header in xe_gt_sysfs.c
> > > > > drm/xe: Simplify header in xe_gt_throttle.c
> > > > > drm/xe: Drop unused headers in xe_guc_ads.c
> > > > > drm/xe: Drop unused header in xe_guc_buf.c
> > > > > drm/xe: Cleanup headers in xe_guc_capture.c
> > > > > drm/xe: Cleanup headers in xe_guc_debugfs.c
> > > > > drm/xe: Simplify headers in xe_guc_hwconfig.c
> > > > > drm/xe: Simplify header in xe_guc_log.c
> > > > > drm/xe: Cleanup headers in xe_guc_relay.c
> > > > > drm/xe: Drop unused headers in xe_guc_submit.c
> > > > > drm/xe: Drop unused header in xe_heci_gsc.c
> > > > > drm/xe: Drop unused header in xe_huc.c
> > > > > drm/xe: Clean up headers in xe_huc_debugfs.c
> > > > > drm/xe: Drop unused header in xe_hw_engine.c
> > > > > drm/xe: Simplify include in xe_hw_engine_class_sysfs.c
> > > > > drm/xe: Simplify include in xe_hw_engine_group.c
> > > > > drm/xe: Cleanup headers in xe_hw_fence.c
> > > > > drm/xe: Cleanup headers in xe_i2c.c
> > > > > drm/xe: Drop unused header in xe_irq.c
> > > > > drm/xe: Drop unused headers in xe_memirq.c
> > > > > drm/xe: Drop unused headers in xe_mmio.c
> > > > > drm/xe: Drop unused headers in xe_mocs.c
> > > > > drm/xe: Simplify include in xe_module.c
> > > > > drm/xe: Drop unused header in xe_nvm.c
> > > > > drm/xe: Drop unused headers in xe_page_reclaim.c
> > > > > drm/xe: Drop unused header in xe_pci.c
> > > > > drm/xe: Simplify include in xe_psmi.c
> > > > > drm/xe: Drop unused header in xe_pxp.c
> > > > > drm/xe: Simplify header in xe_pxp_debugfs.c
> > > > > drm/xe: Cleanup headers in xe_reg_sr.c
> > > > > drm/xe: Drop unused headers in xe_reg_whitelist.c
> > > > > drm/xe: Cleanup headers in xe_ring_ops.c
> > > > > drm/xe: Drop unused header in xe_rtp.c
> > > > > drm/xe: Simplify header in xe_sa.c
> > > > > drm/xe: Simplify header in xe_sched_job.c
> > > > > drm/xe: Drop unused header in xe_sriov_packet.c
> > > > > drm/xe: Drop unused header in xe_sriov_pf_debugfs.c
> > > > > drm/xe: Drop unused header in xe_sriov_vf.c
> > > > > drm/xe: Cleanup headers in xe_step.c
> > > > > drm/xe: Drop unused header in xe_survivability_mode.c
> > > > > drm/xe: Cleanup headers in xe_tile.c
> > > > > drm/xe: Cleanup headers in xe_tlb_inval.c
> > > > > drm/xe: Drop unused header in xe_ttm_stolen_mgr.c
> > > > > drm/xe: Drop unused header in xe_ttm_sys_mgr.c
> > > > > drm/xe: Drop unused header in xe_ttm_vram_mgr.c
> > > > > drm/xe: Drop unused headers in xe_uc.c
> > > > > drm/xe: Cleanup headers in xe_uc_debugfs.c
> > > > > drm/xe: Simplify header in xe_uc_fw.c
> > > > > drm/xe: Drop unused header in xe_validation.c
> > > > > drm/xe: Drop unused header in xe_vm.c
> > > > > drm/xe: Drop unused headers in xe_vram.c
> > > > > drm/xe: Drop unused header in xe_vram_freq.c
> > > > > drm/xe: Drop unused header in xe_vsec.c
> > > > > drm/xe: Simplify header in xe_wa.c
> > > > > drm/xe: Drop unused header in xe_wait_user_fence.c
> > > > > drm/xe: Simplify header in xe_wopcm.c
> > > > >
> > > > > drivers/gpu/drm/xe/tests/xe_bo.c | 1 +
> > > > > drivers/gpu/drm/xe/xe_bb.c | 3 +--
> > > > > drivers/gpu/drm/xe/xe_bo.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_devcoredump.c | 3 +--
> > > > > drivers/gpu/drm/xe/xe_device.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_exec.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_exec_queue.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_execlist.c | 3 +--
> > > > > drivers/gpu/drm/xe/xe_ggtt.c | 3 +--
> > > > > drivers/gpu/drm/xe/xe_gsc_debugfs.c | 5 ++---
> > > > > drivers/gpu/drm/xe/xe_gsc_proxy.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_gsc_submit.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_gt.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_gt_clock.c | 6 +-----
> > > > > drivers/gpu/drm/xe/xe_gt_debugfs.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_gt_idle.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_gt_mcr.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_gt_sriov_pf_service.c | 5 ++---
> > > > > drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_gt_stats.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_gt_throttle.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_guc_ads.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_guc_buf.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_guc_capture.c | 5 +----
> > > > > drivers/gpu/drm/xe/xe_guc_debugfs.c | 5 ++---
> > > > > drivers/gpu/drm/xe/xe_guc_hwconfig.c | 4 ++--
> > > > > drivers/gpu/drm/xe/xe_guc_log.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_guc_relay.c | 3 +--
> > > > > drivers/gpu/drm/xe/xe_guc_submit.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_heci_gsc.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_huc.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_huc_debugfs.c | 5 ++---
> > > > > drivers/gpu/drm/xe/xe_hw_engine.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_hw_engine_group.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_hw_fence.c | 4 +---
> > > > > drivers/gpu/drm/xe/xe_i2c.c | 4 ++--
> > > > > drivers/gpu/drm/xe/xe_irq.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_memirq.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_mmio.c | 4 ----
> > > > > drivers/gpu/drm/xe/xe_mocs.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_module.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_nvm.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_page_reclaim.c | 4 ----
> > > > > drivers/gpu/drm/xe/xe_pci.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_psmi.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_pxp.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_pxp_debugfs.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_reg_sr.c | 5 +----
> > > > > drivers/gpu/drm/xe/xe_reg_whitelist.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_ring_ops.c | 4 +---
> > > > > drivers/gpu/drm/xe/xe_rtp.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_sa.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_sched_job.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_sriov_packet.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_sriov_pf_debugfs.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_sriov_vf.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_step.c | 3 ++-
> > > > > drivers/gpu/drm/xe/xe_survivability_mode.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_tile.c | 3 +--
> > > > > drivers/gpu/drm/xe/xe_tlb_inval.c | 7 ++-----
> > > > > drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_ttm_sys_mgr.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_uc.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_uc_debugfs.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_uc_fw.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_validation.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_vm.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_vram.c | 2 --
> > > > > drivers/gpu/drm/xe/xe_vram_freq.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_vsec.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_wa.c | 2 +-
> > > > > drivers/gpu/drm/xe/xe_wait_user_fence.c | 1 -
> > > > > drivers/gpu/drm/xe/xe_wopcm.c | 2 +-
> > > > > 80 files changed, 45 insertions(+), 129 deletions(-)
> > > > >
> > > > > --
> > > > > 2.52.0
> > > > >
> > >
> > > --
> > > Matt Roper
> > > Graphics Software Engineer
> > > Linux GPU Platform Enablement
> > > Intel Corporation