530.41.03

This commit is contained in:
Andy Ritger
2023-03-23 11:00:12 -07:00
parent 4397463e73
commit 6dd092ddb7
63 changed files with 848 additions and 149 deletions

View File

@@ -481,6 +481,7 @@ static inline void HsIncrementNextIndex(
}
static inline void HsChangeSurfaceFlipRefCount(
NVDevEvoPtr pDevEvo,
NVSurfaceEvoPtr pSurfaceEvo,
NvBool increase)
{
@@ -488,7 +489,7 @@ static inline void HsChangeSurfaceFlipRefCount(
if (increase) {
nvEvoIncrementSurfaceRefCnts(pSurfaceEvo);
} else {
nvEvoDecrementSurfaceRefCnts(pSurfaceEvo);
nvEvoDecrementSurfaceRefCnts(pDevEvo, pSurfaceEvo);
}
}
}

View File

@@ -68,8 +68,6 @@ NVEvoApiHandlesRec *nvGetSurfaceHandlesFromOpenDev(
struct NvKmsPerOpenDev *pOpenDev);
const NVEvoApiHandlesRec *nvGetSurfaceHandlesFromOpenDevConst(
const struct NvKmsPerOpenDev *pOpenDev);
NVDevEvoPtr nvGetDevEvoFromOpenDev(
const struct NvKmsPerOpenDev *pOpenDev);
void nvKmsServiceNonStallInterrupt(void *dataPtr, NvU32 dataU32);

View File

@@ -47,7 +47,8 @@ void nvEvoIncrementSurfaceStructRefCnt(NVSurfaceEvoPtr pSurfaceEvo);
void nvEvoDecrementSurfaceStructRefCnt(NVSurfaceEvoPtr pSurfaceEvo);
void nvEvoIncrementSurfaceRefCnts(NVSurfaceEvoPtr pSurfaceEvo);
void nvEvoDecrementSurfaceRefCnts(NVSurfaceEvoPtr pSurfaceEvo);
void nvEvoDecrementSurfaceRefCnts(NVDevEvoPtr pDevEvo,
NVSurfaceEvoPtr pSurfaceEvo);
NvBool nvEvoSurfaceRefCntsTooLarge(const NVSurfaceEvoRec *pSurfaceEvo);

View File

