525.147.05

This commit is contained in:
Bernhard Stoeckner
2023-10-31 14:37:42 +01:00
parent 1f3ce1beab
commit 207a166fc3
114 changed files with 7252 additions and 842 deletions

View File

@@ -439,6 +439,11 @@ NvlStatus nvlink_lib_register_link(nvlink_device *dev, nvlink_link *link);
*/
NvlStatus nvlink_lib_unregister_link(nvlink_link *link);
/*
* Gets number of devices with type deviceType
*/
NvlStatus nvlink_lib_return_device_count_by_type(NvU32 deviceType, NvU32 *numDevices);
/************************************************************************************************/
/******************************* NVLink link management functions *******************************/

View File

@@ -46,6 +46,11 @@ NvlStatus nvlink_lib_unload(void);
*/
NvlStatus nvlink_lib_ioctl_ctrl(nvlink_ioctrl_params *ctrl_params);
/*
* Gets number of devices with type deviceType
*/
NvlStatus nvlink_lib_return_device_count_by_type(NvU32 deviceType, NvU32 *numDevices);
#ifdef __cplusplus
}
#endif

View File

@@ -30,6 +30,9 @@ extern "C" {
#include "nvlink_common.h"
#define TOP_LEVEL_LOCKING_DISABLED 1
#define PER_LINK_LOCKING_DISABLED 1
#define NVLINK_FREE(x) nvlink_free((void *)x)
// Memory management functions

View File

@@ -187,13 +187,59 @@ nvlink_lib_is_registerd_device_with_reduced_config(void)
{
if (dev->bReducedNvlinkConfig == NV_TRUE)
{
// Release top-level lock
nvlink_lib_top_lock_release();
return NV_TRUE;
}
}
// Release and free top-level lock
// Release top-level lock
nvlink_lib_top_lock_release();
nvlink_lib_top_lock_free();
return NV_FALSE;
}
/*
* Get the number of devices that have the device type deviceType
*/
NvlStatus
nvlink_lib_return_device_count_by_type
(
NvU32 deviceType,
NvU32 *numDevices
)
{
NvlStatus lock_status = NVL_SUCCESS;
nvlink_device *dev = NULL;
NvU32 device_count = 0;
if (nvlink_lib_is_initialized())
{
// Acquire top-level lock
lock_status = nvlink_lib_top_lock_acquire();
if (lock_status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire top-level lock\n",
__FUNCTION__));
return lock_status;
}
// Top-level lock is now acquired
// Loop through device list
FOR_EACH_DEVICE_REGISTERED(dev, nvlinkLibCtx.nv_devicelist_head, node)
{
if (dev->type == deviceType)
{
device_count++;
}
}
// Release top-level lock
nvlink_lib_top_lock_release();
}
*numDevices = device_count;
return NVL_SUCCESS;
}

View File

@@ -26,14 +26,18 @@
#include "nvlink_lock.h"
//
// Only enabling locking for testing purposes at the moment.
// Disabled at all other times.
//
#define LOCKING_DISABLED 1
// Only enabling top level locking for linux as required by Bug 4108674.
// Per link locking is still disabled at all times. It will be enabled
// after other locking related clean up is done.
//
static void _sort_links(nvlink_link **, NvU32, NvBool (*)(void *, void *));
static NvBool _compare(void *, void *);
#if defined(NV_LINUX)
#undef TOP_LEVEL_LOCKING_DISABLED
# define TOP_LEVEL_LOCKING_DISABLED 0
#endif /* defined(NV_LINUX) */
/*
* Allocate top level lock. Return NVL_SUCCESS if
* the lock was allocated else return NVL_ERR_GENERIC.
@@ -41,7 +45,7 @@ static NvBool _compare(void *, void *);
NvlStatus
nvlink_lib_top_lock_alloc(void)
{
if (LOCKING_DISABLED)
if (TOP_LEVEL_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
@@ -82,7 +86,7 @@ nvlink_lib_top_lock_alloc(void)
NvlStatus
nvlink_lib_top_lock_free(void)
{
if (LOCKING_DISABLED)
if (TOP_LEVEL_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
@@ -115,7 +119,7 @@ nvlink_lib_link_lock_alloc
nvlink_link *link
)
{
if (LOCKING_DISABLED)
if (PER_LINK_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
@@ -158,7 +162,7 @@ nvlink_lib_link_lock_free
nvlink_link *link
)
{
if (LOCKING_DISABLED)
if (PER_LINK_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
@@ -188,7 +192,7 @@ nvlink_lib_link_lock_free
NvlStatus
nvlink_lib_top_lock_acquire(void)
{
if (LOCKING_DISABLED)
if (TOP_LEVEL_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
@@ -223,7 +227,7 @@ nvlink_lib_top_lock_acquire(void)
NvlStatus
nvlink_lib_top_lock_release(void)
{
if (LOCKING_DISABLED)
if (TOP_LEVEL_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
@@ -265,13 +269,12 @@ nvlink_lib_link_locks_acquire
int numLinks
)
{
if (LOCKING_DISABLED)
if (PER_LINK_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
int i;
nvlink_link *link_prev = NULL;
// Check if array of links is already empty before attempting to release.
@@ -328,13 +331,12 @@ nvlink_lib_link_locks_release
int numLinks
)
{
int i;
if (LOCKING_DISABLED)
if (PER_LINK_LOCKING_DISABLED)
{
return NVL_SUCCESS;
}
int i;
nvlink_link *link_prev = NULL;
// Check if array of links is already empty before attempting to release.