--- /dev/null
+From b1c0330823fe842dbb34641f1410f0afa51c29d3 Mon Sep 17 00:00:00 2001
+From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
+Date: Wed, 9 Jan 2019 00:34:37 +0100
+Subject: ACPI: EC: Look for ECDT EC after calling acpi_load_tables()
+
+From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+
+commit b1c0330823fe842dbb34641f1410f0afa51c29d3 upstream.
+
+Some systems have had functional issues since commit 5a8361f7ecce
+(ACPICA: Integrate package handling with module-level code) that,
+among other things, changed the initial values of the
+acpi_gbl_group_module_level_code and acpi_gbl_parse_table_as_term_list
+global flags in ACPICA which implicitly caused acpi_ec_ecdt_probe() to
+be called before acpi_load_tables() on the vast majority of platforms.
+
+Namely, before commit 5a8361f7ecce, acpi_load_tables() was called from
+acpi_early_init() if acpi_gbl_parse_table_as_term_list was FALSE and
+acpi_gbl_group_module_level_code was TRUE, which almost always was
+the case as FALSE and TRUE were their initial values, respectively.
+The acpi_gbl_parse_table_as_term_list value would be changed to TRUE
+for a couple of platforms in acpi_quirks_dmi_table[], but it remained
+FALSE in the vast majority of cases.
+
+After commit 5a8361f7ecce, the initial values of the two flags have
+been reversed, so in effect acpi_load_tables() has not been called
+from acpi_early_init() any more. That, in turn, affects
+acpi_ec_ecdt_probe() which is invoked before acpi_load_tables() now
+and it is not possible to evaluate the _REG method for the EC address
+space handler installed by it. That effectively causes the EC address
+space to be inaccessible to AML on platforms with an ECDT matching the
+EC device definition in the DSDT and functional problems ensue in
+there.
+
+Because the default behavior before commit 5a8361f7ecce was to call
+acpi_ec_ecdt_probe() after acpi_load_tables(), it should be safe to
+do that again. Moreover, the EC address space handler installed by
+acpi_ec_ecdt_probe() is only needed for AML to be able to access the
+EC address space and the only AML that can run during acpi_load_tables()
+is module-level code which only is allowed to access address spaces
+with default handlers (memory, I/O and PCI config space).
+
+For this reason, move the acpi_ec_ecdt_probe() invocation back to
+acpi_bus_init(), from where it was taken away by commit d737f333b211
+(ACPI: probe ECDT before loading AML tables regardless of module-level
+code flag), and put it after the invocation of acpi_load_tables() to
+restore the original code ordering from before commit 5a8361f7ecce.
+
+Fixes: 5a8361f7ecce ("ACPICA: Integrate package handling with module-level code")
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=199981
+Reported-by: step-ali <sunmooon15@gmail.com>
+Reported-by: Charles Stanhope <charles.stanhope@gmail.com>
+Tested-by: Charles Stanhope <charles.stanhope@gmail.com>
+Reported-by: Paulo Nascimento <paulo.ulusu@googlemail.com>
+Reported-by: David Purton <dcpurton@marshwiggle.net>
+Reported-by: Adam Harvey <adam@adamharvey.name>
+Reported-by: Zhang Rui <rui.zhang@intel.com>
+Tested-by: Zhang Rui <rui.zhang@intel.com>
+Tested-by: Jean-Marc Lenoir <archlinux@jihemel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Cc: Laurențiu Păncescu <lpancescu@gmail.com>
+Cc: Salvatore Bonaccorso <carnil@debian.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/acpi/bus.c | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+--- a/drivers/acpi/bus.c
++++ b/drivers/acpi/bus.c
+@@ -1054,18 +1054,6 @@ void __init acpi_early_init(void)
+ goto error0;
+ }
+
+- /*
+- * ACPI 2.0 requires the EC driver to be loaded and work before
+- * the EC device is found in the namespace (i.e. before
+- * acpi_load_tables() is called).
+- *
+- * This is accomplished by looking for the ECDT table, and getting
+- * the EC parameters out of that.
+- *
+- * Ignore the result. Not having an ECDT is not fatal.
+- */
+- status = acpi_ec_ecdt_probe();
+-
+ #ifdef CONFIG_X86
+ if (!acpi_ioapic) {
+ /* compatible (0) means level (3) */
+@@ -1142,6 +1130,18 @@ static int __init acpi_bus_init(void)
+ goto error1;
+ }
+
++ /*
++ * ACPI 2.0 requires the EC driver to be loaded and work before the EC
++ * device is found in the namespace.
++ *
++ * This is accomplished by looking for the ECDT table and getting the EC
++ * parameters out of that.
++ *
++ * Do that before calling acpi_initialize_objects() which may trigger EC
++ * address space accesses.
++ */
++ acpi_ec_ecdt_probe();
++
+ status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE);
+ if (ACPI_FAILURE(status)) {
+ printk(KERN_ERR PREFIX
--- /dev/null
+From d737f333b211361b6e239fc753b84c3be2634aaa Mon Sep 17 00:00:00 2001
+From: Erik Schmauss <erik.schmauss@intel.com>
+Date: Wed, 17 Oct 2018 15:41:21 -0700
+Subject: ACPI: probe ECDT before loading AML tables regardless of module-level code flag
+
+From: Erik Schmauss <erik.schmauss@intel.com>
+
+commit d737f333b211361b6e239fc753b84c3be2634aaa upstream.
+
+It was discovered that AML tables were loaded before or after the
+ECDT depending on acpi_gbl_execute_tables_as_methods. According to
+the ACPI spec, the ECDT should be loaded before the namespace is
+populated by loading AML tables (DSDT and SSDT). Since the ECDT
+should be loaded early in the boot process, this change moves the
+ECDT probing to acpi_early_init.
+
+Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Cc: Laurențiu Păncescu <lpancescu@gmail.com>
+Cc: Salvatore Bonaccorso <carnil@debian.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/acpi/bus.c | 44 ++++++++++++++++----------------------------
+ 1 file changed, 16 insertions(+), 28 deletions(-)
+
+--- a/drivers/acpi/bus.c
++++ b/drivers/acpi/bus.c
+@@ -1054,15 +1054,17 @@ void __init acpi_early_init(void)
+ goto error0;
+ }
+
+- if (!acpi_gbl_execute_tables_as_methods &&
+- acpi_gbl_group_module_level_code) {
+- status = acpi_load_tables();
+- if (ACPI_FAILURE(status)) {
+- printk(KERN_ERR PREFIX
+- "Unable to load the System Description Tables\n");
+- goto error0;
+- }
+- }
++ /*
++ * ACPI 2.0 requires the EC driver to be loaded and work before
++ * the EC device is found in the namespace (i.e. before
++ * acpi_load_tables() is called).
++ *
++ * This is accomplished by looking for the ECDT table, and getting
++ * the EC parameters out of that.
++ *
++ * Ignore the result. Not having an ECDT is not fatal.
++ */
++ status = acpi_ec_ecdt_probe();
+
+ #ifdef CONFIG_X86
+ if (!acpi_ioapic) {
+@@ -1133,25 +1135,11 @@ static int __init acpi_bus_init(void)
+
+ acpi_os_initialize1();
+
+- /*
+- * ACPI 2.0 requires the EC driver to be loaded and work before
+- * the EC device is found in the namespace (i.e. before
+- * acpi_load_tables() is called).
+- *
+- * This is accomplished by looking for the ECDT table, and getting
+- * the EC parameters out of that.
+- */
+- status = acpi_ec_ecdt_probe();
+- /* Ignore result. Not having an ECDT is not fatal. */
+-
+- if (acpi_gbl_execute_tables_as_methods ||
+- !acpi_gbl_group_module_level_code) {
+- status = acpi_load_tables();
+- if (ACPI_FAILURE(status)) {
+- printk(KERN_ERR PREFIX
+- "Unable to load the System Description Tables\n");
+- goto error1;
+- }
++ status = acpi_load_tables();
++ if (ACPI_FAILURE(status)) {
++ printk(KERN_ERR PREFIX
++ "Unable to load the System Description Tables\n");
++ goto error1;
+ }
+
+ status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE);
--- /dev/null
+From 60588bfa223ff675b95f866249f90616613fbe31 Mon Sep 17 00:00:00 2001
+From: Cheng Jian <cj.chengjian@huawei.com>
+Date: Fri, 13 Dec 2019 10:45:30 +0800
+Subject: sched/fair: Optimize select_idle_cpu
+
+From: Cheng Jian <cj.chengjian@huawei.com>
+
+commit 60588bfa223ff675b95f866249f90616613fbe31 upstream.
+
+select_idle_cpu() will scan the LLC domain for idle CPUs,
+it's always expensive. so the next commit :
+
+ 1ad3aaf3fcd2 ("sched/core: Implement new approach to scale select_idle_cpu()")
+
+introduces a way to limit how many CPUs we scan.
+
+But it consume some CPUs out of 'nr' that are not allowed
+for the task and thus waste our attempts. The function
+always return nr_cpumask_bits, and we can't find a CPU
+which our task is allowed to run.
+
+Cpumask may be too big, similar to select_idle_core(), use
+per_cpu_ptr 'select_idle_mask' to prevent stack overflow.
+
+Fixes: 1ad3aaf3fcd2 ("sched/core: Implement new approach to scale select_idle_cpu()")
+Signed-off-by: Cheng Jian <cj.chengjian@huawei.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
+Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
+Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
+Link: https://lkml.kernel.org/r/20191213024530.28052-1-cj.chengjian@huawei.com
+Signed-off-by: Yang Wei <yang.wei@linux.alibaba.com>
+Tested-by: Yang Wei <yang.wei@linux.alibaba.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/sched/fair.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/kernel/sched/fair.c
++++ b/kernel/sched/fair.c
+@@ -6154,6 +6154,7 @@ static inline int select_idle_smt(struct
+ */
+ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int target)
+ {
++ struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask);
+ struct sched_domain *this_sd;
+ u64 avg_cost, avg_idle;
+ u64 time, cost;
+@@ -6184,11 +6185,11 @@ static int select_idle_cpu(struct task_s
+
+ time = local_clock();
+
+- for_each_cpu_wrap(cpu, sched_domain_span(sd), target) {
++ cpumask_and(cpus, sched_domain_span(sd), &p->cpus_allowed);
++
++ for_each_cpu_wrap(cpu, cpus, target) {
+ if (!--nr)
+ return -1;
+- if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
+- continue;
+ if (available_idle_cpu(cpu))
+ break;
+ }
btrfs-fix-unmountable-seed-device-after-fstrim.patch
kvm-svm-truncate-gpr-value-for-dr-and-cr-accesses-in-64-bit-mode.patch
kvm-arm64-fix-debug-register-indexing.patch
+acpi-probe-ecdt-before-loading-aml-tables-regardless-of-module-level-code-flag.patch
+acpi-ec-look-for-ecdt-ec-after-calling-acpi_load_tables.patch
+sched-fair-optimize-select_idle_cpu.patch
+xen-pciback-redo-vf-placement-in-the-virtual-topology.patch
--- /dev/null
+From foo@baz Tue Jun 8 07:08:13 PM CEST 2021
+From: Jan Beulich <jbeulich@suse.com>
+Date: Tue, 18 May 2021 18:13:42 +0200
+Subject: xen-pciback: redo VF placement in the virtual topology
+
+From: Jan Beulich <jbeulich@suse.com>
+
+The commit referenced below was incomplete: It merely affected what
+would get written to the vdev-<N> xenstore node. The guest would still
+find the function at the original function number as long as
+__xen_pcibk_get_pci_dev() wouldn't be in sync. The same goes for AER wrt
+__xen_pcibk_get_pcifront_dev().
+
+Undo overriding the function to zero and instead make sure that VFs at
+function zero remain alone in their slot. This has the added benefit of
+improving overall capacity, considering that there's only a total of 32
+slots available right now (PCI segment and bus can both only ever be
+zero at present).
+
+This is upstream commit 4ba50e7c423c29639878c00573288869aa627068.
+
+Fixes: 8a5248fe10b1 ("xen PV passthru: assign SR-IOV virtual functions to
+separate virtual slots")
+Signed-off-by: Jan Beulich <jbeulich@suse.com>
+Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
+Link: https://lore.kernel.org/r/8def783b-404c-3452-196d-3f3fd4d72c9e@suse.com
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/xen/xen-pciback/vpci.c | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+--- a/drivers/xen/xen-pciback/vpci.c
++++ b/drivers/xen/xen-pciback/vpci.c
+@@ -69,7 +69,7 @@ static int __xen_pcibk_add_pci_dev(struc
+ struct pci_dev *dev, int devid,
+ publish_pci_dev_cb publish_cb)
+ {
+- int err = 0, slot, func = -1;
++ int err = 0, slot, func = PCI_FUNC(dev->devfn);
+ struct pci_dev_entry *t, *dev_entry;
+ struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
+
+@@ -94,23 +94,26 @@ static int __xen_pcibk_add_pci_dev(struc
+
+ /*
+ * Keep multi-function devices together on the virtual PCI bus, except
+- * virtual functions.
++ * that we want to keep virtual functions at func 0 on their own. They
++ * aren't multi-function devices and hence their presence at func 0
++ * may cause guests to not scan the other functions.
+ */
+- if (!dev->is_virtfn) {
++ if (!dev->is_virtfn || func) {
+ for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
+ if (list_empty(&vpci_dev->dev_list[slot]))
+ continue;
+
+ t = list_entry(list_first(&vpci_dev->dev_list[slot]),
+ struct pci_dev_entry, list);
++ if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn))
++ continue;
+
+ if (match_slot(dev, t->dev)) {
+ pr_info("vpci: %s: assign to virtual slot %d func %d\n",
+ pci_name(dev), slot,
+- PCI_FUNC(dev->devfn));
++ func);
+ list_add_tail(&dev_entry->list,
+ &vpci_dev->dev_list[slot]);
+- func = PCI_FUNC(dev->devfn);
+ goto unlock;
+ }
+ }
+@@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struc
+ pci_name(dev), slot);
+ list_add_tail(&dev_entry->list,
+ &vpci_dev->dev_list[slot]);
+- func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
+ goto unlock;
+ }
+ }