Skip to content

Conversation

@mgsharm
Copy link
Contributor

@mgsharm mgsharm commented Nov 13, 2025

Description of changes:

This PR adds support for AMD GPU drivers to the Bottlerocket kernel kit by introducing two new packages:

  1. linux-firmware-amd: Provides AMD GPU firmware files required for GPU initialization and operation. Uses kernel.org sources with GPG verification and zstd compression.
  2. kmod-6.12-amdgpu: Provides AMD GPU DKMS kernel modules for kernel 6.12. Includes support for AMD GPUs by building out-of-tree drivers from AMD's official DKMS package (version 6.14.14-2226257).

These packages enable AMD GPU support for Bottlerocket instances with AMD hardware accelerators.

Testing done:

  • Successfully built both packages in the kernel kit
  • Verified package dependencies and build requirements
  • Confirmed proper file installation paths and permissions

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@@ -0,0 +1,72 @@
%global kernel_major 6.12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can move this into the kernel-6.12 build so its just included with the rest of the kernel built in one shot.

@@ -0,0 +1,22 @@
[package]
name = "linux-firmware-amd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had expected this to just be a sub-package of linux-firmware instead of a new top level package. Can we move this logic into the existing package?


%files
%dir %{fwdir}
%{fwdir}/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want everything, I think there is a specific set of firmware we want that is only amdgpu related.

[[package.metadata.build-package.external-files]]
url = "https://repo.radeon.com/amdgpu/30.10.2/el/10/main/x86_64/amdgpu-dkms-6.14.14-2226257.el10.noarch.rpm"
sha512 = "ffe054d3673f729786a32cf8a67d69b942348eb12d800073a7efc873fcba8a760485a003ed1bfb5273eda5f7d514263c80a97243371d36bf69ea986137f8c41e"
force-upstream = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip this and treat it like a normal source.

pushd amdgpu

# Build using the DKMS Makefile with static configuration
make modules KERNELVER=%{_cross_kver} kernel_build_dir=%{_cross_usrsrc}/kernels/6.12 CC=%{_cross_target}-gcc ARCH=%{_cross_karch} CROSS_COMPILE=%{_cross_target}- EXTRA_CFLAGS=-DPACKAGE_VERSION=\\\"%{version}\\\"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the triple \ at the end?

Version: 30.10
Release: 1%{?dist}
Summary: AMD GPU drivers for the 6.12 kernel
License: GPL-2.0 WITH Linux-syscall-note
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The license doesn't match the license in the RPM.

@@ -0,0 +1,20 @@
The Linux Kernel is provided under:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct license, the RPM includes a license already:

./share/doc/amdgpu-dkms/LICENSE

%{summary}.

%prep
# Extract DKMS source from RPM
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not compiling with DKMS so you could just say extract driver srouces.

pushd amdgpu

# Configure DKMS
KERNELVER=%{_cross_kver} amd/dkms/configure --with-linux=%{kernel_sources}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use the cross_configure macro and likely avoid the flags in the make modules call.

Copy link
Contributor

@bcressey bcressey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When aarch64 fails, that's a sign that cross-compiling might not be set up correctly. It's not always true, but it's the theory you should work hard to disprove.

Based on that I'd say you should get the aarch64 build at least to the point where it fails from some source-level compatibility. Otherwise I don't trust that the x86_64 build is doing what we think, meaning the configure / make logic may not be correct.

Comment on lines +33 to +34
# Configure DKMS
KERNELVER=%{_cross_kver} amd/dkms/configure --with-linux=%{kernel_sources}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configure scripts should not be run during %prep, they go in %build

%install
# Install license file
install -d %{buildroot}%{_cross_licensedir}/%{name}
install -p -m 0644 %{S:1} %{buildroot}%{_cross_licensedir}/%{name}/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This license should come from usr/share/doc/amdgpu-dkms/LICENSE in the RPM, it shouldn't be included as a source file.


# Install AMD GPU kernel modules to correct location
install -d %{buildroot}%{_cross_kmoddir}/kernel/drivers/gpu/drm/amd/amdgpu
install -p -m 644 amdgpu/amd/amdkcl/amdkcl.ko %{buildroot}%{_cross_kmoddir}/kernel/drivers/gpu/drm/amd/amdgpu/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should use the %{_ko} macro:

Suggested change
install -p -m 644 amdgpu/amd/amdkcl/amdkcl.ko %{buildroot}%{_cross_kmoddir}/kernel/drivers/gpu/drm/amd/amdgpu/
install -p -m 644 amdgpu/amd/amdkcl/amdkcl.%{_ko} %{buildroot}%{_cross_kmoddir}/kernel/drivers/gpu/drm/amd/amdgpu/

Comment on lines +54 to +55
install -p -m 644 amdgpu/ttm/amdttm.ko %{buildroot}%{_cross_kmoddir}/kernel/drivers/gpu/drm/amd/amdgpu/
install -p -m 644 amdgpu/amddrm_ttm_helper.ko %{buildroot}%{_cross_kmoddir}/kernel/drivers/gpu/drm/amd/amdgpu/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A for loop over the .ko files would be more readable if all these kmods are going into the same directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants