Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e7cd37d authored by Oscar Mateo's avatar Oscar Mateo Committed by Joonas Lahtinen
Browse files

drm/i915/guc: Make intel_guc_send a function pointer



Prepare for an alternate GuC communication interface.

v2: Make a few functions static and name them correctly while we are at it (Oscar), but
leave an intel_guc_send_mmio interface for users that require old-style communication.

v3: Send intel_uc_init_early back to the top (Michal).

Signed-off-by: default avatarMichel Thierry <michel.thierry@intel.com>
Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: default avatarOscar Mateo <oscar.mateo@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
parent e7465473
Loading
Loading
Loading
Loading
+11 −5
Original line number Original line Diff line number Diff line
@@ -83,7 +83,10 @@ void intel_uc_sanitize_options(struct drm_i915_private *dev_priv)


void intel_uc_init_early(struct drm_i915_private *dev_priv)
void intel_uc_init_early(struct drm_i915_private *dev_priv)
{
{
	mutex_init(&dev_priv->guc.send_mutex);
	struct intel_guc *guc = &dev_priv->guc;

	mutex_init(&guc->send_mutex);
	guc->send = intel_guc_send_mmio;
}
}


void intel_uc_init_fw(struct drm_i915_private *dev_priv)
void intel_uc_init_fw(struct drm_i915_private *dev_priv)
@@ -216,7 +219,7 @@ void intel_uc_fini_hw(struct drm_i915_private *dev_priv)
 * Read GuC command/status register (SOFT_SCRATCH_0)
 * Read GuC command/status register (SOFT_SCRATCH_0)
 * Return true if it contains a response rather than a command
 * Return true if it contains a response rather than a command
 */
 */
static bool intel_guc_recv(struct intel_guc *guc, u32 *status)
static bool guc_recv(struct intel_guc *guc, u32 *status)
{
{
	struct drm_i915_private *dev_priv = guc_to_i915(guc);
	struct drm_i915_private *dev_priv = guc_to_i915(guc);


@@ -225,7 +228,10 @@ static bool intel_guc_recv(struct intel_guc *guc, u32 *status)
	return INTEL_GUC_RECV_IS_RESPONSE(val);
	return INTEL_GUC_RECV_IS_RESPONSE(val);
}
}


int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
/*
 * This function implements the MMIO based host to GuC interface.
 */
int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len)
{
{
	struct drm_i915_private *dev_priv = guc_to_i915(guc);
	struct drm_i915_private *dev_priv = guc_to_i915(guc);
	u32 status;
	u32 status;
@@ -253,9 +259,9 @@ int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
	 * up to that length of time, then switch to a slower sleep-wait loop.
	 * up to that length of time, then switch to a slower sleep-wait loop.
	 * No inte_guc_send command should ever take longer than 10ms.
	 * No inte_guc_send command should ever take longer than 10ms.
	 */
	 */
	ret = wait_for_us(intel_guc_recv(guc, &status), 10);
	ret = wait_for_us(guc_recv(guc, &status), 10);
	if (ret)
	if (ret)
		ret = wait_for(intel_guc_recv(guc, &status), 10);
		ret = wait_for(guc_recv(guc, &status), 10);
	if (status != INTEL_GUC_STATUS_SUCCESS) {
	if (status != INTEL_GUC_STATUS_SUCCESS) {
		/*
		/*
		 * Either the GuC explicitly returned an error (which
		 * Either the GuC explicitly returned an error (which
+8 −1
Original line number Original line Diff line number Diff line
@@ -176,6 +176,9 @@ struct intel_guc {


	/* To serialize the intel_guc_send actions */
	/* To serialize the intel_guc_send actions */
	struct mutex send_mutex;
	struct mutex send_mutex;

	/* GuC's FW specific send function */
	int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
};
};


struct intel_huc {
struct intel_huc {
@@ -194,8 +197,12 @@ int intel_uc_init_hw(struct drm_i915_private *dev_priv);
void intel_uc_fini_hw(struct drm_i915_private *dev_priv);
void intel_uc_fini_hw(struct drm_i915_private *dev_priv);
void intel_uc_prepare_fw(struct drm_i915_private *dev_priv,
void intel_uc_prepare_fw(struct drm_i915_private *dev_priv,
			 struct intel_uc_fw *uc_fw);
			 struct intel_uc_fw *uc_fw);
int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
int intel_guc_sample_forcewake(struct intel_guc *guc);
int intel_guc_sample_forcewake(struct intel_guc *guc);
int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
static inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
{
	return guc->send(guc, action, len);
}


/* intel_guc_loader.c */
/* intel_guc_loader.c */
int intel_guc_select_fw(struct intel_guc *guc);
int intel_guc_select_fw(struct intel_guc *guc);