Skip to contentSkip to conversation

gpio/omap: fix invalid context restore of gpio bank-0

PATCH New Jon Hunter 6 participants 10 messages Jun 29, 2012 – Jul 3, 2012

Subsystems (2)
lore
Share & tools
lore

Jon Hunter

author
#0 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.

[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>
---
 drivers/gpio/gpio-omap.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-omap.c +3 -1
index c4ed172..f13fc9c 100644
@@ -1081,7 +1081,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	bank->is_mpuio = pdata->is_mpuio;
 	bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
 	bank->loses_context = pdata->loses_context;
-	bank->get_context_loss_count = pdata->get_context_loss_count;
 	bank->regs = pdata->regs;
 #ifdef CONFIG_OF_GPIO
 	bank->chip.of_node = of_node_get(node);
@@ -1135,6 +1134,9 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	omap_gpio_chip_init(bank);
 	omap_gpio_show_rev(bank);
 
+	if (bank->loses_context)
+		bank->get_context_loss_count = pdata->get_context_loss_count;
+
 	pm_runtime_put(bank->dev);
 
 	list_add_tail(&bank->node, &omap_gpio_list);
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 41 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.

[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>
Quoted 3 lines

---

#2 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

In reply to Jon Hunter
Quoted 15 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

Quoted 5 lines

There are multiple bugs here that need to be addressed ...

1. Why the always-on power domain returns a context loss count of 1? This needs ? to be fixed in the power domain code. However, the gpio driver should not ? assume the loss count is 0 to begin with.

Indeed. GPIO driver should not assume the value.

Quoted 3 lines

2. The omap gpio driver should never be calling get_context_loss_count for a ? gpio bank in a always-on domain. This is pointless and adds unneccessary ? overhead.

Make sense too.

Quoted 18 lines

3. The OMAP gpio driver assumes that the initial power domain context loss count ? will be 0 at the time the gpio driver is probed. However, it could be ? possible that this is not the case and an invalid context restore could be ? performed during the probe. To avoid this otherwise only populated the ? get_context_loss_count() function pointer after the initial call to ? pm_runtime_get() has occurred. This will ensure that the first
? pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.

[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>
Quoted 3 lines

---

Thanks Jon for sorting this out. Patch looks good to me.

#3 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 21 lines · Shilimkar, Santosh
Quoted 15 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

Quoted 5 lines

There are multiple bugs here that need to be addressed ...

1. Why the always-on power domain returns a context loss count of 1? This needs ? to be fixed in the power domain code. However, the gpio driver should not ? assume the loss count is 0 to begin with.

Quoted 16 lines

Indeed. GPIO driver should not assume the value.

Quoted 3 lines

2. The omap gpio driver should never be calling get_context_loss_count for a ? gpio bank in a always-on domain. This is pointless and adds unneccessary ? overhead.

Make sense too.

Quoted 9 lines

3. The OMAP gpio driver assumes that the initial power domain context loss count ? will be 0 at the time the gpio driver is probed. However, it could be ? possible that this is not the case and an invalid context restore could be ? performed during the probe. To avoid this otherwise only populated the ? get_context_loss_count() function pointer after the initial call to ? pm_runtime_get() has occurred. This will ensure that the first
? pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.

Should this one be Cc: stable? If this is a regression, then the regression causing commit should be mentioned.

Tony

author
#4 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 37 lines · Tony Lindgren
Quoted 36 lines · Shilimkar, Santosh
Quoted 15 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

Quoted 5 lines

There are multiple bugs here that need to be addressed ...

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.

Indeed. GPIO driver should not assume the value.

Quoted 3 lines

2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.

Make sense too.

Quoted 8 lines

3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

Quoted 4 lines
Quoted 1 line
Quoted 1 line

This patch addresses issues 2 and 3 above.

Should this one be Cc: stable? If this is a regression, then the regression causing commit should be mentioned.

So that raises a good point. Looking at the stable branch (3.4.4) it is missing 3 other fixes too [1][2][3]. So this particular problem would not have been exposed, however, I am wondering if there are other problems lingering there.

This is a regression is exposed by [2]. I should add that to the changelog.

Cheers
Jon

[1]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b3c64bc30af67ed328a8d919e41160942b870451
[2]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1b1287032df3a69d3ef9a486b444f4ffcca50d01
[3]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=22770de11cb13e7120f973bca6c800de371a6717

#5 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

In reply to Jon Hunter

+ Neil Brown

Hi Jon,

Quoted 17 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

Quoted 10 lines

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the

The 'To avoid this...' sentence here doesn't read well. Looks like you need to:

s/otherwise//
s/populated/populate/

?

Quoted 7 lines

get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.
[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Quoted 8 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>

Thanks for digging inot this bug Jon. The same bug was brought up by Neil Brown (Cc'd) in a different thread.

Neil, it looks to me that this fix will address the problems you were seeing as well. Care to test, and respond with your ack/tested-by if it works for you? Thanks.

Kevin

Quoted 26 lines
---
 drivers/gpio/gpio-omap.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-omap.c +3 -1
index c4ed172..f13fc9c 100644
@@ -1081,7 +1081,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	bank->is_mpuio = pdata->is_mpuio;
 	bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
 	bank->loses_context = pdata->loses_context;
-	bank->get_context_loss_count = pdata->get_context_loss_count;
 	bank->regs = pdata->regs;
 #ifdef CONFIG_OF_GPIO
 	bank->chip.of_node = of_node_get(node);
@@ -1135,6 +1134,9 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	omap_gpio_chip_init(bank);
 	omap_gpio_show_rev(bank);
 
+	if (bank->loses_context)
+		bank->get_context_loss_count = pdata->get_context_loss_count;
+
 	pm_runtime_put(bank->dev);
 
 	list_add_tail(&bank->node, &omap_gpio_list);
author
#6 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 34 lines · Kevin Hilman

+ Neil Brown

Hi Jon,

Quoted 17 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

Quoted 10 lines

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the

Quoted 4 lines

The 'To avoid this...' sentence here doesn't read well. Looks like you need to:

s/otherwise//

Yes, I meant to have dropped "otherwise" here. Thanks!

Quoted 1 line

s/populated/populate/

Yes that too! I must have re-worded and screwed it up royally :-(

Quoted 18 lines

?

Quoted 7 lines

get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.
[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Quoted 8 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>
Quoted 6 lines

Thanks for digging inot this bug Jon. The same bug was brought up by Neil Brown (Cc'd) in a different thread.

Neil, it looks to me that this fix will address the problems you were seeing as well. Care to test, and respond with your ack/tested-by if it works for you? Thanks.

Neil let me know your thoughts and if you are ok, I can clean-up the changelog and re-send.

Cheers
Jon

#7 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 68 lines · On Mon, 2 Jul 2012 13:26:38 -0500 Jon Hunter <[email protected]> wrote:
Quoted 34 lines · Kevin Hilman

+ Neil Brown

Hi Jon,

Quoted 17 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

Quoted 10 lines

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the

Quoted 4 lines

The 'To avoid this...' sentence here doesn't read well. Looks like you need to:

s/otherwise//

Yes, I meant to have dropped "otherwise" here. Thanks!

Quoted 1 line

s/populated/populate/

Yes that too! I must have re-worded and screwed it up royally :-(

Quoted 21 lines

?

Quoted 7 lines

get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.
[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Quoted 8 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>

Thanks for digging inot this bug Jon. The same bug was brought up by Neil Brown (Cc'd) in a different thread.

Quoted 6 lines
Quoted 3 lines

Neil, it looks to me that this fix will address the problems you were seeing as well. Care to test, and respond with your ack/tested-by if it works for you? Thanks.

Neil let me know your thoughts and if you are ok, I can clean-up the changelog and re-send.

Yes, works for me and looks sensible.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120703/11adf637/attachment-0001.sig>

#8 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 74 lines · NeilBrown
Quoted 72 lines · On Mon, 2 Jul 2012 13:26:38 -0500 Jon Hunter <[email protected]> wrote:
Quoted 34 lines · Kevin Hilman

+ Neil Brown

Hi Jon,

Quoted 17 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

Quoted 10 lines

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the

Quoted 4 lines

The 'To avoid this...' sentence here doesn't read well. Looks like you need to:

s/otherwise//

Yes, I meant to have dropped "otherwise" here. Thanks!

Quoted 1 line

s/populated/populate/

Yes that too! I must have re-worded and screwed it up royally :-(

Quoted 24 lines

?

Quoted 7 lines

get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.
[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Quoted 8 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>

Thanks for digging inot this bug Jon. The same bug was brought up by Neil Brown (Cc'd) in a different thread.

Neil, it looks to me that this fix will address the problems you were seeing as well. Care to test, and respond with your ack/tested-by if it works for you? Thanks.

Quoted 7 lines
Quoted 2 lines

Neil let me know your thoughts and if you are ok, I can clean-up the changelog and re-send.

Yes, works for me and looks sensible.

Great! Thanks for testing.

Jon, please make the minor changelog edits, collect the reviewed-by and tested-by tags and repost. I'll then queue this up for Grant.

Based on your earlier comments, this only affects v3.5, so no need to push it into stable, correct?

Kevin

author
#9 lore raw

PATCH 1/1 gpio/omap: fix invalid context restore of gpio bank-0

Quoted 81 lines · Kevin Hilman
Quoted 79 lines · NeilBrown
Quoted 68 lines · On Mon, 2 Jul 2012 13:26:38 -0500 Jon Hunter <[email protected]> wrote:
Quoted 34 lines · Kevin Hilman

+ Neil Brown

Hi Jon,

Quoted 17 lines · Jon Hunter

Currently the gpio _runtime_resume/suspend functions are calling the get_context_loss_count() platform function if the function is populated for a gpio bank. This function is used to determine if the gpio bank logic state needs to be restored due to a power transition. This function will be populated for all banks, but it should only be called for banks that have the "loses_context" variable set. It is pointless to call this if loses_context is false as we know the context will never be lost and will not need restoring.

For all OMAP2+ devices gpio bank-0 is in an always-on power domain and so will never lose context. We found that the get_context_loss_count() was being called for bank-0 during the probe and returning 1 instead of 0 indicating that the context had been lost. This was causing the context restore function to be called at probe time for this bank and because the context had never been saved, was restoring an invalid state. This ultimately resulted in a crash [1].

There are multiple bugs here that need to be addressed ...

Quoted 10 lines

1. Why the always-on power domain returns a context loss count of 1? This needs to be fixed in the power domain code. However, the gpio driver should not assume the loss count is 0 to begin with.
2. The omap gpio driver should never be calling get_context_loss_count for a gpio bank in a always-on domain. This is pointless and adds unneccessary overhead.
3. The OMAP gpio driver assumes that the initial power domain context loss count will be 0 at the time the gpio driver is probed. However, it could be possible that this is not the case and an invalid context restore could be performed during the probe. To avoid this otherwise only populated the

Quoted 4 lines

The 'To avoid this...' sentence here doesn't read well. Looks like you need to:

s/otherwise//

Yes, I meant to have dropped "otherwise" here. Thanks!

Quoted 1 line

s/populated/populate/

Yes that too! I must have re-worded and screwed it up royally :-(

Quoted 21 lines

?

Quoted 7 lines

get_context_loss_count() function pointer after the initial call to pm_runtime_get() has occurred. This will ensure that the first pm_runtime_put() initialised the loss count correctly.

This patch addresses issues 2 and 3 above.
[1] http://marc.info/?l=linux-omap&m=134065775323775&w=2

Quoted 8 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Tarun Kanti DebBarma <[email protected]>
Cc Franky Lin <[email protected]>

Thanks for digging inot this bug Jon. The same bug was brought up by Neil Brown (Cc'd) in a different thread.

Quoted 6 lines
Quoted 3 lines

Neil, it looks to me that this fix will address the problems you were seeing as well. Care to test, and respond with your ack/tested-by if it works for you? Thanks.

Neil let me know your thoughts and if you are ok, I can clean-up the changelog and re-send.

Yes, works for me and looks sensible.

Quoted 7 lines
Quoted 2 lines

Great! Thanks for testing.

Jon, please make the minor changelog edits, collect the reviewed-by and tested-by tags and repost. I'll then queue this up for Grant.

Ok, will do that tomorrow.

Quoted 2 lines

Based on your earlier comments, this only affects v3.5, so no need to push it into stable, correct?

As far as I can tell. However, not sure if any of the other fixes should be back ported.

Cheers
Jon