]> bbs.cooldavid.org Git - net-next-2.6.git/log
net-next-2.6.git
13 years agoscore: fix dereference of NULL pointer in local_flush_tlb_page()
Roel Kluin [Wed, 11 Aug 2010 21:17:31 +0000 (14:17 -0700)]
score: fix dereference of NULL pointer in local_flush_tlb_page()

Don't dereference vma if it's NULL.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agopc8736x_gpio: depends on X86_32
Randy Dunlap [Wed, 11 Aug 2010 21:17:30 +0000 (14:17 -0700)]
pc8736x_gpio: depends on X86_32

Fix kconfig dependency warning for PC8736x_GPIO by restricting it to
X86_32.

  warning: (SCx200_GPIO && SCx200 || PC8736x_GPIO && X86) selects NSC_GPIO which has unmet direct dependencies (X86_32)

NSC_GPIO is X86_32 only.  The other driver (SCx200_GPIO) that selects
NSC_GPIO is X86_32 only (indirectly, since SCx200 depends on X86_32), so
limit this driver also.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Jordan Crouse <jordan.crouse@amd.com>
Cc: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agomm: fix fatal kernel-doc error
Randy Dunlap [Wed, 11 Aug 2010 21:17:30 +0000 (14:17 -0700)]
mm: fix fatal kernel-doc error

Fix a fatal kernel-doc error due to a #define coming between a function's
kernel-doc notation and the function signature.  (kernel-doc cannot handle
this)

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agoacpi: fix bogus preemption logic
Thomas Gleixner [Wed, 11 Aug 2010 21:17:29 +0000 (14:17 -0700)]
acpi: fix bogus preemption logic

The ACPI_PREEMPTION_POINT() logic was introduced in commit 8bd108d
(ACPICA: add preemption point after each opcode parse).  The follow up
commits abe1dfab6138d15692c084ca70 tried to fix the preemption logic
back and forth, but nobody noticed that the usage of
in_atomic_preempt_off() in that context is wrong.

The check which guards the call of cond_resched() is:

    if (!in_atomic_preempt_off() && !irqs_disabled())

in_atomic_preempt_off() is not intended for general use as the comment
above the macro definition clearly says:

 * Check whether we were atomic before we did preempt_disable():
 * (used by the scheduler, *after* releasing the kernel lock)

On a CONFIG_PREEMPT=n kernel the usage of in_atomic_preempt_off() works by
accident, but with CONFIG_PREEMPT=y it's just broken.

The whole purpose of the ACPI_PREEMPTION_POINT() is to reduce the latency
on a CONFIG_PREEMPT=n kernel, so make ACPI_PREEMPTION_POINT() depend on
CONFIG_PREEMPT=n and remove the in_atomic_preempt_off() check.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=16210

[akpm@linux-foundation.org: fix build]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Len Brown <lenb@kernel.org>
Cc: Francois Valenduc <francois.valenduc@tvcablenet.be>
Cc: Lin Ming <ming.m.lin@intel.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agokernel/kfifo.c: add handling of chained scatterlists
Stefani Seibold [Wed, 11 Aug 2010 21:17:27 +0000 (14:17 -0700)]
kernel/kfifo.c: add handling of chained scatterlists

The current kfifo scatterlist implementation will not work with chained
scatterlists.  It assumes that struct scatterlist arrays are allocated
contiguously, which is not the case when chained scatterlists (struct
sg_table) are in use.

Signed-off-by: Stefani Seibold <stefani@seibold.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agox86, asm: Use a lower case name for the end macro in atomic64_386_32.S
Luca Barbieri [Thu, 12 Aug 2010 14:00:35 +0000 (07:00 -0700)]
x86, asm: Use a lower case name for the end macro in atomic64_386_32.S

Use a lowercase name for the end macro, which somehow fixes a binutils 2.16
problem.

Signed-off-by: Luca Barbieri <luca@luca-barbieri.com>
LKML-Reference: <tip-30246557a06bb20618bed906a06d1e1e0faa8bb4@git.kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agoCRIS: Define io_remap_pfn_range as remap_pfn_range
Jesper Nilsson [Thu, 12 Aug 2010 12:32:58 +0000 (14:32 +0200)]
CRIS: Define io_remap_pfn_range as remap_pfn_range

CRIS don't need any special mapping for io, but didn't define this,
meaning that all uses of io_remap_pfn_range lead to compile errors.

This fixes a compile error introduced in CRIS when drivers/mtd/mtdchar.c
mmap handling was changed in commit dd02b67d5e9e7896891fa27eb5db65f55a290998

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
13 years agomfd: Fix incorrect kfree(i2c) in wm8994-core i2c_driver probe
Axel Lin [Mon, 9 Aug 2010 06:52:16 +0000 (14:52 +0800)]
mfd: Fix incorrect kfree(i2c) in wm8994-core i2c_driver probe

The i2c_client received in probe() should not be kfree()'d.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix incorrect kfree(i2c) in wm831x-core i2c_driver probe
Axel Lin [Mon, 9 Aug 2010 06:51:15 +0000 (14:51 +0800)]
mfd: Fix incorrect kfree(i2c) in wm831x-core i2c_driver probe

The i2c_client received in probe() should not be kfree()'d.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix incorrect kfree(i2c) in tps6507x i2c_driver probe
Axel Lin [Mon, 9 Aug 2010 06:49:46 +0000 (14:49 +0800)]
mfd: Fix incorrect kfree(i2c) in tps6507x i2c_driver probe

The i2c_client received in probe() should not be kfree()'d.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add TPS6586x driver
Mike Rapoport [Tue, 10 Aug 2010 23:11:04 +0000 (01:11 +0200)]
mfd: Add TPS6586x driver

Add mfd core driver for TPS6586x PMICs family.
The driver provides I/O access for the sub-device drivers and performs
regstration of the sub-devices based on the platform requirements.
In addition it implements GPIOlib interface for the chip GPIOs.

TODO:
        - add interrupt support
        - add platform data for PWM, backlight leds and charger

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Use macros instead of some constant magic numbers for menelaus
Jarkko Nikula [Sun, 8 Aug 2010 17:05:24 +0000 (20:05 +0300)]
mfd: Use macros instead of some constant magic numbers for menelaus

This patch is originally done by Carlos Eduardo Aguiar. Original fix is
commit 3305829b2816072b9c8ed01374b205ae4de74027 in
git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git

Author modified the fix for mainline version of menelaus.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Cc: Carlos Eduardo Aguiar <carlos.aguiar@indt.org.br>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix menelaus mmc slot 2 misconfiguration
Jarkko Nikula [Sun, 8 Aug 2010 17:05:23 +0000 (20:05 +0300)]
mfd: Fix menelaus mmc slot 2 misconfiguration

We are modifying register value instead of return value.

This fix is originally done by Carlos Eduardo Aguiar. Original fix is
commit bb4e91722e29efe31587d2cc664b6def645aecd9 in
git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git

Author modified the fix for mainline version of menelaus.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Cc: Carlos Eduardo Aguiar <carlos.aguiar@indt.org.br>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Missing slab.h includes
David Miller [Thu, 5 Aug 2010 05:57:14 +0000 (22:57 -0700)]
mfd: Missing slab.h includes

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix wrong wm8350-core kfree in error path
Axel Lin [Wed, 4 Aug 2010 01:54:21 +0000 (09:54 +0800)]
mfd: Fix wrong wm8350-core kfree in error path

This patch includes below fixes:
1. fix wm8350_create_cache error path
   make sure wm8350->reg_cache is freed in error path.
2. fix wm8350_device_init error path
   no need to kfree(wm8350->reg_cache) in the case of goto out.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix wm8994_device_init() return value
Axel Lin [Wed, 4 Aug 2010 01:44:47 +0000 (09:44 +0800)]
mfd: Fix wm8994_device_init() return value

wm8994_device_init() will return 0 in the case of kzalloc fail
in current implementation.
This patch fixes the return value.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Avoid calling platform_device_put() twice in ucb1400 probe error path
Axel Lin [Tue, 3 Aug 2010 08:34:13 +0000 (16:34 +0800)]
mfd: Avoid calling platform_device_put() twice in ucb1400 probe error path

In the case of goto err2, what we want is to call
platform_device_del() instead of platform_device_unregister().
Otherwise, we call platform_device_put() twice.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Annotate tc6387xb probe/remove routines with __devinit/__devexit
Axel Lin [Tue, 3 Aug 2010 05:45:45 +0000 (13:45 +0800)]
mfd: Annotate tc6387xb probe/remove routines with __devinit/__devexit

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix tc6387xb resource reclaim
Axel Lin [Tue, 3 Aug 2010 05:44:00 +0000 (13:44 +0800)]
mfd: Fix tc6387xb resource reclaim

This patch includes below fixes:
1. add a missing iounmap in tc6387xb_probe() error path
2. fix resource reclaim in tc6387xb_remove()

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix wrong goto labels for tc6393xb error handling
Axel Lin [Tue, 3 Aug 2010 03:10:41 +0000 (11:10 +0800)]
mfd: Fix wrong goto labels for tc6393xb error handling

This patch corrects the error handling path.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Get rid of now unused mc13783 private header
Uwe Kleine-König [Mon, 2 Aug 2010 13:48:04 +0000 (15:48 +0200)]
mfd: Get rid of now unused mc13783 private header

This adds all remaining definitions that are used by the core driver
to the .c file.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agohwmon: Don't access struct mc13783 directly from mc13783-adc
Uwe Kleine-König [Mon, 2 Aug 2010 09:14:18 +0000 (11:14 +0200)]
hwmon: Don't access struct mc13783 directly from mc13783-adc

There is a shiny new mc13783 API function that can be used instead.

While at it refactor the code a bit to reduce code duplication a bit.

This removes the last user of <linux/mfd/mc13783-private.h> and so this
include file can go away.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: New mc13783 function exposing flags
Uwe Kleine-König [Mon, 2 Aug 2010 09:14:17 +0000 (11:14 +0200)]
mfd: New mc13783 function exposing flags

This is needed for the mc13783-adc driver to decide if a touch screen is
connected.  If so some channels are not available as generic hwmon inputs.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Check jz4740-adc kmalloc() result
Axel Lin [Mon, 2 Aug 2010 01:02:02 +0000 (09:02 +0800)]
mfd: Check jz4740-adc kmalloc() result

If kmalloc() fails exit with -ENOMEM.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix jz4740-adc resource reclaim in probe error path
Axel Lin [Thu, 29 Jul 2010 08:28:25 +0000 (16:28 +0800)]
mfd: Fix jz4740-adc resource reclaim in probe error path

If mfd_add_devices() fail, we need to relese allocated resources.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add WM8321 support
Mark Brown [Wed, 21 Jul 2010 13:23:37 +0000 (14:23 +0100)]
mfd: Add WM8321 support

The WM8321 is a PMIC for low power, high performance applications. From a
software point of view the device is identical to the WM8320, all the
differences between the two devices are visible only in hardware.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add stmpe auto sleep feature
Sundar R Iyer [Wed, 21 Jul 2010 06:11:07 +0000 (11:41 +0530)]
mfd: Add stmpe auto sleep feature

Some STMPE devices support entering sleep mode automatically on a
specified timeout of inactivity on the I2C bus with the host system.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Sundar R Iyer <sundar.iyer@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agotouchscreen: Fix sign bug
Kulikov Vasiliy [Thu, 15 Jul 2010 18:43:54 +0000 (22:43 +0400)]
touchscreen: Fix sign bug

platform_get_irq_byname() can return negative results, it is not seen to
unsigned ts_irq. Make it signed.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Acked-By: Luotao Fu <l.fu@pengutronix.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add support for TWL6030 PWM
Hemanth V [Wed, 14 Jul 2010 10:04:56 +0000 (12:04 +0200)]
mfd: Add support for TWL6030 PWM

TWL6030 supports PWM (Pulse Width Modulator) which is used
to control charging LED. PWM allows for controlling brightness.
This patch implements the APIs required by leds-pwm driver.

Signed-off-by: Hemanth V <hemanthv@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add additional WM8994 GPIO functions
Mark Brown [Thu, 8 Jul 2010 12:09:51 +0000 (21:09 +0900)]
mfd: Add additional WM8994 GPIO functions

Later revisions of the WM8994 add some more GPIO functions, define them
in the header file.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add JZ4740 ADC driver
Lars-Peter Clausen [Mon, 12 Jul 2010 01:48:08 +0000 (03:48 +0200)]
mfd: Add JZ4740 ADC driver

This patch adds a MFD driver for the JZ4740 ADC unit. The driver is used to
demultiplex IRQs and synchronize access to shared registers between the
battery, hwmon and (future) touchscreen driver.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agogpiolib: Implement set_debounce for WM831x GPIOs
Mark Brown [Sat, 3 Jul 2010 13:40:56 +0000 (15:40 +0200)]
gpiolib: Implement set_debounce for WM831x GPIOs

The debounce times are approximate, they can be selected using the two
input functions.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agoinput: STMPE touch controller support
Luotao Fu [Fri, 2 Jul 2010 12:10:29 +0000 (14:10 +0200)]
input: STMPE touch controller support

This one adds a driver for STMPE touchscreen controllers.
This driver depends on the stmpexxx mfd core driver.

Signed-off-by: Luotao Fu <l.fu@pengutronix.de>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agoinput: Add STMPE keypad driver
Rabin Vincent [Fri, 2 Jul 2010 11:22:10 +0000 (16:52 +0530)]
input: Add STMPE keypad driver

Add an input driver for the keypad on STMPE I/O expanders.  This driver
uses the common support provided by the STMPE MFD driver.

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agogpio: Add STMPE GPIO driver
Rabin Vincent [Fri, 2 Jul 2010 11:22:09 +0000 (16:52 +0530)]
gpio: Add STMPE GPIO driver

Add support for the GPIOs on STMPE I/O Expanders.

[l.fu@pengutronix.de: fix set direction input]
[l.fu@pengutronix.de: set GPIO alternate function while requesting]
Acked-by: Luotao Fu <l.fu@pengutronix.de>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Add STMPE I/O Expander support
Rabin Vincent [Fri, 2 Jul 2010 11:22:08 +0000 (16:52 +0530)]
mfd: Add STMPE I/O Expander support

Add support for the STMPE family of I/O Expanders from
STMicroelectronics.  These devices include upto 24 gpios and a varying
selection of blocks, including PWM, keypad, and touchscreen controllers.
This patch adds the MFD core.

[l.fu@pengutronix.de: fix stmpe811 enable hook]
[l.fu@pengutronix.de: add touchscreen platform data]
Acked-by: Luotao Fu <l.fu@pengutronix.de>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Properly free t7l66xb clk32k clock source
Axel Lin [Thu, 1 Jul 2010 09:43:50 +0000 (17:43 +0800)]
mfd: Properly free t7l66xb clk32k clock source

This patch includes below fixes to properly free clk32k clock source:
1. remove a redundant clk_put in t7l66xb_probe error path
2. add missing clk_disable(t7l66xb->clk32k) and clk_put(t7l66xb->clk32k)
   to properly free the clock source.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: More verbose MFD Kconfig entry
Samuel Ortiz [Sat, 19 Jun 2010 00:29:24 +0000 (02:29 +0200)]
mfd: More verbose MFD Kconfig entry

For people to be able to intellingibly decide if they want to enable MFD
drivers or not, we have to give them a much better description of what they
are.

13 years agomfd: Staticise ab3550 register access functions
Mark Brown [Wed, 9 Jun 2010 13:54:54 +0000 (14:54 +0100)]
mfd: Staticise ab3550 register access functions

These are now exported via an ops table rather than referenced
directly and so should be staticised.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix davinci memory leak
Julia Lawall [Tue, 1 Jun 2010 14:34:38 +0000 (16:34 +0200)]
mfd: Fix davinci memory leak

Error handling code following a kmalloc should free the allocated data.

The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...x...+> }
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: properly handle platform_device_add_resources fail in mfd_add_device
Axel Lin [Mon, 31 May 2010 09:30:55 +0000 (17:30 +0800)]
mfd: properly handle platform_device_add_resources fail in mfd_add_device

platform_device_add_resources may fail, thus add error checking for it.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: kzalloc doesn't return ERR_PTR
Julia Lawall [Fri, 28 May 2010 20:58:46 +0000 (22:58 +0200)]
mfd: kzalloc doesn't return ERR_PTR

Use !x rather than IS_ERR(x) to test the result of kzalloc.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,E;
@@

x = \(kmalloc\|kzalloc\|kcalloc\)(...)
... when != x = E
- IS_ERR(x)
+ !x
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: AB8500 mask off irrelevant bits from the SPI message
Linus Walleij [Fri, 28 May 2010 00:59:44 +0000 (02:59 +0200)]
mfd: AB8500 mask off irrelevant bits from the SPI message

The registers on the AB8500 are only 8 bits wide, so the content
of the remaining bits is undefined. Let's mask off the undefined
stuff when returning a register in an SPI read.

Acked-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix 88pm860x uninitialized variable and clean up
Dan Carpenter [Wed, 26 May 2010 22:54:09 +0000 (00:54 +0200)]
mfd: Fix 88pm860x uninitialized variable and clean up

The original code had a compile warning:
drivers/mfd/88pm860x-core.c:431: warning: ‘ret’ may be used
uninitialized in this function
It seems like the warning is valid if either pdata or pdata->touch is
NULL.

This patch checks pdata and pdata->touch at the beginning of the
function.  That means everything can be pulled in one indent level.
Now all the statements fit within the 80 character limit.

Also at that point the "use_gpadc" variable isn't needed and removing
it simplifies the logic.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Haojian Zhuang <hzhuang1@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix memory leak in ab3100_otp_probe
Axel Lin [Tue, 25 May 2010 06:49:51 +0000 (14:49 +0800)]
mfd: Fix memory leak in ab3100_otp_probe

In current implementation, there is a memory leak if ab3100_otp_read fail.
And in the case of ab3100_otp_init_debugfs fail, it does not properly remove
sysfs entries.
This patch properly handle above failure cases.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Fix led resource in 88pm860x
Haojian Zhuang [Wed, 19 May 2010 05:06:59 +0000 (13:06 +0800)]
mfd: Fix led resource in 88pm860x

Fix typo error in LED resource of 88pm860x.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agomfd: Enable onkey on max8925
Haojian Zhuang [Fri, 18 Jun 2010 17:59:53 +0000 (19:59 +0200)]
mfd: Enable onkey on max8925

Enable onkey feature in max8925 driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
13 years agokconfig: fix tristate choice with minimal config
Sam Ravnborg [Thu, 12 Aug 2010 07:11:52 +0000 (09:11 +0200)]
kconfig: fix tristate choice with minimal config

If a minimal config did not specify the value
of all choice values, the resulting configuration
could have wrong values.

Consider following example:
config M
        def_bool y
        option modules
choice
        prompt "choice list"
config A
        tristate "a"
config B
tristate "b"
endchoice

With a defconfig like this:
CONFIG_M=y
CONFIG_A=y

The resulting configuration would have

    CONFIG_A=m

which was unexpected.

The problem was not not all choice values were set and thus
kconfig calculated a wrong value.

The fix is to set all choice values when we
read a defconfig files.

conf_set_all_new_symbols() is refactored such that
random choice values are now handled by a dedicated function.
And new choice values are set by set_all_choice_values().

This was not the minimal fix, but the fix that resulted
in the most readable code.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reported-by: Arve Hjønnevåg <arve@android.com>
Tested-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
13 years agokconfig: fix savedefconfig for tristate choices
Sam Ravnborg [Thu, 12 Aug 2010 07:11:51 +0000 (09:11 +0200)]
kconfig: fix savedefconfig for tristate choices

savedefconfig failed to save choice symbols equal to 'y'
for tristate choices.
This resulted in this value being lost.

In particular is fixes an issue where

make ARCH=avr32 atngw100_defconfig
make ARCH=avr32 savedefconfig
cp defconfig arch/avr32/configs/atngw100_defconfig
make ARCH=avr32 atngw100_defconfig
diff -u .config .config.old

failed to produce an identical .config.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
13 years agophylib: available for any speed ethernet
Randy Dunlap [Wed, 11 Aug 2010 13:26:57 +0000 (13:26 +0000)]
phylib: available for any speed ethernet

Several gigabit network drivers (SB1250_MAC, TIGON3, FSL, GIANFAR,
UCC_GETH, MV643XX_ETH, XILINX_LL_TEMAC, S6GMAC, STMMAC_ETH, PASEMI_MAC,
and OCTEON_ETHERNET) select PHYLIB.  These drivers are not under
NET_ETHERNET (10/100 mbit), so this warning is generated (long, irrelevant
parts are omitted):

warning: (NET_DSA && NET && EXPERIMENTAL && NET_ETHERNET && !S390 || ... || SB1250_MAC && NETDEVICES && NETDEV_1000 && SIBYTE_SB1xxx_SOC || TIGON3 && NETDEVICES && NETDEV_1000 && PCI || FSL_PQ_MDIO && NETDEVICES && NETDEV_1000 && FSL_SOC || GIANFAR && NETDEVICES && NETDEV_1000 && FSL_SOC || UCC_GETH && NETDEVICES && NETDEV_1000 && QUICC_ENGINE || MV643XX_ETH && NETDEVICES && NETDEV_1000 && (MV64X60 || PPC32 || PLAT_ORION) || XILINX_LL_TEMAC && NETDEVICES && NETDEV_1000 && (PPC || MICROBLAZE) || S6GMAC && NETDEVICES && NETDEV_1000 && XTENSA_VARIANT_S6000 || STMMAC_ETH && NETDEV_1000 && NETDEVICES && CPU_SUBTYPE_ST40 || PASEMI_MAC && NETDEVICES && NETDEV_10000 && PPC_PASEMI && PCI || OCTEON_ETHERNET && STAGING && !STAGING_EXCLUDE_BUILD && CPU_CAVIUM_OCTEON) selects PHYLIB which has unmet direct dependencies (!S390 && NET_ETHERNET)

PHYLIB is used by non-10/100 mbit ethernet drivers, so change the dependencies
to be NETDEVICES instead of NET_ETHERNET.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 years agox86, asm: Refactor atomic64_386_32.S to support old binutils and be cleaner
Luca Barbieri [Fri, 6 Aug 2010 02:04:38 +0000 (04:04 +0200)]
x86, asm: Refactor atomic64_386_32.S to support old binutils and be cleaner

The old code didn't work on binutils 2.12 because setting a symbol to
a register apparently requires a fairly recent version.

This commit refactors the code to use the C preprocessor instead, and
in the process makes the whole code a bit easier to understand.

The object code produced is unchanged as expected.

This fixes kernel bugzilla 16506.

Reported-by: Dieter Stussy <kd6lvw+software@kd6lvw.ampr.org>
Signed-off-by: Luca Barbieri <luca@luca-barbieri.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: <stable@kernel.org> 2.6.35
LKML-Reference: <tip-*@git.kernel.org>

13 years agodm mpath: support discard
Mike Snitzer [Thu, 12 Aug 2010 03:14:32 +0000 (04:14 +0100)]
dm mpath: support discard

Enable discard support in the DM multipath target.

This discard support depends on a few discard-specific fixes to the
block layer's request stacking driver methods.

Discard requests are optional so don't allow a failed discard to trigger
path failures.  If there is a real problem with a given path the
barriers associated with the discard (either before or after the
discard) will cause path failure.  That said, unconditionally passing
discard failures up the stack is not ideal.  This must be fixed once DM
has more information about the nature of the underlying storage failure.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Cc: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
13 years agodm stripe: support discards
Mikulas Patocka [Thu, 12 Aug 2010 03:14:26 +0000 (04:14 +0100)]
dm stripe: support discards

The DM core will submit a discard bio to the stripe target for each
stripe in a striped DM device.  The stripe target will determine
stripe-specific portions of the supplied bio to be remapped into
individual (at most 'num_discard_requests' extents).  If a given
stripe-specific discard bio doesn't touch a particular stripe the bio
will be dropped.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: split discard requests on target boundaries
Mike Snitzer [Thu, 12 Aug 2010 03:14:24 +0000 (04:14 +0100)]
dm: split discard requests on target boundaries

Update __clone_and_map_discard to loop across all targets in a DM
device's table when it processes a discard bio.  If a discard crosses a
target boundary it must be split accordingly.

Update __issue_target_requests and __issue_target_request to allow a
cloned discard bio to have a custom start sector and size.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm stripe: optimize sector division
Mikulas Patocka [Thu, 12 Aug 2010 03:14:21 +0000 (04:14 +0100)]
dm stripe: optimize sector division

Optimize sector division: If the number of stripes is a power of two,
we can do shift and mask instead of division.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm stripe: move sector translation to a function
Mikulas Patocka [Thu, 12 Aug 2010 03:14:14 +0000 (04:14 +0100)]
dm stripe: move sector translation to a function

Move sector to stripe translation into a function.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: error return error for discards
Mike Snitzer [Thu, 12 Aug 2010 03:14:14 +0000 (04:14 +0100)]
dm: error return error for discards

Have the error target respond to a discard request with a hard -EIO
rather than fail the request with -EOPNOTSUPP.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm delay: support discard
Mike Snitzer [Thu, 12 Aug 2010 03:14:13 +0000 (04:14 +0100)]
dm delay: support discard

Enable discard support for the delay target.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: zero silently drop discards
Mike Snitzer [Thu, 12 Aug 2010 03:14:12 +0000 (04:14 +0100)]
dm: zero silently drop discards

Have the zero target silently drop a discard rather than fail the
request with -EOPNOTSUPP.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: use dm_target_offset macro
Alasdair G Kergon [Thu, 12 Aug 2010 03:14:11 +0000 (04:14 +0100)]
dm: use dm_target_offset macro

Use new dm_target_offset() macro to avoid most references to ti->begin
in dm targets.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: factor out max_io_len_target_boundary
Mike Snitzer [Thu, 12 Aug 2010 03:14:10 +0000 (04:14 +0100)]
dm: factor out max_io_len_target_boundary

Split max_io_len_target_boundary out of max_io_len so that the discard
support can make use of it without duplicating max_io_len code.

Avoiding max_io_len's split_io logic enables DM's discard support to
submit the entire discard request to a target.  But discards must still
be split on target boundaries.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: use common __issue_target_request for flush and discard support
Mike Snitzer [Thu, 12 Aug 2010 03:14:09 +0000 (04:14 +0100)]
dm: use common __issue_target_request for flush and discard support

Rename __flush_target to __issue_target_request now that it is used to
issue both flush and discard requests.

Introduce __issue_target_requests as a convenient wrapper to
__issue_target_request 'num_flush_requests' or 'num_discard_requests'
times per target.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: linear support discard
Mike Snitzer [Thu, 12 Aug 2010 03:14:08 +0000 (04:14 +0100)]
dm: linear support discard

Allow discards to be passed through to linear mappings if at least one
underlying device supports it.  Discards will be forwarded only to
devices that support them.

A target that supports discards should set num_discard_requests to
indicate how many times each discard request must be submitted to it.

Verify table's underlying devices support discards prior to setting the
associated DM device as capable of discards (via QUEUE_FLAG_DISCARD).

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Joe Thornber <thornber@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm crypt: simplify crypt_ctr
Milan Broz [Thu, 12 Aug 2010 03:14:07 +0000 (04:14 +0100)]
dm crypt: simplify crypt_ctr

Allocate cipher strings indpendently of struct crypt_config and move
cipher parsing and allocation into a separate function to prepare for
supporting the cryptoapi format e.g. "xts(aes)".

No functional change in this patch.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm crypt: simplify crypt_config destruction logic
Milan Broz [Thu, 12 Aug 2010 03:14:06 +0000 (04:14 +0100)]
dm crypt: simplify crypt_config destruction logic

Use just one label and reuse common destructor for crypt target.

Parse remaining argv arguments in logic order.

Also do not ignore error values from IV init and set key functions.

No functional change in this patch except changed return codes
based on above.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: allow autoloading of dm mod
Peter Rajnoha [Thu, 12 Aug 2010 03:14:05 +0000 (04:14 +0100)]
dm: allow autoloading of dm mod

Add devname:mapper/control and MAPPER_CTRL_MINOR module alias
to support dm-mod module autoloading.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: rename map_info flush_request to target_request_nr
Mike Snitzer [Thu, 12 Aug 2010 03:14:04 +0000 (04:14 +0100)]
dm: rename map_info flush_request to target_request_nr

'target_request_nr' is a more generic name that reflects the fact that
it will be used for both flush and discard support.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: refactor dm_table_complete
Will Drewry [Thu, 12 Aug 2010 03:14:03 +0000 (04:14 +0100)]
dm ioctl: refactor dm_table_complete

This change unifies the various checks and finalization that occurs on a
table prior to use.  By doing so, it allows table construction without
traversing the dm-ioctl interface.

Signed-off-by: Will Drewry <wad@chromium.org>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm snapshot: implement merge
Mikulas Patocka [Thu, 12 Aug 2010 03:14:02 +0000 (04:14 +0100)]
dm snapshot: implement merge

Implement merge method for the snapshot origin to improve read
performance.

Without merge method, dm asks the upper layers to submit smallest possible
bios --- one page. Submitting such small bios impacts performance negatively
when reading or writing the origin device.

Without this patch, CPU consumption when reading the origin on lvm on md-raid0
was 6 to 12%, with this patch, it drops to 1 to 4%.

Note: in my testing, it actually degraded performance in some settings, I
traced it to Maxtor disks having problems with > 512-sector requests.
Reducing the number of sectors to /sys/block/sd*/queue/max_sectors_kb to
256 fixed the read performance. I think we don't have to care about weird
disks that actually degrade performance because of large requests being
sent to them.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: do not initialise full request queue when bio based
Mike Snitzer [Thu, 12 Aug 2010 03:14:02 +0000 (04:14 +0100)]
dm: do not initialise full request queue when bio based

Change bio-based mapped devices no longer to have a fully initialized
request_queue (request_fn, elevator, etc).  This means bio-based DM
devices no longer register elevator sysfs attributes ('iosched/' tree
or 'scheduler' other than "none").

In contrast, a request-based DM device will continue to have a full
request_queue and will register elevator sysfs attributes.  Therefore
a user can determine a DM device's type by checking if elevator sysfs
attributes exist.

First allocate a minimalist request_queue structure for a DM device
(needed for both bio and request-based DM).

Initialization of a full request_queue is deferred until it is known
that the DM device is request-based, at the end of the table load
sequence.

Factor DM device's request_queue initialization:
- common to both request-based and bio-based into dm_init_md_queue().
- specific to request-based into dm_init_request_based_queue().

The md->type_lock mutex is used to protect md->queue, in addition to
md->type, during table_load().

A DM device's first table_load will establish the immutable md->type.
But md->queue initialization, based on md->type, may fail at that time
(because blk_init_allocated_queue cannot allocate memory).  Therefore
any subsequent table_load must (re)try dm_setup_md_queue independently of
establishing md->type.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: make bio or request based device type immutable
Mike Snitzer [Thu, 12 Aug 2010 03:14:01 +0000 (04:14 +0100)]
dm ioctl: make bio or request based device type immutable

Determine whether a mapped device is bio-based or request-based when
loading its first (inactive) table and don't allow that to be changed
later.

This patch performs different device initialisation in each of the two
cases.  (We don't think it's necessary to add code to support changing
between the two types.)

Allowed md->type transitions:
  DM_TYPE_NONE to DM_TYPE_BIO_BASED
  DM_TYPE_NONE to DM_TYPE_REQUEST_BASED

We now prevent table_load from replacing the inactive table with a
conflicting type of table even after an explicit table_clear.

Introduce 'type_lock' into the struct mapped_device to protect md->type
and to prepare for the next patch that will change the queue
initialization and allocate memory while md->type_lock is held.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
 drivers/md/dm-ioctl.c    |   15 +++++++++++++++
 drivers/md/dm.c          |   37 ++++++++++++++++++++++++++++++-------
 drivers/md/dm.h          |    5 +++++
 include/linux/dm-ioctl.h |    4 ++--
 4 files changed, 52 insertions(+), 9 deletions(-)

13 years agodm: skip second flush on bio unsupported error
Mikulas Patocka [Thu, 12 Aug 2010 03:14:00 +0000 (04:14 +0100)]
dm: skip second flush on bio unsupported error

When processing barriers, skip the second flush if processing the bio
failed with -EOPNOTSUPP.  This can happen with discard+barrier requests.
If the device doesn't support discard, there would be two useless
SYNCHRONIZE CACHE commands.  The first dm_flush cannot be so easily
optimized out, so we leave it there.

Previously, -EOPNOTSUPP could be received in dec_pending only with empty
barriers and we ignored that error, assuming the device not supporting
cache flushes has cache always consistent.  With the addition of discard
barriers, this -EOPNOTSUPP can also be generated by discards and we
must record it in md->barrier_error for process_barrier.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm snapshot: persistent use define for disk header chunk size
Tomohiro Kusumi [Thu, 12 Aug 2010 03:13:59 +0000 (04:13 +0100)]
dm snapshot: persistent use define for disk header chunk size

This patch fixes hard-coded value for the size of a chunk that includes
disk header for persistent snapshot. It should be changed to existing
macro NUM_SNAPSHOT_HDR_CHUNKS instead of using hard-coded value 1.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm crypt: use kstrdup
Julia Lawall [Thu, 12 Aug 2010 03:13:58 +0000 (04:13 +0100)]
dm crypt: use kstrdup

Use kstrdup when the goal of an allocation is copy a string into the
allocated region.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression from,to;
expression flag,E1,E2;
statement S;
@@

-  to = kmalloc(strlen(from) + 1,flag);
+  to = kstrdup(from, flag);
   ... when != \(from = E1 \| to = E1 \)
   if (to==NULL || ...) S
   ... when != \(from = E2 \| to = E2 \)
-  strcpy(to, from);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: use nonseekable_open
Arnd Bergmann [Thu, 12 Aug 2010 03:13:57 +0000 (04:13 +0100)]
dm ioctl: use nonseekable_open

The dm control device does not implement read/write, so it has no use for
seeking.  Using no_llseek prevents falling back to default_llseek, which
requires the BKL.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: separate device deletion from dm_put
Kiyoshi Ueda [Thu, 12 Aug 2010 03:13:56 +0000 (04:13 +0100)]
dm: separate device deletion from dm_put

This patch separates the device deletion code from dm_put()
to make sure the deletion happens in the process context.

By this patch, device deletion always occurs in an ioctl (process)
context and dm_put() can be called in interrupt context.
As a result, the request-based dm's bad dm_put() usage pointed out
by Mikulas below disappears.
    http://marc.info/?l=dm-devel&m=126699981019735&w=2

Without this patch, I confirmed there is a case to crash the system:
    dm_put() => dm_table_destroy() => vfree() => BUG_ON(in_interrupt())

Some more backgrounds and details:
In request-based dm, a device opener can remove a mapped_device
while the last request is still completing, because bios in the last
request complete first and then the device opener can close and remove
the mapped_device before the last request completes:
  CPU0                                          CPU1
  =================================================================
  <<INTERRUPT>>
  blk_end_request_all(clone_rq)
    blk_update_request(clone_rq)
      bio_endio(clone_bio) == end_clone_bio
        blk_update_request(orig_rq)
          bio_endio(orig_bio)
                                                <<I/O completed>>
                                                dm_blk_close()
                                                dev_remove()
                                                  dm_put(md)
                                                    <<Free md>>
   blk_finish_request(clone_rq)
     ....
     dm_end_request(clone_rq)
       free_rq_clone(clone_rq)
       blk_end_request_all(orig_rq)
       rq_completed(md)

So request-based dm used dm_get()/dm_put() to hold md for each I/O
until its request completion handling is fully done.
However, the final dm_put() can call the device deletion code which
must not be run in interrupt context and may cause kernel panic.

To solve the problem, this patch moves the device deletion code,
dm_destroy(), to predetermined places that is actually deleting
the mapped_device in ioctl (process) context, and changes dm_put()
just to decrement the reference count of the mapped_device.
By this change, dm_put() can be used in any context and the symmetric
model below is introduced:
    dm_create():  create a mapped_device
    dm_destroy(): destroy a mapped_device
    dm_get():     increment the reference count of a mapped_device
    dm_put():     decrement the reference count of a mapped_device

dm_destroy() waits for all references of the mapped_device to disappear,
then deletes the mapped_device.

dm_destroy() uses active waiting with msleep(1), since deleting
the mapped_device isn't performance-critical task.
And since at this point, nobody opens the mapped_device and no new
reference will be taken, the pending counts are just for racing
completing activity and will eventually decrease to zero.

For the unlikely case of the forced module unload, dm_destroy_immediate(),
which doesn't wait and forcibly deletes the mapped_device, is also
introduced and used in dm_hash_remove_all().  Otherwise, "rmmod -f"
may be stuck and never return.
And now, because the mapped_device is deleted at this point, subsequent
accesses to the mapped_device may cause NULL pointer references.

Cc: stable@kernel.org
Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: release _hash_lock between devices in remove_all
Kiyoshi Ueda [Thu, 12 Aug 2010 03:13:55 +0000 (04:13 +0100)]
dm ioctl: release _hash_lock between devices in remove_all

This patch changes dm_hash_remove_all() to release _hash_lock when
removing a device.  After removing the device, dm_hash_remove_all()
takes _hash_lock and searches the hash from scratch again.

This patch is a preparation for the next patch, which changes device
deletion code to wait for md reference to be 0.  Without this patch,
the wait in the next patch may cause AB-BA deadlock:
  CPU0                                CPU1
  -----------------------------------------------------------------------
  dm_hash_remove_all()
    down_write(_hash_lock)
                                      table_status()
                                        md = find_device()
                                               dm_get(md)
                                                 <increment md->holders>
                                        dm_get_live_or_inactive_table()
                                          dm_get_inactive_table()
                                            down_write(_hash_lock)
    <in the md deletion code>
      <wait for md->holders to be 0>

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: stable@kernel.org
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm: prevent access to md being deleted
Kiyoshi Ueda [Thu, 12 Aug 2010 03:13:54 +0000 (04:13 +0100)]
dm: prevent access to md being deleted

This patch prevents access to mapped_device which is being deleted.

Currently, even after a mapped_device has been removed from the hash,
it could be accessed through idr_find() using minor number.
That could cause a race and NULL pointer reference below:
  CPU0                          CPU1
  ------------------------------------------------------------------
  dev_remove(param)
    down_write(_hash_lock)
    dm_lock_for_deletion(md)
      spin_lock(_minor_lock)
      set_bit(DMF_DELETING)
      spin_unlock(_minor_lock)
    __hash_remove(hc)
    up_write(_hash_lock)
                                dev_status(param)
                                  md = find_device(param)
                                         down_read(_hash_lock)
                                         __find_device_hash_cell(param)
                                           dm_get_md(param->dev)
                                             md = dm_find_md(dev)
                                                    spin_lock(_minor_lock)
                                                    md = idr_find(MINOR(dev))
                                                    spin_unlock(_minor_lock)
    dm_put(md)
      free_dev(md)
                                             dm_get(md)
                                         up_read(_hash_lock)
                                  __dev_status(md, param)
                                  dm_put(md)

This patch fixes such problems.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: stable@kernel.org
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: return uevent flag after rename
Peter Rajnoha [Thu, 12 Aug 2010 03:13:53 +0000 (04:13 +0100)]
dm ioctl: return uevent flag after rename

All the dm ioctls that generate uevents set the DM_UEVENT_GENERATED flag so
that userspace knows whether or not to wait for a uevent to be processed
before continuing,

The dm rename ioctl sets this flag but was not structured to return it
to userspace.  This patch restructures the rename ioctl processing to
behave like the other ioctls that return data and so fix this.

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: make __dev_status void
Alasdair G Kergon [Thu, 12 Aug 2010 03:13:52 +0000 (04:13 +0100)]
dm ioctl: make __dev_status void

__dev_status() cannot fail so make it void and simplify callers.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm ioctl: remove __dev_status from geometry and target message
Peter Rajnoha [Thu, 12 Aug 2010 03:13:52 +0000 (04:13 +0100)]
dm ioctl: remove __dev_status from geometry and target message

