linux/drivers/mmc/host
Andy Shevchenko 78a2ca2727 mmc: sdhci: check host->clock before using it as a denominator
Sometimes host->clock could be zero which is a legal situation. This
patch checks host->clock before usage as a denominator when timeout is
calculated. A similar patch is applied for mmc core (see commit e9b8684,
"mmc: fix division by zero in MMC core").

Without this patch, the execution of the sdhci_calc_timeout could end up
with a backtrace:

<0>[    4.014319] divide error: 0000 [#1] PREEMPT SMP
<4>[    4.014352] Modules linked in: g_ether
<4>[    4.014376]
<4>[    4.014393] Pid: 33, comm: kworker/u:2 Not tainted 3.0.0+ #646
<4>[    4.014421] EIP: 0060:[<c12fa38e>] EFLAGS: 00010046 CPU: 1
<4>[    4.014449] EIP is at sdhci_calc_timeout+0x2e/0x100
<4>[    4.014468] EAX: 00000000 EBX: f5930fc8 ECX: 00000000 EDX: 00000000
<4>[    4.014488] ESI: f5291de8 EDI: f5291db8 EBP: f5291c6c ESP: f5291c50
<4>[    4.014508]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
<0>[    4.014529] Process kworker/u:2 (pid: 33, ti=f5290000 task=f53065a0 task.ti=f5290000)
<0>[    4.014546] Stack:
<4>[    4.014557]  00000082 c1054fdd f5291c78 04000000 f5930fc8 f5291de8 f5291db8 f5291cac
<4>[    4.014611]  c12fab7c c107a98b f5291c88 c13b6d3f f593109c f5882000 f5291cac c1054fdd
<4>[    4.014663]  00000000 00000000 f5882000 00000082 f5930fc8 f5291db8 0000000a f5291ccc
<0>[    4.014716] Call Trace:
<4>[    4.014743]  [<c1054fdd>] ? mod_timer+0x11d/0x380
<4>[    4.014770]  [<c12fab7c>] sdhci_prepare_data+0x2c/0x3a0
<4>[    4.014798]  [<c107a98b>] ? trace_hardirqs_off+0xb/0x10
<4>[    4.014827]  [<c13b6d3f>] ? _raw_spin_unlock_irqrestore+0x2f/0x60
<4>[    4.014854]  [<c1054fdd>] ? mod_timer+0x11d/0x380
<4>[    4.014880]  [<c12fc7db>] sdhci_send_command+0xdb/0x210
<4>[    4.014906]  [<c12fd5f3>] sdhci_request+0xc3/0x150
<4>[    4.014932]  [<c12ec56a>] mmc_start_request+0xda/0x200
<4>[    4.014960]  [<c120d7c2>] ? __raw_spin_lock_init+0x32/0x60
<4>[    4.014989]  [<c1066a85>] ? __init_waitqueue_head+0x35/0x50
<4>[    4.015015]  [<c12ec70b>] mmc_wait_for_req+0x7b/0x90
<4>[    4.015045]  [<c12f0c67>] mmc_send_cxd_data+0xf7/0x130
<4>[    4.015076]  [<c12ecbc0>] ? mmc_erase+0x140/0x140
<4>[    4.015102]  [<c12f139d>] mmc_send_ext_csd+0x1d/0x20
<4>[    4.015125]  [<c12efef0>] mmc_get_ext_csd+0x70/0x140
<4>[    4.015151]  [<c12effe8>] mmc_compare_ext_csds+0x28/0x190
<4>[    4.015176]  [<c12f039f>] mmc_init_card+0x24f/0x650
<4>[    4.015201]  [<c13b6d5d>] ? _raw_spin_unlock_irqrestore+0x4d/0x60
<4>[    4.015226]  [<c107fd9c>] ? trace_hardirqs_on_caller+0x11c/0x160
<4>[    4.015255]  [<c12f09a4>] mmc_attach_mmc+0xa4/0x190
<4>[    4.015282]  [<c12ee3f0>] mmc_rescan+0x210/0x240
<4>[    4.015311]  [<c105f9b6>] process_one_work+0x176/0x550
<4>[    4.015336]  [<c105f93a>] ? process_one_work+0xfa/0x550
<4>[    4.015360]  [<c12ee1e0>] ? mmc_init_erase+0x140/0x140
<4>[    4.015385]  [<c1061c2a>] worker_thread+0x12a/0x2c0
<4>[    4.015410]  [<c1061b00>] ? manage_workers.clone.18+0x100/0x100
<4>[    4.015437]  [<c1066244>] kthread+0x74/0x80
<4>[    4.015463]  [<c10661d0>] ? __init_kthread_worker+0x60/0x60
<4>[    4.015490]  [<c13b7dfa>] kernel_thread_helper+0x6/0xd
<0>[    4.015507] Code: 57 89 d7 56 53 89 c3 83 ec 10 8b 40 04 8b 72 28 f6 c4 10 89 45 f0 0f 85 91 00 00 00 85 f6 0f 84 c1 00 00 00 8b 4e 04 31 d2 89 c8 <f7> 73 58 ba d3 4d 62 10 89 c1 8b 06 f7 e2 c1 ea 06 01 d1 f7 45
<0>[    4.015829] EIP: [<c12fa38e>] sdhci_calc_timeout+0x2e/0x100 SS:ESP 0068:f5291c50

Reported-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2011-08-13 14:50:28 -04:00
..
at91_mci.c mmc: at91_mci: move register header from include/ to drivers/ 2011-07-21 10:35:08 -04:00
at91_mci.h mmc: at91_mci: move register header from include/ to drivers/ 2011-07-21 10:35:08 -04:00
atmel-mci-regs.h atmel-mci: add MCI2 register definitions 2009-06-13 22:43:01 +02:00
atmel-mci.c mmc: atmel-mci: add suspend/resume support 2011-07-20 17:21:08 -04:00
au1xmmc.c tree-wide: fix comment/printk typos 2010-11-01 15:38:34 -04:00
bfin_sdh.c mmc: bfin_sdh: fix alloc size for private data 2011-01-26 00:28:41 -05:00
cb710-mmc.c mmc: cb710: Return err value in cb710_wait_while_busy() 2011-03-15 13:49:42 -04:00
cb710-mmc.h mmc: Driver for CB710/720 memory card reader (MMC part) 2009-06-13 22:42:58 +02:00
davinci_mmc.c mmc: davinci: add support for SDIO irq handling 2011-01-09 19:16:18 -05:00
dw_mmc.c mmc: dw_mmc: Fix mask in IDMAC_SET_BUFFER1_SIZE macro 2011-08-13 14:50:24 -04:00
dw_mmc.h mmc: dw_mmc: don't hard code fifo depth, fix usage 2011-07-20 17:20:59 -04:00
imxmmc.c mmc: Remove distinction between hw and phys segments 2010-10-23 21:11:11 +08:00
imxmmc.h imxmmc: use readl/writel 2008-12-16 14:58:17 +01:00
jz4740_mmc.c mmc: jz4740: don't treat NULL clk as an error 2011-01-25 21:53:51 -05:00
Kconfig mmc: kconfig: remove EXPERIMENTAL from the DMA selection of atmel-mci 2011-07-20 17:21:09 -04:00
Makefile mmc: tmio: Fix build error without CONFIG_MMC_SDHI 2011-07-20 17:21:00 -04:00
mmc_spi.c Fix common misspellings 2011-03-31 11:26:23 -03:00
mmci.c Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2011-07-24 10:20:54 -07:00
mmci.h mmc: mmci: implement pre_req() and post_req() 2011-07-20 17:21:11 -04:00
msm_sdcc.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc 2011-03-18 22:32:40 -07:00
msm_sdcc.h mmc: msm_sdcc: Add gpio handling function to driver 2011-01-21 16:58:00 -08:00
mvsdio.c mmc: Remove distinction between hw and phys segments 2010-10-23 21:11:11 +08:00
mvsdio.h mmc: SDIO driver for Marvell SoCs 2009-03-24 21:30:03 +01:00
mxcmmc.c ARM i.MX dma: Fix burstsize settings 2011-07-07 09:55:50 +02:00
mxs-mmc.c mmc: mxs-mmc: fix clock rate setting 2011-07-21 10:35:08 -04:00
of_mmc_spi.c mmc: of_mmc_spi: add NO_IRQ define to of_mmc_spi.c 2011-06-18 22:18:00 -04:00
omap.c mmc: omap: Fix possible NULL pointer deref 2011-04-27 19:15:12 -04:00
omap_hsmmc.c mmc: omap_hsmmc: fix oops in omap_hsmmc_dma_cb() 2011-07-21 10:35:04 -04:00
pxamci.c mmc: Move regulator handling closer to core 2010-10-23 21:11:16 +08:00
pxamci.h
s3cmci.c Fix common misspellings 2011-03-31 11:26:23 -03:00
s3cmci.h s3cmci: DMA fixes 2009-10-01 16:11:15 -07:00
sdhci-cns3xxx.c mmc: sdhci: change sdhci-pltfm into a module 2011-07-20 17:20:49 -04:00
sdhci-dove.c mmc: sdhci: change sdhci-pltfm into a module 2011-07-20 17:20:49 -04:00
sdhci-esdhc-imx.c mmc: esdhc-imx: fix card interrupt loss on freescale eSDHC 2011-08-13 14:50:26 -04:00
sdhci-esdhc.h mmc: sdhci-esdhc: remove SDHCI_QUIRK_NO_CARD_NO_RESET from esdhc 2011-03-25 10:30:49 -04:00
sdhci-of-esdhc.c mmc: sdhci: change sdhci-pltfm into a module 2011-07-20 17:20:49 -04:00
sdhci-of-hlwd.c mmc: sdhci: change sdhci-pltfm into a module 2011-07-20 17:20:49 -04:00
sdhci-pci.c mmc: sdhci-pci: allow 8-bit bus width for Intel Medfield eMMCs 2011-07-20 17:21:07 -04:00
sdhci-pltfm.c mmc: sdhci-pltfm: dt device does not pass parent to sdhci_alloc_host 2011-07-27 09:31:33 +08:00
sdhci-pltfm.h mmc: sdhci: change sdhci-pltfm into a module 2011-07-20 17:20:49 -04:00
sdhci-pxav2.c mmc: sdhci-pxa: move platform data to include/linux/platform_data 2011-07-20 17:20:52 -04:00
sdhci-pxav3.c mmc: sdhci: pxav3: controller needs 32 bit ADMA addressing 2011-08-13 14:50:20 -04:00
sdhci-s3c.c mmc: sdhci-s3c: Fix build for header change 2011-08-13 14:50:25 -04:00
sdhci-spear.c drivers: Final irq namespace conversion 2011-03-29 14:48:19 +02:00
sdhci-tegra.c mmc: sdhci: change sdhci-pltfm into a module 2011-07-20 17:20:49 -04:00
sdhci.c mmc: sdhci: check host->clock before using it as a denominator 2011-08-13 14:50:28 -04:00
sdhci.h mmc: sdhci: Auto-CMD23 support. 2011-05-25 16:51:40 -04:00
sdricoh_cs.c pcmcia: Convert pcmcia_device_id declarations to const 2011-05-06 07:46:22 +02:00
sh_mmcif.c mmc: sh_mmcif: maximize power saving 2011-07-21 10:35:06 -04:00
sh_mobile_sdhi.c mmc: sdhi: Add write16_hook 2011-07-20 17:20:57 -04:00
tifm_sd.c mmc: Remove distinction between hw and phys segments 2010-10-23 21:11:11 +08:00
tmio_mmc.c mmc: tmio: eliminate unused variable 'mmc' warning 2011-08-13 14:50:27 -04:00
tmio_mmc.h MMC / TMIO: Fix build issue related to struct scatterlist 2011-07-26 11:52:55 -07:00
tmio_mmc_dma.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2011-07-22 14:43:13 -07:00
tmio_mmc_pio.c mmc: tmio: fix a deadlock 2011-07-21 10:35:07 -04:00
ushc.c mmc: ushc: Remove duplicate include of usb.h 2011-01-25 21:53:43 -05:00
via-sdmmc.c mmc: use pci_dev->revision 2011-03-25 10:30:49 -04:00
vub300.c Merge branch 'master' into for-next 2011-07-11 14:15:55 +02:00
wbsd.c Fix common misspellings 2011-03-31 11:26:23 -03:00
wbsd.h