From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 3/4] drm/xe: Combine common force-wake code into helpers
Date: Mon, 10 Jun 2024 15:51:09 -0400 [thread overview]
Message-ID: <ZmdZLT2mznd6XCIo@intel.com> (raw)
In-Reply-To: <20240610183757.1812-4-michal.wajdeczko@intel.com>
On Mon, Jun 10, 2024 at 08:37:56PM +0200, Michal Wajdeczko wrote:
> The code of 'control' and 'wait' force-wake operations are very
> similar for both 'wake' and 'sleep' cases. Add helpers to maximize
> code reuse.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> drivers/gpu/drm/xe/xe_force_wake.c | 55 ++++++++++++++++--------------
> 1 file changed, 30 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_force_wake.c b/drivers/gpu/drm/xe/xe_force_wake.c
> index a1d97cce3d56..b0baa9094418 100644
> --- a/drivers/gpu/drm/xe/xe_force_wake.c
> +++ b/drivers/gpu/drm/xe/xe_force_wake.c
> @@ -20,6 +20,11 @@ static struct xe_gt *fw_to_gt(struct xe_force_wake *fw)
> return fw->gt;
> }
>
> +static inline const char *str_wake_sleep(bool v)
> +{
> + return v ? "wake" : "sleep";
probably better with s/v/wake ?!
but up to you:
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> +}
> +
> static void domain_init(struct xe_force_wake_domain *domain,
> enum xe_force_wake_domain_id id,
> struct xe_reg reg, struct xe_reg ack)
> @@ -94,47 +99,47 @@ void xe_force_wake_init_engines(struct xe_gt *gt, struct xe_force_wake *fw)
> FORCEWAKE_ACK_GSC);
> }
>
> +static void __domain_ctl(struct xe_gt *gt, struct xe_force_wake_domain *domain, bool wake)
> +{
> + xe_mmio_write32(gt, domain->reg_ctl, domain->mask | (wake ? domain->val : 0));
> +}
> +
> +static int __domain_wait(struct xe_gt *gt, struct xe_force_wake_domain *domain, bool wake)
> +{
> + u32 value;
> + int ret;
> +
> + ret = xe_mmio_wait32(gt, domain->reg_ack, domain->val, wake ? domain->val : 0,
> + XE_FORCE_WAKE_ACK_TIMEOUT_MS * USEC_PER_MSEC,
> + &value, true);
> + if (ret)
> + xe_gt_notice(gt, "Force wake domain %d failed to ack %s (%pe) reg[%#x] = %#x\n",
> + domain->id, str_wake_sleep(wake), ERR_PTR(ret),
> + domain->reg_ack.addr, value);
> +
> + return ret;
> +}
> +
> static void domain_wake(struct xe_gt *gt, struct xe_force_wake_domain *domain)
> {
> - xe_mmio_write32(gt, domain->reg_ctl, domain->mask | domain->val);
> + __domain_ctl(gt, domain, true);
> }
>
> static int domain_wake_wait(struct xe_gt *gt,
> struct xe_force_wake_domain *domain)
> {
> - u32 value;
> - int ret;
> -
> - ret = xe_mmio_wait32(gt, domain->reg_ack, domain->val, domain->val,
> - XE_FORCE_WAKE_ACK_TIMEOUT_MS * USEC_PER_MSEC,
> - &value, true);
> - if (ret)
> - xe_gt_notice(gt, "Force wake domain %d failed to ack wake (%pe) reg[%#x] = %#x\n",
> - domain->id, ERR_PTR(ret), domain->reg_ack.addr, value);
> -
> - return ret;
> + return __domain_wait(gt, domain, true);
> }
>
> static void domain_sleep(struct xe_gt *gt, struct xe_force_wake_domain *domain)
> {
> - xe_mmio_write32(gt, domain->reg_ctl, domain->mask);
> + __domain_ctl(gt, domain, false);
> }
>
> static int domain_sleep_wait(struct xe_gt *gt,
> struct xe_force_wake_domain *domain)
> {
> - u32 value;
> - int ret;
> -
> - ret = xe_mmio_wait32(gt, domain->reg_ack, domain->val, 0,
> - XE_FORCE_WAKE_ACK_TIMEOUT_MS * USEC_PER_MSEC,
> - &value, true);
> -
> - if (ret)
> - xe_gt_notice(gt, "Force wake domain %d failed to ack sleep (%pe) reg[%#x] = %#x\n",
> - domain->id, ERR_PTR(ret), domain->reg_ack.addr, value);
> -
> - return ret;
> + return __domain_wait(gt, domain, false);
> }
>
> #define for_each_fw_domain_masked(domain__, mask__, fw__, tmp__) \
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-06-10 19:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 18:37 [PATCH 0/4] Prepare Xe force-wake code for VFs Michal Wajdeczko
2024-06-10 18:37 ` [PATCH 1/4] drm/xe: Prefer GT oriented messages in xe_force_wake.c Michal Wajdeczko
2024-06-10 19:44 ` Rodrigo Vivi
2024-06-10 18:37 ` [PATCH 2/4] drm/xe: Include additional info on failed force-wake operation Michal Wajdeczko
2024-06-10 19:47 ` Rodrigo Vivi
2024-06-10 18:37 ` [PATCH 3/4] drm/xe: Combine common force-wake code into helpers Michal Wajdeczko
2024-06-10 19:51 ` Rodrigo Vivi [this message]
2024-06-10 18:37 ` [PATCH 4/4] drm/xe/vf: Ignore force-wake requests if VF Michal Wajdeczko
2024-06-10 19:51 ` Rodrigo Vivi
2024-06-10 18:54 ` ✓ CI.Patch_applied: success for Prepare Xe force-wake code for VFs Patchwork
2024-06-10 18:54 ` ✓ CI.checkpatch: " Patchwork
2024-06-10 18:55 ` ✓ CI.KUnit: " Patchwork
2024-06-10 19:07 ` ✓ CI.Build: " Patchwork
2024-06-10 19:09 ` ✓ CI.Hooks: " Patchwork
2024-06-10 19:10 ` ✓ CI.checksparse: " Patchwork
2024-06-11 6:09 ` ✓ CI.Patch_applied: success for Prepare Xe force-wake code for VFs (rev2) Patchwork
2024-06-11 6:09 ` ✓ CI.checkpatch: " Patchwork
2024-06-11 6:10 ` ✓ CI.KUnit: " Patchwork
2024-06-11 6:22 ` ✓ CI.Build: " Patchwork
2024-06-11 6:24 ` ✗ CI.Hooks: failure " Patchwork
2024-06-11 6:25 ` ✓ CI.checksparse: success " Patchwork
2024-06-11 7:08 ` ✓ CI.BAT: " Patchwork
2024-06-11 8:45 ` ✓ CI.FULL: " Patchwork
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=ZmdZLT2mznd6XCIo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.