Remove useless __dev_status call while processing an ioctl that sets up
device geometry and target message.  The data is not returned to
userspace so there is no point collecting it and in the case of
target_message it is collected before processing the message so if it
did return it might be stale.

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm snapshot: test chunk size against both origin and snapshot
Mikulas Patocka [Thu, 12 Aug 2010 03:13:51 +0000 (04:13 +0100)]
dm snapshot: test chunk size against both origin and snapshot

Validate chunk size against both origin and snapshot sector size

Don't allow chunk size smaller than either origin or snapshot logical
sector size. Reading or writing data not aligned to sector size is not
allowed and causes immediate errors.

This requires us to open the origin before initialising the
exception store and to export dm_snap_origin.

Cc: stable@kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm snapshot: iterate origin and cow devices
Mikulas Patocka [Thu, 12 Aug 2010 03:13:50 +0000 (04:13 +0100)]
dm snapshot: iterate origin and cow devices

Iterate both origin and snapshot devices

iterate_devices method should call the callback for all the devices where
the bio may be remapped. Thus, snapshot_iterate_devices should call the callback
for both snapshot and origin underlying devices because it remaps some bios
to the snapshot and some to the origin.

snapshot_iterate_devices called the callback only for the origin device.
This led to badly calculated device limits if snapshot and origin were placed
on different types of disks.

Cc: stable@kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agodm mpath: fix NULL pointer dereference when path parameters missing
Alasdair G Kergon [Thu, 12 Aug 2010 03:13:49 +0000 (04:13 +0100)]
dm mpath: fix NULL pointer dereference when path parameters missing

multipath_ctr() forgets to return an error after detecting
missing path parameters.  Fix this.

Signed-off-by: Patrick LoPresti <lopresti@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 years agoio-mapping: move asm include inside the config option
Dave Airlie [Thu, 12 Aug 2010 01:47:50 +0000 (11:47 +1000)]
io-mapping: move asm include inside the config option

nouveau starting using these APIs, the first on non-x86 hw, and this
include isn't required on anything with real amounts of vmalloc space.

this fixes a build problem on powerpc.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agovgaarb: drop vga.h include
Dave Airlie [Thu, 12 Aug 2010 01:44:50 +0000 (11:44 +1000)]
vgaarb: drop vga.h include

We don't actually need this include on any platform.

built on powerpc + x86, reported on m68k.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agodrm/radeon: Add probing of clocks from device-tree
Benjamin Herrenschmidt [Mon, 9 Aug 2010 06:16:36 +0000 (16:16 +1000)]
drm/radeon: Add probing of clocks from device-tree

When we find no ROM we understand and a device-tree is present, see
if we can retreive clock info from there.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agodrm/radeon: drop old and broken mesa warning
Dave Airlie [Wed, 11 Aug 2010 23:40:05 +0000 (09:40 +1000)]
drm/radeon: drop old and broken mesa warning

This never really got fixed in mesa, and the kernel deals with the problem
just fine, so don't got reporting things that confuse people.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agodrm/radeon: Fix pci_map_page() error checking
Benjamin Herrenschmidt [Tue, 10 Aug 2010 04:48:58 +0000 (14:48 +1000)]
drm/radeon: Fix pci_map_page() error checking

0 is a valid DMA address from pci_map_page(), use pci_dma_mapping_error()
instead to check for errors

[airlied: fix warning + two other places with errors.]

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agodrm: Remove count_lock for calling lastclose() after 58474713 (v2)
Chris Wilson [Wed, 11 Aug 2010 13:41:16 +0000 (14:41 +0100)]
drm: Remove count_lock for calling lastclose() after 58474713 (v2)

When removing of the BKL the locking around lastclose() was rearranged
and resulted in the holding of the open_count spinlock over the call
into drm_lastclose(). The drivers were not ready for this path to be
atomic - it may indeed involve long waits to release old objects and
cleanup the GPU - and so we ended up scheduling whilst atomic.

[   54.625598] BUG: scheduling while atomic: X/3546/0x00000002
[   54.625600] Modules linked in: sco bridge stp llc input_polldev rfcomm bnep l2cap crc16 sch_sfq ipv6 md_mod acpi_cpufreq mperf cryptd aes_x86_64 aes_generic xts gf128mul dm_crypt dm_mod btusb bluetooth usbhid hid zaurus cdc_ether usbnet mii cdc_wdm cdc_acm uvcvideo videodev v4l1_compat v4l2_compat_ioctl32 snd_hda_codec_conexant arc4 pcmcia ecb snd_hda_intel joydev sdhci_pci sdhci snd_hda_codec tpm_tis firewire_ohci mmc_core e1000e uhci_hcd thinkpad_acpi nvram yenta_socket pcmcia_rsrc pcmcia_core tpm wmi sr_mod firewire_core iwlagn ehci_hcd snd_hwdep snd_pcm usbcore tpm_bios thermal led_class snd_timer iwlcore snd soundcore ac snd_page_alloc pcspkr psmouse serio_raw battery sg mac80211 evdev cfg80211 i2c_i801 iTCO_wdt iTCO_vendor_support cdrom processor crc_itu_t rfkill xfs exportfs sd_mod crc_t10dif ahci libahci libata scsi_mod [last unloaded: scsi_wait_scan]
[   54.625663] Pid: 3546, comm: X Not tainted 2.6.35-04771-g1787985 #301
[   54.625665] Call Trace:
[   54.625671]  [<ffffffff8102d599>] __schedule_bug+0x57/0x5c
[   54.625675]  [<ffffffff81384141>] schedule+0xe5/0x832
[   54.625679]  [<ffffffff81163e77>] ? put_dec+0x20/0x3c
[   54.625682]  [<ffffffff81384dd4>] schedule_timeout+0x275/0x29f
[   54.625686]  [<ffffffff810455e1>] ? process_timeout+0x0/0xb
[   54.625688]  [<ffffffff81384e17>] schedule_timeout_uninterruptible+0x19/0x1b
[   54.625691]  [<ffffffff81045893>] msleep+0x16/0x1d
[   54.625695]  [<ffffffff812a2e53>] i9xx_crtc_dpms+0x273/0x2ae
[   54.625698]  [<ffffffff812a18be>] intel_crtc_dpms+0x28/0xe7
[   54.625702]  [<ffffffff811ec0fa>] drm_helper_disable_unused_functions+0xf0/0x118
[   54.625705]  [<ffffffff811ecde3>] drm_crtc_helper_set_config+0x644/0x7c8
[   54.625708]  [<ffffffff811f12dd>] ? drm_copy_field+0x40/0x50
[   54.625711]  [<ffffffff811ebca2>] drm_fb_helper_force_kernel_mode+0x3e/0x85
[   54.625713]  [<ffffffff811ebcf2>] drm_fb_helper_restore+0x9/0x24
[   54.625717]  [<ffffffff81290a41>] i915_driver_lastclose+0x2b/0x5c
[   54.625720]  [<ffffffff811f14a7>] drm_lastclose+0x44/0x2ad
[   54.625722]  [<ffffffff811f1ed2>] drm_release+0x5c6/0x609
[   54.625726]  [<ffffffff810d1275>] fput+0x109/0x1c7
[   54.625728]  [<ffffffff810ce5e4>] filp_close+0x61/0x6b
[   54.625731]  [<ffffffff810ce680>] sys_close+0x92/0xd4
[   54.625734]  [<ffffffff81002a2b>] system_call_fastpath+0x16/0x1b

