diff --git a/local/recipes/drivers/linux-kpi/source/src/c_headers/linux/idr.h b/local/recipes/drivers/linux-kpi/source/src/c_headers/linux/idr.h index 05b7e37e40..ea3a438ee9 100644 --- a/local/recipes/drivers/linux-kpi/source/src/c_headers/linux/idr.h +++ b/local/recipes/drivers/linux-kpi/source/src/c_headers/linux/idr.h @@ -3,6 +3,24 @@ #include +/* + * The amdgpu recipe's redox_glue.h provides its own `struct idr`, + * `idr_init/alloc/remove/find/destroy`, `DEFINE_IDR`, and + * `idr_for_each_entry` declarations. To avoid the conflicting + * declarations when amdgpu and the linux-kpi headers are included + * in the same translation unit, the linux-kpi idr declarations are + * suppressed when REDBEAR_AMDGPU_BUILD is defined. The amdgpu + * recipe sets -DREDBEAR_AMDGPU_BUILD in its CFLAGS; every other + * consumer of linux-kpi keeps the generic stubs below. + * + * The IDA macros, `struct ida`, and the forward declaration of + * `struct idr` are not part of the amdgpu surface, so they are + * always defined by linux-kpi regardless of REDBEAR_AMDGPU_BUILD. + */ +struct idr; + +#ifndef REDBEAR_AMDGPU_BUILD + struct idr { unsigned char __opaque[256]; }; @@ -40,19 +58,23 @@ static inline void idr_destroy(struct idr *idr) (void)idr; } -struct ida { - struct idr idr; -}; - -#define DEFINE_IDA(name) struct ida name = { .idr = { .__opaque = {0} } } -#define ida_init(ida) idr_init(&(ida)->idr) -#define ida_alloc(ida, gfp) idr_alloc(&(ida)->idr, NULL, 0, 0, (u32)(gfp)) -#define ida_alloc_range(ida, start, end, gfp) idr_alloc(&(ida)->idr, NULL, (start), (end), (u32)(gfp)) -#define ida_alloc_min(ida, min, gfp) ida_alloc_range(ida, min, INT_MAX, gfp) -#define ida_free(ida, id) idr_remove(&(ida)->idr, (id)) -#define ida_destroy(ida) idr_destroy(&(ida)->idr) +#define DEFINE_IDR(name) struct idr name = { .__opaque = {0} } #define idr_for_each_entry(idr, entry, id) \ for ((id) = 0, (entry) = (void *)0; (entry); (id)++) +#endif /* !REDBEAR_AMDGPU_BUILD */ + +struct ida { + struct idr *idr; +}; + +#define DEFINE_IDA(name) struct ida name = { .idr = NULL } +#define ida_init(ida) do { (void)(ida); } while (0) +#define ida_alloc(ida, gfp) 0 +#define ida_alloc_range(ida, start, end, gfp) 0 +#define ida_alloc_min(ida, min, gfp) 0 +#define ida_free(ida, id) do { (void)(ida); (void)(id); } while (0) +#define ida_destroy(ida) do { (void)(ida); } while (0) + #endif diff --git a/local/recipes/gpu/amdgpu/recipe.toml b/local/recipes/gpu/amdgpu/recipe.toml index 441d45b939..d115357ced 100644 --- a/local/recipes/gpu/amdgpu/recipe.toml +++ b/local/recipes/gpu/amdgpu/recipe.toml @@ -29,9 +29,15 @@ TARGET_CC="${TARGET}-gcc" # Compiler flags for the bounded retained AMD path. Legacy AMD DC config defines remain here only # for header compatibility with the adjacent imported Linux source trees. +# +# REDBEAR_AMDGPU_BUILD tells the linux-kpi idr.h header to suppress its +# generic `struct idr` and idr_* inline declarations; redox_glue.h +# provides the authoritative copies for the amdgpu build. Every other +# consumer of linux-kpi continues to see the generic stubs. export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_DRM_AMD_DC \ -DCONFIG_DRM_AMD_DC_DML2=1 \ -DCONFIG_DRM_AMD_DC_FP -DCONFIG_DRM_AMD_ACP \ + -DREDBEAR_AMDGPU_BUILD \ -include linux/amdgpu_stubs.h \ -I${LINUX_KPI} \ -I${REDOX_GLUE} \ @@ -54,8 +60,8 @@ export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_ -I${AMD_SRC}/display/dc/dcn301 \ -I${AMD_SRC}/display/dc/dcn31 \ -I${AMD_SRC}/display/dc/dcn32 \ - -I${AMD_SRC}/display/dc/dpp \ - -I${AMD_SRC}/display/dc/mmhubbub \ + -I${AMD_SRC}/display/dpp \ + -I${AMD_SRC}/display/mmhubbub \ -I${AMD_SRC}/display/modules \ -I${AMD_SRC}/display/modules/freesync \ -I${AMD_SRC}/display/modules/color \