Skip to content

Commit 7b86cef

Browse files
Jon HunterKevin Hilman
Jon Hunter
authored and
Kevin Hilman
committed
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]. This issue is a regression that was exposed by commit 1b12870 (gpio/omap: fix missing check in *_runtime_suspend()). 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 [2]. 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 only populate 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 [2] http://marc.info/?l=linux-omap&m=134100413303810&w=2 Cc: Kevin Hilman <[email protected]> Cc: Grant Likely <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Tarun Kanti DebBarma <[email protected]> Cc: Franky Lin <[email protected]> Cc: Santosh Shilimkar <[email protected]> Cc: NeilBrown <[email protected]> Reported-by: Franky Lin <[email protected]> Reviewed-by: Santosh Shilimkar <[email protected]> Tested-by: Franky Lin <[email protected]> Acked-by: Kevin Hilman <[email protected]> Tested-by: NeilBrown <[email protected]> Signed-off-by: Jon Hunter <[email protected]> Signed-off-by: Kevin Hilman <[email protected]>
1 parent 9e303f2 commit 7b86cef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpio/gpio-omap.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
10911091
bank->is_mpuio = pdata->is_mpuio;
10921092
bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
10931093
bank->loses_context = pdata->loses_context;
1094-
bank->get_context_loss_count = pdata->get_context_loss_count;
10951094
bank->regs = pdata->regs;
10961095
#ifdef CONFIG_OF_GPIO
10971096
bank->chip.of_node = of_node_get(node);
@@ -1145,6 +1144,9 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
11451144
omap_gpio_chip_init(bank);
11461145
omap_gpio_show_rev(bank);
11471146

1147+
if (bank->loses_context)
1148+
bank->get_context_loss_count = pdata->get_context_loss_count;
1149+
11481150
pm_runtime_put(bank->dev);
11491151

11501152
list_add_tail(&bank->node, &omap_gpio_list);

0 commit comments

Comments
 (0)