Commit 3cac0518 authored by Krzysztof Sprzaczkowski's avatar Krzysztof Sprzaczkowski Committed by Tomasz Zawadzki
Browse files

module/accel: Prevent double RPC call causes app crash (dsa_scan_accel_module)



Prevent double RPC call causes app crash for dsa_scan_accel_module

The RPC dsa_scan_accel_module method may be performed to use
the DSA Module. It should be called before starting the framework,
but only the first call should take effect, next calls should
provide relevant information for a user. In this fix will be an RPC
error code with information that 'the operation is already in progress'.

Fixes issue #3174

Change-Id: I4dcf75afcf0987b68a03722a10fefb3a67ccd02d
Signed-off-by: default avatarKrzysztof Sprzaczkowski <krzysztof.sprzaczkowski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20786


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
parent 726c8313
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -112,8 +112,10 @@ void spdk_idxd_detach(struct spdk_idxd_device *idxd);
 * Sets the IDXD configuration.
 *
 * \param kernel_mode true if using kernel driver.
 *
 * \return 0 on success, negative errno on failure.
 */
void spdk_idxd_set_config(bool kernel_mode);
int spdk_idxd_set_config(bool kernel_mode);

/**
 * Build and submit an idxd memory copy request.
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 10
SO_VER := 11
SO_MINOR := 0

C_SRCS = idxd.c idxd_user.c
+5 −3
Original line number Diff line number Diff line
@@ -342,7 +342,7 @@ idxd_get_impl_by_name(const char *impl_name)
	return NULL;
}

void
int
spdk_idxd_set_config(bool kernel_mode)
{
	struct spdk_idxd_impl *tmp;
@@ -356,15 +356,17 @@ spdk_idxd_set_config(bool kernel_mode)
	if (g_idxd_impl != NULL && g_idxd_impl != tmp) {
		SPDK_ERRLOG("Cannot change idxd implementation after devices are initialized\n");
		assert(false);
		return;
		return -EALREADY;
	}
	g_idxd_impl = tmp;

	if (g_idxd_impl == NULL) {
		SPDK_ERRLOG("Cannot set the idxd implementation with %s mode\n",
			    kernel_mode ? KERNEL_DRIVER_NAME : USERSPACE_DRIVER_NAME);
		return;
		return -EINVAL;
	}

	return 0;
}

static void
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ endif

# module/accel
DEPDIRS-accel_ioat := log ioat thread jsonrpc rpc accel
DEPDIRS-accel_dsa := log idxd thread $(JSON_LIBS) accel trace
DEPDIRS-accel_dsa := log util idxd thread $(JSON_LIBS) accel trace
DEPDIRS-accel_iaa := log idxd thread $(JSON_LIBS) accel trace
DEPDIRS-accel_dpdk_cryptodev := log thread $(JSON_LIBS) accel util
DEPDIRS-accel_dpdk_compressdev := log thread $(JSON_LIBS) accel util
+15 −3
Original line number Diff line number Diff line
@@ -365,13 +365,25 @@ attach_cb(void *cb_ctx, struct spdk_idxd_device *idxd)
	g_num_devices++;
}

void
int
accel_dsa_enable_probe(bool kernel_mode)
{
	int rc;

	if (g_dsa_enable) {
		return -EALREADY;
	}

	rc = spdk_idxd_set_config(kernel_mode);
	if (rc != 0) {
		return rc;
	}

	spdk_accel_module_list_add(&g_dsa_module);
	g_kernel_mode = kernel_mode;
	g_dsa_enable = true;
	spdk_idxd_set_config(g_kernel_mode);
	spdk_accel_module_list_add(&g_dsa_module);

	return 0;
}

static bool
Loading