drivers/gpu/drm/amd/pm/legacy-dpm/si_smc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/pm/legacy-dpm/si_smc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/pm/legacy-dpm/si_smc.c- Extension
.c- Size
- 7391 bytes
- Lines
- 302
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hamdgpu.hsid.hppsmc.hamdgpu_ucode.hsislands_smc.hsmu/smu_6_0_d.hsmu/smu_6_0_sh_mask.hgca/gfx_6_0_d.hgca/gfx_6_0_sh_mask.h
Detected Declarations
function filesfunction amdgpu_si_copy_bytes_to_smcfunction amdgpu_si_start_smcfunction amdgpu_si_reset_smcfunction amdgpu_si_program_jump_on_startfunction amdgpu_si_smc_clockfunction amdgpu_si_is_smc_runningfunction amdgpu_si_send_msg_to_smcfunction amdgpu_si_wait_for_smc_inactivefunction amdgpu_si_load_smc_ucodefunction amdgpu_si_read_smc_sram_dwordfunction amdgpu_si_write_smc_sram_dword
Annotated Snippet
while (byte_count > 0) {
/* SMC address space is BE */
data = (data << 8) + *src++;
byte_count--;
}
data <<= extra_shift;
data |= (original_data & ~((~0UL) << extra_shift));
ret = si_set_smc_sram_address(adev, addr, limit);
if (ret)
goto done;
WREG32(mmSMC_IND_DATA_0, data);
}
done:
spin_unlock_irqrestore(&adev->reg.smc.lock, flags);
return ret;
}
void amdgpu_si_start_smc(struct amdgpu_device *adev)
{
u32 tmp = RREG32_SMC(SMC_SYSCON_RESET_CNTL);
tmp &= ~RST_REG;
WREG32_SMC(SMC_SYSCON_RESET_CNTL, tmp);
}
void amdgpu_si_reset_smc(struct amdgpu_device *adev)
{
u32 tmp;
RREG32(mmCB_CGTT_SCLK_CTRL);
RREG32(mmCB_CGTT_SCLK_CTRL);
RREG32(mmCB_CGTT_SCLK_CTRL);
RREG32(mmCB_CGTT_SCLK_CTRL);
tmp = RREG32_SMC(SMC_SYSCON_RESET_CNTL) |
RST_REG;
WREG32_SMC(SMC_SYSCON_RESET_CNTL, tmp);
}
int amdgpu_si_program_jump_on_start(struct amdgpu_device *adev)
{
static const u8 data[] = { 0x0E, 0x00, 0x40, 0x40 };
return amdgpu_si_copy_bytes_to_smc(adev, 0x0, data, 4, sizeof(data)+1);
}
void amdgpu_si_smc_clock(struct amdgpu_device *adev, bool enable)
{
u32 tmp = RREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0);
if (enable)
tmp &= ~CK_DISABLE;
else
tmp |= CK_DISABLE;
WREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0, tmp);
}
bool amdgpu_si_is_smc_running(struct amdgpu_device *adev)
{
u32 rst = RREG32_SMC(SMC_SYSCON_RESET_CNTL);
u32 clk = RREG32_SMC(SMC_SYSCON_CLOCK_CNTL_0);
if (!(rst & RST_REG) && !(clk & CK_DISABLE))
return true;
return false;
}
PPSMC_Result amdgpu_si_send_msg_to_smc(struct amdgpu_device *adev,
PPSMC_Msg msg)
{
u32 tmp;
int i;
int usec_timeout;
/* SMC seems to process some messages exceptionally slowly. */
switch (msg) {
case PPSMC_MSG_NoForcedLevel:
case PPSMC_MSG_SetEnabledLevels:
case PPSMC_MSG_SetForcedLevels:
case PPSMC_MSG_DisableULV:
case PPSMC_MSG_SwitchToSwState:
usec_timeout = 1000000; /* 1 sec */
Annotation
- Immediate include surface: `linux/firmware.h`, `amdgpu.h`, `sid.h`, `ppsmc.h`, `amdgpu_ucode.h`, `sislands_smc.h`, `smu/smu_6_0_d.h`, `smu/smu_6_0_sh_mask.h`.
- Detected declarations: `function files`, `function amdgpu_si_copy_bytes_to_smc`, `function amdgpu_si_start_smc`, `function amdgpu_si_reset_smc`, `function amdgpu_si_program_jump_on_start`, `function amdgpu_si_smc_clock`, `function amdgpu_si_is_smc_running`, `function amdgpu_si_send_msg_to_smc`, `function amdgpu_si_wait_for_smc_inactive`, `function amdgpu_si_load_smc_ucode`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.