* [PATCH 0/4] Add SMUIO 14.0.2 support
@ 2024-03-18 20:42 Alex Deucher
2024-03-18 20:42 ` [PATCH 2/4] drm/amdgpu: Add smuio v14_0_2 ip block support Alex Deucher
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alex Deucher @ 2024-03-18 20:42 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher
SMUIO is the IO subset of the SMU block. It handles a variety
of functionality on the GPU including reading the ROM image and
accessing the GPU clock counter. This adds support for SMUIO
14.0.2.
Note that patch 1 adds register headers and is very large so it
has been omitted.
Hawking Zhang (4):
drm/amdgpu: Add smuio v14_0_2 ip headers (v4)
drm/amdgpu: Add smuio v14_0_2 ip block support
drm/amdgpu: Add smuio callback to get gpu clk counter
drm/amdgpu: Enable smuio v14_0_2 callbacks
drivers/gpu/drm/amd/amdgpu/Makefile | 3 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 +
drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h | 1 +
drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c | 62 +
drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h | 30 +
.../asic_reg/smuio/smuio_14_0_2_offset.h | 511 ++++++++
.../asic_reg/smuio/smuio_14_0_2_sh_mask.h | 1106 +++++++++++++++++
7 files changed, 1716 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
create mode 100644 drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h
create mode 100644 drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_14_0_2_offset.h
create mode 100644 drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_14_0_2_sh_mask.h
--
2.44.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] drm/amdgpu: Add smuio v14_0_2 ip block support
2024-03-18 20:42 [PATCH 0/4] Add SMUIO 14.0.2 support Alex Deucher
@ 2024-03-18 20:42 ` Alex Deucher
2024-03-18 20:42 ` [PATCH 3/4] drm/amdgpu: Add smuio callback to get gpu clk counter Alex Deucher
2024-03-18 20:42 ` [PATCH 4/4] drm/amdgpu: Enable smuio v14_0_2 callbacks Alex Deucher
2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2024-03-18 20:42 UTC (permalink / raw)
To: amd-gfx; +Cc: Hawking Zhang, Likun Gao, Alex Deucher
From: Hawking Zhang <Hawking.Zhang@amd.com>
Add smuio v14_0_2 ip block support
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Likun Gao <Likun.Gao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/Makefile | 3 +-
drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c | 41 ++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h | 30 ++++++++++++++++
3 files changed, 73 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
create mode 100644 drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4536c8ad0e11..61237f50893b 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -247,7 +247,8 @@ amdgpu-y += \
smuio_v11_0_6.o \
smuio_v13_0.o \
smuio_v13_0_3.o \
- smuio_v13_0_6.o
+ smuio_v13_0_6.o \
+ smuio_v14_0_2.o
# add reset block
amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
new file mode 100644
index 000000000000..7b7cca220b26
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2023 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 "amdgpu.h"
+#include "smuio_v14_0_2.h"
+#include "smuio/smuio_14_0_2_offset.h"
+#include "smuio/smuio_14_0_2_sh_mask.h"
+
+static u32 smuio_v14_0_2_get_rom_index_offset(struct amdgpu_device *adev)
+{
+ return SOC15_REG_OFFSET(SMUIO, 0, regROM_INDEX);
+}
+
+static u32 smuio_v14_0_2_get_rom_data_offset(struct amdgpu_device *adev)
+{
+ return SOC15_REG_OFFSET(SMUIO, 0, regROM_DATA);
+}
+
+const struct amdgpu_smuio_funcs smuio_v14_0_2_funcs = {
+ .get_rom_index_offset = smuio_v14_0_2_get_rom_index_offset,
+ .get_rom_data_offset = smuio_v14_0_2_get_rom_data_offset,
+};
diff --git a/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h
new file mode 100644
index 000000000000..6e617f832d90
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2023 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 __SMUIO_V14_0_2_H__
+#define __SMUIO_V14_0_2_H__
+
+#include "soc15_common.h"
+
+extern const struct amdgpu_smuio_funcs smuio_v14_0_2_funcs;
+
+#endif /* __SMUIO_V14_0_2_H__ */
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] drm/amdgpu: Add smuio callback to get gpu clk counter
2024-03-18 20:42 [PATCH 0/4] Add SMUIO 14.0.2 support Alex Deucher
2024-03-18 20:42 ` [PATCH 2/4] drm/amdgpu: Add smuio v14_0_2 ip block support Alex Deucher
@ 2024-03-18 20:42 ` Alex Deucher
2024-03-18 20:42 ` [PATCH 4/4] drm/amdgpu: Enable smuio v14_0_2 callbacks Alex Deucher
2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2024-03-18 20:42 UTC (permalink / raw)
To: amd-gfx; +Cc: Hawking Zhang, Likun Gao, Alex Deucher
From: Hawking Zhang <Hawking.Zhang@amd.com>
Add smuio callback to get gpu clk counter
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Likun Gao <Likun.Gao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h | 1 +
drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h
index ff4435181055..ec9d12f85f39 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h
@@ -44,6 +44,7 @@ struct amdgpu_smuio_funcs {
u32 (*get_socket_id)(struct amdgpu_device *adev);
enum amdgpu_pkg_type (*get_pkg_type)(struct amdgpu_device *adev);
bool (*is_host_gpu_xgmi_supported)(struct amdgpu_device *adev);
+ u64 (*get_gpu_clock_counter)(struct amdgpu_device *adev);
};
struct amdgpu_smuio {
diff --git a/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
index 7b7cca220b26..2a51a70d4846 100644
--- a/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/smuio_v14_0_2.c
@@ -24,6 +24,7 @@
#include "smuio_v14_0_2.h"
#include "smuio/smuio_14_0_2_offset.h"
#include "smuio/smuio_14_0_2_sh_mask.h"
+#include <linux/preempt.h>
static u32 smuio_v14_0_2_get_rom_index_offset(struct amdgpu_device *adev)
{
@@ -35,7 +36,27 @@ static u32 smuio_v14_0_2_get_rom_data_offset(struct amdgpu_device *adev)
return SOC15_REG_OFFSET(SMUIO, 0, regROM_DATA);
}
+static u64 smuio_v14_0_2_get_gpu_clock_counter(struct amdgpu_device *adev)
+{
+ u64 clock;
+ u64 clock_counter_lo, clock_counter_hi_pre, clock_counter_hi_after;
+
+ preempt_disable();
+ clock_counter_hi_pre = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_UPPER);
+ clock_counter_lo = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_LOWER);
+ /* the clock counter may be udpated during polling the counters */
+ clock_counter_hi_after = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_UPPER);
+ if (clock_counter_hi_pre != clock_counter_hi_after)
+ clock_counter_lo = (u64)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_LOWER);
+ preempt_enable();
+
+ clock = clock_counter_lo | (clock_counter_hi_after << 32ULL);
+
+ return clock;
+}
+
const struct amdgpu_smuio_funcs smuio_v14_0_2_funcs = {
.get_rom_index_offset = smuio_v14_0_2_get_rom_index_offset,
.get_rom_data_offset = smuio_v14_0_2_get_rom_data_offset,
+ .get_gpu_clock_counter = smuio_v14_0_2_get_gpu_clock_counter,
};
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] drm/amdgpu: Enable smuio v14_0_2 callbacks
2024-03-18 20:42 [PATCH 0/4] Add SMUIO 14.0.2 support Alex Deucher
2024-03-18 20:42 ` [PATCH 2/4] drm/amdgpu: Add smuio v14_0_2 ip block support Alex Deucher
2024-03-18 20:42 ` [PATCH 3/4] drm/amdgpu: Add smuio callback to get gpu clk counter Alex Deucher
@ 2024-03-18 20:42 ` Alex Deucher
2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2024-03-18 20:42 UTC (permalink / raw)
To: amd-gfx; +Cc: Hawking Zhang, Likun Gao, Alex Deucher
From: Hawking Zhang <Hawking.Zhang@amd.com>
Enable smuio v14_0_2_callbacks
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Likun Gao <Likun.Gao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 8d9d6b2e68e8..230412fc4d62 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -97,6 +97,7 @@
#include "smuio_v13_0.h"
#include "smuio_v13_0_3.h"
#include "smuio_v13_0_6.h"
+#include "smuio_v14_0_2.h"
#include "vcn_v5_0_0.h"
#include "jpeg_v5_0_0.h"
@@ -2684,6 +2685,9 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
case IP_VERSION(14, 0, 1):
adev->smuio.funcs = &smuio_v13_0_6_funcs;
break;
+ case IP_VERSION(14, 0, 2):
+ adev->smuio.funcs = &smuio_v14_0_2_funcs;
+ break;
default:
break;
}
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-18 20:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-18 20:42 [PATCH 0/4] Add SMUIO 14.0.2 support Alex Deucher
2024-03-18 20:42 ` [PATCH 2/4] drm/amdgpu: Add smuio v14_0_2 ip block support Alex Deucher
2024-03-18 20:42 ` [PATCH 3/4] drm/amdgpu: Add smuio callback to get gpu clk counter Alex Deucher
2024-03-18 20:42 ` [PATCH 4/4] drm/amdgpu: Enable smuio v14_0_2 callbacks Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox