aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-08-16power: supply: smb347-charger: Add missing pin control activationDmitry Osipenko1-0/+10
Pin control needs to be activated by setting the enable bit, otherwise hardware rejects all pin changes. Previously this stayed unnoticed on Nexus 7 because pin control was enabled by default after rebooting from downstream kernel, which uses driver that enables the bit and charger registers are non-volatile until power supply (battery) is disconnected. Configure the pin control enable bit. This fixes the potentially never-enabled charging on devices that use pin control. Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16power: supply: smb347-charger: Utilize generic regmap cachingDmitry Osipenko1-12/+4
Utilize generic regmap caching in order to avoid unnecessary slow I2C accesses to all constant registers each time the supply status updated and remove local caching of charger state to make code cleaner. Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16power: supply: smb347-charger: Make smb347_set_writable() IRQ-safeDmitry Osipenko1-9/+21
The smb347_set_writable() is used by interrupt handler and outside of it. The interrupt should be disabled when the function is used outside of interrupt handler in order to prevent racing with the interrupt context. Add new parameter to smb347_set_writable() that allows to disable IRQ. Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16dt-bindings: power: supply: smb347-charger: Document USB VBUS regulatorDmitry Osipenko2-0/+34
SMB347 can supply power to USB VBUS, which is required by OTG-cable devices that want to switch USB port into the host mode. Add USB VBUS regulator properties. Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16power: reset: Add TPS65086 restart driverEmil Renner Berthing3-0/+105
The only way to reset the BeagleV Starlight v0.9 board[1] properly is to tell the PMIC to reset itself which will then assert the external reset lines of the SoC, USB hub and ethernet phy. This adds a driver to register a reset handler to do just that. [1] https://github.com/beagleboard/beaglev-starlight Signed-off-by: Emil Renner Berthing <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16dt-bindings: power: supply: max17042: describe interruptKrzysztof Kozlowski1-0/+2
The Maxim 17042-family of fuel gauges are often embedded in other Maxim chips, e.g. in Maxim 77693 which is a companion power management IC. In such designs there might be actually two interrupts: - INTB signaling change from charger, flash or MUIC, - ALERT signaling change from fuel gauge. Describe the interrupt in bindings to make it clear it is about the fuel gauge ALERT interrupt, not the INT. Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16power: supply: max17042: remove duplicated STATUS bit definesKrzysztof Kozlowski1-4/+1
All bits of STATUS register are already defined (see STATUS_SMN_BIT and further) so there is no need to define status SoC threshold min/max values one more time. Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-16power: supply: max17042: handle fails of reading status registerKrzysztof Kozlowski1-1/+5
Reading status register can fail in the interrupt handler. In such case, the regmap_read() will not store anything useful under passed 'val' variable and random stack value will be used to determine type of interrupt. Handle the regmap_read() failure to avoid handling interrupt type and triggering changed power supply event based on random stack value. Fixes: 39e7213edc4f ("max17042_battery: Support regmap to access device's registers") Cc: <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-14power: supply: core: Parse battery chemistry/technologyLinus Walleij2-0/+21
This extends the struct power_supply_battery_info with a "technology" field makes the core DT parser optionally obtain this from the device tree. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-14dt-bindings: power: Extend battery bindings with chemistryLinus Walleij1-0/+14
This adds a battery-chemistry property and bindings for the different "technologies" that are used in Linux. More types can be added. This is needed to convert the custom ST-Ericsson AB8500 battery properties over to the generic battery bindings. Cc: [email protected] Signed-off-by: Linus Walleij <[email protected]> Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: reset: linkstation-poweroff: add new devicePawel Dembicki1-0/+42
This commit introduces support for NETGEAR ReadyNAS Duo v2. This device use bit 4 of LED[2:0] Polarity Control Register to indicate AC Power loss. For more details about AC loss detection in NETGEAR ReadyNAS Duo v2, please look at the file: RND_5.3.13_WW.src/u-boot/board/mv_feroceon/mv_hal/usibootup/usibootup.c from Netgear GPL sources. Signed-off-by: Pawel Dembicki <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: reset: linkstation-poweroff: prepare for new devicesPawel Dembicki1-6/+29
This commit prepare driver for another device support. New power_off_cfg structure describes two most important things: name of mdio bus and pointer to register setting function. It allow to add new device with different mdio bus node and other phy register config. Signed-off-by: Pawel Dembicki <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13Merge tag 'ib-mt6360-for-5.15-signed' into psy-nextSebastian Reichel6-0/+960
Immutable branch between regulator and power-supply for for 5.15 This immutable branch introduces the MT6360 charger driver, which requires a new linear range helper. Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: supply: bq24735: reorganize ChargeOption command macrosBruno Meneguele1-12/+15
Rename ChargeOption macros to match the others for ChargeCurrent and ChargeVoltage and also separate the command & masks macros from the bits of interest macros for each command. This macro doesn't introduce any functional change, only code re-org. Signed-off-by: Bruno Meneguele <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: supply: rn5t618: Add voltage_now propertyAndreas Kemnade2-0/+40
Read voltage_now via IIO and provide the property. Signed-off-by: Andreas Kemnade <[email protected]> Reported-by: kernel test robot <[email protected]> # missing depends on IIO Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13iio: adc: rn5t618: Add iio mapAndreas Kemnade1-0/+23
Add iio map to allow power driver to read out values as a consumer. This approach does not block later addition of devicetree support which would be helpful if there is an in-kernel consumer for AIN0/1. Signed-off-by: Andreas Kemnade <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: supply: mt6360_charger: add MT6360 charger supportGene Chen3-0/+879
Add basic support for the battery charger for MT6360 PMIC Signed-off-by: Gene Chen <[email protected]> Reviewed-by: Matti Vaittinen <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13dt-bindings: power: Add bindings document for Charger support on MT6360 PMICGene Chen1-0/+48
Add bindings document for Charger support on MT6360 PMIC Signed-off-by: Gene Chen <[email protected]> Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13lib: add linear range get selector withinGene Chen2-0/+33
Add linear range get selector within for choose closest selector between minimum and maximum selector. Signed-off-by: Gene Chen <[email protected]> Reviewed-by: Matti Vaittinen <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: supply: ab8500: clean up warnings found by checkpatchColin Ian King1-14/+10
Clean up a handful of checkpatch warnings: - static const char * array should probably be static const char * const - function arguments should have identifier names - else should follow close brace '}' - suspect code indent for conditional statements - unnecessary parentheses in an if condition - avoid multiple line dereference - remove debug showing function execution, ftrace can trace these better - prefer 'long' over 'long int' as the int is unnecessary Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-13power: supply: axp288_charger: Use the defined variable to clean codeTang Bin1-6/+5
Use the defined variable "dev" to make the code cleaner. Co-developed-by: Zhang Shengju <[email protected]> Signed-off-by: Zhang Shengju <[email protected]> Signed-off-by: Tang Bin <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06power: supply: sbs-battery: add support for time_to_empty_now attributeMatthias Schiffer1-4/+10
As defined by the Smart Battery Data Specification. An _AVG suffix is added to the enum values REG_TIME_TO_EMPTY and REG_TIME_TO_FULL to make the distinction clear. Signed-off-by: Matthias Schiffer <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06power: supply: sbs-battery: relax voltage limitMatthias Schiffer1-1/+1
The Smart Battery Data Specification allows for values 0..65535 mV, there is no reason to limit the value to 20000. Signed-off-by: Matthias Schiffer <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06power: supply: qcom_smbb: Remove superfluous error messageTang Bin1-4/+1
In the probe function, when get irq failed, the function platform_get_irq_byname() logs an error message, so remove redundant message here. Co-developed-by: Zhang Shengju <[email protected]> Signed-off-by: Zhang Shengju <[email protected]> Signed-off-by: Tang Bin <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06dt-bindings: power: supply: axp20x-battery: Add AXP209 compatibleMaxime Ripard1-0/+1
The AXP209 compatible was used in Device Trees and the driver, but it was never documented. Cc: Chen-Yu Tsai <[email protected]> Cc: [email protected] Cc: Sebastian Reichel <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06dt-bindings: power: supply: axp20x: Add AXP803 compatibleMaxime Ripard3-13/+23
The AXP803 compatible was introduced recently with a fallback to the AXP813, but it was never documented. Cc: Chen-Yu Tsai <[email protected]> Cc: [email protected] Cc: Sebastian Reichel <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Reviewed-by: Rob Herring <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06power: supply: max17042_battery: Add support for MAX77849 Fuel-GaugeNikita Travkin1-0/+2
MAX77849 is a combined fuel-gauge, charger and MUIC IC. Notably, fuel-gauge has dedicated i2c lines and seems to be fully compatible with max17047. Add new compatible for it reusing max17047 code paths. Signed-off-by: Nikita Travkin <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-06dt-bindings: power: supply: max17042: Document max77849-batteryNikita Travkin1-0/+1
max77849 is a combined fuel-gauge, charger and MUIC device. Add it to the bindings documentation. Signed-off-by: Nikita Travkin <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Take the P-Unit semaphore only once during ↵Hans de Goede1-7/+17
probe() The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus. If not explicitly taken by the I2C-driver, then this semaphore is automatically taken by the I2C-bus-driver for each I2C-transfer and this is a quite expensive operation. Explicitly take the semaphore in probe() around the register-accesses done during probe, so that this only needs to be done once, rather then once per register-access. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Move the AXP20X_CC_CTRL check together ↵Hans de Goede1-10/+12
with the other checks The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus. If not explicitly taken by the I2C-driver, then this semaphore is automatically taken by the I2C-bus-driver for each I2C-transfer. Move the AXP20X_CC_CTRL check done in probe() together with the other register-accesses done in probe, so that we can take the semaphore once for the entire set of register-accesses. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Refresh all registers in one goAndrejus Basovas2-97/+106
The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus and while the kernel holds the semaphore the CPU and GPU power-states must not be changed otherwise the system will freeze. This is a complex process, which is quite expensive. This is all done by iosf_mbi_block_punit_i2c_access(). To ensure that no unguarded I2C-bus accesses happen, iosf_mbi_block_punit_i2c_access() gets called by the I2C-bus-driver for every I2C transfer. Because this is so expensive it is allowed to call iosf_mbi_block_punit_i2c_access() in a nested fashion, so that higher-level code which does multiple I2C-transfers can call it once for a group of transfers, turning the calls done by the I2C-bus-driver into no-ops. Userspace power-supply API users typically will read all provided properties in one go, refreshing the last read values when power_supply_changed() is called by the driver and/or periodically (e.g. every 2 minutes). The reading of all properties in one go causes the P-Unit semaphore to quickly be taken and released multiple times in a row. Certain PMIC registers like AXP20X_FG_RES are even used in multiple properties so they get read multiple times, leading to a P-Unit take + release each time the register is read. As already mentioned the taking of the P-Unit semaphore is a quite expensive operation and it has also been reported that the "hammering" of the P-Unit semaphore done by the axp288_fuel_gauge driver can even cause stability issues with the system as a whole. Switch over to a scheme where the axp288_fuel_gauge driver keeps a local copy of all the registers which it uses for properties and make it only refresh its copy of the registers if the values are older then 1 minute; or when a fuel-gauge interrupt has triggered since the last read. This not only reduces the amount of reads, it also makes the code do all the reads in one go, rather then reading specific registers based on which property is being queried. This allows calling iosf_mbi_block_punit_i2c_access() once before doing all the reads, so that we now only take the P-Unit semaphore once per update. Tested-by: Andrejus Basovas <[email protected]> Signed-off-by: Andrejus Basovas <[email protected]> Co-developed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Only read PWR_OP_MODE, FG_LOW_CAP_REG regs ↵Hans de Goede1-16/+21
once Accessing registers on the AXP288 is quite expensive, so we should avoid doing unnecessary accesses. The FG_LOW_CAP_REG never changes underneath us, so we only need to read it once. Devices with an AXP288 do not have user-replace (let alone hot-swappable) batteries and the only bit we care about in the PWR_OP_MODE register is the CHRG_STAT_BAT_PRESENT bit, so we can get away with only reading the PWR_OP_MODE register once too. Note that the FG_LOW_CAP_REG is not marked volatile in the regmap, so we were effectively already reading it once. This change makes this explicit, this is done as preparation of a further patch which moves all remaining register accesses in fuel_gauge_get_property() out of that function. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Store struct device pointer in axp288_fg_infoHans de Goede1-35/+24
Directly store the struct device pointer in axp288_fg_info, rather then storing a pointer to the struct platform_device there and then using "&info->pdev->dev" everywhere. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Drop retry logic from fuel_gauge_reg_readb()Hans de Goede1-8/+2
The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus. This semaphore is automatically taken by the I2C-bus-driver. The retry on -EBUSY logic in fuel_gauge_reg_readb() likely was added to deal with the I2C-bus-drive returning -EBUSY when it failed to take the semaphore, but this really should never happen. The semaphore code even has a WARN_ON(ret) to log a kernel backtrace if this does somehow happen, when this happens something is seriously wrong and the system typically freezes soon afterwards. TL;DR: the regmap_read() should never fail with -EBUSY so the retries are unnecessary. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Report register-address on readb / writeb ↵Hans de Goede1-2/+2
errors When fuel_gauge_reg_readb()/_writeb() fails, report which register we were trying to read / write when the error happened. Also reword the message a bit: - Drop the axp288 prefix, dev_err() already prints this - Switch from telegram / abbreviated style to a normal sentence, aligning the message with those from fuel_gauge_read_*bit_word() Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Silence the chatty IRQ mapping codeHans de Goede1-3/+0
Drop the IRQ mapping messages, because they are really not interesting at all. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Remove debugfs supportHans de Goede1-123/+0
The debugfs code is simply just dumping a bunch of registers, the same information can also easily be gotten through the regmap debugfs interface or through the i2cdump utility. I've not used the debugfs interface once in all these years that I've been working on the axp288_fuel_gauge driver, so lets just remove it. Note this also removes the temperature-channels from the list of IIO ADC channels used by the driver, since these were only used in the debugfs interface. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: axp288_fuel_gauge: Fix define alignmentHans de Goede1-19/+19
The values of various defines used in the driver are not aligned properly when tabsize is set to 8 (I guess they were created with a different tabsize). Properly align the defines to make the code easier to read. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-08-05power: supply: sc27xx: Delete superfluous error messageTang Bin1-3/+1
In the function sc27xx_fgu_probe(), when get irq failed, platform_get_irq() logs an error message, so remove redundant message here. Signed-off-by: Tang Bin <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: cw2015: use dev_err_probe to allow deferred probePeter Robinson1-1/+3
Deal with deferred probe using dev_err_probe so the error is handled and avoid logging lots probe defer information like the following: [ 9.125121] cw2015 4-0062: Failed to register power supply [ 9.211131] cw2015 4-0062: Failed to register power supply Fixes: b4c7715c10c1 ("power: supply: add CellWise cw2015 fuel gauge driver") Signed-off-by: Peter Robinson <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: PCHG: Peripheral device chargerDaisuke Nojiri4-0/+464
This patch adds a driver for PCHG (Peripheral CHarGer). PCHG is a framework managing power supplies for peripheral devices. This driver creates a sysfs node for each peripheral charge port: /sys/class/power_supply/peripheral<n> where <n> is the index of a charge port. For example, when a stylus is connected to a NFC/WLC port, the node returns: /sys/class/power_supply/peripheral0/ capacity=50 charge_type=Standard scope=Device status=Charging type=Battery Signed-off-by: Daisuke Nojiri <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: ab8500: Drop some includes from bmdataLinus Walleij1-2/+0
This file isn't using any AB8500 symbols so drop these includes. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: ab8500: Rename charging algorithm psyLinus Walleij1-2/+3
If we rename the "abx500_chargalg" supply to "ab8500_chargalg" as it should be named, the existing supplies are supplying that supply but that was obviously not working since it had the wrong name. Now that the dependency kicks in we get a bunch of NULL references from ab8500_chargalg_external_power_changed() so check that the workqueue is allocated before we try to queue work on it. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: ab8500: Drop abx500 conceptLinus Walleij6-214/+61
Drop the entire idea with abx500 being abstract and different from ab8500 in the AB8500 charging drivers. This rids the two identical definitions of a slew of structs in ab8500-bm.h and makes things less confusion and easier to understand. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: ab8500: Rename charging algorithm symbolsLinus Walleij4-291/+291
The "abx500" name on the charging algorithm stems from the ambition to produce a series of these analog basebands, re-using the same charging algorithm driver. No ASICs beside AB8500 and AB8505 were ever produced so this terminology is confusing. Rename the algorithm file and symbols to reflect the more narrow scope. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-16power: supply: ab8500: Use library interpolationLinus Walleij2-9/+11
The kernel already has a static inline for linear interpolation so use that instead of rolling our own. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
2021-07-11Linux 5.14-rc1Linus Torvalds1-2/+2
2021-07-11mm/rmap: try_to_migrate() skip zone_device !device_privateHugh Dickins1-3/+3
I know nothing about zone_device pages and !device_private pages; but if try_to_migrate_one() will do nothing for them, then it's better that try_to_migrate() filter them first, than trawl through all their vmas. Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Reviewed-by: Alistair Popple <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Cc: Andrew Morton <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Yang Shi <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2021-07-11mm/rmap: fix new bug: premature return from page_mlock_one()Hugh Dickins1-6/+5
In the unlikely race case that page_mlock_one() finds VM_LOCKED has been cleared by the time it got page table lock, page_vma_mapped_walk_done() must be called before returning, either explicitly, or by a final call to page_vma_mapped_walk() - otherwise the page table remains locked. Fixes: cd62734ca60d ("mm/rmap: split try_to_munlock from try_to_unmap") Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Alistair Popple <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/lkml/20210711151446.GB4070@xsang-OptiPlex-9020/ Link: https://lore.kernel.org/lkml/[email protected]/ Cc: Andrew Morton <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Yang Shi <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2021-07-11mm/rmap: fix old bug: munlocking THP missed other mlocksHugh Dickins1-5/+8
The kernel recovers in due course from missing Mlocked pages: but there was no point in calling page_mlock() (formerly known as try_to_munlock()) on a THP, because nothing got done even when it was found to be mapped in another VM_LOCKED vma. It's true that we need to be careful: Mlocked accounting of pte-mapped THPs is too difficult (so consistently avoided); but Mlocked accounting of only-pmd-mapped THPs is supposed to work, even when multiple mappings are mlocked and munlocked or munmapped. Refine the tests. There is already a VM_BUG_ON_PAGE(PageDoubleMap) in page_mlock(), so page_mlock_one() does not even have to worry about that complication. (I said the kernel recovers: but would page reclaim be likely to split THP before rediscovering that it's VM_LOCKED? I've not followed that up) Fixes: 9a73f61bdb8a ("thp, mlock: do not mlock PTE-mapped file huge pages") Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Cc: Andrew Morton <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Yang Shi <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>