@@ -1880,7 +1880,11 @@ static inline NvU32 nvHardwareHeadToApiHead(const NVDevEvoRec *pDevEvo,
*/
if (head < pDevEvo->numHeads) {
return (pDevEvo->numHeads - 1) - head;
if (!nvkms_force_api_to_hw_head_identity_mappings()) {
return (pDevEvo->numHeads - 1) - head;
} else {
return head;
}
} else {
nvAssert(head == NV_INVALID_HEAD);
return head;
@@ -2360,11 +2364,19 @@ typedef struct _NVFrameLockEvo {
NvBool videoModeReadOnly; /* If video mode is read-only */
NvU32 maxMulDivValue; /* Max sync multiply/divide value */
NvBool mulDivSupported; /* Whether this board supports setting a sync
* multiplier/divider; maxMulDivValue is only
* valid if this is true */
/* Current device state */
enum NvKmsFrameLockAttributePolarityValue polarity;
NvU32 syncDelay;
NvU32 syncInterval;
enum NvKmsFrameLockAttributeVideoModeValue videoMode;
NvU8 mulDivValue;
enum NvKmsFrameLockAttributeMulDivModeValue mulDivMode;
NvBool testMode;
} NVFrameLockEvoRec;

View File

@@ -2820,6 +2820,8 @@ enum NvKmsFrameLockAttribute {
NV_KMS_FRAMELOCK_ATTRIBUTE_SYNC_RATE,
NV_KMS_FRAMELOCK_ATTRIBUTE_SYNC_RATE_4,
NV_KMS_FRAMELOCK_ATTRIBUTE_INCOMING_HOUSE_SYNC_RATE,
NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_VALUE,
NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE,
};
/*! Values for the NV_KMS_FRAMELOCK_ATTRIBUTE_POLARITY attribute. */
@@ -2857,6 +2859,12 @@ enum NvKmsFrameLockAttributePortStatusValue {
NV_KMS_FRAMELOCK_ATTRIBUTE_PORT_STATUS_OUTPUT = 1,
};
/*! Values for the NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE attribute. */
enum NvKmsFrameLockAttributeMulDivModeValue {
NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE_MULTIPLY = 0,
NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE_DIVIDE = 1,
};
struct NvKmsSetFrameLockAttributeRequest {
NvKmsFrameLockHandle frameLockHandle;
enum NvKmsFrameLockAttribute attribute;

View File

@@ -77,6 +77,7 @@ typedef struct {
} read_minval;
} NvKmsSyncPtOpParams;
NvBool nvkms_force_api_to_hw_head_identity_mappings(void);
NvBool nvkms_output_rounding_fix(void);
void nvkms_call_rm (void *ops);

View File

@@ -118,7 +118,7 @@ SetCursorImageOneHead(NVDispEvoPtr pDispEvo,
}
if (pSurfaceEvoOld) {
nvEvoDecrementSurfaceRefCnts(pSurfaceEvoOld);
nvEvoDecrementSurfaceRefCnts(pDevEvo, pSurfaceEvoOld);
}
pDevEvo->gpus[sd].headState[head].cursor.pSurfaceEvo = pSurfaceEvoNew;

View File

@@ -440,6 +440,8 @@ static NVFrameLockEvoPtr AllocFrameLockEvo(NVDevEvoPtr pDevEvo,
pFrameLockEvo->testMode = FALSE;
pFrameLockEvo->houseSyncMode =
NV_KMS_FRAMELOCK_ATTRIBUTE_HOUSE_SYNC_MODE_DISABLED;
pFrameLockEvo->mulDivValue = 1;
pFrameLockEvo->mulDivMode = NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE_MULTIPLY;
/* Query the framelock revision information */
if (nvRmApiControl(nvEvoGlobal.clientHandle,
@@ -482,6 +484,9 @@ static NVFrameLockEvoPtr AllocFrameLockEvo(NVDevEvoPtr pDevEvo,
pFrameLockEvo->maxSyncInterval = gsyncGetCapsParams.maxSyncInterval;
pFrameLockEvo->videoModeReadOnly = !!(gsyncGetCapsParams.capFlags &
NV30F1_CTRL_GSYNC_GET_CAPS_CAP_FLAGS_ONLY_GET_VIDEO_MODE);
pFrameLockEvo->mulDivSupported = !!(gsyncGetCapsParams.capFlags &
NV30F1_CTRL_GSYNC_GET_CAPS_CAP_FLAGS_MULTIPLY_DIVIDE_SYNC);
pFrameLockEvo->maxMulDivValue = gsyncGetCapsParams.maxMulDivValue;
/* Determine if house sync is selectable on this frame lock device */
if (!FrameLockUseHouseSyncGetSupport(pFrameLockEvo,
@@ -865,6 +870,74 @@ static NvBool FrameLockSetSyncDelay(NVFrameLockEvoPtr pFrameLockEvo, NvS64 val)
return TRUE;
}
/*!
* Set the sync multiply/divide value given in val. Returns FALSE if the
* assignment failed. Assigns pFrameLockEvo->mulDivValue upon success.
*/
static NvBool SetFrameLockMulDivVal(NVFrameLockEvoPtr pFrameLockEvo, NvS64 val)
{
NV30F1_CTRL_GSYNC_SET_CONTROL_PARAMS_PARAMS
gsyncSetControlParamsParams = { 0 };
NvU32 ret;
if (!pFrameLockEvo->mulDivSupported ||
(val > pFrameLockEvo->maxMulDivValue)) {
return FALSE;
}
gsyncSetControlParamsParams.which =
NV30F1_CTRL_GSYNC_SET_CONTROL_SYNC_MULTIPLY_DIVIDE;
gsyncSetControlParamsParams.syncMulDiv.multiplyDivideValue = val;
gsyncSetControlParamsParams.syncMulDiv.multiplyDivideMode = pFrameLockEvo->mulDivMode;
ret = nvRmApiControl(nvEvoGlobal.clientHandle,
pFrameLockEvo->device,
NV30F1_CTRL_CMD_GSYNC_SET_CONTROL_PARAMS,
&gsyncSetControlParamsParams,
sizeof(gsyncSetControlParamsParams));
if (ret != NVOS_STATUS_SUCCESS) return FALSE;
pFrameLockEvo->mulDivValue = val;
return TRUE;
}
/*!
* Set the sync multiply/divide mode given in val. Returns FALSE if the
* assignment failed. Assigns pFrameLockEvo->mulDivMode upon success.
*/
static NvBool SetFrameLockMulDivMode(NVFrameLockEvoPtr pFrameLockEvo, NvS64 val)
{
NV30F1_CTRL_GSYNC_SET_CONTROL_PARAMS_PARAMS
gsyncSetControlParamsParams = { 0 };
NvU32 ret;
if (!pFrameLockEvo->mulDivSupported ||
((val != NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE_MULTIPLY) &&
(val != NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE_DIVIDE))) {
return FALSE;
}
gsyncSetControlParamsParams.which =
NV30F1_CTRL_GSYNC_SET_CONTROL_SYNC_MULTIPLY_DIVIDE;
gsyncSetControlParamsParams.syncMulDiv.multiplyDivideValue = pFrameLockEvo->mulDivValue;
gsyncSetControlParamsParams.syncMulDiv.multiplyDivideMode = val;
ret = nvRmApiControl(nvEvoGlobal.clientHandle,
pFrameLockEvo->device,
NV30F1_CTRL_CMD_GSYNC_SET_CONTROL_PARAMS,
&gsyncSetControlParamsParams,
sizeof(gsyncSetControlParamsParams));
if (ret != NVOS_STATUS_SUCCESS) return FALSE;
pFrameLockEvo->mulDivMode = val;
return TRUE;
}
/*!
* Set the sync interval to the value given in val. Returns FALSE if
* the assignment failed. Assigns pFrameLockEvo->syncInterval upon
@@ -1342,6 +1415,12 @@ static NvBool ResetHardwareOneDisp(NVDispEvoPtr pDispEvo, NvS64 value)
if (!FrameLockSetTestMode(pFrameLockEvo, pFrameLockEvo->testMode)) {
ret = FALSE;
}
if (!SetFrameLockMulDivVal(pFrameLockEvo, pFrameLockEvo->mulDivValue)) {
ret = FALSE;
}
if (!SetFrameLockMulDivMode(pFrameLockEvo, pFrameLockEvo->mulDivMode)) {
ret = FALSE;
}
/* Since (we think) sync is disabled, these should always be disabled */
if (!FrameLockSetWatchdog(pFrameLockEvo, FALSE)) {
@@ -1452,6 +1531,61 @@ static NvBool GetFrameLockSyncDelayValidValues(
return TRUE;
}
static NvBool GetFrameLockMulDivVal(const NVFrameLockEvoRec *pFrameLockEvo,
enum NvKmsFrameLockAttribute attribute,
NvS64 *val)
{
if (!pFrameLockEvo->mulDivSupported) {
return FALSE;
}
*val = pFrameLockEvo->mulDivValue;
return TRUE;
}
static NvBool GetFrameLockMulDivValValidValues(
const NVFrameLockEvoRec *pFrameLockEvo,
struct NvKmsAttributeValidValuesCommonReply *pValidValues)
{
nvAssert(pValidValues->type == NV_KMS_ATTRIBUTE_TYPE_RANGE);
if (!pFrameLockEvo->mulDivSupported) {
return FALSE;
}
pValidValues->u.range.min = 1;
pValidValues->u.range.max = pFrameLockEvo->maxMulDivValue;
return TRUE;
}
static NvBool GetFrameLockMulDivModeValidValues(
const NVFrameLockEvoRec *pFrameLockEvo,
struct NvKmsAttributeValidValuesCommonReply *pValidValues)
{
if (!pFrameLockEvo->mulDivSupported) {
return FALSE;
}
nvAssert(pValidValues->type == NV_KMS_ATTRIBUTE_TYPE_INTEGER);
return TRUE;
}
static NvBool GetFrameLockMulDivMode(const NVFrameLockEvoRec *pFrameLockEvo,
enum NvKmsFrameLockAttribute attribute,
NvS64 *val)
{
if (!pFrameLockEvo->mulDivSupported) {
return FALSE;
}
*val = pFrameLockEvo->mulDivMode;
return TRUE;
}
static NvBool SetHouseSyncMode(NVFrameLockEvoPtr pFrameLockEvo, NvS64 val)
{
if ((val < 0) || (val > 31)) {
@@ -2085,6 +2219,18 @@ static const struct {
.getValidValues = NULL,
.type = NV_KMS_ATTRIBUTE_TYPE_INTEGER,
},
[NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_VALUE] = {
.set = SetFrameLockMulDivVal,
.get = GetFrameLockMulDivVal,
.getValidValues = GetFrameLockMulDivValValidValues,
.type = NV_KMS_ATTRIBUTE_TYPE_RANGE,
},
[NV_KMS_FRAMELOCK_ATTRIBUTE_MULTIPLY_DIVIDE_MODE] = {
.set = SetFrameLockMulDivMode,
.get = GetFrameLockMulDivMode,
.getValidValues = GetFrameLockMulDivModeValidValues,
.type = NV_KMS_ATTRIBUTE_TYPE_INTEGER,
},
};
NvBool nvSetFrameLockAttributeEvo(

View File

@@ -1837,16 +1837,21 @@ static void HsConfigInitFlipQueue(
}
static void HsConfigUpdateSurfaceRefCount(
NVDevEvoPtr pDevEvo,
const NVHsChannelConfig *pChannelConfig,
NvBool increase)
{
HsChangeSurfaceFlipRefCount(pChannelConfig->warpMesh.pSurface, increase);
HsChangeSurfaceFlipRefCount(
pDevEvo, pChannelConfig->warpMesh.pSurface, increase);
HsChangeSurfaceFlipRefCount(pChannelConfig->pBlendTexSurface, increase);
HsChangeSurfaceFlipRefCount(
pDevEvo, pChannelConfig->pBlendTexSurface, increase);
HsChangeSurfaceFlipRefCount(pChannelConfig->pOffsetTexSurface, increase);
HsChangeSurfaceFlipRefCount(
pDevEvo, pChannelConfig->pOffsetTexSurface, increase);
HsChangeSurfaceFlipRefCount(pChannelConfig->cursor.pSurfaceEvo, increase);
HsChangeSurfaceFlipRefCount(
pDevEvo, pChannelConfig->cursor.pSurfaceEvo, increase);
}
/*!
@@ -2258,6 +2263,7 @@ void nvHsConfigStart(
*/
if (pHsConfigOneHead->pHsChannel != NULL) {
HsConfigUpdateSurfaceRefCount(
pDevEvo,
&pHsConfigOneHead->channelConfig,
TRUE /* increase */);
}
@@ -2268,6 +2274,7 @@ void nvHsConfigStart(
*/
if (pDispEvo->pHsChannel[apiHead] != NULL) {
HsConfigUpdateSurfaceRefCount(
pDevEvo,
&pDispEvo->pHsChannel[apiHead]->config,
FALSE /* increase */);
}

View File

@@ -169,6 +169,8 @@ static void HsIoctlSetCursorImage(
NVHsChannelEvoRec *pHsChannel,
NVSurfaceEvoRec *pSurfaceEvo)
{
NVDevEvoPtr pDevEvo = pHsChannel->pDispEvo->pDevEvo;
/*
* Increment the refcnt of the new surface, and
* decrement the refcnt of the old surface.
@@ -178,10 +180,10 @@ static void HsIoctlSetCursorImage(
*/
HsChangeSurfaceFlipRefCount(
pSurfaceEvo, TRUE /* increase */);
pDevEvo, pSurfaceEvo, TRUE /* increase */);
HsChangeSurfaceFlipRefCount(
pHsChannel->config.cursor.pSurfaceEvo, FALSE /* increase */);
pDevEvo, pHsChannel->config.cursor.pSurfaceEvo, FALSE /* increase */);
pHsChannel->config.cursor.pSurfaceEvo = pSurfaceEvo;

View File

@@ -549,21 +549,22 @@ static NvBool HsFlipQueueEntryIsReady(
* Update the reference count of all the surfaces described in the pFlipState.
*/
static void HsUpdateFlipQueueEntrySurfaceRefCount(
NVDevEvoPtr pDevEvo,
const NVHsLayerRequestedFlipState *pFlipState,
NvBool increase)
{
HsChangeSurfaceFlipRefCount(
pFlipState->pSurfaceEvo[NVKMS_LEFT], increase);
pDevEvo, pFlipState->pSurfaceEvo[NVKMS_LEFT], increase);
HsChangeSurfaceFlipRefCount(
pFlipState->pSurfaceEvo[NVKMS_RIGHT], increase);
pDevEvo, pFlipState->pSurfaceEvo[NVKMS_RIGHT], increase);
if (!pFlipState->syncObject.usingSyncpt) {
HsChangeSurfaceFlipRefCount(
pFlipState->syncObject.u.semaphores.acquireSurface.pSurfaceEvo, increase);
pDevEvo, pFlipState->syncObject.u.semaphores.acquireSurface.pSurfaceEvo, increase);
HsChangeSurfaceFlipRefCount(
pFlipState->syncObject.u.semaphores.releaseSurface.pSurfaceEvo, increase);
pDevEvo, pFlipState->syncObject.u.semaphores.releaseSurface.pSurfaceEvo, increase);
}
}
@@ -602,7 +603,7 @@ static void HsReleaseFlipQueueEntry(
* HeadSurface no longer needs to read from the surfaces in pFlipState;
* decrement their reference counts.
*/
HsUpdateFlipQueueEntrySurfaceRefCount(pFlipState, FALSE);
HsUpdateFlipQueueEntrySurfaceRefCount(pDevEvo, pFlipState, FALSE);
}
/*!
@@ -684,6 +685,7 @@ void nvHsPushFlipQueueEntry(
const NvU8 layer,
const NVHsLayerRequestedFlipState *pFlipState)
{
NVDevEvoPtr pDevEvo = pHsChannel->pDispEvo->pDevEvo;
NVListRec *pFlipQueue = &pHsChannel->flipQueue[layer].queue;
NVHsChannelFlipQueueEntry *pEntry = nvCalloc(1, sizeof(*pEntry));
@@ -700,7 +702,7 @@ void nvHsPushFlipQueueEntry(
/* Increment the ref counts on the surfaces in the flip queue entry. */
HsUpdateFlipQueueEntrySurfaceRefCount(&pEntry->hwState, TRUE);
HsUpdateFlipQueueEntrySurfaceRefCount(pDevEvo, &pEntry->hwState, TRUE);
/* "Fast forward" through existing flip queue entries that are ready. */
@@ -722,7 +724,7 @@ void nvHsPushFlipQueueEntry(
* If this function returns TRUE, it is the caller's responsibility to
* eventually call
*
* HsUpdateFlipQueueEntrySurfaceRefCount(pFlipState, FALSE)
* HsUpdateFlipQueueEntrySurfaceRefCount(pDevEvo, pFlipState, FALSE)
*
* for the returned pFlipState.
*
@@ -2097,9 +2099,15 @@ static NvBool HsCanOmitNonSgHsUpdate(NVHsChannelEvoPtr pHsChannel)
* config) still require rendering an updated frame to the backbuffer.
* Thus, we will simply limit this optimization for frames that come
* within one frame time after the last recorded flip.
*
* This doesn't apply with full screen swap group flipping clients, which
* must have one fliplocked hardware flip for each flip IOCTL request,
* and would break if RG interrupt fake flips interfered with the flip
* queue.
*/
if (pHeadSwapGroup &&
pHeadSwapGroup->swapGroupIsFullscreen) {
pHeadSwapGroup->swapGroupIsFullscreen &&
!pHsChannel->swapGroupFlipping) {
NvU64 nowUs = nvkms_get_usec();
NvU64 frameTimeUs = nvEvoFrametimeUsFromTimings(
@@ -2243,8 +2251,11 @@ static void HsVBlankCallback(NVDispEvoRec *pDispEvo,
*/
/*
* When fullscreen swapgroup flipping, we don't need to update
* non-swapgroup content at vblank.
* When fullscreen swapgroup flipping, updating
* non-swapgroup content at vblank is unnecessary and
* dangerous, since it results in releasing client
* semaphores before their contents have actually been
* displayed.
*/
if (!pHsChannel->swapGroupFlipping) {
nvHsNextFrame(pHsDevice, pHsChannel,

View File

@@ -1790,7 +1790,7 @@ static void ChangeSurfaceFlipRefCount(
if (increase) {
nvEvoIncrementSurfaceRefCnts(pSurfaceEvo);
} else {
nvEvoDecrementSurfaceRefCnts(pSurfaceEvo);
nvEvoDecrementSurfaceRefCnts(pDevEvo, pSurfaceEvo);
}
}
}

View File

@@ -958,7 +958,7 @@ void nvEvoFreeClientSurfaces(NVDevEvoPtr pDevEvo,
nvEvoDestroyApiHandle(pOpenDevSurfaceHandles, surfaceHandle);
if (isOwner) {
nvEvoDecrementSurfaceRefCnts(pSurfaceEvo);
nvEvoDecrementSurfaceRefCnts(pDevEvo, pSurfaceEvo);
} else {
nvEvoDecrementSurfaceStructRefCnt(pSurfaceEvo);
}
@@ -1003,7 +1003,7 @@ void nvEvoUnregisterSurface(NVDevEvoPtr pDevEvo,
/* Remove the handle from the calling client's namespace. */
nvEvoDestroyApiHandle(pOpenDevSurfaceHandles, surfaceHandle);
nvEvoDecrementSurfaceRefCnts(pSurfaceEvo);
nvEvoDecrementSurfaceRefCnts(pDevEvo, pSurfaceEvo);
}
void nvEvoReleaseSurface(NVDevEvoPtr pDevEvo,
@@ -1041,15 +1041,13 @@ void nvEvoIncrementSurfaceRefCnts(NVSurfaceEvoPtr pSurfaceEvo)
pSurfaceEvo->structRefCnt++;
}
void nvEvoDecrementSurfaceRefCnts(NVSurfaceEvoPtr pSurfaceEvo)
void nvEvoDecrementSurfaceRefCnts(NVDevEvoPtr pDevEvo,
NVSurfaceEvoPtr pSurfaceEvo)
{
nvAssert(pSurfaceEvo->rmRefCnt >= 1);
pSurfaceEvo->rmRefCnt--;
if (pSurfaceEvo->rmRefCnt == 0) {
NVDevEvoPtr pDevEvo =
nvGetDevEvoFromOpenDev(pSurfaceEvo->owner.pOpenDev);
/*
* Don't sync if this surface was registered as not requiring display
* hardware access, to WAR timeouts that result from OGL unregistering
@@ -1224,7 +1222,7 @@ void nvEvoUnregisterDeferredRequestFifo(
pDeferredRequestFifo->fifo,
0);
nvEvoDecrementSurfaceRefCnts(pDeferredRequestFifo->pSurfaceEvo);
nvEvoDecrementSurfaceRefCnts(pDevEvo, pDeferredRequestFifo->pSurfaceEvo);
nvFree(pDeferredRequestFifo);
}

View File

@@ -5795,13 +5795,6 @@ NvBool nvSurfaceEvoInAnyOpens(const NVSurfaceEvoRec *pSurfaceEvo)
}
#endif
NVDevEvoPtr nvGetDevEvoFromOpenDev(
const struct NvKmsPerOpenDev *pOpenDev)
{
nvAssert(pOpenDev != NULL);
return pOpenDev->pDevEvo;
}
const struct NvKmsFlipPermissions *nvGetFlipPermissionsFromOpenDev(
const struct NvKmsPerOpenDev *pOpenDev)
{