platform/kernel/linux-amlogic.git
7 years agojbd2: don't leak modified metadata buffers on an aborted journal
Theodore Ts'o [Sun, 12 Mar 2017 08:20:48 +0000 (08:20 +0000)]
jbd2: don't leak modified metadata buffers on an aborted journal
am: a9b0c14ba1

Change-Id: Id97b18a6f7b7c9b2c089b5c65dc06370ea98e951

7 years agoFix: Disable sys_membarrier when nohz_full is enabled
Mathieu Desnoyers [Sun, 12 Mar 2017 08:20:39 +0000 (08:20 +0000)]
Fix: Disable sys_membarrier when nohz_full is enabled
am: 3de5a92847

Change-Id: Ib7d8806d40c785e0128af2d846bda76727aa1255

7 years agopower: reset: at91-poweroff: timely shutdown LPDDR memories
Alexandre Belloni [Sun, 12 Mar 2017 08:20:30 +0000 (08:20 +0000)]
power: reset: at91-poweroff: timely shutdown LPDDR memories
am: 206af3d97f

Change-Id: Ia12c6648a103471fc42f49883df2ac34f4efcc8e

7 years agoscsi: use 'scsi_device_from_queue()' for scsi_dh
Hannes Reinecke [Sun, 12 Mar 2017 08:20:19 +0000 (08:20 +0000)]
scsi: use 'scsi_device_from_queue()' for scsi_dh
am: e9dc8334d7

Change-Id: I2d5516fc61216433ba12dde3d6919e95e85a4dbf

7 years agoscsi: aacraid: Reorder Adapter status check
Raghava Aditya Renukunta [Sun, 12 Mar 2017 08:20:10 +0000 (08:20 +0000)]
scsi: aacraid: Reorder Adapter status check
am: 73f5176eca

Change-Id: I7dd8c58d19212accedcbe5ac85178ad71aaf31ab

7 years agoscsi: storvsc: properly set residual data length on errors
Long Li [Sun, 12 Mar 2017 08:20:00 +0000 (08:20 +0000)]
scsi: storvsc: properly set residual data length on errors
am: a50781fe6e

Change-Id: I5413195647ecd402a5383006a5ad57bf2c3e0a8e

7 years agoscsi: storvsc: properly handle SRB_ERROR when sense message is present
Long Li [Sun, 12 Mar 2017 08:19:51 +0000 (08:19 +0000)]
scsi: storvsc: properly handle SRB_ERROR when sense message is present
am: e59693753e

Change-Id: Ic6e4debf549cdd2fe08a72d3c79887370d3825ed

7 years agoscsi: storvsc: use tagged SRB requests if supported by the device
Long Li [Sun, 12 Mar 2017 08:19:42 +0000 (08:19 +0000)]
scsi: storvsc: use tagged SRB requests if supported by the device
am: 27f5ef378d

Change-Id: Iddc56ae5b242dd3d01e9a20b3564bb060aff06ca

7 years agodm raid: fix data corruption on reshape request
Heinz Mauelshagen [Sun, 12 Mar 2017 08:19:33 +0000 (08:19 +0000)]
dm raid: fix data corruption on reshape request
am: 2937e22c23

Change-Id: I3a55981aab612685064716fad5c0e70d021c62bb

7 years agodm round robin: revert "use percpu 'repeat_count' and 'current_path'"
Mike Snitzer [Sun, 12 Mar 2017 08:19:24 +0000 (08:19 +0000)]
dm round robin: revert "use percpu 'repeat_count' and 'current_path'"
am: b7f874eedc

Change-Id: I27c857c373193aff5b5699f1e5052a9f95d1762c

7 years agodm stats: fix a leaked s->histogram_boundaries array
Mikulas Patocka [Sun, 12 Mar 2017 08:19:14 +0000 (08:19 +0000)]
dm stats: fix a leaked s->histogram_boundaries array
am: bad6c16b81

Change-Id: I2e0f245f2f4080cd374009a7f5b834b160cfedc4

7 years agodm cache: fix corruption seen when using cache > 2TB
Joe Thornber [Sun, 12 Mar 2017 08:19:04 +0000 (08:19 +0000)]
dm cache: fix corruption seen when using cache > 2TB
am: 9987feba90

Change-Id: Id78e8b92c942e93784f7c68ef800d0a6f345207c

7 years agoPM / devfreq: Fix wrong trans_stat of passive devfreq device
Chanwoo Choi [Sun, 12 Mar 2017 08:18:55 +0000 (08:18 +0000)]
PM / devfreq: Fix wrong trans_stat of passive devfreq device
am: fe8f92c7be

Change-Id: I7be00653758f0382cf537713eca12c988c0432ae

7 years agoPM / devfreq: Fix available_governor sysfs
Chanwoo Choi [Sun, 12 Mar 2017 08:18:44 +0000 (08:18 +0000)]
PM / devfreq: Fix available_governor sysfs
am: 2294b771a4

Change-Id: Ic585f8f044c6544450539391aefac8d5dcaae51f

7 years agoima: fix ima_d_path() possible race with rename
Mimi Zohar [Sun, 12 Mar 2017 08:18:34 +0000 (08:18 +0000)]
ima: fix ima_d_path() possible race with rename
am: d9cc31683a

Change-Id: I1b44484dab9a62445e9da169e4b30e5f4a122ea6

7 years agoipc/shm: Fix shmat mmap nil-page protection
Davidlohr Bueso [Sun, 12 Mar 2017 08:18:26 +0000 (08:18 +0000)]
ipc/shm: Fix shmat mmap nil-page protection
am: 270e84a1e6

Change-Id: Ibcc5e2d46f533a60c0d1cabb24c42e2c72e5a24a

7 years agosigaltstack: support SS_AUTODISARM for CONFIG_COMPAT
Stas Sergeev [Sun, 12 Mar 2017 08:18:16 +0000 (08:18 +0000)]
sigaltstack: support SS_AUTODISARM for CONFIG_COMPAT
am: 6d94a6b32e

Change-Id: I972940b00813db773e278ce8b6bc46f3cba15988

7 years agomm, vmscan: consider eligible zones in get_scan_count
Michal Hocko [Sun, 12 Mar 2017 08:18:06 +0000 (08:18 +0000)]
mm, vmscan: consider eligible zones in get_scan_count
am: 521e92b198

Change-Id: I39482c52cd53db294f51f2e2956f546487e2f1f9

7 years agomm, vmscan: cleanup lru size claculations
Michal Hocko [Sun, 12 Mar 2017 08:17:57 +0000 (08:17 +0000)]
mm, vmscan: cleanup lru size claculations
am: 710531320a

Change-Id: Ia652a70a9cb48a9372af989cbda7142db4a7b798

7 years agomm balloon: umount balloon_mnt when removing vb device
Yisheng Xie [Sun, 12 Mar 2017 08:17:48 +0000 (08:17 +0000)]
mm balloon: umount balloon_mnt when removing vb device
am: 8f6620e391

Change-Id: I0109a7006112a7eae7172d182b2f658a4b0a60e3

7 years agomm: do not access page->mapping directly on page_endio
Minchan Kim [Sun, 12 Mar 2017 08:17:39 +0000 (08:17 +0000)]
mm: do not access page->mapping directly on page_endio
am: 2c290eede9

Change-Id: I1aefdd04229ab592d2978115d311317a3c6a28d0

7 years agomm: vmpressure: fix sending wrong events on underflow
Vinayak Menon [Sun, 12 Mar 2017 08:17:30 +0000 (08:17 +0000)]
mm: vmpressure: fix sending wrong events on underflow
am: 58d1dbb904

Change-Id: I15c4bffe29045f21eeeb6c554a6771a28ade4733

7 years agomm/page_alloc: fix nodes for reclaim in fast path
Gavin Shan [Sun, 12 Mar 2017 08:17:20 +0000 (08:17 +0000)]
mm/page_alloc: fix nodes for reclaim in fast path
am: d1e8042628

Change-Id: I8535fbab1eede643a486709df9910876daa511b9

7 years agomm, devm_memremap_pages: hold device_hotplug lock over mem_hotplug_{begin, done}
Dan Williams [Sun, 12 Mar 2017 08:17:09 +0000 (08:17 +0000)]
mm, devm_memremap_pages: hold device_hotplug lock over mem_hotplug_{begin, done}
am: f1faaec484

Change-Id: I7e37ea31b7376f63e9ff38b5d40020e793a64c1a

7 years agoCIFS: Fix splice read for non-cached files
Pavel Shilovsky [Sun, 12 Mar 2017 08:17:00 +0000 (08:17 +0000)]
CIFS: Fix splice read for non-cached files
am: c06d74df4e

Change-Id: I5be916690073405f640982ecc15c60f40c02e2f9

7 years agoiommu/vt-d: Tylersburg isoch identity map check is done too late.
Ashok Raj [Sun, 12 Mar 2017 08:16:50 +0000 (08:16 +0000)]
iommu/vt-d: Tylersburg isoch identity map check is done too late.
am: 24427cd71d

Change-Id: Ic7b5db5e24e4c05065038aabc65b0b455e482726

7 years agoiommu/vt-d: Fix some macros that are incorrectly specified in intel-iommu
CQ Tang [Sun, 12 Mar 2017 08:16:41 +0000 (08:16 +0000)]
iommu/vt-d: Fix some macros that are incorrectly specified in intel-iommu
am: 61cb3c6357

Change-Id: I2818b12005c1683156e0042b20ae75b3535a8967

7 years agotpm_tis: fix the error handling of init_tis()
Wei Yongjun [Sun, 12 Mar 2017 08:16:32 +0000 (08:16 +0000)]
tpm_tis: fix the error handling of init_tis()
am: 84c2697c9c

Change-Id: I02ecd01133a00a9f80f0e752c4c35a4111ba3424

7 years agoregulator: Fix regulator_summary for deviceless consumers
Leonard Crestez [Sun, 12 Mar 2017 08:16:23 +0000 (08:16 +0000)]
regulator: Fix regulator_summary for deviceless consumers
am: 2f714ba128

Change-Id: Id9a0b50e5aac52ae70403b220f8f81a77962b500

7 years agocoresight: STM: Balance enable/disable
Suzuki K Poulose [Sun, 12 Mar 2017 08:16:13 +0000 (08:16 +0000)]
coresight: STM: Balance enable/disable
am: 59cd503c8c

Change-Id: Ica27d5cba60c63bed9afe197a07fc122cd7312f9

7 years agostaging: rtl: fix possible NULL pointer dereference
Arnd Bergmann [Sun, 12 Mar 2017 08:16:03 +0000 (08:16 +0000)]
staging: rtl: fix possible NULL pointer dereference
am: c7472b964d

Change-Id: I47f0d514222016b00d200d2c4642e18c23f494fb

7 years agostaging/lustre/lnet: Fix allocation size for sv_cpt_data
Oleg Drokin [Sun, 12 Mar 2017 08:15:54 +0000 (08:15 +0000)]
staging/lustre/lnet: Fix allocation size for sv_cpt_data
am: 148c4526d7

Change-Id: Ib4f7fa4a40c994607381e13db156ad50169bf5a6

7 years agostaging: greybus: loopback: fix broken udelay
Johan Hovold [Sun, 12 Mar 2017 08:15:45 +0000 (08:15 +0000)]
staging: greybus: loopback: fix broken udelay
am: 2893a55e39

Change-Id: I6eddb42dbb3e57bc51b7dbf0b932a30b540ee78c

7 years agohwmon: (it87) Ensure that pwm control cache is current before updating values
Guenter Roeck [Sun, 12 Mar 2017 08:15:37 +0000 (08:15 +0000)]
hwmon: (it87) Ensure that pwm control cache is current before updating values
am: 6c95eba9ca

Change-Id: I5f06541ef3e2cbe962135210fa90372fcb495994

7 years agohwmon: (it87) Do not overwrite bit 2..6 of pwm control registers
Guenter Roeck [Sun, 12 Mar 2017 08:15:27 +0000 (08:15 +0000)]
hwmon: (it87) Do not overwrite bit 2..6 of pwm control registers
am: 4401e4779e

Change-Id: Ida7381d431c60735badcd92e16e8cc922f74cd5c

7 years agoALSA: hda - Fix micmute hotkey problem for a lenovo AIO machine
Hui Wang [Sun, 12 Mar 2017 08:15:18 +0000 (08:15 +0000)]
ALSA: hda - Fix micmute hotkey problem for a lenovo AIO machine
am: acb06ff2d5

Change-Id: I15f2ef78c23f327eabcb841ff948bdf910b61028

7 years agoALSA: hda - Add subwoofer support for Dell Inspiron 17 7000 Gaming
Takashi Iwai [Sun, 12 Mar 2017 08:15:09 +0000 (08:15 +0000)]
ALSA: hda - Add subwoofer support for Dell Inspiron 17 7000 Gaming
am: 2abe620e01

Change-Id: I97a18d5ede44249a3755a5e43403f188aad0efdc

7 years agoALSA: seq: Fix link corruption by event error handling
Takashi Iwai [Sun, 12 Mar 2017 08:14:59 +0000 (08:14 +0000)]
ALSA: seq: Fix link corruption by event error handling
am: 09cd5d3479

Change-Id: I57ce19f2798f3d059d592706a79627d2d5fa35da

7 years agoALSA: ctxfi: Fallback DMA mask to 32bit
Takashi Iwai [Sun, 12 Mar 2017 08:14:50 +0000 (08:14 +0000)]
ALSA: ctxfi: Fallback DMA mask to 32bit
am: 074f6db61f

Change-Id: I7bad93a4a27884ada4da2eb0576de0af8dfc26aa

