drm/amdgpu: implement TMZ accessor
Subsystems (2)
PATCH 1/1 drm/amdgpu: implement TMZ accessor
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_tmz_set(adev)" to check and set adev->tmz.* at initialization time. After which one uses "bool amdgpu_is_tmz(adev)" to query whether adev supports TMZ.
Also, remove circular header file include.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 23 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 7 ++----- 4 files changed, 19 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -0
@@ -1249,5 +1249,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -1058,7 +1058,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_tmz_set (adev);return ret; }
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c +11 -12
@@ -27,26 +27,25 @@#include "amdgpu.h" #include "amdgpu_tmz.h" -/** -* amdgpu_is_tmz - validate trust memory zone -* +* amdgpu_tmz_set -- check and set if a device supports TMZ * @adev: amdgpu_device pointer * -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. +* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). */ -bool amdgpu_is_tmz (struct amdgpu_device *adev) +void amdgpu_tmz_set (struct amdgpu_device *adev) {if (!amdgpu_tmz) -return false; +return ; -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; } -dev_info (adev->dev,"TMZ feature is enabled\n" ); + adev->tmz.enabled = true; -return true; +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); }
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +2 -5
@@ -24,16 +24,13 @@#ifndef __AMDGPU_TMZ_H__#define __AMDGPU_TMZ_H__ -#include "amdgpu.h" -/* -* Trust memory zone stuff +* Trusted Memory Zone particulars */ struct amdgpu_tmz {bool enabled; }; - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); +extern void amdgpu_tmz_set (struct amdgpu_device *adev);#endif
Signature · 6 lines
2.23.0.385.gbc12974a89 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Am 31.10.19 um 00:43 schrieb Tuikov, Luben:
Quoted 9 lines
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 andadev->tmz.
Quoted 4 lines
Add "void
amdgpu_tmz_set(adev)" to check and set adev->tmz.* at initialization time. After which one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.
Actually I would rather completely remove the amdgpu_tmz.[hc] files. See TMZ is a feature and not a hardware block.
All that stuff should probably moved into the PSP handling, since the control of TMZ is enabled or disabled in the hardware is there.
Regards,
Christian.
Quoted 94 lines
Also, remove circular header file include.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 23 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 7 ++----- 4 files changed, 19 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0@@ -1249,5 +1249,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -1058,7 +1058,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c +11
-12@@ -27,26 +27,25 @@#include "amdgpu.h" #include "amdgpu_tmz.h" -/** -* amdgpu_is_tmz - validate trust memory zone -* +* amdgpu_tmz_set -- check and set if a device supports TMZ * @adev: amdgpu_device pointer * -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. +* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). */ -bool amdgpu_is_tmz (struct amdgpu_device *adev) +void amdgpu_tmz_set (struct amdgpu_device *adev) {if (!amdgpu_tmz) -return false; +return ; -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; } -dev_info (adev->dev,"TMZ feature is enabled\n" ); + adev->tmz.enabled = true; -return true; +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-3@@ -24,16 +24,13 @@#ifndef __AMDGPU_TMZ_H__#define __AMDGPU_TMZ_H__ -#include "amdgpu.h" -/* -* Trust memory zone stuff +* Trusted Memory Zone particulars
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h line 36
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-2*/ struct amdgpu_tmz {bool enabled; }; - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); +extern void amdgpu_tmz_set (struct amdgpu_device *adev);#endif
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 2723dbff-806b-542f-4ed1-0e9fc807ca15-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 15 lines · Christian König
Am 31.10.19 um 00:43 schrieb Tuikov, Luben:
Quoted 9 lines
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 andadev->tmz.Quoted 4 lines
Add "void
amdgpu_tmz_set(adev)" to check and set adev->tmz.* at initialization time. After which one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.
Quoted 5 lines
Actually I would rather completely remove the amdgpu_tmz.[hc] files. See TMZ is a feature and not a hardware block.
All that stuff should probably moved into the PSP handling, since the control of TMZ is enabled or disabled in the hardware is there.
Hi Christian,
Thanks for reviewing this. Sure, we can do that as well, should there be consensus on it.
I just saw myself needing to know if the device is TMZ (as well as if a buffer is TMZ for which I used amdgpu_bo_encrypted()) and so it became natural to write (after this patch):
if (!amdgpu_bo_encrypted(abo) || !amdgpu_is_tmz(adev)) {
/* normal processing */
} else {
/* TMZ processing */
}BTW, should we proceed as you suggested, do you see those primitives going into psp_v12_0.c?
Regards,
Luben
Quoted 103 lines
Regards,
Christian.Quoted 99 lines
Also, remove circular header file include.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 23 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 7 ++----- 4 files changed, 19 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0@@ -1249,5 +1249,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -1058,7 +1058,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c +11
-12@@ -27,26 +27,25 @@#include "amdgpu.h" #include "amdgpu_tmz.h" -/** -* amdgpu_is_tmz - validate trust memory zone -* +* amdgpu_tmz_set -- check and set if a device supports TMZ * @adev: amdgpu_device pointer * -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. +* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). */ -bool amdgpu_is_tmz (struct amdgpu_device *adev) +void amdgpu_tmz_set (struct amdgpu_device *adev) {if (!amdgpu_tmz) -return false; +return ; -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; } -dev_info (adev->dev,"TMZ feature is enabled\n" ); + adev->tmz.enabled = true; -return true; +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-3@@ -24,16 +24,13 @@#ifndef __AMDGPU_TMZ_H__#define __AMDGPU_TMZ_H__ -#include "amdgpu.h" -/* -* Trust memory zone stuff +* Trusted Memory Zone particulars */ struct amdgpu_tmz {bool enabled; };
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h line 36
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-2- -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); +extern void amdgpu_tmz_set (struct amdgpu_device *adev);#endif
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): ad0649b5-44e9-055a-04a1-ca26fc588316-5C7GfCeVMHo@public.gmane.org
Quoted 32 lines · Luben
Quoted 15 lines · Christian König
Am 31.10.19 um 00:43 schrieb Tuikov, Luben:
Quoted 9 lines
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 andadev->tmz.Quoted 4 lines
Add "void
amdgpu_tmz_set(adev)" to check and set adev->tmz.* at initialization time. After which one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Quoted 5 lines
Actually I would rather completely remove the amdgpu_tmz.[hc] files. See TMZ is a feature and not a hardware block.
All that stuff should probably moved into the PSP handling, since the control of TMZ is enabled or disabled in the hardware is there.
Hi Christian,
Thanks for reviewing this. Sure, we can do that as well, should there be consensus on it.
I just saw myself needing to know if the device is TMZ (as well as if a buffer is TMZ for which I used
amdgpu_bo_encrypted()) and so it became natural to write (after this patch):
Quoted 9 lines
if (!amdgpu_bo_encrypted(abo) || !amdgpu_is_tmz(adev)) { /* normal processing */ } else { /* TMZ processing */ }BTW, should we proceed as you suggested, do you see those primitives going into
psp_v12_0.c?
They are not psp version specific. the PSP handles the security, but it's not really involved much from a driver perspective; they are really more of a memory management thing. I'd suggest putting them in struct amdgpu_gmc.
Alex
Quoted 110 lines
Regards,
LubenQuoted 107 lines
Regards,
Christian.Quoted 103 lines
Also, remove circular header file include.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 23 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 7 ++----- 4 files changed, 19 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0@@ -1249,5 +1249,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -1058,7 +1058,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c +11
-12@@ -27,26 +27,25 @@#include "amdgpu.h" #include "amdgpu_tmz.h" -/** -* amdgpu_is_tmz - validate trust memory zone -* +* amdgpu_tmz_set -- check and set if a device supports TMZ * @adev: amdgpu_device pointer * -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. +* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). */ -bool amdgpu_is_tmz (struct amdgpu_device *adev) +void amdgpu_tmz_set (struct amdgpu_device *adev) {if (!amdgpu_tmz) -return false; +return ; -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; } -dev_info (adev->dev,"TMZ feature is enabled\n" ); + adev->tmz.enabled = true; -return true; +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +2
-5@@ -24,16 +24,13 @@#ifndef __AMDGPU_TMZ_H__#define __AMDGPU_TMZ_H__ -#include "amdgpu.h" -/* -* Trust memory zone stuff +* Trusted Memory Zone particulars */ struct amdgpu_tmz {bool enabled; }; - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); +extern void amdgpu_tmz_set (struct amdgpu_device *adev);
Quoted 7 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h line 36
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +0
-0#endif _______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_PEO=2K=8-CCtvX+KOJstx-g9ba-zkT0TKsXDhH_2H0zQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 39 lines · Alex Deucher
Quoted 38 lines · Luben
Quoted 15 lines · Christian König
Am 31.10.19 um 00:43 schrieb Tuikov, Luben:
Quoted 9 lines
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 andadev->tmz.Quoted 4 lines
Add "void
amdgpu_tmz_set(adev)" to check and set adev->tmz.* at initialization time. After which one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Quoted 5 lines
Actually I would rather completely remove the amdgpu_tmz.[hc] files. See TMZ is a feature and not a hardware block.
All that stuff should probably moved into the PSP handling, since the control of TMZ is enabled or disabled in the hardware is there.
Hi Christian,
Thanks for reviewing this. Sure, we can do that as well, should there be consensus on it.
I just saw myself needing to know if the device is TMZ (as well as if a buffer is TMZ for which I used
amdgpu_bo_encrypted()) and so it became natural to write (after this patch):if (!amdgpu_bo_encrypted(abo) || !amdgpu_is_tmz(adev)) { /* normal processing */ } else { /* TMZ processing */ }
Quoted 8 lines
Quoted 3 lines
BTW, should we proceed as you suggested, do you see those primitives going into
psp_v12_0.c?They are not psp version specific. the PSP handles the security, but it's not really involved much from a driver perspective; they are really more of a memory management thing. I'd suggest putting them in struct
amdgpu_gmc.
Thanks Alex. So then I'd get rid of the files and consolidate into struct amdgpu_gmc, with the files disappearing as Christian suggested.
Regards,
Luben
Quoted 120 lines
Alex
Quoted 117 lines
Regards,
LubenQuoted 103 lines
Regards,
Christian.Quoted 99 lines
Also, remove circular header file include.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 23 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 7 ++----- 4 files changed, 19 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0@@ -1249,5 +1249,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -1058,7 +1058,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c +11
-12@@ -27,26 +27,25 @@#include "amdgpu.h" #include "amdgpu_tmz.h" -/** -* amdgpu_is_tmz - validate trust memory zone -* +* amdgpu_tmz_set -- check and set if a device supports TMZ * @adev: amdgpu_device pointer * -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. +* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). */ -bool amdgpu_is_tmz (struct amdgpu_device *adev) +void amdgpu_tmz_set (struct amdgpu_device *adev) {if (!amdgpu_tmz) -return false; +return ; -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; } -dev_info (adev->dev,"TMZ feature is enabled\n" ); + adev->tmz.enabled = true; -return true; +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-3@@ -24,16 +24,13 @@#ifndef __AMDGPU_TMZ_H__#define __AMDGPU_TMZ_H__ -#include "amdgpu.h" -/* -* Trust memory zone stuff +* Trusted Memory Zone particulars */ struct amdgpu_tmz {bool enabled; };Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h line 36
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-2- -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); +extern void amdgpu_tmz_set (struct amdgpu_device *adev);#endif _______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 29e89f79-6a46-1c3a-a070-0296a7bbb5b4-5C7GfCeVMHo@public.gmane.org
Am 01.11.19 um 19:24 schrieb Tuikov, Luben:
Quoted 40 lines · Alex Deucher
Quoted 39 lines · Luben
Quoted 38 lines · Christian König
Quoted 14 lines
Am 31.10.19 um 00:43 schrieb Tuikov, Luben:
Quoted 9 lines
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 andadev->tmz.Quoted 4 lines
Add "void
amdgpu_tmz_set(adev)" to check and set adev->tmz.* at initialization time. After which one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Quoted 5 lines
Actually I would rather completely remove the amdgpu_tmz.[hc] files. See TMZ is a feature and not a hardware block.
All that stuff should probably moved into the PSP handling, since the control of TMZ is enabled or disabled in the hardware is there.
Hi Christian,
Thanks for reviewing this. Sure, we can do that as well, should there be consensus on it.
I just saw myself needing to know if the device is TMZ (as well as if a buffer is TMZ for which I used
amdgpu_bo_encrypted()) and so it became natural to write (after this patch):if (!amdgpu_bo_encrypted(abo) || !amdgpu_is_tmz(adev)) { /* normal processing */ } else { /* TMZ processing */ }BTW, should we proceed as you suggested, do you see those primitives going into
psp_v12_0.c?
Quoted 7 lines
Quoted 4 lines
They are not psp version specific. the PSP handles the security, but it's not really involved much from a driver perspective; they are really more of a memory management thing. I'd suggest putting them in struct
amdgpu_gmc.Thanks Alex. So then I'd get rid of the files and consolidate into struct
amdgpu_gmc, with the files disappearing as Christian suggested.
Sounds like a plan to me as well.
Thanks,
Christian.
Quoted 119 lines
Regards,
LubenQuoted 115 lines
Alex
Quoted 113 lines
Regards,
LubenQuoted 101 lines
Regards,
Christian.Quoted 98 lines
Also, remove circular header file include.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 23 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 7 ++----- 4 files changed, 19 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0@@ -1249,5 +1249,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -1058,7 +1058,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c +11
-12@@ -27,26 +27,25 @@#include "amdgpu.h" #include "amdgpu_tmz.h" -/** -* amdgpu_is_tmz - validate trust memory zone -* +* amdgpu_tmz_set -- check and set if a device supports TMZ * @adev: amdgpu_device pointer * -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. +* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). */ -bool amdgpu_is_tmz (struct amdgpu_device *adev) +void amdgpu_tmz_set (struct amdgpu_device *adev) {if (!amdgpu_tmz) -return false; +return ; -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; } -dev_info (adev->dev,"TMZ feature is enabled\n" ); + adev->tmz.enabled = true; -return true; +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); }drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-3@@ -24,16 +24,13 @@#ifndef __AMDGPU_TMZ_H__#define __AMDGPU_TMZ_H__ -#include "amdgpu.h" -/* -* Trust memory zone stuff +* Trusted Memory Zone particulars */ struct amdgpu_tmz {bool enabled; };Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h line 36
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h +1
-2- -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); +extern void amdgpu_tmz_set (struct amdgpu_device *adev);#endif _______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): b64da3b9-9f20-549d-27f2-18da3ce10ea4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/1 drm/amdgpu: implement TMZ accessor (v2)
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_tmz_set(adev)" to check and set
adev->tmz.* 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.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -1
@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16
@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h>
@@ -1073,7 +1072,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_tmz_set (adev);return ret; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +23 -0
@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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_tmz_set (struct amdgpu_device *adev) +{ +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; + } + + adev->tmz.enabled = true; + +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); +}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9 -0
@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,int amdgpu_gmc_ras_late_init (struct amdgpu_device *adev);void amdgpu_gmc_ras_fini (struct amdgpu_device *adev); +/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +}; + +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0 -52
52 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif
Signature · 6 lines
2.24.0.155.gd9f6f3b619 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH] drm/amdgpu: implement TMZ accessor (v2)
Quoted 135 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Luben Tuikov
Sent: Thursday, November 21, 2019 9:33 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdgpu: implement TMZ accessor (v2)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 andadev->tmz.Add "void
amdgpu_tmz_set(adev)" to check and set
adev->tmz.* at initialization time. After which
one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.oamdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-1@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) { +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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_tmz_set (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-0@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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_tmz_set (struct amdgpu_device *adev) { +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { + dev_warn(adev->dev, "Trusted Memory Zone (TMZ) featurenot supported\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +6
-0+return ; + } + + adev->tmz.enabled = true; + + dev_info(adev->dev, "Trusted Memory Zone (TMZ) feature
Quoted 2 lines
supported and
+enabled\n"); }
Hi Luben,
TMZ is just a specific feature and I think this is a nice change that moving amdgpu_tmz to amdgpu_gmc.h. Another thing, you can rename amdgpu_tmz_set to amdgpu_gmc_tmz_set in amdgpu_gmc.h/ amdgpu_gmc.c In amdgpu_gmc.c, all functions are prefixed with amdgpu_gmc_*.
With this fixed, Reviewed-by: Aaron Liu <[email protected]>
Quoted 142 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0
-0@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct
amdgpu_device*adev,uint64_taddr, intamdgpu_gmc_ras_late_init(struct amdgpu_device *adev); voidamdgpu_gmc_ras_fini(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9
-0+/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +}; + +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-14@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-15- -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if
- * @dev does not support TMZ.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-5-bool amdgpu_is_tmz(struct amdgpu_device *adev) -{ - if (!amdgpu_tmz) - return false; - - if (adev->asic_type < CHIP_RAVEN || adev->asic_type ==
CHIP_ARCTURUS) {drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-1- dev_warn(adev->dev, "doesn't support trusted memoryzones (TMZ)\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-7-return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-14@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-18- -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif --2.24.0.155.gd9f6f3b619
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3838AAD51A07CB1016AE6B3CF04E0-rweVpJHSKTrcE+Ck/[email protected]
Re: [PATCH] drm/amdgpu: implement TMZ accessor (v2)
Quoted 134 lines · Aaron
Quoted 134 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Luben Tuikov
Sent: Thursday, November 21, 2019 9:33 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdgpu: implement TMZ accessor (v2)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 andadev->tmz.Add "void
amdgpu_tmz_set(adev)" to check and set
adev->tmz.* at initialization time. After which
one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.oamdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-1@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) { +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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_tmz_set (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-0@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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_tmz_set (struct amdgpu_device *adev) { +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { + dev_warn(adev->dev, "Trusted Memory Zone (TMZ) featurenot supported\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5
-0+return ; + } + + adev->tmz.enabled = true; +
Quoted 8 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1
-0+ dev_info(adev->dev, "Trusted Memory Zone (TMZ) featuresupported and
+enabled\n"); }Hi Luben,
TMZ is just a specific feature and I think this is a nice change that movingamdgpu_tmztoamdgpu_gmc.h. Another thing, you can renameamdgpu_tmz_settoamdgpu_gmc_tmz_setin amdgpu_gmc.h/amdgpu_gmc.cInamdgpu_gmc.c, all functions are prefixed with amdgpu_gmc_*.
Yes, I understand this GMC naming. Here's the reasoning:
1. I tried to keep the same name as was already in the code before this patch, amdgpu_tmz_/verb/().
2. I feel that TMZ, while a function _of_ the GMC and Crypto, isn't necessarily directly driving/programming/etc the GMC _hardware block_, just indirectly, via flags present in PTEs, arguments to registers, etc., i.e. as in input, and not necessarily being part of the GMC _driver_ code.
3. Names could become too long, very very long, by stringing along three-letter acronyms. While the function is indeed in amdgpu_gmc.c, it is TMZ-feature related, indirectly, so I belive keeping the same name as it had before, to be correct and succinct enough to be descriptive.
As Christian has pointed out several times "It's a feature, not an IP block", which was the reason he'd been wanting to remove amdgpu_tmz.[ch]. It ended up in amdgpu_gmc, as it seemed to be the closest place to put it.
Regards,
Luben
Quoted 144 lines
With this fixed, Reviewed-by: Aaron Liu <[email protected]>
Quoted 142 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0
-0@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct
amdgpu_device*adev,uint64_taddr, intamdgpu_gmc_ras_late_init(struct amdgpu_device *adev); voidamdgpu_gmc_ras_fini(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9
-0+/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +}; + +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-14@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-15- -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if
- * @dev does not support TMZ.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-5-bool amdgpu_is_tmz(struct amdgpu_device *adev) -{ - if (!amdgpu_tmz) - return false; - - if (adev->asic_type < CHIP_RAVEN || adev->asic_type ==
CHIP_ARCTURUS) {drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-1- dev_warn(adev->dev, "doesn't support trusted memoryzones (TMZ)\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-7-return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-14@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-18- -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif --2.24.0.155.gd9f6f3b619
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 007cb42e-2b6c-0da2-87a7-24692e84eef1-5C7GfCeVMHo@public.gmane.org
Re: [PATCH] drm/amdgpu: implement TMZ accessor (v2)
Quoted 154 lines · Luben Tuikov
Quoted 134 lines · Aaron
Quoted 134 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Luben Tuikov
Sent: Thursday, November 21, 2019 9:33 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdgpu: implement TMZ accessor (v2)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 andadev->tmz.Add "void
amdgpu_tmz_set(adev)" to check and set
adev->tmz.* at initialization time. After which
one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.oamdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-1@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) { +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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_tmz_set (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-0@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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_tmz_set (struct amdgpu_device *adev) { +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { + dev_warn(adev->dev, "Trusted Memory Zone (TMZ) featurenot supported\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5
-0+return ; + } + + adev->tmz.enabled = true; +Quoted 8 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1
-0+ dev_info(adev->dev, "Trusted Memory Zone (TMZ) featuresupported and
+enabled\n"); }Hi Luben,
TMZ is just a specific feature and I think this is a nice change that movingamdgpu_tmztoamdgpu_gmc.h. Another thing, you can renameamdgpu_tmz_settoamdgpu_gmc_tmz_setin amdgpu_gmc.h/amdgpu_gmc.cInamdgpu_gmc.c, all functions are prefixed with amdgpu_gmc_*.Yes, I understand this GMC naming. Here's the reasoning:
1. I tried to keep the same name as was already in the code before this patch, amdgpu_tmz_/verb/().
2. I feel that TMZ, while a function _of_ the GMC and Crypto, isn't necessarily directly driving/programming/etc the GMC
_hardwareblock_, just indirectly, via flags present in PTEs, arguments to registers, etc., i.e. as in input, and not necessarily being part of the GMC _driver_ code.
Quoted 8 lines
3. Names could become too long, very very long, by stringing along three-letter acronyms. While the function is indeed in
amdgpu_gmc.c, it is TMZ-feature related, indirectly, so I belive keeping the same name as it had before, to be correct and succinct enough to be descriptive.As Christian has pointed out several times "It's a feature, not an IP block", which was the reason he'd been wanting to remove amdgpu_tmz.[ch]. It ended up in
amdgpu_gmc, as it seemed to be the closest place to put it.
Another point which I forgot to add is:
Usage. How will this be used and what does it _mean_?
amdgpu_tmz_set(adev);
VS.
amdgpu_gmc_tmz_set(adev);
Are we really setting anything in the GMC IP block?
We're only asking that the device be known as a device which supports and may receive TMZ BOs. It's an abstraction (TMZ) over a device abstraction (struct amdgpu_device).
Similar argument applies to the static inline
amdgpu_is_tmz(adev);
VS
amdgpu_gmc_is_tmz(adev);
Are we asking about the state of the GMC block, or are we asking about the feature support in the amdgpu device abstraction?
I believe we should keep the names as they had been before this patch. This patch only moves them around.
Regards,
Luben
Quoted 148 lines
Regards,
LubenQuoted 144 lines
With this fixed, Reviewed-by: Aaron Liu <[email protected]>
Quoted 142 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0
-0@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct
amdgpu_device*adev,uint64_taddr, intamdgpu_gmc_ras_late_init(struct amdgpu_device *adev); voidamdgpu_gmc_ras_fini(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9
-0+/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +}; + +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-14@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-15- -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if
- * @dev does not support TMZ.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-5-bool amdgpu_is_tmz(struct amdgpu_device *adev) -{ - if (!amdgpu_tmz) - return false; - - if (adev->asic_type < CHIP_RAVEN || adev->asic_type ==
CHIP_ARCTURUS) {drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-1- dev_warn(adev->dev, "doesn't support trusted memoryzones (TMZ)\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-7-return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-14@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-18- -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif --2.24.0.155.gd9f6f3b619
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1584abb5-fa8e-b9dc-f4a2-49b95faff2e2-5C7GfCeVMHo@public.gmane.org
Re: [PATCH] drm/amdgpu: implement TMZ accessor (v2)
Am 21.11.19 um 04:39 schrieb Luben Tuikov:
Quoted 165 lines · Luben Tuikov
Quoted 152 lines · Aaron
Quoted 133 lines
Quoted 133 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Luben Tuikov
Sent: Thursday, November 21, 2019 9:33 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>; Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdgpu: implement TMZ accessor (v2)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 andadev->tmz.Add "void
amdgpu_tmz_set(adev)" to check and set
adev->tmz.* at initialization time. After which
one uses "boolamdgpu_is_tmz(adev)" to query whether adev supports TMZ.Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
Signed-off-by Luben Tuikov <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c
delete mode 100644drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.oamdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.odrivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-1@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) { +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-0@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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_tmz_set (struct amdgpu_device *adev) { +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { + dev_warn(adev->dev, "Trusted Memory Zone (TMZ) featurenot supported\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +4
-0+return ; + } + + adev->tmz.enabled = true;Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +2
-0+ + dev_info(adev->dev, "Trusted Memory Zone (TMZ) featuresupported and
+enabled\n"); }Hi Luben,
TMZ is just a specific feature and I think this is a nice change that movingamdgpu_tmztoamdgpu_gmc.h. Another thing, you can renameamdgpu_tmz_settoamdgpu_gmc_tmz_setin amdgpu_gmc.h/amdgpu_gmc.cInamdgpu_gmc.c, all functions are prefixed with amdgpu_gmc_*.Yes, I understand this GMC naming. Here's the reasoning:
1. I tried to keep the same name as was already in the code before this patch,
amdgpu_tmz_/verb/().2. I feel that TMZ, while a function _of_ the GMC and Crypto, isn't necessarily directly driving/programming/etc the GMC
_hardwareblock_, just indirectly, via flags present in PTEs, arguments to registers, etc., i.e. as in input, and not necessarily being part of the GMC _driver_ code.Quoted 8 lines
3. Names could become too long, very very long, by stringing along three-letter acronyms. While the function is indeed in
amdgpu_gmc.c, it is TMZ-feature related, indirectly, so I belive keeping the same name as it had before, to be correct and succinct enough to be descriptive.As Christian has pointed out several times "It's a feature, not an IP block", which was the reason he'd been wanting to remove amdgpu_tmz.[ch]. It ended up in
amdgpu_gmc, as it seemed to be the closest place to put it.Another point which I forgot to add is:
Usage. How will this be used and what does it _mean_?
Quoted 7 lines
amdgpu_tmz_set(adev);VS.
amdgpu_gmc_tmz_set(adev);Are we really setting anything in the GMC IP block?
Actually yes, but only indirectly.
We set what flags are inserted into the PTEs which are then essentially processed by the GMC.
Quoted 9 lines
We're only asking that the device be known as a device which supports and may receive TMZ BOs. It's an abstraction (TMZ) over a device abstraction (struct
amdgpu_device).Similar argument applies to the static inline
amdgpu_is_tmz(adev);
Quoted 7 lines
VS
amdgpu_gmc_is_tmz(adev);Are we asking about the state of the GMC block, or are we asking about the feature support in the amdgpu device abstraction?
I would name that amdgpu_gmc_is_tmz_enabled(), but that is not a hard requirement.
Quoted 2 lines
I believe we should keep the names as they had been before this patch. This patch only moves them around.
It's just the naming, feel free to add a Acked-by: Christian König <[email protected]> anyway.
Regards,
Christian.
Quoted 151 lines
Regards,
LubenQuoted 147 lines
Regards,
LubenQuoted 144 lines
With this fixed, Reviewed-by: Aaron Liu <[email protected]>
Quoted 142 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0
-0@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct
amdgpu_device*adev,uint64_taddr, intamdgpu_gmc_ras_late_init(struct amdgpu_device *adev); voidamdgpu_gmc_ras_fini(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9
-0+/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +}; + +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-14@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-15- -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if
- * @dev does not support TMZ.
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-5-bool amdgpu_is_tmz(struct amdgpu_device *adev) -{ - if (!amdgpu_tmz) - return false; - - if (adev->asic_type < CHIP_RAVEN || adev->asic_type ==
CHIP_ARCTURUS) {drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-1- dev_warn(adev->dev, "doesn't support trusted memoryzones (TMZ)\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-7-return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-14@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-18- -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif --2.24.0.155.gd9f6f3b619
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 767550e6-243b-a228-1532-037ec7f439b4-5C7GfCeVMHo@public.gmane.org
PATCH 1/1 drm/amdgpu: implement TMZ accessor (v2)
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_tmz_set(adev)" to check and set
adev->tmz.* 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.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -1
@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16
@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h>
@@ -1073,7 +1072,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_tmz_set (adev);return ret; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +23 -0
@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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_tmz_set (struct amdgpu_device *adev) +{ +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; + } + + adev->tmz.enabled = true; + +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); +}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9 -0
@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,int amdgpu_gmc_ras_late_init (struct amdgpu_device *adev);void amdgpu_gmc_ras_fini (struct amdgpu_device *adev); +/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +}; + +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0 -52
52 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif
Signature · 6 lines
2.24.0.155.gd9f6f3b619 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] drm/amdgpu: implement TMZ accessor (v2)
Quoted 97 lines · Luben Tuikov
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 andadev->tmz.Add "void
amdgpu_tmz_set(adev)" to check and set
adev->tmz.* at initialization time. After which
one uses "boolamdgpu_is_tmz(adev)" to query
whether adev supports TMZ.Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
Signed-off-by Luben Tuikov <[email protected]>Acked-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.odrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-1@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0
-0@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c void amdgpu_gmc_ras_fini(struct amdgpu_device *adev) · line 344
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +9
-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_tmz_set (struct amdgpu_device *adev)
I would prefer to call this amdgpu_gmc_tmz_set() to keep the naming in this file consistent. That way it's easy to see figure out where this function is defined.
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +14
-0+{ +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; + } + + adev->tmz.enabled = true; + +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr, · line 275
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +6
-0@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,int amdgpu_gmc_ras_late_init (struct amdgpu_device *adev);void amdgpu_gmc_ras_fini (struct amdgpu_device *adev); +/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +};
Also any reason to not put this in struct amdgpu_gmc? Then we can just expose it as adev->gmc.tmz_enabled.
Alex
Quoted 110 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +3
-0+ +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-52@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. -*/ -bool amdgpu_is_tmz (struct amdgpu_device *adev) -{ -if (!amdgpu_tmz) -return false; - -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-40@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif --2.24.0.155.gd9f6f3b619
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_MPg8h4RA-rQ+HMQimahE8QaHS1-Nh6H8ixX3eOLhS_9g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH] drm/amdgpu: implement TMZ accessor (v2)
Quoted 104 lines · Alex Deucher
Quoted 103 lines · Luben Tuikov
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 andadev->tmz.Add "void
amdgpu_tmz_set(adev)" to check and set
adev->tmz.* at initialization time. After which
one uses "boolamdgpu_is_tmz(adev)" to query
whether adev supports TMZ.Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
Signed-off-by Luben Tuikov <[email protected]>Acked-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 23 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- 7 files changed, 39 insertions(+), 95 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.odrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-1@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -1266,5 +1265,10 @@ _name##_show(struct device *dev, \ \ static struct device_attribute pmu_attr_##_name = __ATTR_RO(_name) +static inline bool amdgpu_is_tmz (struct amdgpu_device *adev) +{ +return adev->tmz.enabled; +} +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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_tmz_set (adev);return ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5
-0@@ -333,3 +333,26 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* amdgpu_tmz_set -- check and set if a device supports TMZ +* @adev: amdgpu_device pointer +*
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c void amdgpu_gmc_ras_fini(struct amdgpu_device *adev) · line 344
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +4
-0+* Check and set if an the device @adev supports Trusted Memory +* Zones (TMZ). +*/ +void amdgpu_tmz_set (struct amdgpu_device *adev)I would prefer to call this
amdgpu_gmc_tmz_set()to keep the naming in this file consistent. That way it's easy to see figure out where this function is defined.
Sure--we can name it that.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +14
-0+{ +if (!amdgpu_tmz) +return ; + +if (adev->asic_type <CHIP_RAVEN || + adev->asic_type ==CHIP_ARCTURUS ) { +dev_warn (adev->dev,"Trusted Memory Zone (TMZ) feature not supported\n" ); +return ; + } + + adev->tmz.enabled = true; + +dev_info (adev->dev,"Trusted Memory Zone (TMZ) feature supported and enabled\n" ); +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +0
-0@@ -267,4 +267,13 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,int amdgpu_gmc_ras_late_init (struct amdgpu_device *adev);void amdgpu_gmc_ras_fini (struct amdgpu_device *adev);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr, · line 275
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +6
-0+/* +* Trusted Memory Zone particulars +*/ +struct amdgpu_tmz { +bool enabled; +};Also any reason to not put this in struct
amdgpu_gmc? Then we can just expose it asadev->gmc.tmz_enabled.
No reason at all--I can move it there. I'm only following on the request to remove amdgpu_tmz.[ch] and move them.
I'll resend a patch then.
Quoted 113 lines
Alex
Quoted 110 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +3
-0+ +extern void amdgpu_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-52@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. -*/ -bool amdgpu_is_tmz (struct amdgpu_device *adev) -{ -if (!amdgpu_tmz) -return false; - -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-40@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif --2.24.0.155.gd9f6f3b619
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cluben.tuikov%40amd.com%7Ce9dc4191c86c476adda608d77379a18e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637104838555336406&sdata=zyfOmkX4XNlEnCJl6nVz5ir9JpxDY8ot2cQZQ6iFErk%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 6394037a-a7d9-b38a-685c-1ab0cb7cec9b-5C7GfCeVMHo@public.gmane.org
PATCH 1/1 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 "boolamdgpu_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.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 25 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 10 files changed, 40 insertions(+), 103 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -5
@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16
@@ -937,9 +936,6 @@ struct amdgpu_device {bool enable_mes;struct amdgpu_mes mes; -/* tmz */ -struct amdgpu_tmz tmz; -struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM ];int num_ip_blocks;struct mutex mn_lock;
@@ -1266,5 +1262,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
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h>
@@ -1073,7 +1072,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 ret; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -2
@@ -235,8 +235,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 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +25 -0
@@ -333,3 +333,28 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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" ); + } +}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +4 -0
@@ -208,6 +208,8 @@ struct amdgpu_gmc { } fault_hash[AMDGPU_GMC_FAULT_HASH_SIZE ]; uint64_t last_fault:AMDGPU_GMC_FAULT_RING_ORDER; +bool tmz_enabled; +const struct amdgpu_gmc_funcs *gmc_funcs;struct amdgpu_xgmi xgmi;
@@ -267,4 +269,6 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,int amdgpu_gmc_ras_late_init (struct amdgpu_device *adev);void amdgpu_gmc_ras_fini (struct amdgpu_device *adev); +extern void amdgpu_gmc_tmz_set (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0 -52
52 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -1
@@ -4796,7 +4796,7 @@ static void gfx_v10_0_ring_emit_tmz(struct amdgpu_ring *ring, bool start,* cmd = 1: frame end */ amdgpu_ring_write (ring, - ((ring->adev->tmz.enabled && trusted) ?FRAME_TMZ :0 ) + ((amdgpu_is_tmz (ring->adev) && trusted) ?FRAME_TMZ :0 ) |FRAME_CMD (start ?0 :1 )); }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -5077,7 +5077,7 @@ static void gfx_v9_0_ring_emit_tmz(struct amdgpu_ring *ring, bool start,* cmd = 1: frame end */ amdgpu_ring_write (ring, - ((ring->adev->tmz.enabled && trusted) ?FRAME_TMZ :0 ) + ((amdgpu_is_tmz (ring->adev) && trusted) ?FRAME_TMZ :0 ) |FRAME_CMD (start ?0 :1 )); }
Signature · 6 lines
2.24.0.155.gd9f6f3b619 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH] drm/amdgpu: implement TMZ accessor (v3)
Quoted 16 lines · Luben Tuikov
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 andadev->tmz.Add "void
amdgpu_gmc_tmz_set(adev)" to check and
setadev->gmc.tmz_enabledat initialization
time. After which one uses "boolamdgpu_is_tmz(adev)" to query whether adev
supports TMZ.
Quoted 7 lines
Also, remove circular header file include.
v2: Remove amdgpu_tmz.[ch] as requested.
v3: Move TMZ into GMC.Signed-off-by Luben Tuikov <[email protected]>Acked-by Christian König <[email protected]>
Quoted 282 lines
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 25 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c | 52 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h | 39 ---------------- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 10 files changed, 40 insertions(+), 103 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.hdrivers/gpu/drm/amd/amdgpu/Makefile +1
-1@@ -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_tmz.o + amdgpu_umc.o smu_v11_0_i2c.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.odrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-5@@ -90,7 +90,6 @@#include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" -#include "amdgpu_tmz.h" #define MAX_GPU_INSTANCE 16@@ -937,9 +936,6 @@ struct amdgpu_device {bool enable_mes;struct amdgpu_mes mes; -/* tmz */ -struct amdgpu_tmz tmz; -struct amdgpu_ip_block ip_blocks[AMDGPU_MAX_IP_NUM ];int num_ip_blocks;struct mutex mn_lock;@@ -1266,5 +1262,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 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-2@@ -64,7 +64,6 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" #include "amdgpu_pmu.h" -#include "amdgpu_tmz.h" #include <linux/suspend.h> @@ -1073,7 +1072,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 ret; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-2@@ -235,8 +235,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 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +25
-0@@ -333,3 +333,28 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)amdgpu_mmhub_ras_fini (adev);amdgpu_xgmi_ras_fini (adev); } + +/** +* 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" ); + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +4
-0@@ -208,6 +208,8 @@ struct amdgpu_gmc { } fault_hash[AMDGPU_GMC_FAULT_HASH_SIZE ]; uint64_t last_fault:AMDGPU_GMC_FAULT_RING_ORDER; +bool tmz_enabled; +const struct amdgpu_gmc_funcs *gmc_funcs;struct amdgpu_xgmi xgmi;@@ -267,4 +269,6 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,int amdgpu_gmc_ras_late_init (struct amdgpu_device *adev);void amdgpu_gmc_ras_fini (struct amdgpu_device *adev); +extern void amdgpu_gmc_tmz_set (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.c deleted +0
-52@@ -1,52 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include <linux/device.h> - -#include <drm/amd_asic_type.h> - -#include "amdgpu.h" -#include "amdgpu_tmz.h" - - -/** -* amdgpu_is_tmz - validate trust memory zone -* -* @adev: amdgpu_device pointer -* -* Return true if @dev supports trusted memory zones (TMZ), and return false if -* @dev does not support TMZ. -*/ -bool amdgpu_is_tmz (struct amdgpu_device *adev) -{ -if (!amdgpu_tmz) -return false; - -if (adev->asic_type <CHIP_RAVEN || adev->asic_type ==CHIP_ARCTURUS ) { -dev_warn (adev->dev,"doesn't support trusted memory zones (TMZ)\n" ); -return false; - } - -dev_info (adev->dev,"TMZ feature is enabled\n" ); - -return true; -}drivers/gpu/drm/amd/amdgpu/amdgpu_tmz.h deleted +0
-39@@ -1,39 +0,0 @@ -/* -* Copyright 2019 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef __AMDGPU_TMZ_H__ -#define __AMDGPU_TMZ_H__ - -#include "amdgpu.h" - -/* -* Trust memory zone stuff -*/ -struct amdgpu_tmz { -bool enabled; -}; - - -extern bool amdgpu_is_tmz (struct amdgpu_device *adev); - -#endif drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1@@ -4796,7 +4796,7 @@ static void gfx_v10_0_ring_emit_tmz(struct amdgpu_ring *ring, bool start,* cmd = 1: frame end */ amdgpu_ring_write (ring, - ((ring->adev->tmz.enabled && trusted) ?FRAME_TMZ :0 ) + ((amdgpu_is_tmz (ring->adev) && trusted) ?FRAME_TMZ :0 ) |FRAME_CMD (start ?0 :1 )); }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-2@@ -5077,7 +5077,7 @@ static void gfx_v9_0_ring_emit_tmz(struct amdgpu_ring *ring, bool start,* cmd = 1: frame end */ amdgpu_ring_write (ring, - ((ring->adev->tmz.enabled && trusted) ?FRAME_TMZ :0 ) + ((amdgpu_is_tmz (ring->adev) && trusted) ?FRAME_TMZ :0 ) |FRAME_CMD (start ?0 :1 )); } --2.24.0.155.gd9f6f3b619
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx