platform/kernel/linux-3.10.git
9 years agodrm/exynos: Split manager/display/subdrv
Sean Paul [Fri, 25 Apr 2014 05:49:16 +0000 (14:49 +0900)]
drm/exynos: Split manager/display/subdrv

This patch splits display and manager from subdrv. The result is that
crtc functions can directly call into manager callbacks and encoder
functions can directly call into display callbacks. This will allow
us to remove the exynos_drm_hdmi shim and support mixer/hdmi & fimd/dp
with common code.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Use unsigned long for possible_crtcs
Sean Paul [Thu, 30 Jan 2014 21:19:11 +0000 (16:19 -0500)]
drm/exynos: Use unsigned long for possible_crtcs

Change all instances of possible_crtcs in the exynos drm driver to be
unsigned long. This matches the type used in the drm layer.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Don't keep dpms state in encoder
Sean Paul [Thu, 30 Jan 2014 21:19:10 +0000 (16:19 -0500)]
drm/exynos: Don't keep dpms state in encoder

This patch removes the dpms state tracking in encoder. This
state is at best confusing and at worst incorrect since the display
drivers can turn on and off without propagating the value.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Rename display_op power_on to dpms
Sean Paul [Thu, 24 Apr 2014 12:25:39 +0000 (21:25 +0900)]
drm/exynos: Rename display_op power_on to dpms

This patch renames the display_op power_on to dpms to accurately reflect
what the function does.

The side-effect of this patch is that the new hdmi dpms callback is now
invoked twice in the dpms path. This is safe and will be dealt with when
the exynos_drm shim goes away.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Remove dpms link between encoder/connector
Sean Paul [Thu, 24 Apr 2014 12:22:56 +0000 (21:22 +0900)]
drm/exynos: Remove dpms link between encoder/connector

This patch removes the call from encoder dpms into connector dpms (which
will then call back into encoder dpms through the helper function). The
callback is likely to keep connector->dpms in the right state when
initiating dpms from crtc or encoder, but this isn't the right way to do
it. This patch is the first step towards rationalizing power management
in the exynos drm driver.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Remove apply manager callback
Sean Paul [Fri, 25 Apr 2014 05:00:14 +0000 (14:00 +0900)]
drm/exynos: Remove apply manager callback

This patch removes the apply() manager callback in favor of putting the
relevant commits in the individual drivers. This will mitigate some of
the difference between the suspend/resume path and the dpms path

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Pass exynos_drm_manager in manager ops instead of dev
Sean Paul [Thu, 24 Apr 2014 12:03:56 +0000 (21:03 +0900)]
drm/exynos: Pass exynos_drm_manager in manager ops instead of dev

This patch changes the manager ops callbacks from accepting the subdrv
device pointer to taking a pointer to the manager. This will allow us
to move closer to decoupling manager/display from subdrv, and subsequently
decoupling the crtc/plane from the encoder.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: hdmi: Implement initialize op for hdmi
Sean Paul [Thu, 24 Apr 2014 11:44:39 +0000 (20:44 +0900)]
drm/exynos: hdmi: Implement initialize op for hdmi

This patch implements the initialize callback in the hdmi and mixer
manager. This allows us to get rid of drm_dev in the drm_hdmi level and
track it in the mixer and hdmi drivers. This is one of the things
holding back the complete removal of the drm_hdmi layer.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Use manager_op initialize in fimd
Sean Paul [Thu, 24 Apr 2014 11:41:20 +0000 (20:41 +0900)]
drm/exynos: Use manager_op initialize in fimd

This patch implements the intitialize manager op in fimd. This will
allow us to keep track of drm_dev in context instead of using subdev,
which in turn makes it easier to remove subdev from fimd.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Add an initialize function to manager and display
Sean Paul [Thu, 30 Jan 2014 21:19:03 +0000 (16:19 -0500)]
drm/exynos: Add an initialize function to manager and display

This patch adds an initialize function to the manager and display
operations. This allows them to keep track of drm_device in their
local context, as well as adds an initialization hook right after
the encoder is created.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Merge overlay_ops into manager_ops
Sean Paul [Thu, 24 Apr 2014 11:37:59 +0000 (20:37 +0900)]
drm/exynos: Merge overlay_ops into manager_ops

This patch merges overlay_ops into manager_ops. In all cases,
overlay_ops is implemented in the same place as manager ops, it doesn't
serve a functional purpose, and doesn't make things more clear.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: Remove useless slab.h include
Stephane Marchesin [Thu, 30 Jan 2014 21:19:01 +0000 (06:19 +0900)]
drm/exynos: Remove useless slab.h include

Signed-off-by: Stephane Marchesin <marcheu@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agodrm/exynos: add phy settings for RB resolutions
Shirish S [Thu, 13 Mar 2014 05:28:27 +0000 (14:28 +0900)]
drm/exynos: add phy settings for RB resolutions

This patch adds support for the below mentioned
pixel clocks in Exynos5250.
Without them, following display modes won¡¯t
be supported:

71 MHz  - 1280x800@60Hz RB
73.25 MHz  - 800x600@120Hz RB
88.75 MHz  - 1440x900@60Hz RB
115.5 MHz  - 1024x768@120Hz RB
119 MHz  - 1680x1050@60Hz RB

Signed-off-by: Shirish S <s.shirish@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agomisc: modem_if: fix section mismatch from tizen_modem.c
MyungJoo Ham [Mon, 28 Apr 2014 03:45:54 +0000 (12:45 +0900)]
misc: modem_if: fix section mismatch from tizen_modem.c

A function, modem_probe, had __init while it was used by
a struct that is not __init.

Change-Id: Ib1571c89b4bfcebc58b2669b669bd4606d1922fa
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
9 years agoarm: exynos4: Support machine specific reboot/poweroff for TRATS
Jonghwa Lee [Fri, 25 Apr 2014 01:23:53 +0000 (10:23 +0900)]
arm: exynos4: Support machine specific reboot/poweroff for TRATS

Change-Id: I086cf498da1f1fd38410e99cd250b0c4aeda1a09
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
9 years agoextcon: Move OF helper function to extcon core and change function name
Chanwoo Choi [Tue, 18 Mar 2014 11:31:33 +0000 (20:31 +0900)]
extcon: Move OF helper function to extcon core and change function name

This patch move simply OF helper function to extcon core and change function
name as following:
- of_extcon_get_extcon_dev() -> extcon_get_edev_by_phandle()

Change-Id: I37fd827f945e3d713cfe15607689eab6792007b1
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Felipe Balbi <balbi@ti.com>
9 years agoextcon: of: Remove unnecessary function call by using the name of device_node
Chanwoo Choi [Tue, 18 Mar 2014 10:09:41 +0000 (19:09 +0900)]
extcon: of: Remove unnecessary function call by using the name of device_node

This patch remove unnecessary function call in of_extcon_get_extcon_dev()
by using the name of device_node structure.

Change-Id: Ifae59614f355d1ad1beef9aab1c497840f22a727
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
9 years agotizen: update tizen_defconfig
Chanho Park [Fri, 25 Apr 2014 07:57:08 +0000 (16:57 +0900)]
tizen: update tizen_defconfig

Enable SEC_COMP and misc updates

Change-Id: I80e8011ded0007f88f7bea367c32d414abd47d52
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agomisc: modem_if: regress to old tizen modem driver
Chanho Park [Tue, 15 Apr 2014 04:42:22 +0000 (13:42 +0900)]
misc: modem_if: regress to old tizen modem driver

Tizen modem utility and xmm626x modem uses old style modem I/F. I
brought the driver from linux-3.0 kernel[1] because the driver
should be matched with telephony and modem-util package.

Kamil brought the driver from linux-3.4-exynos, but the driver didn't
match the current telephony daemon and modem util. Data communication
didn't work with the driver. So, I decided to regress to old driver.

Tizen Modem Team doesn't have any plan to update latest version of
modem package. To maintain consistency of the interface, I picked
the driver from linux-3.0 tree.

[1] : https://review.tizen.org/gerrit/gitweb?p=kernel%2Flinux-3.0.git;a=summary

Change-Id: I6123f4dc149dcc38e1ae339f950f94fdc0c033f9
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agophy: exynos4212-usb: Use refcount to power device PHY for HSIC0
Tomasz Figa [Thu, 24 Apr 2014 11:25:34 +0000 (13:25 +0200)]
phy: exynos4212-usb: Use refcount to power device PHY for HSIC0

HSIC0 requires device PHY to be powered up and the driver handles that
already, but there is no reference counting of device PHY power state,
so unplugging USB cable powers it down, breaking modem IF operation.

This patch fixes the issue by adding handling of reference counting of
device PHY to HSIC0 power-down/-up.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Change-Id: I14b1825fec3cd9c1b2652b89f275a50c73359ad6

9 years agomisc: modem_if: Use pinctrl to properly configure pins
Tomasz Figa [Wed, 23 Apr 2014 15:58:20 +0000 (17:58 +0200)]
misc: modem_if: Use pinctrl to properly configure pins

