Commit 7fcc8afc authored by Krzysztof Sprzaczkowski's avatar Krzysztof Sprzaczkowski Committed by Jim Harris
Browse files

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



Prevent double RPC call causes app crash for iaa_scan_accel_module

The RPC iaa_scan_accel_module method may be performed to use
the IAA 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: I0cc5a9fca290b1fe1709d86064db34aa1e05ba76
Signed-off-by: default avatarKrzysztof Sprzaczkowski <krzysztof.sprzaczkowski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20787


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 99bebace
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ endif
# module/accel
DEPDIRS-accel_ioat := log ioat thread jsonrpc rpc accel
DEPDIRS-accel_dsa := log util idxd thread $(JSON_LIBS) accel trace
DEPDIRS-accel_iaa := log idxd thread $(JSON_LIBS) accel trace
DEPDIRS-accel_iaa := log util 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
DEPDIRS-accel_error := accel $(JSON_LIBS) thread util
+15 −3
Original line number Diff line number Diff line
@@ -330,13 +330,25 @@ attach_cb(void *cb_ctx, struct spdk_idxd_device *iaa)
	g_num_devices++;
}

void
int
accel_iaa_enable_probe(void)
{
	g_iaa_enable = true;
	int rc;

	if (g_iaa_enable) {
		return -EALREADY;
	}

	/* TODO initially only support user mode w/IAA */
	spdk_idxd_set_config(false);
	rc = spdk_idxd_set_config(false);
	if (rc != 0) {
		return rc;
	}

	spdk_accel_module_list_add(&g_iaa_module);
	g_iaa_enable = true;

	return 0;
}

static bool
+1 −1
Original line number Diff line number Diff line
@@ -8,6 +8,6 @@

#include "spdk/stdinc.h"

void accel_iaa_enable_probe(void);
int accel_iaa_enable_probe(void);

#endif /* SPDK_ACCEL_MODULE_IAA_H */
+10 −2
Original line number Diff line number Diff line
@@ -10,19 +10,27 @@
#include "spdk/event.h"
#include "spdk/stdinc.h"
#include "spdk/env.h"
#include "spdk/string.h"

static void
rpc_iaa_scan_accel_module(struct spdk_jsonrpc_request *request,
			  const struct spdk_json_val *params)
{
	int rc;

	if (params != NULL) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "iaa_scan_accel_module requires no parameters");
		return;
	}

	SPDK_NOTICELOG("Enabling IAA user-mode\n");
	accel_iaa_enable_probe();
	rc = accel_iaa_enable_probe();
	if (rc != 0) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		return;
	}

	SPDK_NOTICELOG("Enabled IAA user-mode\n");
	spdk_jsonrpc_send_bool_response(request, true);
}
SPDK_RPC_REGISTER("iaa_scan_accel_module", rpc_iaa_scan_accel_module, SPDK_RPC_STARTUP)