520.61.05

This commit is contained in:
Andy Ritger
2022-10-10 14:59:24 -07:00
parent fe0728787f
commit 90eb10774f
758 changed files with 88383 additions and 26493 deletions

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2014-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2014-2022 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
//
// nvlink.h
@@ -72,6 +71,7 @@ extern "C" {
#define NVLINK_TRANSITION_OFF_TIMEOUT 1
#define NVLINK_TRANSITION_SAFE_TIMEOUT 300
#define NVLINK_TRANSITION_HS_TIMEOUT 8000
#define NVLINK_TRANSITION_ACTIVE_PENDING 2000
#define NVLINK_TRANSITION_POST_HS_TIMEOUT 70
// Link training seed values
@@ -109,9 +109,17 @@ struct nvlink_device
NvU64 type;
NvBool initialized;
// Training type: ALI or Non-ALI
NvBool enableALI;
// fabric node id
NvU16 nodeId;
// per Ioctrl data
NvU32 numIoctrls;
NvU32 numLinksPerIoctrl;
NvU32 numActiveLinksPerIoctrl;
// Client private information
void *pDevInfo;
};
@@ -249,6 +257,7 @@ struct nvlink_link_handlers
NV_API_CALL NvlStatus (*read_discovery_token) (struct nvlink_link *link, NvU64 *token);
NV_API_CALL void (*training_complete) (struct nvlink_link *link);
NV_API_CALL void (*get_uphy_load) (struct nvlink_link *link, NvBool* bUnlocked);
NV_API_CALL NvlStatus (*ali_training) (struct nvlink_link *link);
};
//
@@ -318,11 +327,15 @@ typedef struct nvlink_inband_data nvlink_inband_data;
#define NVLINK_LINKSTATE_DISABLE_HEARTBEAT 0x18 // Disables the heartbeat errors
#define NVLINK_LINKSTATE_CONTAIN 0x19 // TL is in contain mode
#define NVLINK_LINKSTATE_INITTL 0x1A // INITTL
#define NVLINK_LINKSTATE_INITPHASE5 0x1B // INITPHASE5
#define NVLINK_LINKSTATE_ALI 0x1C // ALI
#define NVLINK_LINKSTATE_ACTIVE_PENDING 0x1D // Intermediate state for a link going to active
#define NVLINK_LINKSTATE_INVALID 0xFF // Invalid state
// NVLINK TX SUBLINK states
#define NVLINK_SUBLINK_STATE_TX_HS 0x0 // TX High Speed
#define NVLINK_SUBLINK_STATE_TX_SINGLE_LANE 0x4 // TX Single Lane (1/8th or 1/4th) Mode (Deprecated)
#define NVLINK_SUBLINK_STATE_TX_LOW_POWER 0x4 // TX Single Lane Mode / L1
#define NVLINK_SUBLINK_STATE_TX_TRAIN 0x5 // TX training
#define NVLINK_SUBLINK_STATE_TX_SAFE 0x6 // TX Safe Mode
#define NVLINK_SUBLINK_STATE_TX_OFF 0x7 // TX OFF
@@ -336,6 +349,7 @@ typedef struct nvlink_inband_data nvlink_inband_data;
// NVLINK RX SUBLINK states
#define NVLINK_SUBLINK_STATE_RX_HS 0x0 // RX High Speed
#define NVLINK_SUBLINK_STATE_RX_SINGLE_LANE 0x4 // RX Single Lane (1/8th or 1/4th) Mode (Deprecated)
#define NVLINK_SUBLINK_STATE_RX_LOW_POWER 0x4 // RX Single Lane Mode / L1
#define NVLINK_SUBLINK_STATE_RX_TRAIN 0x5 // RX training
#define NVLINK_SUBLINK_STATE_RX_SAFE 0x6 // RX Safe Mode
#define NVLINK_SUBLINK_STATE_RX_OFF 0x7 // RX OFF
@@ -426,6 +440,15 @@ NvlStatus nvlink_lib_set_link_master(nvlink_link *link);
*/
NvlStatus nvlink_lib_get_link_master(nvlink_link *link, nvlink_link **master);
/*
* Set the training state for the given link as non-ALI or ALI
*/
NvlStatus nvlink_lib_is_link_using_ALI(nvlink_link *link, NvBool *usingALI);
/*
* Set the training state for the given link as non-ALI or ALI
*/
NvlStatus nvlink_lib_link_set_training_mode(nvlink_link *link, NvBool enableALI);
/************************************************************************************************/
/*************************** NVLink topology discovery functions ********************************/
/************************************************************************************************/
@@ -508,6 +531,7 @@ void nvlink_lib_restore_training_seeds(nvlink_link * link,
NvlStatus nvlink_lib_check_training_complete(nvlink_link **links,
NvU32 linkCount);
/************************************************************************************************/
/********************************** NVLink shutdown functions ***********************************/
/************************************************************************************************/
@@ -542,21 +566,26 @@ NvlStatus nvlink_lib_reset_links(nvlink_link **links,
NvU32 numLinks,
NvU32 flags);
/*
* Floorsweep the necessary links and set buffer ready on the active links
*/
NvlStatus nvlink_lib_powerdown_floorswept_links_to_off(nvlink_device *pDevice);
/*
* Nvlink core library structure iterators
*/
#define FOR_EACH_DEVICE_REGISTERED(dev, head, node) \
#define FOR_EACH_DEVICE_REGISTERED(dev, head, node) \
nvListForEachEntry(dev, &head.node, node)
#define FOR_EACH_LINK_REGISTERED(link, dev, node) \
#define FOR_EACH_LINK_REGISTERED(link, dev, node) \
nvListForEachEntry(link, &dev->link_list, node)
#define FOR_EACH_LINK_REGISTERED_SAFE(link, next, dev, node) \
nvListForEachEntry_safe(link, next, &dev->link_list, node)
#define FOR_EACH_CONNECTION(conn, head, node) \
#define FOR_EACH_CONNECTION(conn, head, node) \
nvListForEachEntry(conn, &head.node, node)
#ifdef __cplusplus

View File

@@ -69,6 +69,7 @@ struct nvlink_detailed_device_info
NvU64 deviceType;
NvU8 *devUuid;
NvBool bInitialized;
NvBool bEnableALI;
void *dev_info; // Endpoint driver device info opaque
// to core lib. Passed from end point
// driver to core

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2016-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2016-2022 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#ifndef _NVLINK_LIB_CTRL_H_
#define _NVLINK_LIB_CTRL_H_
@@ -30,7 +29,7 @@
/* List of supported capability type */
#define NVLINK_CAP_FABRIC_MANAGEMENT 0
/*
/*
* Max supported capabilities count
*
*/
@@ -62,7 +61,7 @@
/*
* Total number of nvlink endpoints core library can have
* This is mapped to NVLINK_MAX_SYSTEM_LINK_NUM in drivers/nvlink/interface/nvlink.h
* This is mapped to NVLINK_MAX_SYSTEM_LINK_NUM in drivers/nvlink/interface/nvlink.h
*/
#define NVLINK_MAX_NVLINK_ENDPOINTS 624
@@ -90,7 +89,7 @@ typedef struct
typedef struct
{
NvU16 nodeId;
NvU32 linkIndex;
NvU16 linkIndex;
nvlink_pci_dev_info pciInfo;
} nvlink_endpoint;
@@ -110,13 +109,15 @@ typedef struct
NvU16 numLinks;
NvU32 devType;
NV_DECLARE_ALIGNED(NvU64 enabledLinkMask, 8);
NvBool bEnableAli;
/* See struct definition modification guidelines at the top of this file */
} nvlink_detailed_dev_info;
/* detailed information about a remote nvlink connection endpoint */
typedef struct
{
NvU16 nodeId;
NvU32 linkIndex;
NvU16 linkIndex;
nvlink_pci_dev_info pciInfo;
NvU8 devUuid[NVLINK_UUID_LEN];
NvU32 devType;
@@ -188,9 +189,9 @@ typedef enum
/* link and sublink state of an nvlink endpoint */
typedef struct
{
NvU32 linkMode;
NvU32 txSubLinkMode;
NvU32 rxSubLinkMode;
NvU8 linkMode;
NvU8 txSubLinkMode;
NvU8 rxSubLinkMode;
} nvlink_link_state;
/*
@@ -353,7 +354,7 @@ typedef struct
*/
typedef struct
{
NvU32 linkIndex;
NvU16 linkIndex;
NvBool initStatus;
} nvlink_link_init_status;
@@ -502,7 +503,7 @@ typedef struct
*/
typedef struct
{
NvU32 linkIndex;
NvU16 linkIndex;
NV_DECLARE_ALIGNED(NvU64 tokenValue, 8);
} nvlink_token_info;
@@ -586,6 +587,7 @@ typedef enum
nvlink_train_conn_to_off,
nvlink_train_conn_active_to_swcfg,
nvlink_train_conn_swcfg_to_off,
/* See enum modification guidelines at the top of this file */
} nvlink_conn_train_type;
typedef struct
@@ -1075,7 +1077,7 @@ typedef struct
} nvlink_initphase5;
/*
* CTRL_NVLINK_GET_DEVICE_LINKS_STATE
* CTRL_NVLINK_GET_DEVICE_LINK_STATES
*
* Returns the link state of all enabled links on a given device.
*
@@ -1109,6 +1111,11 @@ typedef struct
NvU32 endStatesCount;
} nvlink_get_device_link_states;
/*
* Note: Verify that new parameter structs for IOCTLs satisfy
* sizing restrictions for all OSs they could be used in.
*/
#define CTRL_NVLINK_CHECK_VERSION 0x01
#define CTRL_NVLINK_SET_NODE_ID 0x02
#define CTRL_NVLINK_SET_TX_COMMON_MODE 0x03

View File

@@ -1,25 +1,21 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#ifndef _NVLINK_LOCK_H_

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -392,7 +391,9 @@ nvlink_core_check_intranode_conn_state
if ((nvlink_core_check_link_state(conn->end0, NVLINK_LINKSTATE_HS)) &&
(nvlink_core_check_link_state(conn->end1, NVLINK_LINKSTATE_HS)))
{
if (!((nvlink_core_check_tx_sublink_state(conn->end0,
// In NVLINK4.0, corelib doesn't control sublink state transitions
if (conn->end0->version < NVLINK_DEVICE_VERSION_40 &&
!((nvlink_core_check_tx_sublink_state(conn->end0,
NVLINK_SUBLINK_STATE_TX_HS)) &&
(nvlink_core_check_tx_sublink_state(conn->end1,
NVLINK_SUBLINK_STATE_TX_HS)) &&
@@ -455,6 +456,16 @@ nvlink_core_check_intranode_conn_state
return NVL_ERR_GENERIC;
}
case NVLINK_LINKSTATE_ACTIVE_PENDING:
{
// Check if both ends of connection are already in ACTIVE_PENDING
if ((nvlink_core_check_link_state(conn->end0, NVLINK_LINKSTATE_ACTIVE_PENDING)) &&
(nvlink_core_check_link_state(conn->end1, NVLINK_LINKSTATE_ACTIVE_PENDING)))
{
return NVL_SUCCESS;
}
break;
}
}
return NVL_SUCCESS;

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -85,6 +84,15 @@ nvlink_core_discover_and_get_remote_end
pLinks[linkCount++] = link;
}
}
if (pLinks[0]->version >= NVLINK_DEVICE_VERSION_40)
{
if (!pLinks[0]->dev->enableALI)
{
nvlink_core_init_links_from_off_to_swcfg_non_ALI(pLinks, linkCount, flags);
}
}
else
{
nvlink_core_init_links_from_off_to_swcfg(pLinks, linkCount, flags);
}
@@ -216,11 +224,12 @@ _nvlink_core_discover_topology(void)
isTokenFound = NV_TRUE;
//
// If R4 tokens were used for NVLink3.0+, then mark initnegotiate
// passed, since ALT training won't get kicked off without it.
// If a token is found mark bInitnegotiateConfigGood as
// True since we can only finish off discovery if
// INITNEGOTIATE has finished in order to get topology info from
// MINION
//
if ((end0->version >= NVLINK_DEVICE_VERSION_30) &&
((end0->localSid == 0) || (end0->remoteSid == 0)))
if ((end0->version >= NVLINK_DEVICE_VERSION_30))
{
end0->bInitnegotiateConfigGood = NV_TRUE;
end1->bInitnegotiateConfigGood = NV_TRUE;

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2021 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -255,6 +254,294 @@ nvlink_core_init_links_from_off_to_swcfg
nvlink_core_initnegotiate(pLinks, numLinks, flags);
}
/**
* Initialize all the endpoints from OFF to SWCFG state
* Used for NvLink 4.0+
*
* @param[in] links Array of link endpoints to initialize
* @param[in] numLinks Number of links in the array
* @param[in] flags Flags to determine whether init is sync/async
*/
void
nvlink_core_init_links_from_off_to_swcfg_non_ALI
(
nvlink_link **pLinks,
NvU32 numLinks,
NvU32 flags
)
{
NvlStatus status = NVL_SUCCESS;
NvU64 linkMode;
NvU32 i;
// Sanity check the links array
nvlink_assert(pLinks != NULL);
// Return early if there are no links to initialize
if (numLinks == 0)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: No links to initialize\n",
__FUNCTION__));
return;
}
// Step 1: Perform INITPHASE1 on all endpoints
nvlink_core_initphase1(pLinks, numLinks, flags);
// Get state on all links. This ensures NVLINK_LINKSTATE_INITPHASE1 completes
if (flags == NVLINK_STATE_CHANGE_ASYNC)
{
for (i = 0; i < numLinks; i++)
{
status = pLinks[i]->link_handlers->get_dl_link_mode(pLinks[i], &linkMode);
if ((status != NVL_SUCCESS) ||
(linkMode == NVLINK_LINKSTATE_FAIL) || (linkMode == NVLINK_LINKSTATE_FAULT))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Link %s:%s is in bad state\n",
__FUNCTION__, pLinks[i]->dev->deviceName, pLinks[i]->linkName));
}
}
}
// Step 2 RECEIVER DETECT :Perform receiver detect on all the endpoints
nvlink_core_set_rx_detect(pLinks, numLinks, flags);
// Get state on all links. This ensures receiver detect command completes
if (flags == NVLINK_STATE_CHANGE_ASYNC)
{
for (i = 0; i < numLinks; i++)
{
// In NVLink3.0 and 3.1, RXDET must be called serially - done above (Bug 2546220)
if (!((pLinks[i]->version == NVLINK_DEVICE_VERSION_30) ||
(pLinks[i]->version == NVLINK_DEVICE_VERSION_31)))
{
// If receiver detect has passed for the link, move to next link
if (pLinks[i]->bRxDetected)
continue;
status = pLinks[i]->link_handlers->get_dl_link_mode(pLinks[i], &linkMode);
if ((status != NVL_SUCCESS) ||
(linkMode == NVLINK_LINKSTATE_FAIL) || (linkMode == NVLINK_LINKSTATE_FAULT))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Link %s:%s is in bad state\n",
__FUNCTION__, pLinks[i]->dev->deviceName, pLinks[i]->linkName));
}
}
}
}
// Step 2.1 RECEIVER DETECT :Poll for output of receiver detect on all the endpoints
nvlink_core_get_rx_detect(pLinks, numLinks, flags);
/***************** Receiver Detect is completed at this point ****************/
/***************** Proceed with the link initialization steps ****************/
// Step 3: Enable Common mode on all Tx's
nvlink_core_enable_common_mode(pLinks, numLinks, flags);
// Get state on all links. This ensures NVLINK_SUBLINK_STATE_TX_COMMON_MODE completes
if (flags == NVLINK_STATE_CHANGE_ASYNC)
{
for (i = 0; i < numLinks; i++)
{
// If receiver detect failed for the link, move to next link
if (!pLinks[i]->bRxDetected || pLinks[i]->bTxCommonModeFail)
continue;
status = pLinks[i]->link_handlers->get_dl_link_mode(pLinks[i], &linkMode);
if ((status != NVL_SUCCESS) ||
(linkMode == NVLINK_LINKSTATE_FAIL) || (linkMode == NVLINK_LINKSTATE_FAULT))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Link %s:%s is in bad state\n",
__FUNCTION__, pLinks[i]->dev->deviceName, pLinks[i]->linkName));
}
}
}
// Step 4: call INITPHASE5
nvlink_core_initphase5(pLinks, numLinks, flags);
// Get state on all links. This ensures NVLINK_SUBLINK_STATE_TX_DATA_READY completes
if (flags == NVLINK_STATE_CHANGE_ASYNC)
{
for (i = 0; i < numLinks; i++)
{
// If receiver detect failed for the link, move to next link
if (!pLinks[i]->bRxDetected || pLinks[i]->bTxCommonModeFail || pLinks[i]->bInitphase5Fails)
continue;
status = pLinks[i]->link_handlers->get_dl_link_mode(pLinks[i], &linkMode);
if ((status != NVL_SUCCESS) ||
(linkMode == NVLINK_LINKSTATE_FAIL) || (linkMode == NVLINK_LINKSTATE_FAULT))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Link %s:%s is in bad state\n",
__FUNCTION__, pLinks[i]->dev->deviceName, pLinks[i]->linkName));
}
}
}
// Step 5: Put the links in SAFE mode
for (i = 0; i < numLinks; i++)
{
// If receiver detect failed for the link, move to next link
if (!pLinks[i]->bRxDetected || pLinks[i]->bTxCommonModeFail || pLinks[i]->bInitphase5Fails)
continue;
linkMode = 0;
if (pLinks[i]->link_handlers->get_dl_link_mode(pLinks[i], &linkMode))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Unable to get link mode for %s:%s",
__FUNCTION__, pLinks[i]->dev->deviceName, pLinks[i]->linkName));
}
if ((linkMode != NVLINK_LINKSTATE_SAFE) && (linkMode != NVLINK_LINKSTATE_HS))
{
// Check if the link has reached failed state
if (pLinks[i]->state == NVLINK_LINKSTATE_FAIL)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_INFO,
"%s:%s marked as failed.\n",
pLinks[i]->dev->deviceName, pLinks[i]->linkName));
continue;
}
//
// Check if number of attempts to put the link into
// safe state has already exceeded the maximum number
// of retries. If yes, mark the link as failed
//
// On NVLink3.0, we don't support retraining in the driver.
// However MODS test 252 (on NVL3+ specifically) will train
// HS->OFF->HS many times. This check causes RM to stop
// training after NVLINK_MAX_NUM_SAFE_RETRIES times
//
if ((pLinks[i]->safe_retries > NVLINK_MAX_NUM_SAFE_RETRIES) &&
(pLinks[i]->version < NVLINK_DEVICE_VERSION_30))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_INFO,
"Max safe mode retries reached for %s:%s. Marking it as failed.\n",
pLinks[i]->dev->deviceName, pLinks[i]->linkName));
pLinks[i]->state = NVLINK_LINKSTATE_FAIL;
continue;
}
// Put the link in safe state and increment the retry count
pLinks[i]->link_handlers->set_dl_link_mode(pLinks[i], NVLINK_LINKSTATE_SAFE, flags);
pLinks[i]->safe_retries++;
}
}
// Poll for links to enter SAFE mode
for (i = 0; i < numLinks; i++)
{
status = nvlink_core_wait_for_link_init(pLinks[i]);
if (status == NVL_SUCCESS)
{
pLinks[i]->powerStateTransitionStatus = nvlink_power_state_in_L0;
}
}
// Send INITNEGOTIATE to all the links
nvlink_core_initnegotiate(pLinks, numLinks, flags);
}
/**
* Kick-off INITPHASE5 on the given array of links
*
* @param[in] links Array of nvlink_link pointers
* @param[in] numLinks Number of links in the array
* @param[in] flags Flags - Async/Sync
*
* return NvlStatus
*/
NvlStatus
nvlink_core_initphase5
(
nvlink_link **links,
NvU32 numLinks,
NvU32 flags
)
{
NvU32 i;
// Sanity check the links array
nvlink_assert(links != NULL);
// Return early if link array is empty
if (numLinks == 0)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_INFO,
"%s: Link array is empty\n",
__FUNCTION__));
return NVL_SUCCESS;
}
for (i = 0; i < numLinks; i++)
{
NvlStatus status = NVL_SUCCESS;
NvU64 dlLinkMode = 0;
// INITPHASE5 is supported only for NVLINK version >= 4.0
if (links[i]->version < NVLINK_DEVICE_VERSION_40)
continue;
// If receiver detect failed for the link, move to next link
if (!links[i]->bRxDetected || links[i]->bTxCommonModeFail)
continue;
if (links[i]->link_handlers->get_dl_link_mode(links[i], &dlLinkMode))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Unable to get link mode for %s:%s",
__FUNCTION__, links[i]->dev->deviceName, links[i]->linkName));
}
// Check if the link has reached failed state
if (links[i]->state == NVLINK_LINKSTATE_FAIL)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_INFO,
"%s: %s:%s marked as failed.\n",
__FUNCTION__, links[i]->dev->deviceName, links[i]->linkName));
continue;
}
// Skip this step if link is in HS/SAFE
if (dlLinkMode == NVLINK_LINKSTATE_HS ||
dlLinkMode == NVLINK_LINKSTATE_SAFE)
{
continue;
}
status = links[i]->link_handlers->set_dl_link_mode(links[i],
NVLINK_LINKSTATE_INITPHASE5,
flags);
// Although it fails we need to continue with the next link
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Initphase5 failed on Device:Link %s:%s\n",
__FUNCTION__, links[i]->dev->deviceName, links[i]->linkName));
links[i]->bInitphase5Fails = NV_TRUE;
}
}
//
// We could have links which are faulty and cannot be initialized. But proceeding
// the initialization sequence allows us to use other non-faulty links. Therefore
// return success always.
//
return NVL_SUCCESS;
}
/**
* Kick-off INITPHASE1 on the given array of links
*
@@ -295,11 +582,16 @@ nvlink_core_initphase1
NvU32 txSubMode = 0;
NvU64 rxMode = 0;
NvU32 rxSubMode = 0;
NvBool bPhyUnlocked = NV_FALSE;
// INITPHASE1 is supported only for NVLINK version >= 3.0
if (links[i]->version < NVLINK_DEVICE_VERSION_30)
continue;
if (links[i]->version >= NVLINK_DEVICE_VERSION_40)
links[i]->link_handlers->get_uphy_load(links[i], &bPhyUnlocked);
if (!bPhyUnlocked)
{
if (links[i]->link_handlers->get_tl_link_mode(links[i], &tlLinkMode))
{
@@ -343,6 +635,7 @@ nvlink_core_initphase1
//
if ((tlLinkMode == NVLINK_LINKSTATE_SLEEP) ||
(dlLinkMode == NVLINK_LINKSTATE_RESET) ||
(bPhyUnlocked) ||
((txMode == NVLINK_SUBLINK_STATE_TX_OFF) &&
(rxMode == NVLINK_SUBLINK_STATE_RX_OFF)))
{

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2017-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2017-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvVer.h"
@@ -443,6 +442,8 @@ nvlink_core_copy_device_info
devInfo->numLinks = nvListCount(&tmpDev->link_list);
devInfo->devType = _nvlink_core_map_device_type(tmpDev->type);
devInfo->enabledLinkMask = _nvlink_core_get_enabled_link_mask(tmpDev);
devInfo->bEnableAli = tmpDev->enableALI;
// copy device uuid information if available
if (tmpDev->uuid != NULL)
{

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -68,7 +67,36 @@ nvlink_core_check_link_state
}
break;
}
case NVLINK_LINKSTATE_ALI:
{
status = link->link_handlers->get_tl_link_mode(link, &crntTlLinkMode);
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Unable to get TL link mode for %s:%s\n",
__FUNCTION__, link->dev->deviceName, link->linkName));
return NV_FALSE;
}
status = link->link_handlers->get_dl_link_mode(link, &crntDlLinkMode);
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Unable to get DL link mode for %s:%s\n",
__FUNCTION__, link->dev->deviceName, link->linkName));
return NV_FALSE;
}
if (crntTlLinkMode == NVLINK_LINKSTATE_HS &&
(crntDlLinkMode == NVLINK_LINKSTATE_HS ||
crntDlLinkMode == NVLINK_LINKSTATE_SLEEP))
{
return NV_TRUE;
}
break;
}
case NVLINK_LINKSTATE_SLEEP:
case NVLINK_LINKSTATE_ACTIVE_PENDING:
{
status = link->link_handlers->get_tl_link_mode(link, &crntTlLinkMode);
if (status != NVL_SUCCESS)
@@ -85,7 +113,6 @@ nvlink_core_check_link_state
}
break;
}
}
// return false for default case or the states are not matching

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -431,7 +430,7 @@ nvlink_core_powerdown_intranode_conns_from_active_to_off
// to track Failure
conns[i]->end0->inSWCFG = NV_FALSE;
}
}
else
{
conns[i]->end0->inSWCFG = NV_TRUE;
@@ -449,14 +448,14 @@ nvlink_core_powerdown_intranode_conns_from_active_to_off
// to track Failure
conns[i]->end1->inSWCFG = NV_FALSE;
}
}
else
{
conns[i]->end1->inSWCFG = NV_TRUE;
}
// Change each sublink state to SAFE
if(conns[i]->end0->inSWCFG == NV_TRUE)
if(conns[i]->end0->inSWCFG == NV_TRUE)
{
conns[i]->end0->link_handlers->set_tx_mode(conns[i]->end0,
NVLINK_SUBLINK_STATE_TX_SAFE,
@@ -843,3 +842,148 @@ _nvlink_core_clear_link_state
link->tx_sublink_state = NVLINK_SUBLINK_STATE_TX_OFF;
link->rx_sublink_state = NVLINK_SUBLINK_STATE_RX_OFF;
}
static NvBool
_nvlink_core_check_if_conn_in_array
(
nvlink_intranode_conn **connArray,
NvU32 connArrayLength,
nvlink_intranode_conn *conn
)
{
NvU32 i;
for (i = 0; i < connArrayLength; ++i)
{
if (conn == connArray[i])
{
return NV_TRUE;
}
}
return NV_FALSE;
}
NvlStatus
nvlink_core_powerdown_floorswept_conns_to_off
(
nvlink_link **links,
NvU32 linkCount,
NvU32 numIoctrls,
NvU32 numLinksPerIoctrl,
NvU32 numActiveLinksPerIoctrl
)
{
NvU32 i,j;
nvlink_intranode_conn **connsToShutdown;
nvlink_intranode_conn **visitedConns;
nvlink_intranode_conn *conn;
NvU32 connCount;
NvU32 numConnsToShutdown;
if (linkCount == 0 || numIoctrls == 0 || numLinksPerIoctrl == 0 ||
numActiveLinksPerIoctrl == 0)
{
return NVL_BAD_ARGS;
}
connsToShutdown = (nvlink_intranode_conn **)nvlink_malloc(
sizeof(nvlink_intranode_conn *) * NVLINK_MAX_SYSTEM_LINK_NUM);
if (connsToShutdown == NULL)
{
return NVL_NO_MEM;
}
visitedConns = (nvlink_intranode_conn **)nvlink_malloc(
sizeof(nvlink_intranode_conn *) * NVLINK_MAX_SYSTEM_LINK_NUM);
if (visitedConns == NULL)
{
return NVL_NO_MEM;
}
//
// For each IOCTRL find the total # of connections and shutdown
// any connections over the number of active links per IOCTRL
//
for (i=0; i<numIoctrls; i++)
{
connCount = 0;
numConnsToShutdown = 0;
for (j = 0; j < linkCount; j++)
{
//
// If the link is associated with the current IOCTRL
// then retrieve its connection. If there is no
// active connection associated with the link then continue
// If the connection is not active, shutdown the links but don't
// increment connCount as this is not an active connection to be used for P2P
// If the number of connections found so far is greater
// then the number of active links allowed, mark the connection
// as being needed to shutdown. Increment the total connection count
//
if (links[j]->linkNumber >= numLinksPerIoctrl*i &&
links[j]->linkNumber < numLinksPerIoctrl*(i+1))
{
nvlink_core_get_intranode_conn(links[j], &(conn));
if (conn == NULL ||
_nvlink_core_check_if_conn_in_array(visitedConns, connCount, conn) ||
(conn->end0 == NULL || conn->end1 == NULL))
{
continue;
}
else if(nvlink_core_check_intranode_conn_state(conn, NVLINK_LINKSTATE_OFF) ==
NVL_SUCCESS)
{
continue;
}
else if ((nvlink_core_check_intranode_conn_state(conn, NVLINK_LINKSTATE_HS) != NVL_SUCCESS &&
nvlink_core_check_intranode_conn_state(conn, NVLINK_LINKSTATE_SAFE) != NVL_SUCCESS) &&
(!_nvlink_core_check_if_conn_in_array(connsToShutdown, numConnsToShutdown, conn)))
{
// If link is not in SAFE or HS and not currently in our connsToShutdown array then add it
connsToShutdown[numConnsToShutdown++] = conn;
}
else
{
visitedConns[connCount++] = conn;
if (connCount > numActiveLinksPerIoctrl &&
!_nvlink_core_check_if_conn_in_array(connsToShutdown, numConnsToShutdown, conn))
{
connsToShutdown[numConnsToShutdown++] = conn;
}
}
//
// If the #of conns found == #of links per IOCTRl then
// bail early since we know none of the other links can be
// part of this IOCTRL
//
if (connCount == numLinksPerIoctrl)
{
connCount = 0;
break;
}
}
}
//
// If the number of shutdown is non-zero then shutdown the connections
// and remove the connection from the corelib since all endpoints
// will query the corelib for topology and this connection should no longer
// be reported
//
if (numConnsToShutdown != 0)
{
nvlink_core_powerdown_intranode_conns_from_active_to_off(connsToShutdown, numConnsToShutdown, 0);
for (j = 0; j < numConnsToShutdown; ++j)
{
nvlink_core_remove_intranode_conn(connsToShutdown[j]);
}
}
}
return NVL_SUCCESS;
}

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -31,6 +30,31 @@ static void _nvlink_core_set_sublink_pre_hs_settings(nvlink_link *, NvU32);
static void _nvlink_core_set_link_pre_active_settings(nvlink_link *, NvU32);
static void _nvlink_core_set_link_post_active_settings(nvlink_link *, NvU32);
NvlStatus
nvlink_core_train_check_link_ready_ALI
(
nvlink_link **links,
NvU32 linkCount
)
{
NvU32 i = 0;
NvlStatus status = NVL_SUCCESS;
for (i = 0; i < linkCount; i++)
{
if (!nvlink_core_check_link_state(links[i], NVLINK_LINKSTATE_ALI))
{
// If link is not in active, update status to be error and continue
status = NVL_ERR_GENERIC;
continue;
}
links[i]->link_handlers->training_complete(links[i]);
}
return status;
}
/**
* Link training
* Train the internode connection link from SWCFG to ACTIVE
@@ -671,6 +695,157 @@ nvlink_core_train_intranode_conns_from_from_L2_to_active
return status;
}
/**
* Train intranode connections associated with a list of links to HS
* using non-ALI sequence
*
* @param[in] conns Array of connections to train
* @param[in] connCount Number of connections in the array
* @param[in] flags Flags to track if training is sync/async
*
* return NVL_SUCCESS if the connections train successfully
*/
NvlStatus
nvlink_core_train_intranode_conns_from_swcfg_to_active_non_ALI
(
nvlink_intranode_conn **conns,
NvU32 connCount,
NvU32 flags
)
{
NvlStatus status = NVL_SUCCESS;
NvlStatus pollStatus = NVL_SUCCESS;
NvU32 i;
if ((conns == NULL) || (connCount == 0))
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: No connections to train to ACTIVE\n",
__FUNCTION__));
return NVL_ERR_GENERIC;
}
// Trigger INITOPTIMIZE on both ends of the connection
for (i = 0; i < connCount; i++)
{
conns[i]->end0->link_handlers->set_dl_link_mode(conns[i]->end0,
NVLINK_LINKSTATE_INITOPTIMIZE,
flags);
// On loopback, only send INITOPTIMIZE to one side.
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->set_dl_link_mode(conns[i]->end1,
NVLINK_LINKSTATE_INITOPTIMIZE,
flags);
}
}
// Trigger POST_INITOPTIMIZE (Checks INITOPTIMIZE was successful) on both ends of the connection
for (i = 0; i < connCount; i++)
{
conns[i]->end0->link_handlers->set_dl_link_mode(conns[i]->end0,
NVLINK_LINKSTATE_POST_INITOPTIMIZE,
flags);
// On loopback, only send POST_INITOPTIMIZE to one side.
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->set_dl_link_mode(conns[i]->end1,
NVLINK_LINKSTATE_POST_INITOPTIMIZE,
flags);
}
}
// Set link modes to ACTIVE
for (i = 0; i < connCount; i++)
{
// Some settings required before moving to ACTIVE
_nvlink_core_set_link_pre_active_settings(conns[i]->end0, flags);
_nvlink_core_set_link_pre_active_settings(conns[i]->end1, flags);
conns[i]->end0->link_handlers->set_dl_link_mode(conns[i]->end0,
NVLINK_LINKSTATE_HS,
flags);
// If not in loopback send the dl link mode
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->set_dl_link_mode(conns[i]->end1,
NVLINK_LINKSTATE_HS,
flags);
}
}
// Verify link mode HS on the endpoints
for (i = 0; i < connCount; i++)
{
pollStatus = nvlink_core_poll_link_state(conns[i]->end0,
NVLINK_LINKSTATE_HS,
NVLINK_TRANSITION_HS_TIMEOUT);
if (pollStatus != NVL_SUCCESS)
{
status = pollStatus;
}
pollStatus = nvlink_core_poll_link_state(conns[i]->end1,
NVLINK_LINKSTATE_HS,
NVLINK_TRANSITION_HS_TIMEOUT);
if (pollStatus != NVL_SUCCESS)
{
status = pollStatus;
}
conns[i]->end0->link_handlers->set_dl_link_mode(conns[i]->end0,
NVLINK_LINKSTATE_INITTL,
flags);
// On loopback, only send once
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->set_dl_link_mode(conns[i]->end1,
NVLINK_LINKSTATE_INITTL,
flags);
}
conns[i]->end0->link_handlers->training_complete(conns[i]->end0);
// On loopback, only send once
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->training_complete(conns[i]->end1);
}
conns[i]->end0->link_handlers->set_tx_mode(conns[i]->end0,
NVLINK_SUBLINK_STATE_TX_POST_HS,
flags);
// On loopback, only send once
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->set_tx_mode(conns[i]->end1,
NVLINK_SUBLINK_STATE_TX_POST_HS,
flags);
}
conns[i]->end0->link_handlers->set_dl_link_mode(conns[i]->end0,
NVLINK_LINKSTATE_TRAFFIC_SETUP,
flags);
// On loopback, only send once
if (conns[i]->end0 != conns[i]->end1)
{
conns[i]->end1->link_handlers->set_dl_link_mode(conns[i]->end1,
NVLINK_LINKSTATE_TRAFFIC_SETUP,
flags);
}
}
return status;
}
/**
* Train intranode connections associated with a list of links to HS
* using ALT sequence

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2017-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2017-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvVer.h"
@@ -708,6 +707,12 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
if (links[0]->dev->enableALI)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_initphase1(links, numLinks,
NVLINK_STATE_CHANGE_SYNC);
break;
@@ -727,6 +732,16 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
//
// If the current nvlink device does not support the command
// skip using the command and return success for FM to continue on.
//
if (links[0]->version >= NVLINK_DEVICE_VERSION_40)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_rx_init_term(links, numLinks,
NVLINK_STATE_CHANGE_ASYNC);
break;
@@ -746,6 +761,12 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
if (links[0]->dev->enableALI)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_set_rx_detect(links, numLinks,
NVLINK_STATE_CHANGE_ASYNC);
break;
@@ -765,6 +786,12 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
if (links[0]->dev->enableALI)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_get_rx_detect(links, numLinks,
NVLINK_STATE_CHANGE_ASYNC);
break;
@@ -784,6 +811,12 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
if (links[0]->dev->enableALI)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
if (iocReq->commMode)
{
iocReq->status = nvlink_core_enable_common_mode(links, numLinks,
@@ -816,6 +849,16 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
//
// If the current nvlink device does not support the command
// skip using the command and return success for FM to continue on.
//
if (links[0]->version >= NVLINK_DEVICE_VERSION_40)
{
iocReq->status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_calibrate_links(links, numLinks,
NVLINK_STATE_CHANGE_SYNC);
break;
@@ -834,6 +877,16 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
//
// If the current nvlink device does not support the command
// skip using the command and return success for FM to continue on.
//
if (links[0]->version >= NVLINK_DEVICE_VERSION_40)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_enable_data(links, numLinks,
NVLINK_STATE_CHANGE_SYNC);
break;
@@ -871,10 +924,17 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
if (links[0]->dev->enableALI)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_initnegotiate(links, numLinks,
NVLINK_STATE_CHANGE_ASYNC);
break;
}
case CTRL_NVLINK_INITPHASE5:
{
nvlink_initphase5 *iocReq;
@@ -889,6 +949,18 @@ nvlink_lib_ctrl_all_links
// default initialize status to NVL_SUCCESS
iocReq->status = NVL_SUCCESS;
//
// If the current nvlink device does not support the command
// skip using the command and return success for FM to continue on.
//
if (links[0]->version < NVLINK_DEVICE_VERSION_40 ||
links[0]->dev->enableALI)
{
status = NVL_SUCCESS;
goto nvlink_lib_ctrl_all_links_end;
}
iocReq->status = nvlink_core_initphase5(links, numLinks,
NVLINK_STATE_CHANGE_ASYNC);
break;
}
@@ -2043,6 +2115,16 @@ nvlink_lib_ctrl_train_intranode_conn
{
case nvlink_train_conn_off_to_swcfg:
{
if (srcLink->version >= NVLINK_DEVICE_VERSION_40)
{
// non-ALI training for NVLink4.0+
if (!srcLink->dev->enableALI)
{
nvlink_core_init_links_from_off_to_swcfg_non_ALI(
initLinks, count, NVLINK_STATE_CHANGE_SYNC);
}
}
else
{
// ALT training for NVLink3.0+
nvlink_core_init_links_from_off_to_swcfg(
@@ -2052,8 +2134,16 @@ nvlink_lib_ctrl_train_intranode_conn
}
case nvlink_train_conn_swcfg_to_active:
{
if (srcLink->version >= NVLINK_DEVICE_VERSION_30)
if (srcLink->version >= NVLINK_DEVICE_VERSION_40)
{
// non-ALI training for NVLink4.0+
if (!srcLink->dev->enableALI)
{
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_non_ALI(
&conn, 1, NVLINK_STATE_CHANGE_SYNC);
}
}
else if (srcLink->version >= NVLINK_DEVICE_VERSION_30)
{
// ALT training for NVLink3.0+
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_ALT(
@@ -2333,6 +2423,16 @@ nvlink_lib_ctrl_train_intranode_conns_parallel
{
case nvlink_train_conn_off_to_swcfg:
{
if (srcLink->version >= NVLINK_DEVICE_VERSION_40)
{
// non-ALI training for NVLink4.0+
if (!srcLink->dev->enableALI)
{
nvlink_core_init_links_from_off_to_swcfg_non_ALI(
initLinks, count, NVLINK_STATE_CHANGE_SYNC);
}
}
else
{
// ALT training for NVLink3.0+
nvlink_core_init_links_from_off_to_swcfg(
@@ -2342,6 +2442,16 @@ nvlink_lib_ctrl_train_intranode_conns_parallel
}
case nvlink_train_conn_swcfg_to_active:
{
if (srcLink->version >= NVLINK_DEVICE_VERSION_40)
{
// non-ALI training for NVLink4.0+
if (!srcLink->dev->enableALI)
{
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_non_ALI(
conns, numConns, NVLINK_STATE_CHANGE_SYNC);
}
}
else
{
// ALT training for NVLink3.0+
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_ALT(
@@ -3418,8 +3528,6 @@ nvlink_lib_ctrl_get_device_link_states
{
nvlink_link *endpoint = NULL;
nvlink_device *dev = NULL;
nvlink_device *devIter = NULL;
nvlink_link *remoteLink = NULL;
NvlStatus status = NVL_SUCCESS;
NvU32 numLinks = 0;
NvU32 i = 0;
@@ -3463,14 +3571,12 @@ nvlink_lib_ctrl_get_device_link_states
// Top-level lock is now acquired. Proceed to traversing the list
// of devices and list of links to lock all links
//
FOR_EACH_DEVICE_REGISTERED(devIter, nvlinkLibCtx.nv_devicelist_head, node)
FOR_EACH_LINK_REGISTERED(endpoint, dev, node)
{
FOR_EACH_LINK_REGISTERED(endpoint, devIter, node)
{
if (numLinks >= NVLINK_MAX_SYSTEM_LINK_NUM)
if (numLinks >= NVLINK_MAX_NVLINK_ENDPOINTS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: numLinks >= NVLINK_MAX_SYSTEM_LINK_NUM",
"%s: numLinks >= NVLINK_MAX_NVLINK_ENDPOINTS",
__FUNCTION__));
nvlink_assert(0);
@@ -3483,7 +3589,6 @@ nvlink_lib_ctrl_get_device_link_states
links[numLinks] = endpoint;
numLinks++;
}
}
// Acquire the per-link locks
status = nvlink_lib_link_locks_acquire(links, numLinks);
@@ -3519,31 +3624,6 @@ nvlink_lib_ctrl_get_device_link_states
"%s: link 0x%x -- rxDet status 0x%x, linkMode 0x%x,\n",
__FUNCTION__, i, links[i]->bRxDetected, params->endStates[i].linkMode));
//
// If the link succeeds rxDet then go through and find its peer link. What is important
// is not actually finding the link, but making sure the corelib goes through the discovery
// process and has endpoints cache the remote information in the corelib such that
// FM or endpoints can query the corelib for the topology of the system.
//
if (links[i]->bRxDetected)
{
remoteLink = NULL;
nvlink_core_discover_and_get_remote_end(links[i], &remoteLink, 0);
if (remoteLink == NULL)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: link 0x%x: couldn't find link pair\n",
__FUNCTION__, i));
continue;
}
// If the link is in active, issue postActive settings
if (params->endStates[i].linkMode == nvlink_link_mode_active)
{
links[i]->link_handlers->training_complete(links[i]);
}
}
}
params->endStatesCount = numLinks;

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -108,6 +107,16 @@ nvlink_lib_reinit_link_from_off_to_swcfg
// Release the top level-lock
//
nvlink_lib_top_lock_release();
if (conn->end0->version >= NVLINK_DEVICE_VERSION_40 ||
conn->end1->version >= NVLINK_DEVICE_VERSION_40)
{
if (!conn->end0->dev->enableALI)
{
nvlink_core_init_links_from_off_to_swcfg_non_ALI(links, 2, flags);
}
}
else
{
nvlink_core_init_links_from_off_to_swcfg(links, 2, flags);
}

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -320,4 +319,135 @@ nvlink_lib_get_link_master
return status;
}
/**
* Set whether the link is using ALI for training.
*
* @param[in] link NVLink Link pointer
* @param[in] enableALI Boolean for whether the link is using
* ALI to train the link
*
* return NvlSuccess if setting the variable was successful.
*/
NvlStatus
nvlink_lib_link_set_training_mode
(
nvlink_link *link,
NvBool enableALI
)
{
NvlStatus status = NVL_SUCCESS;
if (link == NULL)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Bad link pointer specified.\n",
__FUNCTION__));
return NVL_ERR_GENERIC;
}
// Acquire the top-level lock
status = nvlink_lib_top_lock_acquire();
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire top-level lock\n",
__FUNCTION__));
return status;
}
// Acquire the per-link lock
status = nvlink_lib_link_locks_acquire(&link, 1);
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire per-link locks\n",
__FUNCTION__));
// Release the top-level lock
nvlink_lib_top_lock_release();
return status;
}
//
// All the required per-link locks are successfully acquired
// The connection list traversal is also complete now
// Release the top level-lock
//
nvlink_lib_top_lock_release();
// TODO: Add Setter for per-link enableALI state variable
// Release the per-link lock
nvlink_lib_link_locks_release(&link, 1);
return status;
}
/**
* Get whether the link is using ALI for training.
*
* @param[in] link NVLink Link pointer
* @param[out] usingAli Boolean on whether ALI training is being used
*
* return NVL_SUCCESS if getting the variable is successful
*/
NvlStatus
nvlink_lib_is_link_using_ALI
(
nvlink_link *link,
NvBool *usingALI
)
{
NvlStatus status = NVL_SUCCESS;
usingALI = NV_FALSE;
if (link == NULL)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Bad link pointer specified.\n",
__FUNCTION__));
return NVL_ERR_GENERIC;
}
// Acquire the top-level lock
status = nvlink_lib_top_lock_acquire();
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire top-level lock\n",
__FUNCTION__));
return status;
}
// Acquire the per-link lock
status = nvlink_lib_link_locks_acquire(&link, 1);
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire per-link locks\n",
__FUNCTION__));
// Release the top-level lock
nvlink_lib_top_lock_release();
return status;
}
//
// All the required per-link locks are successfully acquired
// The connection list traversal is also complete now
// Release the top level-lock
//
nvlink_lib_top_lock_release();
// TODO: Add Getter for per-link enableALI state variable
// Release the per-link lock
nvlink_lib_link_locks_release(&link, 1);
return status;
}

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -304,10 +303,10 @@ nvlink_lib_powerdown_links_from_active_to_off
nvlink_intranode_conn **conns = NULL;
nvlink_intranode_conn *conn = NULL;
NvU32 numConns = 0;
NvU32 i;
NvU32 i,j;
NvU32 lockLinkCount = 0;
nvlink_link **lockLinks = NULL;
NvBool bIsAlreadyPresent = NV_FALSE;
if ((links == NULL) || (numLinks == 0))
{
@@ -424,8 +423,51 @@ nvlink_lib_powerdown_links_from_active_to_off
continue;
}
conns[numConns] = conn;
numConns++;
//
// If device is using ALI based link training, it is possible
// for links to be still transitioning to active when a request to shutdown
// is made. Ensure that all connections transiton successfully to HS or fault
// before continuining to shutdown
//
if(links[0]->dev->enableALI)
{
status = nvlink_core_check_intranode_conn_state(conn, NVLINK_LINKSTATE_ACTIVE_PENDING);
if (status == NVL_SUCCESS)
{
status = nvlink_core_poll_link_state(conn->end0,
NVLINK_LINKSTATE_HS,
NVLINK_TRANSITION_ACTIVE_PENDING);
if (status != NVL_SUCCESS &&
nvlink_core_check_intranode_conn_state(conn, NVLINK_LINKSTATE_FAULT) != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Connection between %s: %s and %s: %s is not ready for shutdown (link state is no in HS or FAULT). Soldiering on...\n",
__FUNCTION__, conn->end0->dev->deviceName, conn->end0->linkName,
conn->end1->dev->deviceName, conn->end1->linkName));
}
}
}
bIsAlreadyPresent = NV_FALSE;
// Check if the the connection is already included in the list
for (j = 0; j < numConns; j++)
{
if (conns[j] == conn)
{
bIsAlreadyPresent = NV_TRUE;
break;
}
}
// If this is a new connection, add it to the list
if (!bIsAlreadyPresent)
{
conns[numConns] = conn;
numConns++;
}
}
//
@@ -775,3 +817,109 @@ nvlink_lib_reset_links_end:
return status;
}
NvlStatus
nvlink_lib_powerdown_floorswept_links_to_off
(
nvlink_device *dev
)
{
NvlStatus status = NVL_SUCCESS;
nvlink_link *link = NULL;
nvlink_link **lockLinks = NULL;
NvU32 lockLinkCount = 0;
if (dev == NULL)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Bad device pointer specified.\n",
__FUNCTION__));
return NVL_ERR_GENERIC;
}
lockLinks = (nvlink_link **)nvlink_malloc(
sizeof(nvlink_link *) * NVLINK_MAX_SYSTEM_LINK_NUM);
if (lockLinks == NULL)
{
return NVL_NO_MEM;
}
// Acquire the top-level lock
status = nvlink_lib_top_lock_acquire();
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire top-level lock\n",
__FUNCTION__));
goto nvlink_core_powerdown_floorswept_conns_to_off_end;
}
//
// If the device has less than or equal links in the IP then
// can be active, then skip floorsweeping
//
if (dev->numActiveLinksPerIoctrl >= dev->numLinksPerIoctrl)
{
nvlink_lib_top_lock_release();
goto nvlink_core_powerdown_floorswept_conns_to_off_end;
}
//
// Top-level lock is now acquired. Proceed to traversing the device
// and link lists and connection lists
//
// Get the array of link endpoints whose lock needs to be acquired
FOR_EACH_LINK_REGISTERED(link, dev, node)
{
if(link == NULL)
{
continue;
}
lockLinks[lockLinkCount] = link;
lockLinkCount++;
}
// Acquire the per-link locks for all links captured
status = nvlink_lib_link_locks_acquire(lockLinks, lockLinkCount);
if (status != NVL_SUCCESS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: Failed to acquire per-link locks\n",
__FUNCTION__));
// Release the top-level lock
nvlink_lib_top_lock_release();
goto nvlink_core_powerdown_floorswept_conns_to_off_end;
}
//
// All the required per-link locks are successfully acquired
// The connection list traversal is also complete now
// Release the top level-lock
//
nvlink_lib_top_lock_release();
status = nvlink_core_powerdown_floorswept_conns_to_off(lockLinks, lockLinkCount, dev->numIoctrls,
dev->numLinksPerIoctrl, dev->numActiveLinksPerIoctrl);
if (status == NVL_BAD_ARGS)
{
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_INFO,
"%s: Bad args passed in for floorsweeping. Chip might not support the feature\n",
__FUNCTION__));
}
nvlink_core_powerdown_floorswept_conns_to_off_end:
if (lockLinks != NULL)
{
nvlink_free((void *)lockLinks);
}
return status;
}

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"
@@ -116,6 +115,24 @@ nvlink_lib_check_training_complete
nvlink_lib_top_lock_release();
// Only run the check if ALI is enabled
if(links[0]->dev->enableALI)
{
//
// This will be the returned back to the caller, the core function
// will return early with an error status if a link is not Active
//
status = nvlink_core_train_check_link_ready_ALI(lockLinks, lockLinkCount);
}
else
{
// If ALI is not enabled, return error
NVLINK_PRINT((DBG_MODULE_NVLINK_CORE, NVLINK_DBG_LEVEL_ERRORS,
"%s: ALI is not enabled! Cannot check training status, please use non-ALI or ALT training to get links to active\n",
__FUNCTION__));
status = NVL_ERR_GENERIC;
}
// Release the per-link locks
nvlink_lib_link_locks_release(lockLinks, lockLinkCount);
nvlink_lib_check_training_complete_end:
@@ -297,7 +314,18 @@ nvlink_lib_train_links_from_swcfg_to_active
if (connCount > 0)
{
if ((conn->end0->version >= NVLINK_DEVICE_VERSION_30) ||
if ((conn->end0->version >= NVLINK_DEVICE_VERSION_40) ||
(conn->end1->version >= NVLINK_DEVICE_VERSION_40))
{
if (!conn->end0->dev->enableALI)
{
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_non_ALI(conns,
connCount,
flags);
}
}
// For NVLink3+, use ALT sequence
else if ((conn->end0->version >= NVLINK_DEVICE_VERSION_30) ||
(conn->end1->version >= NVLINK_DEVICE_VERSION_30))
{
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_ALT(conns,
@@ -685,9 +713,23 @@ nvlink_lib_retrain_link_from_swcfg_to_active
return status;
}
if ((conn->end0->version >= NVLINK_DEVICE_VERSION_30) ||
if ((conn->end0->version >= NVLINK_DEVICE_VERSION_40) ||
(conn->end1->version >= NVLINK_DEVICE_VERSION_40))
{
if (!conn->end0->bInitnegotiateConfigGood ||
!conn->end1->bInitnegotiateConfigGood)
{
status = NVL_ERR_GENERIC;
}
else if (!conn->end0->dev->enableALI)
{
// ALI training for NVLink4.0+
status = nvlink_core_train_intranode_conns_from_swcfg_to_active_non_ALI(conns, 0x1, flags);
}
}
else if ((conn->end0->version >= NVLINK_DEVICE_VERSION_30) ||
(conn->end1->version >= NVLINK_DEVICE_VERSION_30))
{
if (!conn->end0->bInitnegotiateConfigGood ||
!conn->end1->bInitnegotiateConfigGood)

View File

@@ -1,25 +1,25 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2014-2017 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2014-2017 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#ifndef _NVLINK_CTX_H_
#define _NVLINK_CTX_H_

View File

@@ -1,30 +1,28 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2017-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2017-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#ifndef _NVLINK_HELPER_H_
#define _NVLINK_HELPER_H_
//
// fabric node id will be used as MSB 16 bits of the link token value to
// generate a unique token for discovering connections
@@ -67,6 +65,11 @@ void nvlink_core_copy_device_info(nvlink_device *tmpDev, nvlink_detailed_dev_inf
/****************************** NVLink initialization functions *********************************/
/************************************************************************************************/
/**
* Kick-off INITPHASE5 on the given array of links
*/
NvlStatus nvlink_core_initphase5(nvlink_link **links, NvU32 numLinks, NvU32 flags);
/**
* Kick-off INITPHASE1 on the given array of links
*/
@@ -124,12 +127,18 @@ void nvlink_core_init_links_from_off_to_swcfg(nvlink_link **pLinks,
NvU32 numLinks,
NvU32 flags);
/*
* Initialize all the endpoints from OFF to SWCFG state for Non-ALI sequence
* Used for nvlink 4.0+
*/
void nvlink_core_init_links_from_off_to_swcfg_non_ALI(nvlink_link **pLinks,
NvU32 numLinks,
NvU32 flags);
/**
* Send INITNEGOTIATE command on the given array of links
*/
NvlStatus nvlink_core_initnegotiate(nvlink_link **links, NvU32 numLinks, NvU32 flags);
/************************************************************************************************/
/*************************** NVLink topology discovery functions ********************************/
/************************************************************************************************/
@@ -195,6 +204,7 @@ NvlStatus nvlink_core_train_intranode_conns_from_swcfg_to_active_ALT(nvlink_intr
NvU32 flags);
/**
* Train a single intranode connection associated with a list of links to HS using legacy
* pre-Ampere sequence
@@ -203,6 +213,21 @@ NvlStatus nvlink_core_train_intranode_conns_from_swcfg_to_active_legacy(nvlink_i
NvU32 connCount,
NvU32 flags);
/**
* Train intranode connections associated with a list of links to HS using non-ALI sequence
* for nvlink 4.0+
*/
NvlStatus nvlink_core_train_intranode_conns_from_swcfg_to_active_non_ALI(nvlink_intranode_conn **conns,
NvU32 connCount,
NvU32 flags);
/**
* Check to make sure that links are in active and ready for ALI training for nvlink 4.0+
*/
NvlStatus nvlink_core_train_check_link_ready_ALI(nvlink_link **links,
NvU32 linkCount);
/************************************************************************************************/
/********************************** NVLink shutdown functions ***********************************/
/************************************************************************************************/
@@ -239,6 +264,15 @@ NvlStatus nvlink_core_reset_intranode_conns(nvlink_intranode_conn **conns,
NvU32 connCount,
NvU32 flags);
/**
* Check to make sure that links are in active and ready for ALI training for nvlink 4.0+
*/
NvlStatus nvlink_core_powerdown_floorswept_conns_to_off(nvlink_link **links,
NvU32 numLinks,
NvU32 numIoctrls,
NvU32 numLinksPerIoctrl,
NvU32 numActiveLinksPerIoctrl);
/************************************************************************************************/
/**************************** NVLink connection management functions ****************************/

View File

@@ -1,25 +1,24 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2019-2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvlink_export.h"

View File

@@ -1,25 +1,21 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
Copyright (c) 2020 NVidia Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*******************************************************************************/
#include "nvlink.h"
#include "nvtypes.h"