Commit Graph

692575 Commits

Author SHA1 Message Date
Florian Eckert 7074d0a927 hwmon: (ltq-cputemp) add cpu temp sensor driver
Add the lantiq cpu temperature sensor support for xrx200.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-09-01 07:24:14 -07:00
Florian Eckert 7a3b68b907 hwmon: (ltq-cputemp) add devicetree bindings documentation
Document the devicetree bindings for the ltq-cputemp

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-09-01 07:24:12 -07:00
Vadim Pasternak 610526527a hwmon: (pmbus) Add support for Texas Instruments tps53679 device
The below lists of VOUT_MODE command readout with their related VID
protocols, Digital to Analog Converter steps, supported by the device:
VR12.0 mode, 5-mV DAC - 0x21
VR12.5 mode, 10-mV DAC - 0x22
VR13.0 mode, 10-mV DAC - 0x24
IMVP8 mode, 5-mV DAC - 0x25
VR13.0 mode, 5-mV DAC - 0x27

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-30 18:01:08 -07:00
Guenter Roeck 4e6fe29fb8 Merge remote-tracking branch 'lee/ib-mfd-hwmon-4.14' into hwmon-next 2017-08-30 06:32:01 -07:00
Colin Ian King 6930125858 hwmon: (asc7621) make several arrays static const
Don't populate the arrays on the stack, instead make them static.
Makes the object code smaller by over 950 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  26144	  18768	    352	  45264	   b0d0	drivers/hwmon/asc7621.o

After:
   text	   data	    bss	    dec	    hex	filename
  25029	  18928	    352	  44309	   ad15	drivers/hwmon/asc7621.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-30 06:31:49 -07:00
Xo Wang 5783ec2e5c hwmon: (pmbus/lm25066) Add support for TI LM5066I
The TI LM5066I hotswap controller is a more accurate version of the
LM5066 device already supported. It has different measurement conversion
coefficients than the LM5066, so it needs to be recognized as a
different device.

Signed-off-by: Xo Wang <xow@google.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-30 06:31:13 -07:00
Xo Wang ee983171d4 hwmon: (pmbus/lm25066) Offset coefficient depends on CL
When converting the DIRECT format CURRENT_IN and POWER commands, make
the offset coefficient ("b") predicate on the value of the current limit
setting.

Signed-off-by: Xo Wang <xow@google.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-30 06:31:12 -07:00
Vadim Pasternak d4977c083a hwmon: (pmbus) Add support for Intel VID protocol VR13
The below lists of VOUT_MODE command readout with their related VID
protocols, Digital to Analog Converter steps:
- VR13.0 mode, 10-mV DAC - 0x24
- VR13.0 mode, 5-mV DAC - 0x27

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-30 06:31:00 -07:00
Edward A. James caf59a5b63 Documentation: hwmon: Document the IBM CFF power supply
Signed-off-by: Edward A. James <eajames@us.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-29 18:07:13 -07:00
Edward A. James f69316d62c hwmon: (pmbus) Add IBM Common Form Factor (CFF) power supply driver
Add the driver to monitor IBM CFF power supplies with hwmon over
pmbus.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
[groeck: drop 'default n'; include bitops.h instead of jiffies.h]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-29 18:06:18 -07:00
Edward A. James 74560e4a44 dt-bindings: hwmon: Document the IBM CCF power supply version 1
Signed-off-by: Edward A. James <eajames@us.ibm.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-29 18:01:25 -07:00
Arvind Yadav 1dad2e958a hwmon: (ftsteutates) constify i2c_device_id
i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-29 17:44:23 -07:00
Sebastian Reichel 4f16cab19a hwmon: da9052: Add support for TSI channel
TSI channel has a 4 channel mux connected to it and is normally
used for touchscreen support. The hardware may alternatively
use it as general purpose adc.

Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-08-22 08:45:02 +01:00
Sebastian Reichel ebf555111b mfd: da9052: Make touchscreen registration optional
If the touchscreen pins are used as general purpose analogue
input, the touchscreen driver should not be used. The pins
will be handled by the existing hwmon driver instead.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-08-22 08:44:55 +01:00
Sebastian Reichel 7fe9899ef4 hwmon: da9052: Replace S_IRUGO with 0444
Fix checkpatch warnings about S_IRUGO being less readable than
providing the permissions octal as '0444'.

Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-08-22 08:44:46 +01:00
Sebastian Reichel 67dfabe3a0 mfd: da9052: Add register details for TSI
Add register details an channels definition for using the TSI
registers in the hwmon driver.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-08-22 08:44:37 +01:00
Arnd Bergmann d5553c2619 hwmon: (aspeed-pwm) add THERMAL dependency
With CONFIG_THERMAL=m, a built-in aspeed pwm tacho driver causes
a link error:

