mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
drm/amdgpu: Add uvd indirect to register block
Add uvd indirect method to register access block and replace the existing calls from adev. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
f4eb08f8b2
commit
366201e790
|
|
@ -913,11 +913,7 @@ struct amdgpu_device {
|
|||
amdgpu_rreg64_t pcie_rreg64;
|
||||
amdgpu_wreg64_t pcie_wreg64;
|
||||
amdgpu_rreg64_ext_t pcie_rreg64_ext;
|
||||
amdgpu_wreg64_ext_t pcie_wreg64_ext;
|
||||
/* protects concurrent UVD register access */
|
||||
spinlock_t uvd_ctx_idx_lock;
|
||||
amdgpu_rreg_t uvd_ctx_rreg;
|
||||
amdgpu_wreg_t uvd_ctx_wreg;
|
||||
amdgpu_wreg64_ext_t pcie_wreg64_ext;
|
||||
/* protects concurrent DIDT register access */
|
||||
spinlock_t didt_idx_lock;
|
||||
amdgpu_rreg_t didt_rreg;
|
||||
|
|
@ -1340,8 +1336,8 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
|
|||
#define WREG64_PCIE_EXT(reg, v) adev->pcie_wreg64_ext(adev, (reg), (v))
|
||||
#define RREG32_SMC(reg) amdgpu_reg_smc_rd32(adev, (reg))
|
||||
#define WREG32_SMC(reg, v) amdgpu_reg_smc_wr32(adev, (reg), (v))
|
||||
#define RREG32_UVD_CTX(reg) adev->uvd_ctx_rreg(adev, (reg))
|
||||
#define WREG32_UVD_CTX(reg, v) adev->uvd_ctx_wreg(adev, (reg), (v))
|
||||
#define RREG32_UVD_CTX(reg) amdgpu_reg_uvd_ctx_rd32(adev, (reg))
|
||||
#define WREG32_UVD_CTX(reg, v) amdgpu_reg_uvd_ctx_wr32(adev, (reg), (v))
|
||||
#define RREG32_DIDT(reg) adev->didt_rreg(adev, (reg))
|
||||
#define WREG32_DIDT(reg, v) adev->didt_wreg(adev, (reg), (v))
|
||||
#define RREG32_GC_CAC(reg) adev->gc_cac_rreg(adev, (reg))
|
||||
|
|
|
|||
|
|
@ -3842,8 +3842,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
|
|||
adev->pcie_wreg64 = &amdgpu_invalid_wreg64;
|
||||
adev->pcie_rreg64_ext = &amdgpu_invalid_rreg64_ext;
|
||||
adev->pcie_wreg64_ext = &amdgpu_invalid_wreg64_ext;
|
||||
adev->uvd_ctx_rreg = &amdgpu_invalid_rreg;
|
||||
adev->uvd_ctx_wreg = &amdgpu_invalid_wreg;
|
||||
adev->didt_rreg = &amdgpu_invalid_rreg;
|
||||
adev->didt_wreg = &amdgpu_invalid_wreg;
|
||||
adev->gc_cac_rreg = &amdgpu_invalid_rreg;
|
||||
|
|
@ -3895,7 +3893,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
|
|||
|
||||
spin_lock_init(&adev->mmio_idx_lock);
|
||||
spin_lock_init(&adev->pcie_idx_lock);
|
||||
spin_lock_init(&adev->uvd_ctx_idx_lock);
|
||||
spin_lock_init(&adev->didt_idx_lock);
|
||||
spin_lock_init(&adev->gc_cac_idx_lock);
|
||||
spin_lock_init(&adev->se_cac_idx_lock);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ void amdgpu_reg_access_init(struct amdgpu_device *adev)
|
|||
spin_lock_init(&adev->reg.smc.lock);
|
||||
adev->reg.smc.rreg = NULL;
|
||||
adev->reg.smc.wreg = NULL;
|
||||
|
||||
spin_lock_init(&adev->reg.uvd_ctx.lock);
|
||||
adev->reg.uvd_ctx.rreg = NULL;
|
||||
adev->reg.uvd_ctx.wreg = NULL;
|
||||
}
|
||||
|
||||
uint32_t amdgpu_reg_smc_rd32(struct amdgpu_device *adev, uint32_t reg)
|
||||
|
|
@ -58,6 +62,27 @@ void amdgpu_reg_smc_wr32(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
|
|||
adev->reg.smc.wreg(adev, reg, v);
|
||||
}
|
||||
|
||||
uint32_t amdgpu_reg_uvd_ctx_rd32(struct amdgpu_device *adev, uint32_t reg)
|
||||
{
|
||||
if (!adev->reg.uvd_ctx.rreg) {
|
||||
dev_err_once(adev->dev,
|
||||
"UVD_CTX register read not supported\n");
|
||||
return 0;
|
||||
}
|
||||
return adev->reg.uvd_ctx.rreg(adev, reg);
|
||||
}
|
||||
|
||||
void amdgpu_reg_uvd_ctx_wr32(struct amdgpu_device *adev, uint32_t reg,
|
||||
uint32_t v)
|
||||
{
|
||||
if (!adev->reg.uvd_ctx.wreg) {
|
||||
dev_err_once(adev->dev,
|
||||
"UVD_CTX register write not supported\n");
|
||||
return;
|
||||
}
|
||||
adev->reg.uvd_ctx.wreg(adev, reg, v);
|
||||
}
|
||||
|
||||
/*
|
||||
* register access helper functions.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,11 +40,14 @@ struct amdgpu_reg_ind {
|
|||
|
||||
struct amdgpu_reg_access {
|
||||
struct amdgpu_reg_ind smc;
|
||||
struct amdgpu_reg_ind uvd_ctx;
|
||||
};
|
||||
|
||||
void amdgpu_reg_access_init(struct amdgpu_device *adev);
|
||||
uint32_t amdgpu_reg_smc_rd32(struct amdgpu_device *adev, uint32_t reg);
|
||||
void amdgpu_reg_smc_wr32(struct amdgpu_device *adev, uint32_t reg, uint32_t v);
|
||||
uint32_t amdgpu_reg_uvd_ctx_rd32(struct amdgpu_device *adev, uint32_t reg);
|
||||
void amdgpu_reg_uvd_ctx_wr32(struct amdgpu_device *adev, uint32_t reg, uint32_t v);
|
||||
|
||||
typedef uint32_t (*amdgpu_rreg_ext_t)(struct amdgpu_device *, uint64_t);
|
||||
typedef void (*amdgpu_wreg_ext_t)(struct amdgpu_device *, uint64_t, uint32_t);
|
||||
|
|
|
|||
|
|
@ -201,10 +201,10 @@ static u32 cik_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
|
|||
unsigned long flags;
|
||||
u32 r;
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
|
||||
r = RREG32(mmUVD_CTX_DATA);
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -212,10 +212,10 @@ static void cik_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
|
|||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
|
||||
WREG32(mmUVD_CTX_DATA, (v));
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
}
|
||||
|
||||
static u32 cik_didt_rreg(struct amdgpu_device *adev, u32 reg)
|
||||
|
|
@ -1988,8 +1988,8 @@ static int cik_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->reg.smc.wreg = cik_smc_wreg;
|
||||
adev->pcie_rreg = &cik_pcie_rreg;
|
||||
adev->pcie_wreg = &cik_pcie_wreg;
|
||||
adev->uvd_ctx_rreg = &cik_uvd_ctx_rreg;
|
||||
adev->uvd_ctx_wreg = &cik_uvd_ctx_wreg;
|
||||
adev->reg.uvd_ctx.rreg = &cik_uvd_ctx_rreg;
|
||||
adev->reg.uvd_ctx.wreg = &cik_uvd_ctx_wreg;
|
||||
adev->didt_rreg = &cik_didt_rreg;
|
||||
adev->didt_wreg = &cik_didt_wreg;
|
||||
|
||||
|
|
|
|||
|
|
@ -642,10 +642,6 @@ static int nv_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->pciep_rreg = amdgpu_device_pcie_port_rreg;
|
||||
adev->pciep_wreg = amdgpu_device_pcie_port_wreg;
|
||||
|
||||
/* TODO: will add them during VCN v2 implementation */
|
||||
adev->uvd_ctx_rreg = NULL;
|
||||
adev->uvd_ctx_wreg = NULL;
|
||||
|
||||
adev->didt_rreg = &nv_didt_rreg;
|
||||
adev->didt_wreg = &nv_didt_wreg;
|
||||
|
||||
|
|
|
|||
|
|
@ -1099,10 +1099,10 @@ static u32 si_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
|
|||
unsigned long flags;
|
||||
u32 r;
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
|
||||
r = RREG32(mmUVD_CTX_DATA);
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -1110,10 +1110,10 @@ static void si_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
|
|||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
|
||||
WREG32(mmUVD_CTX_DATA, (v));
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
}
|
||||
|
||||
static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = {
|
||||
|
|
@ -2043,8 +2043,8 @@ static int si_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->pcie_wreg = &si_pcie_wreg;
|
||||
adev->pciep_rreg = &si_pciep_rreg;
|
||||
adev->pciep_wreg = &si_pciep_wreg;
|
||||
adev->uvd_ctx_rreg = si_uvd_ctx_rreg;
|
||||
adev->uvd_ctx_wreg = si_uvd_ctx_wreg;
|
||||
adev->reg.uvd_ctx.rreg = &si_uvd_ctx_rreg;
|
||||
adev->reg.uvd_ctx.wreg = &si_uvd_ctx_wreg;
|
||||
adev->didt_rreg = NULL;
|
||||
adev->didt_wreg = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -245,10 +245,10 @@ static u32 soc15_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
|
|||
address = SOC15_REG_OFFSET(UVD, 0, mmUVD_CTX_INDEX);
|
||||
data = SOC15_REG_OFFSET(UVD, 0, mmUVD_CTX_DATA);
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(address, ((reg) & 0x1ff));
|
||||
r = RREG32(data);
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -259,10 +259,10 @@ static void soc15_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
|
|||
address = SOC15_REG_OFFSET(UVD, 0, mmUVD_CTX_INDEX);
|
||||
data = SOC15_REG_OFFSET(UVD, 0, mmUVD_CTX_DATA);
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(address, ((reg) & 0x1ff));
|
||||
WREG32(data, (v));
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
}
|
||||
|
||||
static u32 soc15_didt_rreg(struct amdgpu_device *adev, u32 reg)
|
||||
|
|
@ -969,8 +969,8 @@ static int soc15_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->pcie_wreg64 = &amdgpu_device_indirect_wreg64;
|
||||
adev->pcie_rreg64_ext = &amdgpu_device_indirect_rreg64_ext;
|
||||
adev->pcie_wreg64_ext = &amdgpu_device_indirect_wreg64_ext;
|
||||
adev->uvd_ctx_rreg = &soc15_uvd_ctx_rreg;
|
||||
adev->uvd_ctx_wreg = &soc15_uvd_ctx_wreg;
|
||||
adev->reg.uvd_ctx.rreg = &soc15_uvd_ctx_rreg;
|
||||
adev->reg.uvd_ctx.wreg = &soc15_uvd_ctx_wreg;
|
||||
adev->didt_rreg = &soc15_didt_rreg;
|
||||
adev->didt_wreg = &soc15_didt_wreg;
|
||||
adev->gc_cac_rreg = &soc15_gc_cac_rreg;
|
||||
|
|
|
|||
|
|
@ -596,10 +596,6 @@ static int soc21_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->pciep_rreg = amdgpu_device_pcie_port_rreg;
|
||||
adev->pciep_wreg = amdgpu_device_pcie_port_wreg;
|
||||
|
||||
/* TODO: will add them during VCN v2 implementation */
|
||||
adev->uvd_ctx_rreg = NULL;
|
||||
adev->uvd_ctx_wreg = NULL;
|
||||
|
||||
adev->didt_rreg = &soc21_didt_rreg;
|
||||
adev->didt_wreg = &soc21_didt_wreg;
|
||||
|
||||
|
|
|
|||
|
|
@ -368,8 +368,6 @@ static int soc24_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->pcie_wreg64 = &amdgpu_device_indirect_wreg64;
|
||||
adev->pciep_rreg = amdgpu_device_pcie_port_rreg;
|
||||
adev->pciep_wreg = amdgpu_device_pcie_port_wreg;
|
||||
adev->uvd_ctx_rreg = NULL;
|
||||
adev->uvd_ctx_wreg = NULL;
|
||||
adev->didt_rreg = NULL;
|
||||
adev->didt_wreg = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -260,8 +260,6 @@ static int soc_v1_0_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
adev->pciep_wreg = amdgpu_device_pcie_port_wreg;
|
||||
adev->pcie_rreg64_ext = &amdgpu_device_indirect_rreg64_ext;
|
||||
adev->pcie_wreg64_ext = &amdgpu_device_indirect_wreg64_ext;
|
||||
adev->uvd_ctx_rreg = NULL;
|
||||
adev->uvd_ctx_wreg = NULL;
|
||||
adev->didt_rreg = NULL;
|
||||
adev->didt_wreg = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -372,10 +372,10 @@ static u32 vi_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
|
|||
unsigned long flags;
|
||||
u32 r;
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
|
||||
r = RREG32(mmUVD_CTX_DATA);
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -383,10 +383,10 @@ static void vi_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
|
|||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_lock_irqsave(&adev->reg.uvd_ctx.lock, flags);
|
||||
WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
|
||||
WREG32(mmUVD_CTX_DATA, (v));
|
||||
spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
|
||||
spin_unlock_irqrestore(&adev->reg.uvd_ctx.lock, flags);
|
||||
}
|
||||
|
||||
static u32 vi_didt_rreg(struct amdgpu_device *adev, u32 reg)
|
||||
|
|
@ -1462,8 +1462,8 @@ static int vi_common_early_init(struct amdgpu_ip_block *ip_block)
|
|||
}
|
||||
adev->pcie_rreg = &vi_pcie_rreg;
|
||||
adev->pcie_wreg = &vi_pcie_wreg;
|
||||
adev->uvd_ctx_rreg = &vi_uvd_ctx_rreg;
|
||||
adev->uvd_ctx_wreg = &vi_uvd_ctx_wreg;
|
||||
adev->reg.uvd_ctx.rreg = &vi_uvd_ctx_rreg;
|
||||
adev->reg.uvd_ctx.wreg = &vi_uvd_ctx_wreg;
|
||||
adev->didt_rreg = &vi_didt_rreg;
|
||||
adev->didt_wreg = &vi_didt_wreg;
|
||||
adev->gc_cac_rreg = &vi_gc_cac_rreg;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user