From 3961019e74da6ca90aa54af82ec60b05b3788515 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Mon, 17 Oct 2022 13:42:35 +0300 Subject: [PATCH] ib_srpt: Port to Linux kernel v6.1 Support for the following IB changes in the Linux kernel v6.1: - 91a3f14ec953 ("IB/cm: Remove the service_mask parameter from ib_cm_listen()") --- scripts/specialize-patch | 4 ++++ srpt/Makefile | 6 ++++++ srpt/conftest/cm_listen_2/Kbuild | 3 +++ srpt/conftest/cm_listen_2/cm_listen_2.c | 11 +++++++++++ srpt/src/ib_srpt.c | 5 ++++- 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 srpt/conftest/cm_listen_2/Kbuild create mode 100644 srpt/conftest/cm_listen_2/cm_listen_2.c diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 98289aa73..e5f508afd 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -100,6 +100,9 @@ function evaluate(stmnt, pattern, arg, op, result) { "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) \\&\\& " \ "RHEL_RELEASE_CODE -0 < 7 * 256 + 5)", stmnt) + gsub("defined\\(IB_CM_LISTEN_TAKES_THIRD_ARG\\)", + "(LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))", stmnt) + gsub("IB_CLIENT_ADD_ONE_RETURNS_INT", "(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) || " \ "RHEL_RELEASE_CODE -0 >= 8 * 256 + 4)", stmnt) @@ -441,6 +444,7 @@ function handle_if(evaluated) || $0 ~ "IB_CLIENT_ADD_ONE_RETURNS_INT" \ || $0 ~ "IB_CLIENT_REMOVE_TAKES_TWO_ARGS" \ || $0 ~ "IB_CM_LISTEN_TAKES_FOURTH_ARG" \ + || $0 ~ "IB_CM_LISTEN_TAKES_THIRD_ARG" \ || $0 ~ "IB_CREATE_CQ_HAS_INIT_ATTR" \ || $0 ~ "IB_PD_HAS_LOCAL_DMA_LKEY" \ || $0 ~ "IB_QUERY_GID_HAS_ATTR_ARG" \ diff --git a/srpt/Makefile b/srpt/Makefile index 5e398ea54..5f2a97a01 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -182,6 +182,12 @@ conftest/cm_listen/result-$(KVER).txt: \ echo "$(call run_conftest,cm_listen, \ -DIB_CM_LISTEN_TAKES_FOURTH_ARG)" >"$@" +conftest/cm_listen_2/result-$(KVER).txt: \ + conftest/cm_listen_2/cm_listen_2.c \ + conftest/cm_listen_2/Kbuild + echo "$(call run_conftest,cm_listen_2, \ + -DIB_CM_LISTEN_TAKES_THIRD_ARG)" >"$@" + conftest/create_cq/result-$(KVER).txt: \ conftest/create_cq/create_cq.c \ conftest/create_cq/Kbuild diff --git a/srpt/conftest/cm_listen_2/Kbuild b/srpt/conftest/cm_listen_2/Kbuild new file mode 100644 index 000000000..e9976646f --- /dev/null +++ b/srpt/conftest/cm_listen_2/Kbuild @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(CONFTEST_CFLAGS) $(LINUXINCLUDE) + +obj-m += cm_listen_2.o diff --git a/srpt/conftest/cm_listen_2/cm_listen_2.c b/srpt/conftest/cm_listen_2/cm_listen_2.c new file mode 100644 index 000000000..927af0b84 --- /dev/null +++ b/srpt/conftest/cm_listen_2/cm_listen_2.c @@ -0,0 +1,11 @@ +#include +#include + +static int __init modinit(void) +{ + return ib_cm_listen(NULL, 0, 0); +} + +module_init(modinit); + +MODULE_LICENSE("GPL"); diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index c62508a51..eec5f7f66 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -4403,9 +4403,12 @@ static int srpt_add_one(struct ib_device *device) * in the system as service_id; therefore, the target_id will change * if this HCA is gone bad and replaced by different HCA */ - ret = ib_cm_listen(sdev->cm_id, cpu_to_be64(srpt_service_guid), 0 + ret = ib_cm_listen(sdev->cm_id, cpu_to_be64(srpt_service_guid) #ifdef IB_CM_LISTEN_TAKES_FOURTH_ARG + , 0 , NULL +#elif defined(IB_CM_LISTEN_TAKES_THIRD_ARG) + , 0 #endif ); if (ret) {