9 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Thu, 15 Dec 2011 02:22:55 +0000 (18:22 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/viro/vfs

* 'for-linus' of git://
  fs/ncpfs: fix error paths and goto statements in ncp_fill_super()
  configfs: register_filesystem() called too early
  fuse: register_filesystem() called too early
  ubifs: too early register_filesystem()
  ... and the same kind of leak for mqueue
  procfs: fix a vfsmount longterm reference leak

9 years agofs/ncpfs: fix error paths and goto statements in ncp_fill_super()
Djalal Harouni [Tue, 13 Dec 2011 01:47:29 +0000 (02:47 +0100)]
fs/ncpfs: fix error paths and goto statements in ncp_fill_super()

The label 'out_bdi' should be followed by bdi_destroy() instead of
fput() which should be after the 'out_fput' label.

If bdi_setup_and_register() fails then jump to the 'out_fput' label
instead of the 'out_bdi' one.

If fget(data.info_fd) fails then jump to the previously fixed 'out_bdi'
label to call bdi_destroy() otherwise the bdi object will not be

Compile tested only.

Signed-off-by: Djalal Harouni <>
Signed-off-by: Al Viro <>
9 years agoMerge branch 'x86-urgent-for-linus' of git://
Linus Torvalds [Tue, 13 Dec 2011 23:02:31 +0000 (15:02 -0800)]
Merge branch 'x86-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

* 'x86-urgent-for-linus' of git://
  Revert "x86, efi: Calling __pa() with an ioremap()ed address is invalid"
  x86, efi: Make efi_call_phys_{prelog,epilog} CONFIG_RELOCATABLE-aware

9 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Tue, 13 Dec 2011 22:59:42 +0000 (14:59 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/sage/ceph-client

* 'for-linus' of git://
  ceph: add missing spin_unlock at ceph_mdsc_build_path()
  ceph: fix SEEK_CUR, SEEK_SET regression
  crush: fix mapping calculation when force argument doesn't exist
  ceph: use i_ceph_lock instead of i_lock
  rbd: remove buggy rollback functionality
  rbd: return an error when an invalid header is read
  ceph: fix rasize reporting by ceph_show_options

9 years agoMerge branch 'writeback-for-linus' of git://
Linus Torvalds [Tue, 13 Dec 2011 22:58:56 +0000 (14:58 -0800)]
Merge branch 'writeback-for-linus' of git://git./linux/kernel/git/wfg/linux

* 'writeback-for-linus' of git://
  writeback: set max_pause to lowest value on zero bdi_dirty
  writeback: permit through good bdi even when global dirty exceeded
  writeback: comment on the bdi dirty threshold
  fs: Make write(2) interruptible by a fatal signal
  writeback: Fix issue on make htmldocs

9 years agoceph: add missing spin_unlock at ceph_mdsc_build_path()
Yehuda Sadeh [Tue, 13 Dec 2011 17:57:44 +0000 (09:57 -0800)]
ceph: add missing spin_unlock at ceph_mdsc_build_path()

one of the paths was missing spin_unlock

Signed-off-by: Yehuda Sadeh <>
9 years agoconfigfs: register_filesystem() called too early
Al Viro [Tue, 13 Dec 2011 17:32:42 +0000 (12:32 -0500)]
configfs: register_filesystem() called too early

Signed-off-by: Al Viro <>
9 years agofuse: register_filesystem() called too early
Al Viro [Tue, 13 Dec 2011 17:25:27 +0000 (12:25 -0500)]
fuse: register_filesystem() called too early

same story as with ubifs

Signed-off-by: Al Viro <>
9 years agoubifs: too early register_filesystem()
Al Viro [Tue, 13 Dec 2011 04:58:21 +0000 (23:58 -0500)]
ubifs: too early register_filesystem()

doing that before you are ready to handle mount() is a Bad Idea(tm)...

Signed-off-by: Al Viro <>
9 years agoMerge branch 'fixes' of
Linus Torvalds [Tue, 13 Dec 2011 17:28:23 +0000 (09:28 -0800)]
Merge branch 'fixes' of

* 'fixes' of
  ARM: 7204/1: arch/arm/kernel/setup.c: initialize arm_dma_zone_size earlier
  ARM: 7185/1: perf: don't assign platform_device on unsupported CPUs
  ARM: 7187/1: fix unwinding for XIP kernels
  ARM: 7186/1: fix Kconfig issue with PHYS_OFFSET and !MMU

9 years agoceph: fix SEEK_CUR, SEEK_SET regression
Sage Weil [Tue, 13 Dec 2011 17:19:26 +0000 (09:19 -0800)]
ceph: fix SEEK_CUR, SEEK_SET regression

Commit 06222e491e663dac939f04b125c9dc52126a75c4 got the if wrong so that
it always evaluates as true.  This is semantically harmless, but makes
SEEK_CUR and SEEK_SET needlessly query the server.

Rewrite the if to explicitly enumerate the cases we DO need a valid i_size
to make this code less fragile.

Reported-by: Roel Kluin <>
Signed-off-by: Sage Weil <>
9 years agolinux/log2.h: Fix rounddown_pow_of_two(1)
Linus Torvalds [Tue, 13 Dec 2011 06:06:55 +0000 (22:06 -0800)]
linux/log2.h: Fix rounddown_pow_of_two(1)

Exactly like roundup_pow_of_two(1), the rounddown version was buggy for
the case of a compile-time constant '1' argument.  Probably because it
originated from the same code, sharing history with the roundup version
from before the bugfix (for that one, see commit 1a06a52ee1b0: "Fix

However, unlike the roundup version, the fix for rounddown is to just
remove the broken special case entirely.  It's simply not needed - the
generic code

    1UL << ilog2(n)

does the right thing for the constant '1' argment too.  The only reason
roundup needed that special case was because rounding up does so by
subtracting one from the argument (and then adding one to the result)
causing the obvious problems with "ilog2(0)".

But rounddown doesn't do any of that, since ilog2() naturally truncates
(ie "rounds down") to the right rounded down value.  And without the
ilog2(0) case, there's no reason for the special case that had the wrong

tl;dr: rounddown_pow_of_two(1) should be 1, not 0.

Acked-by: Dmitry Torokhov <>
Signed-off-by: Linus Torvalds <>
9 years agoMerge branch 'hwmon-for-linus' of git://
Linus Torvalds [Tue, 13 Dec 2011 04:08:27 +0000 (20:08 -0800)]
Merge branch 'hwmon-for-linus' of git://git./linux/kernel/git/groeck/linux-staging

* 'hwmon-for-linus' of git://
  hwmon: (jz4740) Staticise jz4740_hwmon_driver
  hwmon: (jz4740) fix signedness bug

9 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Tue, 13 Dec 2011 04:06:13 +0000 (20:06 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/cjb/mmc

* 'for-linus' of git://
  mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined
  mmc: sdhci-s3c: Remove old and misprototyped suspend operations
  mmc: tmio: fix clock gating on platforms with a .set_pwr() method
  mmc: sh_mmcif: fix clock gating on platforms with a .down_pwr() method
  mmc: core: Fix typo at mmc_card_sleep
  mmc: core: Fix power_off_notify during suspend
  mmc: core: Fix setting power notify state variable for non-eMMC
  mmc: core: Add quirk for long data read time
  mmc: Add module.h include to sdhci-cns3xxx.c
  mmc: mxcmmc: fix falling back to PIO
  mmc: omap_hsmmc: DMA unmap only once in case of MMC error

9 years agoRevert "x86, efi: Calling __pa() with an ioremap()ed address is invalid"
Keith Packard [Mon, 12 Dec 2011 00:12:42 +0000 (16:12 -0800)]
Revert "x86, efi: Calling __pa() with an ioremap()ed address is invalid"

This hangs my MacBook Air at boot time; I get no console
messages at all. I reverted this on top of -rc5 and my machine
boots again.

This reverts commit e8c7106280a305e1ff2a3a8a4dfce141469fb039.

Signed-off-by: Matt Fleming <>
Signed-off-by: Keith Packard <>
Acked-by: H. Peter Anvin <>
Cc: Matthew Garrett <>
Cc: Zhang Rui <>
Cc: Huang Ying <>
Cc: Linus Torvalds <>
Cc: Andrew Morton <>
Signed-off-by: Ingo Molnar <>
9 years agocrush: fix mapping calculation when force argument doesn't exist
Sage Weil [Wed, 7 Dec 2011 17:10:26 +0000 (09:10 -0800)]
crush: fix mapping calculation when force argument doesn't exist

If the force argument isn't valid, we should continue calculating a
mapping as if it weren't specified.

Signed-off-by: Sage Weil <>
9 years agohwmon: (jz4740) Staticise jz4740_hwmon_driver
Axel Lin [Thu, 8 Dec 2011 13:33:37 +0000 (08:33 -0500)]
hwmon: (jz4740) Staticise jz4740_hwmon_driver

It is not used outside this driver so no need to make the symbol global.

Signed-off-by: Axel Lin <>
Acked-by: Lars-Peter Clausen <>
Signed-off-by: Guenter Roeck <>
9 years agohwmon: (jz4740) fix signedness bug
Axel Lin [Thu, 8 Dec 2011 13:04:12 +0000 (08:04 -0500)]
hwmon: (jz4740) fix signedness bug

wait_for_completion_interruptible_timeout() may return negative value.
In this case, checking if (t > 0)  will return true if t is unsigned.

Signed-off-by: Axel Lin <>
Acked-by: Lars-Peter Clausen <>
Cc: (3.0+)
Signed-off-by: Guenter Roeck <>
9 years agoARM: 7204/1: arch/arm/kernel/setup.c: initialize arm_dma_zone_size earlier
Arnaud Patard [Sun, 11 Dec 2011 19:32:25 +0000 (20:32 +0100)]
ARM: 7204/1: arch/arm/kernel/setup.c: initialize arm_dma_zone_size earlier

arm_dma_zone_size is used by arm_bootmem_free() which is called by
paging_init(). Thus it needs to be set before calling it.

Signed-off-by: Arnaud Patard <>
Acked-by: Nicolas Pitre <>
Signed-off-by: Russell King <>
9 years agommc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined
Sujit Reddy Thumma [Wed, 23 Nov 2011 03:13:18 +0000 (08:43 +0530)]
mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined

mmc_suspend_host() tries to claim host during suspend
and release it only when the bus suspend operation is
compeleted. If CONFIG_MMC_UNSAFE_RESUME is defined and
the host is flagged as removable, mmc_suspend_host()
tries to remove the card. In this process, the file system
sync can get blocked trying to acquire host which is already
claimed by mmc_suspend_host() causing deadlock.

Fix this deadlock by releasing host before ->remove() is called.

Signed-off-by: Sujit Reddy Thumma <>
Acked-by: Ulf Hansson <>
Acked-by: Linus Walleij <>
Signed-off-by: Chris Ball <>
9 years agommc: sdhci-s3c: Remove old and misprototyped suspend operations
Mark Brown [Mon, 21 Nov 2011 18:00:51 +0000 (18:00 +0000)]
mmc: sdhci-s3c: Remove old and misprototyped suspend operations

Now that the driver is using dev_pm_ops the suspend operations in the
platform_driver structure won't get called so don't need to be there,
and certainly shouldn't be the same function as dev_pm_ops since the
signatures are different.

Signed-off-by: Mark Brown <>
Acked-by: Jaehoon Chung <>
Signed-off-by: Chris Ball <>
9 years agommc: tmio: fix clock gating on platforms with a .set_pwr() method
Guennadi Liakhovetski [Wed, 16 Nov 2011 09:11:45 +0000 (10:11 +0100)]
mmc: tmio: fix clock gating on platforms with a .set_pwr() method

Do not power down the card in .set_ios(), unless MMC_POWER_OFF is
requested. This fixes the SDHI functionality on ecovec.

Signed-off-by: Guennadi Liakhovetski <>
Signed-off-by: Chris Ball <>
9 years agommc: sh_mmcif: fix clock gating on platforms with a .down_pwr() method
Guennadi Liakhovetski [Wed, 16 Nov 2011 09:10:41 +0000 (10:10 +0100)]
mmc: sh_mmcif: fix clock gating on platforms with a .down_pwr() method

Do not power down the card in .set_ios(), unless MMC_POWER_OFF is
requested. This fixes the MMCIF interface functionality on ecovec boards.

Signed-off-by: Guennadi Liakhovetski <>
Signed-off-by: Chris Ball <>
9 years agommc: core: Fix typo at mmc_card_sleep
Kyungmin Park [Thu, 17 Nov 2011 04:34:33 +0000 (13:34 +0900)]
mmc: core: Fix typo at mmc_card_sleep

Fix wrong bus_ops->sleep check.  (This isn't expected to have real-world
consequences, because the mmc core always defines both 'awake' and
'sleep' ops.)

Signed-off-by: Kyungmin Park <>
Signed-off-by: Chris Ball <>
9 years agommc: core: Fix power_off_notify during suspend
Girish K S [Tue, 15 Nov 2011 06:25:46 +0000 (11:55 +0530)]
mmc: core: Fix power_off_notify during suspend

The eMMC 4.5 devices respond to only RESET and AWAKE command in the
sleep state. Hence the mmc switch command to notify power off state
should be sent before the device enters sleep state.

This patch fixes the same.

Signed-off-by: Girish K S <>
Signed-off-by: Chris Ball <>
9 years agommc: core: Fix setting power notify state variable for non-eMMC
Girish K S [Fri, 4 Nov 2011 10:52:47 +0000 (16:22 +0530)]
mmc: core: Fix setting power notify state variable for non-eMMC

This patch skips the setting of the power notify state variable
for non eMMC 4.5 devices. Also fixes the problem of omap_hsmmc
noisy/broken for suspend resume reported by Kevin Hilman.

Signed-off-by: Girish K S <>
Acked-by: Ulf Hansson <>
Signed-off-by: Chris Ball <>
9 years agommc: core: Add quirk for long data read time
Stefan Nilsson XK [Thu, 3 Nov 2011 08:44:12 +0000 (09:44 +0100)]
mmc: core: Add quirk for long data read time

Adds a quirk that sets the data read timeout to a fixed value instead
of relying on the information in the CSD. The timeout value chosen
is 300ms since that has proven enough for the problematic cards found,
but could be increased if other cards require this.

This patch also enables this quirk for certain Micron cards known to
have this problem.

Signed-off-by: Stefan Nilsson XK <>
Signed-off-by: Ulf Hansson <>
Acked-by: Linus Walleij <>
Cc: <>
Signed-off-by: Chris Ball <>
9 years agommc: Add module.h include to sdhci-cns3xxx.c
Chris Ball [Sat, 12 Nov 2011 00:54:53 +0000 (19:54 -0500)]
mmc: Add module.h include to sdhci-cns3xxx.c

Fixes: drivers/mmc/host/sdhci-cns3xxx.c:110: error: 'THIS_MODULE'
       undeclared here (not in a function)

Reported-by: Al Viro <>
Signed-off-by: Chris Ball <>
9 years agommc: mxcmmc: fix falling back to PIO
Sascha Hauer [Fri, 11 Nov 2011 15:28:05 +0000 (16:28 +0100)]
mmc: mxcmmc: fix falling back to PIO

When we can't configure the dma channel we want to fall
back to PIO. We do this by setting host->do_dma to zero.
This does not work as do_dma is used to see whether dma
can be used for the current transfer. Instead, we have
to set host->dma to NULL.

Signed-off-by: Sascha Hauer <>
Cc: <>
Signed-off-by: Chris Ball <>
9 years agox86, efi: Make efi_call_phys_{prelog,epilog} CONFIG_RELOCATABLE-aware
Matt Fleming [Thu, 8 Dec 2011 12:10:50 +0000 (12:10 +0000)]
x86, efi: Make efi_call_phys_{prelog,epilog} CONFIG_RELOCATABLE-aware

efi_call_phys_prelog() sets up a 1:1 mapping of the physical address
range in swapper_pg_dir. Instead of replacing then restoring entries
in swapper_pg_dir we should be using initial_page_table which already
contains the 1:1 mapping.

It's safe to blindly switch back to swapper_pg_dir in the epilog
because the physical EFI routines are only called before
efi_enter_virtual_mode(), e.g. before any user processes have been
forked. Therefore, we don't need to track which pgd was in %cr3 when
we entered the prelog.

The previous code actually contained a bug because it assumed that the
kernel was loaded at a physical address within the first 8MB of ram,
usually at 0x100000. However, this isn't the case with a
CONFIG_RELOCATABLE=y kernel which could have been loaded anywhere in
the physical address space.

Also delete the ancient (and bogus) comments about the page table
being restored after the lock is released. There is no locking.

Cc: Matthew Garrett <>
Cc: Darrent Hart <>
Signed-off-by: Matt Fleming <>
Signed-off-by: H. Peter Anvin <>
9 years agoLinux 3.2-rc5 v3.2-rc5
Linus Torvalds [Fri, 9 Dec 2011 23:09:32 +0000 (15:09 -0800)]
Linux 3.2-rc5

9 years agoMerge git://
Linus Torvalds [Fri, 9 Dec 2011 22:45:44 +0000 (14:45 -0800)]
Merge git://

* git://
  cifs: check for NULL last_entry before calling cifs_save_resume_key
  cifs: attempt to freeze while looping on a receive attempt
  cifs: Fix sparse warning when calling cifs_strtoUCS
  CIFS: Add descriptions to the brlock cache functions

9 years agoMerge branch 'x86-urgent-for-linus' of git://
Linus Torvalds [Fri, 9 Dec 2011 22:45:12 +0000 (14:45 -0800)]
Merge branch 'x86-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

* 'x86-urgent-for-linus' of git://
  x86, efi: Calling __pa() with an ioremap()ed address is invalid
  x86, hpet: Immediately disable HPET timer 1 if rtc irq is masked
  x86/intel_mid: Kconfig select fix
  x86/intel_mid: Fix the Kconfig for MID selection

9 years agoMerge branch 'spi/for-3.2' of git://
Linus Torvalds [Fri, 9 Dec 2011 22:41:50 +0000 (14:41 -0800)]
Merge branch 'spi/for-3.2' of git://

* 'spi/for-3.2' of git://
  spi/gpio: fix section mismatch warning
  spi/fsl-espi: disable CONFIG_SPI_FSL_ESPI=m build
  spi/nuc900: Include linux/module.h
  spi/ath79: fix compile error due to missing include

9 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Fri, 9 Dec 2011 16:18:08 +0000 (08:18 -0800)]
Merge branch 'for-linus' of git://

* 'for-linus' of git://
  md: raid5 crash during degradation
  md/raid5: never wait for bad-block acks on failed device.
  md: ensure new badblocks are handled promptly.
  md: bad blocks shouldn't cause a Blocked status on a Faulty device.
  md: take a reference to mddev during sysfs access.
  md: refine interpretation of "hold_active == UNTIL_IOCTL".
  md/lock: ensure updates to page_attrs are properly locked.

9 years agoMerge git://
Linus Torvalds [Fri, 9 Dec 2011 16:08:57 +0000 (08:08 -0800)]
Merge git://git./linux/kernel/git/cmetcalf/linux-tile

* git://
  arch/tile: use new generic {enable,disable}_percpu_irq() routines
  drivers/net/ethernet/tile: use skb_frag_page() API
  asm-generic/unistd.h: support new process_vm_{readv,write} syscalls
  arch/tile: fix double-free bug in homecache_free_pages()
  arch/tile: add a few #includes and an EXPORT to catch up with kernel changes.

9 years agoMerge branch 'iommu/fixes' of git://
Linus Torvalds [Fri, 9 Dec 2011 16:08:14 +0000 (08:08 -0800)]
Merge branch 'iommu/fixes' of git://git./linux/kernel/git/joro/iommu

* 'iommu/fixes' of git://
  MAINTAINERS: Update amd-iommu F: patterns
  iommu/amd: Fix typo in kernel-parameters.txt
  iommu/msm: Fix compile error in mach-msm/devices-iommu.c
  Fix comparison using wrong pointer variable in dma debug code

9 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Fri, 9 Dec 2011 16:07:42 +0000 (08:07 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/tiwai/sound

* 'for-linus' of git://
  ALSA: hda/realtek - Fix lost speaker volume controls
  ALSA: hda/realtek - Create "Bass Speaker" for two speaker pins
  ALSA: hda/realtek - Don't create extra controls with channel suffix
  ALSA: hda - Fix remaining VREF mute-LED NID check in post-3.1 changes
  ALSA: hda - Fix GPIO LED setup for IDT 92HD75 codecs
  ASoC: Provide a more complete DMA driver stub
  ASoC: Remove references to corgi and spitz from machine driver document
  ASoC: Make SND_SOC_MX27VIS_AIC32X4 depend on I2C
  ASoC: Fix dependency for SND_SOC_RAUMFELD and SND_PXA2XX_SOC_HX4700
  ASoC: uda1380: Return proper error in uda1380_modinit failure path
  ASoC: kirkwood: Make SND_KIRKWOOD_SOC_OPENRD and SND_KIRKWOOD_SOC_T5325 depend on I2C
  ASoC: Mark WM8994 ADC muxes as virtual
  ALSA: hda/realtek - Fix Oops in alc_mux_select()
  ALSA: sis7019 - give slow codecs more time to reset

9 years agoMerge branch 'perf-urgent-for-linus' of git://
Linus Torvalds [Fri, 9 Dec 2011 16:07:24 +0000 (08:07 -0800)]
Merge branch 'perf-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

* 'perf-urgent-for-linus' of git://
  perf: Do no try to schedule task events if there are none
  lockdep, kmemcheck: Annotate ->lock in lockdep_init_map()
  perf header: Use event_name() to get an event name
  perf stat: Failure with "Operation not supported"

9 years agosys_getppid: add missing rcu_dereference
Mandeep Singh Baines [Thu, 8 Dec 2011 22:34:44 +0000 (14:34 -0800)]
sys_getppid: add missing rcu_dereference

In order to safely dereference current->real_parent inside an
rcu_read_lock, we need an rcu_dereference.

Signed-off-by: Mandeep Singh Baines <>
Cc: Thomas Gleixner <>
Cc: Pavel Emelyanov <>
Cc: Oleg Nesterov <>
Cc: Kees Cook <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agorapidio/tsi721: modify PCIe capability settings
Alexandre Bounine [Thu, 8 Dec 2011 22:34:42 +0000 (14:34 -0800)]
rapidio/tsi721: modify PCIe capability settings

Modify initialization of PCIe capability registers in Tsi721 mport driver:
 - change Completion Timeout value to avoid unexpected data transfer
   aborts during intensive traffic.
 - replace hardcoded offset of PCIe capability block by making it use the
   common function.

This patch is applicable to kernel versions starting from 3.2-rc1.

Signed-off-by: Alexandre Bounine <>
Cc: Matt Porter <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agorapidio/tsi721: fix mailbox resource reporting
Alexandre Bounine [Thu, 8 Dec 2011 22:34:36 +0000 (14:34 -0800)]
rapidio/tsi721: fix mailbox resource reporting

Bug fix for Tsi721 RapidIO mport driver: Tsi721 supports four RapidIO
mailboxes (MBOX0 - MBOX3) as defined by RapidIO specification.  Mailbox
resources has to be properly reported to allow use of all available
mailboxes (initial version reports only MBOX0).

This patch is applicable to kernel versions staring from 3.2-rc1.

Signed-off-by: Alexandre Bounine <>
Cc: Matt Porter <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agorapidio/tsi721: switch to dma_zalloc_coherent
Alexandre Bounine [Thu, 8 Dec 2011 22:34:35 +0000 (14:34 -0800)]
rapidio/tsi721: switch to dma_zalloc_coherent

Replace the pair dma_alloc_coherent()+memset() with the new
dma_zalloc_coherent() added by Andrew Morton for kernel version 3.2

Signed-off-by: Alexandre Bounine <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agoprocfs: do not overflow get_{idle,iowait}_time for nohz
Michal Hocko [Thu, 8 Dec 2011 22:34:32 +0000 (14:34 -0800)]
procfs: do not overflow get_{idle,iowait}_time for nohz

Since commit a25cac5198d4 ("proc: Consider NO_HZ when printing idle and
iowait times") we are reporting idle/io_wait time also while a CPU is
tickless.  We rely on get_{idle,iowait}_time functions to retrieve
proper data.

These functions, however, use usecs_to_cputime to translate micro
seconds time to cputime64_t.  This is just an alias to usecs_to_jiffies
which reduces the data type from u64 to unsigned int and also checks
whether the given parameter overflows jiffies_to_usecs(MAX_JIFFY_OFFSET)
and returns MAX_JIFFY_OFFSET in that case.

When we overflow depends on CONFIG_HZ but especially for CONFIG_HZ_300
it is quite low (1431649781) so we are getting MAX_JIFFY_OFFSET for
>3000s! until we overflow unsigned int.  Just for reference
CONFIG_HZ_100 has an overflow window around 20s, CONFIG_HZ_250 ~8s and
CONFIG_HZ_1000 ~2s.

This results in a bug when people saw [h]top going mad reporting 100%
CPU usage even though there was basically no CPU load.  The reason was
simply that /proc/stat stopped reporting idle/io_wait changes (and
reported MAX_JIFFY_OFFSET) and so the only change happening was for user
system time.

Let's use nsecs_to_jiffies64 instead which doesn't reduce the precision
to 32b type and it is much more appropriate for cumulative time values
(unlike usecs_to_jiffies which intended for timeout calculations).

Signed-off-by: Michal Hocko <>
Tested-by: Artem S. Tashkinov <>
Cc: Dave Jones <>
Cc: Arnd Bergmann <>
Cc: Alexey Dobriyan <>
Cc: Thomas Gleixner <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agomm: vmalloc: check for page allocation failure before vmlist insertion
Mel Gorman [Thu, 8 Dec 2011 22:34:30 +0000 (14:34 -0800)]
mm: vmalloc: check for page allocation failure before vmlist insertion

Commit f5252e00 ("mm: avoid null pointer access in vm_struct via
/proc/vmallocinfo") adds newly allocated vm_structs to the vmlist after
it is fully initialised.  Unfortunately, it did not check that
__vmalloc_area_node() successfully populated the area.  In the event of
allocation failure, the vmalloc area is freed but the pointer to freed
memory is inserted into the vmlist leading to a a crash later in

This patch adds a check for ____vmalloc_area_node() failure within
__vmalloc_node_range.  It does not use "goto fail" as in the previous
error path as a warning was already displayed by __vmalloc_area_node()
before it called vfree in its failure path.

Credit goes to Luciano Chavez for doing all the real work of identifying
exactly where the problem was.

Signed-off-by: Mel Gorman <>
Reported-by: Luciano Chavez <>
Tested-by: Luciano Chavez <>
Reviewed-by: Rik van Riel <>
Acked-by: David Rientjes <>
Cc: <> [3.1.x+]
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agomm: Ensure that pfn_valid() is called once per pageblock when reserving pageblocks
Michal Hocko [Thu, 8 Dec 2011 22:34:27 +0000 (14:34 -0800)]
mm: Ensure that pfn_valid() is called once per pageblock when reserving pageblocks

setup_zone_migrate_reserve() expects that zone->start_pfn starts at
pageblock_nr_pages aligned pfn otherwise we could access beyond an
existing memblock resulting in the following panic if
CONFIG_HOLES_IN_ZONE is not configured and we do not check pfn_valid:

  IP: [<c02d331d>] setup_zone_migrate_reserve+0xcd/0x180
  *pdpt = 0000000000000000 *pde = f000ff53f000ff53
  Oops: 0000 [#1] SMP
  Pid: 1, comm: swapper Not tainted 3.0.7-0.7-pae #1 VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform
  EIP: 0060:[<c02d331d>] EFLAGS: 00010006 CPU: 0
  EIP is at setup_zone_migrate_reserve+0xcd/0x180
  EAX: 000c0000 EBX: f5801fc0 ECX: 000c0000 EDX: 00000000
  ESI: 000c01fe EDI: 000c01fe EBP: 00140000 ESP: f2475f58
  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
  Process swapper (pid: 1, ti=f2474000 task=f2472cd0 task.ti=f2474000)
  Call Trace:
  [<c02d389c>] __setup_per_zone_wmarks+0xec/0x160
  [<c02d3a1f>] setup_per_zone_wmarks+0xf/0x20
  [<c08a771c>] init_per_zone_wmark_min+0x27/0x86
  [<c020111b>] do_one_initcall+0x2b/0x160
  [<c086639d>] kernel_init+0xbe/0x157
  [<c05cae26>] kernel_thread_helper+0x6/0xd
  Code: a5 39 f5 89 f7 0f 46 fd 39 cf 76 40 8b 03 f6 c4 08 74 32 eb 91 90 89 c8 c1 e8 0e 0f be 80 80 2f 86 c0 8b 14 85 60 2f 86 c0 89 c8 <2b> 82 b4 12 00 00 c1 e0 05 03 82 ac 12 00 00 8b 00 f6 c4 08 0f
  EIP: [<c02d331d>] setup_zone_migrate_reserve+0xcd/0x180 SS:ESP 0068:f2475f58
  CR2: 00000000000012b4

We crashed in pageblock_is_reserved() when accessing pfn 0xc0000 because
highstart_pfn = 0x36ffe.

The issue was introduced in 3.0-rc1 by 6d3163ce ("mm: check if any page
in a pageblock is reserved before marking it MIGRATE_RESERVE").

Make sure that start_pfn is always aligned to pageblock_nr_pages to
ensure that pfn_valid s always called at the start of each pageblock.
Architectures with holes in pageblocks will be correctly handled by
pfn_valid_within in pageblock_is_reserved.

Signed-off-by: Michal Hocko <>
Signed-off-by: Mel Gorman <>
Tested-by: Dang Bo <>
Reviewed-by: KAMEZAWA Hiroyuki <>
Cc: Andrea Arcangeli <>
Cc: David Rientjes <>
Cc: Arve Hjnnevg <>
Cc: KOSAKI Motohiro <>
Cc: John Stultz <>
Cc: Dave Hansen <>
Cc: <> [3.0+]
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agomm/migrate.c: pair unlock_page() and lock_page() when migrating huge pages
Hillf Danton [Thu, 8 Dec 2011 22:34:20 +0000 (14:34 -0800)]
mm/migrate.c: pair unlock_page() and lock_page() when migrating huge pages

Avoid unlocking and unlocked page if we failed to lock it.

Signed-off-by: Hillf Danton <>
Cc: Naoya Horiguchi <>
Cc: Andrea Arcangeli <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agothp: set compound tail page _count to zero
Youquan Song [Thu, 8 Dec 2011 22:34:18 +0000 (14:34 -0800)]
thp: set compound tail page _count to zero

Commit 70b50f94f1644 ("mm: thp: tail page refcounting fix") keeps all
page_tail->_count zero at all times.  But the current kernel does not
set page_tail->_count to zero if a 1GB page is utilized.  So when an
IOMMU 1GB page is used by KVM, it wil result in a kernel oops because a
tail page's _count does not equal zero.

  kernel BUG at include/linux/mm.h:386!
  invalid opcode: 0000 [#1] SMP
  Call Trace:
    ? trace_hardirqs_off+0xd/0xf
  RIP  gup_huge_pud+0xf2/0x159

Signed-off-by: Youquan Song <>
Reviewed-by: Andrea Arcangeli <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agothp: add compound tail page _mapcount when mapped
Youquan Song [Thu, 8 Dec 2011 22:34:16 +0000 (14:34 -0800)]
thp: add compound tail page _mapcount when mapped

With the 3.2-rc kernel, IOMMU 2M pages in KVM works.  But when I tried
to use IOMMU 1GB pages in KVM, I encountered an oops and the 1GB page
failed to be used.

The root cause is that 1GB page allocation calls gup_huge_pud() while 2M
page calls gup_huge_pmd.  If compound pages are used and the page is a
tail page, gup_huge_pmd() increases _mapcount to record tail page are
mapped while gup_huge_pud does not do that.

So when the mapped page is relesed, it will result in kernel oops
because the page is not marked mapped.

This patch add tail process for compound page in 1GB huge page which
keeps the same process as 2M page.

Reproduce like:
1. Add grub boot option: hugepagesz=1G hugepages=8
2. mount -t hugetlbfs -o pagesize=1G hugetlbfs /dev/hugepages
3. qemu-kvm -m 2048 -hda os-kvm.img -cpu kvm64 -smp 4 -mem-path /dev/hugepages
-net none -device pci-assign,host=07:00.1

  kernel BUG at mm/swap.c:114!
  invalid opcode: 0000 [#1] SMP
  Call Trace:
  RIP  put_compound_page+0xd4/0x168

Signed-off-by: Youquan Song <>
Reviewed-by: Andrea Arcangeli <>
Cc: Andi Kleen <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agoprintk: avoid double lock acquire
Peter Zijlstra [Thu, 8 Dec 2011 22:34:13 +0000 (14:34 -0800)]
printk: avoid double lock acquire

Commit 4f2a8d3cf5e ("printk: Fix console_sem vs logbuf_lock unlock race")
introduced another silly bug where we would want to acquire an already
held lock.  Avoid this.

Reported-by: Andrea Arcangeli <>
Signed-off-by: Peter Zijlstra <>
Cc: Ingo Molnar <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agomemcg: update maintainers
KAMEZAWA Hiroyuki [Thu, 8 Dec 2011 22:34:10 +0000 (14:34 -0800)]
memcg: update maintainers

More players joined to memory cgroup developments and Johannes' great work
changed internal design of memory cgroup dramatically.  And he will do
more works.  Michal Hokko did many bug fixes and know memory cgroup very
well.  Daisuke Nishimura helped us very much but he seems busy now.
Thanks to his works.

Signed-off-by: KAMEZAWA Hiroyuki <>
Acked-by: Michal Hocko <>
Acked-by: Johannes Weiner <>
Acked-by: Daisuke Nishimura <>
Cc: Balbir Singh <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agodrivers/rtc/rtc-s3c.c: fix driver clock enable/disable balance issues
Jonghwan Choi [Thu, 8 Dec 2011 22:34:02 +0000 (14:34 -0800)]
drivers/rtc/rtc-s3c.c: fix driver clock enable/disable balance issues

If an error occurs after the clock is enabled, the enable/disable state
can become unbalanced.

Signed-off-by: Jonghwan Choi <>
Cc: Alessandro Zummo <>
Acked-by: Kukjin Kim <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agoCREDITS: update Kees's expired fingerprint and fix details
Kees Cook [Thu, 8 Dec 2011 22:34:00 +0000 (14:34 -0800)]
CREDITS: update Kees's expired fingerprint and fix details

Small clean-up for my CREDITS entry; the GPG fingerprint was not up to
date, so I fixed other details at the same time too.

Signed-off-by: Kees Cook <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agothp: reduce khugepaged freezing latency
Andrea Arcangeli [Thu, 8 Dec 2011 22:33:57 +0000 (14:33 -0800)]
thp: reduce khugepaged freezing latency

khugepaged can sometimes cause suspend to fail, requiring that the user
retry the suspend operation.

Use wait_event_freezable_timeout() instead of
schedule_timeout_interruptible() to avoid missing freezer wakeups.  A
try_to_freeze() would have been needed in the khugepaged_alloc_hugepage
tight loop too in case of the allocation failing repeatedly, and
wait_event_freezable_timeout will provide it too.

khugepaged would still freeze just fine by trying again the next minute
but it's better if it freezes immediately.

Reported-by: Jiri Slaby <>
Signed-off-by: Andrea Arcangeli <>
Tested-by: Jiri Slaby <>
Cc: Tejun Heo <>
Cc: Oleg Nesterov <>
Cc: "Srivatsa S. Bhat" <>
Cc: "Rafael J. Wysocki" <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agofs/proc/meminfo.c: fix compilation error
Claudio Scordino [Thu, 8 Dec 2011 22:33:56 +0000 (14:33 -0800)]
fs/proc/meminfo.c: fix compilation error

Fix the error message "directives may not be used inside a macro argument"
which appears when the kernel is compiled for the cris architecture.

Signed-off-by: Claudio Scordino <>
Cc: Andrea Arcangeli <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agovmscan: use atomic-long for shrinker batching
Konstantin Khlebnikov [Thu, 8 Dec 2011 22:33:54 +0000 (14:33 -0800)]
vmscan: use atomic-long for shrinker batching

Use atomic-long operations instead of looping around cmpxchg().

[ massage atomic.h inclusions]
Signed-off-by: Konstantin Khlebnikov <>
Cc: Dave Chinner <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agovmscan: fix initial shrinker size handling
Konstantin Khlebnikov [Thu, 8 Dec 2011 22:33:51 +0000 (14:33 -0800)]
vmscan: fix initial shrinker size handling

A shrinker function can return -1, means that it cannot do anything
without a risk of deadlock.  For example prune_super() does this if it
cannot grab a superblock refrence, even if nr_to_scan=0.  Currently we
interpret this -1 as a ULONG_MAX size shrinker and evaluate `total_scan'
according to this.  So the next time around this shrinker can cause
really big pressure.  Let's skip such shrinkers instead.

Also make total_scan signed, otherwise the check (total_scan < 0) below
never works.

Signed-off-by: Konstantin Khlebnikov <>
Cc: Dave Chinner <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
9 years agoMAINTAINERS: Update amd-iommu F: patterns
Joe Perches [Fri, 9 Dec 2011 04:21:40 +0000 (20:21 -0800)]
MAINTAINERS: Update amd-iommu F: patterns

Commit 29b68415e335 ("x86: amd_iommu: move to drivers/iommu/")
moved the files, update the patterns.

CC: Ohad Ben-Cohen <>
CC: Joerg Roedel <>
Signed-off-by: Joe Perches <>
Signed-off-by: Joerg Roedel <>
9 years agox86, efi: Calling __pa() with an ioremap()ed address is invalid
Matt Fleming [Fri, 18 Nov 2011 13:09:11 +0000 (13:09 +0000)]
x86, efi: Calling __pa() with an ioremap()ed address is invalid

If we encounter an efi_memory_desc_t without EFI_MEMORY_WB set
in ->attribute we currently call set_memory_uc(), which in turn
calls __pa() on a potentially ioremap'd address.

On CONFIG_X86_32 this is invalid, resulting in the following
oops on some machines:

  BUG: unable to handle kernel paging request at f7f22280
  IP: [<c10257b9>] reserve_ram_pages_type+0x89/0x210

  Call Trace:
   [<c104f8ca>] ? page_is_ram+0x1a/0x40
   [<c1025aff>] reserve_memtype+0xdf/0x2f0
   [<c1024dc9>] set_memory_uc+0x49/0xa0
   [<c19334d0>] efi_enter_virtual_mode+0x1c2/0x3aa
   [<c19216d4>] start_kernel+0x291/0x2f2
   [<c19211c7>] ? loglevel+0x1b/0x1b
   [<c19210bf>] i386_start_kernel+0xbf/0xc8

A better approach to this problem is to map the memory region
with the correct attributes from the start, instead of modifying
it after the fact. The uncached case can be handled by
ioremap_nocache() and the cached by ioremap_cache().

Despite first impressions, it's not possible to use
ioremap_cache() to map all cached memory regions on
CONFIG_X86_64 because EFI_RUNTIME_SERVICES_DATA regions really
don't like being mapped into the vmalloc space, as detailed in
the following bug report,

Therefore, we need to ensure that any EFI_RUNTIME_SERVICES_DATA
regions are covered by the direct kernel mapping table on
CONFIG_X86_64. To accomplish this we now map E820_RESERVED_EFI
regions via the direct kernel mapping with the initial call to
init_memory_mapping() in setup_arch(), whereas previously these
regions wouldn't be mapped if they were after the last E820_RAM
region until efi_ioremap() was called. Doing it this way allows
us to delete efi_ioremap() completely.

Signed-off-by: Matt Fleming <>
Cc: H. Peter Anvin <>
Cc: Matthew Garrett <>
Cc: Zhang Rui <>
Cc: Huang Ying <>
Cc: Linus Torvalds <>
Cc: Andrew Morton <>
Signed-off-by: Ingo Molnar <>
9 years ago... and the same kind of leak for mqueue
Al Viro [Fri, 9 Dec 2011 05:38:50 +0000 (00:38 -0500)]
... and the same kind of leak for mqueue

Signed-off-by: Al Viro <>
9 years agoprocfs: fix a vfsmount longterm reference leak
Al Viro [Fri, 9 Dec 2011 04:20:45 +0000 (23:20 -0500)]
procfs: fix a vfsmount longterm reference leak

kern_mount() doesn't pair with plain mntput()...

Signed-off-by: Al Viro <>
9 years agocifs: check for NULL last_entry before calling cifs_save_resume_key
Jeff Layton [Fri, 2 Dec 2011 01:23:34 +0000 (20:23 -0500)]
cifs: check for NULL last_entry before calling cifs_save_resume_key

Prior to commit eaf35b1, cifs_save_resume_key had some NULL pointer
checks at the top. It turns out that at least one of those NULL
pointer checks is needed after all.

When the LastNameOffset in a FIND reply appears to be beyond the end of
the buffer, CIFSFindFirst and CIFSFindNext will set srch_inf.last_entry
to NULL. Since eaf35b1, the code will now oops in this situation.

Fix this by having the callers check for a NULL last entry pointer
before calling cifs_save_resume_key. No change is needed for the
call site in cifs_readdir as it's not reachable with a NULL
current_entry pointer.

This should fix:

Cc: Christoph Hellwig <>
Reported-by: Adam G. Metzler <>
Signed-off-by: Jeff Layton <>
Signed-off-by: Steve French <>
9 years agocifs: attempt to freeze while looping on a receive attempt
Jeff Layton [Fri, 2 Dec 2011 01:22:41 +0000 (20:22 -0500)]
cifs: attempt to freeze while looping on a receive attempt

In the recent overhaul of the demultiplex thread receive path, I
neglected to ensure that we attempt to freeze on each pass through the
receive loop.

Reported-and-Tested-by: Woody Suwalski <>
Reported-and-Tested-by: Adam Williamson <>
Signed-off-by: Jeff Layton <>
Signed-off-by: Steve French <>
9 years agocifs: Fix sparse warning when calling cifs_strtoUCS
Steve French [Thu, 10 Nov 2011 18:48:20 +0000 (12:48 -0600)]
cifs: Fix sparse warning when calling cifs_strtoUCS

Fix sparse endian check warning while calling cifs_strtoUCS

CHECK   fs/cifs/smbencrypt.c
fs/cifs/smbencrypt.c:216:37: warning: incorrect type in argument 1
(different base types)
fs/cifs/smbencrypt.c:216:37:    expected restricted __le16 [usertype] *<noident>
fs/cifs/smbencrypt.c:216:37:    got unsigned short *<noident>

Signed-off-by: Steve French <>
Acked-by: Shirish Pargaonkar <
9 years agoCIFS: Add descriptions to the brlock cache functions
Pavel Shilovsky [Mon, 7 Nov 2011 13:11:24 +0000 (16:11 +0300)]
CIFS: Add descriptions to the brlock cache functions

Signed-off-by: Pavel Shilovsky <>
Signed-off-by: Steve French <>
9 years agomd: raid5 crash during degradation
Adam Kwolek [Fri, 9 Dec 2011 03:26:11 +0000 (14:26 +1100)]
md: raid5 crash during degradation

NULL pointer access causes crash in raid5 module.

Signed-off-by: Adam Kwolek <>
Signed-off-by: NeilBrown <>
9 years agoMerge branch 'timers-urgent-for-linus' of git://
Linus Torvalds [Thu, 8 Dec 2011 21:21:28 +0000 (13:21 -0800)]
Merge branch 'timers-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

* 'timers-urgent-for-linus' of git://
  alarmtimers: Fix time comparison
  ptp: Fix clock_getres() implementation

9 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Thu, 8 Dec 2011 21:18:59 +0000 (13:18 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/mason/linux-btrfs

* 'for-linus' of git://
  Btrfs: drop spin lock when memory alloc fails
  Btrfs: check if the to-be-added device is writable
  Btrfs: try cluster but don't advance in search list
  Btrfs: try to allocate from cluster even at LOOP_NO_EMPTY_SIZE

9 years agoMerge branch 'fixes' of git://
Linus Torvalds [Thu, 8 Dec 2011 21:18:38 +0000 (13:18 -0800)]
Merge branch 'fixes' of git://git./linux/kernel/git/arm/arm-soc

* 'fixes' of git:// (28 commits)
  ARM: sa1100: fix build error
  ARM: OMAP1: recalculate loops per jiffy after dpll1 reprogram
  ARM: davinci: dm365 evm: align nand partition table to u-boot
  ARM: davinci: da850 evm: change audio edma event queue to EVENTQ_0
  ARM: davinci: dm646x evm: wrong register used in setup_vpif_input_channel_mode
  ARM: davinci: dm646x does not have a DSP domain
  ARM: davinci: psc: fix incorrect offsets
  ARM: davinci: psc: fix incorrect mask
  ARM: mx28: LRADC macro rename
  arm: mx23: recognise stmp378x as mx23
  ARM: mxs: fix machines' initializers order
  ARM: mxs/tx28: add __initconst for fec pdata
  ARM: S3C64XX: Staticise s3c6400_sysclass
  ARM: S3C64XX: Add linux/export.h to dev-spi.c
  ARM: S3C64XX: Remove extern from definition of framebuffer setup call
  MAINTAINERS: Extend Samsung patterns to cover SPI and ASoC drivers
  MAINTAINERS: Add linux-samsung-soc mailing list for Samsung
  ARM: CSR: PM: fix build error due to undeclared 'THIS_MODULE'
  ARM: CSR: fix build error due to new mdesc->dma_zone_size

9 years agoTOMOYO: Fix pathname handling of disconnected paths.
Tetsuo Handa [Thu, 8 Dec 2011 12:24:06 +0000 (21:24 +0900)]
TOMOYO: Fix pathname handling of disconnected paths.

Current tomoyo_realpath_from_path() implementation returns strange pathname
when calculating pathname of a file which belongs to lazy unmounted tree.
Use local pathname rather than strange absolute pathname in that case.

Also, this patch fixes a regression by commit 02125a82 "fix apparmor
dereferencing potentially freed dentry, sanitize __d_path() API".

Signed-off-by: Tetsuo Handa <>
Acked-by: Al Viro <>
Signed-off-by: Linus Torvalds <>
9 years agox86, hpet: Immediately disable HPET timer 1 if rtc irq is masked
Mark Langsdorf [Fri, 18 Nov 2011 15:33:06 +0000 (16:33 +0100)]
x86, hpet: Immediately disable HPET timer 1 if rtc irq is masked

When HPET is operating in RTC mode, the TN_ENABLE bit on timer1
controls whether the HPET or the RTC delivers interrupts to irq8. When
the system goes into suspend, the RTC driver sends a signal to the
HPET driver so that the HPET releases control of irq8, allowing the
RTC to wake the system from suspend. The switchover is accomplished by
a write to the HPET configuration registers which currently only
occurs while servicing the HPET interrupt.

On some systems, I have seen the system suspend before an HPET
interrupt occurs, preventing the write to the HPET configuration
register and leaving the HPET in control of the irq8. As the HPET is
not active during suspend, it does not generate a wake signal and RTC
alarms do not work.

This patch forces the HPET driver to immediately transfer control of
the irq8 channel to the RTC instead of waiting until the next
interrupt event.

Signed-off-by: Mark Langsdorf <>
Tested-by: Andreas Herrmann <>
Signed-off-by: Andreas Herrmann <>
Signed-off-by: Thomas Gleixner <>
9 years agoMerge branch 'fixes' of git:// into fixes
Arnd Bergmann [Thu, 8 Dec 2011 15:52:23 +0000 (15:52 +0000)]
Merge branch 'fixes' of git:// into fixes

9 years agoBtrfs: drop spin lock when memory alloc fails
Liu Bo [Thu, 8 Dec 2011 01:08:40 +0000 (20:08 -0500)]
Btrfs: drop spin lock when memory alloc fails

Drop spin lock in convert_extent_bit() when memory alloc fails,
otherwise, it will be a deadlock.

Signed-off-by: Liu Bo <>
Signed-off-by: Chris Mason <>
9 years agoBtrfs: check if the to-be-added device is writable
Li Zefan [Thu, 8 Dec 2011 01:08:40 +0000 (20:08 -0500)]
Btrfs: check if the to-be-added device is writable

If we call ioctl(BTRFS_IOC_ADD_DEV) directly, we'll succeed in adding
a readonly device to a btrfs filesystem, and btrfs will write to
that device, emitting kernel errors:

[ 3109.833692] lost page write due to I/O error on loop2
[ 3109.833720] lost page write due to I/O error on loop2

Signed-off-by: Li Zefan <>
Signed-off-by: Chris Mason <>
9 years agoBtrfs: try cluster but don't advance in search list
Alexandre Oliva [Thu, 8 Dec 2011 01:08:40 +0000 (20:08 -0500)]
Btrfs: try cluster but don't advance in search list

When we find an existing cluster, we switch to its block group as the
current block group, possibly skipping multiple blocks in the process.
Furthermore, under heavy contention, multiple threads may fail to
allocate from a cluster and then release just-created clusters just to
proceed to create new ones in a different block group.

This patch tries to allocate from an existing cluster regardless of its
block group, and doesn't switch to that group, instead proceeding to
try to allocate a cluster from the group it was iterating before the

Signed-off-by: Alexandre Oliva <>
Signed-off-by: Chris Mason <>
10 years agoARM: sa1100: fix build error
Jett.Zhou [Wed, 30 Nov 2011 06:32:54 +0000 (14:32 +0800)]
ARM: sa1100: fix build error

arm-eabi-4.4.3-ld:--defsym zreladdr=: syntax error
make[2]: *** [arch/arm/boot/compressed/vmlinux] Error 1
make[1]: *** [arch/arm/boot/compressed/vmlinux] Error 2
make: *** [uImage] Error 2

Signed-off-by: Haojian Zhuang <>
Signed-off-by: Jett.Zhou <>
10 years agomd/raid5: never wait for bad-block acks on failed device.
NeilBrown [Thu, 8 Dec 2011 05:27:57 +0000 (16:27 +1100)]
md/raid5: never wait for bad-block acks on failed device.

Once a device is failed we really want to completely ignore it.
It should go away soon anyway.

In particular the presence of bad blocks on it should not cause us to
block as we won't be trying to write there anyway.

So as soon as we can check if a device is Faulty, do so and pretend
that it is already gone if it is Faulty.

Signed-off-by: NeilBrown <>
10 years agomd: ensure new badblocks are handled promptly.
NeilBrown [Thu, 8 Dec 2011 05:26:08 +0000 (16:26 +1100)]
md: ensure new badblocks are handled promptly.

When we mark blocks as bad we need them to be acknowledged by the
metadata handler promptly.

For an in-kernel metadata handler that was already being done.  But
for an external metadata handler we need to alert it of the change by
sending a notification through the sysfs file.  This adds that

Signed-off-by: NeilBrown <>
10 years agomd: bad blocks shouldn't cause a Blocked status on a Faulty device.
NeilBrown [Thu, 8 Dec 2011 05:22:48 +0000 (16:22 +1100)]
md: bad blocks shouldn't cause a Blocked status on a Faulty device.

Once a device is marked Faulty the badblocks - whether acknowledged or
not - become irrelevant.  So they shouldn't cause the device to be
marked as Blocked.

Without this patch, a process might write "-blocked" to clear the
Blocked status, but while that will correctly fail the device, it
won't remove the apparent 'blocked' status.

Signed-off-by: NeilBrown <>
10 years agomd: take a reference to mddev during sysfs access.
NeilBrown [Thu, 8 Dec 2011 04:49:46 +0000 (15:49 +1100)]
md: take a reference to mddev during sysfs access.

When we are accessing an mddev via sysfs we know that the
mddev cannot disappear because it has an embedded kobj which
is refcounted by sysfs.
And we also take the mddev_lock.
However this is not enough.

The final mddev_put could have been called and the
mddev_delayed_delete is waiting for sysfs to let go so it can destroy
the kobj and mddev.
In this state there are a lot of changes that should not be attempted.

To to guard against this we:
 - initialise mddev->all_mddevs in on last put so the state can be
   easily detected.
 - in md_attr_show and md_attr_store, check ->all_mddevs under
   all_mddevs_lock and mddev_get the mddev if it still appears to
   be active.

This means that if we get to sysfs as the mddev is being deleted we
will get -EBUSY.

rdev_attr_store and rdev_attr_show are similar but already have
sufficient protection.  They check that rdev->mddev still points to
mddev after taking mddev_lock.  As this is cleared  before delayed
removal which can only be requested under the mddev_lock, this
ensure the rdev and mddev are still alive.

Signed-off-by: NeilBrown <>
10 years agomd: refine interpretation of "hold_active == UNTIL_IOCTL".
NeilBrown [Thu, 8 Dec 2011 04:49:12 +0000 (15:49 +1100)]
md: refine interpretation of "hold_active == UNTIL_IOCTL".

We like md devices to disappear when they really are not needed.
However it is not possible to tell from the current state whether it
is needed or not.  We can only tell from recent history of changes.

In particular immediately after we create an md device it looks very
similar to immediately after we have finished with it.

So we always preserve a newly created md device until something
significant happens.  This state is stored in 'hold_active'.

The normal case is to keep it until an ioctl happens, as that will
normally either activate it, or explicitly de-activate it.  If it
doesn't then it was probably created by mistake and it is now time to
get rid of it.

We can also modify an array via sysfs (instead of via ioctl) and we
currently treat any change via sysfs like an ioctl as a sign that if
it now isn't more active, it should be destroyed.
However this is not appropriate as changes made via sysfs are more
gradual so we should look for a more definitive change.

So this patch only clears 'hold_active' from UNTIL_IOCTL to clear when
the array_state is changed via sysfs.  Other changes via sysfs
are ignored.

Signed-off-by: NeilBrown <>
10 years agoMerge branch 'fixes' of git://
Olof Johansson [Thu, 8 Dec 2011 04:36:27 +0000 (20:36 -0800)]
Merge branch 'fixes' of git://git./linux/kernel/git/tmlind/linux-omap into fixes

10 years agommc: omap_hsmmc: DMA unmap only once in case of MMC error
Per Forlin [Mon, 7 Nov 2011 16:25:11 +0000 (21:55 +0530)]
mmc: omap_hsmmc: DMA unmap only once in case of MMC error

Reported by Russell King:
mmcblk0: error -84 transferring data, sector 149201, nr 64,
cmd response 0x900, card status 0xb00
mmcblk0: retrying using single block read

WARNING: at lib/dma-debug.c:811 check_unmap
omap_hsmmc omap_hsmmc.0: DMA-API: device driver tries to free DMA memory
it has not allocated [device address=0x0000000080933000] [size=20480 bytes]

In case of an error dma_unmap() is issued in omap_hsmmc_dma_cleanup()
and then again in omap_hsmmc_post_req(). Resolve this by clearing the
host_cookie to indicate there is no DMA mapped memory to unmap.

Signed-off-by: Per Forlin <>
Tested-by: Balaji T K <>
Tested-by: Russell King <>
Signed-off-by: Chris Ball <>
10 years agowriteback: set max_pause to lowest value on zero bdi_dirty
Wu Fengguang [Sat, 3 Dec 2011 00:21:51 +0000 (18:21 -0600)]
writeback: set max_pause to lowest value on zero bdi_dirty

Some trace shows lots of bdi_dirty=0 lines where it's actually some
small value if w/o the accounting errors in the per-cpu bdi stats.

In this case the max pause time should really be set to the smallest
(non-zero) value to avoid IO queue underrun and improve throughput.

Signed-off-by: Wu Fengguang <>
10 years agowriteback: permit through good bdi even when global dirty exceeded
Wu Fengguang [Fri, 2 Dec 2011 16:21:33 +0000 (10:21 -0600)]
writeback: permit through good bdi even when global dirty exceeded

On a system with 1 local mount and 1 NFS mount, if the NFS server
becomes not responding when dd to the NFS mount, the NFS dirty pages may
exceed the global dirty limit and _every_ task involving writing will be
blocked. The whole system appears unresponsive.

The workaround is to permit through the bdi's that only has a small
number of dirty pages. The number chosen (bdi_stat_error pages) is not
enough to enable the local disk to run in optimal throughput, however is
enough to make the system responsive on a broken NFS mount. The user can
then kill the dirtiers on the NFS mount and increase the global dirty
limit to bring up the local disk's throughput.

It risks allowing dirty pages to grow much larger than the global dirty
limit when there are 1000+ mounts, however that's very unlikely to happen,
especially in low memory profiles.

Signed-off-by: Wu Fengguang <>
10 years agowriteback: comment on the bdi dirty threshold
Wu Fengguang [Wed, 23 Nov 2011 17:44:41 +0000 (11:44 -0600)]
writeback: comment on the bdi dirty threshold

We do "floating proportions" to let active devices to grow its target
share of dirty pages and stalled/inactive devices to decrease its target
share over time.

It works well except in the case of "an inactive disk suddenly goes
busy", where the initial target share may be too small. To mitigate
this, bdi_position_ratio() has the below line to raise a small
bdi_thresh when it's safe to do so, so that the disk be feed with enough
dirty pages for efficient IO and in turn fast rampup of bdi_thresh:

        bdi_thresh = max(bdi_thresh, (limit - dirty) / 8);

balance_dirty_pages() normally does negative feedback control which
adjusts ratelimit to balance the bdi dirty pages around the target.
In some extreme cases when that is not enough, it will have to block
the tasks completely until the bdi dirty pages drop below bdi_thresh.

Acked-by: Jan Kara <>
Acked-by: Peter Zijlstra <>
Signed-off-by: Wu Fengguang <>
10 years agoMerge branch '3.2-rc-fixes' of git://
Linus Torvalds [Thu, 8 Dec 2011 02:18:27 +0000 (18:18 -0800)]
Merge branch '3.2-rc-fixes' of git://git./linux/kernel/git/nab/target-pending

* '3.2-rc-fixes' of git:// (25 commits)
  iscsi-target: Fix hex2bin warn_unused compile message
  target: Don't return an error if disabling unsupported features
  target/rd: fix or rewrite the copy routine
  target/rd: simplify the page/offset computation
  target: remove the unused se_dev_list
  target/file: walk properly over sg list
  target: remove unused struct fields
  target: Fix page length in emulated INQUIRY VPD page 86h
  target: Handle 0 correctly in transport_get_sectors_6()
  target: Don't return an error status for 0-length READ and WRITE
  iscsi-target: Use kmemdup rather than duplicating its implementation
  iscsi-target: Add missing F_BIT for iscsi_tm_rsp
  iscsi-target: Fix residual count hanlding + remove iscsi_cmd->residual_count
  target: Reject SCSI data overflow for fabrics using transport_generic_map_mem_to_cmd
  target: remove the unused t_task_pt_sgl and t_task_pt_sgl_num se_cmd fields
  target: remove the t_tasks_bidi se_cmd field
  target: remove the t_tasks_fua se_cmd field
  target: remove the se_ordered_node se_cmd field
  target: remove the se_obj_ptr and se_orig_obj_ptr se_cmd fields
  target: Drop config_item_name usage in fabric TFO->free_wwn()

10 years agoBtrfs: try to allocate from cluster even at LOOP_NO_EMPTY_SIZE
Alexandre Oliva [Thu, 8 Dec 2011 00:50:42 +0000 (19:50 -0500)]
Btrfs: try to allocate from cluster even at LOOP_NO_EMPTY_SIZE

If we reach LOOP_NO_EMPTY_SIZE, we won't even try to use a cluster that
others might have set up.  Odds are that there won't be one, but if
someone else succeeded in setting it up, we might as well use it, even
if we don't try to set up a cluster again.

Signed-off-by: Alexandre Oliva <>
Signed-off-by: Chris Mason <>
10 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Thu, 8 Dec 2011 00:13:54 +0000 (16:13 -0800)]
Merge branch 'for-linus' of git://

* 'for-linus' of git://
  xfs: fix the logspace waiting algorithm
  xfs: fix nfs export of 64-bit inodes numbers on 32-bit kernels
  xfs: fix allocation length overflow in xfs_bmapi_write()

10 years agoMerge branch 'pm-fixes' of git://
Linus Torvalds [Thu, 8 Dec 2011 00:12:29 +0000 (16:12 -0800)]
Merge branch 'pm-fixes' of git://git./linux/kernel/git/rafael/linux-pm

* 'pm-fixes' of git://
  PM / Driver core: leave runtime PM enabled during system shutdown

10 years agoMerge branch 'for-linus' of git://
Linus Torvalds [Thu, 8 Dec 2011 00:12:14 +0000 (16:12 -0800)]
Merge branch 'for-linus' of git://git./linux/kernel/git/geert/linux-m68k

* 'for-linus' of git://
  m68k: Wire up process_vm_{read,write}v

10 years agoMerge branch 'perf/urgent' of git:// into perf/urgent
Ingo Molnar [Wed, 7 Dec 2011 22:23:44 +0000 (23:23 +0100)]
Merge branch 'perf/urgent' of git:// into perf/urgent

10 years agoPM / Driver core: leave runtime PM enabled during system shutdown
Alan Stern [Tue, 6 Dec 2011 22:24:52 +0000 (23:24 +0100)]
PM / Driver core: leave runtime PM enabled during system shutdown

Disabling all runtime PM during system shutdown turns out not to be a
good idea, because some devices may need to be woken up from a
low-power state at that time.

The whole point of disabling runtime PM for system shutdown was to
prevent untimely runtime-suspend method calls.  This patch (as1504)
accomplishes the same result by incrementing the usage count for each
device and waiting for ongoing runtime-PM callbacks to finish.  This
is what we already do during system suspend and hibernation, which
makes sense since the shutdown method is pretty much a legacy analog
of the pm->poweroff method.

This fixes a recent regression on some OMAP systems introduced by
commit af8db1508f2c9f3b6e633e2d2d906c6557c617f9 (PM / driver core:
disable device's runtime PM during shutdown).

Reported-and-tested-by: NeilBrown <>
Signed-off-by: Alan Stern <>
Acked-by: Greg Kroah-Hartman <>
Signed-off-by: Rafael J. Wysocki <>
10 years agospi/gpio: fix section mismatch warning
Manuel Lauss [Sat, 19 Nov 2011 12:08:10 +0000 (13:08 +0100)]
spi/gpio: fix section mismatch warning

The function __devinit spi_gpio_probe() references
a function __init spi_gpio_alloc.isra.4().
If spi_gpio_alloc.isra.4 is only used by spi_gpio_probe then
annotate spi_gpio_alloc.isra.4 with a matching annotation.

[wsa: fix spi_gpio_request(), too]

Signed-off-by: Manuel Lauss <>
Signed-off-by: Wolfram Sang <>
10 years agospi/fsl-espi: disable CONFIG_SPI_FSL_ESPI=m build
Jiri Slaby [Wed, 7 Dec 2011 20:18:16 +0000 (21:18 +0100)]
spi/fsl-espi: disable CONFIG_SPI_FSL_ESPI=m build

When spi_fsl_espi is chosen to be built as a module, there is a build
error because we test only CONFIG_SPI_FSL_ESPI in declaration of
struct mpc8xxx_spi in drivers/spi/spi_fsl_lib.h. Also some called
functions are not exported.

So we forbid CONFIG_SPI_FSL_ESPI to be tristate here.

The error looks like:
drivers/spi/spi_fsl_espi.c: In function 'fsl_espi_bufs':
drivers/spi/spi_fsl_espi.c:232: error: 'struct mpc8xxx_spi' has no member named 'len'

Signed-off-by: Jiri Slaby <>
Acked-by: Kumar Gala <>
Cc: Grant Likely <>
Signed-off-by: Wolfram Sang <>
10 years agospi/nuc900: Include linux/module.h
Axel Lin [Thu, 24 Nov 2011 03:10:51 +0000 (11:10 +0800)]
spi/nuc900: Include linux/module.h

Include linux/module.h to fix below build error:

  CC      drivers/spi/spi-nuc900.o
drivers/spi/spi-nuc900.c:484: error: 'THIS_MODULE' undeclared here (not in a function)
drivers/spi/spi-nuc900.c:489: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-nuc900.c:489: warning: data definition has no type or storage class
drivers/spi/spi-nuc900.c:489: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR'
drivers/spi/spi-nuc900.c:489: warning: function declaration isn't a prototype
drivers/spi/spi-nuc900.c:490: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-nuc900.c:490: warning: data definition has no type or storage class
drivers/spi/spi-nuc900.c:490: warning: type defaults to 'int' in declaration of 'MODULE_DESCRIPTION'
drivers/spi/spi-nuc900.c:490: warning: function declaration isn't a prototype
drivers/spi/spi-nuc900.c:491: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-nuc900.c:491: warning: data definition has no type or storage class
drivers/spi/spi-nuc900.c:491: warning: type defaults to 'int' in declaration of 'MODULE_LICENSE'
drivers/spi/spi-nuc900.c:491: warning: function declaration isn't a prototype
drivers/spi/spi-nuc900.c:492: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-nuc900.c:492: warning: data definition has no type or storage class
drivers/spi/spi-nuc900.c:492: warning: type defaults to 'int' in declaration of 'MODULE_ALIAS'
drivers/spi/spi-nuc900.c:492: warning: function declaration isn't a prototype
make[2]: *** [drivers/spi/spi-nuc900.o] Error 1
make[1]: *** [drivers/spi] Error 2
make: *** [drivers] Error 2

Signed-off-by: Axel Lin <>
Acked-by: Paul Gortmaker <>
Signed-off-by: Wolfram Sang <>
10 years agospi/ath79: fix compile error due to missing include
Gabor Juhos [Wed, 16 Nov 2011 19:01:43 +0000 (20:01 +0100)]
spi/ath79: fix compile error due to missing include

Whithout including 'linux/module.h' spi-ath79 driver fails to compile
with the these errors:

drivers/spi/spi-ath79.c:273:12: error: 'THIS_MODULE' undeclared here (not in a function)
drivers/spi/spi-ath79.c:278:20: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-ath79.c:278:1: warning: data definition has no type or storage class
drivers/spi/spi-ath79.c:278:1: warning: type defaults to 'int' in declaration of 'MODULE_DESCRIPTION'
drivers/spi/spi-ath79.c:278:20: warning: function declaration isn't a prototype
drivers/spi/spi-ath79.c:279:15: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-ath79.c:279:1: warning: data definition has no type or storage class
drivers/spi/spi-ath79.c:279:1: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR'
drivers/spi/spi-ath79.c:279:15: warning: function declaration isn't a prototype
drivers/spi/spi-ath79.c:280:16: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-ath79.c:280:1: warning: data definition has no type or storage class
drivers/spi/spi-ath79.c:280:1: warning: type defaults to 'int' in declaration of 'MODULE_LICENSE'
drivers/spi/spi-ath79.c:280:16: warning: function declaration isn't a prototype
drivers/spi/spi-ath79.c:281:14: error: expected declaration specifiers or '...' before string constant
drivers/spi/spi-ath79.c:281:1: warning: data definition has no type or storage class
drivers/spi/spi-ath79.c:281:1: warning: type defaults to 'int' in declaration of 'MODULE_ALIAS'
drivers/spi/spi-ath79.c:281:14: warning: function declaration isn't a prototype

Signed-off-by: Gabor Juhos <>
Signed-off-by: Wolfram Sang <>
10 years agoceph: use i_ceph_lock instead of i_lock
Sage Weil [Wed, 30 Nov 2011 17:47:09 +0000 (09:47 -0800)]
ceph: use i_ceph_lock instead of i_lock

We have been using i_lock to protect all kinds of data structures in the
ceph_inode_info struct, including lists of inodes that we need to iterate
over while avoiding races with inode destruction.  That requires grabbing
a reference to the inode with the list lock protected, but igrab() now
takes i_lock to check the inode flags.

Changing the list lock ordering would be a painful process.

However, using a ceph-specific i_ceph_lock in the ceph inode instead of
i_lock is a simple mechanical change and avoids the ordering constraints
imposed by igrab().

Reported-by: Amon Ott <>
Signed-off-by: Sage Weil <>
10 years agorbd: remove buggy rollback functionality
Josh Durgin [Mon, 24 Oct 2011 23:28:27 +0000 (16:28 -0700)]
rbd: remove buggy rollback functionality

This doesn't interact with resizing well, since it doesn't set the
size of the device to the size at the snapshot. It's also an expensive
operation to be synchronous. Rollback can still be done with the
userspace rbd tool.

Signed-off-by: Josh Durgin <>
10 years agorbd: return an error when an invalid header is read
Josh Durgin [Tue, 15 Nov 2011 22:49:53 +0000 (14:49 -0800)]
rbd: return an error when an invalid header is read

This protects against opening future rbd images that have incompatible format changes.

Signed-off-by: Josh Durgin <>