amdgpu: resolve idr_* conflict with linux-kpi via REDBEAR_AMDGPU_BUILD
The linux-kpi idr.h header and the amdgpu recipe's redox_glue.h
both define struct idr and the idr_init/alloc/remove/find/destroy
inline functions, but with different members and different argument
signatures. When the amdgpu build includes both headers in the same
translation unit (via -include linux/amdgpu_stubs.h and via
redox_glue.h), the compiler reports a redefinition of struct idr
and conflicting types for the idr_* inlines, blocking the build.
Resolve the conflict by gating the linux-kpi idr declarations on a
new REDBEAR_AMDGPU_BUILD preprocessor flag. The amdgpu recipe's
CFLAGS now defines REDBEAR_AMDGPU_BUILD, so the linux-kpi
declarations are suppressed and redox_glue.h's authoritative copies
take over. Every other consumer of linux-kpi (the redox-drm scheme
daemon, the Wi-Fi drivers) continues to see the generic stubs.
The IDA macros and struct ida in linux-kpi are kept outside the
gate because they are not part of the amdgpu surface and must
remain available to other drivers. A forward declaration of
struct idr is added at the top of the header so the
struct ida { struct idr *idr; } member compiles cleanly when the
IDR definitions are suppressed. The IDA macros are updated to
no-ops against a pointer-typed idr slot; the amdgpu build does
not exercise them and other consumers continue to treat them as
stubs.
This commit is contained in:
@@ -3,6 +3,24 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user