linux-drm-fsl-dcu.git
13 years agoacer-wmi: does not set persistence state by rfkill_init_sw_state
Lee, Chun-Yi [Mon, 28 Mar 2011 08:52:02 +0000 (16:52 +0800)]
acer-wmi: does not set persistence state by rfkill_init_sw_state

Acer BIOS keeps devices state when system reboot, but reset to default
device states (Wlan on, Bluetooth off, wwan on) if system cold boot.
That means BIOS's initial state is not always real persistence.

So, removed rfkill_init_sw_state because it sets initial state to
persistence then replicate to other new killswitch when rfkill-input
enabled.
After removed it, acer-wmi set initial soft-block state after rfkill
register, and doesn't allow set_block until rfkill initial finished.

Reference: bko#31002
https://bugzilla.kernel.org/show_bug.cgi?id=31002

Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: OldÅ\99ich JedliÄ\8dka <oldium.pro@seznam.cz>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoplatform-drivers: x86: fix common misspellings
Lucas De Marchi [Thu, 17 Mar 2011 20:18:22 +0000 (17:18 -0300)]
platform-drivers: x86: fix common misspellings

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoacer-wmi: use pr_<level> for messages
Lee, Chun-Yi [Wed, 16 Mar 2011 10:52:36 +0000 (18:52 +0800)]
acer-wmi: use pr_<level> for messages

acer-wmi: use pr_<level> for messages

Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: potential NULL dereference in show_call()
Dan Carpenter [Tue, 15 Mar 2011 07:07:37 +0000 (10:07 +0300)]
asus-wmi: potential NULL dereference in show_call()

In the earlier check we assumed that "obj" could be NULL.  I looked at
some of the other places that call evaluate_object() and they check
for NULL as well.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: signedness bug in read_brightness()
Dan Carpenter [Tue, 15 Mar 2011 07:06:23 +0000 (10:06 +0300)]
asus-wmi: signedness bug in read_brightness()

"err" needs to be signed for the error handling to work.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoplatform-driver-x86: samsung-laptop: make dmi_check_cb to return 1 instead of 0
Axel Lin [Mon, 14 Mar 2011 10:56:18 +0000 (18:56 +0800)]
platform-driver-x86: samsung-laptop: make dmi_check_cb to return 1 instead of 0

dmi_check_system() walks the table running matching functions until
someone returns non zero or we hit the end.

This patch makes dmi_check_cb to return 1 so dmi_check_system() return
immediately when a match is found.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoplatform-driver-x86: fix wrong merge for compal-laptop.c
Axel Lin [Mon, 14 Mar 2011 10:53:14 +0000 (18:53 +0800)]
platform-driver-x86: fix wrong merge for compal-laptop.c

I found the commit 80183a4b
"compal-laptop/fujitsu-laptop/msi-laptop: make dmi_check_cb to return 1 instead of 0"
has wrong patch merge.

The original patch change the return value for dmi_check_cb():
https://lkml.org/lkml/2010/7/2/88
But commit 80183a4b changed the return value for set_backlight_level.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agomsi-laptop: use pr_<level> for messages
Joey Lee [Wed, 16 Mar 2011 07:55:19 +0000 (01:55 -0600)]
msi-laptop: use pr_<level> for messages

msi-laptop: use pr_<level> for messages

Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoPlatform: add Samsung Laptop platform driver
Greg Kroah-Hartman [Fri, 11 Mar 2011 17:41:19 +0000 (12:41 -0500)]
Platform: add Samsung Laptop platform driver

This adds the samsung-laptop driver to the kernel.  It now supports
all known Samsung laptops that use the SABI interface.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoacer-wmi: Fix WMI ID
Pali Rohár [Fri, 11 Mar 2011 17:36:43 +0000 (12:36 -0500)]
acer-wmi: Fix WMI ID

This patch change WMI ID to upper characters. With this patch module
acer-wmi is automatically loaded when WMI ID is detected.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoacer-wmi: deactive mail led when power off
Pali Rohár [Sat, 26 Feb 2011 20:18:58 +0000 (21:18 +0100)]
acer-wmi: deactive mail led when power off

This patch deactive mail led when laptop is going to hibernete/suspend
or power off. After resume from hibernate/suspend correctly restore
mail led state.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agomsi-laptop: send out touchpad on/off key
Lee, Chun-Yi [Mon, 7 Mar 2011 07:46:28 +0000 (15:46 +0800)]
msi-laptop: send out touchpad on/off key

MSI BIOS's raw behavior is send out KEY_TOUCHPAD_TOGGLE key when user
pressed touchpad hotkey.

Actually, we can capture the real touchpad status by read 0xE4 EC address
on MSI netbook/notebook. So, add msi-laptop input device for send out
KEY_TOUCHPAD_ON or KEY_TOUCHPAD_OFF key when user pressed Fn+F3 touchpad
hotkey. It leave userland applications to know the real touchpad status.

Tested on MSI netbook U-100, U-115, U160(N051), U160DX, N014, N034
Tested on MSI notebook CR620

Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoacer-wmi: set the touchpad toggle key code to KEY_TOUCHPAD_TOGGLE
Lee, Chun-Yi [Tue, 1 Mar 2011 17:07:11 +0000 (01:07 +0800)]
acer-wmi: set the touchpad toggle key code to KEY_TOUCHPAD_TOGGLE

Set the touchpad toggle key code from F22 to KEY_TOUCHPAD_TOGGLE,
and userspace should use udev's key re-mapping facilities while X
is unable to process keycodes above 255 to adjust to the keycode.

Cc: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoplatform-driver-x86: intel_mid_thermal: fix unterminated platform_device_id table
Axel Lin [Sat, 26 Feb 2011 15:03:34 +0000 (23:03 +0800)]
platform-driver-x86: intel_mid_thermal: fix unterminated platform_device_id table

The platform_device_id table is supposed to be zero-terminated.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: potential null dereference
Dan Carpenter [Sun, 27 Feb 2011 14:13:25 +0000 (17:13 +0300)]
sony-laptop: potential null dereference

In the original code, if "device_enum" was NULL then it would
dereference it when it printed the error message.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: handle allocation failures
Dan Carpenter [Sat, 26 Feb 2011 12:55:24 +0000 (15:55 +0300)]
sony-laptop: handle allocation failures

Return -ENOMEM if kzalloc() fails.  The callers already handle error
returns.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: return negative on failure in sony_nc_add()
Dan Carpenter [Sat, 26 Feb 2011 12:54:57 +0000 (15:54 +0300)]
sony-laptop: return negative on failure in sony_nc_add()

There were two places in sony_nc_add() where we returned zero on failure
instead of a negative error code.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: make a couple variables static
Dan Carpenter [Sat, 26 Feb 2011 12:54:27 +0000 (15:54 +0300)]
sony-laptop: make a couple variables static

Sparse complains that these variables should be static.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: set the touchpad toggle key code to KEY_TOUCHPAD_TOGGLE
Keng-Yu Lin [Tue, 1 Mar 2011 04:56:13 +0000 (12:56 +0800)]
eeepc-wmi: set the touchpad toggle key code to KEY_TOUCHPAD_TOGGLE

Signed-off-by: Keng-Yu Lin <keng-yu.lin@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoideapad: read brightness setting on brightness key notify
Ike Panhc [Wed, 23 Feb 2011 13:39:59 +0000 (21:39 +0800)]
ideapad: read brightness setting on brightness key notify

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=25922
On ideapad Y530, the brightness key notify will be blocked if the last notify
is not responsed by getting the brightness value. Read value when we get the
notify shall fix the problem and will not have any difference on other ideapads.

Signed-off-by: Ike Panhc <ike.pan@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: kconfig changes to fix build errors
Randy Dunlap [Tue, 22 Feb 2011 21:47:35 +0000 (13:47 -0800)]
eeepc-wmi: kconfig changes to fix build errors

Fix eeepc-wmi build when CONFIG_HOTPLUG_PCI is not enabled:

eeepc-wmi.c:(.text+0x3bc5e9): undefined reference to `pci_hp_deregister'
eeepc-wmi.c:(.text+0x3bcca4): undefined reference to `__pci_hp_register'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: restore KEY_CAMERA_* keys lost in 190ca27
Corentin Chary [Sat, 26 Feb 2011 09:20:43 +0000 (10:20 +0100)]
eeepc-wmi: restore KEY_CAMERA_* keys lost in 190ca27

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: add hwmon interface and pwm1
Corentin Chary [Sat, 26 Feb 2011 09:20:42 +0000 (10:20 +0100)]
asus-wmi: add hwmon interface and pwm1

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: add some common device ids and method ids
Corentin Chary [Sat, 26 Feb 2011 09:20:41 +0000 (10:20 +0100)]
asus-wmi: add some common device ids and method ids

I also found some leds ids (0x00020011-0x00020016 and 0x00040015),
but since they are not really present on the notebook,
I can't guess their name .

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-nb-wmi: Asus Notebooks WMI Driver
Corentin Chary [Sat, 26 Feb 2011 09:20:40 +0000 (10:20 +0100)]
asus-nb-wmi: Asus Notebooks WMI Driver

Introduce a new driver for Asus Notebooks shipped with
a WMI device instead of the old ACPI device. The WMI
device is almost the same as the one present in Eee PC,
but the event guid and the keymap are different.

The keymap comes from asus-laptop module.

On Asus notebooks, when you call the WMI device, you always
need a 64bit buffer, even if you only want to get the state
of a device (tested on a G73).

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: allow debugfs interface to call arbitrary method
Corentin Chary [Sat, 26 Feb 2011 09:20:39 +0000 (10:20 +0100)]
asus-wmi: allow debugfs interface to call arbitrary method

Also add some # format flags to debugfs output.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: add calls to INIT, SPEC and SFUN on init
Corentin Chary [Sat, 26 Feb 2011 09:20:38 +0000 (10:20 +0100)]
asus-wmi: add calls to INIT, SPEC and SFUN on init

INIT() call is needed to enable hotkeys on G73
SPEC() and SFUN() allow us to know more about
available features.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: fix and clean backlight code
Corentin Chary [Sat, 26 Feb 2011 09:20:37 +0000 (10:20 +0100)]
asus-wmi: fix and clean backlight code

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: try to guess the right DSTS methods
Corentin Chary [Sat, 26 Feb 2011 09:20:36 +0000 (10:20 +0100)]
asus-wmi: try to guess the right DSTS methods