Configuring an interrupt pin as output/input manually using
gpio_direction_*() breaks interrupt settings and must not be done.

This patch adds necessary code to enable pull-down for interrupt pin
using pinctrl API instead of setting the pin to low output to fix
issues with missing modem interrupts.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Change-Id: Ie56d84ace1941cef3199fea99d7eb907bb9b5c03

9 years agomfd: max77686: Add suspend/resume callback function for alarm wake-up.
Jonghwa Lee [Tue, 22 Apr 2014 04:56:18 +0000 (13:56 +0900)]
mfd: max77686: Add suspend/resume callback function for alarm wake-up.

While system is resuming, Max77686's Alarm IRQ should be handled after resuming
of i2c controller. It disables IRQ in suspend callback funtion and enables
it in resume callback to postpone handling.

Change-Id: I69f5af2f8b63748853d0ba8a67f0cbb661e1ffcd
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
9 years agomedia: vb2-dma-contig: add a hack to speed up cache management
Marek Szyprowski [Tue, 22 Apr 2014 11:14:08 +0000 (13:14 +0200)]
media: vb2-dma-contig: add a hack to speed up cache management

In most cases video processing is done with coherent (non-cachable) userspace mappings. In such case for USERPTR mode cache management can
be skipped. This patch introduces code for such optimisation. It is called
a hack, because it is not possible in generic way to detect if the
given userspace mapping is coherent on not.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-id: I86aa292455371f1b18eb3f6b765234dc04ff937b

9 years agoarm: dts: trats2: Remove max77686's LDO22 regulator's 'always-on' flag.
Jonghwa Lee [Tue, 22 Apr 2014 14:04:08 +0000 (23:04 +0900)]
arm: dts: trats2: Remove max77686's LDO22 regulator's 'always-on' flag.

In trats2, LDO22 is used to eMMC's source voltage. And it can be controlled
by EN22 gpio pin. If LDO22 regulator is set to 'Always On' mode at software
reset, device will hang some seconds. Leave it controlled by EN22, then no
delay on reboot.

Change-Id: I012bb20bffa42e5ba7887863ef29cb2c473430cb
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
9 years agoASoC: samsung: Remove obsolete GPIO based DT pinmuxing
Mark Brown [Tue, 2 Jul 2013 12:10:28 +0000 (13:10 +0100)]
ASoC: samsung: Remove obsolete GPIO based DT pinmuxing

Since the Samsung platforms have moved to pinctrl for pin muxing and that
is handled in the core the old GPIO based muxing code can just be removed.
Something similar had been submitted by Thomas Abraham back in March but
a resubmission following review never happened.

Change-Id: I5a5813d51eeaefbb7e5c54fda05c1361a0798db2
Signed-off-by: Mark Brown <broonie@linaro.org>
9 years agoRevert "ASoC: samsung: Add pinctrl support to I2S driver"
Sylwester Nawrocki [Thu, 17 Apr 2014 18:50:21 +0000 (20:50 +0200)]
Revert "ASoC: samsung: Add pinctrl support to I2S driver"

This reverts commit 2b0c7de1eaf0e25c69ed1e4b21675ab97c6a4bdf,
which is not needed since pinctrl is handled by the driver core.

Change-Id: I0f204f15a39e07083375067fc828cf46bdb78360
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
9 years agos5p-mfc: Remove unused variable
Sylwester Nawrocki [Thu, 17 Apr 2014 17:01:22 +0000 (19:01 +0200)]
s5p-mfc: Remove unused variable

This fixes following compilation warning:

drivers/media/platform/s5p-mfc/s5p_mfc_dec.c: In function ‘s5p_mfc_buf_prepare’:
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c:1045:15: warning: unused variable ‘index’ [-Wunused-variable]

Change-Id: Id6c0c264c7169871df116ba6496b2e08e2638844
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
9 years agomisc: modem_if: initialize gpio_link_enable if invalid gpio
Chanho Park [Mon, 21 Apr 2014 07:24:33 +0000 (16:24 +0900)]
misc: modem_if: initialize gpio_link_enable if invalid gpio

This patch fixes invalid gpio value caused by 47c53475 commit.
The gpio_link_enable should be initialized to 0 if not provided

Change-Id: Ie22a2a60a2b713a3be9f141a5dc5c71d4adeb667
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agomodem_if: Change hardcoded link enable gpio value
Beomho Seo [Fri, 18 Apr 2014 09:31:24 +0000 (18:31 +0900)]
modem_if: Change hardcoded link enable gpio value

Currently, link enable gpio is hardecoded to zero.
Zero equal gpa0-0 value. It is value for uart rxd line.
If link enable gpio is unused, it is don't have to call gpio request.
This patch change to set line enable gpio value optionally, and
remove unused variable 'ret'.

Change-Id: I4095d57d76362722abd5c5fd92ef529772680d97
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
9 years agoARM: dts: exynos4412: remove duplicated mshc device node
Beomho Seo [Fri, 18 Apr 2014 05:45:03 +0000 (14:45 +0900)]
ARM: dts: exynos4412: remove duplicated mshc device node

MSHC device node are exsited both exynos4412 and exynos4x12
device tree. This patch remove duplicated mshc device node
on exynos4412 device tree.

Change-Id: Ib247d172006e916bac3489f5d0bf4958814364f5
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
9 years agoARM: dts: exynos4412-trats2: remove incorrect device node
Beomho Seo [Fri, 18 Apr 2014 02:04:21 +0000 (11:04 +0900)]
ARM: dts: exynos4412-trats2: remove incorrect device node

After the dts cleanup the gpio-keys device nodes were duplicated for trats2.
One of them is incorrect. As a result volume up/down key not working.
This patch remove duplicated and incorrect gpio-keys device node.

Change-Id: I44c9529b25a28d41ea451861727d7aa84211976e
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
9 years agoASoC: Samsung: correct code in order to get op_clk
Chen Zhen [Wed, 9 Apr 2014 12:50:46 +0000 (20:50 +0800)]
ASoC: Samsung: correct code in order to get op_clk

when i2s->op_clk is NULL we should do clk_get() before clk_get_rate() call ,
rather than calling clk_get_rate() on NULL clk, which will returns 0.

Change-Id: Ic82be597d8e4c27dd670d8d56630c3572e8f7d73
Signed-off-by: Chen Zhen <zhen1.chen@samsung.com>
9 years agoarm: config: tizen: add support for libvirt
Dariusz Michaluk [Mon, 14 Apr 2014 15:30:33 +0000 (17:30 +0200)]
arm: config: tizen: add support for libvirt

libvirt is a toolkit to interact with LXC(Linux kernel containers)
current libvirt-lxc driver need some additional kernel features:
1. Control groups (cgroups)
        CONFIG_CGROUP_DEVICE
        CONFIG_CPUSETS
2. CFS Scheduler
        CONFIG_CFS_BANDWIDTH
3. Multiple instances of devpts filesystem
        CONFIG_DEVPTS_MULTIPLE_INSTANCES
4. Kernel bridging
        CONFIG_BRIDGE_NETFILTER
        CONFIG_NETFILTER_XT_TARGET_CHECKSUM
        CONFIG_STP
        CONFIG_BRIDGE
        CONFIG_BRIDGE_IGMP_SNOOPING
        CONFIG_BRIDGE_VLAN_FILTERING
        CONFIG_LLC
5. VLAN interface
        CONFIG_VLAN_8021Q
        CONFIG_MACVLAN
        CONFIG_VETH
        CONFIG_TUN

Change-Id: I7c09743d1953b8ddbea99afc8e821c2dd9b826a7
Signed-off-by: Dariusz Michaluk <d.michaluk@samsung.com>
9 years agocpuidle:AFTR: Enable STANDBY_WFI0 and STANDBY_WFE0 for cpu0 in AFTR mode
Lukasz Majewski [Fri, 11 Apr 2014 11:52:09 +0000 (13:52 +0200)]
cpuidle:AFTR: Enable STANDBY_WFI0 and STANDBY_WFE0 for cpu0 in AFTR mode

Enabling of CORE0 idle state is based on the state of STANDBYWFI/STANDBYWFE
internal signal.

Change-Id: I43675fa312ce879f3741644057991bdb33f6cd55
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
9 years agocpuidle:clk:Exynos4412: Enable support for clock down when WFI cpuidle state is entered
Lukasz Majewski [Thu, 10 Apr 2014 14:46:08 +0000 (16:46 +0200)]
cpuidle:clk:Exynos4412: Enable support for clock down when WFI cpuidle state is entered

This patch adds support for setting ARM cores' clock frequency down when
entering WFI/WFE based cpuidle state.

On the Trats2 device: performance governor, 1.4 GHz frequency, no extra
load, 4 cores enabled:
Without core clock down feature: 395 mA
With core clock down feature: 337 mA

Power consumption reduction around 15%

