diff mbox series

[V5,2/7] soc: qcom-geni-se: Add interconnect support to fix earlycon crash

Message ID 1588919619-21355-3-git-send-email-akashast@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series Add interconnect support to QSPI and QUP drivers | expand

Commit Message

Akash Asthana May 8, 2020, 6:33 a.m. UTC
QUP core clock is shared among all the SE drivers present on particular
QUP wrapper, the system will reset(unclocked access) if earlycon used after
QUP core clock is put to 0 from other SE drivers before real console comes
up.

As earlycon can't vote for it's QUP core need, to fix this add ICC
support to common/QUP wrapper driver and put vote for QUP core from
probe on behalf of earlycon and remove vote during earlycon exit call.

Signed-off-by: Akash Asthana <akashast@codeaurora.org>
Reported-by: Matthias Kaehlcke <mka@chromium.org>
---
Change in V3:
 - Add geni_remove_earlycon_icc_vote API that will be used by earlycon
   exit function to remove ICC vote for earlyconsole.
 - Remove suspend/resume hook for geni-se driver as we are no longer
   removing earlyconsole ICC vote from system suspend, we are removing
   from earlycon exit.

Change in V4:
 - As per Matthias comment make 'earlycon_wrapper' as static structure.

Changes in V5:
 - Vote for core path only after checking whether "qcom_geni" earlycon is
   actually present or not by traversing over structure "console_drivers".

 drivers/soc/qcom/qcom-geni-se.c       | 63 +++++++++++++++++++++++++++++++++++
 drivers/tty/serial/qcom_geni_serial.c |  7 ++++
 include/linux/qcom-geni-se.h          |  2 ++
 3 files changed, 72 insertions(+)

Comments

Matthias Kaehlcke May 8, 2020, 5:59 p.m. UTC | #1
Hi Akash,

overall this looks good to me, a few comments inline

On Fri, May 08, 2020 at 12:03:34PM +0530, Akash Asthana wrote:
> QUP core clock is shared among all the SE drivers present on particular
> QUP wrapper, the system will reset(unclocked access) if earlycon used after
> QUP core clock is put to 0 from other SE drivers before real console comes
> up.
> 
> As earlycon can't vote for it's QUP core need, to fix this add ICC
> support to common/QUP wrapper driver and put vote for QUP core from
> probe on behalf of earlycon and remove vote during earlycon exit call.
> 
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> Reported-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> Change in V3:
>  - Add geni_remove_earlycon_icc_vote API that will be used by earlycon
>    exit function to remove ICC vote for earlyconsole.
>  - Remove suspend/resume hook for geni-se driver as we are no longer
>    removing earlyconsole ICC vote from system suspend, we are removing
>    from earlycon exit.
> 
> Change in V4:
>  - As per Matthias comment make 'earlycon_wrapper' as static structure.
> 
> Changes in V5:
>  - Vote for core path only after checking whether "qcom_geni" earlycon is
>    actually present or not by traversing over structure "console_drivers".
> 
>  drivers/soc/qcom/qcom-geni-se.c       | 63 +++++++++++++++++++++++++++++++++++
>  drivers/tty/serial/qcom_geni_serial.c |  7 ++++
>  include/linux/qcom-geni-se.h          |  2 ++
>  3 files changed, 72 insertions(+)
> 
> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> index 63403bf..66fe6f2 100644
> --- a/drivers/soc/qcom/qcom-geni-se.c
> +++ b/drivers/soc/qcom/qcom-geni-se.c
> @@ -3,6 +3,7 @@
>  
>  #include <linux/acpi.h>
>  #include <linux/clk.h>
> +#include <linux/console.h>
>  #include <linux/slab.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/io.h>
> @@ -90,11 +91,14 @@ struct geni_wrapper {
>  	struct device *dev;
>  	void __iomem *base;
>  	struct clk_bulk_data ahb_clks[NUM_AHB_CLKS];
> +	struct geni_icc_path to_core;
>  };
>  
>  static const char * const icc_path_names[] = {"qup-core", "qup-config",
>  								"qup-memory"};
>  
> +static struct geni_wrapper *earlycon_wrapper;
> +
>  #define QUP_HW_VER_REG			0x4
>  
>  /* Common SE registers */
> @@ -812,11 +816,33 @@ int geni_icc_disable(struct geni_se *se)
>  }
>  EXPORT_SYMBOL(geni_icc_disable);
>  
> +void geni_remove_earlycon_icc_vote(void)
> +{
> +	struct geni_wrapper *wrapper = earlycon_wrapper;
> +	struct device_node *parent = of_get_next_parent(wrapper->dev->of_node);

Do we need to check that earlycon_wrapper != NULL before dereferencing it?
In theory this should not happen, but better be safe.

> +	struct device_node *child;
> +
> +	for_each_child_of_node(parent, child) {
> +		if (of_device_is_compatible(child, "qcom,geni-se-qup")) {
> +			wrapper = platform_get_drvdata(of_find_device_by_node(
> +					child));
> +			icc_put(wrapper->to_core.path);
> +			wrapper->to_core.path = NULL;

nit: setting the path to NULL isn't really needed IIUC.

> +		}
> +	}
> +	of_node_put(parent);
> +
> +	earlycon_wrapper = NULL;
> +}
> +EXPORT_SYMBOL(geni_remove_earlycon_icc_vote);
> +
>  static int geni_se_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct resource *res;
>  	struct geni_wrapper *wrapper;
> +	struct console *bcon;
> +	int earlycon_present = 0;