This is tricky, new WMI aware notebooks seems to use
0x53545344 while Eee PCs are using 0x53544344. But there
is no way to know if there is an Eee PC in that wild that is
using 0x53545344 or a notebook using 0x53544344. So the
driver try to guess the available DSTS method ... But most Eee PCs
never return 0xFFFFFFFE when a method is not available, they return
0 instead (and that's useless).

So, first, try 0x53544344 then 0x53545344. We will find
a better way when we got more data.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: factorise wmi_evaluate_method call
Corentin Chary [Sat, 26 Feb 2011 09:20:35 +0000 (10:20 +0100)]
asus-wmi: factorise wmi_evaluate_method call

This patch create a single function to call the
WMI methods. This function handle inexistent methods (when
implemented by the WMI devices, and this is not the case on
Eee PCs), ACPI errors, etc..

Also pack struct bios_arg, and make sure that we always send
a 64bit buffer when calling a WMI method, because this is
needed on Asus notebooks.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: handle "unknown status" bit
Corentin Chary [Sat, 26 Feb 2011 09:20:34 +0000 (10:20 +0100)]
asus-wmi: handle "unknown status" bit

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: introduce struct asus_rfkill
Corentin Chary [Sat, 26 Feb 2011 09:20:33 +0000 (10:20 +0100)]
asus-wmi: introduce struct asus_rfkill

First, this allow use to remove the custom asusrfkill_wlan_query,
but this will also allow us to give struct asus_wmi * to
get_devstate/set_devstate later.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: minor cleanups
Corentin Chary [Sat, 26 Feb 2011 09:20:32 +0000 (10:20 +0100)]
asus-wmi: minor cleanups

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: asus generic asus-wmi.ko module
Corentin Chary [Sat, 26 Feb 2011 09:20:31 +0000 (10:20 +0100)]
eeepc-wmi: asus generic asus-wmi.ko module

New Asus notebooks are using a WMI device similar to
the one used in Eee PCs. Since we don't want to load
eeepc-wmi module on Asus notebooks, and we want to
keep the eeepc-wmi module for backward compatibility,
this patch introduce a new module, named asus-wmi, that
will be used by eeepc-wmi and the new Asus Notebook WMI
Driver.

eeepc-wmi's input device strings (device name and phys)
are kept, but rfkill and led names are changed (s/eeepc/asus/).
This should not break anything since rfkill are used by type or
index, not by name, and the eeepc::touchpad led wasn't working
correctly before 2.6.39 anyway.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-wmi: move generic code to asus-wmi
Corentin Chary [Sat, 26 Feb 2011 09:20:30 +0000 (10:20 +0100)]
asus-wmi: move generic code to asus-wmi

New Asus notebooks are using a WMI device similar to
the one used in Eee PCs. Since we don't want to load
a module named eeepc-laptop on Asus Notebooks, start by
copying all the code to asus-wmi.c.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agomedfield: Add Thermal Driver
Durgadoss R [Sun, 20 Feb 2011 17:35:43 +0000 (23:05 +0530)]
medfield: Add Thermal Driver

This is the basic thermal sensor driver for Intel MID platform using the
Medfield chipset. It plugs in via the thermal drivers and provides sensor
readings for the device sensors.

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: add rfkill support for wireless query 0x1b
Anssi Hannula [Sun, 20 Feb 2011 18:07:26 +0000 (20:07 +0200)]
hp-wmi: add rfkill support for wireless query 0x1b

Some recent HP laptops use a new wireless query command type 0x1b.

Add support for it. Tested on HP Mini 5102.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: make rfkill initialization failure non-fatal
Anssi Hannula [Sun, 20 Feb 2011 18:07:25 +0000 (20:07 +0200)]
hp-wmi: make rfkill initialization failure non-fatal

hp_wmi_rfkill_setup cleans up after itself now, so failing completely is
no longer necessary.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: clear rfkill device pointers when appropriate
Anssi Hannula [Sun, 20 Feb 2011 18:07:24 +0000 (20:07 +0200)]
hp-wmi: clear rfkill device pointers when appropriate

NULLify rfkill pointers during initialization. This prevents dereference
of invalid pointer in case the driver is rebound and some rfkill device
isn't detected anymore. Clear them also in hp_wmi_rfkill_setup failure
path so that an rfkill initialization failure doesn't need to be fatal
for the whole driver.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: split rfkill initialization out of hp_wmi_bios_setup
Anssi Hannula [Sun, 20 Feb 2011 18:07:23 +0000 (20:07 +0200)]
hp-wmi: split rfkill initialization out of hp_wmi_bios_setup

Split initialization of rfkill devices from hp_wmi_bios_setup() to
hp_wmi_rfkill_setup(). This makes the code somewhat cleaner, especially
with the future command 0x1b rfkill support.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: allow setting input and output buffer sizes separately
Anssi Hannula [Sun, 20 Feb 2011 18:07:22 +0000 (20:07 +0200)]
hp-wmi: allow setting input and output buffer sizes separately

Split buffersize parameter of hp_wmi_perform_query to insize and
outsize. Existing callers are changed to use the same value for insize
and outsize to avoid any regressions, with the exception of
hp_wmi_set_block where the output buffer is unused and therefore outsize
is set to 0 (this change is not seen by BIOS code).

The maximum input buffer size is kept at 4 bytes as per struct
bios_args. Some commands exist that take longer buffers, but they
haven't been implemented. The data portion of bios_args can be trivially
made dynamically allocated later when such larger buffers become needed.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: remove a variable that is never read
Anssi Hannula [Sun, 20 Feb 2011 18:07:21 +0000 (20:07 +0200)]
hp-wmi: remove a variable that is never read

Remove the status variable from hp_wmi_perform_query which holds the
return value from wmi_evaluate_method(). It is never checked as the
function bails out if the output buffer hasn't been allocated which
indicates the call failed.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agohp-wmi: check query return value in hp_wmi_perform_query
Anssi Hannula [Sun, 20 Feb 2011 18:07:20 +0000 (20:07 +0200)]
hp-wmi: check query return value in hp_wmi_perform_query

Check BIOS provided return value code in hp_wmi_perform_query and print
a warning on error. Printing is suppressed for HPWMI_RET_UNKNOWN_CMDTYPE
which is returned when the command type is unsupported.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: implement new backlight control method
Mattia Dongili [Sat, 19 Feb 2011 02:52:32 +0000 (11:52 +0900)]
sony-laptop: implement new backlight control method

Reasonably recent Vaios have a 0x12f or 0x137 handler that exposes a
fine lid backlight regulation with values ranging from 0 to 255.
The patch is based on findings and code from Javier Achirica
<achirica@gmail.com> and Marco Chiappero <marco@absence.it>

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: implement keyboard backlight support
Mattia Dongili [Sat, 19 Feb 2011 02:52:31 +0000 (11:52 +0900)]
sony-laptop: implement keyboard backlight support

Recent Vaios have the opportunity to control the keyboard backlight via
ACPI calls to the SNC device.
Introduce two module parameters to control how keyboard backlight should
be set at module loading (default to on and with 10 seconds timeout).

Tested-by: Marco Chiappero <marco@absence.it>
Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: cache handles and report them via sysfs
Mattia Dongili [Sat, 19 Feb 2011 02:52:30 +0000 (11:52 +0900)]
sony-laptop: cache handles and report them via sysfs

Avoid calling into acpi each time we need to lookup a method handle
and report the available handles to ease collection of information when
debugging issues. Also move initialization of the platform driver
earlier to allow adding files from other setup functions.

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: remove unused Type4 define
Mattia Dongili [Sat, 19 Feb 2011 02:52:29 +0000 (11:52 +0900)]
sony-laptop: remove unused Type4 define

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: use pr_<level> for messages
Mattia Dongili [Sat, 19 Feb 2011 02:52:28 +0000 (11:52 +0900)]
sony-laptop: use pr_<level> for messages

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: ignore hard switch rfkill events (SPIC)
Mattia Dongili [Sat, 19 Feb 2011 02:52:27 +0000 (11:52 +0900)]
sony-laptop: ignore hard switch rfkill events (SPIC)

There is not much use for these events in userspace and handling the
events themselves seems to get in the way of the actual activation of
the rf devices. The SNC device doesn't expose them already.
https://bugzilla.kernel.org/show_bug.cgi?id=15303

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: documentation updates
Mattia Dongili [Sat, 19 Feb 2011 02:52:26 +0000 (11:52 +0900)]
sony-laptop: documentation updates

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agosony-laptop: add some debug printk useful for bug reports
Mattia Dongili [Sat, 19 Feb 2011 02:52:25 +0000 (11:52 +0900)]
sony-laptop: add some debug printk useful for bug reports

Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoplatform/x86: intel_mid_powerbutton needs INPUT
Randy Dunlap [Wed, 16 Feb 2011 22:31:02 +0000 (14:31 -0800)]
platform/x86: intel_mid_powerbutton needs INPUT

intel_mid_powerbtn.c uses input interfaces, so it should depend
on INPUT to fix build errors when CONFIG_INPUT is not enabled:

intel_mid_powerbtn.c:(.text+0x56ca8f): undefined reference to `input_event'
intel_mid_powerbtn.c:(.devinit.text+0x2e7b4): undefined reference to `input_allocate_device'
intel_mid_powerbtn.c:(.devinit.text+0x2e7ff): undefined reference to `input_set_capability'
intel_mid_powerbtn.c:(.devinit.text+0x2e84a): undefined reference to `input_register_device'
intel_mid_powerbtn.c:(.devinit.text+0x2e88b): undefined reference to `input_free_device'
intel_mid_powerbtn.c:(.devexit.text+0x42f0): undefined reference to `input_unregister_device'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Hong Liu <hong.liu@intel.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoEnable Dell All-In-One volume up/down keys
Colin Ian King [Thu, 17 Feb 2011 18:44:09 +0000 (18:44 +0000)]
Enable Dell All-In-One volume up/down keys

Enable volume up and down hotkeys on WMI events
GUID 284A0E6B-380E-472A-921F-E52786257FB4 and
GUID 02314822-307C-4F66-bf0E-48AEAEB26CC8.

Also works around a firmware bug where the _WED method
should return an integer containing the key code and in fact
the method returns the key code in element zero of a buffer.

BugLink: http://bugs.launchpad.net/bugs/701530
BugLink: http://bugs.launchpad.net/bugs/676997
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agointel_mid_powerbtn: add power button driver for Medfield platform (#3)
Hong Liu [Mon, 7 Feb 2011 19:45:55 +0000 (14:45 -0500)]
intel_mid_powerbtn: add power button driver for Medfield platform (#3)

The power button is connected to MSIC on Medfield, we will get two
interrupts from IOAPIC when pressing or releasing the power button.

Signed-off-by: Hong Liu <hong.liu@intel.com>
[Minor fixes as noted by Dmitry]
Signed-off-by: Alan Cox <alan@linux.intel.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add camera keys
Corentin Chary [Sun, 6 Feb 2011 12:30:47 +0000 (13:30 +0100)]
eeepc-wmi: add camera keys

These keys are supposed to be handled by any software
using the camera (like webKam or cheese...). They can
also be used to actually move the camera when possible.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: reorder device ids
Corentin Chary [Sun, 6 Feb 2011 12:28:43 +0000 (13:28 +0100)]
eeepc-wmi: reorder device ids

Each device seems to be in a "group" (devid >> 16 & 0xFF).

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add touchpad sysfs file
Corentin Chary [Sun, 6 Feb 2011 12:28:42 +0000 (13:28 +0100)]
eeepc-wmi: add touchpad sysfs file

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-laptop: remove deprecated interfaces (lcd_switch and display_get)
Corentin Chary [Sun, 6 Feb 2011 12:27:31 +0000 (13:27 +0100)]
asus-laptop: remove deprecated interfaces (lcd_switch and display_get)

I should have done that one year ago, so it's more than
time to do it.

These two features use non-standard interfaces. There are the
only features that really need multiple path to guess what's
the right method name on a specific laptop.

Removing them allow to remove a lot of code an significantly
clean the driver.

This will affect the backlight code which won't be able to know
if the backlight is on or off.

The platform display file will also be write only (like the one
in eeepc-laptop).

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoasus-laptop: let WLED alone on L1400B
Corentin Chary [Sun, 6 Feb 2011 12:27:30 +0000 (13:27 +0100)]
asus-laptop: let WLED alone on L1400B

Asus took the DSDT from another model (L84F), made some change
to make it work, but forgot to remove WLED method (the laptop
doesn't have a wireless card). They even didn't change the model
name.

ref: https://bugzilla.kernel.org/show_bug.cgi?id=25712

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: comments keymap to clarify the meaning of some keys
Corentin Chary [Sun, 6 Feb 2011 12:30:48 +0000 (13:30 +0100)]
eeepc-wmi: comments keymap to clarify the meaning of some keys

Found while checking PDF manuals...

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: real touchpad led device id is 0x001000012
Corentin Chary [Sun, 6 Feb 2011 12:28:41 +0000 (13:28 +0100)]
eeepc-wmi: real touchpad led device id is 0x001000012

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: respect wireless_hotplug setting
Corentin Chary [Sun, 6 Feb 2011 12:28:40 +0000 (13:28 +0100)]
eeepc-wmi: respect wireless_hotplug setting

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: support backlight power (bl_power) attribute
Corentin Chary [Sun, 6 Feb 2011 12:28:39 +0000 (13:28 +0100)]
eeepc-wmi: support backlight power (bl_power) attribute

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: set the right key code for 0xe9
Corentin Chary [Sun, 6 Feb 2011 12:28:38 +0000 (13:28 +0100)]
eeepc-wmi: set the right key code for 0xe9

This key should power off the backlight, not the display,
it is also used in acpi/video.c to do the same thing.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add wimax support
Corentin Chary [Sun, 6 Feb 2011 12:28:37 +0000 (13:28 +0100)]
eeepc-wmi: add wimax support

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add camera and card reader support
Corentin Chary [Sun, 6 Feb 2011 12:28:36 +0000 (13:28 +0100)]
eeepc-wmi: add camera and card reader support

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: use the presence bit correctly
Corentin Chary [Sun, 6 Feb 2011 12:28:35 +0000 (13:28 +0100)]
eeepc-wmi: use the presence bit correctly

I checked some more DSDT, and it seems that I wasn't
totally right about the meaning of DSTS return value.
Bit 0 is clearly the status of the device, and I discovered
that bit 16 is set when the device is present.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: reorder defines
Corentin Chary [Sun, 6 Feb 2011 12:28:34 +0000 (13:28 +0100)]
eeepc-wmi: reorder defines

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: switch to platform_create_bundle()
Corentin Chary [Sun, 6 Feb 2011 12:28:33 +0000 (13:28 +0100)]
eeepc-wmi: switch to platform_create_bundle()

This allow to remove ~30 lines of code.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add hibernate/resume callbacks
Corentin Chary [Sun, 6 Feb 2011 12:28:32 +0000 (13:28 +0100)]
eeepc-wmi: add hibernate/resume callbacks

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add an helper using simple return codes
Corentin Chary [Sun, 6 Feb 2011 12:28:31 +0000 (13:28 +0100)]
eeepc-wmi: add an helper using simple return codes

eeepc_wmi_get_devstate returns an acpi_status, so each
call need extra logic to handle the return code. This
patch add a simple getter, returning a boolean (or a
negative error code).

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: return proper error code in eeepc_rfkill_set()
Corentin Chary [Sun, 6 Feb 2011 12:28:30 +0000 (13:28 +0100)]
eeepc-wmi: return proper error code in eeepc_rfkill_set()

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: serialize access to wmi method
Corentin Chary [Sun, 6 Feb 2011 12:28:29 +0000 (13:28 +0100)]
eeepc-wmi: serialize access to wmi method

\AMW0.WMBC, which is the main method that we use,
is not reentrant. When wireless hotpluging is enabled,
toggling the status of the wireless device using WMBC will
trigger a notification and the notification handler need to
call WMBC again to get the new status of the device, this
will trigger the following error:

ACPI Error (dswload-0802): [_T_0] Namespace lookup failure, AE_ALREADY_EXISTS
ACPI Exception: AE_ALREADY_EXISTS, During name lookup/catalog (20100428/psloop-231)
ACPI Error (psparse-0537): Method parse/execution failed [\AMW0.WMBC] (Node f7023b88), AE_ALREADY_EXISTS
ACPI: Marking method WMBC as Serialized because of AE_ALREADY_EXISTS error

Since there is currently no way to tell the acpi subsystem to mark
a method as serialized, we do it in eeepc-wmi.

Of course, we could let the first call fail, and then it would work,
but it doesn't seems really clean, and it will make the first
WMBC call return a random value.

This patch was tested on EeePc 1000H with a RaLink RT2860
wireless card using the rt2800pci driver. rt2860sta driver
seems to deadlock when we remove the pci device...

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add hotplug code for Eeepc 1000H
Corentin Chary [Sun, 6 Feb 2011 12:28:28 +0000 (13:28 +0100)]
eeepc-wmi: add hotplug code for Eeepc 1000H

Implement wireless like hotplug handling (code stolen from eeepc-laptop).

Reminder: on some models rfkill is implemented by logically unplugging the
wireless card from the PCI bus. Despite sending ACPI notifications, this does
not appear to be implemented using standard ACPI hotplug - nor does the
firmware provide the _OSC method required to support native PCIe hotplug.
The only sensible choice appears to be to handle the hotplugging directly in
the platform driver.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: add wlan key found on 1015P
Corentin Chary [Sun, 6 Feb 2011 12:28:27 +0000 (13:28 +0100)]
eeepc-wmi: add wlan key found on 1015P

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoeeepc-wmi: reorder keymap
Corentin Chary [Sun, 6 Feb 2011 12:28:26 +0000 (13:28 +0100)]
eeepc-wmi: reorder keymap

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoOLPC XO-1.5 ebook switch driver
Paul Fox [Thu, 3 Feb 2011 16:27:55 +0000 (16:27 +0000)]
OLPC XO-1.5 ebook switch driver

The OLPC XO-1.5 has an ebook switch, triggered when the laptop
screen is rotated then folding down, converting the device into ebook
form.

This switch is exposed through ACPI. Add a driver that exposes it
to userspace as an input device.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
13 years agoBtrfs: fix __btrfs_map_block on 32 bit machines
Chris Mason [Mon, 28 Mar 2011 01:23:21 +0000 (21:23 -0400)]
Btrfs: fix __btrfs_map_block on 32 bit machines

Recent changes for discard support didn't compile,
this fixes them not to try and % 64 bit numbers.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: fix possible deadlock by clearing __GFP_FS flag
Miao Xie [Sun, 27 Mar 2011 08:07:36 +0000 (16:07 +0800)]
btrfs: fix possible deadlock by clearing __GFP_FS flag

Using the GFP_HIGHUSER_MOVABLE flag to allocate the metadata's page may cause
deadlock.
  Task1
  open()
    ...
    btrfs_search_slot()
      ...
      btrfs_cow_block()
...
alloc_page()
  wait for reclaiming
shrink_slab()
  ...
  shrink_icache_memory()
    ...
    btrfs_evict_inode()
      ...
      btrfs_search_slot()

If the path is locked by task1, the deadlock happens.

So the btree's page cache is different with the file's page cache, it can not
allocate pages by GFP_HIGHUSER_MOVABLE flag, we must clear __GFP_FS flag in
GFP_HIGHUSER_MOVABLE flag.

Reported-by: Itaru Kitayama <kitayama@cl.bb4u.ne.jp>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: check link counter overflow in link(2)
Al Viro [Fri, 4 Mar 2011 17:15:18 +0000 (17:15 +0000)]
btrfs: check link counter overflow in link(2)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: don't mess with i_nlink of unlocked inode in rename()
Al Viro [Fri, 4 Mar 2011 17:14:37 +0000 (17:14 +0000)]
btrfs: don't mess with i_nlink of unlocked inode in rename()

old_inode is not locked; it's not safe to play with its link
count.  Instead of bumping it and calling btrfs_unlink_inode(),
add a variant of the latter that does not do btrfs_drop_nlink()/
btrfs_update_inode(), call it instead of btrfs_inc_nlink()/
btrfs_unlink_inode() and do btrfs_update_inode() ourselves.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: check return value of btrfs_alloc_path()
Tsutomu Itoh [Tue, 1 Mar 2011 06:48:31 +0000 (06:48 +0000)]
Btrfs: check return value of btrfs_alloc_path()

Adding the check on the return value of btrfs_alloc_path() to several places.
And, some of callers are modified by this change.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: fix OOPS of empty filesystem after balance
liubo [Mon, 7 Mar 2011 02:13:14 +0000 (02:13 +0000)]
Btrfs: fix OOPS of empty filesystem after balance

btrfs will remove unused block groups after balance.
When a empty filesystem is balanced, the block group with tag "DATA" may be
dropped, and after umount and mount again, it will not find "DATA" space_info
and lead to OOPS.
So we initial the necessary space_infos(DATA, SYSTEM, METADATA) to avoid OOPS.

Reported-by: Daniel J Blueman <daniel.blueman@gmail.com>
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: fix memory leak of empty filesystem after balance
liubo [Mon, 7 Mar 2011 02:13:33 +0000 (02:13 +0000)]
Btrfs: fix memory leak of empty filesystem after balance

After Josef's patch(commit 3c14874acc71180553fb5aba528e3cf57c5b958b),
btrfs will exclude super bytes when reading block groups(by marking a extent
state UPTODATE).  However, these bytes do not get freed while balance remove
unused block groups, and we won't process those removed ones any more, when
we do umount and unload the btrfs module,  btrfs hits a memory leak.

This patch add the missing free operation.

Reproduce steps:
$ mkfs.btrfs disk
$ mount disk /mnt/btrfs -o loop
$ btrfs filesystem balance /mnt/btrfs
$ umount /mnt/btrfs
$ rmmod btrfs

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: fix return value of setflags ioctl
liubo [Thu, 24 Feb 2011 09:38:16 +0000 (09:38 +0000)]
Btrfs: fix return value of setflags ioctl

setflags ioctl should return error when any checks fail.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: fix uncheck memory allocations
Yoshinori Sano [Tue, 15 Feb 2011 12:01:42 +0000 (12:01 +0000)]
Btrfs: fix uncheck memory allocations

To make Btrfs code more robust, several return value checks where memory
allocation can fail are introduced. I use BUG_ON where I don't know how
to handle the error properly, which increases the number of using the
notorious BUG_ON, though.

Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: make inode ref log recovery faster
liubo [Sat, 26 Mar 2011 12:01:12 +0000 (08:01 -0400)]
btrfs: make inode ref log recovery faster

When we recover from crash via write-ahead log tree and process
the inode refs, for each btrfs_inode_ref item, we will
1) check if we already have a perfect match in fs/file tree, if
   we have, then we're done.
2) search the corresponding back reference in fs/file tree, and
   check all the names in this back reference to see if they are
   also in the log to avoid conflict corners.
3) recover the logged inode refs to fs/file tree.

In current btrfs, however,
- for 2)'s check, once is enough, since the checked back reference
  will remain unchanged after processing all the inode refs belonged
  to the key.
