Unverified Commit 21eb4f17 authored by Himal Prasad Ghimiray's avatar Himal Prasad Ghimiray Committed by Rodrigo Vivi
Browse files

drm/xe/gsc: Update handling of xe_force_wake_get return



xe_force_wake_get() now returns the reference count-incremented domain
mask. If it fails for individual domains, the return value will always
be 0. However, for XE_FORCEWAKE_ALL, it may return a non-zero value even
in the event of failure. Update the return handling of xe_force_wake_get()
to reflect this behavior, and ensure that the return value is passed as
input to xe_force_wake_put().

v3
- return xe_wakeref_t instead of int in xe_force_wake_get()

v5
- return unsigned int for xe_force_wake_get()
- No need to WARN from caller in case of forcewake get failure.

v7
- Fix commit message

Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: default avatarBadal Nilawar <badal.nilawar@intel.com>
Reviewed-by: default avatarNirmoy Das <nirmoy.das@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241014075601.2324382-9-himal.prasad.ghimiray@intel.com


Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 82d9de63
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -261,19 +261,17 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)
{
	struct xe_gt *gt = gsc_to_gt(gsc);
	struct xe_tile *tile = gt_to_tile(gt);
	unsigned int fw_ref;
	int ret;

	if (XE_WA(tile->primary_gt, 14018094691)) {
		ret = xe_force_wake_get(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL);
		fw_ref = xe_force_wake_get(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL);

		/*
		 * If the forcewake fails we want to keep going, because the worst
		 * case outcome in failing to apply the WA is that PXP won't work,
		 * which is not fatal. We still throw a warning so the issue is
		 * seen if it happens.
		 * which is not fatal. Forcewake get warns implicitly in case of failure
		 */
		xe_gt_WARN_ON(tile->primary_gt, ret);

		xe_gt_mcr_multicast_write(tile->primary_gt,
					  EU_SYSTOLIC_LIC_THROTTLE_CTL_WITH_LOCK,
					  EU_SYSTOLIC_LIC_THROTTLE_CTL_LOCK_BIT);
@@ -282,7 +280,7 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)
	ret = gsc_upload(gsc);

	if (XE_WA(tile->primary_gt, 14018094691))
		xe_force_wake_put(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL);
		xe_force_wake_put(gt_to_fw(tile->primary_gt), fw_ref);

	if (ret)
		return ret;
@@ -352,6 +350,7 @@ static void gsc_work(struct work_struct *work)
	struct xe_gsc *gsc = container_of(work, typeof(*gsc), work);
	struct xe_gt *gt = gsc_to_gt(gsc);
	struct xe_device *xe = gt_to_xe(gt);
	unsigned int fw_ref;
	u32 actions;
	int ret;

@@ -361,7 +360,7 @@ static void gsc_work(struct work_struct *work)
	spin_unlock_irq(&gsc->lock);

	xe_pm_runtime_get(xe);
	xe_gt_WARN_ON(gt, xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC));
	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);

	if (actions & GSC_ACTION_ER_COMPLETE) {
		ret = gsc_er_complete(gt);
@@ -381,7 +380,7 @@ static void gsc_work(struct work_struct *work)
		xe_gsc_proxy_request_handler(gsc);

out:
	xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC);
	xe_force_wake_put(gt_to_fw(gt), fw_ref);
	xe_pm_runtime_put(xe);
}

@@ -601,7 +600,7 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
{
	struct xe_gt *gt = gsc_to_gt(gsc);
	struct xe_mmio *mmio = &gt->mmio;
	int err;
	unsigned int fw_ref;

	xe_uc_fw_print(&gsc->fw, p);

@@ -610,8 +609,8 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
	if (!xe_uc_fw_is_enabled(&gsc->fw))
		return;

	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
	if (err)
	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
	if (!fw_ref)
		return;

	drm_printf(p, "\nHECI1 FWSTS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
@@ -622,5 +621,5 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
			xe_mmio_read32(mmio, HECI_FWSTS5(MTL_GSC_HECI1_BASE)),
			xe_mmio_read32(mmio, HECI_FWSTS6(MTL_GSC_HECI1_BASE)));

	xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC);
	xe_force_wake_put(gt_to_fw(gt), fw_ref);
}
+4 −5
Original line number Diff line number Diff line
@@ -450,22 +450,21 @@ void xe_gsc_proxy_remove(struct xe_gsc *gsc)
{
	struct xe_gt *gt = gsc_to_gt(gsc);
	struct xe_device *xe = gt_to_xe(gt);
	int err = 0;
	unsigned int fw_ref = 0;

	if (!gsc->proxy.component_added)
		return;

	/* disable HECI2 IRQs */
	xe_pm_runtime_get(xe);
	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
	if (err)
	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
	if (!fw_ref)
		xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n");

	/* try do disable irq even if forcewake failed */
	gsc_proxy_irq_toggle(gsc, false);

	if (!err)
		xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC);
	xe_force_wake_put(gt_to_fw(gt), fw_ref);
	xe_pm_runtime_put(xe);

	xe_gsc_wait_for_worker_completion(gsc);