coresight: turn on etm during first cpu hotplug if enabled in boot

When ETM is enabled via kernel command line or config item but we
boot with maxcpus parameter value of less than number of present
cpus, cpus that are not included as part of maxcpus don't
get ETM enabled during kernel init since those cpus would not be
online.

This change ensures that for such cpus, first hotplug after the
respective cpu's ETM probe is done, enables ETM if it is enabled
via kernel command line or config item but hasn't already been
enabled.

Change-Id: Ie3613819896e781732b80d6be20f930b474418e8
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
diff --git a/drivers/coresight/coresight-etm.c b/drivers/coresight/coresight-etm.c
index 8a45173..521d9ec 100644
--- a/drivers/coresight/coresight-etm.c
+++ b/drivers/coresight/coresight-etm.c
@@ -209,6 +209,8 @@
 	int				cpu;
 	uint8_t				arch;
 	bool				enable;
+	bool				sticky_enable;
+	bool				boot_enable;
 	bool				os_unlock;
 	uint8_t				nr_addr_cmp;
 	uint8_t				nr_cntr;
@@ -511,6 +513,7 @@
 	if (ret)
 		goto err;
 	drvdata->enable = true;
+	drvdata->sticky_enable = true;
 
 	spin_unlock(&drvdata->spinlock);
 
@@ -1852,6 +1855,10 @@
 		break;
 
 	case CPU_ONLINE:
+		if (etmdrvdata[cpu]->boot_enable &&
+		    !etmdrvdata[cpu]->sticky_enable)
+			coresight_enable(etmdrvdata[cpu]->csdev);
+
 		if (etmdrvdata[cpu]->pcsave_boot_enable &&
 		    !etmdrvdata[cpu]->pcsave_sticky_enable)
 			__etm_store_pcsave(etmdrvdata[cpu], 1);
@@ -2149,8 +2156,10 @@
 
 	dev_info(dev, "ETM initialized\n");
 
-	if (boot_enable)
+	if (boot_enable) {
 		coresight_enable(drvdata->csdev);
+		drvdata->boot_enable = true;
+	}
 
 	if (drvdata->pcsave_impl && boot_pcsave_enable) {
 		__etm_store_pcsave(drvdata, 1);