- it has no need to do another 1) between 2) and 3).

I've made a small test to show how it improves,

$dd if=/dev/zero of=foobar bs=4K count=1
$sync
$make 100 hard links continuously, like ln foobar link_i
$fsync foobar
$echo b > /proc/sysrq-trigger
after reboot
$time mount DEV PATH

without patch:
real    0m0.285s
user    0m0.001s
sys     0m0.009s

with patch:
real    0m0.123s
user    0m0.000s
sys     0m0.010s

Changelog v1->v2:
- fix double free - pointed by David Sterba
Changelog v2->v3:
- adjust free order

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: add btrfs_trim_fs() to handle FITRIM
Li Dongyang [Thu, 24 Mar 2011 10:24:28 +0000 (10:24 +0000)]
Btrfs: add btrfs_trim_fs() to handle FITRIM

We take an free extent out from allocator, trim it, then put it back,
but before we trim the block group, we should make sure the block group is
cached, so plus a little change to make cache_block_group() run without a
transaction.

Signed-off-by: Li Dongyang <lidongyang@novell.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: adjust btrfs_discard_extent() return errors and trimmed bytes
Li Dongyang [Thu, 24 Mar 2011 10:24:27 +0000 (10:24 +0000)]
Btrfs: adjust btrfs_discard_extent() return errors and trimmed bytes

Callers of btrfs_discard_extent() should check if we are mounted with -o discard,
as we want to make fitrim to work even the fs is not mounted with -o discard.
Also we should use REQ_DISCARD to map the free extent to get a full mapping,
last we only return errors if
1. the error is not a EOPNOTSUPP
2. no device supports discard

Signed-off-by: Li Dongyang <lidongyang@novell.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: make btrfs_map_block() return entire free extent for each device of RAID0...
Li Dongyang [Thu, 24 Mar 2011 10:24:26 +0000 (10:24 +0000)]
Btrfs: make btrfs_map_block() return entire free extent for each device of RAID0/1/10/DUP

btrfs_map_block() will only return a single stripe length, but we want the
full extent be mapped to each disk when we are trimming the extent,
so we add length to btrfs_bio_stripe and fill it if we are mapping for REQ_DISCARD.

Signed-off-by: Li Dongyang <lidongyang@novell.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: make update_reserved_bytes() public
Li Dongyang [Thu, 24 Mar 2011 10:24:25 +0000 (10:24 +0000)]
Btrfs: make update_reserved_bytes() public

Make the function public as we should update the reserved extents calculations
after taking out an extent for trimming.

Signed-off-by: Li Dongyang <lidongyang@novell.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: return EXDEV when linking from different subvolumes
Mark Fasheh [Tue, 22 Mar 2011 17:20:26 +0000 (17:20 +0000)]
btrfs: return EXDEV when linking from different subvolumes

btrfs_link returns EPERM if a cross-subvolume link is attempted.

However, in this case I believe EXDEV to be the more appropriate value.
>From the link(2) man page:

EXDEV  oldpath and newpath are not on the same mounted file system.  (Linux
       permits a file system to be mounted at multiple points, but link()
       does not work across different mount points, even if the same file
       system is mounted on both.)

This matters because an application may have different behaviors based on
return codes.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: Per file/directory controls for COW and compression
Liu Bo [Tue, 22 Mar 2011 10:12:20 +0000 (10:12 +0000)]
Btrfs: Per file/directory controls for COW and compression

Data compression and data cow are controlled across the entire FS by mount
options right now.  ioctls are needed to set this on a per file or per
directory basis.  This has been proposed previously, but VFS developers
wanted us to use generic ioctls rather than btrfs-specific ones.

According to Chris's comment, there should be just one true compression
method(probably LZO) stored in the super.  However, before this, we would
wait for that one method is stable enough to be adopted into the super.
So I list it as a long term goal, and just store it in ram today.

After applying this patch, we can use the generic "FS_IOC_SETFLAGS" ioctl to
control file and directory's datacow and compression attribute.

NOTE:
 - The compression type is selected by such rules:
   If we mount btrfs with compress options, ie, zlib/lzo, the type is it.
   Otherwise, we'll use the default compress type (zlib today).

v1->v2:
- rebase to the latest btrfs.
v2->v3:
- fix a problem, i.e. when a file is set NOCOW via mount option, then this NOCOW
  will be screwed by inheritance from parent directory.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: add datacow flag in inode flag
liubo [Mon, 21 Mar 2011 08:54:27 +0000 (08:54 +0000)]
Btrfs: add datacow flag in inode flag

For datacow control, the corresponding inode flags are needed.
This is for btrfs use.

v1->v2:
Change FS_COW_FL to another bit due to conflict with the upstream e2fsprogs

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: use GFP_NOFS instead of GFP_KERNEL
Miao Xie [Thu, 24 Mar 2011 11:41:21 +0000 (11:41 +0000)]
btrfs: use GFP_NOFS instead of GFP_KERNEL

In the filesystem context, we must allocate memory by GFP_NOFS,
or we may start another filesystem operation and make kswap thread hang up.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: check return value of read_tree_block()
Tsutomu Itoh [Thu, 24 Mar 2011 06:33:21 +0000 (06:33 +0000)]
Btrfs: check return value of read_tree_block()

This patch is checking return value of read_tree_block(),
and if it is NULL, error processing.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agobtrfs: properly access unaligned checksum buffer
David Sterba [Fri, 18 Mar 2011 22:56:43 +0000 (22:56 +0000)]
btrfs: properly access unaligned checksum buffer

