Commit c6252390 authored by Luben Tuikov's avatar Luben Tuikov Committed by Alex Deucher
Browse files

drm/amdgpu: implement TMZ accessor (v3)



Implement an accessor of adev->tmz.enabled. Let not
code around access it as "if (adev->tmz.enabled)"
as the organization may change. Instead...

Recruit "bool amdgpu_is_tmz(adev)" to return
exactly this Boolean value. That is, this function
is now an accessor of an already initialized and
set adev and adev->tmz.

Add "void amdgpu_gmc_tmz_set(adev)" to check and
set adev->gmc.tmz_enabled at initialization
time. After which one uses "bool
amdgpu_is_tmz(adev)" to query whether adev
supports TMZ.

Also, remove circular header file include.

v2: Remove amdgpu_tmz.[ch] as requested.
v3: Move TMZ into GMC.

Signed-off-by: default avatarLuben Tuikov <luben.tuikov@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 562366c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
	amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o \
	amdgpu_gmc.o amdgpu_mmhub.o amdgpu_xgmi.o amdgpu_csa.o amdgpu_ras.o amdgpu_vm_cpu.o \
	amdgpu_vm_sdma.o amdgpu_discovery.o amdgpu_ras_eeprom.o amdgpu_nbio.o \
	amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_tmz.o
	amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o

amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o

+5 −5
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@
#include "amdgpu_umc.h"
#include "amdgpu_mmhub.h"
#include "amdgpu_df.h"
#include "amdgpu_tmz.h"

#define MAX_GPU_INSTANCE		16

@@ -937,9 +936,6 @@ struct amdgpu_device {
	/* df */
	struct amdgpu_df                df;

	/* tmz */
	struct amdgpu_tmz		tmz;

	struct amdgpu_ip_block          ip_blocks[AMDGPU_MAX_IP_NUM];
	int				num_ip_blocks;
	struct mutex	mn_lock;
@@ -1269,5 +1265,9 @@ _name##_show(struct device *dev, \
									\
static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name)

#endif
static inline bool amdgpu_is_tmz(struct amdgpu_device *adev)
{
       return adev->gmc.tmz_enabled;
}

#endif
+1 −2
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@
#include "amdgpu_ras.h"
#include "amdgpu_pmu.h"
#include "amdgpu_fru_eeprom.h"
#include "amdgpu_tmz.h"

#include <linux/suspend.h>
#include <drm/task_barrier.h>
@@ -1141,7 +1140,7 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)

	adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type);

	adev->tmz.enabled = amdgpu_is_tmz(adev);
	amdgpu_gmc_tmz_set(adev);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -242,8 +242,8 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
	if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
		return -EINVAL;

	if (!adev->tmz.enabled && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
		DRM_ERROR("Cannot allocate secure buffer while tmz is disabled\n");
	if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
		DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
		return -EINVAL;
	}

+25 −0
Original line number Diff line number Diff line
@@ -373,3 +373,28 @@ int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev)

	return 0;
}

/**
 * amdgpu_tmz_set -- check and set if a device supports TMZ
 * @adev: amdgpu_device pointer
 *
 * Check and set if an the device @adev supports Trusted Memory
 * Zones (TMZ).
 */
void amdgpu_gmc_tmz_set(struct amdgpu_device *adev)
{
	if (!amdgpu_tmz)
		return;

	if (adev->asic_type < CHIP_RAVEN ||
	    adev->asic_type == CHIP_ARCTURUS) {
		adev->gmc.tmz_enabled = false;
		dev_warn(adev->dev,
			 "Trusted Memory Zone (TMZ) feature not supported\n");
	} else {

		adev->gmc.tmz_enabled = true;
		dev_info(adev->dev,
			 "Trusted Memory Zone (TMZ) feature supported and enabled\n");
	}
}
Loading