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

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

Merge "msm: ipa: eth: Prevent suspend for 2 seconds after device resume"

parents 89086d9c b3201eea
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -571,9 +571,10 @@ static int ipa_eth_pm_notifier_event_suspend_prepare(
	 * and reverts the device suspension by aborting the system suspend.
	 */
	if (ipa_eth_net_check_active(eth_dev)) {
		pr_info("%s: %s is active, preventing suspend for some time",
				IPA_ETH_SUBSYS, eth_dev->net_dev->name);
		ipa_eth_dev_wakeup_event(eth_dev);
		pr_info("%s: %s is active, preventing suspend for %u ms",
				IPA_ETH_SUBSYS, eth_dev->net_dev->name,
				IPA_ETH_WAKE_TIME_MS);
		pm_wakeup_dev_event(eth_dev->dev, IPA_ETH_WAKE_TIME_MS, false);
		return NOTIFY_BAD;
	}

+28 −2
Original line number Diff line number Diff line
@@ -35,8 +35,12 @@
#define IPA_ETH_IPC_LOGDBG_DEFAULT false
#endif

/* Time to remain awake after a suspend abort due to NIC activity */
#define IPA_ETH_WAKE_TIME_MS 500

/* Time for NIC HW to settle down (ex. receive link interrupt) after a resume */
#define IPA_ETH_RESUME_SETTLE_MS 2000

#define IPA_ETH_PFDEV (ipa3_ctx ? ipa3_ctx->pdev : NULL)
#define IPA_ETH_SUBSYS "ipa_eth"

@@ -161,9 +165,31 @@ extern bool ipa_eth_ipc_logdbg;
bool ipa_eth_is_ready(void);
bool ipa_eth_all_ready(void);

static inline void ipa_eth_dev_wakeup_event(struct ipa_eth_device *eth_dev)
static inline void ipa_eth_dev_assume_active_ms(
	struct ipa_eth_device *eth_dev,
	unsigned int msec)
{
	eth_dev_priv(eth_dev)->assume_active +=
			DIV_ROUND_UP(msec, IPA_ETH_WAKE_TIME_MS);
	pm_system_wakeup();
}

static inline void ipa_eth_dev_assume_active_inc(
	struct ipa_eth_device *eth_dev,
	unsigned int count)
{
	eth_dev_priv(eth_dev)->assume_active += count;
	pm_system_wakeup();
}

static inline void ipa_eth_dev_assume_active_dec(
	struct ipa_eth_device *eth_dev,
	unsigned int count)
{
	pm_wakeup_dev_event(eth_dev->dev, IPA_ETH_WAKE_TIME_MS, false);
	if (eth_dev_priv(eth_dev)->assume_active > count)
		eth_dev_priv(eth_dev)->assume_active -= count;
	else
		eth_dev_priv(eth_dev)->assume_active = 0;
}

struct ipa_eth_device *ipa_eth_alloc_device(
+3 −3
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ static int ipa_eth_pci_suspend_late_handler(struct device *dev)
				IPA_ETH_SUBSYS, eth_dev->net_dev->name);

		/* Have PM_SUSPEND_PREPARE give us one wakeup time quanta */
		eth_dev_priv(eth_dev)->assume_active++;
		ipa_eth_dev_assume_active_inc(eth_dev, 1);

		return -EAGAIN;
	}
@@ -428,8 +428,8 @@ static int ipa_eth_pci_resume_handler(struct device *dev)
			"Device resume delegated to net driver");
		rc = eth_dev_pm_ops(eth_dev)->resume(dev);

		/* Give some time after a resume for the device to settle */
		eth_dev_priv(eth_dev)->assume_active++;
		/* Give some time for device to settle after a resume */
		ipa_eth_dev_assume_active_ms(eth_dev, IPA_ETH_RESUME_SETTLE_MS);
	}

	if (rc)