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

Fix driver build for linux 6.13 #269

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ AUTOCOMPAT := $(obj)/src/driver/linux_resource/autocompat.h
LINUX_RESOURCE := $(src)/src/driver/linux_resource
$(AUTOCOMPAT): $(LINUX_RESOURCE)/kernel_compat.sh $(LINUX_RESOURCE)/kernel_compat_funcs.sh
@mkdir -p $(@D)
($< -k $(CURDIR) $(if $(filter 1,$(V)),-v,-q) > $@) || (rm -f $@ && false)
($< -k $(realpath $(objtree)) $(if $(filter 1,$(V)),-v,-q) > $@) || (rm -f $@ && false)

mkdirs:
@mkdir -p $(obj)/src/lib/efhw
Expand Down Expand Up @@ -251,7 +251,7 @@ $(scripts): $(KBUILDTOP)/driver/linux/%.sh: src/driver/linux/%.sh

modules modules_install: $(OUTMAKEFILES)
$(Q)$(MAKE) -C $(KPATH) M=$(KBUILDTOP) \
"src=\$$(patsubst $(KBUILDTOP)%,$$PWD%,\$$(obj))" \
"src=\$$(patsubst $(KBUILDTOP)%,$$PWD%,\$$(realpath \$$(obj)))" \
"SRCPATH=$$PWD/src" \
'subdir-ccflags-y=$(subst ','\'',$(ONLOAD_CFLAGS))' \
MMAKE_IN_KBUILD=1 MMAKE_USE_KBUILD=1 MMAKE_NO_RULES=1 \
Expand Down
16 changes: 12 additions & 4 deletions src/driver/linux_onload/onload_kernel_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ ci_call_usermodehelper(char *path, char **argv, char **envp, int wait);
#endif


#ifndef get_file_rcu
/* Linux <= 4.0 */
#define get_file_rcu(x) atomic_long_inc_not_zero(&(x)->f_count)
#endif
static inline struct file *ci_get_file_rcu(struct file **f)
{
#ifdef EFRM_HAVE_GET_FILE_RCU_FUNC
return get_file_rcu(f);
#else
/* In linux < 6.7 get_file_rcu() was defined as a macro, like this:
* #define get_file_rcu(x) atomic_long_inc_not_zero(&(x)->f_count)
* Use the same implementation, but match new get_file_rcu() prototype. */
struct file *file = *f;
return atomic_long_inc_not_zero(&file->f_count) ? file : NULL;
#endif /* EFRM_HAVE_GET_FILE_RCU_FUNC */
}

/* init_timer() was removed in Linux 4.15, with timer_setup()
* replacing it */
Expand Down
2 changes: 1 addition & 1 deletion src/driver/linux_onload/onloadfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ oo_create_fd(tcp_helper_resource_t* thr, oo_sp ep_id, int flags,

if( _filp && *_filp ) {
rcu_read_lock();
rc = get_file_rcu(*_filp);
rc = !IS_ERR_OR_NULL(ci_get_file_rcu(_filp));
rcu_read_unlock();
if( rc == 0 ) {
OO_DEBUG_TCPH(ci_log("%s: fd=%d reuses file", __FUNCTION__, fd));
Expand Down
1 change: 1 addition & 0 deletions src/driver/linux_resource/kernel_compat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ EFRM_HAVE_FOLLOW_PTE symbol follow_pte include/linux/mm.h
EFRM_HAVE_FOLLOW_PTE_VMA symtype follow_pte include/linux/mm.h int(struct vm_area_struct*, unsigned long, pte_t**, spinlock_t**)

EFRM_HAVE_LINUX_TPH_H file include/linux/pci-tph.h
EFRM_HAVE_GET_FILE_RCU_FUNC symtype get_file_rcu include/linux/fs.h struct file*(struct file __rcu **)

# TODO move onload-related stuff from net kernel_compat
" | grep -E -v -e '^#' -e '^$' | sed 's/[ \t][ \t]*/:/g'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/efthrm/tcp_helper_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ efab_tcp_helper_detach_file(tcp_helper_endpoint_t* ep,
filp = ep->file_ptr;
/* filp might be NULL if we raced with FD close, other than that
* filp is still valid even if close completed concurrently thanks to rcu_lock */
if( filp == NULL || ! get_file_rcu(filp) ) {
if( filp == NULL || IS_ERR_OR_NULL(ci_get_file_rcu(&filp)) ) {
/* filp is being freed concurrently, best to back off until it is completed */
OO_DEBUG_TCPH(ci_log("%s: pid=%d fd=%d => is being freed", __FUNCTION__, pid, fd));
CITP_STATS_NETIF_INC(&trs->netif, sock_attach_fd_detach_fail_soft);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/efthrm/tcp_helper_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static unsigned efab_linux_tcp_helper_fop_poll_tcp(struct file* filp,
efab_fop_poll__prime_if_needed(trs, tep_p,
SOCK_POLL_AWAITING_EVENTS(mask, wait),
enable_interrupts);
if( ! poll_does_not_wait(wait) && s->b.state == CI_TCP_CLOSED &&
if( wait && wait->_qproc && s->b.state == CI_TCP_CLOSED &&
tep_p->os_socket != NULL) {
/* From the closed state, handover is possible. We should add OS
* socket waitqueue to the poll table.
Expand Down