530.30.02

This commit is contained in:
Andy Ritger
2023-02-28 11:12:44 -08:00
parent e598191e8e
commit 4397463e73
928 changed files with 124728 additions and 88525 deletions

View File

@@ -20,22 +20,18 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#if (defined(NVRM) || defined(RMCFG_FEATURE_PLATFORM_GSP)) && !defined(NVWATCH)
#include "g_ioaccess_nvoc.h"
#endif
#ifndef _IO_ACCESS_H_
#define _IO_ACCESS_H_
#include "nvtypes.h"
#include "nvstatus.h"
typedef struct IO_DEVICE IO_DEVICE, *PIO_DEVICE;
typedef struct IO_APERTURE IO_APERTURE, *PIO_APERTURE;
typedef NvU8 ReadReg008Fn(PIO_APERTURE a, NvU32 addr);
typedef NvU16 ReadReg016Fn(PIO_APERTURE a, NvU32 addr);
typedef NvU32 ReadReg032Fn(PIO_APERTURE a, NvU32 addr);
typedef void WriteReg008Fn(PIO_APERTURE a, NvU32 addr, NvV8 value);
typedef void WriteReg016Fn(PIO_APERTURE a, NvU32 addr, NvV16 value);
typedef void WriteReg032Fn(PIO_APERTURE a, NvU32 addr, NvV32 value);
typedef NvBool ValidRegFn(PIO_APERTURE a, NvU32 addr);
#if (defined(NVRM) || defined(RMCFG_FEATURE_PLATFORM_GSP)) && !defined(NVWATCH)
#include "nvoc/prelude.h"
#endif
#define REG_DRF_SHIFT(drf) ((0?drf) % 32)
#define REG_DRF_MASK(drf) (0xFFFFFFFF>>(31-((1?drf) % 32)+((0?drf) % 32)))
@@ -45,6 +41,48 @@ typedef NvBool ValidRegFn(PIO_APERTURE a, NvU32 addr);
#define REG_DRF_SHIFTMASK(drf) (REG_DRF_MASK(drf)<<(REG_DRF_SHIFT(drf)))
#define REG_DRF_WIDTH(drf) ((1?drf) - (0?drf) + 1)
#if (defined(NVRM) || defined(RMCFG_FEATURE_PLATFORM_GSP)) && !defined(NVWATCH)
#define REG_RD08(ap, addr) regaprtReadReg08 (staticCast(ap, RegisterAperture), addr)
#define REG_RD16(ap, addr) regaprtReadReg16 (staticCast(ap, RegisterAperture), addr)
#define REG_RD32(ap, addr) regaprtReadReg32 (staticCast(ap, RegisterAperture), addr)
#define REG_WR08(ap, addr, val) regaprtWriteReg08 (staticCast(ap, RegisterAperture), addr, val)
#define REG_WR16(ap, addr, val) regaprtWriteReg16 (staticCast(ap, RegisterAperture), addr, val)
#define REG_WR32(ap, addr, val) regaprtWriteReg32 (staticCast(ap, RegisterAperture), addr, val)
#define REG_WR32_UC(ap, addr, val) regaprtWriteReg32Uc(staticCast(ap, RegisterAperture), addr, val)
#define REG_VALID(ap, addr) regaprtIsRegValid (staticCast(ap, RegisterAperture), addr)
NVOC_PREFIX(regaprt)
class RegisterAperture
{
public:
virtual NvU8 regaprtReadReg08 (RegisterAperture *pAperture, NvU32 addr) = 0;
virtual NvU16 regaprtReadReg16 (RegisterAperture *pAperture, NvU32 addr) = 0;
virtual NvU32 regaprtReadReg32 (RegisterAperture *pAperture, NvU32 addr) = 0;
virtual void regaprtWriteReg08 (RegisterAperture *pAperture, NvU32 addr, NvV8 value) = 0;
virtual void regaprtWriteReg16 (RegisterAperture *pAperture, NvU32 addr, NvV16 value) = 0;
virtual void regaprtWriteReg32 (RegisterAperture *pAperture, NvU32 addr, NvV32 value) = 0;
virtual void regaprtWriteReg32Uc(RegisterAperture *pAperture, NvU32 addr, NvV32 value) = 0;
virtual NvBool regaprtIsRegValid (RegisterAperture *pAperture, NvU32 addr) = 0;
};
//
// TODO: Remove the wrapper structure WAR once NVOC supports in-place object construction
// The proxy structure was introduced to avoid major refactoring until the feature is implemented
// Also fix IoAperture getters
// Use the interface class in NVWATCH once NVOC is enabled there
//
#else // (defined(NVRM) || defined(RMCFG_FEATURE_PLATFORM_GSP)) && !defined(NVWATCH)
typedef struct IO_DEVICE IO_DEVICE;
typedef struct IO_APERTURE IO_APERTURE;
typedef NvU8 ReadReg008Fn(IO_APERTURE *a, NvU32 addr);
typedef NvU16 ReadReg016Fn(IO_APERTURE *a, NvU32 addr);
typedef NvU32 ReadReg032Fn(IO_APERTURE *a, NvU32 addr);
typedef void WriteReg008Fn(IO_APERTURE *a, NvU32 addr, NvV8 value);
typedef void WriteReg016Fn(IO_APERTURE *a, NvU32 addr, NvV16 value);
typedef void WriteReg032Fn(IO_APERTURE *a, NvU32 addr, NvV32 value);
typedef NvBool ValidRegFn(IO_APERTURE *a, NvU32 addr);
#define REG_RD08(ap, addr) (ap)->pDevice->pReadReg008Fn((ap), (addr))
#define REG_RD16(ap, addr) (ap)->pDevice->pReadReg016Fn((ap), (addr))
#define REG_RD32(ap, addr) (ap)->pDevice->pReadReg032Fn((ap), (addr))
@@ -57,6 +95,36 @@ typedef NvBool ValidRegFn(PIO_APERTURE a, NvU32 addr);
// Get the address of a register given the Aperture and offset.
#define REG_GET_ADDR(ap, offset) ((ap)->baseAddress + (offset))
struct IO_DEVICE
{
ReadReg008Fn *pReadReg008Fn;
ReadReg016Fn *pReadReg016Fn;
ReadReg032Fn *pReadReg032Fn;
WriteReg008Fn *pWriteReg008Fn;
WriteReg016Fn *pWriteReg016Fn;
WriteReg032Fn *pWriteReg032Fn;
WriteReg032Fn *pWriteReg032UcFn;
ValidRegFn *pValidRegFn;
};
struct IO_APERTURE
{
IO_DEVICE *pDevice; // Pointer to module specific IO_DEVICE
NvU32 baseAddress; // register base address
NvU32 length; // length of aperture
};
NV_STATUS ioaccessInitIOAperture
(
IO_APERTURE *pAperture,
IO_APERTURE *pParentAperture,
IO_DEVICE *pDevice,
NvU32 offset,
NvU32 length
);
#endif // (defined(NVRM) || defined(RMCFG_FEATURE_PLATFORM_GSP)) && !defined(NVWATCH)
//
// Macros for register I/O
//
@@ -77,49 +145,4 @@ typedef NvBool ValidRegFn(PIO_APERTURE a, NvU32 addr);
#define REG_RD_DRF_IDX(ap,d,r,f,i) (((REG_RD32(ap,NV ## d ## r))>>REG_DRF_SHIFT(NV ## d ## r ## f(i)))&REG_DRF_MASK(NV ## d ## r ## f(i)))
#define REG_IDX_OFFSET_RD_DRF(ap,d,r,i,o,f) (((REG_RD32(ap,NV ## d ## r(i,o)))>>REG_DRF_SHIFT(NV ## d ## r ## f))&REG_DRF_MASK(NV ## d ## r ## f))
struct IO_DEVICE
{
ReadReg008Fn *pReadReg008Fn;
ReadReg016Fn *pReadReg016Fn;
ReadReg032Fn *pReadReg032Fn;
WriteReg008Fn *pWriteReg008Fn;
WriteReg016Fn *pWriteReg016Fn;
WriteReg032Fn *pWriteReg032Fn;
WriteReg032Fn *pWriteReg032UcFn;
ValidRegFn *pValidRegFn;
};
struct IO_APERTURE
{
PIO_DEVICE pDevice; // Pointer to module specific IO_DEVICE
NvU32 baseAddress; // register base address
NvU32 length; // length of aperture
};
//---------------------------------------------------------------------------
//
// Function prototypes.
//
//---------------------------------------------------------------------------
NV_STATUS ioaccessCreateIOAperture
(
IO_APERTURE **ppAperture,
IO_APERTURE *pParentAperture,
IO_DEVICE *pDevice,
NvU32 offset,
NvU32 length
);
NV_STATUS ioaccessInitIOAperture
(
IO_APERTURE *pAperture,
IO_APERTURE *pParentAperture,
IO_DEVICE *pDevice,
NvU32 offset,
NvU32 length
);
void ioaccessDestroyIOAperture(IO_APERTURE *pAperture);
#endif // _IO_ACCESS_H_

