From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH] drm/xe: Promote guc_to_gt/xe helpers to .h
Date: Fri, 24 Mar 2023 14:40:31 -0400 [thread overview]
Message-ID: <ZB3unyFtQlmOFZHS@intel.com> (raw)
In-Reply-To: <20230313080117.2320-1-michal.wajdeczko@intel.com>
On Mon, Mar 13, 2023 at 09:01:17AM +0100, Michal Wajdeczko wrote:
> Duplicating these helpers in almost every .c file was a bad idea.
> Define them as inlines in .h file to allow proper reuse.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_pagefault.c | 6 ------
> drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 6 ------
> drivers/gpu/drm/xe/xe_guc.c | 12 ------------
> drivers/gpu/drm/xe/xe_guc.h | 11 +++++++++++
> drivers/gpu/drm/xe/xe_guc_debugfs.c | 12 ------------
> drivers/gpu/drm/xe/xe_guc_hwconfig.c | 12 ------------
> drivers/gpu/drm/xe/xe_guc_submit.c | 12 ------------
> 7 files changed, 11 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c
> index 1677640e1075..2ae54fecf4ab 100644
> --- a/drivers/gpu/drm/xe/xe_gt_pagefault.c
> +++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c
> @@ -58,12 +58,6 @@ struct acc {
> u8 engine_instance;
> };
>
> -static struct xe_gt *
> -guc_to_gt(struct xe_guc *guc)
> -{
> - return container_of(guc, struct xe_gt, uc.guc);
> -}
> -
> static bool access_is_atomic(enum access_type access_type)
> {
> return access_type == ACCESS_TYPE_ATOMIC;
> diff --git a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
> index f279e21300aa..259382d54871 100644
> --- a/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
> +++ b/drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c
> @@ -12,12 +12,6 @@
>
> #define TLB_TIMEOUT (HZ / 4)
>
> -static struct xe_gt *
> -guc_to_gt(struct xe_guc *guc)
> -{
> - return container_of(guc, struct xe_gt, uc.guc);
> -}
> -
> static void xe_gt_tlb_fence_timeout(struct work_struct *work)
> {
> struct xe_gt *gt = container_of(work, struct xe_gt,
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 58b9841616e4..8fb2920d96da 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -22,18 +22,6 @@
> #include "xe_uc_fw.h"
> #include "xe_wopcm.h"
>
> -static struct xe_gt *
> -guc_to_gt(struct xe_guc *guc)
> -{
> - return container_of(guc, struct xe_gt, uc.guc);
> -}
> -
> -static struct xe_device *
> -guc_to_xe(struct xe_guc *guc)
> -{
> - return gt_to_xe(guc_to_gt(guc));
> -}
> -
> /* GuC addresses above GUC_GGTT_TOP also don't map through the GTT */
> #define GUC_GGTT_TOP 0xFEE00000
> static u32 guc_bo_ggtt_addr(struct xe_guc *guc,
> diff --git a/drivers/gpu/drm/xe/xe_guc.h b/drivers/gpu/drm/xe/xe_guc.h
> index 74a74051f354..96f6e3f46ed7 100644
> --- a/drivers/gpu/drm/xe/xe_guc.h
> +++ b/drivers/gpu/drm/xe/xe_guc.h
> @@ -6,6 +6,7 @@
> #ifndef _XE_GUC_H_
> #define _XE_GUC_H_
>
> +#include "xe_gt.h"
sometimes the duplication is better then forcing more dependencies then needed.
I'm really not saying that this is the case here... If we are sure that the
xe_gt.h was already affecting all the cases that include xe_guc.h then we
should go with your patch...
> #include "xe_guc_types.h"
> #include "xe_hw_engine_types.h"
> #include "xe_macros.h"
> @@ -56,4 +57,14 @@ static inline u16 xe_engine_class_to_guc_class(enum xe_engine_class class)
> }
> }
>
> +static inline struct xe_gt *guc_to_gt(struct xe_guc *guc)
> +{
> + return container_of(guc, struct xe_gt, uc.guc);
> +}
> +
> +static inline struct xe_device *guc_to_xe(struct xe_guc *guc)
> +{
> + return gt_to_xe(guc_to_gt(guc));
> +}
> +
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_guc_debugfs.c b/drivers/gpu/drm/xe/xe_guc_debugfs.c
> index 6b72db4d5bb2..dbb3001db928 100644
> --- a/drivers/gpu/drm/xe/xe_guc_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_guc_debugfs.c
> @@ -15,18 +15,6 @@
> #include "xe_guc_log.h"
> #include "xe_macros.h"
>
> -static struct xe_gt *
> -guc_to_gt(struct xe_guc *guc)
> -{
> - return container_of(guc, struct xe_gt, uc.guc);
> -}
> -
> -static struct xe_device *
> -guc_to_xe(struct xe_guc *guc)
> -{
> - return gt_to_xe(guc_to_gt(guc));
> -}
> -
> static struct xe_guc *node_to_guc(struct drm_info_node *node)
> {
> return node->info_ent->data;
> diff --git a/drivers/gpu/drm/xe/xe_guc_hwconfig.c b/drivers/gpu/drm/xe/xe_guc_hwconfig.c
> index a6982f323ed1..a89d26565fdd 100644
> --- a/drivers/gpu/drm/xe/xe_guc_hwconfig.c
> +++ b/drivers/gpu/drm/xe/xe_guc_hwconfig.c
> @@ -13,18 +13,6 @@
> #include "xe_guc.h"
> #include "xe_map.h"
>
> -static struct xe_gt *
> -guc_to_gt(struct xe_guc *guc)
> -{
> - return container_of(guc, struct xe_gt, uc.guc);
> -}
> -
> -static struct xe_device *
> -guc_to_xe(struct xe_guc *guc)
> -{
> - return gt_to_xe(guc_to_gt(guc));
> -}
> -
> static int send_get_hwconfig(struct xe_guc *guc, u32 ggtt_addr, u32 size)
> {
> u32 action[] = {
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index e857013070b9..6b3159e75be9 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -32,18 +32,6 @@
> #include "xe_trace.h"
> #include "xe_vm.h"
>
> -static struct xe_gt *
> -guc_to_gt(struct xe_guc *guc)
> -{
> - return container_of(guc, struct xe_gt, uc.guc);
> -}
> -
> -static struct xe_device *
> -guc_to_xe(struct xe_guc *guc)
> -{
> - return gt_to_xe(guc_to_gt(guc));
> -}
> -
> static struct xe_guc *
> engine_to_guc(struct xe_engine *e)
> {
> --
> 2.25.1
>
next prev parent reply other threads:[~2023-03-24 18:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 8:01 [Intel-xe] [PATCH] drm/xe: Promote guc_to_gt/xe helpers to .h Michal Wajdeczko
2023-03-13 18:14 ` [Intel-xe] ✓ CI.Patch_applied: success for " Patchwork
2023-03-13 18:15 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-03-13 18:19 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-03-24 18:40 ` Rodrigo Vivi [this message]
2023-03-29 20:25 ` [Intel-xe] [PATCH] " Michal Wajdeczko
2023-03-30 11:58 ` Jani Nikula
-- strict thread matches above, loose matches on Subject: below --
2023-03-12 15:59 Michal Wajdeczko
2023-03-15 10:20 ` Matthew Auld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZB3unyFtQlmOFZHS@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox