Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Target.ensure_kconfig() #655

Open
douglas-raillard-arm opened this issue Oct 18, 2023 · 1 comment
Open

Add Target.ensure_kconfig() #655

douglas-raillard-arm opened this issue Oct 18, 2023 · 1 comment

Comments

@douglas-raillard-arm
Copy link
Contributor

douglas-raillard-arm commented Oct 18, 2023

Code sometimes need to check if some kernel config options is enabled. For a lot of them, checking they are =y is actually stricter than necessary, but allowing =m means the check can succeed without the feature being actually available if the corresponding module was not loaded.

To alleviate that, we could have a Target.ensure_kconfig() method that:

  • Checks if the option =y and if so returns
  • if =n or config does not exist at all, raises an exception
  • if =m, tried to lsmod/modprobe the corresponding module and raises if that fails.

Unfortunately, there is no generic way of knowing the module name associated with a given kconfig, so the mapping has hard coded. However, we can have a maintenance script that finds a mapping for a given kernel source tree by looking for obj-$(CONFIG_FOO) += the module.o anothermodule.o and merge the result with the existing mapping in devlib.

@douglas-raillard-arm
Copy link
Contributor Author

Given the behavior of current Android GKI kernels, we cannot rely on =N meaning the feature is not available in a module, as the module may still be available (/proc/config.gz can lie in this way in Android apparently due to the way GKI build system works as reported by @patrik-arm). Therefore, the behavior we want is:

  • Checks if the option =y and if so returns positively
  • Otherwise, try to lsmod/modprobe the corresponding module and raises if that fails or if we don't know what module to load.

If the mapping config<->module name is not know for the feature, the function should raise an exception. It might be a good idea to allow the user to pass an expected module name so they can work around an incomplete mapping provided by devlib.

Since this is definitely a bug in Android, maybe we should check for the target type and use the sane behavior (=N means it's not available) on non-android targets, but that may mean some code working on mainline kernel would break on android targets, whereas having a single path working for the buggy case will ensure user code works in both cases.

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

No branches or pull requests

1 participant