Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,29 @@ AMBARELLA_OSDRV_S3L_LICENSE = MIT (load_ucode), PROPRIETARY (modules, microcode)
# load_ucode puts the DSP microcode in place. files/firmware is the generic set
# from Ambarella's S3L SDK release 2.5.0_20181109 (2018/10/28, 284712.282649),
# not from a camera's stock firmware, which the tree does not accept (#2767).
#
# The prebuilt modules hard-code struct offsets and carry no __versions, so a
# kernel config that moves them builds, boots and loads the modules, and fails
# only at the first /dev/iav ioctl. iav_open reads inode->i_cdev at 272 and
# writes file->private_data at 112: CONFIG_LBDAF moves the first (#2763), and
# CONFIG_QUOTA on top of it moved it again (#2778). So the kernel's own Kbuild
# compiles src/abi against this kernel, and the build stops on a mismatch.
AMBARELLA_OSDRV_S3L_DEPENDENCIES = linux
AMBARELLA_OSDRV_S3L_IAV_OFFSETS = INODE_I_CDEV:272 FILE_PRIVATE_DATA:112

define AMBARELLA_OSDRV_S3L_BUILD_CMDS
$(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) load_ucode
$(LINUX_MAKE_ENV) $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) \
M=$(@D)/abi abi_probe.s
for want in $(AMBARELLA_OSDRV_S3L_IAV_OFFSETS); do \
name=$${want%%:*}; \
got=$$(sed -n "s/^->$$name [#$$]*\([0-9]*\) .*/\1/p" $(@D)/abi/abi_probe.s); \
if [ "$$got" != "$${want#*:}" ]; then \
echo "ambarella-osdrv-s3l: $$name is '$$got' in this kernel," \
"iav.ko needs $${want#*:}: check the kernel config" >&2; \
exit 1; \
fi; \
done
endef

define AMBARELLA_OSDRV_S3L_INSTALL_TARGET_CMDS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-m := abi_probe.o
14 changes: 14 additions & 0 deletions general/package/legacy/ambarella-osdrv-s3l/src/abi/abi_probe.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
/*
* Not a module: Kbuild compiles this to assembly only, with the kernel's own
* headers and flags, so the package can read the offsets the prebuilt iav.ko
* depends on. See ambarella-osdrv-s3l.mk.
*/
#include <linux/fs.h>
#include <linux/kbuild.h>

void abi_probe(void)
{
DEFINE(INODE_I_CDEV, offsetof(struct inode, i_cdev));
DEFINE(FILE_PRIVATE_DATA, offsetof(struct file, private_data));
}
Loading