drivers/hwmon/aspeed-pwm-tacho.o: In function `aspeed_pwm_tacho_probe':
aspeed-pwm-tacho.c:(.text+0x7f0): undefined reference to `thermal_of_cooling_device_register'

This adds a dependency similar to what other hwmon drivers use,
ensuring that the aspeed driver cannot be built-in in this
case but has to be a module. With THERMAL=n, we still allow building it.

Fixes: 2d7a548a3e ("drivers: hwmon: Support for ASPEED PWM/Fan tach")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-15 07:54:34 -07:00
Edward A. James 1e069dfd96 hwmon: (pmbus) Add debugfs for status registers
Export all the available status registers through debugfs. This is
useful for hardware diagnostics, especially on multi-page pmbus devices,
as user-space access of the i2c space could corrupt the pmbus page
accounting.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-14 12:22:07 -07:00
Mykola Kostenok f198907d2f hwmon: (aspeed-pwm-tacho) cooling device support.
Add support in aspeed-pwm-tacho driver for cooling device creation.
This cooling device could be bound to a thermal zone
for the thermal control. Device will appear in /sys/class/thermal
folder as cooling_deviceX. Then it could be bound to particular
thermal zones. Allow specification of the cooling levels
vector - PWM duty cycle values in a range from 0 to 255
which correspond to thermal cooling states.

Signed-off-by: Mykola Kostenok <c_mykolak@mellanox.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Mykola Kostenok 5e047541c1 Documentation: dt-bindings: aspeed-pwm-tacho cooling device.
It's add support for cooling device creation to
aspeed-pwm-tacho.
Cooling device could be bound to a thermal zone
for the thermal control.

Signed-off-by: Mykola Kostenok <c_mykolak@mellanox.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Edward A. James c159be9e90 hwmon: (pmbus): Add generic alarm bit for iin and pin
Add PB_STATUS_INPUT as the generic alarm bit for iin and pin. We also
need to redo the status register checking before setting up the boolean
attribute, since it won't necessarily check STATUS_WORD if the device
doesn't support it, which we need for this bit.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Edward A. James cbcdec6202 hwmon: (pmbus): Access word data for STATUS_WORD
Pmbus always reads byte data from the status register, even if
configured to use STATUS_WORD. Use a function pointer to read the
correct amount of data from the registers.
Also switch to try STATUS_WORD first before STATUS_BYTE on init.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Edward A. James a66a6eb9db hwmon: (pmbus): Switch status registers to 16 bit
Switch the storage of status registers to 16 bit values. This allows us
to store all the bits of STATUS_WORD.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Maciej S. Szmigiero 384548e569 hwmon: (it87) Reapply probe path chip registers settings after resume
After a suspend / resume cycle we possibly need to reapply chip registers
settings that we had set or fixed in a probe path, since they might have
been reset to default values or set incorrectly by a BIOS again.

Tested on a Gigabyte M720-US3 board, which requires routing internal VCCH5V
to in7 (and had it wrong again on resume from S3).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
[groeck: Return value from it87_resume_sio() is unused; make it void]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Maciej S. Szmigiero 557cbf49d2 hwmon: (it87) Split out chip registers setting code on probe path
This commit splits out chip registers setting code on probe path to
separate functions so they can be reused for setting the device properly
again when system resumes from suspend.

While we are at it let's also make clear that on IT8720 and IT8782 it's
the VCCH5V line that is (possibly) routed to in7.
This will make it consistent with a similar message that it printed on
IT8783.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Julia Lawall 778fb961b0 hwmon: (scpi) constify thermal_zone_of_device_ops structures
The thermal_zone_of_device_ops structure is only passed as the fourth
argument to devm_thermal_zone_of_sensor_register, which is declared
as const.  Thus the thermal_zone_of_device_ops structure itself can
be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Julia Lawall c9920650c7 hwmon: (core) constify thermal_zone_of_device_ops structures
The thermal_zone_of_device_ops structure is only passed as the fourth
argument to devm_thermal_zone_of_sensor_register, which is declared
as const.  Thus the thermal_zone_of_device_ops structure itself can
be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Arvind Yadav 4d3f24142c hwmon: (i5k_amb) constify pci_device_id
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by <linux/pci.h> work with
const pci_device_id. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   3562	    320	      8	   3890	    f32	drivers/hwmon/i5k_amb.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
   3658	    224	      8	   3890	    f32	drivers/hwmon/i5k_amb.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Rob Herring bb923fdc37 hwmon: (ads1015) Convert to using %pOF instead of full_name
Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Dirk Eibach <eibach@gdsys.de>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Guenter Roeck 99b981b23b hwmon: (jc42) Add support for CAT34TS02C
CAT34TS02C is similar to CAT34TS02 but has a different device ID.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Guenter Roeck 568003cefe hwmon: (jc42) Add support for GT30TS00, GT34TS02, and CAT34TS04
Giantec GT30TS00 GT30TS00 and GT34TS02 as well as ONS CAT34TS04
are used on DDR4 DIMMs.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Arvind Yadav f5397be8ad hwmon: (adt7475) constify attribute_group structures.
attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
  10055	   7032	      0	  17087	   42bf	drivers/hwmon/adt7475.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
  10567	   6520	      0	  17087	   42bf	drivers/hwmon/adt7475.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Arvind Yadav 33d62d11c3 hwmon: (adc128d818) constify attribute_group structures.
attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   2304	   2936	      0	   5240	   1478	drivers/hwmon/adc128d818.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
   2344	   2872	      0	   5216	   1460	drivers/hwmon/adc128d818.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Arvind Yadav afc680f38e hwmon: (nct7802) constify attribute_group structures.
attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   6161	   9400	      0	  15561	   3cc9	drivers/hwmon/nct7802.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
   6465	   9080	      0	  15545	   3cb9	drivers/hwmon/nct7802.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Arvind Yadav 524703ac1a hwmon: constify attribute_group structures.
attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   6655	    304	      0	   6959	   1b2f	drivers/hwmon/hwmon.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
   6703	    240	      0	   6943	   1b1f	drivers/hwmon/hwmon.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:38 -07:00
Anton Vasilyev 3be6bd690d hwmon: (stts751) buffer overrun on wrong chip configuration
If stts751 hw by some reason reports conversion rate bigger then 9:
        ret = i2c_smbus_read_byte_data(priv->client, STTS751_REG_RATE);
then dereferencing stts751_intervals[priv->interval] leads to buffer
overrun.

The patch adds sanity check for value stored on chip.

Found by Linux Driver Verification project (linuxtesting.org).

Fixes: 7f07ec0fa1 ("hwmon: new driver for ST stts751 thermal sensor")
Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:08 -07:00
Thilo Cestonaro 7576750f03 hwmon: (ftsteutates) Fix clearing alarm sysfs entries
sysfs store functions should return the number of bytes written.
Returning zero results in an endless loop.

Fixes: 08426eda58 ("hwmon: Add driver for FTS BMC chip "Teutates"")
Signed-off-by: Thilo Cestonaro <thilo.cestonaro@ts.fujitsu.com>
[groeck: Clean up documentation change and description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-08-13 08:24:01 -07:00
Linus Torvalds aae4e7a8bc Linux 4.13-rc4 2017-08-06 18:44:49 -07:00
Linus Torvalds acdae9ee6a platform-drivers-x86 for v4.13-4
Fix loop preventing some platforms from waking up via the power
 button in s2idle.
 
 intel-vbtn:
  - match power button on press rather than release
 -----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJZhjtgAAoJEKbMaAwKp3647u4IALEnsRt10hj2ognbpQUPxqzB
 uwjlQ7ukqwWVbpgElQ6q2hKUFHNnk2CGuzIEjvRKpme0UpsSPUQRPZGeUGDmvC3l
 cOxNSmyTJkmeCEU9G7yj1NrcaOEFQ9iRLrZmSRnYBSWBgjzYdpfC/xog2y8mVkgO
 FQAU2ul9Ph5eXEOTQBw56LtzsraJtBdV76aKESuJEAw3h0E8svhLeV43caVic/Go
 Yv9aRZRkj/5oQHwXe+GC5K4dFdWFYZ9iGLQFHgcICRACcUq7p0ysVvf8YMVQplyR
 Xm2j8Dq1ierId5g90p5fznIM4BeBnIM2Iclkk4dPaIrP3Fogd9eq1gvxQKvWgpY=
 =IOnZ
 -----END PGP SIGNATURE-----

Merge tag 'platform-drivers-x86-v4.13-4' of git://git.infradead.org/linux-platform-drivers-x86

Pull x86 platform driver fix from Darren Hart:
 "Fix loop preventing some platforms from waking up via the power button
  in s2idle:

   - intel-vbtn: match power button on press rather than release"

* tag 'platform-drivers-x86-v4.13-4' of git://git.infradead.org/linux-platform-drivers-x86:
  platform/x86: intel-vbtn: match power button on press rather than release
2017-08-06 16:11:34 -07:00
Linus Torvalds ed66da1104 A large number of ext4 bug fixes and cleanups for v4.13
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEK2m5VNv+CHkogTfJ8vlZVpUNgaMFAlmHbBAACgkQ8vlZVpUN
 gaMu3gf+LpI5bI1XA3R8KbXB2snnz6wM7OzArfqvreX+m+xP1CK6nVpAIgpkZqfw
 QkQ1xPJk7Q25vex/pPcsgLO0Vxf0i4vpydK+fYnf30S4WvGQVq6OHZWFFv2zM2YB
 7TWxjG+KryM7j6JSXdUiSTKP3nX84TW/IMIWuZMR1nuOa8N5M4yD3uc+3EBTjSbq
 P/dxfmkp2hQKnlZVBWqCjJDhtxwUYTF4iZ/pbSVeGbgHCh1674ml+airb4K9ltNU
 0vR0JChD12YJaafjaAyIrqqKwDGvnN+H5wyhCodEV9w8jthbcU04Jfmi1auB9UxT
 y7/sgbV64W2o5hBwxY3RXjZkVLpDsw==
 =Mtr7
 -----END PGP SIGNATURE-----

Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

Pull ext4 fixes from Ted Ts'o:
 "A large number of ext4 bug fixes and cleanups for v4.13"

* tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
  ext4: fix copy paste error in ext4_swap_extents()
  ext4: fix overflow caused by missing cast in ext4_resize_fs()
  ext4, project: expand inode extra size if possible
  ext4: cleanup ext4_expand_extra_isize_ea()
  ext4: restructure ext4_expand_extra_isize
  ext4: fix forgetten xattr lock protection in ext4_expand_extra_isize
  ext4: make xattr inode reads faster
  ext4: inplace xattr block update fails to deduplicate blocks
  ext4: remove unused mode parameter
  ext4: fix warning about stack corruption
  ext4: fix dir_nlink behaviour
  ext4: silence array overflow warning
  ext4: fix SEEK_HOLE/SEEK_DATA for blocksize < pagesize
  ext4: release discard bio after sending discard commands
  ext4: convert swap_inode_data() over to use swap() on most of the fields
  ext4: error should be cleared if ea_inode isn't added to the cache
  ext4: Don't clear SGID when inheriting ACLs
  ext4: preserve i_mode if __ext4_set_acl() fails
  ext4: remove unused metadata accounting variables
  ext4: correct comment references to ext4_ext_direct_IO()
2017-08-06 12:31:17 -07:00
Linus Torvalds 6ea1bc9b1a Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS fixes from Ralf Baechle:
 "This fixes two build issues for ralink platforms, both due to missing
  #includes which used to be included indirectly via other headers"

* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus:
  MIPS: ralink: mt7620: Add missing header
  MIPS: ralink: Fix build error due to missing header
2017-08-06 11:52:01 -07:00
Dmitry V. Levin fbb77611e9 Fix compat_sys_sigpending breakage
The latest change of compat_sys_sigpending in commit 8f13621abc
("sigpending(): move compat to native") has broken it in two ways.

First, it tries to write 4 bytes more than userspace expects:
sizeof(old_sigset_t) == sizeof(long) == 8 instead of
sizeof(compat_old_sigset_t) == sizeof(u32) == 4.

Second, on big endian architectures these bytes are being written in the
wrong order.

This bug was found by strace test suite.

Reported-by: Anatoly Pugachev <matorola@gmail.com>
Inspired-by: Eugene Syromyatnikov <evgsyr@gmail.com>
Fixes: 8f13621abc ("sigpending(): move compat to native")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-06 11:48:27 -07:00
Maninder Singh 4e56201321 ext4: fix copy paste error in ext4_swap_extents()
This bug was found by a static code checker tool for copy paste
problems.

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2017-08-06 01:33:07 -04:00
Jerry Lee aec51758ce ext4: fix overflow caused by missing cast in ext4_resize_fs()
On a 32-bit platform, the value of n_blcoks_count may be wrong during
the file system is resized to size larger than 2^32 blocks.  This may
caused the superblock being corrupted with zero blocks count.

Fixes: 1c6bd7173d
Signed-off-by: Jerry Lee <jerrylee@qnap.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org # 3.7+
2017-08-06 01:18:31 -04:00
Miao Xie c03b45b853 ext4, project: expand inode extra size if possible
When upgrading from old format, try to set project id
to old file first time, it will return EOVERFLOW, but if
that file is dirtied(touch etc), changing project id will
be allowed, this might be confusing for users, we could
try to expand @i_extra_isize here too.

Reported-by: Zhang Yi <yi.zhang@huawei.com>
Signed-off-by: Miao Xie <miaoxie@huawei.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2017-08-06 01:00:49 -04:00
Miao Xie b640b2c51b ext4: cleanup ext4_expand_extra_isize_ea()
Clean up some goto statement, make ext4_expand_extra_isize_ea() clearer.

Signed-off-by: Miao Xie <miaoxie@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
2017-08-06 00:55:48 -04:00
Miao Xie cf0a5e818f ext4: restructure ext4_expand_extra_isize
Current ext4_expand_extra_isize just tries to expand extra isize, if
someone is holding xattr lock or some check fails, it will give up.
So rename its name to ext4_try_to_expand_extra_isize.

Besides that, we clean up unnecessary check and move some relative checks
into it.

Signed-off-by: Miao Xie <miaoxie@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
2017-08-06 00:40:01 -04:00
Miao Xie 3b10fdc6d8 ext4: fix forgetten xattr lock protection in ext4_expand_extra_isize
We should avoid the contention between the i_extra_isize update and
the inline data insertion, so move the xattr trylock in front of
i_extra_isize update.

Signed-off-by: Miao Xie <miaoxie@huawei.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
2017-08-06 00:27:38 -04:00
Tahsin Erdogan 9699d4f91d ext4: make xattr inode reads faster
ext4_xattr_inode_read() currently reads each block sequentially while
waiting for io operation to complete before moving on to the next
block. This prevents request merging in block layer.

Add a ext4_bread_batch() function that starts reads for all blocks
then optionally waits for them to complete. A similar logic is used
in ext4_find_entry(), so update that code to use the new function.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2017-08-06 00:07:01 -04:00
Tahsin Erdogan ec00022030 ext4: inplace xattr block update fails to deduplicate blocks
When an xattr block has a single reference, block is updated inplace
and it is reinserted to the cache. Later, a cache lookup is performed
to see whether an existing block has the same contents. This cache
lookup will most of the time return the just inserted entry so
deduplication is not achieved.

Running the following test script will produce two xattr blocks which
can be observed in "File ACL: " line of debugfs output:

  mke2fs -b 1024 -I 128 -F -O extent /dev/sdb 1G
  mount /dev/sdb /mnt/sdb

  touch /mnt/sdb/{x,y}

  setfattr -n user.1 -v aaa /mnt/sdb/x
  setfattr -n user.2 -v bbb /mnt/sdb/x

  setfattr -n user.1 -v aaa /mnt/sdb/y
  setfattr -n user.2 -v bbb /mnt/sdb/y

  debugfs -R 'stat x' /dev/sdb | cat
  debugfs -R 'stat y' /dev/sdb | cat

This patch defers the reinsertion to the cache so that we can locate
other blocks with the same contents.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2017-08-05 22:41:42 -04:00