Blame opae-libs/plugins/xfpga/reconf.c

Packit 534379
// Copyright(c) 2017-2020, Intel Corporation
Packit 534379
//
Packit 534379
// Redistribution  and  use  in source  and  binary  forms,  with  or  without
Packit 534379
// modification, are permitted provided that the following conditions are met:
Packit 534379
//
Packit 534379
// * Redistributions of  source code  must retain the  above copyright notice,
Packit 534379
//   this list of conditions and the following disclaimer.
Packit 534379
// * Redistributions in binary form must reproduce the above copyright notice,
Packit 534379
//   this list of conditions and the following disclaimer in the documentation
Packit 534379
//   and/or other materials provided with the distribution.
Packit 534379
// * Neither the name  of Intel Corporation  nor the names of its contributors
Packit 534379
//   may be used to  endorse or promote  products derived  from this  software
Packit 534379
//   without specific prior written permission.
Packit 534379
//
Packit 534379
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 534379
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO,  THE
Packit 534379
// IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 534379
// ARE DISCLAIMED.  IN NO EVENT  SHALL THE COPYRIGHT OWNER  OR CONTRIBUTORS BE
Packit 534379
// LIABLE  FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR
Packit 534379
// CONSEQUENTIAL  DAMAGES  (INCLUDING,  BUT  NOT LIMITED  TO,  PROCUREMENT  OF
Packit 534379
// SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE,  DATA, OR PROFITS;  OR BUSINESS
Packit 534379
// INTERRUPTION)  HOWEVER CAUSED  AND ON ANY THEORY  OF LIABILITY,  WHETHER IN
Packit 534379
// CONTRACT,  STRICT LIABILITY,  OR TORT  (INCLUDING NEGLIGENCE  OR OTHERWISE)
Packit 534379
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  EVEN IF ADVISED OF THE
Packit 534379
// POSSIBILITY OF SUCH DAMAGE.
Packit 534379
Packit 534379
#ifdef HAVE_CONFIG_H
Packit 534379
#include <config.h>
Packit 534379
#endif // HAVE_CONFIG_H
Packit 534379
Packit 534379
#include <string.h>
Packit 534379
#include <stdio.h>
Packit 534379
#include <stdlib.h>
Packit 534379
#include <ctype.h>
Packit 534379
#include <limits.h>
Packit 534379
#include <sys/types.h>
Packit 534379
#include <sys/stat.h>
Packit 534379
Packit 534379
#include "xfpga.h"
Packit 534379
#include "bitstream_int.h"
Packit 534379
#include "common_int.h"
Packit 534379
#include "opae_drv.h"
Packit 534379
#include "usrclk/user_clk_pgm_uclock.h"
Packit 534379
Packit 534379
#include "reconf_int.h"
Packit 534379
// sysfs attributes
Packit 534379
#define PORT_SYSFS_ERRORS     "errors/errors"
Packit 534379
#define PORT_SYSFS_ERR_CLEAR  "errors/clear"
Packit 534379
#define PWRMGMT_THRESHOLD1    "power_mgmt/threshold1"
Packit 534379
#define PWRMGMT_THRESHOLD2    "power_mgmt/threshold2"
Packit 534379
Packit 534379
// Max power values
Packit 534379
#define FPGA_BBS_IDLE_POWER   30            // watts
Packit 534379
#define FPGA_MAX_POWER        90            // watts
Packit 534379
#define FPGA_GBS_MAX_POWER    60            // watts
Packit 534379
#define FPGA_THRESHOLD2(x)    ((x*10)/100)  // threshold1 + 10%
Packit 534379
Packit 534379
#pragma pack(push, 1)
Packit 534379
// GBS Header
Packit 534379
struct bitstream_header {
Packit 534379
	uint32_t magic;
Packit 534379
	uint64_t ifid_l;
Packit 534379
	uint64_t ifid_h;
Packit 534379
};
Packit 534379
#pragma pack(pop)
Packit 534379
Packit 534379
// Reconnfigure Error CSR
Packit 534379
struct reconf_error {
Packit 534379
	union {
Packit 534379
		uint64_t csr;
Packit 534379
		struct {
Packit 534379
			uint64_t  reconf_operation_error:1;                   /* PR operation error detected */
Packit 534379
			uint64_t  reconf_CRC_error:1;                         /* PR CRC error detected*/
Packit 534379
			uint64_t  reconf_incompatible_bitstream_error:1;      /* PR incompatible bitstream error detected */
Packit 534379
			uint64_t  reconf_IP_protocol_error:1;                 /* PR IP protocol error detected */
Packit 534379
			uint64_t  reconf_FIFO_overflow_error:1;               /* PR FIFO overflow error detected */
Packit 534379
			uint64_t  reconf_timeout_error:1;                     /* PR timeout error detected */
Packit 534379
			uint64_t  reconf_secure_load_error:1;                 /* PR secure load error detected */
Packit 534379
			uint64_t  rsvd:57;                                    /* Reserved */
Packit 534379
		};
Packit 534379
	};
Packit 534379
};
Packit 534379
Packit 534379
Packit 534379
STATIC fpga_result validate_bitstream(fpga_handle handle,
Packit 534379
			const uint8_t *bitstream, size_t bitstream_len,
Packit 534379
			int *header_len)
