1. 23 Oct, 2020 1 commit
    • Rafael J. Wysocki's avatar
      Merge branches 'pm-cpufreq' and 'pm-cpuidle' · db06391e
      Rafael J. Wysocki authored
      * pm-cpufreq:
        cpufreq: schedutil: restore cached freq when next_f is not changed
        acpi-cpufreq: Honor _PSD table setting on new AMD CPUs
        cpufreq: intel_pstate: Delete intel_pstate sysfs if failed to register the driver
        cpufreq: Improve code around unlisted freq check
      
      * pm-cpuidle:
        intel_idle: Ignore _CST if control cannot be taken from the platform
        cpuidle: Remove pointless stub
        intel_idle: mention assumption that WBINVD is not needed
        MAINTAINERS: Add section for cpuidle-psci PM domain
      db06391e
  2. 20 Oct, 2020 1 commit
  3. 19 Oct, 2020 2 commits
  4. 16 Oct, 2020 9 commits
    • Lina Iyer's avatar
      PM: domains: enable domain idle state accounting · c6a113b5
      Lina Iyer authored
      To enable better debug of PM domains, keep a track of successful
      and failing attempts to enter each domain idle state.
      
      This statistics are exported in debugfs when reading the
      idle_states node associated with each PM domain.
      Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
      [ rjw: Subject and changelog edits ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c6a113b5
    • Geert Uytterhoeven's avatar
      PM: domains: Add curly braces to delimit comment + statement block · 505a70b7
      Geert Uytterhoeven authored
      There is not strict need to group a comment and a single statement in an
      if block, as comments are stripped by the pre-processor.  However,
      adding curly braces does make the code easier to read, and may avoid
      mistakes when changing the code later.
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      505a70b7
    • Ulf Hansson's avatar
      PM: domains: Add support for PM domain on/off notifiers for genpd · d4f81383
      Ulf Hansson authored
      A device may have specific HW constraints that must be obeyed to, before
      its corresponding PM domain (genpd) can be powered off - and vice verse at
      power on. These constraints can't be managed through the regular runtime PM
      based deployment for a device, because the access pattern for it, isn't
      always request based. In other words, using the runtime PM callbacks to
      deal with the constraints doesn't work for these cases.
      
      For these reasons, let's instead add a PM domain power on/off notification
      mechanism to genpd. To add/remove a notifier for a device, the device must
      already have been attached to the genpd, which also means that it needs to
      be a part of the PM domain topology.
      
      To add/remove a notifier, let's introduce two genpd specific functions:
       - dev_pm_genpd_add|remove_notifier()
      
      Note that, to further clarify when genpd power on/off notifiers may be
      used, one can compare with the existing CPU_CLUSTER_PM_ENTER|EXIT
      notifiers. In the long run, the genpd power on/off notifiers should be able
      to replace them, but that requires additional genpd based platform support
      for the current users.
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Tested-by: default avatarLina Iyer <ilina@codeaurora.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d4f81383
    • Mel Gorman's avatar
      intel_idle: Ignore _CST if control cannot be taken from the platform · 75af76d0
      Mel Gorman authored
      e6d4f08a ("intel_idle: Use ACPI _CST on server systems") avoids
      enabling c-states that have been disabled by the platform with the
      exception of C1E.
      
      Unfortunately, BIOS implementations are not always consistent in terms
      of how capabilities are advertised and control cannot always be handed
      over. If control cannot be handed over then intel_idle reports that "ACPI
      _CST not found or not usable" but does not clear acpi_state_table.count
      meaning the information is still partially used.
      
      This patch ignores ACPI information if CST control cannot be requested from
      the platform. This was only observed on a number of Haswell platforms that
      had identical CPUs but not identical BIOS versions.  While this problem
      may be rare overall, 24 separate test cases bisected to this specific
      commit across 4 separate test machines and is worth addressing. If the
      situation occurs, the kernel behaves as it did before commit e6d4f08a
      and uses any c-states that are discovered.
      
      The affected test cases were all ones that involved a small number of
      processes -- exec microbenchmark, pipe microbenchmark, git test suite,
      netperf, tbench with one client and system call microbenchmark. Each
      case benefits from being able to use turboboost which is prevented if the
      lower c-states are unavailable. This may mask real regressions specific
      to older hardware so it is worth addressing.
      
      C-state status before and after the patch
      
      5.9.0-vanilla            POLL     latency:0      disabled:0 default:enabled
      5.9.0-vanilla            C1       latency:2      disabled:0 default:enabled
      5.9.0-vanilla            C1E      latency:10     disabled:0 default:enabled
      5.9.0-vanilla            C3       latency:33     disabled:1 default:disabled
      5.9.0-vanilla            C6       latency:133    disabled:1 default:disabled
      5.9.0-ignore-cst-v1r1    POLL     latency:0      disabled:0 default:enabled
      5.9.0-ignore-cst-v1r1    C1       latency:2      disabled:0 default:enabled
      5.9.0-ignore-cst-v1r1    C1E      latency:10     disabled:0 default:enabled
      5.9.0-ignore-cst-v1r1    C3       latency:33     disabled:0 default:enabled
      5.9.0-ignore-cst-v1r1    C6       latency:133    disabled:0 default:enabled
      
      Patch enables C3/C6.
      
      Netperf UDP_STREAM
      
      netperf-udp
                                            5.5.0                  5.9.0
                                          vanilla        ignore-cst-v1r1
      Hmean     send-64         193.41 (   0.00%)      226.54 *  17.13%*
      Hmean     send-128        392.16 (   0.00%)      450.54 *  14.89%*
      Hmean     send-256        769.94 (   0.00%)      881.85 *  14.53%*
      Hmean     send-1024      2994.21 (   0.00%)     3468.95 *  15.85%*
      Hmean     send-2048      5725.60 (   0.00%)     6628.99 *  15.78%*
      Hmean     send-3312      8468.36 (   0.00%)    10288.02 *  21.49%*
      Hmean     send-4096     10135.46 (   0.00%)    12387.57 *  22.22%*
      Hmean     send-8192     17142.07 (   0.00%)    19748.11 *  15.20%*
      Hmean     send-16384    28539.71 (   0.00%)    30084.45 *   5.41%*
      
      Fixes: e6d4f08a ("intel_idle: Use ACPI _CST on server systems")
      Signed-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Cc: 5.6+ <stable@vger.kernel.org> # 5.6+
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      75af76d0
    • Daniel Lezcano's avatar
      cpuidle: Remove pointless stub · bae314dd
      Daniel Lezcano authored
      The cpuidle.h header is declaring a function with an empty stub
      for the cpuidle disabled case, but that function is only called
      by cpuidle governors which depend on cpuidle anyway.
      
      In other words, the function is only called when cpuidle is enabled,
      so there is no need for the stub.
      
      Remove the pointless stub.
      Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      [ rjw: Changelog edits ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      bae314dd
    • Alexander Monakov's avatar
      intel_idle: mention assumption that WBINVD is not needed · 8bb2e2a8
      Alexander Monakov authored
      Intel SDM does not explicitly say that entering a C-state via MWAIT will
      implicitly flush CPU caches as appropriate for that C-state. However,
      documentation for individual Intel CPU generations does mention this
      behavior.
      
      Since intel_idle binds to any Intel CPU with MWAIT, list this assumption
      of MWAIT behavior.
      
      In passing, reword opening comment to make it clear that the driver can
      load on any old and future Intel CPU with MWAIT.
      Signed-off-by: default avatarAlexander Monakov <amonakov@ispras.ru>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8bb2e2a8
    • Ulf Hansson's avatar
      MAINTAINERS: Add section for cpuidle-psci PM domain · e0578334
      Ulf Hansson authored
      The cpuidle-psci-domain.c is not listed in the section for the cpuidle
      driver for ARM PSCI.
      
      From discussions at LKML, Lorenzo and Sudeep prefer to add a separate
      section for it, so do that and add myself as the maintainer for that
      part.
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      [ rjw: Changelog edits ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e0578334
    • Chen Yu's avatar
      cpufreq: intel_pstate: Delete intel_pstate sysfs if failed to register the driver · cdc1719c
      Chen Yu authored
      There is a corner case that if the intel_pstate driver fails to be
      registered (might be due to invalid MSR access) and acpi_cpufreq
      takse over, the intel_pstate sysfs interface is still populated
      which may confuse user space (turbostat for example):
      
      grep . /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
      acpi-cpufreq
      
      grep . /sys/devices/system/cpu/intel_pstate/*
      /sys/devices/system/cpu/intel_pstate/max_perf_pct:0
      /sys/devices/system/cpu/intel_pstate/min_perf_pct:0
      grep: /sys/devices/system/cpu/intel_pstate/no_turbo: Resource temporarily unavailable
      grep: /sys/devices/system/cpu/intel_pstate/num_pstates: Resource temporarily unavailable
      /sys/devices/system/cpu/intel_pstate/status:off
      grep: /sys/devices/system/cpu/intel_pstate/turbo_pct: Resource temporarily unavailable
      
      The mere presence of the intel_pstate sysfs interface does not mean
      that intel_pstate is in use (for example, echo "off" to "status"),
      but it should not be created in the failing case.
      
      Fix this issue by deleting the intel_pstate sysfs if the driver
      registration fails.
      Reported-by: default avatarWendy Wang <wendy.wang@intel.com>
      Suggested-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarChen Yu <yu.c.chen@intel.com>
      Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com
      [ rjw: Refactor code to avoid jumps, change function name, changelog edits ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      cdc1719c
    • Viresh Kumar's avatar
      cpufreq: Improve code around unlisted freq check · 97148d0a
      Viresh Kumar authored
      The cpufreq core checks if the frequency programmed by the bootloaders
      is not listed in the freq table and programs one from the table in such
      a case. This is done only if the driver has set the
      CPUFREQ_NEED_INITIAL_FREQ_CHECK flag.
      
      Currently we print two separate messages, with almost the same content,
      and do this with a pr_warn() which may be a bit too much as the driver
      only asked us to check this as it expected this to be the case. Lower
      down the severity of the print message by switching to pr_info() instead
      and print a single message only.
      Reported-by: default avatarSumit Gupta <sumitg@nvidia.com>
      Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Reviewed-by: default avatarSumit Gupta <sumitg@nvidia.com>
      Tested-by: default avatarSumit Gupta <sumitg@nvidia.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      97148d0a
  5. 14 Oct, 2020 27 commits
    • Linus Torvalds's avatar
      Merge tag 'pnp-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · defb53a7
      Linus Torvalds authored
      Pull PNP updates from Rafael Wysocki:
       "These clean the PNP code somewhat:
      
         - Remove the now unused pnp_find_card() function (Christoph Hellwig)
      
         - Drop duplicate pci.h include from the quirks code and add an
           "internal.h" include to acpi_pnp.c to fix a compiler warning (Tian
           Tao)"
      
      * tag 'pnp-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        PNP: remove the now unused pnp_find_card() function
        PNP: ACPI: Fix missing-prototypes in acpi_pnp.c
        PNP: quirks: Fix duplicate included pci.h
      defb53a7
    • Linus Torvalds's avatar
      Merge tag 'acpi-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · cf1d2b44
      Linus Torvalds authored
      Pull ACPI updates from Rafael Wysocki:
       "These add support for generic initiator-only proximity domains to the
        ACPI NUMA code and the architectures using it, clean up some
        non-ACPICA code referring to debug facilities from ACPICA, reduce the
        overhead related to accessing GPE registers, add a new DPTF (Dynamic
        Power and Thermal Framework) participant driver, update the ACPICA
        code in the kernel to upstream revision 20200925, add a new ACPI
        backlight whitelist entry, fix a few assorted issues and clean up some
        code.
      
        Specifics:
      
         - Add support for generic initiator-only proximity domains to the
           ACPI NUMA code and the architectures using it (Jonathan Cameron)
      
         - Clean up some non-ACPICA code referring to debug facilities from
           ACPICA that are not actually used in there (Hanjun Guo)
      
         - Add new DPTF driver for the PCH FIVR participant (Srinivas
           Pandruvada)
      
         - Reduce overhead related to accessing GPE registers in ACPICA and
           the OS interface layer and make it possible to access GPE registers
           using logical addresses if they are memory-mapped (Rafael Wysocki)
      
         - Update the ACPICA code in the kernel to upstream revision 20200925
           including changes as follows:
            + Add predefined names from the SMBus sepcification (Bob Moore)
            + Update acpi_help UUID list (Bob Moore)
            + Return exceptions for string-to-integer conversions in iASL (Bob
              Moore)
            + Add a new "ALL <NameSeg>" debugger command (Bob Moore)
            + Add support for 64 bit risc-v compilation (Colin Ian King)
            + Do assorted cleanups (Bob Moore, Colin Ian King, Randy Dunlap)
      
         - Add new ACPI backlight whitelist entry for HP 635 Notebook (Alex
           Hung)
      
         - Move TPS68470 OpRegion driver to drivers/acpi/pmic/ and split out
           Kconfig and Makefile specific for ACPI PMIC (Andy Shevchenko)
      
         - Clean up the ACPI SoC driver for AMD SoCs (Hanjun Guo)
      
         - Add missing config_item_put() to fix refcount leak (Hanjun Guo)
      
         - Drop lefrover field from struct acpi_memory_device (Hanjun Guo)
      
         - Make the ACPI extlog driver check for RDMSR failures (Ben
           Hutchings)
      
         - Fix handling of lid state changes in the ACPI button driver when
           input device is closed (Dmitry Torokhov)
      
         - Fix several assorted build issues (Barnabás Pőcze, John Garry,
           Nathan Chancellor, Tian Tao)
      
         - Drop unused inline functions and reduce code duplication by using
           kobj_to_dev() in the NFIT parsing code (YueHaibing, Wang Qing)
      
         - Serialize tools/power/acpi Makefile (Thomas Renninger)"
      
      * tag 'acpi-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (64 commits)
        ACPICA: Update version to 20200925 Version 20200925
        ACPICA: Remove unnecessary semicolon
        ACPICA: Debugger: Add a new command: "ALL <NameSeg>"
        ACPICA: iASL: Return exceptions for string-to-integer conversions
        ACPICA: acpi_help: Update UUID list
        ACPICA: Add predefined names found in the SMBus sepcification
        ACPICA: Tree-wide: fix various typos and spelling mistakes
        ACPICA: Drop the repeated word "an" in a comment
        ACPICA: Add support for 64 bit risc-v compilation
        ACPI: button: fix handling lid state changes when input device closed
        tools/power/acpi: Serialize Makefile
        ACPI: scan: Replace ACPI_DEBUG_PRINT() with pr_debug()
        ACPI: memhotplug: Remove 'state' from struct acpi_memory_device
        ACPI / extlog: Check for RDMSR failure
        ACPI: Make acpi_evaluate_dsm() prototype consistent
        docs: mm: numaperf.rst Add brief description for access class 1.
        node: Add access1 class to represent CPU to memory characteristics
        ACPI: HMAT: Fix handling of changes from ACPI 6.2 to ACPI 6.3
        ACPI: Let ACPI know we support Generic Initiator Affinity Structures
        x86: Support Generic Initiator only proximity domains
        ...
      cf1d2b44
    • Linus Torvalds's avatar
      Merge tag 'pm-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 0b8417c1
      Linus Torvalds authored
      Pull power management updates from Rafael Wysocki:
       "These rework the collection of cpufreq statistics to allow it to take
        place if fast frequency switching is enabled in the governor, rework
        the frequency invariance handling in the cpufreq core and drivers, add
        new hardware support to a couple of cpufreq drivers, fix a number of
        assorted issues and clean up the code all over.
      
        Specifics:
      
         - Rework cpufreq statistics collection to allow it to take place when
           fast frequency switching is enabled in the governor (Viresh Kumar).
      
         - Make the cpufreq core set the frequency scale on behalf of the
           driver and update several cpufreq drivers accordingly (Ionela
           Voinescu, Valentin Schneider).
      
         - Add new hardware support to the STI and qcom cpufreq drivers and
           improve them (Alain Volmat, Manivannan Sadhasivam).
      
         - Fix multiple assorted issues in cpufreq drivers (Jon Hunter,
           Krzysztof Kozlowski, Matthias Kaehlcke, Pali Rohár, Stephan
           Gerhold, Viresh Kumar).
      
         - Fix several assorted issues in the operating performance points
           (OPP) framework (Stephan Gerhold, Viresh Kumar).
      
         - Allow devfreq drivers to fetch devfreq instances by DT enumeration
           instead of using explicit phandles and modify the devfreq core code
           to support driver-specific devfreq DT bindings (Leonard Crestez,
           Chanwoo Choi).
      
         - Improve initial hardware resetting in the tegra30 devfreq driver
           and clean up the tegra cpuidle driver (Dmitry Osipenko).
      
         - Update the cpuidle core to collect state entry rejection statistics
           and expose them via sysfs (Lina Iyer).
      
         - Improve the ACPI _CST code handling diagnostics (Chen Yu).
      
         - Update the PSCI cpuidle driver to allow the PM domain
           initialization to occur in the OSI mode as well as in the PC mode
           (Ulf Hansson).
      
         - Rework the generic power domains (genpd) core code to allow domain
           power off transition to be aborted in the absence of the "power
           off" domain callback (Ulf Hansson).
      
         - Fix two suspend-to-idle issues in the ACPI EC driver (Rafael
           Wysocki).
      
         - Fix the handling of timer_expires in the PM-runtime framework on
           32-bit systems and the handling of device links in it (Grygorii
           Strashko, Xiang Chen).
      
         - Add IO requests batching support to the hibernate image saving and
           reading code and drop a bogus get_gendisk() from there (Xiaoyi
           Chen, Christoph Hellwig).
      
         - Allow PCIe ports to be put into the D3cold power state if they are
           power-manageable via ACPI (Lukas Wunner).
      
         - Add missing header file include to a power capping driver (Pujin
           Shi).
      
         - Clean up the qcom-cpr AVS driver a bit (Liu Shixin).
      
         - Kevin Hilman steps down as designated reviwer of adaptive voltage
           scaling (AVS) drivers (Kevin Hilman)"
      
      * tag 'pm-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (65 commits)
        cpufreq: stats: Fix string format specifier mismatch
        arm: disable frequency invariance for CONFIG_BL_SWITCHER
        cpufreq,arm,arm64: restructure definitions of arch_set_freq_scale()
        cpufreq: stats: Add memory barrier to store_reset()
        cpufreq: schedutil: Simplify sugov_fast_switch()
        ACPI: EC: PM: Drop ec_no_wakeup check from acpi_ec_dispatch_gpe()
        ACPI: EC: PM: Flush EC work unconditionally after wakeup
        PCI/ACPI: Whitelist hotplug ports for D3 if power managed by ACPI
        PM: hibernate: remove the bogus call to get_gendisk() in software_resume()
        cpufreq: Move traces and update to policy->cur to cpufreq core
        cpufreq: stats: Enable stats for fast-switch as well
        cpufreq: stats: Mark few conditionals with unlikely()
        cpufreq: stats: Remove locking
        cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()
        PM: domains: Allow to abort power off when no ->power_off() callback
        PM: domains: Rename power state enums for genpd
        PM / devfreq: tegra30: Improve initial hardware resetting
        PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function
        PM / devfreq: Change prototype of devfreq_get_devfreq_by_phandle function
        PM / devfreq: Add devfreq_get_devfreq_by_node function
        ...
      0b8417c1
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v5.10-1' of... · 15cb5469
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v5.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver updates from Hans de Goede:
       "Rather calm cycle for x86 platform drivers, all these have been in
        for-next for a couple of days with no bot complaints.
      
        Highlights:
      
         - PMC TigerLake fixes and new RocketLake support
      
         - various small fixes / updates in other drivers/tools"
      
      * tag 'platform-drivers-x86-v5.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        MAINTAINERS: update X86 PLATFORM DRIVERS entry with new kernel.org git repo
        platform/x86: mlx-platform: Add capability field to platform FAN description
        platform_data/mlxreg: Extend core platform structure
        platform_data/mlxreg: Update module license
        platform/x86: mlx-platform: Remove PSU EEPROM configuration
        MAINTAINERS: Update maintainers for pmc_core driver
        platform/x86: intel_pmc_core: fix: Replace dev_dbg macro with dev_info()
        platform/x86: intel_pmc_core: Add Intel RocketLake (RKL) support
        platform/x86: intel_pmc_core: Clean up: Remove the duplicate comments and reorganize
        platform/x86: intel_pmc_core: Fix the slp_s0 counter displayed value
        platform/x86: intel_pmc_core: Fix TigerLake power gating status map
        platform/x86: pmc_core: Use descriptive names for LPM registers
        tools/power/x86/intel-speed-select: Update version for v5.10
        tools/power/x86/intel-speed-select: Fix missing base-freq core IDs
        platform/x86: hp-wmi: add support for thermal policy
      15cb5469
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.10b-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · a09b1d78
      Linus Torvalds authored
      Pull xen updates from Juergen Gross:
      
       - two small cleanup patches
      
       - avoid error messages when initializing MCA banks in a Xen dom0
      
       - a small series for converting the Xen gntdev driver to use
         pin_user_pages*() instead of get_user_pages*()
      
       - intermediate fix for running as a Xen guest on Arm with KPTI enabled
         (the final solution will need new Xen functionality)
      
      * tag 'for-linus-5.10b-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        x86/xen: Fix typo in xen_pagetable_p2m_free()
        x86/xen: disable Firmware First mode for correctable memory errors
        xen/arm: do not setup the runstate info page if kpti is enabled
        xen: remove redundant initialization of variable ret
        xen/gntdev.c: Convert get_user_pages*() to pin_user_pages*()
        xen/gntdev.c: Mark pages as dirty
      a09b1d78
    • Linus Torvalds's avatar
      Merge tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux · 4907a43d
      Linus Torvalds authored
      Pull Hyper-V updates from Wei Liu:
      
       - a series from Boqun Feng to support page size larger than 4K
      
       - a few miscellaneous clean-ups
      
      * tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
        hv: clocksource: Add notrace attribute to read_hv_sched_clock_*() functions
        x86/hyperv: Remove aliases with X64 in their name
        PCI: hv: Document missing hv_pci_protocol_negotiation() parameter
        scsi: storvsc: Support PAGE_SIZE larger than 4K
        Driver: hv: util: Use VMBUS_RING_SIZE() for ringbuffer sizes
        HID: hyperv: Use VMBUS_RING_SIZE() for ringbuffer sizes
        Input: hyperv-keyboard: Use VMBUS_RING_SIZE() for ringbuffer sizes
        hv_netvsc: Use HV_HYP_PAGE_SIZE for Hyper-V communication
        hv: hyperv.h: Introduce some hvpfn helper functions
        Drivers: hv: vmbus: Move virt_to_hvpfn() to hyperv header
        Drivers: hv: Use HV_HYP_PAGE in hv_synic_enable_regs()
        Drivers: hv: vmbus: Introduce types of GPADL
        Drivers: hv: vmbus: Move __vmbus_open()
        Drivers: hv: vmbus: Always use HV_HYP_PAGE_SIZE for gpadl
        drivers: hv: remove cast from hyperv_die_event
      4907a43d
    • Linus Torvalds's avatar
      Merge tag 'x86_seves_for_v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · da9803df
      Linus Torvalds authored
      Pull x86 SEV-ES support from Borislav Petkov:
       "SEV-ES enhances the current guest memory encryption support called SEV
        by also encrypting the guest register state, making the registers
        inaccessible to the hypervisor by en-/decrypting them on world
        switches. Thus, it adds additional protection to Linux guests against
        exfiltration, control flow and rollback attacks.
      
        With SEV-ES, the guest is in full control of what registers the
        hypervisor can access. This is provided by a guest-host exchange
        mechanism based on a new exception vector called VMM Communication
        Exception (#VC), a new instruction called VMGEXIT and a shared
        Guest-Host Communication Block which is a decrypted page shared
        between the guest and the hypervisor.
      
        Intercepts to the hypervisor become #VC exceptions in an SEV-ES guest
        so in order for that exception mechanism to work, the early x86 init
        code needed to be made able to handle exceptions, which, in itself,
        brings a bunch of very nice cleanups and improvements to the early
        boot code like an early page fault handler, allowing for on-demand
        building of the identity mapping. With that, !KASLR configurations do
        not use the EFI page table anymore but switch to a kernel-controlled
        one.
      
        The main part of this series adds the support for that new exchange
        mechanism. The goal has been to keep this as much as possibly separate
        from the core x86 code by concentrating the machinery in two
        SEV-ES-specific files:
      
          arch/x86/kernel/sev-es-shared.c
          arch/x86/kernel/sev-es.c
      
        Other interaction with core x86 code has been kept at minimum and
        behind static keys to minimize the performance impact on !SEV-ES
        setups.
      
        Work by Joerg Roedel and Thomas Lendacky and others"
      
      * tag 'x86_seves_for_v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (73 commits)
        x86/sev-es: Use GHCB accessor for setting the MMIO scratch buffer
        x86/sev-es: Check required CPU features for SEV-ES
        x86/efi: Add GHCB mappings when SEV-ES is active
        x86/sev-es: Handle NMI State
        x86/sev-es: Support CPU offline/online
        x86/head/64: Don't call verify_cpu() on starting APs
        x86/smpboot: Load TSS and getcpu GDT entry before loading IDT
        x86/realmode: Setup AP jump table
        x86/realmode: Add SEV-ES specific trampoline entry point
        x86/vmware: Add VMware-specific handling for VMMCALL under SEV-ES
        x86/kvm: Add KVM-specific VMMCALL handling under SEV-ES
        x86/paravirt: Allow hypervisor-specific VMMCALL handling under SEV-ES
        x86/sev-es: Handle #DB Events
        x86/sev-es: Handle #AC Events
        x86/sev-es: Handle VMMCALL Events
        x86/sev-es: Handle MWAIT/MWAITX Events
        x86/sev-es: Handle MONITOR/MONITORX Events
        x86/sev-es: Handle INVD Events
        x86/sev-es: Handle RDPMC Events
        x86/sev-es: Handle RDTSC(P) Events
        ...
      da9803df
    • Linus Torvalds's avatar
      Merge tag 'objtool-core-2020-10-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 6873139e
      Linus Torvalds authored
      Pull objtool updates from Ingo Molnar:
       "Most of the changes are cleanups and reorganization to make the
        objtool code more arch-agnostic. This is in preparation for non-x86
        support.
      
        Other changes:
      
         - KASAN fixes
      
         - Handle unreachable trap after call to noreturn functions better
      
         - Ignore unreachable fake jumps
      
         - Misc smaller fixes & cleanups"
      
      * tag 'objtool-core-2020-10-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
        perf build: Allow nested externs to enable BUILD_BUG() usage
        objtool: Allow nested externs to enable BUILD_BUG()
        objtool: Permit __kasan_check_{read,write} under UACCESS
        objtool: Ignore unreachable trap after call to noreturn functions
        objtool: Handle calling non-function symbols in other sections
        objtool: Ignore unreachable fake jumps
        objtool: Remove useless tests before save_reg()
        objtool: Decode unwind hint register depending on architecture
        objtool: Make unwind hint definitions available to other architectures
        objtool: Only include valid definitions depending on source file type
        objtool: Rename frame.h -> objtool.h
        objtool: Refactor jump table code to support other architectures
        objtool: Make relocation in alternative handling arch dependent
        objtool: Abstract alternative special case handling
        objtool: Move macros describing structures to arch-dependent code
        objtool: Make sync-check consider the target architecture
        objtool: Group headers to check in a single list
        objtool: Define 'struct orc_entry' only when needed
        objtool: Skip ORC entry creation for non-text sections
        objtool: Move ORC logic out of check()
        ...
      6873139e
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · d5660df4
      Linus Torvalds authored
      Merge misc updates from Andrew Morton:
       "181 patches.
      
        Subsystems affected by this patch series: kbuild, scripts, ntfs,
        ocfs2, vfs, mm (slab, slub, kmemleak, dax, debug, pagecache, fadvise,
        gup, swap, memremap, memcg, selftests, pagemap, mincore, hmm, dma,
        memory-failure, vmallo and migration)"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (181 commits)
        mm/migrate: remove obsolete comment about device public
        mm/migrate: remove cpages-- in migrate_vma_finalize()
        mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary
        memblock: use separate iterators for memory and reserved regions
        memblock: implement for_each_reserved_mem_region() using __next_mem_region()
        memblock: remove unused memblock_mem_size()
        x86/setup: simplify reserve_crashkernel()
        x86/setup: simplify initrd relocation and reservation
        arch, drivers: replace for_each_membock() with for_each_mem_range()
        arch, mm: replace for_each_memblock() with for_each_mem_pfn_range()
        memblock: reduce number of parameters in for_each_mem_range()
        memblock: make memblock_debug and related functionality private
        memblock: make for_each_memblock_type() iterator private
        mircoblaze: drop unneeded NUMA and sparsemem initializations
        riscv: drop unneeded node initialization
        h8300, nds32, openrisc: simplify detection of memory extents
        arm64: numa: simplify dummy_numa_init()
        arm, xtensa: simplify initialization of high memory pages
        dma-contiguous: simplify cma_early_percent_memory()
        KVM: PPC: Book3S HV: simplify kvm_cma_reserve()
        ...
      d5660df4
    • Ralph Campbell's avatar
      mm/migrate: remove obsolete comment about device public · f1f4f3ab
      Ralph Campbell authored
      Device public memory never had an in tree consumer and was removed in
      commit 25b2995a ("mm: remove MEMORY_DEVICE_PUBLIC support").  Delete
      the obsolete comment.
      Signed-off-by: default avatarRalph Campbell <rcampbell@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Link: http://lkml.kernel.org/r/20200827190735.12752-2-rcampbell@nvidia.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f1f4f3ab
    • Ralph Campbell's avatar
      mm/migrate: remove cpages-- in migrate_vma_finalize() · 42578891
      Ralph Campbell authored
      The variable struct migrate_vma->cpages is only used in
      migrate_vma_setup().  There is no need to decrement it in
      migrate_vma_finalize() since it is never checked.
      Signed-off-by: default avatarRalph Campbell <rcampbell@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Jason Gunthorpe <jgg@nvidia.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Link: http://lkml.kernel.org/r/20200827190735.12752-1-rcampbell@nvidia.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      42578891
    • Suren Baghdasaryan's avatar
      mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary · 67197a4f
      Suren Baghdasaryan authored
      Currently __set_oom_adj loops through all processes in the system to keep
      oom_score_adj and oom_score_adj_min in sync between processes sharing
      their mm.  This is done for any task with more that one mm_users, which
      includes processes with multiple threads (sharing mm and signals).
      However for such processes the loop is unnecessary because their signal
      structure is shared as well.
      
      Android updates oom_score_adj whenever a tasks changes its role
      (background/foreground/...) or binds to/unbinds from a service, making it
      more/less important.  Such operation can happen frequently.  We noticed
      that updates to oom_score_adj became more expensive and after further
      investigation found out that the patch mentioned in "Fixes" introduced a
      regression.  Using Pixel 4 with a typical Android workload, write time to
      oom_score_adj increased from ~3.57us to ~362us.  Moreover this regression
      linearly depends on the number of multi-threaded processes running on the
      system.
      
      Mark the mm with a new MMF_MULTIPROCESS flag bit when task is created with
      (CLONE_VM && !CLONE_THREAD && !CLONE_VFORK).  Change __set_oom_adj to use
      MMF_MULTIPROCESS instead of mm_users to decide whether oom_score_adj
      update should be synchronized between multiple processes.  To prevent
      races between clone() and __set_oom_adj(), when oom_score_adj of the
      process being cloned might be modified from userspace, we use
      oom_adj_mutex.  Its scope is changed to global.
      
      The combination of (CLONE_VM && !CLONE_THREAD) is rarely used except for
      the case of vfork().  To prevent performance regressions of vfork(), we
      skip taking oom_adj_mutex and setting MMF_MULTIPROCESS when CLONE_VFORK is
      specified.  Clearing the MMF_MULTIPROCESS flag (when the last process
      sharing the mm exits) is left out of this patch to keep it simple and
      because it is believed that this threading model is rare.  Should there
      ever be a need for optimizing that case as well, it can be done by hooking
      into the exit path, likely following the mm_update_next_owner pattern.
      
      With the combination of (CLONE_VM && !CLONE_THREAD && !CLONE_VFORK) being
      quite rare, the regression is gone after the change is applied.
      
      [surenb@google.com: v3]
        Link: https://lkml.kernel.org/r/20200902012558.2335613-1-surenb@google.com
      
      Fixes: 44a70ade ("mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj")
      Reported-by: default avatarTim Murray <timmurray@google.com>
      Suggested-by: default avatarMichal Hocko <mhocko@kernel.org>
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Eugene Syromiatnikov <esyr@redhat.com>
      Cc: Christian Kellner <christian@kellner.me>
      Cc: Adrian Reber <areber@redhat.com>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Aleksa Sarai <cyphar@cyphar.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
      Cc: Michel Lespinasse <walken@google.com>
      Cc: Daniel Jordan <daniel.m.jordan@oracle.com>
      Cc: Andrei Vagin <avagin@gmail.com>
      Cc: Bernd Edlinger <bernd.edlinger@hotmail.de>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Yafang Shao <laoar.shao@gmail.com>
      Link: https://lkml.kernel.org/r/20200824153036.3201505-1-surenb@google.comDebugged-by: default avatarMinchan Kim <minchan@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      67197a4f
    • Mike Rapoport's avatar
      memblock: use separate iterators for memory and reserved regions · cc6de168
      Mike Rapoport authored
      for_each_memblock() is used to iterate over memblock.memory in a few
      places that use data from memblock_region rather than the memory ranges.
      
      Introduce separate for_each_mem_region() and
      for_each_reserved_mem_region() to improve encapsulation of memblock
      internals from its users.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: Ingo Molnar <mingo@kernel.org>			[x86]
      Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>	[MIPS]
      Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>	[.clang-format]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-18-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cc6de168
    • Mike Rapoport's avatar
      memblock: implement for_each_reserved_mem_region() using __next_mem_region() · 9f3d5eaa
      Mike Rapoport authored
      Iteration over memblock.reserved with for_each_reserved_mem_region() used
      __next_reserved_mem_region() that implemented a subset of
      __next_mem_region().
      
      Use __for_each_mem_range() and, essentially, __next_mem_region() with
      appropriate parameters to reduce code duplication.
      
      While on it, rename for_each_reserved_mem_region() to
      for_each_reserved_mem_range() for consistency.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>	[.clang-format]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-17-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f3d5eaa
    • Mike Rapoport's avatar
      memblock: remove unused memblock_mem_size() · 5bd0960b
      Mike Rapoport authored
      The only user of memblock_mem_size() was x86 setup code, it is gone now
      and memblock_mem_size() funciton can be removed.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-16-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5bd0960b
    • Mike Rapoport's avatar
      x86/setup: simplify reserve_crashkernel() · 6120cdc0
      Mike Rapoport authored
      * Replace magic numbers with defines
      * Replace memblock_find_in_range() + memblock_reserve() with
        memblock_phys_alloc_range()
      * Stop checking for low memory size in reserve_crashkernel_low(). The
        allocation from limited range will anyway fail if there is no enough
        memory, so there is no need for extra traversal of memblock.memory
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-15-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6120cdc0
    • Mike Rapoport's avatar
      x86/setup: simplify initrd relocation and reservation · 3c45ee6d
      Mike Rapoport authored
      Currently, initrd image is reserved very early during setup and then it
      might be relocated and re-reserved after the initial physical memory
      mapping is created.  The "late" reservation of memblock verifies that
      mapped memory size exceeds the size of initrd, then checks whether the
      relocation required and, if yes, relocates inirtd to a new memory
      allocated from memblock and frees the old location.
      
      The check for memory size is excessive as memblock allocation will anyway
      fail if there is not enough memory.  Besides, there is no point to
      allocate memory from memblock using memblock_find_in_range() +
      memblock_reserve() when there exists memblock_phys_alloc_range() with
      required functionality.
      
      Remove the redundant check and simplify memblock allocation.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-14-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3c45ee6d
    • Mike Rapoport's avatar
      arch, drivers: replace for_each_membock() with for_each_mem_range() · b10d6bca
      Mike Rapoport authored
      There are several occurrences of the following pattern:
      
      	for_each_memblock(memory, reg) {
      		start = __pfn_to_phys(memblock_region_memory_base_pfn(reg);
      		end = __pfn_to_phys(memblock_region_memory_end_pfn(reg));
      
      		/* do something with start and end */
      	}
      
      Using for_each_mem_range() iterator is more appropriate in such cases and
      allows simpler and cleaner code.
      
      [akpm@linux-foundation.org: fix arch/arm/mm/pmsa-v7.c build]
      [rppt@linux.ibm.com: mips: fix cavium-octeon build caused by memblock refactoring]
        Link: http://lkml.kernel.org/r/20200827124549.GD167163@linux.ibm.comSigned-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-13-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b10d6bca
    • Mike Rapoport's avatar
      arch, mm: replace for_each_memblock() with for_each_mem_pfn_range() · c9118e6c
      Mike Rapoport authored
      There are several occurrences of the following pattern:
      
      	for_each_memblock(memory, reg) {
      		start_pfn = memblock_region_memory_base_pfn(reg);
      		end_pfn = memblock_region_memory_end_pfn(reg);
      
      		/* do something with start_pfn and end_pfn */
      	}
      
      Rather than iterate over all memblock.memory regions and each time query
      for their start and end PFNs, use for_each_mem_pfn_range() iterator to get
      simpler and clearer code.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>	[.clang-format]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-12-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c9118e6c
    • Mike Rapoport's avatar
      memblock: reduce number of parameters in for_each_mem_range() · 6e245ad4
      Mike Rapoport authored
      Currently for_each_mem_range() and for_each_mem_range_rev() iterators are
      the most generic way to traverse memblock regions.  As such, they have 8
      parameters and they are hardly convenient to users.  Most users choose to
      utilize one of their wrappers and the only user that actually needs most
      of the parameters is memblock itself.
      
      To avoid yet another naming for memblock iterators, rename the existing
      for_each_mem_range[_rev]() to __for_each_mem_range[_rev]() and add a new
      for_each_mem_range[_rev]() wrappers with only index, start and end
      parameters.
      
      The new wrapper nicely fits into init_unavailable_mem() and will be used
      in upcoming changes to simplify memblock traversals.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>	[MIPS]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-11-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6e245ad4
    • Mike Rapoport's avatar
      memblock: make memblock_debug and related functionality private · 87c55870
      Mike Rapoport authored
      The only user of memblock_dbg() outside memblock was s390 setup code and
      it is converted to use pr_debug() instead.  This allows to stop exposing
      memblock_debug and memblock_dbg() to the rest of the kernel.
      
      [akpm@linux-foundation.org: make memblock_dbg() safer and neater]
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-10-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      87c55870
    • Mike Rapoport's avatar
      memblock: make for_each_memblock_type() iterator private · cd991db8
      Mike Rapoport authored
      for_each_memblock_type() is not used outside mm/memblock.c, move it there
      from include/linux/memblock.h
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-9-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cd991db8
    • Mike Rapoport's avatar
      mircoblaze: drop unneeded NUMA and sparsemem initializations · 49645793
      Mike Rapoport authored
      microblaze does not support neither NUMA not SPARSMEM, so there is no
      point to call memblock_set_node() and
      sparse_memory_present_with_active_regions() functions during microblaze
      memory initialization.
      
      Remove these calls and the surrounding code.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-8-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      49645793
    • Mike Rapoport's avatar
      riscv: drop unneeded node initialization · c8e47018
      Mike Rapoport authored
      RISC-V does not (yet) support NUMA and for UMA architectures node 0 is
      used implicitly during early memory initialization.
      
      There is no need to call memblock_set_node(), remove this call and the
      surrounding code.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-7-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c8e47018
    • Mike Rapoport's avatar
      h8300, nds32, openrisc: simplify detection of memory extents · 80c45744
      Mike Rapoport authored
      Instead of traversing memblock.memory regions to find memory_start and
      memory_end, simply query memblock_{start,end}_of_DRAM().
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarStafford Horne <shorne@gmail.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-6-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      80c45744
    • Mike Rapoport's avatar
      arm64: numa: simplify dummy_numa_init() · ab8f21aa
      Mike Rapoport authored
      dummy_numa_init() loops over memblock.memory and passes nid=0 to
      numa_add_memblk() which essentially wraps memblock_set_node().  However,
      memblock_set_node() can cope with entire memory span itself, so the loop
      over memblock.memory regions is redundant.
      
      Using a single call to memblock_set_node() rather than a loop also fixes
      an issue with a buggy ACPI firmware in which the SRAT table covers some
      but not all of the memory in the EFI memory map.
      
      Jonathan Cameron says:
      
        This issue can be easily triggered by having an SRAT table which fails
        to cover all elements of the EFI memory map.
      
        This firmware error is detected and a warning printed. e.g.
        "NUMA: Warning: invalid memblk node 64 [mem 0x240000000-0x27fffffff]"
        At that point we fall back to dummy_numa_init().
      
        However, the failed ACPI init has left us with our memblocks all broken
        up as we split them when trying to assign them to NUMA nodes.
      
        We then iterate over the memblocks and add them to node 0.
      
        numa_add_memblk() calls memblock_set_node() which merges regions that
        were previously split up during the earlier attempt to add them to
        different nodes during parsing of SRAT.
      
        This means elements are moved in the memblock array and we can end up
        in a different memblock after the call to numa_add_memblk().
        Result is:
      
        Unable to handle kernel paging request at virtual address 0000000000003a40
        Mem abort info:
          ESR = 0x96000004
          EC = 0x25: DABT (current EL), IL = 32 bits
          SET = 0, FnV = 0
          EA = 0, S1PTW = 0
        Data abort info:
          ISV = 0, ISS = 0x00000004
          CM = 0, WnR = 0
        [0000000000003a40] user address but active_mm is swapper
        Internal error: Oops: 96000004 [#1] PREEMPT SMP
      
        ...
      
        Call trace:
          sparse_init_nid+0x5c/0x2b0
          sparse_init+0x138/0x170
          bootmem_init+0x80/0xe0
          setup_arch+0x2a0/0x5fc
          start_kernel+0x8c/0x648
      
      Replace the loop with a single call to memblock_set_node() to the entire
      memory.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-5-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ab8f21aa
    • Mike Rapoport's avatar
      arm, xtensa: simplify initialization of high memory pages · cddb5ddf
      Mike Rapoport authored
      free_highpages() in both arm and xtensa essentially open-code
      for_each_free_mem_range() loop to detect high memory pages that were not
      reserved and that should be initialized and passed to the buddy allocator.
      
      Replace open-coded implementation of for_each_free_mem_range() with usage
      of memblock API to simplify the code.
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Tested-by: Max Filippov <jcmvbkbc@gmail.com>	[xtensa]
      Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>	[xtensa]
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Emil Renner Berthing <kernel@esmil.dk>
      Cc: Hari Bathini <hbathini@linux.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20200818151634.14343-4-rppt@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cddb5ddf