android_kernel_samsung_msm8976/drivers/ata
Tejun Heo 4e7255f33a libata, freezer: avoid block device removal while system is frozen
commit 85fbd722ad0f5d64d1ad15888cd1eb2188bfb557 upstream.

Freezable kthreads and workqueues are fundamentally problematic in
that they effectively introduce a big kernel lock widely used in the
kernel and have already been the culprit of several deadlock
scenarios.  This is the latest occurrence.

During resume, libata rescans all the ports and revalidates all
pre-existing devices.  If it determines that a device has gone
missing, the device is removed from the system which involves
invalidating block device and flushing bdi while holding driver core
layer locks.  Unfortunately, this can race with the rest of device
resume.  Because freezable kthreads and workqueues are thawed after
device resume is complete and block device removal depends on
freezable workqueues and kthreads (e.g. bdi_wq, jbd2) to make
progress, this can lead to deadlock - block device removal can't
proceed because kthreads are frozen and kthreads can't be thawed
because device resume is blocked behind block device removal.

839a8e8660 ("writeback: replace custom worker pool implementation
with unbound workqueue") made this particular deadlock scenario more
visible but the underlying problem has always been there - the
original forker task and jbd2 are freezable too.  In fact, this is
highly likely just one of many possible deadlock scenarios given that
freezer behaves as a big kernel lock and we don't have any debug
mechanism around it.

I believe the right thing to do is getting rid of freezable kthreads
and workqueues.  This is something fundamentally broken.  For now,
implement a funny workaround in libata - just avoid doing block device
hot[un]plug while the system is frozen.  Kernel engineering at its
finest.  :(

v2: Add EXPORT_SYMBOL_GPL(pm_freezing) for cases where libata is built
    as a module.

v3: Comment updated and polling interval changed to 10ms as suggested
    by Rafael.

v4: Add #ifdef CONFIG_FREEZER around the hack as pm_freezing is not
    defined when FREEZER is not configured thus breaking build.
    Reported by kbuild test robot.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Tomaž Šolc <tomaz.solc@tablix.org>
Reviewed-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=62801
Link: http://lkml.kernel.org/r/20131213174932.GA27070@htj.dyndns.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-01-09 12:24:23 -08:00
..
acard-ahci.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
ahci.c ahci: add Marvell 9230 to the AHCI PCI device list 2013-12-04 10:56:13 -08:00
ahci.h libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
ahci_platform.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
ata_generic.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
ata_piix.c ata: Fix DVD not dectected at some platform with Wellsburg PCH 2013-08-04 16:50:55 +08:00
Kconfig libata: make it clear that sata_inic162x is experimental 2013-08-04 16:50:55 +08:00
libahci.c ahci: disabled FBS prior to issuing software reset 2013-12-04 10:56:13 -08:00
libata-acpi.c libata-acpi: add back ACPI based hotplug functionality 2013-06-25 00:51:33 +02:00
libata-core.c libata: disable a disk via libata.force params 2014-01-09 12:24:23 -08:00
libata-eh.c libata: make ata_eh_qc_retry() bump scmd->allowed on bogus failures 2013-11-13 12:05:31 +09:00
libata-pmp.c libata: apply behavioral quirks to sil3826 PMP 2013-08-29 09:47:38 -07:00
libata-scsi.c libata, freezer: avoid block device removal while system is frozen 2014-01-09 12:24:23 -08:00
libata-sff.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
libata-transport.c libata: Fix display of sata speed 2013-12-04 10:55:51 -08:00
libata-transport.h [libata] Add ATA transport class 2010-10-21 20:21:03 -04:00
libata-zpodd.c libata-zpodd: must use ata_tf_init() 2013-07-25 14:07:27 -07:00
libata.h libata-acpi: add back ACPI based hotplug functionality 2013-06-25 00:51:33 +02:00
Makefile libata: add R-Car SATA driver 2013-02-20 17:10:53 -05:00
pata_acpi.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_ali.c pata_ali: fix "Satelite" typo 2011-10-14 13:10:42 -04:00
pata_amd.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_arasan_cf.c ata: arasan: remove the need for platform_data 2013-04-19 22:25:51 +02:00
pata_artop.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_at32.c pata_at32: use module_platform_driver_probe() 2013-04-03 19:52:10 -04:00
pata_at91.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_atiixp.c pata_atiixp: override cable detection on MSI E350DM-E33 2012-08-17 13:26:51 -04:00
pata_atp867x.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_bf54x.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_cmd64x.c ata: Convert dev_printk(KERN_<LEVEL> to dev_<level>( 2012-11-28 12:40:15 -05:00
pata_cmd640.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_cs5520.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_cs5530.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_cs5535.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_cs5536.c pata_cs5536: add quirk for broken udma 2012-11-28 12:38:41 -05:00
pata_cypress.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_efar.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_ep93xx.c drivers/ata: don't check resource with devm_ioremap_resource 2013-05-12 15:19:46 +02:00
pata_hpt3x2n.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_hpt3x3.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_hpt37x.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_hpt366.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_icside.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_imx.c pata_imx: add devicetree support 2013-04-11 19:38:00 -04:00
pata_isapnp.c
pata_it821x.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_it8213.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_ixp4xx_cf.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_jmicron.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_legacy.c pata_legacy: bogus clock in opti82c46x_set_piomode() 2013-04-03 19:53:10 -04:00
pata_macio.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_marvell.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_mpc52xx.c Merge remote-tracking branch 'agust/next' into next 2013-02-20 11:39:05 +11:00
pata_mpiix.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_netcell.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_ninja32.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_ns87410.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_ns87415.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_octeon_cf.c pata_octeon_cf: Use resource_size function 2013-04-03 19:53:30 -04:00
pata_of_platform.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_oldpiix.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_opti.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_optidma.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_palmld.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_pcmcia.c drivers/ata: use module_pcmcia_driver() in pcmcia drivers 2013-03-15 12:26:03 -07:00
pata_pdc202xx_old.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_pdc2027x.c pata_pdc2027x: Fix compiler warning 2013-04-12 15:24:12 +02:00
pata_piccolo.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_platform.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_pxa.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_radisys.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_rb532_cf.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_rdc.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_rz1000.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_samsung_cf.c pata_samsung_cf: use module_platform_driver_probe() 2013-03-04 17:12:52 -05:00
pata_sc1200.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_scc.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_sch.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_serverworks.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_sil680.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
pata_sis.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_sl82c105.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_triflex.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pata_via.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
pdc_adma.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
sata_dwc_460ex.c sata_dwc_460ex: remove file exec bit (chmod 0755 -> 0644) 2012-12-14 09:43:39 -05:00
sata_fsl.c sata_fsl: save irqs while coalescing 2013-08-29 09:47:38 -07:00
sata_highbank.c sata_highbank: increase retry count but shorten duration for Calxeda controller 2013-07-25 14:07:28 -07:00
sata_inic162x.c libata: make it clear that sata_inic162x is experimental 2013-08-04 16:50:55 +08:00
sata_mv.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
sata_nv.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
sata_promise.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
sata_promise.h
sata_qstor.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
sata_rcar.c sata_rcar: fix interrupt handling 2013-06-02 00:54:45 -07:00
sata_sil.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
sata_sil24.c sata_sil24: remove unused variable from sata_sil24.c 2012-11-28 12:39:20 -05:00
sata_sis.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
sata_svw.c sata_svw: switch to ->show_info() 2013-04-09 14:13:28 -04:00
sata_sx4.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
sata_uli.c ata: use module_pci_driver 2012-07-25 15:12:11 -04:00
sata_via.c libata: update "Maintained by:" tags 2013-05-14 11:13:04 -07:00
sata_vsc.c Drivers: ata: remove __dev* attributes. 2013-01-03 15:57:03 -08:00
sis.h