drivers/gfx/nvidia: Misc fixes, some debugging

Change-Id: I072cd3db5859331a036ce7963a3607a56f53f37b
Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford 2021-11-22 21:55:34 -07:00
parent 865292a883
commit 75468a84c0
3 changed files with 54 additions and 21 deletions

View File

@ -10,7 +10,7 @@
#define GPS_FUNC_PSHARESTATUS 32
#define GPS_FUNC_PSHAREPARAMS 42
Method (NVGB, 2, NotSerialized)
Method (GPS, 2, Serialized)
{
Printf("GPS {")
@ -24,13 +24,13 @@ Method (NVGB, 2, NotSerialized)
// Get current platform status, thermal budget
Case (GPS_FUNC_PSHARESTATUS) {
Printf(" GPS_FUNC_PSHARESTATUS")
Printf(" GPS_FUNC_PSHARESTATUS: %o", ToHexString(Arg1))
Local0 = Buffer (4) { 0 }
}
// Get GPU Boost platform parameters
Case (GPS_FUNC_PSHAREPARAMS) {
Printf(" GPS_FUNC_PSHAREPARAMS")
Printf(" GPS_FUNC_PSHAREPARAMS: %o", ToHexString(Arg1))
CreateField (Arg1, 0, 3, QTYP) // Query Type
CreateField (Arg1, 8, 1, GTMP) // GPU temperature status
CreateField (Arg1, 9, 1, CTMP) // CPU temperature status
@ -44,6 +44,8 @@ Method (NVGB, 2, NotSerialized)
VERS = 0x00010000
STAT = QTYP
Printf(" Query Type = %o", ToInteger(QTYP))
Switch (ToInteger(QTYP)) {
// Get current status
Case (0) {

View File

@ -10,11 +10,12 @@
#define GPS_REVISION_ID 0x200
#define JT_DSM_GUID "CBECA351-067B-4924-9CBD-B46B00B86F34"
#define JT_REVISION_ID 0x200
#define JT_REVISION_ID 0x103
#define NVOP_DSM_GUID "A486D8F8-0BDA-471B-A72B-6042A6B5BEE0"
#define NVOP_REVISION_ID 0x100
// 00:01.0
Device (\_SB.PCI0.PEG0)
{
Name (_ADR, CONFIG_DRIVERS_GFX_NVIDIA_BRIDGE << 16)
@ -24,12 +25,20 @@ Device (\_SB.PCI0.PEG0)
Method (_ON)
{
Printf("PEG0._ON {")
// TODO: Check for deferred GCx action
\_SB.PCI0.PEG0.DGPU._ON()
_STA = 1
Printf("} PEG0._ON")
}
Method (_OFF)
{
Printf("PEG0._OFF {")
// TODO: Check for deferred GCx action
\_SB.PCI0.PEG0.DGPU._OFF()
_STA = 0
Printf("} PEG0._OFF")
}
}
@ -37,15 +46,13 @@ Device (\_SB.PCI0.PEG0)
Name (_PR3, Package () { PWRR })
}
// 01:00.0
Device (\_SB.PCI0.PEG0.DGPU)
{
Name(_ADR, 0x00000000)
// GPU Power
Name (GPWR, 0)
// GCx State
Name (GCST, 0)
Name (GPWR, 0) // GPU Power
Name (GCST, 6) // GCx State
// For supporting Hybrid Graphics, the package refers to the PCIe controller
// itself, which leverages GC6 Control methods under the dGPU namespace.
@ -54,6 +61,7 @@ Device (\_SB.PCI0.PEG0.DGPU)
Method (_STA)
{
Printf("DGPU._STA")
/*
* Only return "On" when:
* - GPU power is good
@ -70,7 +78,7 @@ Device (\_SB.PCI0.PEG0.DGPU)
Method (_ON)
{
Printf("_ON {")
Printf("DGPU._ON {")
Printf(" Enable GPU power")
STXS(DGPU_PWR_EN)
Sleep(10)
@ -80,12 +88,13 @@ Device (\_SB.PCI0.PEG0.DGPU)
Sleep(10)
GPWR = 1
Printf("} _ON")
GCST = 0
Printf("} DGPU._ON")
}
Method (_OFF)
{
Printf("_OFF {")
Printf("DGPU._OFF {")
Printf(" Put GPU in reset")
CTXS(DGPU_RST_N)
Sleep(10)
@ -95,36 +104,57 @@ Device (\_SB.PCI0.PEG0.DGPU)
Sleep(10)
GPWR = 0
Printf("} _OFF")
GCST = 6
Printf("} DGPU._OFF")
}
Method (_PS0)
{
// XGXS, XGIS, XCLM
Printf("_PS0 {}")
}
Method (_PS3)
{
// EGNS, EGIS, EGIN
Printf("_PS3 {}")
}
Method (_DSM, 4, NotSerialized)
Method (_DSM, 4, Serialized)
{
// Notebook Common Interface
If (Arg0 == ToUUID(NBCI_DSM_GUID)) {
Printf("NBCI_DSM_GUID")
If (Arg1 <= NBCI_REVISION_ID) {
Printf(" TODO: Unimplemented!")
}
}
// NVIDIA GPU Boost
If (Arg0 == ToUUID(GPS_DSM_GUID)) {
Printf("GPS_DSM_GUID")
If (Arg1 <= GPS_REVISION_ID) {
Return(NVGB(Arg2, Arg3))
Return(GPS(Arg2, Arg3))
}
}
// NVIDIA Low Power States
If (Arg0 == ToUUID(JT_DSM_GUID)) {
Printf("JT_DSM_GUID")
If (Arg1 <= JT_REVISION_ID) {
Return(NVJT(Arg2, Arg3))
}
}
Printf("Unsupported GUID")
// Advanced Optimus
If (Arg0 == ToUUID(NVOP_DSM_GUID)) {
Printf("NVOP_DSM_GUID")
If (Arg1 <= NVOP_REVISION_ID) {
Printf(" TODO: Unimplemented!")
}
}
Printf("Unsupported GUID: %o", ToHexString(Arg0))
Return(NVIDIA_ERROR_UNSUPPORTED)
}

View File

@ -7,19 +7,20 @@
#define JT_FUNC_POWERCONTROL 3
#define JT_FUNC_PLATPOLICY 4
Method (NVJT, 2, NotSerialized)
Method (NVJT, 2, Serialized)
{
Printf("NVJT {")
Switch (ToInteger(Arg0)) {
Case (JT_FUNC_SUPPORT) {
Printf(" JT_FUNC_SUPPORT");
// Functions supported: 0, 1, 3, 4
Local0 = Buffer() { 0x1B, 0, 0, 0 }
//Local0 = Buffer() { 0x1B, 0, 0, 0 }
Local0 = Buffer() { 0x13, 0, 0, 0 }
}
Case (JT_FUNC_CAPS) {
Printf(" JT_FUNC_CAPS");
Local0 = Buffer(4) { 0, 0, 0, 0 }
Local0 = Buffer(4) { 0 }
// G-SYNC NVSR Power Features
CreateField (Local0, 0, 1, JTEN)
@ -78,7 +79,7 @@ Method (NVJT, 2, NotSerialized)
GSW = 0
// Maximum Revision Supported
CreateField (Local0, 20, 16, MXRV)
CreateField (Local0, 20, 12, MXRV)
MXRV = JT_REVISION_ID
}
@ -89,7 +90,7 @@ Method (NVJT, 2, NotSerialized)
}
Case (JT_FUNC_PLATPOLICY) {
Printf(" JT_FUNC_PLATPOLICY");
Printf(" JT_FUNC_PLATPOLICY: %o", ToHexString(Arg1));
//CreateField (Arg1, 2, 1, AUD) // Azalia Audio Device
//CreateField (Arg1, 3, 1, ADM) // Audio Disable Mask
//CreateField (Arg1, 4, 4, DGS) // Driver expected State Mask