The driver's own KMD (upstream amdgpu, KFD, TTM, DRM and the linuxu shims)
compiled with no optimization level: clang's -O0, apart from five objects
whose BUILD_BUG_ONs need folding. Every register access, fence, interrupt
and copy path ran unoptimized. Both the DriverKit library and the host
builds the offline tests link now use the flags Linux builds that code
with (CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE, CONFIG_FRAME_POINTER as arm64
has it): -O2 -fno-strict-aliasing -fno-strict-overflow
-fno-delete-null-pointer-checks -fno-common, frame pointers kept for crash
logs. -funsigned-char stays out: it changes char semantics, not code
generation, from what Apple's signed-char ABI has always run.
The DriverKit objects also turn off the printf-family and string-copy
builtins: at -O2 clang rewrites such calls into others (sprintf, strcpy,
strncpy, vsnprintf, fwrite) that the DriverKit runtime does not export.
The library's external references are then a subset of the -O0 build's.
The offline suite passes as before; three tests fail with and without this
change alike (rg is not installed here, and two sanitizer findings in
test-only code: test-debugfs-lifecycle, test-kmem-cache-lifecycle,
test-upstream-pci-failure).
Adds the Linux file RPC (user client type 2) that carries DRM and KFD
ioctls with Linux numbering, libmlg_drm for clients, the in-dext command
submission self-test, and fixes the DRM_COMMAND_BASE override in the
linuxu drm.h.
linuxu's drm/drm.h redefined DRM_COMMAND_BASE as 0 and DRM_COMMAND_END
as 0x0f over the uapi's 0x40 and 0xA0. Every DRM_IOCTL_AMDGPU_* number
was therefore not the Linux one, and drm_ioctl() sent the core ioctls
below 0x0f (DRM_IOCTL_VERSION, GET_UNIQUE, ...) to the driver's table:
a render-node client issuing Linux ioctl numbers, as libdrm and Mesa do,
reached the wrong handlers. The uapi band now stands.
Linux builds with CONFIG_INIT_STACK_ALL_ZERO, the default whenever the
compiler supports it, and upstream depends on it: amdgpu_vm_bo_update()
returns an uninitialized r for the PRT mapping when nothing needs
updating, which the first AMDGPU_CS of every render client hits. Host and
DriverKit builds now pass -ftrivial-auto-var-init=zero as Linux does.
- get_random_bytes()/get_random_u*() from the platform CSPRNG
(arc4random_buf(), which DriverKit's libSystem also provides); DP MST
uses it for sideband nonces.
- lib/uuid.c built unmodified as a helper (guid_gen(), guid_null for DP
MST branch GUIDs), with hex_to_bin()/hex2bin()/bin2hex() from
lib/hexdump.c and the upstream linux/hex.h.
- kstrtobool() and kstrtobool_from_user() from lib/kstrtox.c for the
DC debugfs write handlers.
- vzalloc() for the DML/DML2 work areas.
- Upstream headers and helpers: linux/bitfield.h and linux/typecheck.h
verbatim (kernel.h now uses the upstream typecheck()), the full
linux/backlight.h and drm_privacy_screen_consumer.h (their
!CONFIG inlines replace stray declarations), ffz(), might_sleep_if(),
delayed_work_pending(), ARCH_KMALLOC_MINALIGN, linux/minmax.h, and
linux/err.h from linux/dmi.h as the quirk tables need. ssleep() is the
upstream inline now.
Add drivers/gpu/drm/display/ to the sparse checkout and compile the
display side of upstream amdgpu:
- mk/upstream_sources.mk gains the 498 objects of AMD_DISPLAY_FILES
(amd/display/Makefile and the Makefiles it includes, evaluated with
DRM_AMD_DC=y, DRM_AMD_DC_FP=y, DEBUG_FS=y), the drm_display_helper
module for the DRM_DISPLAY_* helpers amdgpu selects, the whole
drm_kms_helper module and the panel orientation/backlight quirk tables.
DCN 4.0.1 links the dcn10..dcn35 code it reuses, so every DCN is built.
- mk/kernel_config.mk and linux/autoconf.h enable DRM_AMD_DC, DC_FP and
the display helper configs; CEC, DP AUX chardev/CEC, DP tunnel, bridge
connector, SI DCE and secure display stay off.
- INCPATHS carries the subdir-ccflags-y include roots of the display
Makefiles in upstream order.
- CONFIG_DRM_AMD_DC_FP is declared in patches/manifest.json as a config
intervention: Kconfig drops it for clang+arm64 because of kernel FPU
rules that do not apply to userspace. scripts/verify-upstream.py checks
that each declared config intervention names a Kconfig symbol and is
set in autoconf.h.
- linux/kconfig.h provides IS_ENABLED/IS_REACHABLE as kbuild's forced
include does; autoconf.h pulls it in after the CONFIG table.
Display stays off at runtime by default; that gating follows separately.
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple
Silicon Macs inside a DriverKit system extension, for AMD GPUs attached
over Thunderbolt. The Linux sources come from a pinned submodule and are
compiled against linuxu, a userspace implementation of the Linux kernel
APIs they use. Includes the HSA runtime, the host installer app, the
setup and firmware fetch scripts, and the offline test suite.