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

Build xrt drivers on Linux 6.12-rc3 #8555

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dima-anet
Copy link

Problem solved by the commit

xrt doesn't build on linux kernels newer than v6.10

How problem was solved, alternative solutions (if any) and why they were rejected

Add more ifdefs, one patch generated with Сoccinelle.

What has been tested and how, request additional testing if necessary

So far, I only build tested on v6.12-rc3.
And local sources yet use 2023.1 release, so it might not fix all build issues (though, the biggest diff I generated on the latest master).

Risks (if any) associated the changes in the commit

For older kernels this should be no-op as guarded by ifdefs.

Addresses the following compilation errors:

> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl//../include/xrt_cu.h:416:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
>   416 | static void inline xrt_cu_enable_intr(struct xrt_cu *xcu, u32 intr_type)
>       | ^~~~~~
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl//../include/xrt_cu.h:422:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
>   422 | static void inline xrt_cu_disable_intr(struct xrt_cu *xcu, u32 intr_type)
>       | ^~~~~~
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl//../include/xrt_cu.h:428:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
>   428 | static u32 inline xrt_cu_clear_intr(struct xrt_cu *xcu)
>       | ^~~~~~
> In file included from XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_subdev.c:20:
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_drv.h: In function 'xocl_subdev_priv_alloc':
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_drv.h:456:16: error: implicit declaration of function 'vzalloc'; did you mean 'kzalloc'? [-Werror=implicit-function-declaration]
>   456 |         priv = vzalloc(sizeof(*priv) + size);
>       |                ^~~~~~~
>       |                kzalloc
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_subdev.c:272:17: error: implicit declaration of function 'vfree'; did you mean 'kvfree'? [-Werror=implicit-function-declaration]
>   272 |                 vfree(subdev_info);
>       |                 ^~~~~
>       |                 kvfree
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_subdev.c: In function 'xocl_request_firmware':
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_subdev.c:2208:16: error: implicit declaration of function 'vmalloc'; di
> mean 'kmalloc'? [-Werror=implicit-function-declaration]
>  2208 |         *buf = vmalloc(fw->size);
>       |                ^~~~~~~
>       |                kmalloc
> XRT-202310.2.15.225/build/Release/usr/src/xrt-2.15.0/driver/xocl/userpf/../xocl_debug.c:148:19: error: 'no_llseek' undeclared here (not in a function); did you mean 'noop_llseek'?
>   148 |         .llseek = no_llseek,
>       |                   ^~~~~~~~~
>       |                   noop_llseek

Signed-off-by: Dmitry Safonov <[email protected]>
See the upstream linux commit 0edb555a65d1 ("platform: Make
platform_driver::remove() return void").

Generated with the following Coccinelle script:
> @rule_remove@
> identifier D;
> identifier func;
> @@
> static struct platform_driver D = {
> ...,
>         .remove         = func,
> ...
> };
> @rule_func depends on rule_remove@
> identifier pdev;
> identifier rule_remove.func;
> fresh identifier Fn = "__" ## func;
> @@
> static int
> - func(struct platform_device *pdev)
> + Fn(struct platform_device *pdev)
> {
> ...
> }
> +
> + #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
> + void func(struct platform_device *pdev)
> + {
> +        Fn(pdev);
> + }
> + #else
> + #define func Fn
> + #endif

Though, it added new function with a brace on the same line, so I ran
checkpath.pl --fix on the resulting patch.
And then it seems there is either bug in spatch or it doesn't know
how to deal with 'static', which prevented me from adding
'static void func(...)', so on top of checkpatch.pl, I ran
> sed 's/^+\(void [[:print:]]\+_remove(struct platform_device \*pdev)\)$/+static \1/'

And yet the last bit is also manual: I had to remove a stray semicolon,
that was living after ps_remove() last curly brace, which post-spatch
became '#endif;' and the compiler didn't quite liked it.

Signed-off-by: Dmitry Safonov <[email protected]>
The driver doesn't have to declare I2C_CLASS_SPD support as it supports
I2C_CLASS_HWMON, see linux commit 9fd12f385720 ("i2c: Don't let i2c adapters
declare I2C_CLASS_SPD support if they support I2C_CLASS_HWMON").

Signed-off-by: Dmitry Safonov <[email protected]>
In linux v6.10 https://git.kernel.org/linus/1788cf6a91d9 switched tty port's
from circ_buf to kfifo.

Signed-off-by: Dmitry Safonov <[email protected]>
@gbuildx
Copy link
Collaborator

gbuildx commented Oct 22, 2024

dima-anet - is not a collaborator
Can XRT admins please validate PR

@gbuildx
Copy link
Collaborator

gbuildx commented Oct 22, 2024

Can one of the admins verify this patch?

@dima-anet
Copy link
Author

Also just to note: I fixed only build-errors, but there are also quite some warnings. Mostly about inline declarations and missed static keywords or extern declarations.

@maxzhen maxzhen requested a review from houlz0507 October 22, 2024 15:59
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

Successfully merging this pull request may close these issues.

4 participants