use bool & true/false

The variable is only used when CONFIG_SERIAL_EARLYCON is set, I think
you need to add '__maybe_unused' to avoid a compiler warning then earlycon
support is disabled.

bikeshed: 'has_earlycon' would be slightly more concise (feel free to ignore).

>  	int ret;
>  
>  	wrapper = devm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL);
> @@ -839,6 +865,43 @@ static int geni_se_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +#ifdef CONFIG_SERIAL_EARLYCON
> +	if (console_drivers)

The loop should have curly braces ("use braces when a loop contains more than
a single simple statement"), even though the compiler doesn't need them in
this case. This is not a loop, but I was told by a maintainer that it equally
applies, which makes sense.

You could avoid one level of indentation through:

if (!console_drivers)
	goto exit;

> +		for_each_console(bcon)

ditto (braces)

> +			if (!strcmp(bcon->name, "qcom_geni")) {
> +				earlycon_present = 1;
> +				break;
> +			}
> +	if (!earlycon_present)
> +		goto exit;
> +
> +	wrapper->to_core.path = devm_of_icc_get(dev, "qup-core");
> +	if (IS_ERR(wrapper->to_core.path))
> +		return PTR_ERR(wrapper->to_core.path);
> +	/*
> +	 * Put minmal BW request on core clocks on behalf of early console.
> +	 * The vote will be removed earlycon exit function.
> +	 *
> +	 * Note: We are putting vote on each QUP wrapper instead only to which
> +	 * earlycon is connected because QUP core clock of different wrapper
> +	 * share same voltage domain. If core1 is put to 0, then core2 will
> +	 * also run at 0, if not voted. Default ICC vote will be removed ASA
> +	 * we touch any of the core clock.
> +	 * core1 = core2 = max(core1, core2)
> +	 */
> +	ret = icc_set_bw(wrapper->to_core.path, GENI_DEFAULT_BW,
> +							GENI_DEFAULT_BW);

nit: the indentation is a bit odd. Align with 'wrapper->to_core.path' or a
nearby tab stop?
Matthias Kaehlcke May 8, 2020, 7:14 p.m. UTC | #2
On Fri, May 08, 2020 at 10:59:38AM -0700, Matthias Kaehlcke wrote:
> Hi Akash,
> 
> overall this looks good to me, a few comments inline
> 
> On Fri, May 08, 2020 at 12:03:34PM +0530, Akash Asthana wrote:
> > QUP core clock is shared among all the SE drivers present on particular
> > QUP wrapper, the system will reset(unclocked access) if earlycon used after
> > QUP core clock is put to 0 from other SE drivers before real console comes
> > up.
> > 
> > As earlycon can't vote for it's QUP core need, to fix this add ICC
> > support to common/QUP wrapper driver and put vote for QUP core from
> > probe on behalf of earlycon and remove vote during earlycon exit call.
> > 
> > Signed-off-by: Akash Asthana <akashast@codeaurora.org>
> > Reported-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> > Change in V3:
> >  - Add geni_remove_earlycon_icc_vote API that will be used by earlycon
> >    exit function to remove ICC vote for earlyconsole.
> >  - Remove suspend/resume hook for geni-se driver as we are no longer
> >    removing earlyconsole ICC vote from system suspend, we are removing
> >    from earlycon exit.
> > 
> > Change in V4:
> >  - As per Matthias comment make 'earlycon_wrapper' as static structure.
> > 
> > Changes in V5:
> >  - Vote for core path only after checking whether "qcom_geni" earlycon is
> >    actually present or not by traversing over structure "console_drivers".
> > 
> >  drivers/soc/qcom/qcom-geni-se.c       | 63 +++++++++++++++++++++++++++++++++++
> >  drivers/tty/serial/qcom_geni_serial.c |  7 ++++
> >  include/linux/qcom-geni-se.h          |  2 ++
> >  3 files changed, 72 insertions(+)
> > 
> > diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> > index 63403bf..66fe6f2 100644
> > --- a/drivers/soc/qcom/qcom-geni-se.c
> > +++ b/drivers/soc/qcom/qcom-geni-se.c

...

> > +#ifdef CONFIG_SERIAL_EARLYCON
> > +	if (console_drivers)
> 
> The loop should have curly braces ("use braces when a loop contains more than
> a single simple statement"), even though the compiler doesn't need them in
> this case. This is not a loop, but I was told by a maintainer that it equally
> applies, which makes sense.
> 
> You could avoid one level of indentation through:
> 
> if (!console_drivers)
> 	goto exit;
> 
> > +		for_each_console(bcon)

Actually the NULL check of 'console_drivers' is not needed:

#define for_each_console(con) \
        for (con = console_drivers; con != NULL; con = con->next)

see also:

commit caa72c3bc584bc28b557bcf1a47532a7a6f37e6f
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Mon Feb 3 15:31:25 2020 +0200

    console: Drop double check for console_drivers being non-NULL
Andy Shevchenko May 9, 2020, 12:11 p.m. UTC | #3
On Fri, May 8, 2020 at 9:34 AM Akash Asthana <akashast@codeaurora.org> wrote:
>
> QUP core clock is shared among all the SE drivers present on particular
> QUP wrapper, the system will reset(unclocked access) if earlycon used after
> QUP core clock is put to 0 from other SE drivers before real console comes
> up.
>
> As earlycon can't vote for it's QUP core need, to fix this add ICC
> support to common/QUP wrapper driver and put vote for QUP core from
> probe on behalf of earlycon and remove vote during earlycon exit call.

...

> +       for_each_child_of_node(parent, child) {

> +               if (of_device_is_compatible(child, "qcom,geni-se-qup")) {

if (!...)
 continue;

will save you a readability of the loop body.

Or...

> +                       wrapper = platform_get_drvdata(of_find_device_by_node(
> +                                       child));

...leave this on one line

> +                       icc_put(wrapper->to_core.path);
> +                       wrapper->to_core.path = NULL;
> +               }

And here is the question, what do you want to do if you find more
devices with the same compatible string?

> +       }
Akash Asthana May 14, 2020, 6:45 a.m. UTC | #4
Hi Matthias,

On 5/8/2020 11:29 PM, Matthias Kaehlcke wrote:
> Hi Akash,
>
> overall this looks good to me, a few comments inline
>
> On Fri, May 08, 2020 at 12:03:34PM +0530, Akash Asthana wrote:
>> QUP core clock is shared among all the SE drivers present on particular
>> QUP wrapper, the system will reset(unclocked access) if earlycon used after
>> QUP core clock is put to 0 from other SE drivers before real console comes
>> up.
>>
>> As earlycon can't vote for it's QUP core need, to fix this add ICC
>> support to common/QUP wrapper driver and put vote for QUP core from
>> probe on behalf of earlycon and remove vote during earlycon exit call.
>>
>> Signed-off-by: Akash Asthana <akashast@codeaurora.org>
>> Reported-by: Matthias Kaehlcke <mka@chromium.org>
>> ---
>> Change in V3:
>>   - Add geni_remove_earlycon_icc_vote API that will be used by earlycon
>>     exit function to remove ICC vote for earlyconsole.
>>   - Remove suspend/resume hook for geni-se driver as we are no longer
>>     removing earlyconsole ICC vote from system suspend, we are removing
>>     from earlycon exit.
>>
>> Change in V4:
>>   - As per Matthias comment make 'earlycon_wrapper' as static structure.
>>
>> Changes in V5:
>>   - Vote for core path only after checking whether "qcom_geni" earlycon is
>>     actually present or not by traversing over structure "console_drivers".
>>
>>   drivers/soc/qcom/qcom-geni-se.c       | 63 +++++++++++++++++++++++++++++++++++
>>   drivers/tty/serial/qcom_geni_serial.c |  7 ++++
>>   include/linux/qcom-geni-se.h          |  2 ++
>>   3 files changed, 72 insertions(+)
>>
>> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
>> index 63403bf..66fe6f2 100644
>> --- a/drivers/soc/qcom/qcom-geni-se.c
>> +++ b/drivers/soc/qcom/qcom-geni-se.c
>> @@ -3,6 +3,7 @@
>>   
>>   #include <linux/acpi.h>
>>   #include <linux/clk.h>
>> +#include <linux/console.h>
>>   #include <linux/slab.h>
>>   #include <linux/dma-mapping.h>
>>   #include <linux/io.h>
>> @@ -90,11 +91,14 @@ struct geni_wrapper {
>>   	struct device *dev;
>>   	void __iomem *base;
>>   	struct clk_bulk_data ahb_clks[NUM_AHB_CLKS];
>> +	struct geni_icc_path to_core;
>>   };
>>   
>>   static const char * const icc_path_names[] = {"qup-core", "qup-config",
>>   								"qup-memory"};
>>   
>> +static struct geni_wrapper *earlycon_wrapper;
>> +
>>   #define QUP_HW_VER_REG			0x4
>>   
>>   /* Common SE registers */
>> @@ -812,11 +816,33 @@ int geni_icc_disable(struct geni_se *se)
>>   }
>>   EXPORT_SYMBOL(geni_icc_disable);
>>   
>> +void geni_remove_earlycon_icc_vote(void)
>> +{
>> +	struct geni_wrapper *wrapper = earlycon_wrapper;
>> +	struct device_node *parent = of_get_next_parent(wrapper->dev->of_node);
> Do we need to check that earlycon_wrapper != NULL before dereferencing it?
> In theory this should not happen, but better be safe.
Ok, I will add NULL check.
>
>> +	struct device_node *child;
>> +
>> +	for_each_child_of_node(parent, child) {
>> +		if (of_device_is_compatible(child, "qcom,geni-se-qup")) {
>> +			wrapper = platform_get_drvdata(of_find_device_by_node(
>> +					child));
>> +			icc_put(wrapper->to_core.path);
>> +			wrapper->to_core.path = NULL;
> nit: setting the path to NULL isn't really needed IIUC.
icc_put just free the path and don't reinitialize the path to NULL, if 
the path is used after it is put target will crash. So just for safety I 
am setting this path to NULL.
>
>> +		}
>> +	}
>> +	of_node_put(parent);
>> +
>> +	earlycon_wrapper = NULL;
>> +}
>> +EXPORT_SYMBOL(geni_remove_earlycon_icc_vote);
>> +
>>   static int geni_se_probe(struct platform_device *pdev)
>>   {
>>   	struct device *dev = &pdev->dev;
>>   	struct resource *res;
>>   	struct geni_wrapper *wrapper;
>> +	struct console *bcon;
>> +	int earlycon_present = 0;
> use bool & true/false
>
> The variable is only used when CONFIG_SERIAL_EARLYCON is set, I think
> you need to add '__maybe_unused' to avoid a compiler warning then earlycon
> support is disabled.
>
> bikeshed: 'has_earlycon' would be slightly more concise (feel free to ignore).
Ok
>
>>   	int ret;
>>   
>>   	wrapper = devm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL);
>> @@ -839,6 +865,43 @@ static int geni_se_probe(struct platform_device *pdev)
>>   		}
>>   	}
>>   
>> +#ifdef CONFIG_SERIAL_EARLYCON
>> +	if (console_drivers)
> The loop should have curly braces ("use braces when a loop contains more than
> a single simple statement"), even though the compiler doesn't need them in
> this case. This is not a loop, but I was told by a maintainer that it equally
> applies, which makes sense.
>
> You could avoid one level of indentation through:
Ok
>
> if (!console_drivers)
> 	goto exit;

I think I can omit this extra check because "for_each_console" will take 
care of this.

>
>> +		for_each_console(bcon)
> ditto (braces)
>
>> +			if (!strcmp(bcon->name, "qcom_geni")) {
>> +				earlycon_present = 1;
>> +				break;
>> +			}
>> +	if (!earlycon_present)
>> +		goto exit;
>> +
>> +	wrapper->to_core.path = devm_of_icc_get(dev, "qup-core");
>> +	if (IS_ERR(wrapper->to_core.path))
>> +		return PTR_ERR(wrapper->to_core.path);
>> +	/*
>> +	 * Put minmal BW request on core clocks on behalf of early console.
>> +	 * The vote will be removed earlycon exit function.
>> +	 *
>> +	 * Note: We are putting vote on each QUP wrapper instead only to which
>> +	 * earlycon is connected because QUP core clock of different wrapper
>> +	 * share same voltage domain. If core1 is put to 0, then core2 will
>> +	 * also run at 0, if not voted. Default ICC vote will be removed ASA
>> +	 * we touch any of the core clock.
>> +	 * core1 = core2 = max(core1, core2)
>> +	 */
>> +	ret = icc_set_bw(wrapper->to_core.path, GENI_DEFAULT_BW,
>> +							GENI_DEFAULT_BW);
> nit: the indentation is a bit odd. Align with 'wrapper->to_core.path' or a
> nearby tab stop?

ok


Thanks for providing the feedback.

Regards,

Akash
Akash Asthana May 14, 2020, 7:03 a.m. UTC | #5
Hi Matthias,


>> The loop should have curly braces ("use braces when a loop contains more than
>> a single simple statement"), even though the compiler doesn't need them in
>> this case. This is not a loop, but I was told by a maintainer that it equally
>> applies, which makes sense.
>>
>> You could avoid one level of indentation through:
>>
>> if (!console_drivers)
>> 	goto exit;
>>
>>> +		for_each_console(bcon)
> Actually the NULL check of 'console_drivers' is not needed:
>
> #define for_each_console(con) \
>          for (con = console_drivers; con != NULL; con = con->next)

Ok, I will remove this check.


Regards,

Akash

>
> see also:
>
> commit caa72c3bc584bc28b557bcf1a47532a7a6f37e6f
> Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Date:   Mon Feb 3 15:31:25 2020 +0200
>
>      console: Drop double check for console_drivers being non-NULL
Akash Asthana May 14, 2020, 7:34 a.m. UTC | #6
Hi Andy,

On 5/9/2020 5:41 PM, Andy Shevchenko wrote:
> On Fri, May 8, 2020 at 9:34 AM Akash Asthana <akashast@codeaurora.org> wrote:
>> QUP core clock is shared among all the SE drivers present on particular
>> QUP wrapper, the system will reset(unclocked access) if earlycon used after
>> QUP core clock is put to 0 from other SE drivers before real console comes
>> up.
>>
>> As earlycon can't vote for it's QUP core need, to fix this add ICC
>> support to common/QUP wrapper driver and put vote for QUP core from
>> probe on behalf of earlycon and remove vote during earlycon exit call.
> ...
>
>> +       for_each_child_of_node(parent, child) {
>> +               if (of_device_is_compatible(child, "qcom,geni-se-qup")) {
> if (!...)
>   continue;
> will save you a readability of the loop body.
>
> Or...
Ok.
>
>> +                       wrapper = platform_get_drvdata(of_find_device_by_node(
>> +                                       child));
> ...leave this on one line
ok
>
>> +                       icc_put(wrapper->to_core.path);
>> +                       wrapper->to_core.path = NULL;
>> +               }
> And here is the question, what do you want to do if you find more
> devices with the same compatible string?

We are voting on core path (from probe *geni_se_probe*) for all the 
devices which are compatible to string "qcom,geni-se-qup" so, here we'll 
remove those vote and release the icc_path for all the those devices

We have to vote on each qup device instead ones to which console is 
connected because all the qup shares the same core clocks. You may refer 
previous thread@ https://www.spinics.net/lists/linux-spi/msg21000.html 
for more info on this limitation.

Thankyou for taking time out and reviewing the patch.

Regards,

Akash

>
>> +       }
diff mbox series

Patch

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 63403bf..66fe6f2 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -3,6 +3,7 @@ 
 
 #include <linux/acpi.h>
 #include <linux/clk.h>
+#include <linux/console.h>
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
@@ -90,11 +91,14 @@  struct geni_wrapper {
 	struct device *dev;
 	void __iomem *base;
 	struct clk_bulk_data ahb_clks[NUM_AHB_CLKS];
+	struct geni_icc_path to_core;
 };
 
 static const char * const icc_path_names[] = {"qup-core", "qup-config",
 								"qup-memory"};
 
+static struct geni_wrapper *earlycon_wrapper;
+
 #define QUP_HW_VER_REG			0x4
 
 /* Common SE registers */
@@ -812,11 +816,33 @@  int geni_icc_disable(struct geni_se *se)
 }
 EXPORT_SYMBOL(geni_icc_disable);
 
+void geni_remove_earlycon_icc_vote(void)
+{
+	struct geni_wrapper *wrapper = earlycon_wrapper;
+	struct device_node *parent = of_get_next_parent(wrapper->dev->of_node);
+	struct device_node *child;
+
+	for_each_child_of_node(parent, child) {
+		if (of_device_is_compatible(child, "qcom,geni-se-qup")) {
+			wrapper = platform_get_drvdata(of_find_device_by_node(
+					child));
+			icc_put(wrapper->to_core.path);
+			wrapper->to_core.path = NULL;
+		}
+	}
+	of_node_put(parent);
+
+	earlycon_wrapper = NULL;
+}
+EXPORT_SYMBOL(geni_remove_earlycon_icc_vote);
+
 static int geni_se_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct resource *res;
 	struct geni_wrapper *wrapper;
+	struct console *bcon;
+	int earlycon_present = 0;
 	int ret;
 
 	wrapper = devm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL);
