Re: [PATCH] drm/amdgpu: use function pointer for gfxhub functions
On Thu, Sep 17, 2020 at 7:16 PM Oak Zeng wrote: > > gfxhub functions are now called from function pointers, > instead of from asic-specific functions. > > Signed-off-by: Oak Zeng Reviewed-by: Alex Deucher > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +- > .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 3 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 5 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 43 ++ > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 10 > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.h | 1 + > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c | 13 +- > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h | 2 +- > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 24 +++--- > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.h | 10 +--- > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 27 +++ > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.h | 12 + > drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 53 > +- > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 28 +--- > 15 files changed, 155 insertions(+), 83 deletions(-) > create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 13f92de..0d8ace9 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -104,6 +104,7 @@ > #include "amdgpu_mes.h" > #include "amdgpu_umc.h" > #include "amdgpu_mmhub.h" > +#include "amdgpu_gfxhub.h" > #include "amdgpu_df.h" > > #define MAX_GPU_INSTANCE 16 > @@ -884,6 +885,9 @@ struct amdgpu_device { > /* mmhub */ > struct amdgpu_mmhub mmhub; > > + /* gfxhub */ > + struct amdgpu_gfxhubgfxhub; > + > /* gfx */ > struct amdgpu_gfx gfx; > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > index df0aab0..1529815 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > @@ -32,7 +32,6 @@ > #include "v10_structs.h" > #include "nv.h" > #include "nvd.h" > -#include "gfxhub_v2_0.h" > > enum hqd_dequeue_request_type { > NO_ACTION = 0, > @@ -753,7 +752,7 @@ static void set_vm_context_page_table_base(struct kgd_dev > *kgd, uint32_t vmid, > } > > /* SDMA is on gfxhub as well for Navi1* series */ > - gfxhub_v2_0_setup_vm_pt_regs(adev, vmid, page_table_base); > + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > } > > const struct kfd2kgd_calls gfx_v10_kfd2kgd = { > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > index e12623a..b7ea20e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > @@ -31,7 +31,6 @@ > #include "v10_structs.h" > #include "nv.h" > #include "nvd.h" > -#include "gfxhub_v2_1.h" > > enum hqd_dequeue_request_type { > NO_ACTION = 0, > @@ -657,7 +656,7 @@ static void set_vm_context_page_table_base_v10_3(struct > kgd_dev *kgd, uint32_t v > struct amdgpu_device *adev = get_amdgpu_device(kgd); > > /* SDMA is on gfxhub as well for Navi1* series */ > - gfxhub_v2_1_setup_vm_pt_regs(adev, vmid, page_table_base); > + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > } > > #if 0 > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > index e6aede7..b824582 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > @@ -36,9 +36,6 @@ > #include "v9_structs.h" > #include "soc15.h" > #include "soc15d.h" > -#include "mmhub_v1_0.h" > -#include "gfxhub_v1_0.h" > - > > enum hqd_dequeue_request_type { > NO_ACTION = 0, > @@ -703,7 +700,7 @@ void kgd_gfx_v9_set_vm_context_page_table_base(struct > kgd_dev *kgd, > > adev->mmhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > > - gfxhub_v1_0_setup_vm_pt_regs(adev, vmid, page_table_base); > + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > } > > const struct kfd2kgd_calls gfx_v9_kfd2kgd = { > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > new file mode 100644 > index 000..66ebc2e > --- /dev/null > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > @@ -0,0 +1,43 @@ > +/* > + * Copyright 2020 Advanced Micro Devices, Inc. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated
RE: [PATCH] drm/amdgpu: use function pointer for gfxhub functions
[AMD Official Use Only - Internal Distribution Only] Forgot the mention, the main reason I think it is not necessary to write a comment in this case is, if you program with C language and write something like below, the unset function pointer is NULL guaranteed by compiler. +const struct amdgpu_gfxhub_funcs gfxhub_v1_0_funcs = { + .get_mc_fb_offset = gfxhub_v1_0_get_mc_fb_offset, + .setup_vm_pt_regs = gfxhub_v1_0_setup_vm_pt_regs, + .gart_enable = gfxhub_v1_0_gart_enable, + .gart_disable = gfxhub_v1_0_gart_disable, + .set_fault_enable_default = gfxhub_v1_0_set_fault_enable_default, + .init = gfxhub_v1_0_init, +}; Regards, Oak From: amd-gfx On Behalf Of Zeng, Oak Sent: Monday, September 28, 2020 5:52 PM To: Ernst Sjöstrand ; Deucher, Alexander ; Koenig, Christian Cc: amd-gfx mailing list Subject: RE: [PATCH] drm/amdgpu: use function pointer for gfxhub functions [AMD Official Use Only - Internal Distribution Only] [AMD Official Use Only - Internal Distribution Only] Sorry for late reply… Yes some of the function pointers can be NULL. For those NULL function pointer, it is the call’s responsibility to *not* call them. We have been practicing like this for many function pointers before. For example, if you look at gmc_v9_0.c, the gmc_v9_0_ip_funcs, some function pointers are also not set. I don’t think it is very necessary to add a comment, since this has been the practice without any comment before. @Deucher, Alexander<mailto:alexander.deuc...@amd.com> @Koenig, Christian<mailto:christian.koe...@amd.com> what do you think? Can you guys help to review this patch? Thanks Regards, Oak From: Ernst Sjöstrand mailto:ern...@gmail.com>> Sent: Friday, September 18, 2020 5:03 AM To: Zeng, Oak mailto:oak.z...@amd.com>> Cc: amd-gfx mailing list mailto:amd-gfx@lists.freedesktop.org>>; Deucher, Alexander mailto:alexander.deuc...@amd.com>>; Koenig, Christian mailto:christian.koe...@amd.com>> Subject: Re: [PATCH] drm/amdgpu: use function pointer for gfxhub functions Can some of them be null and others not? Perhaps write that in the comments somewhere. Like v1 doesn't have get_fb_location for example. Regards //Ernst Den fre 18 sep. 2020 kl 01:16 skrev Oak Zeng mailto:oak.z...@amd.com>>: gfxhub functions are now called from function pointers, instead of from asic-specific functions. Signed-off-by: Oak Zeng mailto:oak.z...@amd.com>> --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 43 ++ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 10 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.h | 1 + drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c | 13 +- drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h | 2 +- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 24 +++--- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.h | 10 +--- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 27 +++ drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.h | 12 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 53 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 28 +--- 15 files changed, 155 insertions(+), 83 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 13f92de..0d8ace9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -104,6 +104,7 @@ #include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" +#include "amdgpu_gfxhub.h" #include "amdgpu_df.h" #define MAX_GPU_INSTANCE 16 @@ -884,6 +885,9 @@ struct amdgpu_device { /* mmhub */ struct amdgpu_mmhub mmhub; + /* gfxhub */ + struct amdgpu_gfxhubgfxhub; + /* gfx */ struct amdgpu_gfx gfx; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c index df0aab0..1529815 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c @@ -32,7 +32,6 @@ #include "v10_structs.h" #include "nv.h" #include "nvd.h" -#include "gfxhub_v2_0.h" enum hqd_dequeue_request_type { NO_ACTION = 0, @@ -753,7 +752,7 @@ static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, } /* SDMA is on gfxhub as well for Navi1* series */ - gfxhub_v2_0_setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhu
RE: [PATCH] drm/amdgpu: use function pointer for gfxhub functions
[AMD Official Use Only - Internal Distribution Only] Sorry for late reply… Yes some of the function pointers can be NULL. For those NULL function pointer, it is the call’s responsibility to *not* call them. We have been practicing like this for many function pointers before. For example, if you look at gmc_v9_0.c, the gmc_v9_0_ip_funcs, some function pointers are also not set. I don’t think it is very necessary to add a comment, since this has been the practice without any comment before. @Deucher, Alexander<mailto:alexander.deuc...@amd.com> @Koenig, Christian<mailto:christian.koe...@amd.com> what do you think? Can you guys help to review this patch? Thanks Regards, Oak From: Ernst Sjöstrand Sent: Friday, September 18, 2020 5:03 AM To: Zeng, Oak Cc: amd-gfx mailing list ; Deucher, Alexander ; Koenig, Christian Subject: Re: [PATCH] drm/amdgpu: use function pointer for gfxhub functions Can some of them be null and others not? Perhaps write that in the comments somewhere. Like v1 doesn't have get_fb_location for example. Regards //Ernst Den fre 18 sep. 2020 kl 01:16 skrev Oak Zeng mailto:oak.z...@amd.com>>: gfxhub functions are now called from function pointers, instead of from asic-specific functions. Signed-off-by: Oak Zeng mailto:oak.z...@amd.com>> --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 43 ++ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 10 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.h | 1 + drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c | 13 +- drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h | 2 +- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 24 +++--- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.h | 10 +--- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 27 +++ drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.h | 12 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 53 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 28 +--- 15 files changed, 155 insertions(+), 83 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 13f92de..0d8ace9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -104,6 +104,7 @@ #include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" +#include "amdgpu_gfxhub.h" #include "amdgpu_df.h" #define MAX_GPU_INSTANCE 16 @@ -884,6 +885,9 @@ struct amdgpu_device { /* mmhub */ struct amdgpu_mmhub mmhub; + /* gfxhub */ + struct amdgpu_gfxhubgfxhub; + /* gfx */ struct amdgpu_gfx gfx; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c index df0aab0..1529815 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c @@ -32,7 +32,6 @@ #include "v10_structs.h" #include "nv.h" #include "nvd.h" -#include "gfxhub_v2_0.h" enum hqd_dequeue_request_type { NO_ACTION = 0, @@ -753,7 +752,7 @@ static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, } /* SDMA is on gfxhub as well for Navi1* series */ - gfxhub_v2_0_setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); } const struct kfd2kgd_calls gfx_v10_kfd2kgd = { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c index e12623a..b7ea20e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c @@ -31,7 +31,6 @@ #include "v10_structs.h" #include "nv.h" #include "nvd.h" -#include "gfxhub_v2_1.h" enum hqd_dequeue_request_type { NO_ACTION = 0, @@ -657,7 +656,7 @@ static void set_vm_context_page_table_base_v10_3(struct kgd_dev *kgd, uint32_t v struct amdgpu_device *adev = get_amdgpu_device(kgd); /* SDMA is on gfxhub as well for Navi1* series */ - gfxhub_v2_1_setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); } #if 0 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c index e6aede7..b824582 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +++ b/dr
Re: [PATCH] drm/amdgpu: use function pointer for gfxhub functions
Can some of them be null and others not? Perhaps write that in the comments somewhere. Like v1 doesn't have get_fb_location for example. Regards //Ernst Den fre 18 sep. 2020 kl 01:16 skrev Oak Zeng : > gfxhub functions are now called from function pointers, > instead of from asic-specific functions. > > Signed-off-by: Oak Zeng > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +- > .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 3 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 5 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 43 ++ > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 10 > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.h | 1 + > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c | 13 +- > drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h | 2 +- > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 24 +++--- > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.h | 10 +--- > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 27 +++ > drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.h | 12 + > drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 53 > +- > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 28 +--- > 15 files changed, 155 insertions(+), 83 deletions(-) > create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 13f92de..0d8ace9 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -104,6 +104,7 @@ > #include "amdgpu_mes.h" > #include "amdgpu_umc.h" > #include "amdgpu_mmhub.h" > +#include "amdgpu_gfxhub.h" > #include "amdgpu_df.h" > > #define MAX_GPU_INSTANCE 16 > @@ -884,6 +885,9 @@ struct amdgpu_device { > /* mmhub */ > struct amdgpu_mmhub mmhub; > > + /* gfxhub */ > + struct amdgpu_gfxhubgfxhub; > + > /* gfx */ > struct amdgpu_gfx gfx; > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > index df0aab0..1529815 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c > @@ -32,7 +32,6 @@ > #include "v10_structs.h" > #include "nv.h" > #include "nvd.h" > -#include "gfxhub_v2_0.h" > > enum hqd_dequeue_request_type { > NO_ACTION = 0, > @@ -753,7 +752,7 @@ static void set_vm_context_page_table_base(struct > kgd_dev *kgd, uint32_t vmid, > } > > /* SDMA is on gfxhub as well for Navi1* series */ > - gfxhub_v2_0_setup_vm_pt_regs(adev, vmid, page_table_base); > + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > } > > const struct kfd2kgd_calls gfx_v10_kfd2kgd = { > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > index e12623a..b7ea20e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c > @@ -31,7 +31,6 @@ > #include "v10_structs.h" > #include "nv.h" > #include "nvd.h" > -#include "gfxhub_v2_1.h" > > enum hqd_dequeue_request_type { > NO_ACTION = 0, > @@ -657,7 +656,7 @@ static void > set_vm_context_page_table_base_v10_3(struct kgd_dev *kgd, uint32_t v > struct amdgpu_device *adev = get_amdgpu_device(kgd); > > /* SDMA is on gfxhub as well for Navi1* series */ > - gfxhub_v2_1_setup_vm_pt_regs(adev, vmid, page_table_base); > + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > } > > #if 0 > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > index e6aede7..b824582 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c > @@ -36,9 +36,6 @@ > #include "v9_structs.h" > #include "soc15.h" > #include "soc15d.h" > -#include "mmhub_v1_0.h" > -#include "gfxhub_v1_0.h" > - > > enum hqd_dequeue_request_type { > NO_ACTION = 0, > @@ -703,7 +700,7 @@ void kgd_gfx_v9_set_vm_context_page_table_base(struct > kgd_dev *kgd, > > adev->mmhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > > - gfxhub_v1_0_setup_vm_pt_regs(adev, vmid, page_table_base); > + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); > } > > const struct kfd2kgd_calls gfx_v9_kfd2kgd = { > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > new file mode 100644 > index 000..66ebc2e > --- /dev/null > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h > @@ -0,0 +1,43 @@ > +/* > + * Copyright 2020 Advanced Micro Devices, Inc. > + * > + * Permission
[PATCH] drm/amdgpu: use function pointer for gfxhub functions
gfxhub functions are now called from function pointers, instead of from asic-specific functions. Signed-off-by: Oak Zeng --- drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h | 43 ++ drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 10 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.h | 1 + drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c | 13 +- drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h | 2 +- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 24 +++--- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.h | 10 +--- drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c | 27 +++ drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.h | 12 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 53 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 28 +--- 15 files changed, 155 insertions(+), 83 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 13f92de..0d8ace9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -104,6 +104,7 @@ #include "amdgpu_mes.h" #include "amdgpu_umc.h" #include "amdgpu_mmhub.h" +#include "amdgpu_gfxhub.h" #include "amdgpu_df.h" #define MAX_GPU_INSTANCE 16 @@ -884,6 +885,9 @@ struct amdgpu_device { /* mmhub */ struct amdgpu_mmhub mmhub; + /* gfxhub */ + struct amdgpu_gfxhubgfxhub; + /* gfx */ struct amdgpu_gfx gfx; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c index df0aab0..1529815 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c @@ -32,7 +32,6 @@ #include "v10_structs.h" #include "nv.h" #include "nvd.h" -#include "gfxhub_v2_0.h" enum hqd_dequeue_request_type { NO_ACTION = 0, @@ -753,7 +752,7 @@ static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid, } /* SDMA is on gfxhub as well for Navi1* series */ - gfxhub_v2_0_setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); } const struct kfd2kgd_calls gfx_v10_kfd2kgd = { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c index e12623a..b7ea20e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c @@ -31,7 +31,6 @@ #include "v10_structs.h" #include "nv.h" #include "nvd.h" -#include "gfxhub_v2_1.h" enum hqd_dequeue_request_type { NO_ACTION = 0, @@ -657,7 +656,7 @@ static void set_vm_context_page_table_base_v10_3(struct kgd_dev *kgd, uint32_t v struct amdgpu_device *adev = get_amdgpu_device(kgd); /* SDMA is on gfxhub as well for Navi1* series */ - gfxhub_v2_1_setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); } #if 0 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c index e6aede7..b824582 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c @@ -36,9 +36,6 @@ #include "v9_structs.h" #include "soc15.h" #include "soc15d.h" -#include "mmhub_v1_0.h" -#include "gfxhub_v1_0.h" - enum hqd_dequeue_request_type { NO_ACTION = 0, @@ -703,7 +700,7 @@ void kgd_gfx_v9_set_vm_context_page_table_base(struct kgd_dev *kgd, adev->mmhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); - gfxhub_v1_0_setup_vm_pt_regs(adev, vmid, page_table_base); + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); } const struct kfd2kgd_calls gfx_v9_kfd2kgd = { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h new file mode 100644 index 000..66ebc2e --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h @@ -0,0 +1,43 @@ +/* + * Copyright 2020 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