Change-Id: I7bae29b0332a97c7b18ffb79f4b0a5ff3d70b7ce
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
9 years agocpuidle:exynos:AFTR: Use secure monitor calls to enable entering AFTR
Lukasz Majewski [Thu, 10 Apr 2014 10:38:42 +0000 (12:38 +0200)]
cpuidle:exynos:AFTR: Use secure monitor calls to enable entering AFTR

Secure monitor calls are necessary to enter the AFTR low power mode on the
trats2 device.

Without them it is not possible to access certain CP15 registers (e.g.
Power Control Register).

Change-Id: I8f91acb80acdbd43c86a679d69037be041d76309
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
9 years agodrm/exynos: add dmabuf sync support for kms framework
Inki Dae [Tue, 17 Sep 2013 12:01:47 +0000 (21:01 +0900)]
drm/exynos: add dmabuf sync support for kms framework

Change-Id: I5937869e5fa2ec2a41e864494eac0077ccdbdb51
Signed-off-by: Inki Dae <inki.dae@samsung.com>
9 years agoARM: dts: Add missing aliases entry for i2c-mhl node
Sylwester Nawrocki [Fri, 11 Apr 2014 09:08:34 +0000 (11:08 +0200)]
ARM: dts: Add missing aliases entry for i2c-mhl node

This fixes regression introduced in commit 10d282f12d57a467a83a
ARM: exynos: dts: cleanup the dts file for trats2

Without an alias the i2c-mhl get dynamically assigned an I2C bus
id 0 which is assigned in DT to the I2C0 hardware controller.
As a result I2C0 hardware controller fails to initialize which
in turn breaks the camera subsystem driver initialization.

Change-Id: I92c254cc1d93899b277761b750b0e657c2daad95
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
9 years agoARM: odroidx2: update defconfig to enable Audio
Chen Zhen [Wed, 9 Apr 2014 01:57:05 +0000 (09:57 +0800)]
ARM: odroidx2: update defconfig to enable Audio

This enables the necessary configuration for audio,such as SND_TIMER,SND_PCM,SND_JACK,
I2S and so on.

Change-Id: I6cb157e28529ba5a3756f5df5ddf19a2d59fe3ca
Signed-off-by: Chen Zhen <zhen1.chen@samsung.com>
9 years agoARM: dts: odroidx2: add i2s node and sound node for audio
ChenZhen [Thu, 27 Mar 2014 01:39:05 +0000 (09:39 +0800)]
ARM: dts: odroidx2: add i2s node and sound node for audio

In order to config a integrated audio path,it's necessary to define
the bus type and codec which we used.

Change-Id: I4a65d45b5cec4b81ce1a93deaa614020d6a17ae7
Signed-off-by: Chen Zhen <zhen1.chen@samsung.com>
9 years agomedia: s5p_mfc: fix doublly free issue
Zhaowei Yuan [Wed, 2 Apr 2014 07:58:36 +0000 (15:58 +0800)]
media: s5p_mfc: fix doublly free issue

When video_register_device() returns failure, vfd will be freed at once and
dev->vfl_dec will be freed after label "err_dec_reg", but the two pointers point
to the same area, so it was doublly freed here. Since video_device_release()
will be called by video_unregister_device() indirectly, we should remove the
two other calls after labels err_enc_reg and err_dec_reg.

Change-Id: I5ee8f83eeb47443e2f772914127514eab996c347
Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
9 years agoASoC: samsung: add machine driver for odroidx2
Chen Zhen [Fri, 28 Mar 2014 03:35:25 +0000 (11:35 +0800)]
ASoC: samsung: add machine driver for odroidx2

This machine driver primary define the audio path,the supported data format and
sample frequency.

Change-Id: I2cdb5f6f65b67d0039f234930210f75c1be9fe38
Signed-off-by: Chen Zhen <zhen1.chen@samsung.com>
9 years agoASoC: Samsung: Do not queue cyclic buffers multiple times
Tomasz Figa [Sun, 11 Aug 2013 17:59:21 +0000 (19:59 +0200)]
ASoC: Samsung: Do not queue cyclic buffers multiple times

The legacy S3C-DMA API required every period of a cyclic buffer to be
queued separately. After conversion of Samsung ASoC to Samsung DMA
wrappers somebody made an assumption that the same is needed for DMA
engine API, which is not true.

In effect, Samsung ASoC DMA code was queuing the whole cyclic buffer
multiple times with a shift of one period per iteration, leading to:
  a) severe memory waste - up to 13x times more DMA transfer descriptors
     are allocated than needed,
  b) possible memory corruption, because further cyclic buffers were out
     of the original buffers, due to the offset.

This patch fixes this problem by making the legacy S3C-DMA API use the
same semantics as DMA engine (the whole cyclic buffer is enqueued at
once) and modifying users of Samsung DMA wrappers in cyclic mode to
behave appropriately.

Change-Id: Ib9e656c40ef71e2e90af3f008959eeae19ce7d7e
Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
9 years agoEnable seccomp in tizen_defconfig arm configuration
Zofia Abramowska [Thu, 13 Mar 2014 13:36:33 +0000 (14:36 +0100)]
Enable seccomp in tizen_defconfig arm configuration

Enabling seccomp and seccomp filters due to future seccomp related
work on platform for limiting access to system for unprivileged
applications.

Change-Id: Ib067d5510e06d89e539537485fecd63e9bd92c40
Signed-off-by: Zofia Abramowska <z.abramowska@samsung.com>
9 years agoRemoving s3c-rtc status override for exynos4412-trats2.
Marcin Niesluchowski [Wed, 26 Mar 2014 10:08:52 +0000 (11:08 +0100)]
Removing s3c-rtc status override for exynos4412-trats2.

s3c-rtc is not functioning - initializing its value on every boot.
As registering rtc devices is non-deterministic, s3c-rtc may be
registered under rtc0 and rtc0 is default device for setting and
getting hardware time (hwclock). Another working rtc driver is
enabled.

Change-Id: I651da859db6ad9b35d422288845c0bebbcf540f5
Signed-off-by: Marcin Niesluchowski <m.niesluchow@samsung.com>
9 years agocpufreq:LAB: Change method of boost state preserving
Lukasz Majewski [Wed, 2 Apr 2014 10:31:57 +0000 (12:31 +0200)]
cpufreq:LAB: Change method of boost state preserving

It is not necessary to change the boost state when LAB governor is entered,
since LAB will change it according to its own politics. Only enter state
is preserved.

When leaving the LAB, only when required, work is scheduled to restore boost
initial state.

Change-Id: I6323f3c0011fe54a33d70c9ad0f9da5360b4a735
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
9 years agocpufreq:governor: Add serialization to the cpufreq_governor_dbs() function
Lukasz Majewski [Wed, 2 Apr 2014 10:14:25 +0000 (12:14 +0200)]
cpufreq:governor: Add serialization to the cpufreq_governor_dbs() function

It is necessary to serialize access to cpufreq_governor_dbs() function, since
it can be accessed from different, not protected by any mutex paths like
sysfs boost attribute or LAB governor internals.

Change-Id: Id7b62db6ca0b7c28f5e8c6286aec312d3d0c971e
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
9 years agomedia: s5p_mfc: remove the code checking dev->plat_dev
Zhaowei Yuan [Wed, 2 Apr 2014 07:22:33 +0000 (15:22 +0800)]
media: s5p_mfc: remove the code checking dev->plat_dev

We should remove the code checking dev->plat_dev since we
can ensure the pointer pdev can not be NULL.

Change-Id: Ibdc44403068ee4462e414d6e84757b8a4c2b512c
Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
9 years agoARM: dts: set mmc clock-frequency for odroidx2
Donghwa Lee [Mon, 31 Mar 2014 02:31:56 +0000 (11:31 +0900)]
ARM: dts: set mmc clock-frequency for odroidx2

from: Jaehoon Chung <jh80.chung@samsung.com>

set mmc clock-frequency to 400MHZ for odroidx2

Change-Id: I94b9dccbdd8091e333debbe8b06a881bf3ea7ee9
Signed-off-by: Donghwa Lee <dh09.lee@samsung.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
9 years agomedia: s5p-mfc: add to set clock rate
Donghwa Lee [Mon, 31 Mar 2014 02:13:09 +0000 (11:13 +0900)]
media: s5p-mfc: add to set clock rate

from: Seung-Woo Kim <sw0312.kim@samsung.com>

MFC needs 200MHz for sclk_mfc clock to work properly. The clock
rate setting was missed, so this patch adds it.

Change-Id: Ica696a5fda2babe81e885945fa5affd0b09ff5ba
Signed-off-by: Donghwa Lee <dh09.lee@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
9 years agoclocksource: exynos_mct: Change exynos4_mct_tick_clear return type to void
Krzysztof Kozlowski [Mon, 24 Mar 2014 09:01:32 +0000 (10:01 +0100)]
clocksource: exynos_mct: Change exynos4_mct_tick_clear return type to void

Return value of exynos4_mct_tick_clear() was never checked so it can
be safely changed to void.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Change-Id: I14f872e244434002005c532adf8afc97ef77cea5

9 years agoclocksource: exynos_mct: Fix stall after CPU hotplugging
Krzysztof Kozlowski [Mon, 24 Mar 2014 08:27:22 +0000 (09:27 +0100)]
clocksource: exynos_mct: Fix stall after CPU hotplugging

Fix stall after hotplugging CPU1. The stall was a result of starting the
CPU1 local timer not in L1 timer but in L0 (which is used by CPU0).

Stall information:
[  530.045259] INFO: rcu_preempt detected stalls on CPUs/tasks:
[  530.045618]  1: (6 GPs behind) idle=6d0/0/0 softirq=369/369
[  530.050987]  (detected by 0, t=6589 jiffies, g=33, c=32, q=0)
[  530.056721] Task dump for CPU 1:
[  530.059928] swapper/1       R running      0     0      1 0x00001000
[  530.066377] [<c0524e14>] (__schedule+0x414/0x9b4) from [<c00b6610>] (rcu_idle_enter+0x18/0x38)
[  530.074955] [<c00b6610>] (rcu_idle_enter+0x18/0x38) from [<c0079a18>] (cpu_startup_entry+0x60/0x3bc)
[  530.084069] [<c0079a18>] (cpu_startup_entry+0x60/0x3bc) from [<c0517d34>] (secondary_start_kernel+0x164/0x1a0)
[  530.094029] [<c0517d34>] (secondary_start_kernel+0x164/0x1a0) from [<40517244>] (0x40517244)

The timers for CPU1 were missed:
[  591.668436] cpu: 1
[  591.670430]  clock 0:
[  591.672691]   .base:       c0ab7750
[  591.676160]   .index:      0
[  591.679025]   .resolution: 1 nsecs
[  591.682404]   .get_time:   ktime_get
[  591.685970]   .offset:     0 nsecs
[  591.689349] active timers:
[  591.692045]  #0: <dfb51f40>, hrtimer_wakeup, S:01
[  591.696759]  # expires at 454687834257-454687884257 nsecs [in -136770537232 to -136770487232 nsecs]

And the event_handler for next event was wrong:
[  591.917120] Tick Device: mode:     1
[  591.920676] Per CPU device: 0
[  591.923621] Clock Event Device: mct_tick0
[  591.927623]  max_delta_ns:   178956969027
[  591.931613]  min_delta_ns:   1249
[  591.934913]  mult:           51539608
[  591.938557]  shift:          32
[  591.941681]  mode:           3
[  591.944724]  next_event:     595025000000 nsecs
[  591.949227]  set_next_event: exynos4_tick_set_next_event
[  591.954522]  set_mode:       exynos4_tick_set_mode
[  591.959296]  event_handler:  hrtimer_interrupt
[  591.963730]  retries:        0
[  591.966761]
[  591.968245] Tick Device: mode:     0
[  591.971801] Per CPU device: 1
[  591.974746] Clock Event Device: mct_tick1
[  591.978750]  max_delta_ns:   178956969027
[  591.982739]  min_delta_ns:   1249
[  591.986037]  mult:           51539608
[  591.989681]  shift:          32
[  591.992806]  mode:           3
[  591.995848]  next_event:     453685000000 nsecs
[  592.000353]  set_next_event: exynos4_tick_set_next_event
[  592.005648]  set_mode:       exynos4_tick_set_mode
[  592.010421]  event_handler:  tick_handle_periodic
[  592.015115]  retries:        0
[  592.018145]

After turning off the CPU1, the MCT L1 local timer was disabled but the
interrupt was not cleared. Turning on the CPU1 enabled the IRQ
with setup_irq() but, before setting affinity to CPU1, the pending L1 timer
interrupt was processed by CPU0 in exynos4_mct_tick_isr().

The ISR then called event handler which set up the next timer event for
current CPU (CPU0). Therefore the MCT L1 timer wasn't actually started.

Fix the stall by:
1. Setting next timer event not on current CPU but on the CPU indicated
by cpumask in 'clock_event_device'.
2. Clearing the timer interrupt upon stopping the local timer.

The patch also moves around the call to exynos4_mct_tick_stop() but this
is done only for the code readability as it is not essential for the fix.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Change-Id: I3a1a23e2b970661b5f7c60fc633a7545aa80ed5e

9 years agocpufreq: serialize calls to __cpufreq_governor()
Viresh Kumar [Sat, 31 Aug 2013 12:18:23 +0000 (17:48 +0530)]
cpufreq: serialize calls to __cpufreq_governor()

We can't take a big lock around __cpufreq_governor() as this causes
recursive locking for some cases. But calls to this routine must be
serialized for every policy. Otherwise we can see some unpredictable
events.

For example, consider following scenario:

__cpufreq_remove_dev()
 __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
   policy->governor->governor(policy, CPUFREQ_GOV_STOP);
    cpufreq_governor_dbs()
     case CPUFREQ_GOV_STOP:
      mutex_destroy(&cpu_cdbs->timer_mutex)
      cpu_cdbs->cur_policy = NULL;
  <PREEMPT>
store()
 __cpufreq_set_policy()
  __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
    policy->governor->governor(policy, CPUFREQ_GOV_LIMITS);
     case CPUFREQ_GOV_LIMITS:
      mutex_lock(&cpu_cdbs->timer_mutex); <-- Warning (destroyed mutex)
       if (policy->max < cpu_cdbs->cur_policy->cur) <- cur_policy == NULL

And so store() will eventually result in a crash if cur_policy is
NULL at this point.

Introduce an additional variable which would guarantee serialization
here.

Change-Id: Ibae767cbd9c25c7598b39d1405fa3d98d2125101
Reported-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
9 years agocpufreq: Fix serialization of frequency transitions
Viresh Kumar [Tue, 2 Jul 2013 11:06:28 +0000 (16:36 +0530)]
cpufreq: Fix serialization of frequency transitions

Commit 7c30ed ("cpufreq: make sure frequency transitions are serialized")
interacts poorly with systems that have a single core freqency for all
cores.  On such systems we have a single policy for all cores with
several CPUs.  When we do a frequency transition the governor calls the
pre and post change notifiers which causes cpufreq_notify_transition()
per CPU.  Since the policy is the same for all of them all CPUs after
the first and the warnings added are generated by checking a per-policy
flag the warnings will be triggered for all cores after the first.

Fix this by allowing notifier to be called for n times. Where n is the number of
cpus in policy->cpus.

Change-Id: I5712dde7f992644f9c3ddc8313151f80bea0d877
Reported-and-tested-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
9 years agocpufreq: make sure frequency transitions are serialized
Viresh Kumar [Wed, 19 Jun 2013 04:46:55 +0000 (10:16 +0530)]
cpufreq: make sure frequency transitions are serialized

Whenever we are changing frequency of a cpu, we are calling PRECHANGE and
POSTCHANGE notifiers. They must be serialized. i.e. PRECHANGE or POSTCHANGE
shouldn't be called twice contiguously.

This can happen due to bugs in users of __cpufreq_driver_target() or actual
cpufreq drivers who are sending these notifiers.

This patch adds some protection against this. Now, we keep track of the last
transaction and see if something went wrong.

Change-Id: I0f5465bd515c431ae2d3711d065f70aacec7e978
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
9 years agocpufreq: remove unnecessary cpufreq_cpu_{get|put}() calls
Viresh Kumar [Fri, 31 May 2013 06:15:08 +0000 (06:15 +0000)]
cpufreq: remove unnecessary cpufreq_cpu_{get|put}() calls

struct cpufreq_policy is already passed as argument to some routines
like: __cpufreq_driver_getavg() and so we don't really need to do
cpufreq_cpu_get() before and cpufreq_cpu_put() in them to get a
policy structure.

Remove them.

Change-Id: I6a9ff8ed483a4f4faacc2ea047d93354dccdb0b6
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
9 years agoASoC: max98090: Add of_match_table
ChenZhen [Tue, 25 Mar 2014 07:52:50 +0000 (15:52 +0800)]
ASoC: max98090: Add of_match_table

It's necessary to add of_match_table to match driver.

Change-Id: I7c09aef9a3f54180041398009b9141142de54ea4
Signed-off-by: ChenZhen <zhen1.chen@samsung.com>
9 years agoARM: dts: odroidx2: add i2c1 node for max98090
ChenZhen [Tue, 25 Mar 2014 01:54:52 +0000 (09:54 +0800)]
ARM: dts: odroidx2: add i2c1 node for max98090

Add i2c1 node for the codec driver max98090.

Change-Id: Ib6afaf7574827540281959a1f8338d50e221df39
Signed-off-by: ChenZhen <zhen1.chen@samsung.com>
9 years agopackaging: specify ExclusiveArch to arm/aarch64
Chanho Park [Tue, 25 Mar 2014 05:03:00 +0000 (14:03 +0900)]
packaging: specify ExclusiveArch to arm/aarch64

This patch specifies "ExclusiveArch" for building only arm and
aarch64.