7 years agoALSA: timer: Reject user params with too small ticks
Takashi Iwai [Sun, 12 Mar 2017 08:14:41 +0000 (08:14 +0000)]
ALSA: timer: Reject user params with too small ticks
am: 5ac9276dd1

Change-Id: I10e2d71df6afce32a43d3d7a9656937a4113ab7b

7 years agoALSA: hda - fix Lewisburg audio issue
Jaroslav Kysela [Sun, 12 Mar 2017 08:14:32 +0000 (08:14 +0000)]
ALSA: hda - fix Lewisburg audio issue
am: 51ce9867c2

Change-Id: Idcc9ef1ea1219407fdbe7d31432b00d2e9bbf32d

7 years agoALSA: hda/realtek - Cannot adjust speaker's volume on a Dell AIO
Kai-Heng Feng [Sun, 12 Mar 2017 08:14:24 +0000 (08:14 +0000)]
ALSA: hda/realtek - Cannot adjust speaker's volume on a Dell AIO
am: ebc3e95502

Change-Id: I882f3c7433e5ca2a9e33e18657362fafc0ee2972

7 years agoARM: dts: at91: Enable DMA on sama5d2_xplained console
Alexandre Belloni [Sun, 12 Mar 2017 08:14:14 +0000 (08:14 +0000)]
ARM: dts: at91: Enable DMA on sama5d2_xplained console
am: 9971863fdd

Change-Id: I9585a72bbc8717c831cb64c495862b5207fa1655

7 years agoARM: dts: at91: Enable DMA on sama5d4_xplained console
Alexandre Belloni [Sun, 12 Mar 2017 08:14:05 +0000 (08:14 +0000)]
ARM: dts: at91: Enable DMA on sama5d4_xplained console
am: f9a1949f8f

Change-Id: Idc392f1a7615552a2173916999283a4d029e41e1

7 years agoARM: at91: define LPDDR types
Alexandre Belloni [Sun, 12 Mar 2017 08:13:56 +0000 (08:13 +0000)]
ARM: at91: define LPDDR types
am: 37e70c4de5

Change-Id: Ia6592a9db0e2d1053b433213a884143637d8acb8

7 years agospi: s3c64xx: fix inconsistency between binding and driver
Andi Shyti [Sun, 12 Mar 2017 08:13:47 +0000 (08:13 +0000)]
spi: s3c64xx: fix inconsistency between binding and driver
am: 404950add4

Change-Id: If19098198f6a85b04b1611e6a193be207ecda379

7 years agoext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea()
Theodore Ts'o [Sun, 12 Mar 2017 08:13:38 +0000 (08:13 +0000)]
ext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea()
am: da1e40237f

Change-Id: I5c85cefcb10cba1d3a0edf6f6968927896929512

7 years agomedia: Properly pass through media entity types in entity enumeration
Sakari Ailus [Sun, 12 Mar 2017 08:13:29 +0000 (08:13 +0000)]
media: Properly pass through media entity types in entity enumeration
am: 719f1765b0

Change-Id: Ia9b9e295799255ca56ddf1dae49a6e372b5055a8

7 years agolirc_dev: LIRC_{G,S}ET_REC_MODE do not work
Sean Young [Sun, 12 Mar 2017 08:13:20 +0000 (08:13 +0000)]
lirc_dev: LIRC_{G,S}ET_REC_MODE do not work
am: ce1e60b492

Change-Id: I23c1e7dfc017e45dd514f41bd6fe9d15fdf469c9

7 years agocxd2820r: fix gpio null pointer dereference
Antti Palosaari [Sun, 12 Mar 2017 08:13:10 +0000 (08:13 +0000)]
cxd2820r: fix gpio null pointer dereference
am: 238442c2b5

Change-Id: I7ceb8c838cda13ea13ce4c669bc87735ab9dd385

7 years agomedia: fix dm1105.c build error
Randy Dunlap [Sun, 12 Mar 2017 08:13:01 +0000 (08:13 +0000)]
media: fix dm1105.c build error
am: 7e5b7798d0

Change-Id: Iaecc7a94ac72a2d9f0ad5a12e241583947a74bfe

7 years agouvcvideo: Fix a wrong macro
Guennadi Liakhovetski [Sun, 12 Mar 2017 08:12:52 +0000 (08:12 +0000)]
uvcvideo: Fix a wrong macro
am: 02789ccd59

Change-Id: I73c8f1df95f61399bdfa6596f36cb4671ba81224

7 years agoam437x-vpfe: always assign bpp variable
Nicolas Iooss [Sun, 12 Mar 2017 08:12:43 +0000 (08:12 +0000)]
am437x-vpfe: always assign bpp variable
am: d6b88a09cc

Change-Id: Ib0feaa9ffe319659036937417271b180ab21ba4d

7 years agommc: sdhci-acpi: support deferred probe
Zhang Rui [Sun, 12 Mar 2017 08:12:33 +0000 (08:12 +0000)]
mmc: sdhci-acpi: support deferred probe
am: 80bbadbc42

Change-Id: I8c7a37edef67fef67815c832cb20d228ea4b6606

7 years agoMIPS: Handle microMIPS jumps in the same way as MIPS32/MIPS64 jumps
Paul Burton [Sun, 12 Mar 2017 08:12:24 +0000 (08:12 +0000)]
MIPS: Handle microMIPS jumps in the same way as MIPS32/MIPS64 jumps
am: 8d06cbd365

Change-Id: I1269796847ae8d9dc0a4a3d427a559b18ef7f89b

7 years agoMIPS: Calculate microMIPS ra properly when unwinding the stack
Paul Burton [Sun, 12 Mar 2017 08:12:14 +0000 (08:12 +0000)]
MIPS: Calculate microMIPS ra properly when unwinding the stack
am: 209ad1941d

Change-Id: I0dd0947122b2efcced99fe0761732f41bd910a30

7 years agoMIPS: Fix is_jump_ins() handling of 16b microMIPS instructions
Paul Burton [Sun, 12 Mar 2017 08:12:06 +0000 (08:12 +0000)]
MIPS: Fix is_jump_ins() handling of 16b microMIPS instructions
am: b14e085086

Change-Id: I13bd3881ddb2f2999b82c111de9d1630d977a858

7 years agoMIPS: Fix get_frame_info() handling of microMIPS function size
Paul Burton [Sun, 12 Mar 2017 08:11:57 +0000 (08:11 +0000)]
MIPS: Fix get_frame_info() handling of microMIPS function size
am: b0b4eb58c5

Change-Id: Ic0a244312e3f1b9cb9a297d9fd692f34dddd4545

7 years agoMIPS: Prevent unaligned accesses during stack unwinding
Paul Burton [Sun, 12 Mar 2017 08:11:49 +0000 (08:11 +0000)]
MIPS: Prevent unaligned accesses during stack unwinding
am: ce449cbdcf

Change-Id: I7e6e790cb8db07930f08cfc1e61a19b516163ae2

7 years agoMIPS: Clear ISA bit correctly in get_frame_info()
Paul Burton [Sun, 12 Mar 2017 08:11:39 +0000 (08:11 +0000)]
MIPS: Clear ISA bit correctly in get_frame_info()
am: d0eae5bbd1

Change-Id: If9cf0de485b0caf623a10b330f9ca3ca743c0e3f

7 years agoMIPS: Lantiq: Keep ethernet enabled during boot
Felix Fietkau [Sun, 12 Mar 2017 08:11:30 +0000 (08:11 +0000)]
MIPS: Lantiq: Keep ethernet enabled during boot
am: 3660e62cfc

Change-Id: I0aa5c31f0205a33589f00b05a7853d90bc5e1004

7 years agoMIPS: OCTEON: Fix copy_from_user fault handling for large buffers
James Cowgill [Sun, 12 Mar 2017 08:11:22 +0000 (08:11 +0000)]
MIPS: OCTEON: Fix copy_from_user fault handling for large buffers
am: 6f35f1fc14

Change-Id: Ie987dd591b46d46b35d3f40a25588543783e55ab

7 years agoMIPS: BCM47XX: Fix button inversion for Asus WL-500W
Mirko Parthey [Sun, 12 Mar 2017 08:11:13 +0000 (08:11 +0000)]
MIPS: BCM47XX: Fix button inversion for Asus WL-500W
am: ef9e73be03

Change-Id: I3390484d5a10ac9c13dca526f392201d9b380d1b

7 years agoMIPS: Fix special case in 64 bit IP checksumming.
Ralf Baechle [Sun, 12 Mar 2017 08:11:05 +0000 (08:11 +0000)]
MIPS: Fix special case in 64 bit IP checksumming.
am: ef674c5eb8

Change-Id: I1314700d061976af7208b99d2792f971e3af971f

7 years agoMIPS: pic32mzda: Fix linker error for pic32_get_pbclk()
Purna Chandra Mandal [Sun, 12 Mar 2017 08:10:57 +0000 (08:10 +0000)]
MIPS: pic32mzda: Fix linker error for pic32_get_pbclk()
am: a8af2054e9

Change-Id: Ide50cfd761d7869693aad1b35b8673fb4bc90bfa

7 years agojbd2: don't leak modified metadata buffers on an aborted journal
Theodore Ts'o [Sun, 5 Feb 2017 04:14:19 +0000 (23:14 -0500)]
jbd2: don't leak modified metadata buffers on an aborted journal

commit e112666b4959b25a8552d63bc564e1059be703e8 upstream.

If the journal has been aborted, we shouldn't mark the underlying
buffer head as dirty, since that will cause the metadata block to get
modified.  And if the journal has been aborted, we shouldn't allow
this since it will almost certainly lead to a corrupted file system.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoFix: Disable sys_membarrier when nohz_full is enabled
Mathieu Desnoyers [Thu, 3 Nov 2016 16:29:28 +0000 (10:29 -0600)]
Fix: Disable sys_membarrier when nohz_full is enabled

commit 907565337ebf998a68cb5c5b2174ce5e5da065eb upstream.

Userspace applications should be allowed to expect the membarrier system
call with MEMBARRIER_CMD_SHARED command to issue memory barriers on
nohz_full CPUs, but synchronize_sched() does not take those into
account.

Given that we do not want unrelated processes to be able to affect
real-time sensitive nohz_full CPUs, simply return ENOSYS when membarrier
is invoked on a kernel with enabled nohz_full CPUs.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Josh Triplett <josh@joshtriplett.org>
CC: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: Lai Jiangshan <jiangshanlai@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agopower: reset: at91-poweroff: timely shutdown LPDDR memories
Alexandre Belloni [Tue, 25 Oct 2016 09:37:59 +0000 (11:37 +0200)]
power: reset: at91-poweroff: timely shutdown LPDDR memories

commit 0b0408745e7ff24757cbfd571d69026c0ddb803c upstream.

LPDDR memories can only handle up to 400 uncontrolled power off. Ensure the
proper power off sequence is used before shutting down the platform.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoscsi: use 'scsi_device_from_queue()' for scsi_dh
Hannes Reinecke [Fri, 17 Feb 2017 08:02:45 +0000 (09:02 +0100)]
scsi: use 'scsi_device_from_queue()' for scsi_dh

commit 857de6e00778738dc3d61f75acbac35bdc48e533 upstream.

The device handler needs to check if a given queue belongs to a scsi
device; only then does it make sense to attach a device handler.

[mkp: dropped flags]

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoscsi: aacraid: Reorder Adapter status check
Raghava Aditya Renukunta [Thu, 16 Feb 2017 20:51:21 +0000 (12:51 -0800)]
scsi: aacraid: Reorder Adapter status check

commit c421530bf848604e97d0785a03b3fe2c62775083 upstream.

The driver currently checks the SELF_TEST_FAILED first and then
KERNEL_PANIC next. Under error conditions(boot code failure) both
SELF_TEST_FAILED and KERNEL_PANIC can be set at the same time.

The driver has the capability to reset the controller on an KERNEL_PANIC,
but not on SELF_TEST_FAILED.

Fixed by first checking KERNEL_PANIC and then the others.

Fixes: e8b12f0fb835223752 ([SCSI] aacraid: Add new code for PMC-Sierra's SRC base controller family)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoscsi: storvsc: properly set residual data length on errors
Long Li [Thu, 15 Dec 2016 02:46:03 +0000 (18:46 -0800)]
scsi: storvsc: properly set residual data length on errors

commit 40630f462824ee24bc00d692865c86c3828094e0 upstream.

On I/O errors, the Windows driver doesn't set data_transfer_length
on error conditions other than SRB_STATUS_DATA_OVERRUN.
In these cases we need to set data_transfer_length to 0,
indicating there is no data transferred. On SRB_STATUS_DATA_OVERRUN,
data_transfer_length is set by the Windows driver to the actual data transferred.

Reported-by: Shiva Krishna <Shiva.Krishna@nimblestorage.com>
Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoscsi: storvsc: properly handle SRB_ERROR when sense message is present
Long Li [Thu, 15 Dec 2016 02:46:02 +0000 (18:46 -0800)]
scsi: storvsc: properly handle SRB_ERROR when sense message is present

commit bba5dc332ec2d3a685cb4dae668c793f6a3713a3 upstream.

When sense message is present on error, we should pass along to the upper
layer to decide how to deal with the error.
This patch fixes connectivity issues with Fiber Channel devices.

Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoscsi: storvsc: use tagged SRB requests if supported by the device
Long Li [Thu, 15 Dec 2016 02:46:01 +0000 (18:46 -0800)]
scsi: storvsc: use tagged SRB requests if supported by the device

commit 3cd6d3d9b1abab8dcdf0800224ce26daac24eea2 upstream.

Properly set SRB flags when hosting device supports tagged queuing.
This patch improves the performance on Fiber Channel disks.

Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agodm raid: fix data corruption on reshape request
Heinz Mauelshagen [Tue, 28 Feb 2017 18:17:49 +0000 (19:17 +0100)]
dm raid: fix data corruption on reshape request

commit d36a19541fe8f392778ac137d60f9be8dfdd8f9d upstream.

The lvm2 sequence to manage dm-raid constructor flags that trigger a
rebuild or a reshape is defined as:

1) load table with flags (e.g. rebuild/delta_disks/data_offset)
2) clear out the flags in lvm2 metadata
3) store the lvm2 metadata, reload the table to reset the flags
   previously established during the initial load (1) -- in order to
   prevent repeatedly requesting a rebuild or a reshape on activation

Currently, loading an inactive table with rebuild/reshape flags
specified will cause dm-raid to rebuild/reshape on resume and thus start
updating the raid metadata (about the progress).  When the second table
reload, to reset the flags, occurs the constructor accesses the volatile
progress state kept in the raid superblocks.  Because the active mapping
is still processing the rebuild/reshape, that position will be stale by
the time the device is resumed.

In the reshape case, this causes data corruption by processing already
reshaped stripes again.  In the rebuild case, it does _not_ cause data
corruption but instead involves superfluous rebuilds.

Fix by keeping the raid set frozen during the first resume and then
allow the rebuild/reshape during the second resume.

Fixes: 9dbd1aa3a ("dm raid: add reshaping support to the target")
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agodm round robin: revert "use percpu 'repeat_count' and 'current_path'"
Mike Snitzer [Fri, 17 Feb 2017 04:57:17 +0000 (23:57 -0500)]
dm round robin: revert "use percpu 'repeat_count' and 'current_path'"

commit 37a098e9d10db6e2efc05fe61e3a6ff2e9802c53 upstream.

The sloppy nature of lockless access to percpu pointers
(s->current_path) in rr_select_path(), from multiple threads, is
causing some paths to used more than others -- which results in less
IO performance being observed.

Revert these upstream commits to restore truly symmetric round-robin
IO submission in DM multipath:

b0b477c dm round robin: use percpu 'repeat_count' and 'current_path'
802934b dm round robin: do not use this_cpu_ptr() without having preemption disabled

There is no benefit to all this complexity if repeat_count = 1 (which is
the recommended default).

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agodm stats: fix a leaked s->histogram_boundaries array
Mikulas Patocka [Wed, 15 Feb 2017 17:06:19 +0000 (12:06 -0500)]
dm stats: fix a leaked s->histogram_boundaries array

commit 6085831883c25860264721df15f05bbded45e2a2 upstream.

Fixes: dfcfac3e4cd9 ("dm stats: collect and report histogram of IO latencies")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agodm cache: fix corruption seen when using cache > 2TB
Joe Thornber [Thu, 9 Feb 2017 16:46:18 +0000 (11:46 -0500)]
dm cache: fix corruption seen when using cache > 2TB

commit ca763d0a53b264a650342cee206512bc92ac7050 upstream.

A rounding bug due to compiler generated temporary being 32bit was found
in remap_to_cache().  A localized cast in remap_to_cache() fixes the
corruption but this preferred fix (changing from uint32_t to sector_t)
eliminates potential for future rounding errors elsewhere.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoPM / devfreq: Fix wrong trans_stat of passive devfreq device
Chanwoo Choi [Tue, 31 Jan 2017 06:38:17 +0000 (15:38 +0900)]
PM / devfreq: Fix wrong trans_stat of passive devfreq device

commit 30582c25a4b4e0a5e456a309fde79b845e9473b2 upstream.

Until now, the trans_stat information of passive devfreq is not updated.
This patch updates the trans_stat information after setting the target
frequency of passive devfreq device.

Fixes: 996133119f57 ("PM / devfreq: Add new passive governor")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoPM / devfreq: Fix available_governor sysfs
Chanwoo Choi [Tue, 31 Jan 2017 06:38:16 +0000 (15:38 +0900)]
PM / devfreq: Fix available_governor sysfs

commit bcf23c79c4e46130701370af4383b61a3cba755c upstream.

The devfreq using passive governor is not able to change the governor.
So, the user can not change the governor through 'available_governor' sysfs
entry. Also, the devfreq which don't use the passive governor is not able to
change to 'passive' governor on the fly.

Fixes: 996133119f57 ("PM / devfreq: Add new passive governor")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoima: fix ima_d_path() possible race with rename
Mimi Zohar [Tue, 17 Jan 2017 11:45:41 +0000 (06:45 -0500)]
ima: fix ima_d_path() possible race with rename

commit bc15ed663e7e53ee4dc3e60f8d09c93a0528c694 upstream.

On failure to return a pathname from ima_d_path(), a pointer to
dname is returned, which is subsequently used in the IMA measurement
list, the IMA audit records, and other audit logging.  Saving the
pointer to dname for later use has the potential to race with rename.

Intead of returning a pointer to dname on failure, this patch returns
a pointer to a copy of the filename.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoipc/shm: Fix shmat mmap nil-page protection
Davidlohr Bueso [Mon, 27 Feb 2017 22:28:24 +0000 (14:28 -0800)]
ipc/shm: Fix shmat mmap nil-page protection

commit 95e91b831f87ac8e1f8ed50c14d709089b4e01b8 upstream.

The issue is described here, with a nice testcase:

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

The problem is that shmat() calls do_mmap_pgoff() with MAP_FIXED, and
the address rounded down to 0.  For the regular mmap case, the
protection mentioned above is that the kernel gets to generate the
address -- arch_get_unmapped_area() will always check for MAP_FIXED and
return that address.  So by the time we do security_mmap_addr(0) things
get funky for shmat().

The testcase itself shows that while a regular user crashes, root will
not have a problem attaching a nil-page.  There are two possible fixes
to this.  The first, and which this patch does, is to simply allow root
to crash as well -- this is also regular mmap behavior, ie when hacking
up the testcase and adding mmap(...  |MAP_FIXED).  While this approach
is the safer option, the second alternative is to ignore SHM_RND if the
rounded address is 0, thus only having MAP_SHARED flags.  This makes the
behavior of shmat() identical to the mmap() case.  The downside of this
is obviously user visible, but does make sense in that it maintains
semantics after the round-down wrt 0 address and mmap.

Passes shm related ltp tests.

Link: http://lkml.kernel.org/r/1486050195-18629-1-git-send-email-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Reported-by: Gareth Evans <gareth.evans@contextis.co.uk>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agosigaltstack: support SS_AUTODISARM for CONFIG_COMPAT
Stas Sergeev [Mon, 27 Feb 2017 22:27:25 +0000 (14:27 -0800)]
sigaltstack: support SS_AUTODISARM for CONFIG_COMPAT

commit 441398d378f29a5ad6d0fcda07918e54e4961800 upstream.

Currently SS_AUTODISARM is not supported in compatibility mode, but does
not return -EINVAL either.  This makes dosemu built with -m32 on x86_64
to crash.  Also the kernel's sigaltstack selftest fails if compiled with
-m32.

This patch adds the needed support.

Link: http://lkml.kernel.org/r/20170205101213.8163-2-stsp@list.ru
Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
Cc: Milosz Tanski <milosz@adfin.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Waiman Long <Waiman.Long@hpe.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm, vmscan: consider eligible zones in get_scan_count
Michal Hocko [Wed, 22 Feb 2017 23:46:01 +0000 (15:46 -0800)]
mm, vmscan: consider eligible zones in get_scan_count

commit 71ab6cfe88dcf9f6e6a65eb85cf2bda20a257682 upstream.

get_scan_count() considers the whole node LRU size when

 - doing SCAN_FILE due to many page cache inactive pages
 - calculating the number of pages to scan

In both cases this might lead to unexpected behavior especially on 32b
systems where we can expect lowmem memory pressure very often.

A large highmem zone can easily distort SCAN_FILE heuristic because
there might be only few file pages from the eligible zones on the node
lru and we would still enforce file lru scanning which can lead to
trashing while we could still scan anonymous pages.

The later use of lruvec_lru_size can be problematic as well.  Especially
when there are not many pages from the eligible zones.  We would have to
skip over many pages to find anything to reclaim but shrink_node_memcg
would only reduce the remaining number to scan by SWAP_CLUSTER_MAX at
maximum.  Therefore we can end up going over a large LRU many times
without actually having chance to reclaim much if anything at all.  The
closer we are out of memory on lowmem zone the worse the problem will
be.

Fix this by filtering out all the ineligible zones when calculating the
lru size for both paths and consider only sc->reclaim_idx zones.

The patch would need to be tweaked a bit to apply to 4.10 and older but
I will do that as soon as it hits the Linus tree in the next merge
window.

Link: http://lkml.kernel.org/r/20170117103702.28542-3-mhocko@kernel.org
Fixes: b2e18757f2c9 ("mm, vmscan: begin reclaiming pages on a per-node basis")
Signed-off-by: Michal Hocko <mhocko@suse.com>
Tested-by: Trevor Cordes <trevor@tecnopolis.ca>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm, vmscan: cleanup lru size claculations
Michal Hocko [Wed, 22 Feb 2017 23:45:58 +0000 (15:45 -0800)]
mm, vmscan: cleanup lru size claculations

commit fd538803731e50367b7c59ce4ad3454426a3d671 upstream.

lruvec_lru_size returns the full size of the LRU list while we sometimes
need a value reduced only to eligible zones (e.g.  for lowmem requests).
inactive_list_is_low is one such user.  Later patches will add more of
them.  Add a new parameter to lruvec_lru_size and allow it filter out
zones which are not eligible for the given context.

Link: http://lkml.kernel.org/r/20170117103702.28542-2-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm balloon: umount balloon_mnt when removing vb device
Yisheng Xie [Fri, 24 Feb 2017 23:00:40 +0000 (15:00 -0800)]
mm balloon: umount balloon_mnt when removing vb device

commit 9c57b5808c625f4fc93da330b932647eaff321f7 upstream.

With CONFIG_BALLOON_COMPACTION=y the kernel will mount balloon_mnt for
balloon page migration when we probe a virtio_balloon device.  However
we do not unmount it when removing the device.  Fix this.

Fixes: b1123ea6d3b3 ("mm: balloon: use general non-lru movable page feature")
Link: http://lkml.kernel.org/r/1486531318-35189-1-git-send-email-xieyisheng1@huawei.com
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Rafael Aquini <aquini@redhat.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Gioh Kim <gi-oh.kim@profitbricks.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm: do not access page->mapping directly on page_endio
Minchan Kim [Fri, 24 Feb 2017 22:59:59 +0000 (14:59 -0800)]
mm: do not access page->mapping directly on page_endio

commit dd8416c47715cf324c9a16f13273f9fda87acfed upstream.

With rw_page, page_endio is used for completing IO on a page and it
propagates write error to the address space if the IO fails.  The
problem is it accesses page->mapping directly which might be okay for
file-backed pages but it shouldn't for anonymous page.  Otherwise, it
can corrupt one of field from anon_vma under us and system goes panic
randomly.

swap_writepage
  bdev_writepage
    ops->rw_page

I encountered the BUG during developing new zram feature and it was
really hard to figure it out because it made random crash, somtime
mmap_sem lockdep, sometime other places where places never related to
zram/zsmalloc, and not reproducible with some configuration.

When I consider how that bug is subtle and people do fast-swap test with
brd, it's worth to add stable mark, I think.

Fixes: dd6bd0d9c7db ("swap: use bdev_read_page() / bdev_write_page()")
Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm: vmpressure: fix sending wrong events on underflow
Vinayak Menon [Fri, 24 Feb 2017 22:59:39 +0000 (14:59 -0800)]
mm: vmpressure: fix sending wrong events on underflow

commit e1587a4945408faa58d0485002c110eb2454740c upstream.

At the end of a window period, if the reclaimed pages is greater than
scanned, an unsigned underflow can result in a huge pressure value and
thus a critical event.  Reclaimed pages is found to go higher than
scanned because of the addition of reclaimed slab pages to reclaimed in
shrink_node without a corresponding increment to scanned pages.

Minchan Kim mentioned that this can also happen in the case of a THP
page where the scanned is 1 and reclaimed could be 512.

Link: http://lkml.kernel.org/r/1486641577-11685-1-git-send-email-vinmenon@codeaurora.org
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Rik van Riel <riel@redhat.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Shiraz Hashim <shashim@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm/page_alloc: fix nodes for reclaim in fast path
Gavin Shan [Fri, 24 Feb 2017 22:59:33 +0000 (14:59 -0800)]
mm/page_alloc: fix nodes for reclaim in fast path

commit e02dc017c3032dcdce1b993af0db135462e1b4b7 upstream.

When @node_reclaim_node isn't 0, the page allocator tries to reclaim
pages if the amount of free memory in the zones are below the low
watermark.  On Power platform, none of NUMA nodes are scanned for page
reclaim because no nodes match the condition in zone_allows_reclaim().
On Power platform, RECLAIM_DISTANCE is set to 10 which is the distance
of Node-A to Node-A.  So the preferred node even won't be scanned for
page reclaim.

   __alloc_pages_nodemask()
   get_page_from_freelist()
      zone_allows_reclaim()

Anton proposed the test code as below:

   # cat alloc.c
      :
   int main(int argc, char *argv[])
   {
void *p;
unsigned long size;
unsigned long start, end;

start = time(NULL);
size = strtoul(argv[1], NULL, 0);
printf("To allocate %ldGB memory\n", size);

size <<= 30;
p = malloc(size);
assert(p);
memset(p, 0, size);

end = time(NULL);
printf("Used time: %ld seconds\n", end - start);
sleep(3600);
return 0;
   }

The system I use for testing has two NUMA nodes.  Both have 128GB
memory.  In below scnario, the page caches on node#0 should be reclaimed
when it encounters pressure to accommodate request of allocation.

   # echo 2 > /proc/sys/vm/zone_reclaim_mode; \
     sync; \
     echo 3 > /proc/sys/vm/drop_caches; \
   # taskset -c 0 cat file.32G > /dev/null; \
     grep FilePages /sys/devices/system/node/node0/meminfo
     Node 0 FilePages:       33619712 kB
   # taskset -c 0 ./alloc 128
   # grep FilePages /sys/devices/system/node/node0/meminfo
     Node 0 FilePages:       33619840 kB
   # grep MemFree /sys/devices/system/node/node0/meminfo
     Node 0 MemFree:          186816 kB

With the patch applied, the pagecache on node-0 is reclaimed when its
free memory is running out.  It's the expected behaviour.

   # echo 2 > /proc/sys/vm/zone_reclaim_mode; \
     sync; \
     echo 3 > /proc/sys/vm/drop_caches
   # taskset -c 0 cat file.32G > /dev/null; \
     grep FilePages /sys/devices/system/node/node0/meminfo
     Node 0 FilePages:       33605568 kB
   # taskset -c 0 ./alloc 128
   # grep FilePages /sys/devices/system/node/node0/meminfo
     Node 0 FilePages:        1379520 kB
   # grep MemFree /sys/devices/system/node/node0/meminfo
     Node 0 MemFree:           317120 kB

Fixes: 5f7a75acdb24 ("mm: page_alloc: do not cache reclaim distances")
Link: http://lkml.kernel.org/r/1486532455-29613-1-git-send-email-gwshan@linux.vnet.ibm.com
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomm, devm_memremap_pages: hold device_hotplug lock over mem_hotplug_{begin, done}
Dan Williams [Fri, 24 Feb 2017 22:55:45 +0000 (14:55 -0800)]
mm, devm_memremap_pages: hold device_hotplug lock over mem_hotplug_{begin, done}

commit b5d24fda9c3dce51fcb4eee459550a458eaaf1e2 upstream.

The mem_hotplug_{begin,done} lock coordinates with {get,put}_online_mems()
to hold off "readers" of the current state of memory from new hotplug
actions.  mem_hotplug_begin() expects exclusive access, via the
device_hotplug lock, to set mem_hotplug.active_writer.  Calling
mem_hotplug_begin() without locking device_hotplug can lead to
corrupting mem_hotplug.refcount and missed wakeups / soft lockups.

[dan.j.williams@intel.com: v2]
Link: http://lkml.kernel.org/r/148728203365.38457.17804568297887708345.stgit@dwillia2-desk3.amr.corp.intel.com
Link: http://lkml.kernel.org/r/148693885680.16345.17802627926777862337.stgit@dwillia2-desk3.amr.corp.intel.com
Fixes: f931ab479dd2 ("mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done}")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Toshi Kani <toshi.kani@hpe.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoCIFS: Fix splice read for non-cached files
Pavel Shilovsky [Thu, 19 Jan 2017 21:53:15 +0000 (13:53 -0800)]
CIFS: Fix splice read for non-cached files

commit 9c25702cee1405099f982894c865c163de7909a8 upstream.

Currently we call copy_page_to_iter() for uncached reading into a pipe.
This is wrong because it treats pages as VFS cache pages and copies references
rather than actual data. When we are trying to read from the pipe we end up
calling page_cache_pipe_buf_confirm() which returns -ENODATA. This error
is translated into 0 which is returned to a user.

This issue is reproduced by running xfs-tests suite (generic test #249)
against mount points with "cache=none". Fix it by mapping pages manually
and calling copy_to_iter() that copies data into the pipe.

Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoiommu/vt-d: Tylersburg isoch identity map check is done too late.
Ashok Raj [Mon, 30 Jan 2017 17:39:53 +0000 (09:39 -0800)]
iommu/vt-d: Tylersburg isoch identity map check is done too late.

commit 21e722c4c8377b5bc82ad058fed12165af739c1b upstream.

The check to set identity map for tylersburg is done too late. It needs
to be done before the check for identity_map domain is done.

To: Joerg Roedel <joro@8bytes.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Cc: Ashok Raj <ashok.raj@intel.com>
Fixes: 86080ccc22 ("iommu/vt-d: Allocate si_domain in init_dmars()")
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Reported-by: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoiommu/vt-d: Fix some macros that are incorrectly specified in intel-iommu
CQ Tang [Mon, 30 Jan 2017 17:39:52 +0000 (09:39 -0800)]
iommu/vt-d: Fix some macros that are incorrectly specified in intel-iommu

commit aaa59306b0b7e0ca4ba92cc04c5db101cbb1c096 upstream.

Some of the macros are incorrect with wrong bit-shifts resulting in picking
the incorrect invalidation granularity. Incorrect Source-ID in extended
devtlb invalidation caused device side errors.

To: Joerg Roedel <joro@8bytes.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Cc: CQ Tang <cq.tang@intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Fixes: 2f26e0a9 ("iommu/vt-d: Add basic SVM PASID support")
Signed-off-by: CQ Tang <cq.tang@intel.com>
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Tested-by: CQ Tang <cq.tang@intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agotpm_tis: fix the error handling of init_tis()
Wei Yongjun [Tue, 7 Feb 2017 15:51:47 +0000 (15:51 +0000)]
tpm_tis: fix the error handling of init_tis()

commit 5939eaf4f9d432586dd2cdeea778506471e8088e upstream.

Add the missing platform_driver_unregister() and remove the duplicate
platform_device_unregister(force_pdev) in the error handling case.

Fixes: 00194826e6be ("tpm_tis: Clean up the force=1 module parameter")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoregulator: Fix regulator_summary for deviceless consumers
Leonard Crestez [Tue, 14 Feb 2017 15:31:03 +0000 (17:31 +0200)]
regulator: Fix regulator_summary for deviceless consumers

commit e42a46b6f52473661ad192f76a128a68fe301df4 upstream.

It is allowed to call regulator_get with a NULL dev argument
(_regulator_get explicitly checks for it) but this causes an error later
when printing /sys/kernel/debug/regulator_summary.

Fix this by explicitly handling "deviceless" consumers in the debugfs code.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agocoresight: STM: Balance enable/disable
Suzuki K Poulose [Mon, 16 Jan 2017 18:00:00 +0000 (18:00 +0000)]
coresight: STM: Balance enable/disable

commit 4474f4c40a9c607c7317e686b23619b7b768004f upstream.

The stm is automatically enabled when an application sets the policy
via ->link() call back by using coresight_enable(), which keeps the
refcount of the current users of the STM. However, the unlink() callback
issues stm_disable() directly, which leaves the STM turned off, without
the coresight layer knowing about it. This prevents any further uses
of the STM hardware as the coresight layer still thinks the STM is
turned on and doesn't enable the hardware when required. Even manually
enabling the STM via sysfs can't really enable the hw.

e.g,

 $ echo 1 > $CS_DEVS/$ETR/enable_sink
 $ mkdir -p $CONFIG_FS/stp-policy/$source.0/stm_test/
 $ echo 32768 65535 > $CONFIG_FS/stp-policy/$source.0/stm_test/channels
 $ echo 64 > $CS_DEVS/$source/traceid
 $ ./stm_app
 Sending 64000 byte blocks of pattern 0 at 0us intervals
 Success to map channel(32768~32783) to 0xffffa95fa000
 Sending on channel 32768
 $ dd if=/dev/$ETR of=~/trace.bin.1
 597+1 records in
 597+1 records out
 305920 bytes (306 kB) copied, 0.399952 s, 765 kB/s
 $ ./stm_app
 Sending 64000 byte blocks of pattern 0 at 0us intervals
 Success to map channel(32768~32783) to 0xffff7e9e2000
 Sending on channel 32768
 $ dd if=/dev/$ETR of=~/trace.bin.2
 0+0 records in
 0+0 records out
 0 bytes (0 B) copied, 0.0232083 s, 0.0 kB/s

 Note that we don't get any data from the ETR for the second session.

 Also dmesg shows :

 [   77.520458] coresight-tmc 20800000.etr: TMC-ETR enabled
 [   77.537097] coresight-replicator etr_replicator@20890000: REPLICATOR enabled
 [   77.558828] coresight-replicator main_replicator@208a0000: REPLICATOR enabled
 [   77.581068] coresight-funnel 208c0000.main_funnel: FUNNEL inport 0 enabled
 [   77.602217] coresight-tmc 20840000.etf: TMC-ETF enabled
 [   77.618422] coresight-stm 20860000.stm: STM tracing enabled
 [  139.554252] coresight-stm 20860000.stm: STM tracing disabled
  # End of first tracing session
 [  146.351135] coresight-tmc 20800000.etr: TMC read start
 [  146.514486] coresight-tmc 20800000.etr: TMC read end
  # Note that the STM is not turned on via stm_generic_link()->coresight_enable()
  # and hence none of the components are turned on.
 [  152.479080] coresight-tmc 20800000.etr: TMC read start
 [  152.542632] coresight-tmc 20800000.etr: TMC read end

This patch fixes the problem by balancing the unlink operation by using
the coresight_disable(), keeping the coresight layer in sync with the
hardware state and thus allowing normal usage of the STM component.

Fixes: commit 237483aa5cf43 ("coresight: stm: adding driver for CoreSight STM component")
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Reported-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: rtl: fix possible NULL pointer dereference
Arnd Bergmann [Wed, 11 Jan 2017 14:53:08 +0000 (15:53 +0100)]
staging: rtl: fix possible NULL pointer dereference

commit 6e017006022abfea5d2466cad936065f45763ad1 upstream.

gcc-7 detects that wlanhdr_to_ethhdr() in two drivers calls memcpy() with
a destination argument that an earlier function call may have set to NULL:

staging/rtl8188eu/core/rtw_recv.c: In function 'wlanhdr_to_ethhdr':
staging/rtl8188eu/core/rtw_recv.c:1318:2: warning: argument 1 null where non-null expected [-Wnonnull]
staging/rtl8712/rtl871x_recv.c: In function 'r8712_wlanhdr_to_ethhdr':
staging/rtl8712/rtl871x_recv.c:649:2: warning: argument 1 null where non-null expected [-Wnonnull]

I'm fixing this by adding a NULL pointer check and returning failure
from the function, which is hopefully already handled properly.

This seems to date back to when the drivers were originally added,
so backporting the fix to stable seems appropriate. There are other
related realtek drivers in the kernel, but none of them contain a
function with a similar name or produce this warning.

Fixes: 1cc18a22b96b ("staging: r8188eu: Add files for new driver - part 5")
Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging/lustre/lnet: Fix allocation size for sv_cpt_data
Oleg Drokin [Sun, 19 Feb 2017 21:35:59 +0000 (16:35 -0500)]
staging/lustre/lnet: Fix allocation size for sv_cpt_data

commit dc7ffefdcc28a45214aa707fdc3df6a5e611ba09 upstream.

This is unbreaking another of those "stealth" janitor
patches that got in and subtly broke some things.

sv_cpt_data is a pointer to pointer, so need to
dereference it twice to allocate the correct structure size.

Fixes: 9899cb68c6c2 ("Staging: lustre: rpc: Use sizeof type *pointer instead of sizeof type.")
CC: Sandhya Bankar <bankarsandhya512@gmail.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: greybus: loopback: fix broken udelay
Johan Hovold [Thu, 26 Jan 2017 11:37:32 +0000 (12:37 +0100)]
staging: greybus: loopback: fix broken udelay

commit 33b8807a6fe10d0e675e0704444373a6fad93188 upstream.

The loopback driver allows the user to set a minimum delay of up to one
second to be inserted between test iterations (i.e. request
submissions). The delay is currently specified in microseconds and is
implemented using udelay.

Busy looping for long periods is not just anti-social; udelay must not
be used for delays longer than a few milliseconds due to the risk of
integer overflow.

Replace the broken udelay with a usleep_range with a 100 us range for
short delays (< 20 ms) and otherwise revert to using msleep.

Fixes: b36f04fa9417 ("greybus: loopback: Convert thread delay to microseconds")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agohwmon: (it87) Ensure that pwm control cache is current before updating values
Guenter Roeck [Wed, 8 Feb 2017 22:02:59 +0000 (14:02 -0800)]
hwmon: (it87) Ensure that pwm control cache is current before updating values

commit 82dbe987b70042b340f851bdc969a971081e5f02 upstream.

If sensor attributes were never read, the pwm control data has not been
initiialized, which can cause wrong driver behavior. Ensure that cached
data is current before acting on it.

Reported-by: Kevin Folz <kfolz@evertz.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agohwmon: (it87) Do not overwrite bit 2..6 of pwm control registers
Guenter Roeck [Wed, 8 Feb 2017 22:07:42 +0000 (14:07 -0800)]
hwmon: (it87) Do not overwrite bit 2..6 of pwm control registers

commit 4c7b8ca1ae5ed9e27014732c8a918ba11a86cf09 upstream.

In IT8620E, after setting pwm control to manual, it was observed that
pwm values for fan 4..6 have reversed results (writing 0 results in fans
running at full speed, writing 255 results in fans turned off).

With the new PWM control, pwm polarity for pwm control 4..6 is specified
in its pwm control registers. Those registers are overwritten when setting
the pwm mode or the temperature mapping. Do not touch bit 2..6 of pwm
control registers on register writes to fix the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>