v2: The spinlock is actually superfluous as access to open_count is
entirely serialised by drm_global_mutex and so can be dropped. The
count_lock spinlock instead appears to be used to protect access to
dev->buf_alloc and dev->buf_use.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agodrm/radeon/kms: allow FG_ALPHA_VALUE on r5xx
Marek Olšák [Wed, 11 Aug 2010 18:42:51 +0000 (04:42 +1000)]
drm/radeon/kms: allow FG_ALPHA_VALUE on r5xx

This is a CS checker fix. I need this for FP16 alpha-test.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agodrm/radeon/kms: another r6xx/r7xx CS checker fix
Alex Deucher [Wed, 11 Aug 2010 15:54:25 +0000 (11:54 -0400)]
drm/radeon/kms: another r6xx/r7xx CS checker fix

add default case for buffer formats

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Cc: Andre Maasikas <amaasikas@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agocan: add limit for nframes and clean up signed/unsigned variables
Oliver Hartkopp [Wed, 11 Aug 2010 23:12:35 +0000 (16:12 -0700)]
can: add limit for nframes and clean up signed/unsigned variables

This patch adds a limit for nframes as the number of frames in TX_SETUP and
RX_SETUP are derived from a single byte multiplex value by default.
Use-cases that would require to send/filter more than 256 CAN frames should
be implemented in userspace for complexity reasons anyway.

Additionally the assignments of unsigned values from userspace to signed
values in kernelspace and vice versa are fixed by using unsigned values in
kernelspace consistently.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Reported-by: Ben Hawkes <hawkes@google.com>
Acked-by: Urs Thuermann <urs.thuermann@volkswagen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 years agoDRM: Replace kmalloc/memset combos with kzalloc
Davidlohr Bueso [Wed, 11 Aug 2010 13:18:52 +0000 (09:18 -0400)]
DRM: Replace kmalloc/memset combos with kzalloc

Currently most, if not all, memory allocation in drm_bufs.c is followed by initializing the memory with 0.

Replace the use of kmalloc+memset with kzalloc.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agoFurther tidyup of raid6 naming in lib/raid6
NeilBrown [Wed, 11 Aug 2010 20:44:54 +0000 (06:44 +1000)]
Further tidyup of raid6 naming in lib/raid6

Rename raid6/raid6x86.h to raid6/x86.h
and modify some comments.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoMake lib/raid6/test build correctly.
NeilBrown [Wed, 11 Aug 2010 20:38:24 +0000 (06:38 +1000)]
Make lib/raid6/test build correctly.

Some bit-rot needs to be cleaned out.

Signed-off-by: NeilBrown <neilb@suse.de>
13 years agoAFS: Implement an autocell mount capability [ver #2]
wanglei [Wed, 11 Aug 2010 08:38:04 +0000 (09:38 +0100)]
AFS: Implement an autocell mount capability [ver #2]

Implement the ability for the root directory of a mounted AFS filesystem to
accept lookups of arbitrary directory names, to interpet the names as the names
of cells, to look the cell names up in the DNS for AFSDB records and to mount
the root.cell volume of the nominated cell on the pseudo-directory created by
lookup.

This facility is requested by passing:

-o autocell

to the mountpoint for which this is desired, usually the /afs mount.

To use this facility, a DNS upcall program is required for AFSDB records.  This
can be obtained from:

http://people.redhat.com/~dhowells/afs/dns.afsdb.c

It should be compiled with -lresolv and -lkeyutils and installed as, say:

/usr/sbin/dns.afsdb

Then the following line needs to be added to /sbin/request-key.conf:

create dns_resolver afsdb:* * /usr/sbin/dns.afsdb %k

This can be tested by mounting AFS, say:

insmod dns_resolver.ko
insmod af-rxrpc.ko
insmod kafs.ko rootcell=grand.central.org
mount -t afs "#grand.central.org:root.cell." /afs -o autocell

and doing:

ls /afs/grand.central.org/

which should show:

archive/  cvs/  doc/  local/  project/  service/  software/  user/  www/

if it works.

Signed-off-by: Wang Lei <wang840925@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
13 years agoDNS: If the DNS server returns an error, allow that to be cached [ver #2]
Wang Lei [Wed, 11 Aug 2010 08:37:58 +0000 (09:37 +0100)]
DNS: If the DNS server returns an error, allow that to be cached [ver #2]

If the DNS server returns an error, allow that to be cached in the DNS resolver
key in lieu of a value.  Userspace passes the desired error number as an option
in the payload:

"#dnserror=<number>"

Userspace must map h_errno from the name resolution routines to an appropriate
Linux error before passing it up.  Something like the following mapping is
recommended:

[HOST_NOT_FOUND] = ENODATA,
[TRY_AGAIN] = EAGAIN,
[NO_RECOVERY] = ECONNREFUSED,
[NO_DATA] = ENODATA,

in lieu of Linux errors specifically for representing name service errors.  The
filesystem must map these errors appropropriately before passing them to
userspace.  AFS is made to map ENODATA and EAGAIN to EDESTADDRREQ for the
return to userspace; ECONNREFUSED is allowed to stand as is.

The error can be seen in /proc/keys as a negative number after the description
of the key.  Compare, for example, the following key entries:

2f97238c I--Q--     1  53s 3f010000     0     0 dns_resol afsdb:grand.centrall.org: -61
338bfbbe I--Q--     1  59m 3f010000     0     0 dns_resol afsdb:grand.central.org: 37

If the error option is supplied in the payload, the main part of the payload is
discarded.  The key should have an expiry time set by userspace.

Signed-off-by: Wang Lei <wang840925@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
13 years agoNFS: Use kernel DNS resolver [ver #2]
Bryan Schumaker [Wed, 11 Aug 2010 08:37:53 +0000 (09:37 +0100)]
NFS: Use kernel DNS resolver [ver #2]

Use the kernel DNS resolver to translate hostnames to IP addresses.  Create a
new config option to choose between the legacy DNS resolver and the new
resolver.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
13 years agocifs: update README to include details about 'fsc' option
Suresh Jayaraman [Thu, 5 Aug 2010 13:22:21 +0000 (18:52 +0530)]
cifs: update README to include details about 'fsc' option

Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>