Skip to contentSkip to conversation

drm/amdgpu: Expose an IP function to get register offset

PATCH In review Oak Zeng 2 participants 2 messages Oct 30, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Oak Zeng

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Expose an IP function to get register offset

Expose get_reg_offset function of sdma_v4_0 for kfd to use

Change-Id Ib687b390d6d3f8c8a35651e064e35aacf6722f98
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 7 +++++++
 drivers/gpu/drm/amd/include/amd_shared.h | 3 +++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +7 -0
index f35f578..1b6c591 100644
@@ -206,6 +206,12 @@ static u32 sdma_v4_0_get_reg_offset(struct amdgpu_device *adev,
 	return 0;
 }
 
+static u32 sdma_v4_0_get_reg_offset_external(void *handle, u32 instance, u32 offset)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	return sdma_v4_0_get_reg_offset(adev, instance, offset);
+}
+
 static unsigned sdma_v4_0_seq_to_irq_id(int seq_num)
 {
 	switch (seq_num) {
@@ -1746,6 +1752,7 @@ const struct amd_ip_funcs sdma_v4_0_ip_funcs = {
 	.set_clockgating_state = sdma_v4_0_set_clockgating_state,
 	.set_powergating_state = sdma_v4_0_set_powergating_state,
 	.get_clockgating_state = sdma_v4_0_get_clockgating_state,
+	.get_reg_offset = sdma_v4_0_get_reg_offset_external,
 };
 
 static const struct amdgpu_ring_funcs sdma_v4_0_ring_funcs = {
drivers/gpu/drm/amd/include/amd_shared.h +3 -0
index fc7fcb1..ab44fa8 100644
@@ -173,6 +173,9 @@ struct amd_ip_funcs {
 				     enum amd_powergating_state state);
 	/* get current clockgating status */
 	void (*get_clockgating_state)(void *handle, u32 *flags);
+
+	/* get instance's register offset */
+	u32 (*get_reg_offset)(void *handle, u32 instance, u32 offset);
 };
 
 
Signature · 6 lines
2.7.4

_______________________________________________
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): 1540932032-29755-1-git-send-email-Oak.Zeng-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 8 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Oak Zeng
Sent: Tuesday, October 30, 2018 4:41 PM
To: [email protected]
Cc: Zeng, Oak <[email protected]>
Subject: [PATCH] drm/amdgpu: Expose an IP function to get register offset

Quoted 4 lines

Expose get_reg_offset function of sdma_v4_0 for kfd to use

Change-Id Ib687b390d6d3f8c8a35651e064e35aacf6722f98

First, split something like this into two patches, one to add the new API, one to add the implementations.
Next how are you planning to use this? Do you have plans to add this for other IPs as well, or is it just a one off for
sdma? I'd rather not a new functionality at the IP level as a one-off for one IP. The implementation is trivial; it's just a wrapper around an array lookup. It's probably easier to just implement the same thing in kfd rather than adding a new callback. Or even make a generic wrapper e.g.,

amdgpu_device_ip_get_reg_offset(hwip, instance, seg, offset)

{
    return adev->reg_offset[hwip][instance][seg] + offset;
}

Alex

Quoted 48 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 7 +++++++
 drivers/gpu/drm/amd/include/amd_shared.h | 3 +++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +6 -0
index f35f578..1b6c591 100644
@@ -206,6 +206,12 @@ static u32 sdma_v4_0_get_reg_offset(struct
 amdgpu_device *adev,
 	return 0;
 }
 
+static u32 sdma_v4_0_get_reg_offset_external(void *handle, u32
+instance, u32 offset) {
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	return sdma_v4_0_get_reg_offset(adev, instance, offset); }
+
 static unsigned sdma_v4_0_seq_to_irq_id(int seq_num)  {
 	switch (seq_num) {
@@ -1746,6 +1752,7 @@ const struct amd_ip_funcs sdma_v4_0_ip_funcs = {
 	.set_clockgating_state = sdma_v4_0_set_clockgating_state,
 	.set_powergating_state = sdma_v4_0_set_powergating_state,
 	.get_clockgating_state = sdma_v4_0_get_clockgating_state,
+	.get_reg_offset = sdma_v4_0_get_reg_offset_external,
 };
 
 static const struct amdgpu_ring_funcs sdma_v4_0_ring_funcs = { diff --git

a/drivers/gpu/drm/amd/include/amd_shared.h
b/drivers/gpu/drm/amd/include/amd_shared.h
index fc7fcb1..ab44fa8 100644

drivers/gpu/drm/amd/include/amd_shared.h +3 -1
@@ -173,6 +173,9 @@ struct amd_ip_funcs {
 				     enum amd_powergating_state state);
 	/* get current clockgating status */
 	void (*get_clockgating_state)(void *handle, u32 *flags);
+
+	/* get instance's register offset */
+	u32 (*get_reg_offset)(void *handle, u32 instance, u32 offset);
 };
 
 
--

2.7.4

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