View File

@@ -62,6 +62,9 @@ public:
//! IP Version value. Temporary until NVOC-style HALs are rolled out.
NvU32 ipVersion;
//! flags used to create the object.
NvU32 createFlags;
/*!
* @brief Add pChild as a child of this object.
*
@@ -118,8 +121,6 @@ public:
#define NV_ODB_IP_VER_MAJOR 31:24 /* R-IVF */
#define IPVersion(pObj) staticCast((pObj), Object)->ipVersion
#define IsIPVersionValid(pObj) (DRF_VAL(_ODB, _IP_VER, _MAJOR, IPVersion(pObj)) != 0)
#define IsIPVersionOrLater(pObj, v0) (IPVersion(pObj) >= (v0))
// v0 .. v1 inclusive
#define IsIPVersionInRange(pObj, v0, v1) ((IPVersion(pObj) >= (v0)) && (IPVersion(pObj) <= (v1)))

View File

@@ -106,9 +106,13 @@
* Default behavior
* NVOC_OBJ_CREATE_FLAGS_PARENT_HALSPEC_ONLY
* Use halspec from parent without adding the new created object the child tree
* NVOC_OBJ_CREATE_FLAGS_IN_PLACE_CONSTRUCT
* Skip memory allocation on object create, assume the argument points to memory
* already allocated.
*/
#define NVOC_OBJ_CREATE_FLAGS_NONE 0x0000u
#define NVOC_OBJ_CREATE_FLAGS_PARENT_HALSPEC_ONLY 0x0001u
#define NVOC_OBJ_CREATE_FLAGS_IN_PLACE_CONSTRUCT 0x0002u
/*!
* @brief Create and construct a new object by class name.

View File

@@ -44,6 +44,8 @@ const NVOC_CLASS_INFO *__nvoc_objGetClassInfo(Dynamic *pObj);
void __nvoc_objDelete(Dynamic *pDynamic);
NV_STATUS __nvoc_handleObjCreateMemAlloc(NvU32 createFlags, NvU32 allocSize, void **ppLocalPtr, void **ppThis);
NV_STATUS __nvoc_objCreateDynamic(
Dynamic **pNewObject,
Dynamic *pParent,

View File

@@ -170,6 +170,7 @@ typedef void *PUID_TOKEN;
#define RS_LOCK_FLAGS_NO_CUSTOM_LOCK_3 NVBIT(4)
#define RS_LOCK_FLAGS_NO_DEPENDANT_SESSION_LOCK NVBIT(5)
#define RS_LOCK_FLAGS_FREE_SESSION_LOCK NVBIT(6)
#define RS_LOCK_FLAGS_LOW_PRIORITY NVBIT(7)
/// RS_LOCK_STATE
#define RS_LOCK_STATE_TOP_LOCK_ACQUIRED NVBIT(0)
@@ -276,6 +277,13 @@ struct CALL_CONTEXT
RS_LOCK_INFO *pLockInfo; ///< Saved locking context information for the call
API_SECURITY_INFO secInfo;
RS_RES_CONTROL_PARAMS_INTERNAL *pControlParams; ///< parameters of the call [optional]
void *pSerializedParams; ///< Serialized version of the params
void *pDeserializedParams; ///< Deserialized version of the params
NvU32 serializedSize; ///< Serialized size
NvU32 deserializedSize; ///< Deserialized size
NvBool bReserialize; ///< Reserialize before calling into GSP
NvBool bRestoreParams; ///< Need to restore pParams
};
typedef enum {

View File

@@ -84,6 +84,16 @@ public:
*/
NvBool bResourceWarning;
/**
* True if client is disabled, awaiting free
*/
NvBool bDisabled;
/**
* True if client's high priority resources were freed
*/
NvBool bHighPriorityFreeDone;
/**
* Maps resource handle -> RsResourceRef
*/
@@ -140,6 +150,11 @@ public:
*/
RS_FREE_STACK *pFreeStack;
/**
* Node for a client's disabled client list
*/
ListNode disabledClientNode;
/**
* Construct a client instance
* @param[in] pClient This client
@@ -412,6 +427,7 @@ public:
*/
NV_STATUS clientSetRestrictedRange(RsClient *pClient, NvHandle handleRangeStart, NvU32 handleRangeSize);
};
MAKE_INTRUSIVE_LIST(RsDisabledClientList, RsClient, disabledClientNode);
/**
* Get an iterator to the elements in the client's resource map
@@ -454,6 +470,14 @@ RS_ORDERED_ITERATOR clientRefOrderedIter(RsClient *pClient, RsResourceRef *pScop
*/
NvBool clientRefOrderedIterNext(RsClient *pClient, RS_ORDERED_ITERATOR *pIt);
/**
* Release all CPU address mappings for a resource
*
* @param[in] pClient Client that owns the resource
* @param[in] pCallContext Caller information (which includes the resource reference whose mappings will be freed)
* @param[in] pLockInfo Information about which locks are already held, for recursive calls
*/
NV_STATUS clientUnmapResourceRefMappings(RsClient *pClient, CALL_CONTEXT *pCallContext, RS_LOCK_INFO *pLockInfo);
/**
* RsResource interface to a RsClient
@@ -488,6 +512,7 @@ struct RS_CLIENT_FREE_PARAMS_INTERNAL
NvHandle hDomain; ///< [in] The parent domain
NvHandle hClient; ///< [in] The client handle
NvBool bHiPriOnly; ///< [in] Only free high priority resources
NvBool bDisableOnly; ///< [in] Only disable the listed clients, do not free them yet
NvU32 state; ///< [in] User-defined state
RS_RES_FREE_PARAMS_INTERNAL *pResFreeParams; ///< [in] Necessary for locking state

View File

@@ -140,6 +140,7 @@ struct RS_RES_FREE_PARAMS_INTERNAL
// Internal use only
NvBool bHiPriOnly; ///< [in] Only free if this is a high priority resources
NvBool bDisableOnly; ///< [in] Disable the target instead of freeing it (only applies to clients)
RS_LOCK_INFO *pLockInfo; ///< [inout] Locking flags and state
NvU32 freeFlags; ///< [in] Flags for the free operation
NvU32 freeState; ///< [inout] Free state
@@ -296,6 +297,30 @@ public:
virtual NV_STATUS resControlFilter(RsResource *pResource, CALL_CONTEXT *pCallContext,
RS_RES_CONTROL_PARAMS_INTERNAL *pParams);
/**
* Serialize the control parameters if they are going to GSP/Host, not serialized, and support serialization
* Or
* Deserialize the control parameters if necessary and replace the inner params pointer with the deserialized params
*
* @param[in] pResource
* @param[in] pCallContext
* @param[in] pParams
*/
virtual NV_STATUS resControlSerialization_Prologue(RsResource *pResource, CALL_CONTEXT *pCallContext,
RS_RES_CONTROL_PARAMS_INTERNAL *pParams);
/**
* Deserialize the parameters returned from GSP if client did not pass serialized params
* Or
* Serialize the control parameters if client expects it and restore the original inner params pointer
*
* @param[in] pResource
* @param[in] pCallContext
* @param[in] pParams
*/
virtual void resControlSerialization_Epilogue(RsResource *pResource, CALL_CONTEXT *pCallContext,
RS_RES_CONTROL_PARAMS_INTERNAL *pParams);
/**
* Operations performed right before the control call is executed. Default stubbed.
*

View File

@@ -28,6 +28,7 @@
#include "nvport/nvport.h"
#include "resserv/resserv.h"
#include "resserv/rs_client.h"
#include "nvoc/runtime.h"
#ifdef __cplusplus
@@ -181,6 +182,11 @@ struct RsServer
NvU32 activeClientCount;
NvU64 activeResourceCount;
/// List of clients that are de-activated and pending free
RsDisabledClientList disabledClientList;
RsClient *pNextDisabledClient;
PORT_SPINLOCK *pDisabledClientListLock;
};
/**
@@ -262,20 +268,35 @@ NV_STATUS serverAllocClient(RsServer *pServer, RS_RES_ALLOC_PARAMS_INTERNAL *pPa
NV_STATUS serverFreeClient(RsServer *pServer, RS_CLIENT_FREE_PARAMS* pParams);
/**
* Free a list of client handles. All resources references owned by the client will be
* freed. All priority resources will be freed first across all listed clients.
* Mark a list of client handles as disabled. All CPU mappings owned by that
* client will be unmapped immediate, and the client will be marked as disabled.
* A call to @ref serverFreeDisabledClients will then free all such clients.
*
* It is invalid to attempt to free a client from a user other than the one
* that allocated it.
*
* @param[in] pServer This server instance
* @param[in] phClientList The list of client handles to free
* @param[in] phClientList The list of client handles to disable
* @param[in] numClients The number of clients in the list
* @param[in] freeState User-defined free state
* @param[in] pSecInfo Security Info
*
*/
NV_STATUS serverFreeClientList(RsServer *pServer, NvHandle *phClientList, NvU32 numClients, NvU32 freeState, API_SECURITY_INFO *pSecInfo);
NV_STATUS serverMarkClientListDisabled(RsServer *pServer, NvHandle *phClientList, NvU32 numClients, NvU32 freeState, API_SECURITY_INFO *pSecInfo);
/**
* Frees all currently disabled clients. All resources references owned by
* any of the clients will be freed.
* All priority resources will be freed first across all listed clients.
*
* NOTE: may return NV_WARN_MORE_PROCESSING_REQUIRED if not all clients were freed
*
* @param[in] pServer This server instance
* @param[in] freeState User-defined free state
* @param[in] limit Max number of iterations to make returning; 0 means no limit
*
*/
NV_STATUS serverFreeDisabledClients(RsServer *pServer, NvU32 freeState, NvU32 limit);
/**
* Allocate a resource.
@@ -351,8 +372,67 @@ NvBool serverShareIterNext(RS_SHARE_ITERATOR*);
* @param[in] pServer
* @param[in] clientHandleBase
*/
NV_STATUS serverSetClientHandleBase(RsServer *pServer, NvU32 clientHandleBase);
NV_STATUS serverSetClientHandleBase(RsServer *pServer, NvU32 clientHandleBase);
/**
* Deserialize parameters for servicing command
*
* @param[in] pCallContext
* @param[in] cmd
* @param[in] pParams
* @param[in] paramsSize
* @param[in] flags
*/
NV_STATUS serverDeserializeCtrlDown(CALL_CONTEXT *pCallContext, NvU32 cmd, void *pParams, NvU32 paramsSize, NvU32 *flags);
/**
* Serialize parameters for servicing command
*
* @param[in] pCallContext
* @param[in] cmd
* @param[in] pParams
* @param[in] paramsSize
* @param[in] flags
*/
NV_STATUS serverSerializeCtrlDown(CALL_CONTEXT *pCallContext, NvU32 cmd, void *pParams, NvU32 paramsSize, NvU32 *flags);
/**
* Deserialize parameters for returning from command
*
* @param[in] pCallContext
* @param[in] cmd
* @param[in] pParams
* @param[in] paramsSize
* @param[in] flags
*/
NV_STATUS serverDeserializeCtrlUp(CALL_CONTEXT *pCallContext, NvU32 cmd, void *pParams, NvU32 paramsSize, NvU32 *flags);
/**
* Serialize parameters for returning from command
*
* @param[in] pCallContext
* @param[in] cmd
* @param[in] pParams
* @param[in] paramsSize
* @param[in] flags
*/
NV_STATUS serverSerializeCtrlUp(CALL_CONTEXT *pCallContext, NvU32 cmd, void *pParams, NvU32 paramsSize, NvU32 *flags);
/**
* Unset flag for reserializing control before going to GSP
* Used if kernel control servicing passes params to GSP without changing them
*
* @param[in] pCallContext
*/
void serverDisableReserializeControl(CALL_CONTEXT *pCallContext);
/**
* Free finn structures allocated for serializing/deserializing
*
* @param[in] pCallContext
* @param[in] pParams
*/
void serverFreeSerializeStructures(CALL_CONTEXT *pCallContext, void *pParams);
/**
* Return an available client handle for new client allocation

View File

@@ -262,7 +262,7 @@ NvU32 tlsEntryUnreference(NvU64 entryId);
#define TLS_ISR_ALLOCATOR_SIZE 512
#else
#if defined(LOCK_VAL_ENABLED)
#define TLS_ISR_ALLOCATOR_SIZE 400
#define TLS_ISR_ALLOCATOR_SIZE 512
#else
#define TLS_ISR_ALLOCATOR_SIZE 256
#endif