Packit 534379
{
Packit 534379
	if (bitstream == NULL) {
Packit 534379
		OPAE_MSG("Bitstream is NULL");
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
Packit 534379
	if (bitstream_len <= 0 ||
Packit 534379
		bitstream_len <= sizeof(struct bitstream_header)) {
Packit 534379
		OPAE_MSG("Invalid bitstream size");
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
Packit 534379
	if (check_bitstream_guid(bitstream) == FPGA_OK) {
Packit 534379
		*header_len = get_bitstream_header_len(bitstream);
Packit 534379
Packit 534379
		if (*header_len < 0) {
Packit 534379
			OPAE_MSG("Invalid bitstream header length");
Packit 534379
			return FPGA_EXCEPTION;
Packit 534379
		}
Packit 534379
Packit 534379
		if (validate_bitstream_metadata(handle, bitstream) != FPGA_OK) {
Packit 534379
			OPAE_MSG("Invalid JSON data");
Packit 534379
			return FPGA_EXCEPTION;
Packit 534379
		}
Packit 534379
Packit 534379
		return FPGA_OK;
Packit 534379
	} else {
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
}
Packit 534379
Packit 534379
Packit 534379
// open child accelerator exclusively - it not, it's busy!
Packit 534379
STATIC fpga_result open_accel(fpga_handle handle, fpga_handle *accel)
Packit 534379
{
Packit 534379
	fpga_result result                = FPGA_OK;
Packit 534379
	fpga_result destroy_result        = FPGA_OK;
Packit 534379
	struct _fpga_handle *_handle      = (struct _fpga_handle *)handle;
Packit 534379
	fpga_token token = NULL;
Packit 534379
	fpga_properties props;
Packit 534379
	uint32_t matches = 0;
Packit 534379
Packit 534379
	if (_handle == NULL) {
Packit 534379
		OPAE_ERR("Invalid handle");
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
Packit 534379
	if (_handle->token == NULL) {
Packit 534379
		OPAE_ERR("Invalid token within handle");
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
Packit 534379
	result = xfpga_fpgaGetProperties(NULL, &props;;
Packit 534379
	if (result != FPGA_OK)
Packit 534379
		return result;
Packit 534379
Packit 534379
	result = fpgaPropertiesSetParent(props, _handle->token);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Error setting parent in properties.");
Packit 534379
		goto free_props;
Packit 534379
	}
Packit 534379
Packit 534379
	// TODO: Use slot number as part of filter
Packit 534379
	//       We only want to query for accelerators for the
Packit 534379
	//       slot being reconfigured
Packit 534379
	result = xfpga_fpgaEnumerate(&props, 1, &token, 1, &matches);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Error enumerating for accelerator to reconfigure");
Packit 534379
		goto free_props;
Packit 534379
	}
Packit 534379
Packit 534379
	if (matches == 0) {
Packit 534379
		OPAE_ERR("No accelerator found to reconfigure");
Packit 534379
		result = FPGA_BUSY;
Packit 534379
		goto destroy_token;
Packit 534379
	}
Packit 534379
Packit 534379
	result = xfpga_fpgaOpen(token, accel, 0);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Could not open accelerator for given slot");
Packit 534379
		goto destroy_token;
Packit 534379
	}
Packit 534379
Packit 534379
destroy_token:
Packit 534379
	destroy_result = xfpga_fpgaDestroyToken(&token);
Packit 534379
	if (destroy_result != FPGA_OK)
Packit 534379
		OPAE_ERR("Error destroying a token");
Packit 534379
Packit 534379
free_props:
Packit 534379
	destroy_result = fpgaDestroyProperties(&props;;
Packit 534379
	if (destroy_result != FPGA_OK)
Packit 534379
		OPAE_ERR("Error destroying properties");
Packit 534379
Packit 534379
	if (result != FPGA_OK || destroy_result != FPGA_OK)
Packit 534379
		return result != FPGA_OK ? result : destroy_result;
Packit 534379
Packit 534379
	return FPGA_OK;
Packit 534379
}
Packit 534379
Packit 534379
Packit 534379
// clears port errors
Packit 534379
STATIC fpga_result clear_port_errors(fpga_handle handle)
Packit 534379
{
Packit 534379
	char sysfs_path[PATH_MAX] = {0};
Packit 534379
	fpga_result result        = FPGA_OK;
Packit 534379
	uint64_t error            = 0 ;
Packit 534379
Packit 534379
	result = sysfs_get_port_error_path(handle, sysfs_path);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to get port errors path");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	// Read port error.
Packit 534379
	result = sysfs_read_u64(sysfs_path, &error);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to read port errors");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	result = sysfs_get_port_error_clear_path(handle, sysfs_path);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to get port errors clear path");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	// Clear port error.
Packit 534379
	result = sysfs_write_u64(sysfs_path, error);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to clear port errors");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	return result;
Packit 534379
}
Packit 534379
Packit 534379
// set afu user clock
Packit 534379
fpga_result set_afu_userclock(fpga_handle handle,
Packit 534379
				uint64_t usrlclock_high,
Packit 534379
				uint64_t usrlclock_low)
Packit 534379
{
Packit 534379
	char sysfs_path[PATH_MAX]         = {0};
Packit 534379
	fpga_result result                = FPGA_OK;
Packit 534379
	uint64_t userclk_high             = 0;
Packit 534379
	uint64_t userclk_low              = 0;
Packit 534379
Packit 534379
	// Read port sysfs path
Packit 534379
	result = get_port_sysfs(handle, sysfs_path);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to get port syfs path");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	// set user clock
Packit 534379
	result = set_userclock(sysfs_path, usrlclock_high, usrlclock_low);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to set user clock");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	// read user clock
Packit 534379
	result = get_userclock(sysfs_path, &userclk_high, &userclk_low);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to get user clock");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	return result;
Packit 534379
}
Packit 534379
Packit 534379
// Sets FPGA threshold power values
Packit 534379
fpga_result set_fpga_pwr_threshold(fpga_handle handle,
Packit 534379
					uint64_t gbs_power)
Packit 534379
{
Packit 534379
	char sysfs_path[SYSFS_PATH_MAX]   = { 0, };
Packit 534379
	fpga_result result                = FPGA_OK;
Packit 534379
	uint64_t fpga_power               = 0;
Packit 534379
	struct _fpga_token  *_token       = NULL;
Packit 534379
	struct _fpga_handle *_handle      = (struct _fpga_handle *)handle;
Packit 534379
Packit 534379
	if (_handle == NULL) {
Packit 534379
		OPAE_ERR("Invalid handle");
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
Packit 534379
	_token = (struct _fpga_token *)_handle->token;
Packit 534379
	if (_token == NULL) {
Packit 534379
		OPAE_ERR("Invalid token within handle");
Packit 534379
		return FPGA_INVALID_PARAM;
Packit 534379
	}
Packit 534379
Packit 534379
	// Set max power if not specified by gbs
Packit 534379
	if (gbs_power == 0) {
Packit 534379
		gbs_power = FPGA_GBS_MAX_POWER;
Packit 534379
	}
Packit 534379
Packit 534379
	// verify gbs power limits
Packit 534379
	if (gbs_power > FPGA_GBS_MAX_POWER) {
Packit 534379
		OPAE_ERR("Invalid GBS power value");
Packit 534379
		result = FPGA_NOT_SUPPORTED;
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	// FPGA threshold1 = BBS Idle power + GBS power
Packit 534379
	fpga_power = gbs_power + FPGA_BBS_IDLE_POWER;
Packit 534379
	if (fpga_power > FPGA_MAX_POWER) {
Packit 534379
		OPAE_ERR("Total power requirements exceed FPGA maximum");
Packit 534379
		result = FPGA_NOT_SUPPORTED;
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	// set fpga threshold 1
Packit 534379
	if (snprintf(sysfs_path, sizeof(sysfs_path),
Packit 534379
		     "%s/%s", _token->sysfspath, PWRMGMT_THRESHOLD1) < 0) {
Packit 534379
		OPAE_ERR("snprintf buffer overflow");
Packit 534379
		result = FPGA_EXCEPTION;
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	OPAE_DBG(" FPGA Threshold1             :%ld watts\n", fpga_power);
Packit 534379
Packit 534379
	result = sysfs_write_u64(sysfs_path, fpga_power);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to write power threshold 1");
Packit 534379
		return result;
Packit 534379
	}
Packit 534379
Packit 534379
	return result;
Packit 534379
}
Packit 534379
Packit 534379
fpga_result __XFPGA_API__ xfpga_fpgaReconfigureSlot(fpga_handle fpga,
Packit 534379
						uint32_t slot,
Packit 534379
						const uint8_t *bitstream,
Packit 534379
						size_t bitstream_len,
Packit 534379
						int flags)
Packit 534379
{
Packit 534379
	struct _fpga_handle *_handle    = (struct _fpga_handle *)fpga;
Packit 534379
	fpga_result result              = FPGA_OK;
Packit 534379
	struct reconf_error  error      = { {0} };
Packit 534379
	struct gbs_metadata  metadata;
Packit 534379
	int bitstream_header_len        = 0;
Packit 534379
	int err                         = 0;
Packit 534379
	fpga_handle accel               = NULL;
Packit 534379
	struct stat st;
Packit 534379
Packit 534379
	result = handle_check_and_lock(_handle);
Packit 534379
	if (result)
Packit 534379
		return result;
Packit 534379
Packit 534379
	if (_handle->fddev < 0) {
Packit 534379
		OPAE_ERR("Invalid handle file descriptor");
Packit 534379
		result = FPGA_INVALID_PARAM;
Packit 534379
		goto out_unlock;
Packit 534379
	}
Packit 534379
Packit 534379
	if (validate_bitstream(fpga, bitstream, bitstream_len,
Packit 534379
				&bitstream_header_len) != FPGA_OK) {
Packit 534379
		OPAE_MSG("Invalid bitstream");
Packit 534379
		result = FPGA_INVALID_PARAM;
Packit 534379
		goto out_unlock;
Packit 534379
	}
Packit 534379
Packit 534379
	// error out if "force" flag is NOT indicated
Packit 534379
	// and the resource is in use
Packit 534379
	if (!(flags & FPGA_RECONF_FORCE)) {
Packit 534379
		result = open_accel(fpga, &accel);
Packit 534379
		if (result != FPGA_OK) {
Packit 534379
			OPAE_ERR("Accelerator in use or not found");
Packit 534379
			goto out_unlock;
Packit 534379
		}
Packit 534379
	}
Packit 534379
Packit 534379
	// Clear port errors
Packit 534379
	result = clear_port_errors(fpga);
Packit 534379
	if (result != FPGA_OK) {
Packit 534379
		OPAE_ERR("Failed to clear port errors.");
Packit 534379
	}
Packit 534379
Packit 534379
	if (get_bitstream_json_len(bitstream) > 0) {
Packit 534379
		enum fpga_hw_type hw_type = FPGA_HW_UNKNOWN;
Packit 534379
Packit 534379
		// Read GBS json metadata
Packit 534379
		memset(&metadata, 0, sizeof(metadata));
Packit 534379
		result = read_gbs_metadata(bitstream, &metadata);
Packit 534379
		if (result != FPGA_OK) {
Packit 534379
			OPAE_ERR("Failed to read metadata");
Packit 534379
			goto out_unlock;
Packit 534379
		}
Packit 534379
Packit 534379
		OPAE_DBG(" Version                  :%f\n", metadata.version);
Packit 534379
		OPAE_DBG(" Magic Num                :%ld\n",
Packit 534379
			 metadata.afu_image.magic_num);
Packit 534379
		OPAE_DBG(" Interface Id             :%s\n",
Packit 534379
			 metadata.afu_image.interface_uuid);
Packit 534379
		OPAE_DBG(" Clock_frequency_high     :%d\n",
Packit 534379
			 metadata.afu_image.clock_frequency_high);
Packit 534379
		OPAE_DBG(" Clock_frequency_low      :%d\n",
Packit 534379
			 metadata.afu_image.clock_frequency_low);
Packit 534379
		OPAE_DBG(" Power                    :%d\n",
Packit 534379
			 metadata.afu_image.power);
Packit 534379
		OPAE_DBG(" Name                     :%s\n",
Packit 534379
			 metadata.afu_image.afu_clusters.name);
Packit 534379
		OPAE_DBG(" Total_contexts           :%d\n",
Packit 534379
			 metadata.afu_image.afu_clusters.total_contexts);
Packit 534379
		OPAE_DBG(" AFU_uuid                 :%s\n",
Packit 534379
			 metadata.afu_image.afu_clusters.afu_uuid);
Packit 534379
Packit 534379
		// Set AFU user clock
Packit 534379
		if (metadata.afu_image.clock_frequency_high > 0 || metadata.afu_image.clock_frequency_low > 0) {
Packit 534379
			result = set_afu_userclock(fpga, metadata.afu_image.clock_frequency_high, metadata.afu_image.clock_frequency_low);
Packit 534379
			if (result != FPGA_OK) {
Packit 534379
				OPAE_ERR("Failed to set user clock");
Packit 534379
				goto out_unlock;
Packit 534379
			}
Packit 534379
		}
Packit 534379
Packit 534379
		// get fpga device id.
Packit 534379
		result = get_fpga_hw_type(fpga, &hw_type);
Packit 534379
		if (result != FPGA_OK) {
Packit 534379
			OPAE_ERR("Failed to discover hardware type.");
Packit 534379
			goto out_unlock;
Packit 534379
		}
Packit 534379
Packit 534379
		// Set power threshold for integrated fpga.
Packit 534379
		if (hw_type == FPGA_HW_MCP &&
Packit 534379
			!stat(FPGA_SYSFS_CLASS_PATH_INTEL, &st)) {
Packit 534379
			result = set_fpga_pwr_threshold(fpga, metadata.afu_image.power);
Packit 534379
			if (result != FPGA_OK) {
Packit 534379
				OPAE_ERR("Failed to set threshold.");
Packit 534379
				goto out_unlock;
Packit 534379
			}
Packit 534379
Packit 534379
		} // device id
Packit 534379
Packit 534379
	}
Packit 534379
Packit 534379
	result = opae_fme_port_pr(
Packit 534379
		_handle->fddev, 0, slot, bitstream_len - bitstream_header_len,
Packit 534379
		(uint64_t)bitstream + bitstream_header_len, &error.csr);
Packit 534379
	if (result != 0) {
Packit 534379
		OPAE_ERR("Failed to reconfigure bitstream: %s",
Packit 534379
			  strerror(errno));
Packit 534379
Packit 534379
		if ((errno == EINVAL) || (errno == EFAULT)) {
Packit 534379
			result = FPGA_INVALID_PARAM;
Packit 534379
		} else {
Packit 534379
			result = FPGA_EXCEPTION;
Packit 534379
		}
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_operation_error == 0x1) {
Packit 534379
		OPAE_ERR("PR operation error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_CRC_error == 0x1) {
Packit 534379
		OPAE_ERR("PR CRC error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_incompatible_bitstream_error == 0x1) {
Packit 534379
		OPAE_ERR("PR incompatible bitstream error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_IP_protocol_error == 0x1) {
Packit 534379
		OPAE_ERR("PR IP protocol error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_FIFO_overflow_error == 0x1) {
Packit 534379
		OPAE_ERR("PR FIFO overflow error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_timeout_error == 0x1) {
Packit 534379
		OPAE_ERR("PR timeout error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	if (error.reconf_secure_load_error == 0x1) {
Packit 534379
		OPAE_ERR("PR secure load error detected");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
out_unlock:
Packit 534379
	// close the accelerator opened during `open_accel`
Packit 534379
	if (accel && xfpga_fpgaClose(accel) != FPGA_OK) {
Packit 534379
		OPAE_ERR("Error closing accelerator after reconfiguration");
Packit 534379
		result = FPGA_RECONF_ERROR;
Packit 534379
	}
Packit 534379
Packit 534379
	err = pthread_mutex_unlock(&_handle->lock);
Packit 534379
	if (err)
Packit 534379
		OPAE_ERR("pthread_mutex_unlock() failed: %s", strerror(err));
Packit 534379
	return result;
Packit 534379
}