Change-Id: I33a484b478d7848257a4ea8b4375b0ea1994c47e
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agopackaging: change modules directory to /boot/lib/modules
Chanho Park [Mon, 24 Mar 2014 05:15:16 +0000 (14:15 +0900)]
packaging: change modules directory to /boot/lib/modules

This patch changes the default modules directory from /lib/modules
to /boot/lib/modules. The mobile kernel didn't use /lib/modules
for modules because it should be matched with kernel version and
can be recoveried with the /boot directory. The old kernel used
modules.img which includes kernel modules. And we also loop-mounted
it to the /lib/modules directory. Instead of it, we'll use /boot/lib/
modules directory because it will have same functionality if the
/boot directory will be read-only. And we will add the recovery
partition of the /boot.

Change-Id: Ie0f0af47f0f6d3fe25c780fb8685df745b587dd7
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agopackaging: update kernel version to 3.10.33
Chanho Park [Mon, 24 Mar 2014 05:12:04 +0000 (14:12 +0900)]
packaging: update kernel version to 3.10.33

Recently, we updated the kernel version from 3.10.19 to 3.10.33.
This patch also updates the kernel version in the spec file.

Change-Id: Ifc5239ea428e2178aa70ddd3b94364fdbb7ebe79
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agovmpressure: make sure there are no events queued after memcg is offlined
Michal Hocko [Wed, 31 Jul 2013 20:53:51 +0000 (13:53 -0700)]
vmpressure: make sure there are no events queued after memcg is offlined

vmpressure is called synchronously from reclaim where the target_memcg
is guaranteed to be alive but the eventfd is signaled from the work
queue context.  This means that memcg (along with vmpressure structure
which is embedded into it) might go away while the work item is pending
which would result in use-after-release bug.

We have two possible ways how to fix this.  Either vmpressure pins memcg
before it schedules vmpr->work and unpin it in vmpressure_work_fn or
explicitely flush the work item from the css_offline context (as
suggested by Tejun).

This patch implements the later one and it introduces vmpressure_cleanup
which flushes the vmpressure work queue item item.  It hooks into
mem_cgroup_css_offline after the memcg itself is cleaned up.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Tejun Heo <tj@kernel.org>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Li Zefan <lizefan@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: I1deefca16b6e243f86bd78b84c561db02e7a20e8

9 years agovmpressure: do not check for pending work to prevent from new work
Michal Hocko [Wed, 31 Jul 2013 20:53:50 +0000 (13:53 -0700)]
vmpressure: do not check for pending work to prevent from new work

because it is racy and it doesn't give us much anyway as schedule_work
handles this case already.

Change-Id: I9946652da98eef2ed0312a5470e69db13fab0e4c
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Tejun Heo <tj@kernel.org>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Li Zefan <lizefan@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agovmpressure: change vmpressure::sr_lock to spinlock
Michal Hocko [Wed, 31 Jul 2013 20:53:48 +0000 (13:53 -0700)]
vmpressure: change vmpressure::sr_lock to spinlock

There is nothing that can sleep inside critical sections protected by
this lock and those sections are really small so there doesn't make much
sense to use mutex for them.  Change the log to a spinlock

Change-Id: I54c8361a88ec810676cf631f3754c5b860d54b01
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Tejun Heo <tj@kernel.org>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Li Zefan <lizefan@huawei.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agotizen: enable zswap/zsmalloc/zbud to compress swap memory
Chanho Park [Fri, 21 Mar 2014 07:24:26 +0000 (16:24 +0900)]
tizen: enable zswap/zsmalloc/zbud to compress swap memory

Change-Id: Iccf427f0acecad261b7cd8baa7114ecf9a421914
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agomodem: sipc4: Chagne the manner of recieving data for FMT,RFS type device
Jonghwa Lee [Thu, 20 Mar 2014 07:19:31 +0000 (16:19 +0900)]
modem: sipc4: Chagne the manner of recieving data for FMT,RFS type device

When packet arrives, link device call iodev's helper function to recieve
packets. The way of recieving data of IPC_FMT and IPC_RFS type iodevs differs
from IPC_RAW and IPC_MULTI_RAW. This patch adds specified method of recieving
data for FMT, RFS typed.

This modification references TIZEN 2.2 kernel.

Change-Id: I01efa7678bbabfbd1011ceba42571fc221313c4d
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
9 years agodrm/exynos: remove DRIVER_HAVE_IRQ feature
Joonyoung Shim [Thu, 20 Mar 2014 08:09:46 +0000 (17:09 +0900)]
drm/exynos: remove DRIVER_HAVE_IRQ feature

Exynos drm driver cannot support DRIVER_HAVE_IRQ feature because it uses
driver specific one instead of routine of drm framework to
install/uninstall irq handler.

Change-Id: I5796d7113cbc4283cbb41591384aaa69011818d4
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agorbtree: fix rbtree_postorder_for_each_entry_safe() iterator
Jan Kara [Tue, 12 Nov 2013 23:11:19 +0000 (15:11 -0800)]
rbtree: fix rbtree_postorder_for_each_entry_safe() iterator

The iterator rbtree_postorder_for_each_entry_safe() relies on pointer
underflow behavior when testing for loop termination.  In particular it
expects that

  &rb_entry(NULL, type, field)->field

is NULL.  But the result of this expression is not defined by a C standard
and some gcc versions (e.g.  4.3.4) assume the above expression can never
be equal to NULL.  The net result is an oops because the iteration is not
properly terminated.

Fix the problem by modifying the iterator to avoid pointer underflows.

