Commit 071bba96 authored by Lijo Lazar's avatar Lijo Lazar Committed by Alex Deucher
Browse files

drm/amdgpu: Reserve discovery TMR only if needed



For legacy SOCs, discovery binary is sideloaded. Instead of checking for
binary blob, use a flag to determine if discovery region needs to be
reserved.

Signed-off-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 80e462c5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -298,10 +298,15 @@ static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
	else
		vram_size <<= 20;

	/*
	 * If in VRAM, discovery TMR is marked for reservation. If it is in system mem,
	 * then it is not required to be reserved.
	 */
	if (sz_valid) {
		uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
		amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
					  adev->discovery.size, false);
		adev->discovery.reserve_tmr = true;
	} else {
		ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary);
	}
@@ -418,8 +423,11 @@ static int amdgpu_discovery_verify_npsinfo(struct amdgpu_device *adev,

static const char *amdgpu_discovery_get_fw_name(struct amdgpu_device *adev)
{
	if (amdgpu_discovery == 2)
	if (amdgpu_discovery == 2) {
		/* Assume there is valid discovery TMR in VRAM even if binary is sideloaded */
		adev->discovery.reserve_tmr = true;
		return "amdgpu/ip_discovery.bin";
	}

	switch (adev->asic_type) {
	case CHIP_VEGA10:
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ struct amdgpu_discovery_info {
	struct ip_discovery_top *ip_top;
	uint32_t size;
	uint8_t *bin;
	bool reserve_tmr;
};

void amdgpu_discovery_fini(struct amdgpu_device *adev);
+9 −13
Original line number Diff line number Diff line
@@ -1769,19 +1769,15 @@ static int amdgpu_ttm_reserve_tmr(struct amdgpu_device *adev)
		ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS;
	}

	if (!adev->gmc.is_app_apu) {
	ret = amdgpu_bo_create_kernel_at(
			adev, adev->gmc.real_vram_size - reserve_size,
			reserve_size, &adev->mman.fw_reserved_memory, NULL);
		adev, adev->gmc.real_vram_size - reserve_size, reserve_size,
		&adev->mman.fw_reserved_memory, NULL);
	if (ret) {
		dev_err(adev->dev, "alloc tmr failed(%d)!\n", ret);
			amdgpu_bo_free_kernel(&adev->mman.fw_reserved_memory,
					      NULL, NULL);
		amdgpu_bo_free_kernel(&adev->mman.fw_reserved_memory, NULL,
				      NULL);
		return ret;
	}
	} else {
		DRM_DEBUG_DRIVER("backdoor fw loading path for PSP TMR, no reservation needed\n");
	}

	return 0;
}
@@ -1957,7 +1953,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
	 * If IP discovery enabled, a block of memory should be
	 * reserved for IP discovey.
	 */
	if (adev->discovery.bin) {
	if (adev->discovery.reserve_tmr) {
		r = amdgpu_ttm_reserve_tmr(adev);
		if (r)
			return r;