Commit ce05ac56 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: optimize amdgpu_device_vram_access a bit.

Only write the _HI register when necessary.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Acked-by: default avatarJonathan Kim <Jonathan.Kim@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 42d708db
...@@ -183,20 +183,25 @@ bool amdgpu_device_supports_baco(struct drm_device *dev) ...@@ -183,20 +183,25 @@ bool amdgpu_device_supports_baco(struct drm_device *dev)
void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos, void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
uint32_t *buf, size_t size, bool write) uint32_t *buf, size_t size, bool write)
{ {
uint64_t last;
unsigned long flags; unsigned long flags;
uint32_t hi = ~0;
uint64_t last;
spin_lock_irqsave(&adev->mmio_idx_lock, flags);
for (last = pos + size; pos < last; pos += 4) {
uint32_t tmp = pos >> 31;
last = size - 4;
for (last += pos; pos <= last; pos += 4) {
spin_lock_irqsave(&adev->mmio_idx_lock, flags);
WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)pos) | 0x80000000); WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)pos) | 0x80000000);
WREG32_NO_KIQ(mmMM_INDEX_HI, pos >> 31); if (tmp != hi) {
WREG32_NO_KIQ(mmMM_INDEX_HI, tmp);
hi = tmp;
}
if (write) if (write)
WREG32_NO_KIQ(mmMM_DATA, *buf++); WREG32_NO_KIQ(mmMM_DATA, *buf++);
else else
*buf++ = RREG32_NO_KIQ(mmMM_DATA); *buf++ = RREG32_NO_KIQ(mmMM_DATA);
spin_unlock_irqrestore(&adev->mmio_idx_lock, flags);
} }
spin_unlock_irqrestore(&adev->mmio_idx_lock, flags);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment