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

Commit 93df5326 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "esoc: Call the PON and POFF hooks with bit-masked flags"

parents 8bfecd29 e9ce612b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ static void mhi_arch_pci_link_state_cb(struct msm_pcie_notify *notify)
	}
}

static int mhi_arch_esoc_ops_power_on(void *priv, bool mdm_state)
static int mhi_arch_esoc_ops_power_on(void *priv, unsigned int flags)
{
	struct mhi_controller *mhi_cntrl = priv;
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
@@ -134,10 +134,11 @@ static int mhi_arch_esoc_ops_power_on(void *priv, bool mdm_state)
	return mhi_pci_probe(pci_dev, NULL);
}

void mhi_arch_esoc_ops_power_off(void *priv, bool mdm_state)
static void mhi_arch_esoc_ops_power_off(void *priv, unsigned int flags)
{
	struct mhi_controller *mhi_cntrl = priv;
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
	bool mdm_state = (flags & ESOC_HOOK_MDM_CRASH);

	MHI_LOG("Enter: mdm_crashed:%d\n", mdm_state);

+23 −19
Original line number Diff line number Diff line
/* Copyright (c) 2013-2015, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2015, 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -73,7 +73,7 @@ struct mdm_drv {
#define to_mdm_drv(d)	container_of(d, struct mdm_drv, cmd_eng)

static void esoc_client_link_power_off(struct esoc_clink *esoc_clink,
							bool mdm_crashed);
							unsigned int flags);

static int esoc_msm_restart_handler(struct notifier_block *nb,
		unsigned long action, void *data)
@@ -93,7 +93,7 @@ static int esoc_msm_restart_handler(struct notifier_block *nb,
			mutex_unlock(&mdm_drv->poff_lock);
			return NOTIFY_OK;
		}
		esoc_client_link_power_off(esoc_clink, false);
		esoc_client_link_power_off(esoc_clink, ESOC_HOOK_MDM_DOWN);
		esoc_mdm_log(
			"Reboot notifier: Notifying esoc of cold reboot\n");
		dev_dbg(&esoc_clink->dev, "Notifying esoc of cold reboot\n");
@@ -179,38 +179,38 @@ static void mdm_ssr_fn(struct work_struct *work)
}

static void esoc_client_link_power_on(struct esoc_clink *esoc_clink,
							bool mdm_crashed)
						unsigned int flags)
{
	int i;
	struct esoc_client_hook *client_hook;

	dev_dbg(&esoc_clink->dev, "Calling power_on hooks\n");
	esoc_mdm_log(
	"Calling power_on hooks with crash state: %d\n", mdm_crashed);
	"Calling power_on hooks with flags: 0x%x\n", flags);

	for (i = 0; i < ESOC_MAX_HOOKS; i++) {
		client_hook = esoc_clink->client_hook[i];
		if (client_hook && client_hook->esoc_link_power_on)
			client_hook->esoc_link_power_on(client_hook->priv,
							mdm_crashed);
							flags);
	}
}

static void esoc_client_link_power_off(struct esoc_clink *esoc_clink,
							bool mdm_crashed)
						unsigned int flags)
{
	int i;
	struct esoc_client_hook *client_hook;

	dev_dbg(&esoc_clink->dev, "Calling power_off hooks\n");
	esoc_mdm_log(
	"Calling power_off hooks with crash state: %d\n", mdm_crashed);
	"Calling power_off hooks with flags: 0x%x\n", flags);

	for (i = 0; i < ESOC_MAX_HOOKS; i++) {
		client_hook = esoc_clink->client_hook[i];
		if (client_hook && client_hook->esoc_link_power_off) {
			client_hook->esoc_link_power_off(client_hook->priv,
							mdm_crashed);
							flags);
		}
	}
}
@@ -251,7 +251,7 @@ static int mdm_subsys_shutdown(const struct subsys_desc *crashed_subsys,
			return 0;

		esoc_clink_queue_request(ESOC_REQ_CRASH_SHUTDOWN, esoc_clink);
		esoc_client_link_power_off(esoc_clink, true);
		esoc_client_link_power_off(esoc_clink, ESOC_HOOK_MDM_CRASH);

		esoc_mdm_log("Executing the ESOC_PREPARE_DEBUG command\n");
		ret = clink_ops->cmd_exe(ESOC_PREPARE_DEBUG,
@@ -295,7 +295,7 @@ static int mdm_subsys_shutdown(const struct subsys_desc *crashed_subsys,
			mutex_unlock(&mdm_drv->poff_lock);
			return ret;
		}
		esoc_client_link_power_off(esoc_clink, false);
		esoc_client_link_power_off(esoc_clink, ESOC_HOOK_MDM_DOWN);
		/* Pull the reset line low to turn off the device */
		clink_ops->cmd_exe(ESOC_FORCE_PWR_OFF, esoc_clink);
		mdm_drv->mode = PWR_OFF;
@@ -305,14 +305,15 @@ static int mdm_subsys_shutdown(const struct subsys_desc *crashed_subsys,
	return 0;
}

static void mdm_subsys_retry_powerup_cleanup(struct esoc_clink *esoc_clink)
static void mdm_subsys_retry_powerup_cleanup(struct esoc_clink *esoc_clink,
							unsigned int poff_flags)
{
	struct mdm_ctrl *mdm = get_esoc_clink_data(esoc_clink);
	struct mdm_drv *mdm_drv = esoc_get_drv_data(esoc_clink);

	esoc_mdm_log("Doing cleanup\n");

	esoc_client_link_power_off(esoc_clink, false);
	esoc_client_link_power_off(esoc_clink, poff_flags);
	mdm_disable_irqs(mdm);
	mdm_drv->pon_state = PON_INIT;
	reinit_completion(&mdm_drv->pon_done);
@@ -326,7 +327,7 @@ static int mdm_handle_boot_fail(struct esoc_clink *esoc_clink, u8 *pon_trial)

	switch (boot_fail_action) {
	case BOOT_FAIL_ACTION_RETRY:
		mdm_subsys_retry_powerup_cleanup(esoc_clink);
		mdm_subsys_retry_powerup_cleanup(esoc_clink, 0);
		esoc_mdm_log("Request to retry a warm reset\n");
		(*pon_trial)++;
		break;
@@ -336,7 +337,8 @@ static int mdm_handle_boot_fail(struct esoc_clink *esoc_clink, u8 *pon_trial)
	 * issuing a cold reset & a warm reset back to back.
	 */
	case BOOT_FAIL_ACTION_COLD_RESET:
		mdm_subsys_retry_powerup_cleanup(esoc_clink);
		mdm_subsys_retry_powerup_cleanup(esoc_clink,
							ESOC_HOOK_MDM_DOWN);
		esoc_mdm_log("Doing cold reset by power-down and warm reset\n");
		(*pon_trial)++;
		mdm_power_down(mdm);
@@ -350,7 +352,8 @@ static int mdm_handle_boot_fail(struct esoc_clink *esoc_clink, u8 *pon_trial)
		return -EIO;
	case BOOT_FAIL_ACTION_SHUTDOWN:
	default:
		mdm_subsys_retry_powerup_cleanup(esoc_clink);
		mdm_subsys_retry_powerup_cleanup(esoc_clink,
							ESOC_HOOK_MDM_DOWN);
		esoc_mdm_log("Shutdown the modem and quit\n");
		mdm_power_down(mdm);
		return -EIO;
@@ -393,7 +396,7 @@ static int mdm_subsys_powerup(const struct subsys_desc *crashed_subsys)
				dev_err(&esoc_clink->dev, "pwr on fail\n");
				return ret;
			}
			esoc_client_link_power_on(esoc_clink, false);
			esoc_client_link_power_on(esoc_clink, 0);
		} else if (mdm_drv->mode == IN_DEBUG) {
			esoc_mdm_log("In SSR power-on mode\n");
			esoc_mdm_log("Executing the ESOC_EXIT_DEBUG command\n");
@@ -412,7 +415,8 @@ static int mdm_subsys_powerup(const struct subsys_desc *crashed_subsys)
				dev_err(&esoc_clink->dev, "pwr on fail\n");
				return ret;
			}
			esoc_client_link_power_on(esoc_clink, true);
			esoc_client_link_power_on(esoc_clink,
							ESOC_HOOK_MDM_CRASH);
		}

		/*
@@ -437,7 +441,7 @@ static int mdm_subsys_powerup(const struct subsys_desc *crashed_subsys)
			esoc_mdm_log(
			"Boot failed. Doing cleanup and attempting to retry\n");
			pon_trial++;
			mdm_subsys_retry_powerup_cleanup(esoc_clink);
			mdm_subsys_retry_powerup_cleanup(esoc_clink, 0);
		} else if (mdm_drv->pon_state == PON_SUCCESS) {
			break;
		}
+7 −3
Original line number Diff line number Diff line
/* Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014, 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -16,12 +16,16 @@
#include <linux/esoc_ctrl.h>
#include <linux/notifier.h>

/* Flag values used with the power_on and power_off hooks */
#define ESOC_HOOK_MDM_CRASH	0x0001 /* In crash handling path */
#define ESOC_HOOK_MDM_DOWN	0x0002 /* MDM about to go down */

struct esoc_client_hook {
	char *name;
	void *priv;
	enum esoc_client_hook_prio prio;
	int (*esoc_link_power_on)(void *priv, bool mdm_crashed);
	void (*esoc_link_power_off)(void *priv, bool mdm_crashed);
	int (*esoc_link_power_on)(void *priv, unsigned int flags);
	void (*esoc_link_power_off)(void *priv, unsigned int flags);
	u64 (*esoc_link_get_id)(void *priv);
};