@@ -839,6 +865,43 @@  static int geni_se_probe(struct platform_device *pdev)
 		}
 	}
 
+#ifdef CONFIG_SERIAL_EARLYCON
+	if (console_drivers)
+		for_each_console(bcon)
+			if (!strcmp(bcon->name, "qcom_geni")) {
+				earlycon_present = 1;
+				break;
+			}
+	if (!earlycon_present)
+		goto exit;
+
+	wrapper->to_core.path = devm_of_icc_get(dev, "qup-core");
+	if (IS_ERR(wrapper->to_core.path))
+		return PTR_ERR(wrapper->to_core.path);
+	/*
+	 * Put minmal BW request on core clocks on behalf of early console.
+	 * The vote will be removed earlycon exit function.
+	 *
+	 * Note: We are putting vote on each QUP wrapper instead only to which
+	 * earlycon is connected because QUP core clock of different wrapper
+	 * share same voltage domain. If core1 is put to 0, then core2 will
+	 * also run at 0, if not voted. Default ICC vote will be removed ASA
+	 * we touch any of the core clock.
+	 * core1 = core2 = max(core1, core2)
+	 */
+	ret = icc_set_bw(wrapper->to_core.path, GENI_DEFAULT_BW,
+							GENI_DEFAULT_BW);
+	if (ret) {
+		dev_err(&pdev->dev, "%s: ICC BW voting failed for core\n",
+			__func__);
+		return ret;
+	}
+
+	if (of_get_compatible_child(pdev->dev.of_node, "qcom,geni-debug-uart"))
+		earlycon_wrapper = wrapper;
+	of_node_put(pdev->dev.of_node);
+#endif
+exit:
 	dev_set_drvdata(dev, wrapper);
 	dev_dbg(dev, "GENI SE Driver probed\n");
 	return devm_of_platform_populate(dev);
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 6119090..8c5d97c 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1090,6 +1090,12 @@  static void qcom_geni_serial_earlycon_write(struct console *con,
 	__qcom_geni_serial_console_write(&dev->port, s, n);
 }
 
+static int qcom_geni_serial_earlycon_exit(struct console *con)
+{
+	geni_remove_earlycon_icc_vote();
+	return 0;
+}
+
 static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev,
 								const char *opt)
 {
@@ -1135,6 +1141,7 @@  static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev,
 	writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN);
 
 	dev->con->write = qcom_geni_serial_earlycon_write;
+	dev->con->exit = qcom_geni_serial_earlycon_exit;
 	dev->con->setup = NULL;
 	return 0;
 }
diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h
index 7afa08d..51e9e9b 100644
--- a/include/linux/qcom-geni-se.h
+++ b/include/linux/qcom-geni-se.h
@@ -458,5 +458,7 @@  void geni_icc_bw_init(struct geni_icc_path *icc_paths, unsigned int avg_bw,
 int geni_icc_enable(struct geni_se *se);
 
 int geni_icc_disable(struct geni_se *se);
+
+void geni_remove_earlycon_icc_vote(void);
 #endif
 #endif