linux/drivers/gpio
Jon Hunter 7b86cef34a 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 1b1287032 (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 <khilman@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Franky Lin <frankyl@broadcom.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: NeilBrown <neilb@suse.de>

Reported-by: Franky Lin <frankyl@broadcom.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Franky Lin <frankyl@broadcom.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
2012-07-03 09:41:39 -07:00
..
devres.c GPIO driver changes for v3.5 merge window 2012-05-24 14:01:46 -07:00
gpio-74x164.c drivers/gpio: Fix drivers who are implicit users of module.h 2011-10-31 19:31:47 -04:00
gpio-ab8500.c
gpio-adp5520.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-adp5588.c gpio: Fix uninitialized variable bit in adp5588_irq_handler 2012-04-10 14:20:55 -06:00
gpio-bt8xx.c gpio: Convert drivers to use module_pci_driver() 2012-04-07 14:30:35 -06:00
gpio-cs5535.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-da9052.c Changes queued in gpio/next for the start of the 3.3 merge window 2012-01-07 12:15:36 -08:00
gpio-davinci.c gpio/davinci: fix enabling unbanked GPIO IRQs 2012-03-12 11:53:33 -06:00
gpio-em.c gpio: Emma Mobile GPIO driver V2 2012-05-18 00:00:45 +02:00
gpio-ep93xx.c gpio/generic: initialize basic_mmio_gpio shadow variables properly 2012-05-19 12:17:35 -06:00
gpio-ge.c powerpc/85xx: Board support for GE IMP3A 2012-03-16 11:15:48 -05:00
gpio-generic.c gpio/generic: initialize basic_mmio_gpio shadow variables properly 2012-05-19 12:17:35 -06:00
gpio-ich.c gpio: Add support for Intel ICHx/3100/Series[56] GPIO 2012-05-01 12:00:21 +02:00
gpio-it8761e.c
gpio-janz-ttl.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-ks8695.c ARM: 7036/1: mach-ks8695: break out GPIO driver specifics 2011-08-22 09:12:54 +01:00
gpio-langwell.c gpio/langwell: re-read the IRQ status register after each iteration 2012-05-10 16:35:28 -06:00
gpio-lpc32xx.c gpio/lpc32xx: Add device tree support 2012-05-18 16:48:36 -06:00
gpio-max730x.c
gpio-max732x.c
gpio-max7300.c
gpio-max7301.c
gpio-mc9s08dz60.c ARM/mx35/3ds: gpio: add mc9s08dz60 gpio function 2012-01-30 07:49:08 -07:00
gpio-mc33880.c drivers/gpio: Fix drivers who are implicit users of module.h 2011-10-31 19:31:47 -04:00
gpio-mcp23s08.c gpio-mcp23s08: dbg_show: fix pullup configuration display 2012-05-18 16:48:35 -06:00
gpio-ml-ioh.c gpio: Convert drivers to use module_pci_driver() 2012-04-07 14:30:35 -06:00
gpio-mm-lantiq.c GPIO: MIPS: lantiq: convert gpio-mm-lantiq to OF and of_mm_gpio 2012-05-21 14:31:53 +01:00
gpio-mpc8xxx.c gpio: mpc8xxx: Prevent NULL pointer deref in demux handler 2012-05-18 16:48:36 -06:00
gpio-mpc5200.c drivers/gpio: Fix drivers who are implicit users of module.h 2011-10-31 19:31:47 -04:00
gpio-msic.c gpio: add MSIC gpio driver 2012-05-11 13:14:54 -06:00
gpio-msm-v1.c gpio_msm: Move Qualcomm v6 MSM driver into drivers 2011-08-01 04:58:00 -07:00
gpio-msm-v2.c gpio_msm: Move Qualcomm MSM v2 gpio driver into drivers 2011-08-01 04:58:00 -07:00
gpio-mxc.c gpio/generic: initialize basic_mmio_gpio shadow variables properly 2012-05-19 12:17:35 -06:00
gpio-mxs.c arm-soc: device tree conversions, part 2 2012-05-26 12:57:47 -07:00
gpio-omap.c gpio/omap: fix invalid context restore of gpio bank-0 2012-07-03 09:41:39 -07:00
gpio-pca953x.c Add support for TCA6424A 2012-05-18 16:48:34 -06:00
gpio-pcf857x.c gpiolib: output basic details and consolidate gpio device drivers 2011-12-12 13:40:16 -07:00
gpio-pch.c GPIO driver changes for v3.5 merge window 2012-05-24 14:01:46 -07:00
gpio-pl061.c gpio/gpio-pl061: No need of thaw and poweroff routines for hibernate 2012-02-16 06:37:51 -07:00
gpio-pxa.c gpio: pxa: parse gpio from DTS file 2012-05-05 16:36:47 +08:00
gpio-rc5t583.c gpio/rc5t583: add gpio driver for RICOH PMIC RC5T583 2012-05-18 22:59:28 -06:00
gpio-rdc321x.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-sa1100.c ARM: 7342/2: sa1100: prepare for sparse irq conversion 2012-03-25 23:57:20 +01:00
gpio-samsung.c gpio/samsung: fix the typo 'exynos5_xxx' instead of 'exonys5_xxx' 2012-06-03 21:21:01 -07:00
gpio-sch.c gpio: Add Intel Centerton support to gpio-sch 2012-05-22 23:39:14 +02:00
gpio-sodaville.c gpio/generic: initialize basic_mmio_gpio shadow variables properly 2012-05-19 12:17:35 -06:00
gpio-sta2x11.c gpio: Add STA2X11 GPIO block 2012-05-09 15:38:39 +02:00
gpio-stmpe.c GPIO changes for v3.4 2012-03-28 14:08:46 -07:00
gpio-stp-xway.c GPIO: MIPS: lantiq: convert gpio-stp-xway to OF 2012-05-21 14:31:53 +01:00
gpio-sx150x.c
gpio-tc3589x.c
gpio-tegra.c gpio: tegra: Hide tegra_gpio_enable/disable() 2012-04-18 10:26:38 -06:00
gpio-timberdale.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-tnetv107x.c ARM: 7039/1: mach-davinci: move DaVinci TNET GPIO driver to GPIO subsystem 2011-08-22 09:12:55 +01:00
gpio-tps65910.c gpio: tps65910: dt: process gpio specific device node info 2012-05-22 23:50:13 +02:00
gpio-tps65912.c
gpio-twl4030.c gpio/twl: Add DT support to gpio-twl4030 driver 2012-03-22 13:05:55 +01:00
gpio-ucb1400.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-vr41xx.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-vx855.c gpio: Convert GPIO drivers to module_platform_driver 2012-01-02 00:26:06 -07:00
gpio-wm831x.c mfd: Convert wm831x to irq_domain 2012-05-20 17:27:07 +02:00
gpio-wm8350.c
gpio-wm8994.c gpio: Add decode of WM8994 GPIO configuration 2012-01-02 00:27:01 -07:00
gpio-xilinx.c gpiolib: output basic details and consolidate gpio device drivers 2011-12-12 13:40:16 -07:00
gpiolib-of.c gpio: Adjust of_xlate API to support multiple GPIO chips 2012-05-18 16:48:36 -06:00
gpiolib.c gpiolib: Remove 'const' from data argument of gpiochip_find() 2012-05-18 23:01:05 -06:00
Kconfig Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2012-05-29 18:27:19 -07:00
Makefile Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2012-05-29 18:27:19 -07:00