Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.

Commit

Permalink
[HACK] msm: ipa: Enhance IPA_EMULATION guarding to avoid undefined re…
Browse files Browse the repository at this point in the history
…ferences

When compiling the kernel using GCC LTO, we hit the following errors at link time:

/usr/lib/gcc/aarch64-linux-gnu/11.2.0/../../../../aarch64-linux-gnu/bin/ld: /tmp/cclIai5s.ltrans87.ltrans.o: in function `ipa_pci_remove':
<artificial>:(.text+0xfc): undefined reference to `ipa_ut_module_exit'
/usr/lib/gcc/aarch64-linux-gnu/11.2.0/../../../../aarch64-linux-gnu/bin/ld: /tmp/cclIai5s.ltrans87.ltrans.o: in function `ipa_pci_probe':
<artificial>:(.text+0x2310c): undefined reference to `ipa_ut_module_init'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/0ctobot/Android/OnePlus/kebab/neutrino_kernel_oneplus_sm8250/Makefile:1211: vmlinux] Error 1
make: *** [Makefile:146: sub-make] Error 2

This seems to be a result of DCE, as these functions become
effectively unreachable with !CONFIG_IPA_UT and the compiler has
optimized out code for if-statements that it can prove are always
false.

This little hack may not jibe perfectly with what the original
author had in mind, but it's sufficient for our usecase.

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
0ctobot committed Aug 30, 2021
1 parent be026b4 commit d827d1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/platform/msm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ config MSM_11AD

config IPA_EMULATION
bool "IPA on X86 Linux (IPA emulation support)"
depends on X86 && IPA3
depends on X86 && IPA3 && IPA_UT
help
This options is used only when building the X86 version of
the IPA/GSI driver. On this mode, IPA driver will be probed
Expand Down
10 changes: 6 additions & 4 deletions drivers/platform/msm/ipa/ipa_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@

#if defined(CONFIG_IPA_EMULATION)
static bool running_emulation = true;
#elif defined(CONFIG_PCI)
static bool running_emulation;
#endif

static enum ipa_hw_type ipa_api_hw_type;
Expand Down Expand Up @@ -3196,7 +3194,7 @@ static const struct pci_error_handlers ipa_pci_err_handler = {
.resume = ipa_pci_io_resume,
};

static struct pci_driver ipa_pci_driver = {
static struct pci_driver ipa_pci_driver __maybe_unused = {
.name = ipa_pci_driver_name,
.id_table = ipa_pci_tbl,
.probe = ipa_pci_probe,
Expand Down Expand Up @@ -3848,16 +3846,20 @@ static int ipa_pci_probe(
if (result && result != -EPROBE_DEFER)
pr_err("ipa: ipa3_pci_drv_probe failed\n");

#if defined(CONFIG_IPA_EMULATION)
if (running_emulation)
ipa_ut_module_init();
#endif

return result;
}

static void ipa_pci_remove(struct pci_dev *pci_dev)
{
#if defined(CONFIG_IPA_EMULATION)
if (running_emulation)
ipa_ut_module_exit();
#endif
}

static void ipa_pci_shutdown(struct pci_dev *pci_dev)
Expand All @@ -3883,7 +3885,7 @@ static void ipa_pci_io_resume(struct pci_dev *pci_dev)
static int __init ipa_module_init(void)
{
pr_debug("IPA module init\n");
#ifdef CONFIG_PCI
#if defined(CONFIG_PCI) && defined(CONFIG_IPA_EMULATION)
if (running_emulation) {
/* Register as a PCI device driver */
return pci_register_driver(&ipa_pci_driver);
Expand Down

0 comments on commit d827d1f

Please sign in to comment.