Change-Id: I06d5983b5335412be6cb6ebd95db3c682e26ed38
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: <stable@vger.kernel.org> [3.12.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agorbtree: add rbtree_postorder_for_each_entry_safe() helper
Cody P Schafer [Wed, 11 Sep 2013 21:25:11 +0000 (14:25 -0700)]
rbtree: add rbtree_postorder_for_each_entry_safe() helper

Because deletion (of the entire tree) is a relatively common use of the
rbtree_postorder iteration, and because doing it safely means fiddling
with temporary storage, provide a helper to simplify postorder rbtree
iteration.

Change-Id: I8442bc3efc79dca08bfbc6ebb63607cf4e83bcf6
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Reviewed-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: David Woodhouse <David.Woodhouse@intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agorbtree: add postorder iteration functions
Cody P Schafer [Wed, 11 Sep 2013 21:25:10 +0000 (14:25 -0700)]
rbtree: add postorder iteration functions

Postorder iteration yields all of a node's children prior to yielding the
node itself, and this particular implementation also avoids examining the
leaf links in a node after that node has been yielded.

In what I expect will be its most common usage, postorder iteration allows
the deletion of every node in an rbtree without modifying the rbtree nodes
(no _requirement_ that they be nulled) while avoiding referencing child
nodes after they have been "deleted" (most commonly, freed).

I have only updated zswap to use this functionality at this point, but
numerous bits of code (most notably in the filesystem drivers) use a hand
rolled postorder iteration that NULLs child links as it traverses the
tree.  Each of those instances could be replaced with this common
implementation.

1 & 2 add rbtree postorder iteration functions.
3 adds testing of the iteration to the rbtree runtime tests
4 allows building the rbtree runtime tests as builtins
5 updates zswap.

This patch:

Add postorder iteration functions for rbtree.  These are useful for safely
freeing an entire rbtree without modifying the tree at all.

Change-Id: Ibc97f0e13288030501b5e84defc6603eeb1adca6
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Reviewed-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: David Woodhouse <David.Woodhouse@intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap.c: change params from hidden to ro
Dan Streetman [Thu, 23 Jan 2014 23:52:48 +0000 (15:52 -0800)]
mm/zswap.c: change params from hidden to ro

The "compressor" and "enabled" params are currently hidden, this changes
them to read-only, so userspace can tell if zswap is enabled or not and
see what compressor is in use.

Change-Id: I42d8ac2544ccbf981de26d98b772417e183360f6
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Cc: Vladimir Murzin <murzin.v@gmail.com>
Cc: Bob Liu <bob.liu@oracle.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Weijie Yang <weijie.yang@samsung.com>
Acked-by: Seth Jennings <sjennings@variantweb.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap: refactor the get/put routines
Weijie Yang [Tue, 12 Nov 2013 23:08:27 +0000 (15:08 -0800)]
mm/zswap: refactor the get/put routines

The refcount routine was not fit the kernel get/put semantic exactly,
There were too many judgement statements on refcount and it could be
minus.

This patch does the following:

 - move refcount judgement to zswap_entry_put() to hide resource free function.

 - add a new function zswap_entry_find_get(), so that callers can use
   easily in the following pattern:

     zswap_entry_find_get
     .../* do something */
     zswap_entry_put

 - to eliminate compile error, move some functions declaration

This patch is based on Minchan Kim <minchan@kernel.org> 's idea and suggestion.

Change-Id: I8510ffe4f49a1a5f00b53be89b2ee33854464db8
Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Cc: Seth Jennings <sjennings@variantweb.net>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently
Weijie Yang [Tue, 12 Nov 2013 23:08:26 +0000 (15:08 -0800)]
mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

Consider the following scenario:

thread 0: reclaim entry x (get refcount, but not call zswap_get_swap_cache_page)
thread 1: call zswap_frontswap_invalidate_page to invalidate entry x.
finished, entry x and its zbud is not freed as its refcount != 0
now, the swap_map[x] = 0
thread 0: now call zswap_get_swap_cache_page
swapcache_prepare return -ENOENT because entry x is not used any more
zswap_get_swap_cache_page return ZSWAP_SWAPCACHE_NOMEM
zswap_writeback_entry do nothing except put refcount

Now, the memory of zswap_entry x and its zpage leak.

Modify:
 - check the refcount in fail path, free memory if it is not referenced.

 - use ZSWAP_SWAPCACHE_FAIL instead of ZSWAP_SWAPCACHE_NOMEM as the fail path
   can be not only caused by nomem but also by invalidate.

Change-Id: I3d76f21a11f2d9ff0bec412c90b3895efce6478d
Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap: avoid unnecessary page scanning
Weijie Yang [Tue, 12 Nov 2013 23:07:52 +0000 (15:07 -0800)]
mm/zswap: avoid unnecessary page scanning

Add SetPageReclaim() before __swap_writepage() so that page can be moved
to the tail of the inactive list, which can avoid unnecessary page
scanning as this page was reclaimed by swap subsystem before.

Change-Id: If1ed52e3161c332d9f1f6fdd8851e97b5d3b4271
Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap: bugfix: memory leak when re-swapon
Weijie Yang [Wed, 16 Oct 2013 20:46:54 +0000 (13:46 -0700)]
mm/zswap: bugfix: memory leak when re-swapon

zswap_tree is not freed when swapoff, and it got re-kmalloced in swapon,
so a memory leak occurs.

Free the memory of zswap_tree in zswap_frontswap_invalidate_area().

Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
Cc: Minchan Kim <minchan@kernel.org>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Cc: <stable@vger.kernel.org>
From: Weijie Yang <weijie.yang@samsung.com>
Subject: mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

Consider the following scenario:
thread 0: reclaim entry x (get refcount, but not call zswap_get_swap_cache_page)
thread 1: call zswap_frontswap_invalidate_page to invalidate entry x.
finished, entry x and its zbud is not freed as its refcount != 0
now, the swap_map[x] = 0
thread 0: now call zswap_get_swap_cache_page
swapcache_prepare return -ENOENT because entry x is not used any more
zswap_get_swap_cache_page return ZSWAP_SWAPCACHE_NOMEM
zswap_writeback_entry do nothing except put refcount
Now, the memory of zswap_entry x and its zpage leak.

Modify:
 - check the refcount in fail path, free memory if it is not referenced.

 - use ZSWAP_SWAPCACHE_FAIL instead of ZSWAP_SWAPCACHE_NOMEM as the fail path
   can be not only caused by nomem but also by invalidate.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: <stable@vger.kernel.org>
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Change-Id: I4a875e48714d73bf2c1f75b60d90776365c047de
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap: use postorder iteration when destroying rbtree
Cody P Schafer [Wed, 11 Sep 2013 21:25:33 +0000 (14:25 -0700)]
mm/zswap: use postorder iteration when destroying rbtree

Change-Id: I83b93b7eaadb7c66981f1119eda1119c978d1b9c
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Reviewed-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: David Woodhouse <David.Woodhouse@intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zbud: fix some trivial typos in comments
Jianguo Wu [Wed, 11 Sep 2013 21:21:42 +0000 (14:21 -0700)]
mm/zbud: fix some trivial typos in comments

Change-Id: I1acb8c1f4ff9ab8dbd698380a731daef51d028fc
Signed-off-by: Jianguo Wu <wujianguo@huawei.com>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm/zswap.c: get swapper address_space by using macro
Sunghan Suh [Wed, 11 Sep 2013 21:20:22 +0000 (14:20 -0700)]
mm/zswap.c: get swapper address_space by using macro

There is a proper macro to get the corresponding swapper address space
from a swap entry.  Instead of directly accessing "swapper_spaces" array,
use the "swap_address_space" macro.

Change-Id: I145f9a3fad914ff83853cd80c60af61f40eab1cf
Signed-off-by: Sunghan Suh <sunghan.suh@samsung.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomm: zbud: fix condition check on allocation size
Heesub Shin [Wed, 31 Jul 2013 20:53:40 +0000 (13:53 -0700)]
mm: zbud: fix condition check on allocation size

zbud_alloc() incorrectly verifies the size of allocation limit.  It
should deny the allocation request greater than (PAGE_SIZE -
ZHDR_SIZE_ALIGNED - CHUNK_SIZE), not (PAGE_SIZE - ZHDR_SIZE_ALIGNED)
which has no remaining spaces for its buddy.  There is no point in
spending the entire zbud page storing only a single page, since we don't
have any benefits.

Change-Id: Ief305088b6983c01426300a0638520f51b17ad2a
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Bob Liu <bob.liu@oracle.com>
Cc: Dongjun Shin <d.j.shin@samsung.com>
Cc: Sunae Seo <sunae.seo@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: remove zram->lock in read path and change it with mutex
Minchan Kim [Thu, 30 Jan 2014 23:46:06 +0000 (15:46 -0800)]
zram: remove zram->lock in read path and change it with mutex

Finally, we separated zram->lock dependency from 32bit stat/ table
handling so there is no reason to use rw_semaphore between read and
write path so this patch removes the lock from read path totally and
changes rw_semaphore with mutex.  So, we could do

old:

  read-read: OK
  read-write: NO
  write-write: NO

Now:

  read-read: OK
  read-write: OK
  write-write: NO

The below data proves mixed workload performs well 11 times and there is
also enhance on write-write path because current rw-semaphore doesn't
support SPIN_ON_OWNER.  It's side effect but anyway good thing for us.

Write-related tests perform better (from 61% to 1058%) but read path has
good/bad(from -2.22% to 1.45%) but they are all marginal within stddev.

  CPU 12
  iozone -t -T -l 12 -u 12 -r 16K -s 60M -I +Z -V 0

  ==Initial write                ==Initial write
  records: 10                    records: 10
  avg:  516189.16                avg:  839907.96
  std:   22486.53 (4.36%)        std:   47902.17 (5.70%)
  max:  546970.60                max:  909910.35
  min:  481131.54                min:  751148.38
  ==Rewrite                      ==Rewrite
  records: 10                    records: 10
  avg:  509527.98                avg: 1050156.37
  std:   45799.94 (8.99%)        std:   40695.44 (3.88%)
  max:  611574.27                max: 1111929.26
  min:  443679.95                min:  980409.62
  ==Read                         ==Read
  records: 10                    records: 10
  avg: 4408624.17                avg: 4472546.76
  std:  281152.61 (6.38%)        std:  163662.78 (3.66%)
  max: 4867888.66                max: 4727351.03
  min: 4058347.69                min: 4126520.88
  ==Re-read                      ==Re-read
  records: 10                    records: 10
  avg: 4462147.53                avg: 4363257.75
  std:  283546.11 (6.35%)        std:  247292.63 (5.67%)
  max: 4912894.44                max: 4677241.75
  min: 4131386.50                min: 4035235.84
  ==Reverse Read                 ==Reverse Read
  records: 10                    records: 10
  avg: 4565865.97                avg: 4485818.08
  std:  313395.63 (6.86%)        std:  248470.10 (5.54%)
  max: 5232749.16                max: 4789749.94
  min: 4185809.62                min: 3963081.34
  ==Stride read                  ==Stride read
  records: 10                    records: 10
  avg: 4515981.80                avg: 4418806.01
  std:  211192.32 (4.68%)        std:  212837.97 (4.82%)
  max: 4889287.28                max: 4686967.22
  min: 4210362.00                min: 4083041.84
  ==Random read                  ==Random read
  records: 10                    records: 10
  avg: 4410525.23                avg: 4387093.18
  std:  236693.22 (5.37%)        std:  235285.23 (5.36%)
  max: 4713698.47                max: 4669760.62
  min: 4057163.62                min: 3952002.16
  ==Mixed workload               ==Mixed workload
  records: 10                    records: 10
  avg:  243234.25                avg: 2818677.27
  std:   28505.07 (11.72%)       std:  195569.70 (6.94%)
  max:  288905.23                max: 3126478.11
  min:  212473.16                min: 2484150.69
  ==Random write                 ==Random write
  records: 10                    records: 10
  avg:  555887.07                avg: 1053057.79
  std:   70841.98 (12.74%)       std:   35195.36 (3.34%)
  max:  683188.28                max: 1096125.73
  min:  437299.57                min:  992481.93
  ==Pwrite                       ==Pwrite
  records: 10                    records: 10
  avg:  501745.93                avg:  810363.09
  std:   16373.54 (3.26%)        std:   19245.01 (2.37%)
  max:  518724.52                max:  833359.70
  min:  464208.73                min:  765501.87
  ==Pread                        ==Pread
  records: 10                    records: 10
  avg: 4539894.60                avg: 4457680.58
  std:  197094.66 (4.34%)        std:  188965.60 (4.24%)
  max: 4877170.38                max: 4689905.53
  min: 4226326.03                min: 4095739.72

Change-Id: I7d2299149ce6982d76caaaadb936b7385cbee515
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: remove workqueue for freeing removed pending slot
Minchan Kim [Thu, 30 Jan 2014 23:46:04 +0000 (15:46 -0800)]
zram: remove workqueue for freeing removed pending slot

Commit a0c516cbfc74 ("zram: don't grab mutex in zram_slot_free_noity")
introduced free request pending code to avoid scheduling by mutex under
spinlock and it was a mess which made code lenghty and increased
overhead.

Now, we don't need zram->lock any more to free slot so this patch
reverts it and then, tb_lock should protect it.

Change-Id: I3429e568bab78c197da3fc5cbd5afb9355bf7d21
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: introduce zram->tb_lock
Minchan Kim [Thu, 30 Jan 2014 23:46:03 +0000 (15:46 -0800)]
zram: introduce zram->tb_lock

Currently, the zram table is protected by zram->lock but it's rather
coarse-grained lock and it makes hard for scalibility.

Let's use own rwlock instead of depending on zram->lock.  This patch
adds new locking so obviously, it would make slow but this patch is just
prepartion for removing coarse-grained rw_semaphore(ie, zram->lock)
which is hurdle about zram scalability.

Final patch in this patchset series will remove the lock from read-path
and change rw_semaphore with mutex in write path.  With bonus, we could
drop pending slot free mess in next patch.

Change-Id: If5456f871bc6b0d6ee1f8218fde3f5a13d261c8b
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: use atomic operation for stat
Minchan Kim [Thu, 30 Jan 2014 23:46:02 +0000 (15:46 -0800)]
zram: use atomic operation for stat

Some of fields in zram->stats are protected by zram->lock which is
rather coarse-grained so let's use atomic operation without explict
locking.

This patch is ready for removing dependency of zram->lock in read path
which is very coarse-grained rw_semaphore.  Of course, this patch adds
new atomic operation so it might make slow but my 12CPU test couldn't
spot any regression.  All gain/lose is marginal within stddev.

  iozone -t -T -l 12 -u 12 -r 16K -s 60M -I +Z -V 0

  ==Initial write                ==Initial write
  records: 50                    records: 50
  avg:  412875.17                avg:  415638.23
  std:   38543.12 (9.34%)        std:   36601.11 (8.81%)
  max:  521262.03                max:  502976.72
  min:  343263.13                min:  351389.12
  ==Rewrite                      ==Rewrite
  records: 50                    records: 50
  avg:  416640.34                avg:  397914.33
  std:   60798.92 (14.59%)       std:   46150.42 (11.60%)
  max:  543057.07                max:  522669.17
  min:  304071.67                min:  316588.77
  ==Read                         ==Read
  records: 50                    records: 50
  avg: 4147338.63                avg: 4070736.51
  std:  179333.25 (4.32%)        std:  223499.89 (5.49%)
  max: 4459295.28                max: 4539514.44
  min: 3753057.53                min: 3444686.31
  ==Re-read                      ==Re-read
  records: 50                    records: 50
  avg: 4096706.71                avg: 4117218.57
  std:  229735.04 (5.61%)        std:  171676.25 (4.17%)
  max: 4430012.09                max: 4459263.94
  min: 2987217.80                min: 3666904.28
  ==Reverse Read                 ==Reverse Read
  records: 50                    records: 50
  avg: 4062763.83                avg: 4078508.32
  std:  186208.46 (4.58%)        std:  172684.34 (4.23%)
  max: 4401358.78                max: 4424757.22
  min: 3381625.00                min: 3679359.94
  ==Stride read                  ==Stride read
  records: 50                    records: 50
  avg: 4094933.49                avg: 4082170.22
  std:  185710.52 (4.54%)        std:  196346.68 (4.81%)
  max: 4478241.25                max: 4460060.97
  min: 3732593.23                min: 3584125.78
  ==Random read                  ==Random read
  records: 50                    records: 50
  avg: 4031070.04                avg: 4074847.49
  std:  192065.51 (4.76%)        std:  206911.33 (5.08%)
  max: 4356931.16                max: 4399442.56
  min: 3481619.62                min: 3548372.44
  ==Mixed workload               ==Mixed workload
  records: 50                    records: 50
  avg:  149925.73                avg:  149675.54
  std:    7701.26 (5.14%)        std:    6902.09 (4.61%)
  max:  191301.56                max:  175162.05
  min:  133566.28                min:  137762.87
  ==Random write                 ==Random write
  records: 50                    records: 50
  avg:  404050.11                avg:  393021.47
  std:   58887.57 (14.57%)       std:   42813.70 (10.89%)
  max:  601798.09                max:  524533.43
  min:  325176.99                min:  313255.34
  ==Pwrite                       ==Pwrite
  records: 50                    records: 50
  avg:  411217.70                avg:  411237.96
  std:   43114.99 (10.48%)       std:   33136.29 (8.06%)
  max:  530766.79                max:  471899.76
  min:  320786.84                min:  317906.94
  ==Pread                        ==Pread
  records: 50                    records: 50
  avg: 4154908.65                avg: 4087121.92
  std:  151272.08 (3.64%)        std:  219505.04 (5.37%)
  max: 4459478.12                max: 4435857.38
  min: 3730512.41                min: 3101101.67

Change-Id: Ib0d538597fbc4a2037b0464f8d62fb73fa0b0c24
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: remove unnecessary free
Minchan Kim [Thu, 30 Jan 2014 23:46:01 +0000 (15:46 -0800)]
zram: remove unnecessary free

Commit a0c516cbfc74 ("zram: don't grab mutex in zram_slot_free_noity")
introduced pending zram slot free in zram's write path in case of
missing slot free by memory allocation failure in zram_slot_free_notify
but it is not necessary because we have already freed the slot right
before overwriting.

Change-Id: I5048bce2ca8c377d9539f0397a04bddc5f5a5e92
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Jerome Marchand <jmarchan@redhat.com>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: delay pending free request in read path
Minchan Kim [Thu, 30 Jan 2014 23:46:00 +0000 (15:46 -0800)]
zram: delay pending free request in read path

Sergey reported we don't need to handle pending free request every I/O
so that this patch removes it in read path while we remain it in write
path.

Let's consider below example.

Swap subsystem ask to zram "A" block free by swap_slot_free_notify but
zram had been pended it without real freeing.  Swap subsystem allocates
"A" block for new data but request pended for a long time just handled
and zram blindly free new data on the "A" block.  :(

That's why we couldn't remove handle pending free request right before
zram-write.

Change-Id: Ib4409bfad7b1ae263e2708c74875c322da72c7b3
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: fix race between reset and flushing pending work
Minchan Kim [Thu, 30 Jan 2014 23:45:58 +0000 (15:45 -0800)]
zram: fix race between reset and flushing pending work

Dan and Sergey reported that there is a racy between reset and flushing
of pending work so that it could make oops by freeing zram->meta in
reset while zram_slot_free can access zram->meta if new request is
adding during the race window.

This patch moves flush after taking init_lock so it prevents new request
so that it closes the race.

Change-Id: Ibc09001d1ad4a4ef852d661384259b53f0f9c19b
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Jerome Marchand <jmarchan@redhat.com>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozsmalloc: add maintainers
Minchan Kim [Thu, 30 Jan 2014 23:45:57 +0000 (15:45 -0800)]
zsmalloc: add maintainers

tAdd adds maintainer information for zsmalloc into the MAINTAINERS file.

Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Conflicts:
MAINTAINERS

Change-Id: I315effbbfbd5aabb96dcadd1d35d9592ee24182d

9 years agozram: add zram maintainers
Minchan Kim [Thu, 30 Jan 2014 23:45:56 +0000 (15:45 -0800)]
zram: add zram maintainers

Add maintainer information for zram into the MAINTAINERS file.

Change-Id: I8a6b11120f55b76aeccf18ce004293721e48081a
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozsmalloc: add copyright
Minchan Kim [Thu, 30 Jan 2014 23:45:55 +0000 (15:45 -0800)]
zsmalloc: add copyright

Add my copyright to the zsmalloc source code which I maintain.

Change-Id: Ic3dd8dd11297ef902f4cb913e40c52249282d947
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: add copyright
Minchan Kim [Thu, 30 Jan 2014 23:45:55 +0000 (15:45 -0800)]
zram: add copyright

Add my copyright to the zram source code which I maintain.

Change-Id: I8816064aa958c9304c53fae0972e011060cc2bcc
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: remove old private project comment
Minchan Kim [Thu, 30 Jan 2014 23:45:54 +0000 (15:45 -0800)]
zram: remove old private project comment

Remove the old private compcache project address so upcoming patches
should be sent to LKML because we Linux kernel community will take care.

Change-Id: Ia5bf208791c8fa6e96161fd9fb842d6829f14698
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agozram: promote zram from staging
Minchan Kim [Thu, 30 Jan 2014 23:45:52 +0000 (15:45 -0800)]
zram: promote zram from staging

Zram has lived in staging for a LONG LONG time and have been
fixed/improved by many contributors so code is clean and stable now.  Of
course, there are lots of product using zram in real practice.

The major TV companys have used zram as swap since two years ago and
recently our production team released android smart phone with zram
which is used as swap, too and recently Android Kitkat start to use zram
for small memory smart phone.  And there was a report Google released
their ChromeOS with zram, too and cyanogenmod have been used zram long
time ago.  And I heard some disto have used zram block device for tmpfs.
In addition, I saw many report from many other peoples.  For example,
Lubuntu start to use it.

The benefit of zram is very clear.  With my experience, one of the
benefit was to remove jitter of video application with backgroud memory
pressure.  It would be effect of efficient memory usage by compression
but more issue is whether swap is there or not in the system.  Recent
mobile platforms have used JAVA so there are many anonymous pages.  But
embedded system normally are reluctant to use eMMC or SDCard as swap
because there is wear-leveling and latency issues so if we do not use
swap, it means we can't reclaim anoymous pages and at last, we could
encounter OOM kill.  :(

Although we have real storage as swap, it was a problem, too.  Because
it sometime ends up making system very unresponsible caused by slow swap
storage performance.

Quote from Luigi on Google
 "Since Chrome OS was mentioned: the main reason why we don't use swap
  to a disk (rotating or SSD) is because it doesn't degrade gracefully
  and leads to a bad interactive experience.  Generally we prefer to
  manage RAM at a higher level, by transparently killing and restarting
  processes.  But we noticed that zram is fast enough to be competitive
  with the latter, and it lets us make more efficient use of the
  available RAM.  " and he announced.
http://www.spinics.net/lists/linux-mm/msg57717.html

Other uses case is to use zram for block device.  Zram is block device
so anyone can format the block device and mount on it so some guys on
the internet start zram as /var/tmp.
http://forums.gentoo.org/viewtopic-t-838198-start-0.html

Let's promote zram and enhance/maintain it instead of removing.

Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Nitin Gupta <ngupta@vflare.org>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Bob Liu <bob.liu@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Luigi Semenzato <semenzato@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Conflicts:
drivers/block/Makefile

Change-Id: I368f76a5368fffaacbf349cfd78f79cba5da0a0d

9 years agozsmalloc: move it under mm
Minchan Kim [Thu, 30 Jan 2014 23:45:50 +0000 (15:45 -0800)]
zsmalloc: move it under mm

This patch moves zsmalloc under mm directory.

Before that, description will explain why we have needed custom
allocator.

Zsmalloc is a new slab-based memory allocator for storing compressed
pages.  It is designed for low fragmentation and high allocation success
rate on large object, but <= PAGE_SIZE allocations.

zsmalloc differs from the kernel slab allocator in two primary ways to
achieve these design goals.

zsmalloc never requires high order page allocations to back slabs, or
"size classes" in zsmalloc terms.  Instead it allows multiple
single-order pages to be stitched together into a "zspage" which backs
the slab.  This allows for higher allocation success rate under memory
pressure.

Also, zsmalloc allows objects to span page boundaries within the zspage.
This allows for lower fragmentation than could be had with the kernel
slab allocator for objects between PAGE_SIZE/2 and PAGE_SIZE.  With the
kernel slab allocator, if a page compresses to 60% of it original size,
the memory savings gained through compression is lost in fragmentation
because another object of the same size can't be stored in the leftover
space.

This ability to span pages results in zsmalloc allocations not being
directly addressable by the user.  The user is given an
non-dereferencable handle in response to an allocation request.  That
handle must be mapped, using zs_map_object(), which returns a pointer to
the mapped region that can be used.  The mapping is necessary since the
object data may reside in two different noncontigious pages.

The zsmalloc fulfills the allocation needs for zram perfectly

[sjenning@linux.vnet.ibm.com: borrow Seth's quote]
Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: Nitin Gupta <ngupta@vflare.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Bob Liu <bob.liu@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Luigi Semenzato <semenzato@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Conflicts:
mm/Kconfig

Change-Id: I57dad090a3c48db4a67c88e6fa20a4bdbb82d984

9 years agozsmalloc: add more comment
Nitin Cupta [Wed, 11 Dec 2013 02:04:37 +0000 (11:04 +0900)]
zsmalloc: add more comment

This patch adds lots of comments and it will help others
to review and enhance.

Change-Id: I743596bf18e8acf1082c21437c2caef5f15aad71
Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agozsmalloc: add Kconfig for enabling page table method
Minchan Kim [Wed, 11 Dec 2013 02:04:36 +0000 (11:04 +0900)]
zsmalloc: add Kconfig for enabling page table method

Zsmalloc has two methods 1) copy-based and 2) pte based to
access objects that span two pages.
You can see history why we supported two approach from [1].

But it was bad choice that adding hard coding to select arch
which want to use pte based method because there are lots of
SoC in an architecure and they can have different cache size,
CPU speed and so on so it would be better to expose it to user
as selectable Kconfig option like Andrew Morton suggested.

[1] https://lkml.org/lkml/2012/7/11/58

Change-Id: Ieedde9cfac0a7d9bbcb3d5d5b36318efd41132eb
Acked-by: Nitin Gupta <ngupta@vflare.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoStaging: zram: Fix memory leak by refcount mismatch
Rashika Kheria [Sun, 10 Nov 2013 16:43:53 +0000 (22:13 +0530)]
Staging: zram: Fix memory leak by refcount mismatch

As suggested by Minchan Kim and Jerome Marchand "The code in reset_store
get the block device (bdget_disk()) but it does not put it (bdput()) when
it's done using it. The usage count is therefore incremented but never
decremented."

This patch also puts bdput() for all error cases.

Change-Id: I92198df5ff42242ef3627e5d3db4acece7940d61
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoStaging: zram: Fix access of NULL pointer
Rashika Kheria [Wed, 30 Oct 2013 13:06:32 +0000 (18:36 +0530)]
Staging: zram: Fix access of NULL pointer

This patch fixes the bug in reset_store caused by accessing NULL pointer.

The bdev gets its value from bdget_disk() which could fail when memory
pressure is severe and hence can return NULL because allocation of
inode in bdget could fail.

Hence, this patch introduces a check for bdev to prevent reference to a
NULL pointer in the later part of the code. It also removes unnecessary
check of bdev for fsync_bdev().

Change-Id: I47cdcc08076df7958a19406b8502627802c7bd07
Cc: stable <stable@vger.kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoStaging: zram: Fix variable dereferenced before check
Rashika Kheria [Wed, 30 Oct 2013 13:13:32 +0000 (18:43 +0530)]
Staging: zram: Fix variable dereferenced before check

This patch fixes the following Smatch warning in zram_drv.c-
drivers/staging/zram/zram_drv.c:899
destroy_device() warn: variable dereferenced before check 'zram->disk' (see line 896)

Change-Id: If920cb9e1328289c561de89e074523071cd772b5
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agozsmalloc: Fix "map_vm_area" undefined reference errors.
Majunath Goudar [Tue, 8 Oct 2013 10:32:15 +0000 (16:02 +0530)]
zsmalloc: Fix "map_vm_area" undefined reference errors.

This patch adds a MMU dependency to configure the ZSMALLOC in
drivers/staging/zsmalloc/Kconfig. Without this patch, build
system can lead to build failure. This was observed during
randconfig testing, in which ZSMALLOC was enabled w/o MMU being
enabled. Following was the error:

LD      vmlinux
drivers/built-in.o: In function `__zs_map_object':
drivers/staging/zsmalloc/zsmalloc-main.c:650: undefined reference to `map_vm_area'
make: *** [vmlinux] Error 1

Change-Id: Ia78fb6b91949e85f3b9fee18eaffa18205aaccb9
Signed-off-by: Manjunath Goudar <csmanjuvijay@gmail.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoRevert "staging: zram: Add auto loading of module if user opens /dev/zram."
Greg Kroah-Hartman [Thu, 12 Sep 2013 22:41:31 +0000 (15:41 -0700)]
Revert "staging: zram: Add auto loading of module if user opens /dev/zram."

This reverts commit c70bda992c12e593e411c02a52e4bd6985407539.

It's incorrect, Kay writes:
Please just remove it. "devname" is meant to be used for
single-instance devices with a static dev_t, never for things
like zramX.

It will not do anything useful here, it does nothing really
without a statically assigned dev_t, and it should not be used
for devices of this kind anyway.

Change-Id: Ia1503b3cff95e5dd31c934f420025ea252f09129
Reported-by: Tom Gundersen <teg@jklm.no>
Reported-by: Kay Sievers <kay@vrfy.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>