On Fri, Mar 18, 2011 at 11:56:53AM -0400, Chris Mason wrote:
> Thanks for fielding this one.  Does put_unaligned_le32 optimize away on
> platforms with efficient access?  It would be great if we didn't need
> the #ifdef.

(quicktest: assembly output is same for put_unaligned_le32 and direct
assignment on my x86_64)
I was originally following examples in
Documentation/unaligned-memory-access.txt. From other code it seems to me that
the define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is intended for larger
portions of code. Macros/wrappers for {put,get}_unaligned* are chosen via
arch/<arch>/include/asm/unaligned.h accordingly, therefore it's safe to use
put_unaligned_le32 without the ifdef.

dave

Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: cleanup some BUG_ON()
Tsutomu Itoh [Wed, 23 Mar 2011 08:14:16 +0000 (08:14 +0000)]
Btrfs: cleanup some BUG_ON()

This patch changes some BUG_ON() to the error return.
(but, most callers still use BUG_ON())

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: add initial tracepoint support for btrfs
liubo [Thu, 24 Mar 2011 11:18:59 +0000 (11:18 +0000)]
Btrfs: add initial tracepoint support for btrfs

Tracepoints can provide insight into why btrfs hits bugs and be greatly
helpful for debugging, e.g
              dd-7822  [000]  2121.641088: btrfs_inode_request: root = 5(FS_TREE), gen = 4, ino = 256, blocks = 8, disk_i_size = 0, last_trans = 8, logged_trans = 0
              dd-7822  [000]  2121.641100: btrfs_inode_new: root = 5(FS_TREE), gen = 8, ino = 257, blocks = 0, disk_i_size = 0, last_trans = 0, logged_trans = 0
 btrfs-transacti-7804  [001]  2146.935420: btrfs_cow_block: root = 2(EXTENT_TREE), refs = 2, orig_buf = 29368320 (orig_level = 0), cow_buf = 29388800 (cow_level = 0)
 btrfs-transacti-7804  [001]  2146.935473: btrfs_cow_block: root = 1(ROOT_TREE), refs = 2, orig_buf = 29364224 (orig_level = 0), cow_buf = 29392896 (cow_level = 0)
 btrfs-transacti-7804  [001]  2146.972221: btrfs_transaction_commit: root = 1(ROOT_TREE), gen = 8
   flush-btrfs-2-7821  [001]  2155.824210: btrfs_chunk_alloc: root = 3(CHUNK_TREE), offset = 1103101952, size = 1073741824, num_stripes = 1, sub_stripes = 0, type = DATA
   flush-btrfs-2-7821  [001]  2155.824241: btrfs_cow_block: root = 2(EXTENT_TREE), refs = 2, orig_buf = 29388800 (orig_level = 0), cow_buf = 29396992 (cow_level = 0)
   flush-btrfs-2-7821  [001]  2155.824255: btrfs_cow_block: root = 4(DEV_TREE), refs = 2, orig_buf = 29372416 (orig_level = 0), cow_buf = 29401088 (cow_level = 0)
   flush-btrfs-2-7821  [000]  2155.824329: btrfs_cow_block: root = 3(CHUNK_TREE), refs = 2, orig_buf = 20971520 (orig_level = 0), cow_buf = 20975616 (cow_level = 0)
 btrfs-endio-wri-7800  [001]  2155.898019: btrfs_cow_block: root = 5(FS_TREE), refs = 2, orig_buf = 29384704 (orig_level = 0), cow_buf = 29405184 (cow_level = 0)
 btrfs-endio-wri-7800  [001]  2155.898043: btrfs_cow_block: root = 7(CSUM_TREE), refs = 2, orig_buf = 29376512 (orig_level = 0), cow_buf = 29409280 (cow_level = 0)

Here is what I have added:

1) ordere_extent:
        btrfs_ordered_extent_add
        btrfs_ordered_extent_remove
        btrfs_ordered_extent_start
        btrfs_ordered_extent_put

These provide critical information to understand how ordered_extents are
updated.

2) extent_map:
        btrfs_get_extent

extent_map is used in both read and write cases, and it is useful for tracking
how btrfs specific IO is running.

3) writepage:
        __extent_writepage
        btrfs_writepage_end_io_hook

Pages are cirtical resourses and produce a lot of corner cases during writeback,
so it is valuable to know how page is written to disk.

4) inode:
        btrfs_inode_new
        btrfs_inode_request
        btrfs_inode_evict

These can show where and when a inode is created, when a inode is evicted.

5) sync:
        btrfs_sync_file
        btrfs_sync_fs

These show sync arguments.

6) transaction:
        btrfs_transaction_commit

In transaction based filesystem, it will be useful to know the generation and
who does commit.

7) back reference and cow:
btrfs_delayed_tree_ref
btrfs_delayed_data_ref
btrfs_delayed_ref_head
btrfs_cow_block

Btrfs natively supports back references, these tracepoints are helpful on
understanding btrfs's COW mechanism.

8) chunk:
btrfs_chunk_alloc
btrfs_chunk_free

Chunk is a link between physical offset and logical offset, and stands for space
infomation in btrfs, and these are helpful on tracing space things.

9) reserved_extent:
btrfs_reserved_extent_alloc
btrfs_reserved_extent_free

These can show how btrfs uses its space.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
13 years agoBtrfs: use RCU instead of a spinlock to protect the root node
Chris Mason [Wed, 23 Mar 2011 18:54:42 +0000 (14:54 -0400)]
Btrfs: use RCU instead of a spinlock to protect the root node

The pointer to the extent buffer for the root of each tree
is protected by a spinlock so that we can safely read the pointer
and take a reference on the extent buffer.

But now that the extent buffers are freed via RCU, we can safely
use rcu_read_lock instead.

Signed-off-by: Chris Mason <chris.mason@oracle.com>