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

On latest RHEL8, dkms fails to build #2

Open
davidtluong opened this issue Apr 14, 2023 · 5 comments
Open

On latest RHEL8, dkms fails to build #2

davidtluong opened this issue Apr 14, 2023 · 5 comments

Comments

@davidtluong
Copy link

This is what's happening when trying to install on lastest rhel8:

DKMS make.log for gasket-0.0.git.245.66aa4629 for kernel 4.18.0-425.19.2.el8_7.x86_64 (x86_64)
Fri Apr 14 10:29:56 EDT 2023
make -C "/lib/modules/4.18.0-425.19.2.el8_7.x86_64/build" M="/var/lib/dkms/gasket/0.0.git.245.66aa4629/build" modules
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/usr/src/kernels/4.18.0-425.19.2.el8_7.x86_64'
  CC [M]  /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_core.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_ioctl.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_interrupt.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_page_table.o
/var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_page_table.c: In function ‘gasket_perform_mapping’:
/var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_page_table.c:541:48: error: passing argument 1 of ‘sg_page_iter_dma_address’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    ptes[i].dma_addr = sg_page_iter_dma_address(sg_iter);
                                                ^~~~~~~
In file included from ./include/linux/dmapool.h:14,
                 from ./include/linux/pci.h:1567,
                 from /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_page_table.h:15,
                 from /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_page_table.c:42:
./include/linux/scatterlist.h:445:51: note: expected ‘struct sg_dma_page_iter *’ but argument is of type ‘struct sg_page_iter *’
 sg_page_iter_dma_address(struct sg_dma_page_iter *dma_iter)
                          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:318: /var/lib/dkms/gasket/0.0.git.245.66aa4629/build/gasket_page_table.o] Error 1
make[1]: *** [Makefile:1585: _module_/var/lib/dkms/gasket/0.0.git.245.66aa4629/build] Error 2
make[1]: Leaving directory '/usr/src/kernels/4.18.0-425.19.2.el8_7.x86_64'
make: *** [Makefile:15: all] Error 2
@davidtluong
Copy link
Author

My fix for this was:

sudo vi +540 /var/lib/dkms/gasket/0.0.git.245.66aa4629/source/gasket_page_table.c

Changing the 5 to a 4 so it doesn't handle the if and goes to the else. Seems that RHEL has sent the corresponding patch through to update sg_page_iter_dma_address

@abeeson
Copy link

abeeson commented Nov 8, 2023

I'm still seeing this issue on RHEL 8 (Rocky specifically) on kernel 4.18.0-477.27.1.el8_8.x86_64

I had to apply this fix in the comment above, as well as the DMA_BUF call on line 57 was also causing problems, reverting the line on 56 to:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)

From this PR:
09385d4

Resolved it, avoiding that line and letting the modules compile OK.

Hope this helps somebody else, not sure why its failing for us, as far as I can tell that should now be OK for RHEL 8.....

@kyleishie
Copy link

I'm still seeing this issue on RHEL 8 (Rocky specifically) on kernel 4.18.0-477.27.1.el8_8.x86_64

I had to apply this fix in the comment above, as well as the DMA_BUF call on line 57 was also causing problems, reverting the line on 56 to: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)

From this PR: 09385d4

Resolved it, avoiding that line and letting the modules compile OK.

Hope this helps somebody else, not sure why its failing for us, as far as I can tell that should now be OK for RHEL 8.....

This solved it for me. Thanks @abeeson and @rh-dluong

@cyqsimon
Copy link

Damn. Fix one problem, introduce five others.

I was the one who raised the issue that led to this change: google#14. It was supposed to be a more elegant solution than the version-based conditionals, which we were trying our hardest to get rid of.

Also please disregard the incorrect autolinked PR. That one fixes RHEL9 backport issues, not this one.

@cyqsimon
Copy link

So I did some brief investigation; two problems here:

Problem 1: Macro MODULE_IMPORT_NS is not available before 5.4

/var/lib/dkms/gasket/0.0.git.256.b6a7c6d8/build/gasket_page_table.c:57:1: warning: data definition has no type or storage class
 MODULE_IMPORT_NS(DMA_BUF);
 ^~~~~~~~~~~~~~~~
/var/lib/dkms/gasket/0.0.git.256.b6a7c6d8/build/gasket_page_table.c:57:1: error: type defaults to ‘int’ in declaration of ‘MODULE_IMPORT_NS’ [-Werror=implicit-int]
/var/lib/dkms/gasket/0.0.git.256.b6a7c6d8/build/gasket_page_table.c:57:1: warning: parameter names (without types) in function declaration

The missing macro causes the compiler to see this as a function declaration with implicit return type.

Proposed fix (this probably belongs in upstream):

diff --git a/src/gasket_page_table.c b/src/gasket_page_table.c
index c9067cb..641735c 100644
--- a/src/gasket_page_table.c
+++ b/src/gasket_page_table.c
@@ -53,7 +53,7 @@
 #include <linux/version.h>
 #include <linux/vmalloc.h>
 
-#if __has_include(<linux/dma-buf.h>)
+#if __has_include(<linux/dma-buf.h>) && defined MODULE_IMPORT_NS
 MODULE_IMPORT_NS(DMA_BUF);
 #endif

Problem 2: RHEL8 backports changes in 5.1, breaking conditional compilation

/var/lib/dkms/gasket/0.0.git.256.b6a7c6d8/build/gasket_page_table.c: In function ‘gasket_perform_mapping’:
/var/lib/dkms/gasket/0.0.git.256.b6a7c6d8/build/gasket_page_table.c:541:48: error: passing argument 1 of ‘sg_page_iter_dma_address’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    ptes[i].dma_addr = sg_page_iter_dma_address(sg_iter);
                                                ^~~~~~~

Proposed fix:

diff --git a/src/gasket_page_table.c b/src/gasket_page_table.c
index c9067cb..396975d 100644
--- a/src/gasket_page_table.c
+++ b/src/gasket_page_table.c
@@ -537,7 +537,9 @@ static int gasket_perform_mapping(struct gasket_page_table *pg_tbl,
 				return -EINVAL;
 
 			/* Page already mapped for DMA. */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) && \
+  /* First reported for 8.7; could be earlier */ \
+  (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8, 7))
 			ptes[i].dma_addr = sg_page_iter_dma_address(sg_iter);
 #else
 			ptes[i].dma_addr = sg_page_iter_dma_address(

With both patches applied it compiles without warnings or errors. Tested with Rocky8.10.

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

4 participants