Pull updates from Andrew Morton: "Most of -mm and quite a number of other subsystems: hotfixes, scripts, ocfs2, misc, lib, binfmt, init, reiserfs, exec, dma-mapping, kcov. MM is fairly quiet this time. Holidays, I assume" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (118 commits) kcov: ignore fault-inject and stacktrace include/linux/io-mapping.h-mapping: use PHYS_PFN() macro in io_mapping_map_atomic_wc() execve: warn if process starts with executable stack reiserfs: prevent NULL pointer dereference in reiserfs_insert_item() init/main.c: fix misleading "This architecture does not have kernel memory protection" message init/main.c: fix quoted value handling in unknown_bootoption init/main.c: remove unnecessary repair_env_string in do_initcall_level init/main.c: log arguments and environment passed to init fs/binfmt_elf.c: coredump: allow process with empty address space to coredump fs/binfmt_elf.c: coredump: delete duplicated overflow check fs/binfmt_elf.c: coredump: allocate core ELF header on stack fs/binfmt_elf.c: make BAD_ADDR() unlikely fs/binfmt_elf.c: better codegen around current->mm fs/binfmt_elf.c: don't copy ELF header around fs/binfmt_elf.c: fix ->start_code calculation fs/binfmt_elf.c: smaller code generation around auxv vector fill lib/find_bit.c: uninline helper _find_next_bit() lib/find_bit.c: join _find_next_bit{_le} uapi: rename ext2_swab() to swab() and share globally in swab.h lib/scatterlist.c: adjust indentation in __sg_alloc_table ...
Showing the changes to drivers (30 of 136 files). Show all
Unified · Split
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include <linux/acpi.h> | 27 | #include <linux/acpi.h> |
| 28 | #include <linux/workqueue.h> | 28 | #include <linux/workqueue.h> |
| 29 | #include <linux/uaccess.h> | 29 | #include <linux/uaccess.h> |
| 30 | #include <linux/units.h> | ||
| 30 | 31 | ||
| 31 | #define PREFIX "ACPI: " | 32 | #define PREFIX "ACPI: " |
| 32 | 33 | ||
| @@ -172,7 +173,7 @@ struct acpi_thermal { · 139 unmodified lines | |||
| 172 | struct acpi_handle_list devices; | 173 | struct acpi_handle_list devices; |
| 173 | struct thermal_zone_device *thermal_zone; | 174 | struct thermal_zone_device *thermal_zone; |
| 174 | int tz_enabled; | 175 | int tz_enabled; |
| 175 | int kelvin_offset; | 176 | int kelvin_offset; /* in millidegrees */ |
| 176 | struct work_struct thermal_check_work; | 177 | struct work_struct thermal_check_work; |
| 177 | }; | 178 | }; |
| 178 | 179 | ||
| @@ -297,7 +298,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · 118 unmodified lines | |||
| 297 | if (crt == -1) { | 298 | if (crt == -1) { |
| 298 | tz->trips.critical.flags.valid = 0; | 299 | tz->trips.critical.flags.valid = 0; |
| 299 | } else if (crt > 0) { | 300 | } else if (crt > 0) { |
| 300 | unsigned long crt_k = CELSIUS_TO_DECI_KELVIN(crt); | 301 | unsigned long crt_k = celsius_to_deci_kelvin(crt); |
| 302 | |||
| 301 | /* | 303 | /* |
| 302 | * Allow override critical threshold | 304 | * Allow override critical threshold |
| 303 | */ | 305 | */ |
| @@ -333,7 +335,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · 29 unmodified lines | |||
| 333 | if (psv == -1) { | 335 | if (psv == -1) { |
| 334 | status = AE_SUPPORT; | 336 | status = AE_SUPPORT; |
| 335 | } else if (psv > 0) { | 337 | } else if (psv > 0) { |
| 336 | tmp = CELSIUS_TO_DECI_KELVIN(psv); | 338 | tmp = celsius_to_deci_kelvin(psv); |
| 337 | status = AE_OK; | 339 | status = AE_OK; |
| 338 | } else { | 340 | } else { |
| 339 | status = acpi_evaluate_integer(tz->device->handle, | 341 | status = acpi_evaluate_integer(tz->device->handle, |
| @@ -413,7 +415,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · 73 unmodified lines | |||
| 413 | break; | 415 | break; |
| 414 | if (i == 1) | 416 | if (i == 1) |
| 415 | tz->trips.active[0].temperature = | 417 | tz->trips.active[0].temperature = |
| 416 | CELSIUS_TO_DECI_KELVIN(act); | 418 | celsius_to_deci_kelvin(act); |
| 417 | else | 419 | else |
| 418 | /* | 420 | /* |
| 419 | * Don't allow override higher than | 421 | * Don't allow override higher than |
| @@ -421,9 +423,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · 1 unmodified line | |||
| 421 | */ | 423 | */ |
| 422 | tz->trips.active[i - 1].temperature = | 424 | tz->trips.active[i - 1].temperature = |
| 423 | (tz->trips.active[i - 2].temperature < | 425 | (tz->trips.active[i - 2].temperature < |
| 424 | CELSIUS_TO_DECI_KELVIN(act) ? | 426 | celsius_to_deci_kelvin(act) ? |
| 425 | tz->trips.active[i - 2].temperature : | 427 | tz->trips.active[i - 2].temperature : |
| 426 | CELSIUS_TO_DECI_KELVIN(act)); | 428 | celsius_to_deci_kelvin(act)); |
| 427 | break; | 429 | break; |
| 428 | } else { | 430 | } else { |
| 429 | tz->trips.active[i].temperature = tmp; | 431 | tz->trips.active[i].temperature = tmp; |
| @@ -519,7 +521,7 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) · 89 unmodified lines | |||
| 519 | if (result) | 521 | if (result) |
| 520 | return result; | 522 | return result; |
| 521 | 523 | ||
| 522 | *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(tz->temperature, | 524 | *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, |
| 523 | tz->kelvin_offset); | 525 | tz->kelvin_offset); |
| 524 | return 0; | 526 | return 0; |
| 525 | } | 527 | } |
| @@ -624,7 +626,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, · 98 unmodified lines | |||
| 624 | 626 | ||
| 625 | if (tz->trips.critical.flags.valid) { | 627 | if (tz->trips.critical.flags.valid) { |
| 626 | if (!trip) { | 628 | if (!trip) { |
| 627 | *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( | 629 | *temp = deci_kelvin_to_millicelsius_with_offset( |
| 628 | tz->trips.critical.temperature, | 630 | tz->trips.critical.temperature, |
| 629 | tz->kelvin_offset); | 631 | tz->kelvin_offset); |
| 630 | return 0; | 632 | return 0; |
| @@ -634,7 +636,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, · 3 unmodified lines | |||
| 634 | 636 | ||
| 635 | if (tz->trips.hot.flags.valid) { | 637 | if (tz->trips.hot.flags.valid) { |
| 636 | if (!trip) { | 638 | if (!trip) { |
| 637 | *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( | 639 | *temp = deci_kelvin_to_millicelsius_with_offset( |
| 638 | tz->trips.hot.temperature, | 640 | tz->trips.hot.temperature, |
| 639 | tz->kelvin_offset); | 641 | tz->kelvin_offset); |
| 640 | return 0; | 642 | return 0; |
| @@ -644,7 +646,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, · 3 unmodified lines | |||
| 644 | 646 | ||
| 645 | if (tz->trips.passive.flags.valid) { | 647 | if (tz->trips.passive.flags.valid) { |
| 646 | if (!trip) { | 648 | if (!trip) { |
| 647 | *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( | 649 | *temp = deci_kelvin_to_millicelsius_with_offset( |
| 648 | tz->trips.passive.temperature, | 650 | tz->trips.passive.temperature, |
| 649 | tz->kelvin_offset); | 651 | tz->kelvin_offset); |
| 650 | return 0; | 652 | return 0; |
| @@ -655,7 +657,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, · 4 unmodified lines | |||
| 655 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && | 657 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && |
| 656 | tz->trips.active[i].flags.valid; i++) { | 658 | tz->trips.active[i].flags.valid; i++) { |
| 657 | if (!trip) { | 659 | if (!trip) { |
| 658 | *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( | 660 | *temp = deci_kelvin_to_millicelsius_with_offset( |
| 659 | tz->trips.active[i].temperature, | 661 | tz->trips.active[i].temperature, |
| 660 | tz->kelvin_offset); | 662 | tz->kelvin_offset); |
| 661 | return 0; | 663 | return 0; |
| @@ -672,7 +674,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal, · 10 unmodified lines | |||
| 672 | struct acpi_thermal *tz = thermal->devdata; | 674 | struct acpi_thermal *tz = thermal->devdata; |
| 673 | 675 | ||
| 674 | if (tz->trips.critical.flags.valid) { | 676 | if (tz->trips.critical.flags.valid) { |
| 675 | *temperature = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( | 677 | *temperature = deci_kelvin_to_millicelsius_with_offset( |
| 676 | tz->trips.critical.temperature, | 678 | tz->trips.critical.temperature, |
| 677 | tz->kelvin_offset); | 679 | tz->kelvin_offset); |
| 678 | return 0; | 680 | return 0; |
| @@ -692,7 +694,7 @@ static int thermal_get_trend(struct thermal_zone_device *thermal, · 13 unmodified lines | |||
| 692 | 694 | ||
| 693 | if (type == THERMAL_TRIP_ACTIVE) { | 695 | if (type == THERMAL_TRIP_ACTIVE) { |
| 694 | int trip_temp; | 696 | int trip_temp; |
| 695 | int temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( | 697 | int temp = deci_kelvin_to_millicelsius_with_offset( |
| 696 | tz->temperature, tz->kelvin_offset); | 698 | tz->temperature, tz->kelvin_offset); |
| 697 | if (thermal_get_trip_temp(thermal, trip, &trip_temp)) | 699 | if (thermal_get_trip_temp(thermal, trip, &trip_temp)) |
| 698 | return -EINVAL; | 700 | return -EINVAL; |
| @@ -1043,9 +1045,9 @@ static void acpi_thermal_guess_offset(struct acpi_thermal *tz) · 344 unmodified lines | |||
| 1043 | { | 1045 | { |
| 1044 | if (tz->trips.critical.flags.valid && | 1046 | if (tz->trips.critical.flags.valid && |
| 1045 | (tz->trips.critical.temperature % 5) == 1) | 1047 | (tz->trips.critical.temperature % 5) == 1) |
| 1046 | tz->kelvin_offset = 2731; | 1048 | tz->kelvin_offset = 273100; |
| 1047 | else | 1049 | else |
| 1048 | tz->kelvin_offset = 2732; | 1050 | tz->kelvin_offset = 273200; |
| 1049 | } | 1051 | } |
| 1050 | 1052 | ||
| 1051 | static void acpi_thermal_check_fn(struct work_struct *work) | 1053 | static void acpi_thermal_check_fn(struct work_struct *work) |
| @@ -1087,7 +1089,7 @@ static int acpi_thermal_add(struct acpi_device *device) · 35 unmodified lines | |||
| 1087 | INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); | 1089 | INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); |
| 1088 | 1090 | ||
| 1089 | pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), | 1091 | pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), |
| 1090 | acpi_device_bid(device), DECI_KELVIN_TO_CELSIUS(tz->temperature)); | 1092 | acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); |
| 1091 | goto end; | 1093 | goto end; |
| 1092 | 1094 | ||
| 1093 | free_memory: | 1095 | free_memory: |
| @@ -70,20 +70,6 @@ void unregister_memory_notifier(struct notifier_block *nb) · 69 unmodified lines | |||
| 70 | } | 70 | } |
| 71 | EXPORT_SYMBOL(unregister_memory_notifier); | 71 | EXPORT_SYMBOL(unregister_memory_notifier); |
| 72 | 72 | ||
| 73 | static ATOMIC_NOTIFIER_HEAD(memory_isolate_chain); | ||
| 74 | |||
| 75 | int register_memory_isolate_notifier(struct notifier_block *nb) | ||
| 76 | { | ||
| 77 | return atomic_notifier_chain_register(&memory_isolate_chain, nb); | ||
| 78 | } | ||
| 79 | EXPORT_SYMBOL(register_memory_isolate_notifier); | ||
| 80 | |||
| 81 | void unregister_memory_isolate_notifier(struct notifier_block *nb) | ||
| 82 | { | ||
| 83 | atomic_notifier_chain_unregister(&memory_isolate_chain, nb); | ||
| 84 | } | ||
| 85 | EXPORT_SYMBOL(unregister_memory_isolate_notifier); | ||
| 86 | |||
| 87 | static void memory_block_release(struct device *dev) | 73 | static void memory_block_release(struct device *dev) |
| 88 | { | 74 | { |
| 89 | struct memory_block *mem = to_memory_block(dev); | 75 | struct memory_block *mem = to_memory_block(dev); |
| @@ -175,11 +161,6 @@ int memory_notify(unsigned long val, void *v) · 85 unmodified lines | |||
| 175 | return blocking_notifier_call_chain(&memory_chain, val, v); | 161 | return blocking_notifier_call_chain(&memory_chain, val, v); |
| 176 | } | 162 | } |
| 177 | 163 | ||
| 178 | int memory_isolate_notify(unsigned long val, void *v) | ||
| 179 | { | ||
| 180 | return atomic_notifier_call_chain(&memory_isolate_chain, val, v); | ||
| 181 | } | ||
| 182 | |||
| 183 | /* | 164 | /* |
| 184 | * The probe routines leave the pages uninitialized, just as the bootmem code | 165 | * The probe routines leave the pages uninitialized, just as the bootmem code |
| 185 | * does. Make sure we do not access them, but instead use only information from | 166 | * does. Make sure we do not access them, but instead use only information from |
| @@ -225,7 +206,7 @@ static bool pages_correctly_probed(unsigned long start_pfn) · 39 unmodified lines | |||
| 225 | */ | 206 | */ |
| 226 | static int | 207 | static int |
| 227 | memory_block_action(unsigned long start_section_nr, unsigned long action, | 208 | memory_block_action(unsigned long start_section_nr, unsigned long action, |
| 228 | int online_type) | 209 | int online_type, int nid) |
| 229 | { | 210 | { |
| 230 | unsigned long start_pfn; | 211 | unsigned long start_pfn; |
| 231 | unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; | 212 | unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; |
| @@ -238,7 +219,7 @@ memory_block_action(unsigned long start_section_nr, unsigned long action, · 6 unmodified lines | |||
| 238 | if (!pages_correctly_probed(start_pfn)) | 219 | if (!pages_correctly_probed(start_pfn)) |
| 239 | return -EBUSY; | 220 | return -EBUSY; |
| 240 | 221 | ||
| 241 | ret = online_pages(start_pfn, nr_pages, online_type); | 222 | ret = online_pages(start_pfn, nr_pages, online_type, nid); |
| 242 | break; | 223 | break; |
| 243 | case MEM_OFFLINE: | 224 | case MEM_OFFLINE: |
| 244 | ret = offline_pages(start_pfn, nr_pages); | 225 | ret = offline_pages(start_pfn, nr_pages); |
| @@ -264,7 +245,7 @@ static int memory_block_change_state(struct memory_block *mem, · 19 unmodified lines | |||
| 264 | mem->state = MEM_GOING_OFFLINE; | 245 | mem->state = MEM_GOING_OFFLINE; |
| 265 | 246 | ||
| 266 | ret = memory_block_action(mem->start_section_nr, to_state, | 247 | ret = memory_block_action(mem->start_section_nr, to_state, |
| 267 | mem->online_type); | 248 | mem->online_type, mem->nid); |
| 268 | 249 | ||
| 269 | mem->state = ret ? from_state_req : to_state; | 250 | mem->state = ret ? from_state_req : to_state; |
| 270 | 251 | ||
| @@ -207,14 +207,17 @@ static inline void zram_fill_page(void *ptr, unsigned long len, · 206 unmodified lines | |||
| 207 | 207 | ||
| 208 | static bool page_same_filled(void *ptr, unsigned long *element) | 208 | static bool page_same_filled(void *ptr, unsigned long *element) |
| 209 | { | 209 | { |
| 210 | unsigned int pos; | ||
| 211 | unsigned long *page; | 210 | unsigned long *page; |
| 212 | unsigned long val; | 211 | unsigned long val; |
| 212 | unsigned int pos, last_pos = PAGE_SIZE / sizeof(*page) - 1; | ||
| 213 | 213 | ||
| 214 | page = (unsigned long *)ptr; | 214 | page = (unsigned long *)ptr; |
| 215 | val = page[0]; | 215 | val = page[0]; |
| 216 | 216 | ||
| 217 | for (pos = 1; pos < PAGE_SIZE / sizeof(*page); pos++) { | 217 | if (val != page[last_pos]) |
| 218 | return false; | ||
| 219 | |||
| 220 | for (pos = 1; pos < last_pos; pos++) { | ||
| 218 | if (val != page[pos]) | 221 | if (val != page[pos]) |
| 219 | return false; | 222 | return false; |
| 220 | } | 223 | } |
| @@ -626,7 +629,7 @@ static ssize_t writeback_store(struct device *dev, · 405 unmodified lines | |||
| 626 | struct bio bio; | 629 | struct bio bio; |
| 627 | struct bio_vec bio_vec; | 630 | struct bio_vec bio_vec; |
| 628 | struct page *page; | 631 | struct page *page; |
| 629 | ssize_t ret; | 632 | ssize_t ret = len; |
| 630 | int mode; | 633 | int mode; |
| 631 | unsigned long blk_idx = 0; | 634 | unsigned long blk_idx = 0; |
| 632 | 635 | ||
| @@ -762,7 +765,6 @@ next: · 129 unmodified lines | |||
| 762 | 765 | ||
| 763 | if (blk_idx) | 766 | if (blk_idx) |
| 764 | free_block_bdev(zram, blk_idx); | 767 | free_block_bdev(zram, blk_idx); |
| 765 | ret = len; | ||
| 766 | __free_page(page); | 768 | __free_page(page); |
| 767 | release_init_lock: | 769 | release_init_lock: |
| 768 | up_read(&zram->init_lock); | 770 | up_read(&zram->init_lock); |
| @@ -188,8 +188,8 @@ via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) · 187 unmodified lines | |||
| 188 | kfree(vsg->desc_pages); | 188 | kfree(vsg->desc_pages); |
| 189 | /* fall through */ | 189 | /* fall through */ |
| 190 | case dr_via_pages_locked: | 190 | case dr_via_pages_locked: |
| 191 | put_user_pages_dirty_lock(vsg->pages, vsg->num_pages, | 191 | unpin_user_pages_dirty_lock(vsg->pages, vsg->num_pages, |
| 192 | (vsg->direction == DMA_FROM_DEVICE)); | 192 | (vsg->direction == DMA_FROM_DEVICE)); |
| 193 | /* fall through */ | 193 | /* fall through */ |
| 194 | case dr_via_pages_alloc: | 194 | case dr_via_pages_alloc: |
| 195 | vfree(vsg->pages); | 195 | vfree(vsg->pages); |
| @@ -239,7 +239,7 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer) · 43 unmodified lines | |||
| 239 | vsg->pages = vzalloc(array_size(sizeof(struct page *), vsg->num_pages)); | 239 | vsg->pages = vzalloc(array_size(sizeof(struct page *), vsg->num_pages)); |
| 240 | if (NULL == vsg->pages) | 240 | if (NULL == vsg->pages) |
| 241 | return -ENOMEM; | 241 | return -ENOMEM; |
| 242 | ret = get_user_pages_fast((unsigned long)xfer->mem_addr, | 242 | ret = pin_user_pages_fast((unsigned long)xfer->mem_addr, |
| 243 | vsg->num_pages, | 243 | vsg->num_pages, |
| 244 | vsg->direction == DMA_FROM_DEVICE ? FOLL_WRITE : 0, | 244 | vsg->direction == DMA_FROM_DEVICE ? FOLL_WRITE : 0, |
| 245 | vsg->pages); | 245 | vsg->pages); |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | |||
| 6 | #include <linux/log2.h> | 6 | #include <linux/log2.h> |
| 7 | #include <linux/err.h> | 7 | #include <linux/err.h> |
| 8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
| 9 | #include <linux/units.h> | ||
| 9 | 10 | ||
| 10 | #include "qcom-vadc-common.h" | 11 | #include "qcom-vadc-common.h" |
| 11 | 12 | ||
| @@ -236,8 +237,7 @@ static int qcom_vadc_scale_die_temp(const struct vadc_linear_graph *calib_graph, · 224 unmodified lines | |||
| 236 | voltage = 0; | 237 | voltage = 0; |
| 237 | } | 238 | } |
| 238 | 239 | ||
| 239 | voltage -= KELVINMIL_CELSIUSMIL; | 240 | *result_mdec = milli_kelvin_to_millicelsius(voltage); |
| 240 | *result_mdec = voltage; | ||
| 241 | 241 | ||
| 242 | return 0; | 242 | return 0; |
| 243 | } | 243 | } |
| @@ -325,7 +325,7 @@ static int qcom_vadc_scale_hw_calib_die_temp( · 81 unmodified lines | |||
| 325 | { | 325 | { |
| 326 | *result_mdec = qcom_vadc_scale_code_voltage_factor(adc_code, | 326 | *result_mdec = qcom_vadc_scale_code_voltage_factor(adc_code, |
| 327 | prescale, data, 2); | 327 | prescale, data, 2); |
| 328 | *result_mdec -= KELVINMIL_CELSIUSMIL; | 328 | *result_mdec = milli_kelvin_to_millicelsius(*result_mdec); |
| 329 | 329 | ||
| 330 | return 0; | 330 | return 0; |
| 331 | } | 331 | } |
| @@ -38,7 +38,6 @@ · 37 unmodified lines | |||
| 38 | #define VADC_AVG_SAMPLES_MAX 512 | 38 | #define VADC_AVG_SAMPLES_MAX 512 |
| 39 | #define ADC5_AVG_SAMPLES_MAX 16 | 39 | #define ADC5_AVG_SAMPLES_MAX 16 |
| 40 | 40 | ||
| 41 | #define KELVINMIL_CELSIUSMIL 273150 | ||
| 42 | #define PMIC5_CHG_TEMP_SCALE_FACTOR 377500 | 41 | #define PMIC5_CHG_TEMP_SCALE_FACTOR 377500 |
| 43 | #define PMIC5_SMB_TEMP_CONSTANT 419400 | 42 | #define PMIC5_SMB_TEMP_CONSTANT 419400 |
| 44 | #define PMIC5_SMB_TEMP_SCALE_FACTOR 356 | 43 | #define PMIC5_SMB_TEMP_SCALE_FACTOR 356 |
| @@ -54,7 +54,7 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d · 53 unmodified lines | |||
| 54 | 54 | ||
| 55 | for_each_sg_page(umem->sg_head.sgl, &sg_iter, umem->sg_nents, 0) { | 55 | for_each_sg_page(umem->sg_head.sgl, &sg_iter, umem->sg_nents, 0) { |
| 56 | page = sg_page_iter_page(&sg_iter); | 56 | page = sg_page_iter_page(&sg_iter); |
| 57 | put_user_pages_dirty_lock(&page, 1, umem->writable && dirty); | 57 | unpin_user_pages_dirty_lock(&page, 1, umem->writable && dirty); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | sg_free_table(&umem->sg_head); | 60 | sg_free_table(&umem->sg_head); |
| @@ -257,16 +257,13 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, · 196 unmodified lines | |||
| 257 | sg = umem->sg_head.sgl; | 257 | sg = umem->sg_head.sgl; |
| 258 | 258 | ||
| 259 | while (npages) { | 259 | while (npages) { |
| 260 | down_read(&mm->mmap_sem); | 260 | ret = pin_user_pages_fast(cur_base, |
| 261 | ret = get_user_pages(cur_base, | 261 | min_t(unsigned long, npages, |
| 262 | min_t(unsigned long, npages, | 262 | PAGE_SIZE / |
| 263 | PAGE_SIZE / sizeof (struct page *)), | 263 | sizeof(struct page *)), |
| 264 | gup_flags | FOLL_LONGTERM, | 264 | gup_flags | FOLL_LONGTERM, page_list); |
| 265 | page_list, NULL); | 265 | if (ret < 0) |
| 266 | if (ret < 0) { | ||
| 267 | up_read(&mm->mmap_sem); | ||
| 268 | goto umem_release; | 266 | goto umem_release; |
| 269 | } | ||
| 270 | 267 | ||
| 271 | cur_base += ret * PAGE_SIZE; | 268 | cur_base += ret * PAGE_SIZE; |
| 272 | npages -= ret; | 269 | npages -= ret; |
| @@ -274,8 +271,6 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, · 1 unmodified line | |||
| 274 | sg = ib_umem_add_sg_table(sg, page_list, ret, | 271 | sg = ib_umem_add_sg_table(sg, page_list, ret, |
| 275 | dma_get_max_seg_size(device->dma_device), | 272 | dma_get_max_seg_size(device->dma_device), |
| 276 | &umem->sg_nents); | 273 | &umem->sg_nents); |
| 277 | |||
| 278 | up_read(&mm->mmap_sem); | ||
| 279 | } | 274 | } |
| 280 | 275 | ||
| 281 | sg_mark_end(sg); | 276 | sg_mark_end(sg); |
| @@ -293,9 +293,8 @@ EXPORT_SYMBOL(ib_umem_odp_release); · 292 unmodified lines | |||
| 293 | * The function returns -EFAULT if the DMA mapping operation fails. It returns | 293 | * The function returns -EFAULT if the DMA mapping operation fails. It returns |
| 294 | * -EAGAIN if a concurrent invalidation prevents us from updating the page. | 294 | * -EAGAIN if a concurrent invalidation prevents us from updating the page. |
| 295 | * | 295 | * |
| 296 | * The page is released via put_user_page even if the operation failed. For | 296 | * The page is released via put_page even if the operation failed. For on-demand |
| 297 | * on-demand pinning, the page is released whenever it isn't stored in the | 297 | * pinning, the page is released whenever it isn't stored in the umem. |
| 298 | * umem. | ||
| 299 | */ | 298 | */ |
| 300 | static int ib_umem_odp_map_dma_single_page( | 299 | static int ib_umem_odp_map_dma_single_page( |
| 301 | struct ib_umem_odp *umem_odp, | 300 | struct ib_umem_odp *umem_odp, |
| @@ -348,7 +347,7 @@ static int ib_umem_odp_map_dma_single_page( · 46 unmodified lines | |||
| 348 | } | 347 | } |
| 349 | 348 | ||
| 350 | out: | 349 | out: |
| 351 | put_user_page(page); | 350 | put_page(page); |
| 352 | return ret; | 351 | return ret; |
| 353 | } | 352 | } |
| 354 | 353 | ||
| @@ -458,7 +457,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, · 103 unmodified lines | |||
| 458 | ret = -EFAULT; | 457 | ret = -EFAULT; |
| 459 | break; | 458 | break; |
| 460 | } | 459 | } |
| 461 | put_user_page(local_page_list[j]); | 460 | put_page(local_page_list[j]); |
| 462 | continue; | 461 | continue; |
| 463 | } | 462 | } |
| 464 | 463 | ||
| @@ -485,8 +484,8 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, · 20 unmodified lines | |||
| 485 | * ib_umem_odp_map_dma_single_page(). | 484 | * ib_umem_odp_map_dma_single_page(). |
| 486 | */ | 485 | */ |
| 487 | if (npages - (j + 1) > 0) | 486 | if (npages - (j + 1) > 0) |
| 488 | put_user_pages(&local_page_list[j+1], | 487 | release_pages(&local_page_list[j+1], |
| 489 | npages - (j + 1)); | 488 | npages - (j + 1)); |
| 490 | break; | 489 | break; |
| 491 | } | 490 | } |
| 492 | } | 491 | } |
| @@ -106,7 +106,7 @@ int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t np · 105 unmodified lines | |||
| 106 | int ret; | 106 | int ret; |
| 107 | unsigned int gup_flags = FOLL_LONGTERM | (writable ? FOLL_WRITE : 0); | 107 | unsigned int gup_flags = FOLL_LONGTERM | (writable ? FOLL_WRITE : 0); |
| 108 | 108 | ||
| 109 | ret = get_user_pages_fast(vaddr, npages, gup_flags, pages); | 109 | ret = pin_user_pages_fast(vaddr, npages, gup_flags, pages); |
| 110 | if (ret < 0) | 110 | if (ret < 0) |
| 111 | return ret; | 111 | return ret; |
| 112 | 112 | ||
| @@ -118,7 +118,7 @@ int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t np · 5 unmodified lines | |||
| 118 | void hfi1_release_user_pages(struct mm_struct *mm, struct page **p, | 118 | void hfi1_release_user_pages(struct mm_struct *mm, struct page **p, |
| 119 | size_t npages, bool dirty) | 119 | size_t npages, bool dirty) |
| 120 | { | 120 | { |
| 121 | put_user_pages_dirty_lock(p, npages, dirty); | 121 | unpin_user_pages_dirty_lock(p, npages, dirty); |
| 122 | 122 | ||
| 123 | if (mm) { /* during close after signal, mm can be NULL */ | 123 | if (mm) { /* during close after signal, mm can be NULL */ |
| 124 | atomic64_sub(npages, &mm->pinned_vm); | 124 | atomic64_sub(npages, &mm->pinned_vm); |
| @@ -472,7 +472,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, · 471 unmodified lines | |||
| 472 | goto out; | 472 | goto out; |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | ret = get_user_pages_fast(uaddr & PAGE_MASK, 1, | 475 | ret = pin_user_pages_fast(uaddr & PAGE_MASK, 1, |
| 476 | FOLL_WRITE | FOLL_LONGTERM, pages); | 476 | FOLL_WRITE | FOLL_LONGTERM, pages); |
| 477 | if (ret < 0) | 477 | if (ret < 0) |
| 478 | goto out; | 478 | goto out; |
| @@ -482,7 +482,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, · 3 unmodified lines | |||
| 482 | 482 | ||
| 483 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 483 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
| 484 | if (ret < 0) { | 484 | if (ret < 0) { |
| 485 | put_user_page(pages[0]); | 485 | unpin_user_page(pages[0]); |
| 486 | goto out; | 486 | goto out; |
| 487 | } | 487 | } |
| 488 | 488 | ||
| @@ -490,7 +490,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, · 1 unmodified line | |||
| 490 | mthca_uarc_virt(dev, uar, i)); | 490 | mthca_uarc_virt(dev, uar, i)); |
| 491 | if (ret) { | 491 | if (ret) { |
| 492 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 492 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
| 493 | put_user_page(sg_page(&db_tab->page[i].mem)); | 493 | unpin_user_page(sg_page(&db_tab->page[i].mem)); |
| 494 | goto out; | 494 | goto out; |
| 495 | } | 495 | } |
| 496 | 496 | ||
| @@ -556,7 +556,7 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar, · 59 unmodified lines | |||
| 556 | if (db_tab->page[i].uvirt) { | 556 | if (db_tab->page[i].uvirt) { |
| 557 | mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1); | 557 | mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1); |
| 558 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 558 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
| 559 | put_user_page(sg_page(&db_tab->page[i].mem)); | 559 | unpin_user_page(sg_page(&db_tab->page[i].mem)); |
| 560 | } | 560 | } |
| 561 | } | 561 | } |
| 562 | 562 | ||
| @@ -40,7 +40,7 @@ · 39 unmodified lines | |||
| 40 | static void __qib_release_user_pages(struct page **p, size_t num_pages, | 40 | static void __qib_release_user_pages(struct page **p, size_t num_pages, |
| 41 | int dirty) | 41 | int dirty) |
| 42 | { | 42 | { |
| 43 | put_user_pages_dirty_lock(p, num_pages, dirty); | 43 | unpin_user_pages_dirty_lock(p, num_pages, dirty); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| @@ -108,7 +108,7 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages, · 61 unmodified lines | |||
| 108 | 108 | ||
| 109 | down_read(¤t->mm->mmap_sem); | 109 | down_read(¤t->mm->mmap_sem); |
| 110 | for (got = 0; got < num_pages; got += ret) { | 110 | for (got = 0; got < num_pages; got += ret) { |
| 111 | ret = get_user_pages(start_page + got * PAGE_SIZE, | 111 | ret = pin_user_pages(start_page + got * PAGE_SIZE, |
| 112 | num_pages - got, | 112 | num_pages - got, |
| 113 | FOLL_LONGTERM | FOLL_WRITE | FOLL_FORCE, | 113 | FOLL_LONGTERM | FOLL_WRITE | FOLL_FORCE, |
| 114 | p + got, NULL); | 114 | p + got, NULL); |
| @@ -317,7 +317,7 @@ static int qib_user_sdma_page_to_frags(const struct qib_devdata *dd, · 316 unmodified lines | |||
| 317 | * the caller can ignore this page. | 317 | * the caller can ignore this page. |
| 318 | */ | 318 | */ |
| 319 | if (put) { | 319 | if (put) { |
| 320 | put_user_page(page); | 320 | unpin_user_page(page); |
| 321 | } else { | 321 | } else { |
| 322 | /* coalesce case */ | 322 | /* coalesce case */ |
| 323 | kunmap(page); | 323 | kunmap(page); |
| @@ -631,7 +631,7 @@ static void qib_user_sdma_free_pkt_frag(struct device *dev, · 307 unmodified lines | |||
| 631 | kunmap(pkt->addr[i].page); | 631 | kunmap(pkt->addr[i].page); |
| 632 | 632 | ||
| 633 | if (pkt->addr[i].put_page) | 633 | if (pkt->addr[i].put_page) |
| 634 | put_user_page(pkt->addr[i].page); | 634 | unpin_user_page(pkt->addr[i].page); |
| 635 | else | 635 | else |
| 636 | __free_page(pkt->addr[i].page); | 636 | __free_page(pkt->addr[i].page); |
| 637 | } else if (pkt->addr[i].kvaddr) { | 637 | } else if (pkt->addr[i].kvaddr) { |
| @@ -670,7 +670,7 @@ static int qib_user_sdma_pin_pages(const struct qib_devdata *dd, · 32 unmodified lines | |||
| 670 | else | 670 | else |
| 671 | j = npages; | 671 | j = npages; |
| 672 | 672 | ||
| 673 | ret = get_user_pages_fast(addr, j, FOLL_LONGTERM, pages); | 673 | ret = pin_user_pages_fast(addr, j, FOLL_LONGTERM, pages); |
| 674 | if (ret != j) { | 674 | if (ret != j) { |
| 675 | i = 0; | 675 | i = 0; |
| 676 | j = ret; | 676 | j = ret; |
| @@ -706,7 +706,7 @@ static int qib_user_sdma_pin_pages(const struct qib_devdata *dd, · 29 unmodified lines | |||
| 706 | /* if error, return all pages not managed by pkt */ | 706 | /* if error, return all pages not managed by pkt */ |
| 707 | free_pages: | 707 | free_pages: |
| 708 | while (i < j) | 708 | while (i < j) |
| 709 | put_user_page(pages[i++]); | 709 | unpin_user_page(pages[i++]); |
| 710 | 710 | ||
| 711 | done: | 711 | done: |
| 712 | return ret; | 712 | return ret; |
| @@ -75,7 +75,7 @@ static void usnic_uiom_put_pages(struct list_head *chunk_list, int dirty) · 74 unmodified lines | |||
| 75 | for_each_sg(chunk->page_list, sg, chunk->nents, i) { | 75 | for_each_sg(chunk->page_list, sg, chunk->nents, i) { |
| 76 | page = sg_page(sg); | 76 | page = sg_page(sg); |
| 77 | pa = sg_phys(sg); | 77 | pa = sg_phys(sg); |
| 78 | put_user_pages_dirty_lock(&page, 1, dirty); | 78 | unpin_user_pages_dirty_lock(&page, 1, dirty); |
| 79 | usnic_dbg("pa: %pa\n", &pa); | 79 | usnic_dbg("pa: %pa\n", &pa); |
| 80 | } | 80 | } |
| 81 | kfree(chunk); | 81 | kfree(chunk); |
| @@ -141,7 +141,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable, · 59 unmodified lines | |||
| 141 | ret = 0; | 141 | ret = 0; |
| 142 | 142 | ||
| 143 | while (npages) { | 143 | while (npages) { |
| 144 | ret = get_user_pages(cur_base, | 144 | ret = pin_user_pages(cur_base, |
| 145 | min_t(unsigned long, npages, | 145 | min_t(unsigned long, npages, |
| 146 | PAGE_SIZE / sizeof(struct page *)), | 146 | PAGE_SIZE / sizeof(struct page *)), |
| 147 | gup_flags | FOLL_LONGTERM, | 147 | gup_flags | FOLL_LONGTERM, |
| @@ -63,7 +63,7 @@ struct siw_mem *siw_mem_id2obj(struct siw_device *sdev, int stag_index) · 62 unmodified lines | |||
| 63 | static void siw_free_plist(struct siw_page_chunk *chunk, int num_pages, | 63 | static void siw_free_plist(struct siw_page_chunk *chunk, int num_pages, |
| 64 | bool dirty) | 64 | bool dirty) |
| 65 | { | 65 | { |
| 66 | put_user_pages_dirty_lock(chunk->plist, num_pages, dirty); | 66 | unpin_user_pages_dirty_lock(chunk->plist, num_pages, dirty); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | void siw_umem_release(struct siw_umem *umem, bool dirty) | 69 | void siw_umem_release(struct siw_umem *umem, bool dirty) |
| @@ -426,7 +426,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) · 356 unmodified lines | |||
| 426 | while (nents) { | 426 | while (nents) { |
| 427 | struct page **plist = &umem->page_chunk[i].plist[got]; | 427 | struct page **plist = &umem->page_chunk[i].plist[got]; |
| 428 | 428 | ||
| 429 | rv = get_user_pages(first_page_va, nents, | 429 | rv = pin_user_pages(first_page_va, nents, |
| 430 | foll_flags | FOLL_LONGTERM, | 430 | foll_flags | FOLL_LONGTERM, |
| 431 | plist, NULL); | 431 | plist, NULL); |
| 432 | if (rv < 0) | 432 | if (rv < 0) |
| @@ -183,12 +183,12 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, · 182 unmodified lines | |||
| 183 | dprintk(1, "init user [0x%lx+0x%lx => %d pages]\n", | 183 | dprintk(1, "init user [0x%lx+0x%lx => %d pages]\n", |
| 184 | data, size, dma->nr_pages); | 184 | data, size, dma->nr_pages); |
| 185 | 185 | ||
| 186 | err = get_user_pages(data & PAGE_MASK, dma->nr_pages, | 186 | err = pin_user_pages(data & PAGE_MASK, dma->nr_pages, |
| 187 | flags | FOLL_LONGTERM, dma->pages, NULL); | 187 | flags | FOLL_LONGTERM, dma->pages, NULL); |
| 188 | 188 | ||
| 189 | if (err != dma->nr_pages) { | 189 | if (err != dma->nr_pages) { |
| 190 | dma->nr_pages = (err >= 0) ? err : 0; | 190 | dma->nr_pages = (err >= 0) ? err : 0; |
| 191 | dprintk(1, "get_user_pages: err=%d [%d]\n", err, | 191 | dprintk(1, "pin_user_pages: err=%d [%d]\n", err, |
| 192 | dma->nr_pages); | 192 | dma->nr_pages); |
| 193 | return err < 0 ? err : -EINVAL; | 193 | return err < 0 ? err : -EINVAL; |
| 194 | } | 194 | } |
| @@ -349,8 +349,8 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma) · 154 unmodified lines | |||
| 349 | BUG_ON(dma->sglen); | 349 | BUG_ON(dma->sglen); |
| 350 | 350 | ||
| 351 | if (dma->pages) { | 351 | if (dma->pages) { |
| 352 | for (i = 0; i < dma->nr_pages; i++) | 352 | unpin_user_pages_dirty_lock(dma->pages, dma->nr_pages, |
| 353 | put_page(dma->pages[i]); | 353 | dma->direction == DMA_FROM_DEVICE); |
| 354 | kfree(dma->pages); | 354 | kfree(dma->pages); |
| 355 | dma->pages = NULL; | 355 | dma->pages = NULL; |
| 356 | } | 356 | } |
| @@ -296,7 +296,6 @@ static inline void bnx2x_dcb_config_qm(struct bnx2x *bp, enum cos_mode mode, · 295 unmodified lines | |||
| 296 | * possible, the driver should only write the valid vnics into the internal | 296 | * possible, the driver should only write the valid vnics into the internal |
| 297 | * ram according to the appropriate port mode. | 297 | * ram according to the appropriate port mode. |
| 298 | */ | 298 | */ |
| 299 | #define BITS_TO_BYTES(x) ((x)/8) | ||
| 300 | 299 | ||
| 301 | /* CMNG constants, as derived from system spec calculations */ | 300 | /* CMNG constants, as derived from system spec calculations */ |
| 302 | 301 | ||
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include <linux/firmware.h> | 27 | #include <linux/firmware.h> |
| 28 | #include <linux/etherdevice.h> | 28 | #include <linux/etherdevice.h> |
| 29 | #include <linux/if_arp.h> | 29 | #include <linux/if_arp.h> |
| 30 | #include <linux/units.h> | ||
| 30 | 31 | ||
| 31 | #include <net/mac80211.h> | 32 | #include <net/mac80211.h> |
| 32 | 33 | ||
| @@ -6468,7 +6469,7 @@ il4965_set_hw_params(struct il_priv *il) · 6435 unmodified lines | |||
| 6468 | il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; | 6469 | il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; |
| 6469 | 6470 | ||
| 6470 | il->hw_params.ct_kill_threshold = | 6471 | il->hw_params.ct_kill_threshold = |
| 6471 | CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); | 6472 | celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY); |
| 6472 | 6473 | ||
| 6473 | il->hw_params.sens = &il4965_sensitivity; | 6474 | il->hw_params.sens = &il4965_sensitivity; |
| 6474 | il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; | 6475 | il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | |||
| 17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
| 18 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
| 19 | #include <linux/netdevice.h> | 19 | #include <linux/netdevice.h> |
| 20 | #include <linux/units.h> | ||
| 20 | #include <net/mac80211.h> | 21 | #include <net/mac80211.h> |
| 21 | #include <linux/etherdevice.h> | 22 | #include <linux/etherdevice.h> |
| 22 | #include <asm/unaligned.h> | 23 | #include <asm/unaligned.h> |
| @@ -1104,7 +1105,7 @@ il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40, · 1081 unmodified lines | |||
| 1104 | /* get current temperature (Celsius) */ | 1105 | /* get current temperature (Celsius) */ |
| 1105 | current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); | 1106 | current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); |
| 1106 | current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); | 1107 | current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); |
| 1107 | current_temp = KELVIN_TO_CELSIUS(current_temp); | 1108 | current_temp = kelvin_to_celsius(current_temp); |
| 1108 | 1109 | ||
| 1109 | /* select thermal txpower adjustment params, based on channel group | 1110 | /* select thermal txpower adjustment params, based on channel group |
| 1110 | * (same frequency group used for mimo txatten adjustment) */ | 1111 | * (same frequency group used for mimo txatten adjustment) */ |
| @@ -1610,8 +1611,8 @@ il4965_hw_get_temperature(struct il_priv *il) · 499 unmodified lines | |||
| 1610 | temperature = | 1611 | temperature = |
| 1611 | (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; | 1612 | (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; |
| 1612 | 1613 | ||
| 1613 | D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, | 1614 | D_TEMP("Calibrated temperature: %dK, %ldC\n", temperature, |
| 1614 | KELVIN_TO_CELSIUS(temperature)); | 1615 | kelvin_to_celsius(temperature)); |
| 1615 | 1616 | ||
| 1616 | return temperature; | 1617 | return temperature; |
| 1617 | } | 1618 | } |
| @@ -1670,12 +1671,12 @@ il4965_temperature_calib(struct il_priv *il) · 52 unmodified lines | |||
| 1670 | 1671 | ||
| 1671 | if (il->temperature != temp) { | 1672 | if (il->temperature != temp) { |
| 1672 | if (il->temperature) | 1673 | if (il->temperature) |
| 1673 | D_TEMP("Temperature changed " "from %dC to %dC\n", | 1674 | D_TEMP("Temperature changed " "from %ldC to %ldC\n", |
| 1674 | KELVIN_TO_CELSIUS(il->temperature), | 1675 | kelvin_to_celsius(il->temperature), |
| 1675 | KELVIN_TO_CELSIUS(temp)); | 1676 | kelvin_to_celsius(temp)); |
| 1676 | else | 1677 | else |
| 1677 | D_TEMP("Temperature " "initialized to %dC\n", | 1678 | D_TEMP("Temperature " "initialized to %ldC\n", |
| 1678 | KELVIN_TO_CELSIUS(temp)); | 1679 | kelvin_to_celsius(temp)); |
| 1679 | } | 1680 | } |
| 1680 | 1681 | ||
| 1681 | il->temperature = temp; | 1682 | il->temperature = temp; |
| @@ -779,9 +779,6 @@ struct il_sensitivity_ranges { · 778 unmodified lines | |||
| 779 | u16 nrg_th_cca; | 779 | u16 nrg_th_cca; |
| 780 | }; | 780 | }; |
| 781 | 781 | ||
| 782 | #define KELVIN_TO_CELSIUS(x) ((x)-273) | ||
| 783 | #define CELSIUS_TO_KELVIN(x) ((x)+273) | ||
| 784 | |||
| 785 | /** | 782 | /** |
| 786 | * struct il_hw_params | 783 | * struct il_hw_params |
| 787 | * @bcast_id: f/w broadcast station ID | 784 | * @bcast_id: f/w broadcast station ID |
| @@ -237,11 +237,6 @@ struct iwl_sensitivity_ranges { · 236 unmodified lines | |||
| 237 | u16 nrg_th_cca; | 237 | u16 nrg_th_cca; |
| 238 | }; | 238 | }; |
| 239 | 239 | ||
| 240 | |||
| 241 | #define KELVIN_TO_CELSIUS(x) ((x)-273) | ||
| 242 | #define CELSIUS_TO_KELVIN(x) ((x)+273) | ||
| 243 | |||
| 244 | |||
| 245 | /****************************************************************************** | 240 | /****************************************************************************** |
| 246 | * | 241 | * |
| 247 | * Functions implemented in core module which are forward declared here | 242 | * Functions implemented in core module which are forward declared here |
| @@ -10,6 +10,8 @@ · 9 unmodified lines | |||
| 10 | * | 10 | * |
| 11 | *****************************************************************************/ | 11 | *****************************************************************************/ |
| 12 | 12 | ||
| 13 | #include <linux/units.h> | ||
| 14 | |||
| 13 | /* | 15 | /* |
| 14 | * DVM device-specific data & functions | 16 | * DVM device-specific data & functions |
| 15 | */ | 17 | */ |
| @@ -345,7 +347,7 @@ static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv) · 329 unmodified lines | |||
| 345 | static void iwl5150_set_ct_threshold(struct iwl_priv *priv) | 347 | static void iwl5150_set_ct_threshold(struct iwl_priv *priv) |
| 346 | { | 348 | { |
| 347 | const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF; | 349 | const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF; |
| 348 | s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) - | 350 | s32 threshold = (s32)celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY) - |
| 349 | iwl_temp_calib_to_offset(priv); | 351 | iwl_temp_calib_to_offset(priv); |
| 350 | 352 | ||
| 351 | priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef; | 353 | priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef; |
| @@ -381,7 +383,7 @@ static void iwl5150_temperature(struct iwl_priv *priv) · 29 unmodified lines | |||
| 381 | vt = le32_to_cpu(priv->statistics.common.temperature); | 383 | vt = le32_to_cpu(priv->statistics.common.temperature); |
| 382 | vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset; | 384 | vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset; |
| 383 | /* now vt hold the temperature in Kelvin */ | 385 | /* now vt hold the temperature in Kelvin */ |
| 384 | priv->temperature = KELVIN_TO_CELSIUS(vt); | 386 | priv->temperature = kelvin_to_celsius(vt); |
| 385 | iwl_tt_handler(priv); | 387 | iwl_tt_handler(priv); |
| 386 | } | 388 | } |
| 387 | 389 | ||
| @@ -337,13 +337,7 @@ static void pmem_release_disk(void *__pmem) · 336 unmodified lines | |||
| 337 | put_disk(pmem->disk); | 337 | put_disk(pmem->disk); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | static void pmem_pagemap_page_free(struct page *page) | ||
| 341 | { | ||
| 342 | wake_up_var(&page->_refcount); | ||
| 343 | } | ||
| 344 | |||
| 345 | static const struct dev_pagemap_ops fsdax_pagemap_ops = { | 340 | static const struct dev_pagemap_ops fsdax_pagemap_ops = { |
| 346 | .page_free = pmem_pagemap_page_free, | ||
| 347 | .kill = pmem_pagemap_kill, | 341 | .kill = pmem_pagemap_kill, |
| 348 | .cleanup = pmem_pagemap_cleanup, | 342 | .cleanup = pmem_pagemap_cleanup, |
| 349 | }; | 343 | }; |
| @@ -5,14 +5,11 @@ · 4 unmodified lines | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <linux/hwmon.h> | 7 | #include <linux/hwmon.h> |
| 8 | #include <linux/units.h> | ||
| 8 | #include <asm/unaligned.h> | 9 | #include <asm/unaligned.h> |
| 9 | 10 | ||
| 10 | #include "nvme.h" | 11 | #include "nvme.h" |
| 11 | 12 | ||
| 12 | /* These macros should be moved to linux/temperature.h */ | ||
| 13 | #define MILLICELSIUS_TO_KELVIN(t) DIV_ROUND_CLOSEST((t) + 273150, 1000) | ||
| 14 | #define KELVIN_TO_MILLICELSIUS(t) ((t) * 1000L - 273150) | ||
| 15 | |||
| 16 | struct nvme_hwmon_data { | 13 | struct nvme_hwmon_data { |
| 17 | struct nvme_ctrl *ctrl; | 14 | struct nvme_ctrl *ctrl; |
| 18 | struct nvme_smart_log log; | 15 | struct nvme_smart_log log; |
| @@ -35,7 +32,7 @@ static int nvme_get_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, · 16 unmodified lines | |||
| 35 | return -EIO; | 32 | return -EIO; |
| 36 | if (ret < 0) | 33 | if (ret < 0) |
| 37 | return ret; | 34 | return ret; |
| 38 | *temp = KELVIN_TO_MILLICELSIUS(status & NVME_TEMP_THRESH_MASK); | 35 | *temp = kelvin_to_millicelsius(status & NVME_TEMP_THRESH_MASK); |
| 39 | 36 | ||
| 40 | return 0; | 37 | return 0; |
| 41 | } | 38 | } |
| @@ -46,7 +43,7 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, · 4 unmodified lines | |||
| 46 | unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; | 43 | unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; |
| 47 | int ret; | 44 | int ret; |
| 48 | 45 | ||
| 49 | temp = MILLICELSIUS_TO_KELVIN(temp); | 46 | temp = millicelsius_to_kelvin(temp); |
| 50 | threshold |= clamp_val(temp, 0, NVME_TEMP_THRESH_MASK); | 47 | threshold |= clamp_val(temp, 0, NVME_TEMP_THRESH_MASK); |
| 51 | 48 | ||
| 52 | if (under) | 49 | if (under) |
| @@ -88,7 +85,7 @@ static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, · 35 unmodified lines | |||
| 88 | case hwmon_temp_min: | 85 | case hwmon_temp_min: |
| 89 | return nvme_get_temp_thresh(data->ctrl, channel, true, val); | 86 | return nvme_get_temp_thresh(data->ctrl, channel, true, val); |
| 90 | case hwmon_temp_crit: | 87 | case hwmon_temp_crit: |
| 91 | *val = KELVIN_TO_MILLICELSIUS(data->ctrl->cctemp); | 88 | *val = kelvin_to_millicelsius(data->ctrl->cctemp); |
| 92 | return 0; | 89 | return 0; |
| 93 | default: | 90 | default: |
| 94 | break; | 91 | break; |
| @@ -105,7 +102,7 @@ static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, · 10 unmodified lines | |||
| 105 | temp = get_unaligned_le16(log->temperature); | 102 | temp = get_unaligned_le16(log->temperature); |
| 106 | else | 103 | else |
| 107 | temp = le16_to_cpu(log->temp_sensor[channel - 1]); | 104 | temp = le16_to_cpu(log->temp_sensor[channel - 1]); |
| 108 | *val = KELVIN_TO_MILLICELSIUS(temp); | 105 | *val = kelvin_to_millicelsius(temp); |
| 109 | break; | 106 | break; |
| 110 | case hwmon_temp_alarm: | 107 | case hwmon_temp_alarm: |
| 111 | *val = !!(log->critical_warning & NVME_SMART_CRIT_TEMPERATURE); | 108 | *val = !!(log->critical_warning & NVME_SMART_CRIT_TEMPERATURE); |
| @@ -257,12 +257,12 @@ static int goldfish_pipe_error_convert(int status) · 256 unmodified lines | |||
| 257 | } | 257 | } |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | static int pin_user_pages(unsigned long first_page, | 260 | static int goldfish_pin_pages(unsigned long first_page, |
| 261 | unsigned long last_page, | 261 | unsigned long last_page, |
| 262 | unsigned int last_page_size, | 262 | unsigned int last_page_size, |
| 263 | int is_write, | 263 | int is_write, |
| 264 | struct page *pages[MAX_BUFFERS_PER_COMMAND], | 264 | struct page *pages[MAX_BUFFERS_PER_COMMAND], |
| 265 | unsigned int *iter_last_page_size) | 265 | unsigned int *iter_last_page_size) |
| 266 | { | 266 | { |
| 267 | int ret; | 267 | int ret; |
| 268 | int requested_pages = ((last_page - first_page) >> PAGE_SHIFT) + 1; | 268 | int requested_pages = ((last_page - first_page) >> PAGE_SHIFT) + 1; |
| @@ -274,7 +274,7 @@ static int pin_user_pages(unsigned long first_page, · 5 unmodified lines | |||
| 274 | *iter_last_page_size = last_page_size; | 274 | *iter_last_page_size = last_page_size; |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | ret = get_user_pages_fast(first_page, requested_pages, | 277 | ret = pin_user_pages_fast(first_page, requested_pages, |
| 278 | !is_write ? FOLL_WRITE : 0, | 278 | !is_write ? FOLL_WRITE : 0, |
| 279 | pages); | 279 | pages); |
| 280 | if (ret <= 0) | 280 | if (ret <= 0) |
| @@ -285,18 +285,6 @@ static int pin_user_pages(unsigned long first_page, · 4 unmodified lines | |||
| 285 | return ret; | 285 | return ret; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | static void release_user_pages(struct page **pages, int pages_count, | ||
| 289 | int is_write, s32 consumed_size) | ||
| 290 | { | ||
| 291 | int i; | ||
| 292 | |||
| 293 | for (i = 0; i < pages_count; i++) { | ||
| 294 | if (!is_write && consumed_size > 0) | ||
| 295 | set_page_dirty(pages[i]); | ||
| 296 | put_page(pages[i]); | ||
| 297 | } | ||
| 298 | } | ||
| 299 | |||
| 300 | /* Populate the call parameters, merging adjacent pages together */ | 288 | /* Populate the call parameters, merging adjacent pages together */ |
| 301 | static void populate_rw_params(struct page **pages, | 289 | static void populate_rw_params(struct page **pages, |
| 302 | int pages_count, | 290 | int pages_count, |
| @@ -354,9 +342,9 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe, · 51 unmodified lines | |||
| 354 | if (mutex_lock_interruptible(&pipe->lock)) | 342 | if (mutex_lock_interruptible(&pipe->lock)) |
| 355 | return -ERESTARTSYS; | 343 | return -ERESTARTSYS; |
| 356 | 344 | ||
| 357 | pages_count = pin_user_pages(first_page, last_page, | 345 | pages_count = goldfish_pin_pages(first_page, last_page, |
| 358 | last_page_size, is_write, | 346 | last_page_size, is_write, |
| 359 | pipe->pages, &iter_last_page_size); | 347 | pipe->pages, &iter_last_page_size); |
| 360 | if (pages_count < 0) { | 348 | if (pages_count < 0) { |
| 361 | mutex_unlock(&pipe->lock); | 349 | mutex_unlock(&pipe->lock); |
| 362 | return pages_count; | 350 | return pages_count; |
| @@ -372,7 +360,8 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe, · 9 unmodified lines | |||
| 372 | 360 | ||
| 373 | *consumed_size = pipe->command_buffer->rw_params.consumed_size; | 361 | *consumed_size = pipe->command_buffer->rw_params.consumed_size; |
| 374 | 362 | ||
| 375 | release_user_pages(pipe->pages, pages_count, is_write, *consumed_size); | 363 | unpin_user_pages_dirty_lock(pipe->pages, pages_count, |
| 364 | !is_write && *consumed_size > 0); | ||
| 376 | 365 | ||
| 377 | mutex_unlock(&pipe->lock); | 366 | mutex_unlock(&pipe->lock); |
| 378 | return 0; | 367 | return 0; |
| @@ -33,9 +33,9 @@ · 32 unmodified lines | |||
| 33 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
| 34 | #include <linux/platform_data/x86/asus-wmi.h> | 34 | #include <linux/platform_data/x86/asus-wmi.h> |
| 35 | #include <linux/platform_device.h> | 35 | #include <linux/platform_device.h> |
| 36 | #include <linux/thermal.h> | ||
| 37 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
| 38 | #include <linux/dmi.h> | 37 | #include <linux/dmi.h> |
| 38 | #include <linux/units.h> | ||
| 39 | 39 | ||
| 40 | #include <acpi/battery.h> | 40 | #include <acpi/battery.h> |
| 41 | #include <acpi/video.h> | 41 | #include <acpi/video.h> |
| @@ -1514,9 +1514,8 @@ static ssize_t asus_hwmon_temp1(struct device *dev, · 1472 unmodified lines | |||
| 1514 | if (err < 0) | 1514 | if (err < 0) |
| 1515 | return err; | 1515 | return err; |
| 1516 | 1516 | ||
| 1517 | value = DECI_KELVIN_TO_CELSIUS((value & 0xFFFF)) * 1000; | 1517 | return sprintf(buf, "%ld\n", |
| 1518 | 1518 | deci_kelvin_to_millicelsius(value & 0xFFFF)); | |
| 1519 | return sprintf(buf, "%d\n", value); | ||
| 1520 | } | 1519 | } |
| 1521 | 1520 | ||
| 1522 | /* Fan1 */ | 1521 | /* Fan1 */ |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| 23 | #include <linux/thermal.h> | 23 | #include <linux/thermal.h> |
| 24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
| 25 | #include <linux/units.h> | ||
| 25 | 26 | ||
| 26 | MODULE_AUTHOR("Thomas Sujith"); | 27 | MODULE_AUTHOR("Thomas Sujith"); |
| 27 | MODULE_AUTHOR("Zhang Rui"); | 28 | MODULE_AUTHOR("Zhang Rui"); |
| @@ -302,8 +303,10 @@ static ssize_t aux_show(struct device *dev, struct device_attribute *dev_attr, · 274 unmodified lines | |||
| 302 | int result; | 303 | int result; |
| 303 | 304 | ||
| 304 | result = sensor_get_auxtrip(attr->handle, idx, &value); | 305 | result = sensor_get_auxtrip(attr->handle, idx, &value); |
| 306 | if (result) | ||
| 307 | return result; | ||
| 305 | 308 | ||
| 306 | return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value)); | 309 | return sprintf(buf, "%lu", deci_kelvin_to_celsius(value)); |
| 307 | } | 310 | } |
| 308 | 311 | ||
| 309 | static ssize_t aux0_show(struct device *dev, | 312 | static ssize_t aux0_show(struct device *dev, |
| @@ -332,8 +335,8 @@ static ssize_t aux_store(struct device *dev, struct device_attribute *dev_attr, · 22 unmodified lines | |||
| 332 | if (value < 0) | 335 | if (value < 0) |
| 333 | return -EINVAL; | 336 | return -EINVAL; |
| 334 | 337 | ||
| 335 | result = sensor_set_auxtrip(attr->handle, idx, | 338 | result = sensor_set_auxtrip(attr->handle, idx, |
| 336 | CELSIUS_TO_DECI_KELVIN(value)); | 339 | celsius_to_deci_kelvin(value)); |
| 337 | return result ? result : count; | 340 | return result ? result : count; |
| 338 | } | 341 | } |
| 339 | 342 | ||
| @@ -21,8 +21,6 @@ · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | #include "thermal_core.h" | 22 | #include "thermal_core.h" |
| 23 | 23 | ||
| 24 | #define TO_MCELSIUS(c) ((c) * 1000) | ||
| 25 | |||
| 26 | /* Thermal Manager Control and Status Register */ | 24 | /* Thermal Manager Control and Status Register */ |
| 27 | #define PMU_TDC0_SW_RST_MASK (0x1 << 1) | 25 | #define PMU_TDC0_SW_RST_MASK (0x1 << 1) |
| 28 | #define PMU_TM_DISABLE_OFFS 0 | 26 | #define PMU_TM_DISABLE_OFFS 0 |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
| 9 | #include <linux/acpi.h> | 9 | #include <linux/acpi.h> |
| 10 | #include <linux/thermal.h> | 10 | #include <linux/thermal.h> |
| 11 | #include <linux/units.h> | ||
| 11 | #include "int340x_thermal_zone.h" | 12 | #include "int340x_thermal_zone.h" |
| 12 | 13 | ||
| 13 | static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, | 14 | static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, |
| @@ -34,7 +35,7 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, · 20 unmodified lines | |||
| 34 | *temp = (unsigned long)conv_temp * 10; | 35 | *temp = (unsigned long)conv_temp * 10; |
| 35 | } else | 36 | } else |
| 36 | /* _TMP returns the temperature in tenths of degrees Kelvin */ | 37 | /* _TMP returns the temperature in tenths of degrees Kelvin */ |
| 37 | *temp = DECI_KELVIN_TO_MILLICELSIUS(tmp); | 38 | *temp = deci_kelvin_to_millicelsius(tmp); |
| 38 | 39 | ||
| 39 | return 0; | 40 | return 0; |
| 40 | } | 41 | } |
| @@ -116,7 +117,7 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, · 75 unmodified lines | |||
| 116 | 117 | ||
| 117 | snprintf(name, sizeof(name), "PAT%d", trip); | 118 | snprintf(name, sizeof(name), "PAT%d", trip); |
| 118 | status = acpi_execute_simple_method(d->adev->handle, name, | 119 | status = acpi_execute_simple_method(d->adev->handle, name, |
| 119 | MILLICELSIUS_TO_DECI_KELVIN(temp)); | 120 | millicelsius_to_deci_kelvin(temp)); |
| 120 | if (ACPI_FAILURE(status)) | 121 | if (ACPI_FAILURE(status)) |
| 121 | return -EIO; | 122 | return -EIO; |
| 122 | 123 | ||
| @@ -163,7 +164,7 @@ static int int340x_thermal_get_trip_config(acpi_handle handle, char *name, · 40 unmodified lines | |||
| 163 | if (ACPI_FAILURE(status)) | 164 | if (ACPI_FAILURE(status)) |
| 164 | return -EIO; | 165 | return -EIO; |
| 165 | 166 | ||
| 166 | *temp = DECI_KELVIN_TO_MILLICELSIUS(r); | 167 | *temp = deci_kelvin_to_millicelsius(r); |
| 167 | 168 | ||
| 168 | return 0; | 169 | return 0; |
| 169 | } | 170 | } |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | |||
| 13 | #include <linux/pci.h> | 13 | #include <linux/pci.h> |
| 14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
| 15 | #include <linux/thermal.h> | 15 | #include <linux/thermal.h> |
| 16 | #include <linux/units.h> | ||
| 16 | #include <linux/pm.h> | 17 | #include <linux/pm.h> |
| 17 | 18 | ||
| 18 | /* Intel PCH thermal Device IDs */ | 19 | /* Intel PCH thermal Device IDs */ |
| @@ -93,7 +94,7 @@ static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, · 74 unmodified lines | |||
| 93 | if (ACPI_SUCCESS(status)) { | 94 | if (ACPI_SUCCESS(status)) { |
| 94 | unsigned long trip_temp; | 95 | unsigned long trip_temp; |
| 95 | 96 | ||
| 96 | trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r); | 97 | trip_temp = deci_kelvin_to_millicelsius(r); |
| 97 | if (trip_temp) { | 98 | if (trip_temp) { |
| 98 | ptd->psv_temp = trip_temp; | 99 | ptd->psv_temp = trip_temp; |
| 99 | ptd->psv_trip_id = *nr_trips; | 100 | ptd->psv_trip_id = *nr_trips; |
| @@ -309,9 +309,8 @@ static int put_pfn(unsigned long pfn, int prot) · 308 unmodified lines | |||
| 309 | { | 309 | { |
| 310 | if (!is_invalid_reserved_pfn(pfn)) { | 310 | if (!is_invalid_reserved_pfn(pfn)) { |
| 311 | struct page *page = pfn_to_page(pfn); | 311 | struct page *page = pfn_to_page(pfn); |
| 312 | if (prot & IOMMU_WRITE) | 312 | |
| 313 | SetPageDirty(page); | 313 | unpin_user_pages_dirty_lock(&page, 1, prot & IOMMU_WRITE); |
| 314 | put_page(page); | ||
| 315 | return 1; | 314 | return 1; |
| 316 | } | 315 | } |
| 317 | return 0; | 316 | return 0; |
| @@ -322,7 +321,6 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, · 4 unmodified lines | |||
| 322 | { | 321 | { |
| 323 | struct page *page[1]; | 322 | struct page *page[1]; |
| 324 | struct vm_area_struct *vma; | 323 | struct vm_area_struct *vma; |
| 325 | struct vm_area_struct *vmas[1]; | ||
| 326 | unsigned int flags = 0; | 324 | unsigned int flags = 0; |
| 327 | int ret; | 325 | int ret; |
| 328 | 326 | ||
| @@ -330,33 +328,14 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, · 1 unmodified line | |||
| 330 | flags |= FOLL_WRITE; | 328 | flags |= FOLL_WRITE; |
| 331 | 329 | ||
| 332 | down_read(&mm->mmap_sem); | 330 | down_read(&mm->mmap_sem); |
| 333 | if (mm == current->mm) { | 331 | ret = pin_user_pages_remote(NULL, mm, vaddr, 1, flags | FOLL_LONGTERM, |
| 334 | ret = get_user_pages(vaddr, 1, flags | FOLL_LONGTERM, page, | 332 | page, NULL, NULL); |
| 335 | vmas); | ||
| 336 | } else { | ||
| 337 | ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, | ||
| 338 | vmas, NULL); | ||
| 339 | /* | ||
| 340 | * The lifetime of a vaddr_get_pfn() page pin is | ||
| 341 | * userspace-controlled. In the fs-dax case this could | ||
| 342 | * lead to indefinite stalls in filesystem operations. | ||
| 343 | * Disallow attempts to pin fs-dax pages via this | ||
| 344 | * interface. | ||
| 345 | */ | ||
| 346 | if (ret > 0 && vma_is_fsdax(vmas[0])) { | ||
| 347 | ret = -EOPNOTSUPP; | ||
| 348 | put_page(page[0]); | ||
| 349 | } | ||
| 350 | } | ||
| 351 | up_read(&mm->mmap_sem); | ||
| 352 | |||
| 353 | if (ret == 1) { | 333 | if (ret == 1) { |
| 354 | *pfn = page_to_pfn(page[0]); | 334 | *pfn = page_to_pfn(page[0]); |
| 355 | return 0; | 335 | ret = 0; |
| 336 | goto done; | ||
| 356 | } | 337 | } |
| 357 | 338 | ||
| 358 | down_read(&mm->mmap_sem); | ||
| 359 | |||
| 360 | vaddr = untagged_addr(vaddr); | 339 | vaddr = untagged_addr(vaddr); |
| 361 | 340 | ||
| 362 | vma = find_vma_intersection(mm, vaddr, vaddr + 1); | 341 | vma = find_vma_intersection(mm, vaddr, vaddr + 1); |
| @@ -366,7 +345,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, · 3 unmodified lines | |||
| 366 | if (is_invalid_reserved_pfn(*pfn)) | 345 | if (is_invalid_reserved_pfn(*pfn)) |
| 367 | ret = 0; | 346 | ret = 0; |
| 368 | } | 347 | } |
| 369 | 348 | done: | |
| 370 | up_read(&mm->mmap_sem); | 349 | up_read(&mm->mmap_sem); |
| 371 | return ret; | 350 | return ret; |
| 372 | } | 351 | } |