[tip:irq/core] genirq/affinity: Add is_managed to struct irq_affinity_desc

2018-12-19 Thread tip-bot for Dou Liyang
Commit-ID:  c410abbbacb9b378365ba17a30df08b4b9eec64f
Gitweb: https://git.kernel.org/tip/c410abbbacb9b378365ba17a30df08b4b9eec64f
Author: Dou Liyang 
AuthorDate: Tue, 4 Dec 2018 23:51:21 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 19 Dec 2018 11:32:08 +0100

genirq/affinity: Add is_managed to struct irq_affinity_desc

Devices which use managed interrupts usually have two classes of
interrupts:

  - Interrupts for multiple device queues
  - Interrupts for general device management

Currently both classes are treated the same way, i.e. as managed
interrupts. The general interrupts get the default affinity mask assigned
while the device queue interrupts are spread out over the possible CPUs.

Treating the general interrupts as managed is both a limitation and under
certain circumstances a bug. Assume the following situation:

 default_irq_affinity = 4..7

So if CPUs 4-7 are offlined, then the core code will shut down the device
management interrupts because the last CPU in their affinity mask went
offline.

It's also a limitation because it's desired to allow manual placement of
the general device interrupts for various reasons. If they are marked
managed then the interrupt affinity setting from both user and kernel space
is disabled. That limitation was reported by Kashyap and Sumit.

Expand struct irq_affinity_desc with a new bit 'is_managed' which is set
for truly managed interrupts (queue interrupts) and cleared for the general
device interrupts.

[ tglx: Simplify code and massage changelog ]

Reported-by: Kashyap Desai 
Reported-by: Sumit Saxena 
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: linux-...@vger.kernel.org
Cc: shivasharan.srikanteshw...@broadcom.com
Cc: ming@redhat.com
Cc: h...@lst.de
Cc: bhelg...@google.com
Cc: douliya...@huawei.com
Link: https://lkml.kernel.org/r/20181204155122.6327-3-douliya...@gmail.com

---
 include/linux/interrupt.h |  1 +
 kernel/irq/affinity.c |  4 
 kernel/irq/irqdesc.c  | 13 -
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index c44b7844dc83..c672f34235e7 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -263,6 +263,7 @@ struct irq_affinity {
  */
 struct irq_affinity_desc {
struct cpumask  mask;
+   unsigned intis_managed : 1;
 };
 
 #if defined(CONFIG_SMP)
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index c0fe591b0dc9..45b68b4ea48b 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -289,6 +289,10 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
for (; curvec < nvecs; curvec++)
cpumask_copy([curvec].mask, irq_default_affinity);
 
+   /* Mark the managed interrupts */
+   for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++)
+   masks[i].is_managed = 1;
+
 outnodemsk:
free_node_to_cpumask(node_to_cpumask);
return masks;
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index cb401d6c5040..ee062b7939d3 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -453,27 +453,30 @@ static int alloc_descs(unsigned int start, unsigned int 
cnt, int node,
   struct module *owner)
 {
struct irq_desc *desc;
-   unsigned int flags;
int i;
 
/* Validate affinity mask(s) */
if (affinity) {
-   for (i = 0; i < cnt; i++) {
+   for (i = 0; i < cnt; i++, i++) {
if (cpumask_empty([i].mask))
return -EINVAL;
}
}
 
-   flags = affinity ? IRQD_AFFINITY_MANAGED | IRQD_MANAGED_SHUTDOWN : 0;
-
for (i = 0; i < cnt; i++) {
const struct cpumask *mask = NULL;
+   unsigned int flags = 0;
 
if (affinity) {
-   node = cpu_to_node(cpumask_first(affinity));
+   if (affinity->is_managed) {
+   flags = IRQD_AFFINITY_MANAGED |
+   IRQD_MANAGED_SHUTDOWN;
+   }
mask = >mask;
+   node = cpu_to_node(cpumask_first(mask));
affinity++;
}
+
desc = alloc_desc(start + i, node, flags, mask, owner);
if (!desc)
goto err;


[tip:irq/core] genirq/core: Introduce struct irq_affinity_desc

2018-12-19 Thread tip-bot for Dou Liyang
Commit-ID:  bec04037e4e484f41ee4d9409e40616874169d20
Gitweb: https://git.kernel.org/tip/bec04037e4e484f41ee4d9409e40616874169d20
Author: Dou Liyang 
AuthorDate: Tue, 4 Dec 2018 23:51:20 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 19 Dec 2018 11:32:08 +0100

genirq/core: Introduce struct irq_affinity_desc

The interrupt affinity management uses straight cpumask pointers to convey
the automatically assigned affinity masks for managed interrupts. The core
interrupt descriptor allocation also decides based on the pointer being non
NULL whether an interrupt is managed or not.

Devices which use managed interrupts usually have two classes of
interrupts:

  - Interrupts for multiple device queues
  - Interrupts for general device management

Currently both classes are treated the same way, i.e. as managed
interrupts. The general interrupts get the default affinity mask assigned
while the device queue interrupts are spread out over the possible CPUs.

Treating the general interrupts as managed is both a limitation and under
certain circumstances a bug. Assume the following situation:

 default_irq_affinity = 4..7

So if CPUs 4-7 are offlined, then the core code will shut down the device
management interrupts because the last CPU in their affinity mask went
offline.

It's also a limitation because it's desired to allow manual placement of
the general device interrupts for various reasons. If they are marked
managed then the interrupt affinity setting from both user and kernel space
is disabled.

To remedy that situation it's required to convey more information than the
cpumasks through various interfaces related to interrupt descriptor
allocation.

Instead of adding yet another argument, create a new data structure
'irq_affinity_desc' which for now just contains the cpumask. This struct
can be expanded to convey auxilliary information in the next step.

No functional change, just preparatory work.

[ tglx: Simplified logic and clarified changelog ]

Suggested-by: Thomas Gleixner 
Suggested-by: Bjorn Helgaas 
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: linux-...@vger.kernel.org
Cc: kashyap.de...@broadcom.com
Cc: shivasharan.srikanteshw...@broadcom.com
Cc: sumit.sax...@broadcom.com
Cc: ming@redhat.com
Cc: h...@lst.de
Cc: douliya...@huawei.com
Link: https://lkml.kernel.org/r/20181204155122.6327-2-douliya...@gmail.com

---
 drivers/pci/msi.c |  9 -
 include/linux/interrupt.h | 14 --
 include/linux/irq.h   |  6 --
 include/linux/irqdomain.h |  6 --
 include/linux/msi.h   |  4 ++--
 kernel/irq/affinity.c | 22 --
 kernel/irq/devres.c   |  4 ++--
 kernel/irq/irqdesc.c  | 17 +
 kernel/irq/irqdomain.c|  4 ++--
 kernel/irq/msi.c  |  8 
 10 files changed, 55 insertions(+), 39 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 265ed3e4c920..7a1c8a09efa5 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -534,14 +534,13 @@ error_attrs:
 static struct msi_desc *
 msi_setup_entry(struct pci_dev *dev, int nvec, const struct irq_affinity *affd)
 {
-   struct cpumask *masks = NULL;
+   struct irq_affinity_desc *masks = NULL;
struct msi_desc *entry;
u16 control;
 
if (affd)
masks = irq_create_affinity_masks(nvec, affd);
 
-
/* MSI Entry Initialization */
entry = alloc_msi_entry(>dev, nvec, masks);
if (!entry)
@@ -672,7 +671,7 @@ static int msix_setup_entries(struct pci_dev *dev, void 
__iomem *base,
  struct msix_entry *entries, int nvec,
  const struct irq_affinity *affd)
 {
-   struct cpumask *curmsk, *masks = NULL;
+   struct irq_affinity_desc *curmsk, *masks = NULL;
struct msi_desc *entry;
int ret, i;
 
@@ -1264,7 +1263,7 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev 
*dev, int nr)
 
for_each_pci_msi_entry(entry, dev) {
if (i == nr)
-   return entry->affinity;
+   return >affinity->mask;
i++;
}
WARN_ON_ONCE(1);
@@ -1276,7 +1275,7 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev 
*dev, int nr)
 nr >= entry->nvec_used))
return NULL;
 
-   return >affinity[nr];
+   return >affinity[nr].mask;
} else {
return cpu_possible_mask;
}
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index ca397ff40836..c44b7844dc83 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -257,6 +257,14 @@ struct irq_affinity {
int *sets;
 };
 
+/**
+ * struct irq_affinity_desc - Interrupt affinity descriptor
+ * @mask:  cpumask to hold the affinity assignment
+ */
+struct irq_affinity_desc {
+ 

[tip:x86/apic] irq/matrix: Spread managed interrupts on allocation

2018-09-18 Thread tip-bot for Dou Liyang
Commit-ID:  76f99ae5b54d48430d1f0c5512a84da0ff9761e0
Gitweb: https://git.kernel.org/tip/76f99ae5b54d48430d1f0c5512a84da0ff9761e0
Author: Dou Liyang 
AuthorDate: Sun, 9 Sep 2018 01:58:38 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 18 Sep 2018 18:27:24 +0200

irq/matrix: Spread managed interrupts on allocation

Linux spreads out the non managed interrupt across the possible target CPUs
to avoid vector space exhaustion.

Managed interrupts are treated differently, as for them the vectors are
reserved (with guarantee) when the interrupt descriptors are initialized.

When the interrupt is requested a real vector is assigned. The assignment
logic uses the first CPU in the affinity mask for assignment. If the
interrupt has more than one CPU in the affinity mask, which happens when a
multi queue device has less queues than CPUs, then doing the same search as
for non managed interrupts makes sense as it puts the interrupt on the
least interrupt plagued CPU. For single CPU affine vectors that's obviously
a NOOP.

Restructre the matrix allocation code so it does the 'best CPU' search, add
the sanity check for an empty affinity mask and adapt the call site in the
x86 vector management code.

[ tglx: Added the empty mask check to the core and improved change log ]

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180908175838.14450-2-dou_liy...@163.com

---
 arch/x86/kernel/apic/vector.c |  9 -
 include/linux/irq.h   |  3 ++-
 kernel/irq/matrix.c   | 17 ++---
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 7654febd5102..652e7ffa9b9d 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -313,14 +313,13 @@ assign_managed_vector(struct irq_data *irqd, const struct 
cpumask *dest)
struct apic_chip_data *apicd = apic_chip_data(irqd);
int vector, cpu;
 
-   cpumask_and(vector_searchmask, vector_searchmask, affmsk);
-   cpu = cpumask_first(vector_searchmask);
-   if (cpu >= nr_cpu_ids)
-   return -EINVAL;
+   cpumask_and(vector_searchmask, dest, affmsk);
+
/* set_affinity might call here for nothing */
if (apicd->vector && cpumask_test_cpu(apicd->cpu, vector_searchmask))
return 0;
-   vector = irq_matrix_alloc_managed(vector_matrix, cpu);
+   vector = irq_matrix_alloc_managed(vector_matrix, vector_searchmask,
+ );
trace_vector_alloc_managed(irqd->irq, vector, vector);
if (vector < 0)
return vector;
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 201de12a9957..c9bffda04a45 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1151,7 +1151,8 @@ void irq_matrix_offline(struct irq_matrix *m);
 void irq_matrix_assign_system(struct irq_matrix *m, unsigned int bit, bool 
replace);
 int irq_matrix_reserve_managed(struct irq_matrix *m, const struct cpumask 
*msk);
 void irq_matrix_remove_managed(struct irq_matrix *m, const struct cpumask 
*msk);
-int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu);
+int irq_matrix_alloc_managed(struct irq_matrix *m, const struct cpumask *msk,
+   unsigned int *mapped_cpu);
 void irq_matrix_reserve(struct irq_matrix *m);
 void irq_matrix_remove_reserved(struct irq_matrix *m);
 int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index 67768bbe736e..6e6d467f3dec 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -260,11 +260,21 @@ void irq_matrix_remove_managed(struct irq_matrix *m, 
const struct cpumask *msk)
  * @m: Matrix pointer
  * @cpu:   On which CPU the interrupt should be allocated
  */
-int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu)
+int irq_matrix_alloc_managed(struct irq_matrix *m, const struct cpumask *msk,
+unsigned int *mapped_cpu)
 {
-   struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
-   unsigned int bit, end = m->alloc_end;
+   unsigned int bit, cpu, end = m->alloc_end;
+   struct cpumap *cm;
+
+   if (cpumask_empty(msk))
+   return -EINVAL;
 
+   cpu = matrix_find_best_cpu(m, msk);
+   if (cpu == UINT_MAX)
+   return -ENOSPC;
+
+   cm = per_cpu_ptr(m->maps, cpu);
+   end = m->alloc_end;
/* Get managed bit which are not allocated */
bitmap_andnot(m->scratch_map, cm->managed_map, cm->alloc_map, end);
bit = find_first_bit(m->scratch_map, end);
@@ -273,6 +283,7 @@ int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned 
int cpu)
set_bit(bit, cm->alloc_map);
cm->allocated++;
m->total_allocated++;
+   *mapped_cpu = cpu;
trace_irq_matrix_alloc_managed(bit, cpu, m, cm);
return 

[tip:x86/apic] irq/matrix: Spread managed interrupts on allocation

2018-09-18 Thread tip-bot for Dou Liyang
Commit-ID:  76f99ae5b54d48430d1f0c5512a84da0ff9761e0
Gitweb: https://git.kernel.org/tip/76f99ae5b54d48430d1f0c5512a84da0ff9761e0
Author: Dou Liyang 
AuthorDate: Sun, 9 Sep 2018 01:58:38 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 18 Sep 2018 18:27:24 +0200

irq/matrix: Spread managed interrupts on allocation

Linux spreads out the non managed interrupt across the possible target CPUs
to avoid vector space exhaustion.

Managed interrupts are treated differently, as for them the vectors are
reserved (with guarantee) when the interrupt descriptors are initialized.

When the interrupt is requested a real vector is assigned. The assignment
logic uses the first CPU in the affinity mask for assignment. If the
interrupt has more than one CPU in the affinity mask, which happens when a
multi queue device has less queues than CPUs, then doing the same search as
for non managed interrupts makes sense as it puts the interrupt on the
least interrupt plagued CPU. For single CPU affine vectors that's obviously
a NOOP.

Restructre the matrix allocation code so it does the 'best CPU' search, add
the sanity check for an empty affinity mask and adapt the call site in the
x86 vector management code.

[ tglx: Added the empty mask check to the core and improved change log ]

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180908175838.14450-2-dou_liy...@163.com

---
 arch/x86/kernel/apic/vector.c |  9 -
 include/linux/irq.h   |  3 ++-
 kernel/irq/matrix.c   | 17 ++---
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 7654febd5102..652e7ffa9b9d 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -313,14 +313,13 @@ assign_managed_vector(struct irq_data *irqd, const struct 
cpumask *dest)
struct apic_chip_data *apicd = apic_chip_data(irqd);
int vector, cpu;
 
-   cpumask_and(vector_searchmask, vector_searchmask, affmsk);
-   cpu = cpumask_first(vector_searchmask);
-   if (cpu >= nr_cpu_ids)
-   return -EINVAL;
+   cpumask_and(vector_searchmask, dest, affmsk);
+
/* set_affinity might call here for nothing */
if (apicd->vector && cpumask_test_cpu(apicd->cpu, vector_searchmask))
return 0;
-   vector = irq_matrix_alloc_managed(vector_matrix, cpu);
+   vector = irq_matrix_alloc_managed(vector_matrix, vector_searchmask,
+ );
trace_vector_alloc_managed(irqd->irq, vector, vector);
if (vector < 0)
return vector;
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 201de12a9957..c9bffda04a45 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1151,7 +1151,8 @@ void irq_matrix_offline(struct irq_matrix *m);
 void irq_matrix_assign_system(struct irq_matrix *m, unsigned int bit, bool 
replace);
 int irq_matrix_reserve_managed(struct irq_matrix *m, const struct cpumask 
*msk);
 void irq_matrix_remove_managed(struct irq_matrix *m, const struct cpumask 
*msk);
-int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu);
+int irq_matrix_alloc_managed(struct irq_matrix *m, const struct cpumask *msk,
+   unsigned int *mapped_cpu);
 void irq_matrix_reserve(struct irq_matrix *m);
 void irq_matrix_remove_reserved(struct irq_matrix *m);
 int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index 67768bbe736e..6e6d467f3dec 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -260,11 +260,21 @@ void irq_matrix_remove_managed(struct irq_matrix *m, 
const struct cpumask *msk)
  * @m: Matrix pointer
  * @cpu:   On which CPU the interrupt should be allocated
  */
-int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu)
+int irq_matrix_alloc_managed(struct irq_matrix *m, const struct cpumask *msk,
+unsigned int *mapped_cpu)
 {
-   struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
-   unsigned int bit, end = m->alloc_end;
+   unsigned int bit, cpu, end = m->alloc_end;
+   struct cpumap *cm;
+
+   if (cpumask_empty(msk))
+   return -EINVAL;
 
+   cpu = matrix_find_best_cpu(m, msk);
+   if (cpu == UINT_MAX)
+   return -ENOSPC;
+
+   cm = per_cpu_ptr(m->maps, cpu);
+   end = m->alloc_end;
/* Get managed bit which are not allocated */
bitmap_andnot(m->scratch_map, cm->managed_map, cm->alloc_map, end);
bit = find_first_bit(m->scratch_map, end);
@@ -273,6 +283,7 @@ int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned 
int cpu)
set_bit(bit, cm->alloc_map);
cm->allocated++;
m->total_allocated++;
+   *mapped_cpu = cpu;
trace_irq_matrix_alloc_managed(bit, cpu, m, cm);
return 

[tip:x86/apic] irq/matrix: Split out the CPU selection code into a helper

2018-09-18 Thread tip-bot for Dou Liyang
Commit-ID:  8ffe4e61c06a48324cfd97f1199bb9838acce2f2
Gitweb: https://git.kernel.org/tip/8ffe4e61c06a48324cfd97f1199bb9838acce2f2
Author: Dou Liyang 
AuthorDate: Sun, 9 Sep 2018 01:58:37 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 18 Sep 2018 18:27:24 +0200

irq/matrix: Split out the CPU selection code into a helper

Linux finds the CPU which has the lowest vector allocation count to spread
out the non managed interrupts across the possible target CPUs, but does
not do so for managed interrupts.

Split out the CPU selection code into a helper function for reuse. No
functional change.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180908175838.14450-1-dou_liy...@163.com

---
 kernel/irq/matrix.c | 65 +++--
 1 file changed, 38 insertions(+), 27 deletions(-)

diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index 5092494bf261..67768bbe736e 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -124,6 +124,27 @@ static unsigned int matrix_alloc_area(struct irq_matrix 
*m, struct cpumap *cm,
return area;
 }
 
+/* Find the best CPU which has the lowest vector allocation count */
+static unsigned int matrix_find_best_cpu(struct irq_matrix *m,
+   const struct cpumask *msk)
+{
+   unsigned int cpu, best_cpu, maxavl = 0;
+   struct cpumap *cm;
+
+   best_cpu = UINT_MAX;
+
+   for_each_cpu(cpu, msk) {
+   cm = per_cpu_ptr(m->maps, cpu);
+
+   if (!cm->online || cm->available <= maxavl)
+   continue;
+
+   best_cpu = cpu;
+   maxavl = cm->available;
+   }
+   return best_cpu;
+}
+
 /**
  * irq_matrix_assign_system - Assign system wide entry in the matrix
  * @m: Matrix pointer
@@ -322,37 +343,27 @@ void irq_matrix_remove_reserved(struct irq_matrix *m)
 int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
 bool reserved, unsigned int *mapped_cpu)
 {
-   unsigned int cpu, best_cpu, maxavl = 0;
+   unsigned int cpu, bit;
struct cpumap *cm;
-   unsigned int bit;
 
-   best_cpu = UINT_MAX;
-   for_each_cpu(cpu, msk) {
-   cm = per_cpu_ptr(m->maps, cpu);
-
-   if (!cm->online || cm->available <= maxavl)
-   continue;
+   cpu = matrix_find_best_cpu(m, msk);
+   if (cpu == UINT_MAX)
+   return -ENOSPC;
 
-   best_cpu = cpu;
-   maxavl = cm->available;
-   }
+   cm = per_cpu_ptr(m->maps, cpu);
+   bit = matrix_alloc_area(m, cm, 1, false);
+   if (bit >= m->alloc_end)
+   return -ENOSPC;
+   cm->allocated++;
+   cm->available--;
+   m->total_allocated++;
+   m->global_available--;
+   if (reserved)
+   m->global_reserved--;
+   *mapped_cpu = cpu;
+   trace_irq_matrix_alloc(bit, cpu, m, cm);
+   return bit;
 
-   if (maxavl) {
-   cm = per_cpu_ptr(m->maps, best_cpu);
-   bit = matrix_alloc_area(m, cm, 1, false);
-   if (bit < m->alloc_end) {
-   cm->allocated++;
-   cm->available--;
-   m->total_allocated++;
-   m->global_available--;
-   if (reserved)
-   m->global_reserved--;
-   *mapped_cpu = best_cpu;
-   trace_irq_matrix_alloc(bit, best_cpu, m, cm);
-   return bit;
-   }
-   }
-   return -ENOSPC;
 }
 
 /**


[tip:x86/apic] irq/matrix: Split out the CPU selection code into a helper

2018-09-18 Thread tip-bot for Dou Liyang
Commit-ID:  8ffe4e61c06a48324cfd97f1199bb9838acce2f2
Gitweb: https://git.kernel.org/tip/8ffe4e61c06a48324cfd97f1199bb9838acce2f2
Author: Dou Liyang 
AuthorDate: Sun, 9 Sep 2018 01:58:37 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 18 Sep 2018 18:27:24 +0200

irq/matrix: Split out the CPU selection code into a helper

Linux finds the CPU which has the lowest vector allocation count to spread
out the non managed interrupts across the possible target CPUs, but does
not do so for managed interrupts.

Split out the CPU selection code into a helper function for reuse. No
functional change.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180908175838.14450-1-dou_liy...@163.com

---
 kernel/irq/matrix.c | 65 +++--
 1 file changed, 38 insertions(+), 27 deletions(-)

diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index 5092494bf261..67768bbe736e 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -124,6 +124,27 @@ static unsigned int matrix_alloc_area(struct irq_matrix 
*m, struct cpumap *cm,
return area;
 }
 
+/* Find the best CPU which has the lowest vector allocation count */
+static unsigned int matrix_find_best_cpu(struct irq_matrix *m,
+   const struct cpumask *msk)
+{
+   unsigned int cpu, best_cpu, maxavl = 0;
+   struct cpumap *cm;
+
+   best_cpu = UINT_MAX;
+
+   for_each_cpu(cpu, msk) {
+   cm = per_cpu_ptr(m->maps, cpu);
+
+   if (!cm->online || cm->available <= maxavl)
+   continue;
+
+   best_cpu = cpu;
+   maxavl = cm->available;
+   }
+   return best_cpu;
+}
+
 /**
  * irq_matrix_assign_system - Assign system wide entry in the matrix
  * @m: Matrix pointer
@@ -322,37 +343,27 @@ void irq_matrix_remove_reserved(struct irq_matrix *m)
 int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
 bool reserved, unsigned int *mapped_cpu)
 {
-   unsigned int cpu, best_cpu, maxavl = 0;
+   unsigned int cpu, bit;
struct cpumap *cm;
-   unsigned int bit;
 
-   best_cpu = UINT_MAX;
-   for_each_cpu(cpu, msk) {
-   cm = per_cpu_ptr(m->maps, cpu);
-
-   if (!cm->online || cm->available <= maxavl)
-   continue;
+   cpu = matrix_find_best_cpu(m, msk);
+   if (cpu == UINT_MAX)
+   return -ENOSPC;
 
-   best_cpu = cpu;
-   maxavl = cm->available;
-   }
+   cm = per_cpu_ptr(m->maps, cpu);
+   bit = matrix_alloc_area(m, cm, 1, false);
+   if (bit >= m->alloc_end)
+   return -ENOSPC;
+   cm->allocated++;
+   cm->available--;
+   m->total_allocated++;
+   m->global_available--;
+   if (reserved)
+   m->global_reserved--;
+   *mapped_cpu = cpu;
+   trace_irq_matrix_alloc(bit, cpu, m, cm);
+   return bit;
 
-   if (maxavl) {
-   cm = per_cpu_ptr(m->maps, best_cpu);
-   bit = matrix_alloc_area(m, cm, 1, false);
-   if (bit < m->alloc_end) {
-   cm->allocated++;
-   cm->available--;
-   m->total_allocated++;
-   m->global_available--;
-   if (reserved)
-   m->global_reserved--;
-   *mapped_cpu = best_cpu;
-   trace_irq_matrix_alloc(bit, best_cpu, m, cm);
-   return bit;
-   }
-   }
-   return -ENOSPC;
 }
 
 /**


[tip:x86/platform] x86/platform/UV: Mark memblock related init code and data correctly

2018-07-30 Thread tip-bot for Dou Liyang
Commit-ID:  24cfd8ca1d28331b9dad3b88d1958c976b2cfab6
Gitweb: https://git.kernel.org/tip/24cfd8ca1d28331b9dad3b88d1958c976b2cfab6
Author: Dou Liyang 
AuthorDate: Mon, 30 Jul 2018 15:59:47 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 30 Jul 2018 19:53:58 +0200

x86/platform/UV: Mark memblock related init code and data correctly

parse_mem_block_size() and mem_block_size are only used during init. Mark
them accordingly.

Fixes: d7609f4210cb ("x86/platform/UV: Add kernel parameter to set memory block 
size")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Cc: Mike Travis 
Cc: Andrew Banman 
Link: https://lkml.kernel.org/r/20180730075947.23023-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/x2apic_uv_x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c 
b/arch/x86/kernel/apic/x2apic_uv_x.c
index d492752f79e1..391f358ebb4c 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -394,10 +394,10 @@ extern int uv_hub_info_version(void)
 EXPORT_SYMBOL(uv_hub_info_version);
 
 /* Default UV memory block size is 2GB */
-static unsigned long mem_block_size = (2UL << 30);
+static unsigned long mem_block_size __initdata = (2UL << 30);
 
 /* Kernel parameter to specify UV mem block size */
-static int parse_mem_block_size(char *ptr)
+static int __init parse_mem_block_size(char *ptr)
 {
unsigned long size = memparse(ptr, NULL);
 


[tip:x86/platform] x86/platform/UV: Mark memblock related init code and data correctly

2018-07-30 Thread tip-bot for Dou Liyang
Commit-ID:  24cfd8ca1d28331b9dad3b88d1958c976b2cfab6
Gitweb: https://git.kernel.org/tip/24cfd8ca1d28331b9dad3b88d1958c976b2cfab6
Author: Dou Liyang 
AuthorDate: Mon, 30 Jul 2018 15:59:47 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 30 Jul 2018 19:53:58 +0200

x86/platform/UV: Mark memblock related init code and data correctly

parse_mem_block_size() and mem_block_size are only used during init. Mark
them accordingly.

Fixes: d7609f4210cb ("x86/platform/UV: Add kernel parameter to set memory block 
size")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Cc: Mike Travis 
Cc: Andrew Banman 
Link: https://lkml.kernel.org/r/20180730075947.23023-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/x2apic_uv_x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c 
b/arch/x86/kernel/apic/x2apic_uv_x.c
index d492752f79e1..391f358ebb4c 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -394,10 +394,10 @@ extern int uv_hub_info_version(void)
 EXPORT_SYMBOL(uv_hub_info_version);
 
 /* Default UV memory block size is 2GB */
-static unsigned long mem_block_size = (2UL << 30);
+static unsigned long mem_block_size __initdata = (2UL << 30);
 
 /* Kernel parameter to specify UV mem block size */
-static int parse_mem_block_size(char *ptr)
+static int __init parse_mem_block_size(char *ptr)
 {
unsigned long size = memparse(ptr, NULL);
 


[tip:x86/timers] x86/tsc: Consolidate init code

2018-07-30 Thread tip-bot for Dou Liyang
Commit-ID:  608008a45798fe9e2aee04f99b5270ea57c1376f
Gitweb: https://git.kernel.org/tip/608008a45798fe9e2aee04f99b5270ea57c1376f
Author: Dou Liyang 
AuthorDate: Mon, 30 Jul 2018 15:54:20 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 30 Jul 2018 19:33:35 +0200

x86/tsc: Consolidate init code

Split out suplicated code from tsc_early_init() and tsc_init() into a
common helper and fixup some comment typos.

[ tglx: Massaged changelog and renamed function ]

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Pavel Tatashin 
Cc: 
Cc: Peter Zijlstra 
Cc: "H. Peter Anvin" 
Link: https://lkml.kernel.org/r/20180730075421.22830-2-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/tsc.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 02e416b87ac1..1463468ba9a0 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -182,7 +182,7 @@ static void __init cyc2ns_init_boot_cpu(void)
 }
 
 /*
- * Secondary CPUs do not run through cyc2ns_init(), so set up
+ * Secondary CPUs do not run through tsc_init(), so set up
  * all the scale factors for all CPUs, assuming the same
  * speed as the bootup CPU. (cpufreq notifiers will fix this
  * up if their speed diverges)
@@ -1389,7 +1389,7 @@ static bool __init determine_cpu_tsc_frequencies(bool 
early)
}
 
/*
-* Trust non-zero tsc_khz as authorative,
+* Trust non-zero tsc_khz as authoritative,
 * and use it to sanity check cpu_khz,
 * which will be off if system timer is off.
 */
@@ -1421,6 +1421,14 @@ static unsigned long __init get_loops_per_jiffy(void)
return lpj;
 }
 
+static void __init tsc_enable_sched_clock(void)
+{
+   /* Sanitize TSC ADJUST before cyc2ns gets initialized */
+   tsc_store_and_check_tsc_adjust(true);
+   cyc2ns_init_boot_cpu();
+   static_branch_enable(&__use_tsc);
+}
+
 void __init tsc_early_init(void)
 {
if (!boot_cpu_has(X86_FEATURE_TSC))
@@ -1429,10 +1437,7 @@ void __init tsc_early_init(void)
return;
loops_per_jiffy = get_loops_per_jiffy();
 
-   /* Sanitize TSC ADJUST before cyc2ns gets initialized */
-   tsc_store_and_check_tsc_adjust(true);
-   cyc2ns_init_boot_cpu();
-   static_branch_enable(&__use_tsc);
+   tsc_enable_sched_clock();
 }
 
 void __init tsc_init(void)
@@ -1456,13 +1461,10 @@ void __init tsc_init(void)
setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
return;
}
-   /* Sanitize TSC ADJUST before cyc2ns gets initialized */
-   tsc_store_and_check_tsc_adjust(true);
-   cyc2ns_init_boot_cpu();
+   tsc_enable_sched_clock();
}
 
cyc2ns_init_secondary_cpus();
-   static_branch_enable(&__use_tsc);
 
if (!no_sched_irq_time)
enable_sched_clock_irqtime();


[tip:x86/timers] x86/tsc: Consolidate init code

2018-07-30 Thread tip-bot for Dou Liyang
Commit-ID:  608008a45798fe9e2aee04f99b5270ea57c1376f
Gitweb: https://git.kernel.org/tip/608008a45798fe9e2aee04f99b5270ea57c1376f
Author: Dou Liyang 
AuthorDate: Mon, 30 Jul 2018 15:54:20 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 30 Jul 2018 19:33:35 +0200

x86/tsc: Consolidate init code

Split out suplicated code from tsc_early_init() and tsc_init() into a
common helper and fixup some comment typos.

[ tglx: Massaged changelog and renamed function ]

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Pavel Tatashin 
Cc: 
Cc: Peter Zijlstra 
Cc: "H. Peter Anvin" 
Link: https://lkml.kernel.org/r/20180730075421.22830-2-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/tsc.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 02e416b87ac1..1463468ba9a0 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -182,7 +182,7 @@ static void __init cyc2ns_init_boot_cpu(void)
 }
 
 /*
- * Secondary CPUs do not run through cyc2ns_init(), so set up
+ * Secondary CPUs do not run through tsc_init(), so set up
  * all the scale factors for all CPUs, assuming the same
  * speed as the bootup CPU. (cpufreq notifiers will fix this
  * up if their speed diverges)
@@ -1389,7 +1389,7 @@ static bool __init determine_cpu_tsc_frequencies(bool 
early)
}
 
/*
-* Trust non-zero tsc_khz as authorative,
+* Trust non-zero tsc_khz as authoritative,
 * and use it to sanity check cpu_khz,
 * which will be off if system timer is off.
 */
@@ -1421,6 +1421,14 @@ static unsigned long __init get_loops_per_jiffy(void)
return lpj;
 }
 
+static void __init tsc_enable_sched_clock(void)
+{
+   /* Sanitize TSC ADJUST before cyc2ns gets initialized */
+   tsc_store_and_check_tsc_adjust(true);
+   cyc2ns_init_boot_cpu();
+   static_branch_enable(&__use_tsc);
+}
+
 void __init tsc_early_init(void)
 {
if (!boot_cpu_has(X86_FEATURE_TSC))
@@ -1429,10 +1437,7 @@ void __init tsc_early_init(void)
return;
loops_per_jiffy = get_loops_per_jiffy();
 
-   /* Sanitize TSC ADJUST before cyc2ns gets initialized */
-   tsc_store_and_check_tsc_adjust(true);
-   cyc2ns_init_boot_cpu();
-   static_branch_enable(&__use_tsc);
+   tsc_enable_sched_clock();
 }
 
 void __init tsc_init(void)
@@ -1456,13 +1461,10 @@ void __init tsc_init(void)
setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
return;
}
-   /* Sanitize TSC ADJUST before cyc2ns gets initialized */
-   tsc_store_and_check_tsc_adjust(true);
-   cyc2ns_init_boot_cpu();
+   tsc_enable_sched_clock();
}
 
cyc2ns_init_secondary_cpus();
-   static_branch_enable(&__use_tsc);
 
if (!no_sched_irq_time)
enable_sched_clock_irqtime();


[tip:x86/timers] x86/kvmclock: Mark kvm_get_preset_lpj() as __init

2018-07-30 Thread tip-bot for Dou Liyang
Commit-ID:  1088c6eef261939bda8346ec35b513790a2111d5
Gitweb: https://git.kernel.org/tip/1088c6eef261939bda8346ec35b513790a2111d5
Author: Dou Liyang 
AuthorDate: Mon, 30 Jul 2018 15:54:21 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 30 Jul 2018 19:33:35 +0200

x86/kvmclock: Mark kvm_get_preset_lpj() as __init

kvm_get_preset_lpj() is only called from kvmclock_init(), so mark it __init
as well.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Pavel Tatashin 
Cc: 
Cc: Paolo Bonzini 
Cc:   Radim Krčmář
Cc:  
Cc: "H. Peter Anvin" 
Cc: "Radim Krčmář" 
Cc: k...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180730075421.22830-3-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/kvmclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 91b94c0ae4e3..d2edd7e6c294 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -145,7 +145,7 @@ static unsigned long kvm_get_tsc_khz(void)
return pvclock_tsc_khz(this_cpu_pvti());
 }
 
-static void kvm_get_preset_lpj(void)
+static void __init kvm_get_preset_lpj(void)
 {
unsigned long khz;
u64 lpj;


[tip:x86/timers] x86/kvmclock: Mark kvm_get_preset_lpj() as __init

2018-07-30 Thread tip-bot for Dou Liyang
Commit-ID:  1088c6eef261939bda8346ec35b513790a2111d5
Gitweb: https://git.kernel.org/tip/1088c6eef261939bda8346ec35b513790a2111d5
Author: Dou Liyang 
AuthorDate: Mon, 30 Jul 2018 15:54:21 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 30 Jul 2018 19:33:35 +0200

x86/kvmclock: Mark kvm_get_preset_lpj() as __init

kvm_get_preset_lpj() is only called from kvmclock_init(), so mark it __init
as well.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Pavel Tatashin 
Cc: 
Cc: Paolo Bonzini 
Cc:   Radim Krčmář
Cc:  
Cc: "H. Peter Anvin" 
Cc: "Radim Krčmář" 
Cc: k...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180730075421.22830-3-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/kvmclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 91b94c0ae4e3..d2edd7e6c294 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -145,7 +145,7 @@ static unsigned long kvm_get_tsc_khz(void)
return pvclock_tsc_khz(this_cpu_pvti());
 }
 
-static void kvm_get_preset_lpj(void)
+static void __init kvm_get_preset_lpj(void)
 {
unsigned long khz;
u64 lpj;


[tip:x86/urgent] x86/vector: Fix the args of vector_alloc tracepoint

2018-06-06 Thread tip-bot for Dou Liyang
Commit-ID:  838d76d63ec4eaeaa12bedfa50f261480f615200
Gitweb: https://git.kernel.org/tip/838d76d63ec4eaeaa12bedfa50f261480f615200
Author: Dou Liyang 
AuthorDate: Fri, 1 Jun 2018 14:50:31 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 6 Jun 2018 13:38:02 +0200

x86/vector: Fix the args of vector_alloc tracepoint

The vector_alloc tracepont reversed the reserved and ret aggs, that made
the trace print wrong. Exchange them.

Fixes: 8d1e3dca7de6 ("x86/vector: Add tracepoints for vector management")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180601065031.21872-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/trace/irq_vectors.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/trace/irq_vectors.h 
b/arch/x86/include/asm/trace/irq_vectors.h
index 22647a642e98..0af81b590a0c 100644
--- a/arch/x86/include/asm/trace/irq_vectors.h
+++ b/arch/x86/include/asm/trace/irq_vectors.h
@@ -236,7 +236,7 @@ TRACE_EVENT(vector_alloc,
TP_PROTO(unsigned int irq, unsigned int vector, bool reserved,
 int ret),
 
-   TP_ARGS(irq, vector, ret, reserved),
+   TP_ARGS(irq, vector, reserved, ret),
 
TP_STRUCT__entry(
__field(unsigned int,   irq )


[tip:x86/urgent] x86/vector: Fix the args of vector_alloc tracepoint

2018-06-06 Thread tip-bot for Dou Liyang
Commit-ID:  838d76d63ec4eaeaa12bedfa50f261480f615200
Gitweb: https://git.kernel.org/tip/838d76d63ec4eaeaa12bedfa50f261480f615200
Author: Dou Liyang 
AuthorDate: Fri, 1 Jun 2018 14:50:31 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 6 Jun 2018 13:38:02 +0200

x86/vector: Fix the args of vector_alloc tracepoint

The vector_alloc tracepont reversed the reserved and ret aggs, that made
the trace print wrong. Exchange them.

Fixes: 8d1e3dca7de6 ("x86/vector: Add tracepoints for vector management")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Cc: sta...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180601065031.21872-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/trace/irq_vectors.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/trace/irq_vectors.h 
b/arch/x86/include/asm/trace/irq_vectors.h
index 22647a642e98..0af81b590a0c 100644
--- a/arch/x86/include/asm/trace/irq_vectors.h
+++ b/arch/x86/include/asm/trace/irq_vectors.h
@@ -236,7 +236,7 @@ TRACE_EVENT(vector_alloc,
TP_PROTO(unsigned int irq, unsigned int vector, bool reserved,
 int ret),
 
-   TP_ARGS(irq, vector, ret, reserved),
+   TP_ARGS(irq, vector, reserved, ret),
 
TP_STRUCT__entry(
__field(unsigned int,   irq )


[tip:x86/urgent] x86/idt: Simplify the idt_setup_apic_and_irq_gates()

2018-06-06 Thread tip-bot for Dou Liyang
Commit-ID:  336628128826a9acb045571a960e32e4414ccb61
Gitweb: https://git.kernel.org/tip/336628128826a9acb045571a960e32e4414ccb61
Author: Dou Liyang 
AuthorDate: Wed, 23 May 2018 10:35:55 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 6 Jun 2018 13:38:01 +0200

x86/idt: Simplify the idt_setup_apic_and_irq_gates()

The idt_setup_apic_and_irq_gates() sets the gates from
FIRST_EXTERNAL_VECTOR up to FIRST_SYSTEM_VECTOR first. then secondly, from
FIRST_SYSTEM_VECTOR to NR_VECTORS, it takes both APIC=y and APIC=n into
account.

But for APIC=n, the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS, all
vectors has been set at the first step.

Simplify the second step, make it just work for APIC=y.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/20180523023555.2933-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/idt.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
index 2c3a1b4294eb..74383a3780dc 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -317,15 +317,12 @@ void __init idt_setup_apic_and_irq_gates(void)
set_intr_gate(i, entry);
}
 
-   for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
 #ifdef CONFIG_X86_LOCAL_APIC
+   for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
set_bit(i, system_vectors);
set_intr_gate(i, spurious_interrupt);
-#else
-   entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
-   set_intr_gate(i, entry);
-#endif
}
+#endif
 }
 
 /**


[tip:x86/urgent] x86/idt: Simplify the idt_setup_apic_and_irq_gates()

2018-06-06 Thread tip-bot for Dou Liyang
Commit-ID:  336628128826a9acb045571a960e32e4414ccb61
Gitweb: https://git.kernel.org/tip/336628128826a9acb045571a960e32e4414ccb61
Author: Dou Liyang 
AuthorDate: Wed, 23 May 2018 10:35:55 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 6 Jun 2018 13:38:01 +0200

x86/idt: Simplify the idt_setup_apic_and_irq_gates()

The idt_setup_apic_and_irq_gates() sets the gates from
FIRST_EXTERNAL_VECTOR up to FIRST_SYSTEM_VECTOR first. then secondly, from
FIRST_SYSTEM_VECTOR to NR_VECTORS, it takes both APIC=y and APIC=n into
account.

But for APIC=n, the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS, all
vectors has been set at the first step.

Simplify the second step, make it just work for APIC=y.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/20180523023555.2933-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/idt.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
index 2c3a1b4294eb..74383a3780dc 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -317,15 +317,12 @@ void __init idt_setup_apic_and_irq_gates(void)
set_intr_gate(i, entry);
}
 
-   for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
 #ifdef CONFIG_X86_LOCAL_APIC
+   for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
set_bit(i, system_vectors);
set_intr_gate(i, spurious_interrupt);
-#else
-   entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
-   set_intr_gate(i, entry);
-#endif
}
+#endif
 }
 
 /**


[tip:x86/apic] x86/vector: Merge allocate_vector() into assign_vector_locked()

2018-05-19 Thread tip-bot for Dou Liyang
Commit-ID:  2773397171ac4b6e794ba0b3e34c06cbaf29897a
Gitweb: https://git.kernel.org/tip/2773397171ac4b6e794ba0b3e34c06cbaf29897a
Author: Dou Liyang 
AuthorDate: Fri, 11 May 2018 16:09:56 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 19 May 2018 15:09:11 +0200

x86/vector: Merge allocate_vector() into assign_vector_locked()

assign_vector_locked() calls allocate_vector() to get a real vector for an
IRQ. If the current target CPU is online and in the new requested affinity
mask, allocate_vector() will return 0 and nothing should be done. But,
assign_vector_locked() calls apic_update_irq_cfg() even in that case which
is pointless.

allocate_vector() is not called from anything else, so the functions can be
merged and in case of no change the apic_update_irq_cfg() can be avoided.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180511080956.6316-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/vector.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index bb6f7a2148d7..a75de0792942 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -218,7 +218,8 @@ static int reserve_irq_vector(struct irq_data *irqd)
return 0;
 }
 
-static int allocate_vector(struct irq_data *irqd, const struct cpumask *dest)
+static int
+assign_vector_locked(struct irq_data *irqd, const struct cpumask *dest)
 {
struct apic_chip_data *apicd = apic_chip_data(irqd);
bool resvd = apicd->has_reserved;
@@ -236,22 +237,12 @@ static int allocate_vector(struct irq_data *irqd, const 
struct cpumask *dest)
return 0;
 
vector = irq_matrix_alloc(vector_matrix, dest, resvd, );
-   if (vector > 0)
-   apic_update_vector(irqd, vector, cpu);
trace_vector_alloc(irqd->irq, vector, resvd, vector);
-   return vector;
-}
-
-static int assign_vector_locked(struct irq_data *irqd,
-   const struct cpumask *dest)
-{
-   struct apic_chip_data *apicd = apic_chip_data(irqd);
-   int vector = allocate_vector(irqd, dest);
-
if (vector < 0)
return vector;
+   apic_update_vector(irqd, vector, cpu);
+   apic_update_irq_cfg(irqd, vector, cpu);
 
-   apic_update_irq_cfg(irqd, apicd->vector, apicd->cpu);
return 0;
 }
 


[tip:x86/apic] x86/vector: Merge allocate_vector() into assign_vector_locked()

2018-05-19 Thread tip-bot for Dou Liyang
Commit-ID:  2773397171ac4b6e794ba0b3e34c06cbaf29897a
Gitweb: https://git.kernel.org/tip/2773397171ac4b6e794ba0b3e34c06cbaf29897a
Author: Dou Liyang 
AuthorDate: Fri, 11 May 2018 16:09:56 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 19 May 2018 15:09:11 +0200

x86/vector: Merge allocate_vector() into assign_vector_locked()

assign_vector_locked() calls allocate_vector() to get a real vector for an
IRQ. If the current target CPU is online and in the new requested affinity
mask, allocate_vector() will return 0 and nothing should be done. But,
assign_vector_locked() calls apic_update_irq_cfg() even in that case which
is pointless.

allocate_vector() is not called from anything else, so the functions can be
merged and in case of no change the apic_update_irq_cfg() can be avoided.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180511080956.6316-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/vector.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index bb6f7a2148d7..a75de0792942 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -218,7 +218,8 @@ static int reserve_irq_vector(struct irq_data *irqd)
return 0;
 }
 
-static int allocate_vector(struct irq_data *irqd, const struct cpumask *dest)
+static int
+assign_vector_locked(struct irq_data *irqd, const struct cpumask *dest)
 {
struct apic_chip_data *apicd = apic_chip_data(irqd);
bool resvd = apicd->has_reserved;
@@ -236,22 +237,12 @@ static int allocate_vector(struct irq_data *irqd, const 
struct cpumask *dest)
return 0;
 
vector = irq_matrix_alloc(vector_matrix, dest, resvd, );
-   if (vector > 0)
-   apic_update_vector(irqd, vector, cpu);
trace_vector_alloc(irqd->irq, vector, resvd, vector);
-   return vector;
-}
-
-static int assign_vector_locked(struct irq_data *irqd,
-   const struct cpumask *dest)
-{
-   struct apic_chip_data *apicd = apic_chip_data(irqd);
-   int vector = allocate_vector(irqd, dest);
-
if (vector < 0)
return vector;
+   apic_update_vector(irqd, vector, cpu);
+   apic_update_irq_cfg(irqd, vector, cpu);
 
-   apic_update_irq_cfg(irqd, apicd->vector, apicd->cpu);
return 0;
 }
 


[tip:x86/urgent] x86/vector: Remove the unused macro FPU_IRQ

2018-04-26 Thread tip-bot for Dou Liyang
Commit-ID:  7d878817db22f64c2b2c241335ec03e4c3fd5476
Gitweb: https://git.kernel.org/tip/7d878817db22f64c2b2c241335ec03e4c3fd5476
Author: Dou Liyang 
AuthorDate: Thu, 26 Apr 2018 14:08:32 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 26 Apr 2018 11:57:57 +0200

x86/vector: Remove the unused macro FPU_IRQ

The macro FPU_IRQ has never been used since v3.10, So remove it.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180426060832.27312-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/irq_vectors.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 57003074bd7a..548d90bbf919 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -114,8 +114,6 @@
 #define FIRST_SYSTEM_VECTORNR_VECTORS
 #endif
 
-#define FPU_IRQ  13
-
 /*
  * Size the maximum number of interrupts.
  *


[tip:x86/urgent] x86/vector: Remove the unused macro FPU_IRQ

2018-04-26 Thread tip-bot for Dou Liyang
Commit-ID:  7d878817db22f64c2b2c241335ec03e4c3fd5476
Gitweb: https://git.kernel.org/tip/7d878817db22f64c2b2c241335ec03e4c3fd5476
Author: Dou Liyang 
AuthorDate: Thu, 26 Apr 2018 14:08:32 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 26 Apr 2018 11:57:57 +0200

x86/vector: Remove the unused macro FPU_IRQ

The macro FPU_IRQ has never been used since v3.10, So remove it.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180426060832.27312-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/irq_vectors.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 57003074bd7a..548d90bbf919 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -114,8 +114,6 @@
 #define FIRST_SYSTEM_VECTORNR_VECTORS
 #endif
 
-#define FPU_IRQ  13
-
 /*
  * Size the maximum number of interrupts.
  *


[tip:x86/urgent] x86/vector: Remove the macro VECTOR_OFFSET_START

2018-04-25 Thread tip-bot for Dou Liyang
Commit-ID:  e3072805c61167b85a30ceeef606620704db31f7
Gitweb: https://git.kernel.org/tip/e3072805c61167b85a30ceeef606620704db31f7
Author: Dou Liyang 
AuthorDate: Wed, 25 Apr 2018 10:05:53 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 26 Apr 2018 07:31:17 +0200

x86/vector: Remove the macro VECTOR_OFFSET_START

Now, Linux uses matrix allocator for vector assignment, the original
assignment code which used VECTOR_OFFSET_START has been removed.

So remove the stale macro as well.

Fixes: commit 69cde0004a4b ("x86/vector: Use matrix allocator for vector 
assignment")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Acked-by: David Rientjes 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180425020553.17210-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/irq_vectors.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 404c5fdff859..57003074bd7a 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -34,11 +34,6 @@
  * (0x80 is the syscall vector, 0x30-0x3f are for ISA)
  */
 #define FIRST_EXTERNAL_VECTOR  0x20
-/*
- * We start allocating at 0x21 to spread out vectors evenly between
- * priority levels. (0x80 is the syscall vector)
- */
-#define VECTOR_OFFSET_START1
 
 /*
  * Reserve the lowest usable vector (and hence lowest priority)  0x20 for


[tip:x86/urgent] x86/vector: Remove the macro VECTOR_OFFSET_START

2018-04-25 Thread tip-bot for Dou Liyang
Commit-ID:  e3072805c61167b85a30ceeef606620704db31f7
Gitweb: https://git.kernel.org/tip/e3072805c61167b85a30ceeef606620704db31f7
Author: Dou Liyang 
AuthorDate: Wed, 25 Apr 2018 10:05:53 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 26 Apr 2018 07:31:17 +0200

x86/vector: Remove the macro VECTOR_OFFSET_START

Now, Linux uses matrix allocator for vector assignment, the original
assignment code which used VECTOR_OFFSET_START has been removed.

So remove the stale macro as well.

Fixes: commit 69cde0004a4b ("x86/vector: Use matrix allocator for vector 
assignment")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Acked-by: David Rientjes 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180425020553.17210-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/irq_vectors.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 404c5fdff859..57003074bd7a 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -34,11 +34,6 @@
  * (0x80 is the syscall vector, 0x30-0x3f are for ISA)
  */
 #define FIRST_EXTERNAL_VECTOR  0x20
-/*
- * We start allocating at 0x21 to spread out vectors evenly between
- * priority levels. (0x80 is the syscall vector)
- */
-#define VECTOR_OFFSET_START1
 
 /*
  * Reserve the lowest usable vector (and hence lowest priority)  0x20 for


[tip:x86/urgent] x86/vector: Remove the macro VECTOR_OFFSET_START

2018-04-25 Thread tip-bot for Dou Liyang
Commit-ID:  5a626a8dfb58a64a39f4351e3962e7320191f189
Gitweb: https://git.kernel.org/tip/5a626a8dfb58a64a39f4351e3962e7320191f189
Author: Dou Liyang 
AuthorDate: Wed, 25 Apr 2018 10:05:53 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 25 Apr 2018 10:56:24 +0200

x86/vector: Remove the macro VECTOR_OFFSET_START

Now, Linux uses matrix allocator for vector assignment, the original
assignment code which used VECTOR_OFFSET_START has been removed.

So remove the stale macro as well.

Fixes: commit 69cde0004a4b ("x86/vector: Use matrix allocator for vector 
assignment")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Acked-by: David Rientjes 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180425020553.17210-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/irq_vectors.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 404c5fdff859..57003074bd7a 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -34,11 +34,6 @@
  * (0x80 is the syscall vector, 0x30-0x3f are for ISA)
  */
 #define FIRST_EXTERNAL_VECTOR  0x20
-/*
- * We start allocating at 0x21 to spread out vectors evenly between
- * priority levels. (0x80 is the syscall vector)
- */
-#define VECTOR_OFFSET_START1
 
 /*
  * Reserve the lowest usable vector (and hence lowest priority)  0x20 for


[tip:x86/urgent] x86/vector: Remove the macro VECTOR_OFFSET_START

2018-04-25 Thread tip-bot for Dou Liyang
Commit-ID:  5a626a8dfb58a64a39f4351e3962e7320191f189
Gitweb: https://git.kernel.org/tip/5a626a8dfb58a64a39f4351e3962e7320191f189
Author: Dou Liyang 
AuthorDate: Wed, 25 Apr 2018 10:05:53 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 25 Apr 2018 10:56:24 +0200

x86/vector: Remove the macro VECTOR_OFFSET_START

Now, Linux uses matrix allocator for vector assignment, the original
assignment code which used VECTOR_OFFSET_START has been removed.

So remove the stale macro as well.

Fixes: commit 69cde0004a4b ("x86/vector: Use matrix allocator for vector 
assignment")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Acked-by: David Rientjes 
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180425020553.17210-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/irq_vectors.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h 
b/arch/x86/include/asm/irq_vectors.h
index 404c5fdff859..57003074bd7a 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -34,11 +34,6 @@
  * (0x80 is the syscall vector, 0x30-0x3f are for ISA)
  */
 #define FIRST_EXTERNAL_VECTOR  0x20
-/*
- * We start allocating at 0x21 to spread out vectors evenly between
- * priority levels. (0x80 is the syscall vector)
- */
-#define VECTOR_OFFSET_START1
 
 /*
  * Reserve the lowest usable vector (and hence lowest priority)  0x20 for


[tip:x86/urgent] x86/processor: Remove two unused function declarations

2018-04-17 Thread tip-bot for Dou Liyang
Commit-ID:  451cf3ca7d4615631443014ee769c25e267c25ff
Gitweb: https://git.kernel.org/tip/451cf3ca7d4615631443014ee769c25e267c25ff
Author: Dou Liyang 
AuthorDate: Wed, 4 Apr 2018 14:45:27 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 17 Apr 2018 11:56:32 +0200

x86/processor: Remove two unused function declarations

early_trap_init() and cpu_set_gdt() have been removed, so remove the stale
declarations as well.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: keesc...@chromium.org
Cc: l...@kernel.org
Cc: h...@zytor.com
Cc: b...@suse.de
Cc: kirill.shute...@linux.intel.com
Link: https://lkml.kernel.org/r/20180404064527.10562-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/processor.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4fa4206029e3..21a114914ba4 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -749,13 +749,11 @@ enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, 
IDLE_NOMWAIT,
 extern void enable_sep_cpu(void);
 extern int sysenter_setup(void);
 
-extern void early_trap_init(void);
 void early_trap_pf_init(void);
 
 /* Defined in head.S */
 extern struct desc_ptr early_gdt_descr;
 
-extern void cpu_set_gdt(int);
 extern void switch_to_new_gdt(int);
 extern void load_direct_gdt(int);
 extern void load_fixmap_gdt(int);


[tip:x86/urgent] x86/processor: Remove two unused function declarations

2018-04-17 Thread tip-bot for Dou Liyang
Commit-ID:  451cf3ca7d4615631443014ee769c25e267c25ff
Gitweb: https://git.kernel.org/tip/451cf3ca7d4615631443014ee769c25e267c25ff
Author: Dou Liyang 
AuthorDate: Wed, 4 Apr 2018 14:45:27 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 17 Apr 2018 11:56:32 +0200

x86/processor: Remove two unused function declarations

early_trap_init() and cpu_set_gdt() have been removed, so remove the stale
declarations as well.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: keesc...@chromium.org
Cc: l...@kernel.org
Cc: h...@zytor.com
Cc: b...@suse.de
Cc: kirill.shute...@linux.intel.com
Link: https://lkml.kernel.org/r/20180404064527.10562-1-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/processor.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4fa4206029e3..21a114914ba4 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -749,13 +749,11 @@ enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, 
IDLE_NOMWAIT,
 extern void enable_sep_cpu(void);
 extern int sysenter_setup(void);
 
-extern void early_trap_init(void);
 void early_trap_pf_init(void);
 
 /* Defined in head.S */
 extern struct desc_ptr early_gdt_descr;
 
-extern void cpu_set_gdt(int);
 extern void switch_to_new_gdt(int);
 extern void load_direct_gdt(int);
 extern void load_fixmap_gdt(int);


[tip:x86/urgent] x86/acpi: Prevent X2APIC id 0xffffffff from being accounted

2018-04-17 Thread tip-bot for Dou Liyang
Commit-ID:  10daf10ab154e31237a8c07242be3063fb6a9bf4
Gitweb: https://git.kernel.org/tip/10daf10ab154e31237a8c07242be3063fb6a9bf4
Author: Dou Liyang 
AuthorDate: Thu, 12 Apr 2018 09:40:52 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 17 Apr 2018 11:56:31 +0200

x86/acpi: Prevent X2APIC id 0x from being accounted

RongQing reported that there are some X2APIC id 0x in his machine's
ACPI MADT table, which makes the number of possible CPU inaccurate.

The reason is that the ACPI X2APIC parser has no sanity check for APIC ID
0x, which is an invalid id in all APIC types. See "Intel® 64
Architecture x2APIC Specification", Chapter 2.4.1.

Add a sanity check to acpi_parse_x2apic() which ignores the invalid id.

Reported-by: Li RongQing 
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Cc: len.br...@intel.com
Cc: r...@rjwysocki.net
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180412014052.25186-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/acpi/boot.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index dde444f932c1..3b20607d581b 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -215,6 +215,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, 
const unsigned long end)
apic_id = processor->local_apic_id;
enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
 
+   /* Ignore invalid ID */
+   if (apic_id == 0x)
+   return 0;
+
/*
 * We need to register disabled CPU as well to permit
 * counting disabled CPUs. This allows us to size


[tip:x86/urgent] x86/acpi: Prevent X2APIC id 0xffffffff from being accounted

2018-04-17 Thread tip-bot for Dou Liyang
Commit-ID:  10daf10ab154e31237a8c07242be3063fb6a9bf4
Gitweb: https://git.kernel.org/tip/10daf10ab154e31237a8c07242be3063fb6a9bf4
Author: Dou Liyang 
AuthorDate: Thu, 12 Apr 2018 09:40:52 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 17 Apr 2018 11:56:31 +0200

x86/acpi: Prevent X2APIC id 0x from being accounted

RongQing reported that there are some X2APIC id 0x in his machine's
ACPI MADT table, which makes the number of possible CPU inaccurate.

The reason is that the ACPI X2APIC parser has no sanity check for APIC ID
0x, which is an invalid id in all APIC types. See "Intel® 64
Architecture x2APIC Specification", Chapter 2.4.1.

Add a sanity check to acpi_parse_x2apic() which ignores the invalid id.

Reported-by: Li RongQing 
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Cc: len.br...@intel.com
Cc: r...@rjwysocki.net
Cc: h...@zytor.com
Link: https://lkml.kernel.org/r/20180412014052.25186-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/acpi/boot.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index dde444f932c1..3b20607d581b 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -215,6 +215,10 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, 
const unsigned long end)
apic_id = processor->local_apic_id;
enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
 
+   /* Ignore invalid ID */
+   if (apic_id == 0x)
+   return 0;
+
/*
 * We need to register disabled CPU as well to permit
 * counting disabled CPUs. This allows us to size


[tip:x86/apic] x86/apic: Drop logical_smp_processor_id() inline

2018-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  8f1561680f42a5491b371b513f1ab8197f31fd62
Gitweb: https://git.kernel.org/tip/8f1561680f42a5491b371b513f1ab8197f31fd62
Author: Dou Liyang 
AuthorDate: Thu, 1 Mar 2018 13:59:30 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 1 Mar 2018 10:12:21 +0100

x86/apic: Drop logical_smp_processor_id() inline

The logical_smp_processor_id() inline which is only called in
setup_local_APIC() on x86_32 systems has no real value.

Drop it and directly use GET_APIC_LOGICAL_ID() at the call site and use a
more suitable variable name for readability

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: andy.shevche...@gmail.com
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180301055930.2396-4-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/smp.h  | 10 --
 arch/x86/kernel/apic/apic.c | 10 +-
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 461f53d27708..e2057780d67f 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -176,16 +176,6 @@ static inline int wbinvd_on_all_cpus(void)
 extern unsigned disabled_cpus;
 
 #ifdef CONFIG_X86_LOCAL_APIC
-
-#ifndef CONFIG_X86_64
-static inline int logical_smp_processor_id(void)
-{
-   /* we don't want to mark this access volatile - bad code generation */
-   return GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
-}
-
-#endif
-
 extern int hard_smp_processor_id(void);
 
 #else /* CONFIG_X86_LOCAL_APIC */
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 7a347d7450b6..ce2066373922 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1468,7 +1468,7 @@ static void setup_local_APIC(void)
int cpu = smp_processor_id();
unsigned int value;
 #ifdef CONFIG_X86_32
-   int i;
+   int logical_apicid, ldr_apicid;
 #endif
 
 
@@ -1507,11 +1507,11 @@ static void setup_local_APIC(void)
 * initialized during get_smp_config(), make sure it matches the
 * actual value.
 */
-   i = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
-   WARN_ON(i != BAD_APICID && i != logical_smp_processor_id());
+   logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
+   ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
+   WARN_ON(logical_apicid != BAD_APICID && logical_apicid != ldr_apicid);
/* always use the value from LDR */
-   early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
-   logical_smp_processor_id();
+   early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid;
 #endif
 
/*


[tip:x86/apic] x86/apic: Drop logical_smp_processor_id() inline

2018-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  8f1561680f42a5491b371b513f1ab8197f31fd62
Gitweb: https://git.kernel.org/tip/8f1561680f42a5491b371b513f1ab8197f31fd62
Author: Dou Liyang 
AuthorDate: Thu, 1 Mar 2018 13:59:30 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 1 Mar 2018 10:12:21 +0100

x86/apic: Drop logical_smp_processor_id() inline

The logical_smp_processor_id() inline which is only called in
setup_local_APIC() on x86_32 systems has no real value.

Drop it and directly use GET_APIC_LOGICAL_ID() at the call site and use a
more suitable variable name for readability

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: andy.shevche...@gmail.com
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180301055930.2396-4-douly.f...@cn.fujitsu.com

---
 arch/x86/include/asm/smp.h  | 10 --
 arch/x86/kernel/apic/apic.c | 10 +-
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 461f53d27708..e2057780d67f 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -176,16 +176,6 @@ static inline int wbinvd_on_all_cpus(void)
 extern unsigned disabled_cpus;
 
 #ifdef CONFIG_X86_LOCAL_APIC
-
-#ifndef CONFIG_X86_64
-static inline int logical_smp_processor_id(void)
-{
-   /* we don't want to mark this access volatile - bad code generation */
-   return GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
-}
-
-#endif
-
 extern int hard_smp_processor_id(void);
 
 #else /* CONFIG_X86_LOCAL_APIC */
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 7a347d7450b6..ce2066373922 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1468,7 +1468,7 @@ static void setup_local_APIC(void)
int cpu = smp_processor_id();
unsigned int value;
 #ifdef CONFIG_X86_32
-   int i;
+   int logical_apicid, ldr_apicid;
 #endif
 
 
@@ -1507,11 +1507,11 @@ static void setup_local_APIC(void)
 * initialized during get_smp_config(), make sure it matches the
 * actual value.
 */
-   i = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
-   WARN_ON(i != BAD_APICID && i != logical_smp_processor_id());
+   logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
+   ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
+   WARN_ON(logical_apicid != BAD_APICID && logical_apicid != ldr_apicid);
/* always use the value from LDR */
-   early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
-   logical_smp_processor_id();
+   early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid;
 #endif
 
/*


[tip:x86/apic] x86/apic: Modernize the pending interrupt code

2018-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  3ea9e7ae1a2038b9fdff729861c9b4af0087024f
Gitweb: https://git.kernel.org/tip/3ea9e7ae1a2038b9fdff729861c9b4af0087024f
Author: Dou Liyang 
AuthorDate: Thu, 1 Mar 2018 13:59:29 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 1 Mar 2018 10:12:20 +0100

x86/apic: Modernize the pending interrupt code

The pending interrupt check code is old, update the following:

  - Use for_each_set_bit() instead of open coding it
  - Replace printk() with pr_err()
  - Get rid of printk line breaks
  - Make curly braces balanced

Suggested-by: Andy Shevchenko 
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180301055930.2396-3-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 69d2936e3154..7a347d7450b6 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1412,7 +1412,8 @@ static void apic_pending_intr_clear(void)
 {
long long max_loops = cpu_khz ? cpu_khz : 100;
unsigned long long tsc = 0, ntsc;
-   unsigned int value, queued;
+   unsigned int queued;
+   unsigned long value;
int i, j, acked = 0;
 
if (boot_cpu_has(X86_FEATURE_TSC))
@@ -1435,24 +1436,22 @@ static void apic_pending_intr_clear(void)
 
for (i = APIC_ISR_NR - 1; i >= 0; i--) {
value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
+   pr_err("LAPIC pending interrupts after %d EOI\n", 
acked);
break;
}
if (queued) {
if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
ntsc = rdtsc();
max_loops = (cpu_khz << 10) - (ntsc - tsc);
-   } else
+   } else {
max_loops--;
+   }
}
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);


[tip:x86/apic] x86/apic: Modernize the pending interrupt code

2018-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  3ea9e7ae1a2038b9fdff729861c9b4af0087024f
Gitweb: https://git.kernel.org/tip/3ea9e7ae1a2038b9fdff729861c9b4af0087024f
Author: Dou Liyang 
AuthorDate: Thu, 1 Mar 2018 13:59:29 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 1 Mar 2018 10:12:20 +0100

x86/apic: Modernize the pending interrupt code

The pending interrupt check code is old, update the following:

  - Use for_each_set_bit() instead of open coding it
  - Replace printk() with pr_err()
  - Get rid of printk line breaks
  - Make curly braces balanced

Suggested-by: Andy Shevchenko 
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180301055930.2396-3-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 69d2936e3154..7a347d7450b6 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1412,7 +1412,8 @@ static void apic_pending_intr_clear(void)
 {
long long max_loops = cpu_khz ? cpu_khz : 100;
unsigned long long tsc = 0, ntsc;
-   unsigned int value, queued;
+   unsigned int queued;
+   unsigned long value;
int i, j, acked = 0;
 
if (boot_cpu_has(X86_FEATURE_TSC))
@@ -1435,24 +1436,22 @@ static void apic_pending_intr_clear(void)
 
for (i = APIC_ISR_NR - 1; i >= 0; i--) {
value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
+   pr_err("LAPIC pending interrupts after %d EOI\n", 
acked);
break;
}
if (queued) {
if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
ntsc = rdtsc();
max_loops = (cpu_khz << 10) - (ntsc - tsc);
-   } else
+   } else {
max_loops--;
+   }
}
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);


[tip:x86/apic] x86/apic: Move pending interrupt check code into it's own function

2018-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  9b217f33017715903d0956dfc58f82d2a2d00e63
Gitweb: https://git.kernel.org/tip/9b217f33017715903d0956dfc58f82d2a2d00e63
Author: Dou Liyang 
AuthorDate: Thu, 1 Mar 2018 13:59:28 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 1 Mar 2018 10:12:20 +0100

x86/apic: Move pending interrupt check code into it's own function

The pending interrupt check code is mixed with the local APIC setup code,
that looks messy.

Extract the related code, move it into a new function named
apic_pending_intr_clear().

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180301055930.2396-2-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 100 
 1 file changed, 55 insertions(+), 45 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2ceac9f6c5d7..69d2936e3154 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1408,6 +1408,56 @@ static void lapic_setup_esr(void)
oldvalue, value);
 }
 
+static void apic_pending_intr_clear(void)
+{
+   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned long long tsc = 0, ntsc;
+   unsigned int value, queued;
+   int i, j, acked = 0;
+
+   if (boot_cpu_has(X86_FEATURE_TSC))
+   tsc = rdtsc();
+   /*
+* After a crash, we no longer service the interrupts and a pending
+* interrupt from previous kernel might still have ISR bit set.
+*
+* Most probably by now CPU has serviced that pending interrupt and
+* it might not have done the ack_APIC_irq() because it thought,
+* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
+* does not clear the ISR bit and cpu thinks it has already serivced
+* the interrupt. Hence a vector might get locked. It was noticed
+* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
+*/
+   do {
+   queued = 0;
+   for (i = APIC_ISR_NR - 1; i >= 0; i--)
+   queued |= apic_read(APIC_IRR + i*0x10);
+
+   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
+   value = apic_read(APIC_ISR + i*0x10);
+   for (j = 31; j >= 0; j--) {
+   if (value & (1< 256) {
+   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
+  acked);
+   break;
+   }
+   if (queued) {
+   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
+   ntsc = rdtsc();
+   max_loops = (cpu_khz << 10) - (ntsc - tsc);
+   } else
+   max_loops--;
+   }
+   } while (queued && max_loops > 0);
+   WARN_ON(max_loops <= 0);
+}
+
 /**
  * setup_local_APIC - setup the local APIC
  *
@@ -1417,13 +1467,11 @@ static void lapic_setup_esr(void)
 static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
-   unsigned int value, queued;
-   int i, j, acked = 0;
-   unsigned long long tsc = 0, ntsc;
-   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned int value;
+#ifdef CONFIG_X86_32
+   int i;
+#endif
 
-   if (boot_cpu_has(X86_FEATURE_TSC))
-   tsc = rdtsc();
 
if (disable_apic) {
disable_ioapic_support();
@@ -1475,45 +1523,7 @@ static void setup_local_APIC(void)
value &= ~APIC_TPRI_MASK;
apic_write(APIC_TASKPRI, value);
 
-   /*
-* After a crash, we no longer service the interrupts and a pending
-* interrupt from previous kernel might still have ISR bit set.
-*
-* Most probably by now CPU has serviced that pending interrupt and
-* it might not have done the ack_APIC_irq() because it thought,
-* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-* does not clear the ISR bit and cpu thinks it has already serivced
-* the interrupt. Hence a vector might get locked. It was noticed
-* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-*/
-   do {
-   queued = 0;
-   for (i = APIC_ISR_NR - 1; i >= 0; i--)
-   queued |= apic_read(APIC_IRR + i*0x10);
-
-   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-   value = apic_read(APIC_ISR + i*0x10);
- 

[tip:x86/apic] x86/apic: Move pending interrupt check code into it's own function

2018-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  9b217f33017715903d0956dfc58f82d2a2d00e63
Gitweb: https://git.kernel.org/tip/9b217f33017715903d0956dfc58f82d2a2d00e63
Author: Dou Liyang 
AuthorDate: Thu, 1 Mar 2018 13:59:28 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 1 Mar 2018 10:12:20 +0100

x86/apic: Move pending interrupt check code into it's own function

The pending interrupt check code is mixed with the local APIC setup code,
that looks messy.

Extract the related code, move it into a new function named
apic_pending_intr_clear().

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180301055930.2396-2-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 100 
 1 file changed, 55 insertions(+), 45 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2ceac9f6c5d7..69d2936e3154 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1408,6 +1408,56 @@ static void lapic_setup_esr(void)
oldvalue, value);
 }
 
+static void apic_pending_intr_clear(void)
+{
+   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned long long tsc = 0, ntsc;
+   unsigned int value, queued;
+   int i, j, acked = 0;
+
+   if (boot_cpu_has(X86_FEATURE_TSC))
+   tsc = rdtsc();
+   /*
+* After a crash, we no longer service the interrupts and a pending
+* interrupt from previous kernel might still have ISR bit set.
+*
+* Most probably by now CPU has serviced that pending interrupt and
+* it might not have done the ack_APIC_irq() because it thought,
+* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
+* does not clear the ISR bit and cpu thinks it has already serivced
+* the interrupt. Hence a vector might get locked. It was noticed
+* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
+*/
+   do {
+   queued = 0;
+   for (i = APIC_ISR_NR - 1; i >= 0; i--)
+   queued |= apic_read(APIC_IRR + i*0x10);
+
+   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
+   value = apic_read(APIC_ISR + i*0x10);
+   for (j = 31; j >= 0; j--) {
+   if (value & (1< 256) {
+   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
+  acked);
+   break;
+   }
+   if (queued) {
+   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
+   ntsc = rdtsc();
+   max_loops = (cpu_khz << 10) - (ntsc - tsc);
+   } else
+   max_loops--;
+   }
+   } while (queued && max_loops > 0);
+   WARN_ON(max_loops <= 0);
+}
+
 /**
  * setup_local_APIC - setup the local APIC
  *
@@ -1417,13 +1467,11 @@ static void lapic_setup_esr(void)
 static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
-   unsigned int value, queued;
-   int i, j, acked = 0;
-   unsigned long long tsc = 0, ntsc;
-   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned int value;
+#ifdef CONFIG_X86_32
+   int i;
+#endif
 
-   if (boot_cpu_has(X86_FEATURE_TSC))
-   tsc = rdtsc();
 
if (disable_apic) {
disable_ioapic_support();
@@ -1475,45 +1523,7 @@ static void setup_local_APIC(void)
value &= ~APIC_TPRI_MASK;
apic_write(APIC_TASKPRI, value);
 
-   /*
-* After a crash, we no longer service the interrupts and a pending
-* interrupt from previous kernel might still have ISR bit set.
-*
-* Most probably by now CPU has serviced that pending interrupt and
-* it might not have done the ack_APIC_irq() because it thought,
-* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-* does not clear the ISR bit and cpu thinks it has already serivced
-* the interrupt. Hence a vector might get locked. It was noticed
-* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-*/
-   do {
-   queued = 0;
-   for (i = APIC_ISR_NR - 1; i >= 0; i--)
-   queued |= apic_read(APIC_IRR + i*0x10);
-
-   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-   value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
-   break;
-   }
-   if (queued) {
-   if 

[tip:x86/apic] x86/apic: Replace common tools with new ones

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  ea5dfef5a890c9e6e47bdddfc23c4a4ba0c1bea1
Gitweb: https://git.kernel.org/tip/ea5dfef5a890c9e6e47bdddfc23c4a4ba0c1bea1
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:57 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:09:11 +0100

x86/apic: Replace common tools with new ones

The pending interrupt check code is old, update the following.

  -Replace for-if pair with for_each_set_bit()
  -Replace printk() with pr_err()

Also merge the printk's code in one line and make curly braces balanced

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180226023957.22861-2-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 3fda9734db25..4704a3541b11 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1412,7 +1412,8 @@ static void apic_pending_intr_clear(void)
 {
long long max_loops = cpu_khz ? cpu_khz : 100;
unsigned long long tsc = 0, ntsc;
-   unsigned int value, queued;
+   unsigned int queued;
+   unsigned long value;
int i, j, acked = 0;
 
if (boot_cpu_has(X86_FEATURE_TSC))
@@ -1435,24 +1436,22 @@ static void apic_pending_intr_clear(void)
 
for (i = APIC_ISR_NR - 1; i >= 0; i--) {
value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
+   pr_err("LAPIC pending interrupts after %d EOI\n", 
acked);
break;
}
if (queued) {
if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
ntsc = rdtsc();
max_loops = (cpu_khz << 10) - (ntsc - tsc);
-   } else
+   } else {
max_loops--;
+   }
}
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);


[tip:x86/apic] x86/apic: Replace common tools with new ones

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  ea5dfef5a890c9e6e47bdddfc23c4a4ba0c1bea1
Gitweb: https://git.kernel.org/tip/ea5dfef5a890c9e6e47bdddfc23c4a4ba0c1bea1
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:57 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:09:11 +0100

x86/apic: Replace common tools with new ones

The pending interrupt check code is old, update the following.

  -Replace for-if pair with for_each_set_bit()
  -Replace printk() with pr_err()

Also merge the printk's code in one line and make curly braces balanced

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180226023957.22861-2-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 3fda9734db25..4704a3541b11 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1412,7 +1412,8 @@ static void apic_pending_intr_clear(void)
 {
long long max_loops = cpu_khz ? cpu_khz : 100;
unsigned long long tsc = 0, ntsc;
-   unsigned int value, queued;
+   unsigned int queued;
+   unsigned long value;
int i, j, acked = 0;
 
if (boot_cpu_has(X86_FEATURE_TSC))
@@ -1435,24 +1436,22 @@ static void apic_pending_intr_clear(void)
 
for (i = APIC_ISR_NR - 1; i >= 0; i--) {
value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
+   pr_err("LAPIC pending interrupts after %d EOI\n", 
acked);
break;
}
if (queued) {
if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
ntsc = rdtsc();
max_loops = (cpu_khz << 10) - (ntsc - tsc);
-   } else
+   } else {
max_loops--;
+   }
}
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);


[tip:x86/apic] x86/apic: Move pending intr check code into it's own function

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  2066f4d67e7d9cbe44e451d782cdcc0a0d12e5d3
Gitweb: https://git.kernel.org/tip/2066f4d67e7d9cbe44e451d782cdcc0a0d12e5d3
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:56 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:09:11 +0100

x86/apic: Move pending intr check code into it's own function

The pending interrupt check code is mixed with the local APIC setup code,
that looks messy.

Extract the related code, move it into a new function named
apic_pending_intr_clear().

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180226023957.22861-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 98 -
 1 file changed, 52 insertions(+), 46 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2ceac9f6c5d7..3fda9734db25 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1408,6 +1408,56 @@ static void lapic_setup_esr(void)
oldvalue, value);
 }
 
+static void apic_pending_intr_clear(void)
+{
+   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned long long tsc = 0, ntsc;
+   unsigned int value, queued;
+   int i, j, acked = 0;
+
+   if (boot_cpu_has(X86_FEATURE_TSC))
+   tsc = rdtsc();
+   /*
+* After a crash, we no longer service the interrupts and a pending
+* interrupt from previous kernel might still have ISR bit set.
+*
+* Most probably by now CPU has serviced that pending interrupt and
+* it might not have done the ack_APIC_irq() because it thought,
+* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
+* does not clear the ISR bit and cpu thinks it has already serivced
+* the interrupt. Hence a vector might get locked. It was noticed
+* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
+*/
+   do {
+   queued = 0;
+   for (i = APIC_ISR_NR - 1; i >= 0; i--)
+   queued |= apic_read(APIC_IRR + i*0x10);
+
+   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
+   value = apic_read(APIC_ISR + i*0x10);
+   for (j = 31; j >= 0; j--) {
+   if (value & (1< 256) {
+   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
+  acked);
+   break;
+   }
+   if (queued) {
+   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
+   ntsc = rdtsc();
+   max_loops = (cpu_khz << 10) - (ntsc - tsc);
+   } else
+   max_loops--;
+   }
+   } while (queued && max_loops > 0);
+   WARN_ON(max_loops <= 0);
+}
+
 /**
  * setup_local_APIC - setup the local APIC
  *
@@ -1417,13 +1467,7 @@ static void lapic_setup_esr(void)
 static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
-   unsigned int value, queued;
-   int i, j, acked = 0;
-   unsigned long long tsc = 0, ntsc;
-   long long max_loops = cpu_khz ? cpu_khz : 100;
-
-   if (boot_cpu_has(X86_FEATURE_TSC))
-   tsc = rdtsc();
+   unsigned int value;
 
if (disable_apic) {
disable_ioapic_support();
@@ -1475,45 +1519,7 @@ static void setup_local_APIC(void)
value &= ~APIC_TPRI_MASK;
apic_write(APIC_TASKPRI, value);
 
-   /*
-* After a crash, we no longer service the interrupts and a pending
-* interrupt from previous kernel might still have ISR bit set.
-*
-* Most probably by now CPU has serviced that pending interrupt and
-* it might not have done the ack_APIC_irq() because it thought,
-* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-* does not clear the ISR bit and cpu thinks it has already serivced
-* the interrupt. Hence a vector might get locked. It was noticed
-* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-*/
-   do {
-   queued = 0;
-   for (i = APIC_ISR_NR - 1; i >= 0; i--)
-   queued |= apic_read(APIC_IRR + i*0x10);
-
-   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-   value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) 

[tip:x86/apic] x86/apic: Move pending intr check code into it's own function

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  2066f4d67e7d9cbe44e451d782cdcc0a0d12e5d3
Gitweb: https://git.kernel.org/tip/2066f4d67e7d9cbe44e451d782cdcc0a0d12e5d3
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:56 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:09:11 +0100

x86/apic: Move pending intr check code into it's own function

The pending interrupt check code is mixed with the local APIC setup code,
that looks messy.

Extract the related code, move it into a new function named
apic_pending_intr_clear().

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: https://lkml.kernel.org/r/20180226023957.22861-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 98 -
 1 file changed, 52 insertions(+), 46 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2ceac9f6c5d7..3fda9734db25 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1408,6 +1408,56 @@ static void lapic_setup_esr(void)
oldvalue, value);
 }
 
+static void apic_pending_intr_clear(void)
+{
+   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned long long tsc = 0, ntsc;
+   unsigned int value, queued;
+   int i, j, acked = 0;
+
+   if (boot_cpu_has(X86_FEATURE_TSC))
+   tsc = rdtsc();
+   /*
+* After a crash, we no longer service the interrupts and a pending
+* interrupt from previous kernel might still have ISR bit set.
+*
+* Most probably by now CPU has serviced that pending interrupt and
+* it might not have done the ack_APIC_irq() because it thought,
+* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
+* does not clear the ISR bit and cpu thinks it has already serivced
+* the interrupt. Hence a vector might get locked. It was noticed
+* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
+*/
+   do {
+   queued = 0;
+   for (i = APIC_ISR_NR - 1; i >= 0; i--)
+   queued |= apic_read(APIC_IRR + i*0x10);
+
+   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
+   value = apic_read(APIC_ISR + i*0x10);
+   for (j = 31; j >= 0; j--) {
+   if (value & (1< 256) {
+   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
+  acked);
+   break;
+   }
+   if (queued) {
+   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
+   ntsc = rdtsc();
+   max_loops = (cpu_khz << 10) - (ntsc - tsc);
+   } else
+   max_loops--;
+   }
+   } while (queued && max_loops > 0);
+   WARN_ON(max_loops <= 0);
+}
+
 /**
  * setup_local_APIC - setup the local APIC
  *
@@ -1417,13 +1467,7 @@ static void lapic_setup_esr(void)
 static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
-   unsigned int value, queued;
-   int i, j, acked = 0;
-   unsigned long long tsc = 0, ntsc;
-   long long max_loops = cpu_khz ? cpu_khz : 100;
-
-   if (boot_cpu_has(X86_FEATURE_TSC))
-   tsc = rdtsc();
+   unsigned int value;
 
if (disable_apic) {
disable_ioapic_support();
@@ -1475,45 +1519,7 @@ static void setup_local_APIC(void)
value &= ~APIC_TPRI_MASK;
apic_write(APIC_TASKPRI, value);
 
-   /*
-* After a crash, we no longer service the interrupts and a pending
-* interrupt from previous kernel might still have ISR bit set.
-*
-* Most probably by now CPU has serviced that pending interrupt and
-* it might not have done the ack_APIC_irq() because it thought,
-* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-* does not clear the ISR bit and cpu thinks it has already serivced
-* the interrupt. Hence a vector might get locked. It was noticed
-* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-*/
-   do {
-   queued = 0;
-   for (i = APIC_ISR_NR - 1; i >= 0; i--)
-   queued |= apic_read(APIC_IRR + i*0x10);
-
-   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-   value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
-   break;
-   }
-   if (queued) {
-   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
-  

[tip:x86/apic] x86/apic: Replace common tools with new ones

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  eb088bc5133167ca7790bae351761f5448a8941d
Gitweb: https://git.kernel.org/tip/eb088bc5133167ca7790bae351761f5448a8941d
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:57 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:02:58 +0100

x86/apic: Replace common tools with new ones

The pending interrupt check code is old, update the following.

  -Replace for-if pair with for_each_set_bit()
  -Replace printk() with pr_err()

Also merge the printk's code in one line and make curly braces balanced

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: 
https://lkml.kernel.org/r/20180226232554.14108.16881.st...@tlendack-t1.amdoffice.net

---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 3fda9734db25..4704a3541b11 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1412,7 +1412,8 @@ static void apic_pending_intr_clear(void)
 {
long long max_loops = cpu_khz ? cpu_khz : 100;
unsigned long long tsc = 0, ntsc;
-   unsigned int value, queued;
+   unsigned int queued;
+   unsigned long value;
int i, j, acked = 0;
 
if (boot_cpu_has(X86_FEATURE_TSC))
@@ -1435,24 +1436,22 @@ static void apic_pending_intr_clear(void)
 
for (i = APIC_ISR_NR - 1; i >= 0; i--) {
value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
+   pr_err("LAPIC pending interrupts after %d EOI\n", 
acked);
break;
}
if (queued) {
if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
ntsc = rdtsc();
max_loops = (cpu_khz << 10) - (ntsc - tsc);
-   } else
+   } else {
max_loops--;
+   }
}
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);


[tip:x86/apic] x86/apic: Replace common tools with new ones

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  eb088bc5133167ca7790bae351761f5448a8941d
Gitweb: https://git.kernel.org/tip/eb088bc5133167ca7790bae351761f5448a8941d
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:57 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:02:58 +0100

x86/apic: Replace common tools with new ones

The pending interrupt check code is old, update the following.

  -Replace for-if pair with for_each_set_bit()
  -Replace printk() with pr_err()

Also merge the printk's code in one line and make curly braces balanced

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: 
https://lkml.kernel.org/r/20180226232554.14108.16881.st...@tlendack-t1.amdoffice.net

---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 3fda9734db25..4704a3541b11 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1412,7 +1412,8 @@ static void apic_pending_intr_clear(void)
 {
long long max_loops = cpu_khz ? cpu_khz : 100;
unsigned long long tsc = 0, ntsc;
-   unsigned int value, queued;
+   unsigned int queued;
+   unsigned long value;
int i, j, acked = 0;
 
if (boot_cpu_has(X86_FEATURE_TSC))
@@ -1435,24 +1436,22 @@ static void apic_pending_intr_clear(void)
 
for (i = APIC_ISR_NR - 1; i >= 0; i--) {
value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
+   pr_err("LAPIC pending interrupts after %d EOI\n", 
acked);
break;
}
if (queued) {
if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
ntsc = rdtsc();
max_loops = (cpu_khz << 10) - (ntsc - tsc);
-   } else
+   } else {
max_loops--;
+   }
}
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);


[tip:x86/apic] x86/apic: Move pending intr check code into it's own function

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  0da89dfa7a6a85e2bab44462fe960ce41eecc4c9
Gitweb: https://git.kernel.org/tip/0da89dfa7a6a85e2bab44462fe960ce41eecc4c9
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:56 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:02:58 +0100

x86/apic: Move pending intr check code into it's own function

The pending interrupt check code is mixed with the local APIC setup code,
that looks messy.

Extract the related code, move it into a new function named
apic_pending_intr_clear().

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: 
https://lkml.kernel.org/r/20180226232554.14108.16881.st...@tlendack-t1.amdoffice.net

---
 arch/x86/kernel/apic/apic.c | 98 -
 1 file changed, 52 insertions(+), 46 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2ceac9f6c5d7..3fda9734db25 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1408,6 +1408,56 @@ static void lapic_setup_esr(void)
oldvalue, value);
 }
 
+static void apic_pending_intr_clear(void)
+{
+   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned long long tsc = 0, ntsc;
+   unsigned int value, queued;
+   int i, j, acked = 0;
+
+   if (boot_cpu_has(X86_FEATURE_TSC))
+   tsc = rdtsc();
+   /*
+* After a crash, we no longer service the interrupts and a pending
+* interrupt from previous kernel might still have ISR bit set.
+*
+* Most probably by now CPU has serviced that pending interrupt and
+* it might not have done the ack_APIC_irq() because it thought,
+* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
+* does not clear the ISR bit and cpu thinks it has already serivced
+* the interrupt. Hence a vector might get locked. It was noticed
+* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
+*/
+   do {
+   queued = 0;
+   for (i = APIC_ISR_NR - 1; i >= 0; i--)
+   queued |= apic_read(APIC_IRR + i*0x10);
+
+   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
+   value = apic_read(APIC_ISR + i*0x10);
+   for (j = 31; j >= 0; j--) {
+   if (value & (1< 256) {
+   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
+  acked);
+   break;
+   }
+   if (queued) {
+   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
+   ntsc = rdtsc();
+   max_loops = (cpu_khz << 10) - (ntsc - tsc);
+   } else
+   max_loops--;
+   }
+   } while (queued && max_loops > 0);
+   WARN_ON(max_loops <= 0);
+}
+
 /**
  * setup_local_APIC - setup the local APIC
  *
@@ -1417,13 +1467,7 @@ static void lapic_setup_esr(void)
 static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
-   unsigned int value, queued;
-   int i, j, acked = 0;
-   unsigned long long tsc = 0, ntsc;
-   long long max_loops = cpu_khz ? cpu_khz : 100;
-
-   if (boot_cpu_has(X86_FEATURE_TSC))
-   tsc = rdtsc();
+   unsigned int value;
 
if (disable_apic) {
disable_ioapic_support();
@@ -1475,45 +1519,7 @@ static void setup_local_APIC(void)
value &= ~APIC_TPRI_MASK;
apic_write(APIC_TASKPRI, value);
 
-   /*
-* After a crash, we no longer service the interrupts and a pending
-* interrupt from previous kernel might still have ISR bit set.
-*
-* Most probably by now CPU has serviced that pending interrupt and
-* it might not have done the ack_APIC_irq() because it thought,
-* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-* does not clear the ISR bit and cpu thinks it has already serivced
-* the interrupt. Hence a vector might get locked. It was noticed
-* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-*/
-   do {
-   queued = 0;
-   for (i = APIC_ISR_NR - 1; i >= 0; i--)
-   queued |= apic_read(APIC_IRR + i*0x10);
-
-   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-   value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j 

[tip:x86/apic] x86/apic: Move pending intr check code into it's own function

2018-02-28 Thread tip-bot for Dou Liyang
Commit-ID:  0da89dfa7a6a85e2bab44462fe960ce41eecc4c9
Gitweb: https://git.kernel.org/tip/0da89dfa7a6a85e2bab44462fe960ce41eecc4c9
Author: Dou Liyang 
AuthorDate: Mon, 26 Feb 2018 10:39:56 +0800
Committer:  Thomas Gleixner 
CommitDate: Wed, 28 Feb 2018 15:02:58 +0100

x86/apic: Move pending intr check code into it's own function

The pending interrupt check code is mixed with the local APIC setup code,
that looks messy.

Extract the related code, move it into a new function named
apic_pending_intr_clear().

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Andy Shevchenko 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: 
https://lkml.kernel.org/r/20180226232554.14108.16881.st...@tlendack-t1.amdoffice.net

---
 arch/x86/kernel/apic/apic.c | 98 -
 1 file changed, 52 insertions(+), 46 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2ceac9f6c5d7..3fda9734db25 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1408,6 +1408,56 @@ static void lapic_setup_esr(void)
oldvalue, value);
 }
 
+static void apic_pending_intr_clear(void)
+{
+   long long max_loops = cpu_khz ? cpu_khz : 100;
+   unsigned long long tsc = 0, ntsc;
+   unsigned int value, queued;
+   int i, j, acked = 0;
+
+   if (boot_cpu_has(X86_FEATURE_TSC))
+   tsc = rdtsc();
+   /*
+* After a crash, we no longer service the interrupts and a pending
+* interrupt from previous kernel might still have ISR bit set.
+*
+* Most probably by now CPU has serviced that pending interrupt and
+* it might not have done the ack_APIC_irq() because it thought,
+* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
+* does not clear the ISR bit and cpu thinks it has already serivced
+* the interrupt. Hence a vector might get locked. It was noticed
+* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
+*/
+   do {
+   queued = 0;
+   for (i = APIC_ISR_NR - 1; i >= 0; i--)
+   queued |= apic_read(APIC_IRR + i*0x10);
+
+   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
+   value = apic_read(APIC_ISR + i*0x10);
+   for (j = 31; j >= 0; j--) {
+   if (value & (1< 256) {
+   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
+  acked);
+   break;
+   }
+   if (queued) {
+   if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
+   ntsc = rdtsc();
+   max_loops = (cpu_khz << 10) - (ntsc - tsc);
+   } else
+   max_loops--;
+   }
+   } while (queued && max_loops > 0);
+   WARN_ON(max_loops <= 0);
+}
+
 /**
  * setup_local_APIC - setup the local APIC
  *
@@ -1417,13 +1467,7 @@ static void lapic_setup_esr(void)
 static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
-   unsigned int value, queued;
-   int i, j, acked = 0;
-   unsigned long long tsc = 0, ntsc;
-   long long max_loops = cpu_khz ? cpu_khz : 100;
-
-   if (boot_cpu_has(X86_FEATURE_TSC))
-   tsc = rdtsc();
+   unsigned int value;
 
if (disable_apic) {
disable_ioapic_support();
@@ -1475,45 +1519,7 @@ static void setup_local_APIC(void)
value &= ~APIC_TPRI_MASK;
apic_write(APIC_TASKPRI, value);
 
-   /*
-* After a crash, we no longer service the interrupts and a pending
-* interrupt from previous kernel might still have ISR bit set.
-*
-* Most probably by now CPU has serviced that pending interrupt and
-* it might not have done the ack_APIC_irq() because it thought,
-* interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-* does not clear the ISR bit and cpu thinks it has already serivced
-* the interrupt. Hence a vector might get locked. It was noticed
-* for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-*/
-   do {
-   queued = 0;
-   for (i = APIC_ISR_NR - 1; i >= 0; i--)
-   queued |= apic_read(APIC_IRR + i*0x10);
-
-   for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-   value = apic_read(APIC_ISR + i*0x10);
-   for (j = 31; j >= 0; j--) {
-   if (value & (1< 256) {
-   printk(KERN_ERR "LAPIC pending interrupts after %d 
EOI\n",
-  acked);
-   break;
-   }
-   if (queued) {
-   if (boot_cpu_has(X86_FEATURE_TSC) && 

[tip:x86/urgent] x86/topology: Fix function name in documentation

2018-02-23 Thread tip-bot for Dou Liyang
Commit-ID:  0c52f7c5499dc708a64742da0cb7eb4f6d94588b
Gitweb: https://git.kernel.org/tip/0c52f7c5499dc708a64742da0cb7eb4f6d94588b
Author: Dou Liyang 
AuthorDate: Thu, 22 Feb 2018 16:48:12 +0800
Committer:  Ingo Molnar 
CommitDate: Fri, 23 Feb 2018 08:40:12 +0100

x86/topology: Fix function name in documentation

topology_sibling_cpumask() is the correct thread-related topology
function in the kernel:

  s/topology_sibling_mask/topology_sibling_cpumask

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: cor...@lwn.net
Cc: linux-...@vger.kernel.org
Link: http://lkml.kernel.org/r/20180222084812.14497-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 Documentation/x86/topology.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/x86/topology.txt b/Documentation/x86/topology.txt
index f3e9d7e9ed6c..2953e3ec9a02 100644
--- a/Documentation/x86/topology.txt
+++ b/Documentation/x86/topology.txt
@@ -108,7 +108,7 @@ The topology of a system is described in the units of:
 
 The number of online threads is also printed in /proc/cpuinfo "siblings."
 
-  - topology_sibling_mask():
+  - topology_sibling_cpumask():
 
 The cpumask contains all online threads in the core to which a thread
 belongs.


[tip:x86/urgent] x86/topology: Fix function name in documentation

2018-02-23 Thread tip-bot for Dou Liyang
Commit-ID:  0c52f7c5499dc708a64742da0cb7eb4f6d94588b
Gitweb: https://git.kernel.org/tip/0c52f7c5499dc708a64742da0cb7eb4f6d94588b
Author: Dou Liyang 
AuthorDate: Thu, 22 Feb 2018 16:48:12 +0800
Committer:  Ingo Molnar 
CommitDate: Fri, 23 Feb 2018 08:40:12 +0100

x86/topology: Fix function name in documentation

topology_sibling_cpumask() is the correct thread-related topology
function in the kernel:

  s/topology_sibling_mask/topology_sibling_cpumask

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: cor...@lwn.net
Cc: linux-...@vger.kernel.org
Link: http://lkml.kernel.org/r/20180222084812.14497-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 Documentation/x86/topology.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/x86/topology.txt b/Documentation/x86/topology.txt
index f3e9d7e9ed6c..2953e3ec9a02 100644
--- a/Documentation/x86/topology.txt
+++ b/Documentation/x86/topology.txt
@@ -108,7 +108,7 @@ The topology of a system is described in the units of:
 
 The number of online threads is also printed in /proc/cpuinfo "siblings."
 
-  - topology_sibling_mask():
+  - topology_sibling_cpumask():
 
 The cpumask contains all online threads in the core to which a thread
 belongs.


[tip:x86/apic] x86/apic: Make setup_local_APIC() static

2018-02-16 Thread tip-bot for Dou Liyang
Commit-ID:  b753a2b79a5bbad35dfaf8d3dba964727c30654a
Gitweb: https://git.kernel.org/tip/b753a2b79a5bbad35dfaf8d3dba964727c30654a
Author: Dou Liyang 
AuthorDate: Wed, 14 Feb 2018 14:25:54 +0800
Committer:  Ingo Molnar 
CommitDate: Fri, 16 Feb 2018 10:39:11 +0100

x86/apic: Make setup_local_APIC() static

This function isn't used outside of apic.c, so let's mark it static.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: http://lkml.kernel.org/r/20180214062554.21020-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/apic.h | 1 -
 arch/x86/kernel/apic/apic.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 6e1990d..c6a3201 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -138,7 +138,6 @@ extern void lapic_shutdown(void);
 extern void sync_Arb_IDs(void);
 extern void init_bsp_APIC(void);
 extern void apic_intr_mode_init(void);
-extern void setup_local_APIC(void);
 extern void init_apic_mappings(void);
 void register_lapic_address(unsigned long address);
 extern void setup_boot_APIC_clock(void);
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 25ddf02..871018d 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1414,7 +1414,7 @@ static void lapic_setup_esr(void)
  * Used to setup local APIC while initializing BSP or bringing up APs.
  * Always called with preemption disabled.
  */
-void setup_local_APIC(void)
+static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
unsigned int value, queued;


[tip:x86/apic] x86/apic: Make setup_local_APIC() static

2018-02-16 Thread tip-bot for Dou Liyang
Commit-ID:  b753a2b79a5bbad35dfaf8d3dba964727c30654a
Gitweb: https://git.kernel.org/tip/b753a2b79a5bbad35dfaf8d3dba964727c30654a
Author: Dou Liyang 
AuthorDate: Wed, 14 Feb 2018 14:25:54 +0800
Committer:  Ingo Molnar 
CommitDate: Fri, 16 Feb 2018 10:39:11 +0100

x86/apic: Make setup_local_APIC() static

This function isn't used outside of apic.c, so let's mark it static.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: b...@redhat.com
Cc: ebied...@xmission.com
Link: http://lkml.kernel.org/r/20180214062554.21020-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/apic.h | 1 -
 arch/x86/kernel/apic/apic.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 6e1990d..c6a3201 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -138,7 +138,6 @@ extern void lapic_shutdown(void);
 extern void sync_Arb_IDs(void);
 extern void init_bsp_APIC(void);
 extern void apic_intr_mode_init(void);
-extern void setup_local_APIC(void);
 extern void init_apic_mappings(void);
 void register_lapic_address(unsigned long address);
 extern void setup_boot_APIC_clock(void);
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 25ddf02..871018d 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1414,7 +1414,7 @@ static void lapic_setup_esr(void)
  * Used to setup local APIC while initializing BSP or bringing up APs.
  * Always called with preemption disabled.
  */
-void setup_local_APIC(void)
+static void setup_local_APIC(void)
 {
int cpu = smp_processor_id();
unsigned int value, queued;


[tip:x86/apic] x86/apic: Simplify init_bsp_APIC() usage

2018-02-13 Thread tip-bot for Dou Liyang
Commit-ID:  ccf5355d05cd891522267f04b2723002e7f061de
Gitweb: https://git.kernel.org/tip/ccf5355d05cd891522267f04b2723002e7f061de
Author: Dou Liyang 
AuthorDate: Wed, 17 Jan 2018 15:37:48 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 13 Feb 2018 17:30:38 +0100

x86/apic: Simplify init_bsp_APIC() usage

Since CONFIG_X86_64 selects CONFIG_X86_LOCAL_APIC, the following
condition:

  #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)

is equivalent to:

  #if defined(CONFIG_X86_LOCAL_APIC)

... and we can eliminate that #ifdef by providing an empty
init_bsp_APIC() stub in the !CONFIG_X86_LOCAL_APIC case.

Also add some comments to explain why we call init_bsp_APIC().

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: mr...@linux.ee
Cc: ville.syrj...@linux.intel.com
Link: http://lkml.kernel.org/r/20180117073748.23905-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/apic.h | 1 +
 arch/x86/kernel/irqinit.c   | 9 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 9872277..6e1990d 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -183,6 +183,7 @@ static inline void disable_local_APIC(void) { }
 # define setup_boot_APIC_clock x86_init_noop
 # define setup_secondary_APIC_clock x86_init_noop
 static inline void lapic_update_tsc_freq(void) { }
+static inline void init_bsp_APIC(void) { }
 static inline void apic_intr_mode_init(void) { }
 static inline void lapic_assign_system_vectors(void) { }
 static inline void lapic_assign_legacy_vector(unsigned int i, bool r) { }
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index a539410..772196c 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -61,9 +61,14 @@ void __init init_ISA_irqs(void)
struct irq_chip *chip = legacy_pic->chip;
int i;
 
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
+   /*
+* Try to set up the through-local-APIC virtual wire mode earlier.
+*
+* On some 32-bit UP machines, whose APIC has been disabled by BIOS
+* and then got re-enabled by "lapic", it hangs at boot time without 
this.
+*/
init_bsp_APIC();
-#endif
+
legacy_pic->init(0);
 
for (i = 0; i < nr_legacy_irqs(); i++)


[tip:x86/apic] x86/apic: Simplify init_bsp_APIC() usage

2018-02-13 Thread tip-bot for Dou Liyang
Commit-ID:  ccf5355d05cd891522267f04b2723002e7f061de
Gitweb: https://git.kernel.org/tip/ccf5355d05cd891522267f04b2723002e7f061de
Author: Dou Liyang 
AuthorDate: Wed, 17 Jan 2018 15:37:48 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 13 Feb 2018 17:30:38 +0100

x86/apic: Simplify init_bsp_APIC() usage

Since CONFIG_X86_64 selects CONFIG_X86_LOCAL_APIC, the following
condition:

  #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)

is equivalent to:

  #if defined(CONFIG_X86_LOCAL_APIC)

... and we can eliminate that #ifdef by providing an empty
init_bsp_APIC() stub in the !CONFIG_X86_LOCAL_APIC case.

Also add some comments to explain why we call init_bsp_APIC().

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: mr...@linux.ee
Cc: ville.syrj...@linux.intel.com
Link: http://lkml.kernel.org/r/20180117073748.23905-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/apic.h | 1 +
 arch/x86/kernel/irqinit.c   | 9 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 9872277..6e1990d 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -183,6 +183,7 @@ static inline void disable_local_APIC(void) { }
 # define setup_boot_APIC_clock x86_init_noop
 # define setup_secondary_APIC_clock x86_init_noop
 static inline void lapic_update_tsc_freq(void) { }
+static inline void init_bsp_APIC(void) { }
 static inline void apic_intr_mode_init(void) { }
 static inline void lapic_assign_system_vectors(void) { }
 static inline void lapic_assign_legacy_vector(unsigned int i, bool r) { }
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index a539410..772196c 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -61,9 +61,14 @@ void __init init_ISA_irqs(void)
struct irq_chip *chip = legacy_pic->chip;
int i;
 
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
+   /*
+* Try to set up the through-local-APIC virtual wire mode earlier.
+*
+* On some 32-bit UP machines, whose APIC has been disabled by BIOS
+* and then got re-enabled by "lapic", it hangs at boot time without 
this.
+*/
init_bsp_APIC();
-#endif
+
legacy_pic->init(0);
 
for (i = 0; i < nr_legacy_irqs(); i++)


[tip:x86/apic] x86/x2apic: Mark set_x2apic_phys_mode() as __init

2018-02-13 Thread tip-bot for Dou Liyang
Commit-ID:  afed7d172091040f38c75a2927fed170ea11585f
Gitweb: https://git.kernel.org/tip/afed7d172091040f38c75a2927fed170ea11585f
Author: Dou Liyang 
AuthorDate: Wed, 17 Jan 2018 11:45:43 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 13 Feb 2018 17:24:36 +0100

x86/x2apic: Mark set_x2apic_phys_mode() as __init

set_x2apic_phys_mode() is only called as part of early_param()
initialization - so mark it as __init.

Signed-off-by: Dou Liyang 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20180117034543.26723-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/x2apic_phys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/x2apic_phys.c 
b/arch/x86/kernel/apic/x2apic_phys.c
index f8d9d69..e2829bf 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -14,7 +14,7 @@ int x2apic_phys;
 
 static struct apic apic_x2apic_phys;
 
-static int set_x2apic_phys_mode(char *arg)
+static int __init set_x2apic_phys_mode(char *arg)
 {
x2apic_phys = 1;
return 0;


[tip:x86/apic] x86/x2apic: Mark set_x2apic_phys_mode() as __init

2018-02-13 Thread tip-bot for Dou Liyang
Commit-ID:  afed7d172091040f38c75a2927fed170ea11585f
Gitweb: https://git.kernel.org/tip/afed7d172091040f38c75a2927fed170ea11585f
Author: Dou Liyang 
AuthorDate: Wed, 17 Jan 2018 11:45:43 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 13 Feb 2018 17:24:36 +0100

x86/x2apic: Mark set_x2apic_phys_mode() as __init

set_x2apic_phys_mode() is only called as part of early_param()
initialization - so mark it as __init.

Signed-off-by: Dou Liyang 
Cc: Juergen Gross 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20180117034543.26723-1-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/x2apic_phys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/x2apic_phys.c 
b/arch/x86/kernel/apic/x2apic_phys.c
index f8d9d69..e2829bf 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -14,7 +14,7 @@ int x2apic_phys;
 
 static struct apic apic_x2apic_phys;
 
-static int set_x2apic_phys_mode(char *arg)
+static int __init set_x2apic_phys_mode(char *arg)
 {
x2apic_phys = 1;
return 0;


[tip:x86/pti] x86/spectre: Check CONFIG_RETPOLINE in command line parser

2018-01-30 Thread tip-bot for Dou Liyang
Commit-ID:  9471eee9186a46893726e22ebb54cade3f9bc043
Gitweb: https://git.kernel.org/tip/9471eee9186a46893726e22ebb54cade3f9bc043
Author: Dou Liyang 
AuthorDate: Tue, 30 Jan 2018 14:13:50 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 30 Jan 2018 15:30:35 +0100

x86/spectre: Check CONFIG_RETPOLINE in command line parser

The spectre_v2 option 'auto' does not check whether CONFIG_RETPOLINE is
enabled. As a consequence it fails to emit the appropriate warning and sets
feature flags which have no effect at all.

Add the missing IS_ENABLED() check.

Fixes: da285121560e ("x86/spectre: Add boot time option to select Spectre v2 
mitigation")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: a...@linux.intel.com
Cc: pet...@infradead.org
Cc: Tomohiro" 
Cc: dave.han...@intel.com
Cc: b...@alien8.de
Cc: ar...@linux.intel.com
Cc: d...@amazon.co.uk
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/f5892721-7528-3647-08fb-f8d10e65a...@cn.fujitsu.com

---
 arch/x86/kernel/cpu/bugs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 3bfb2b2..400c34e 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -213,10 +213,10 @@ static void __init spectre_v2_select_mitigation(void)
return;
 
case SPECTRE_V2_CMD_FORCE:
-   /* FALLTRHU */
case SPECTRE_V2_CMD_AUTO:
-   goto retpoline_auto;
-
+   if (IS_ENABLED(CONFIG_RETPOLINE))
+   goto retpoline_auto;
+   break;
case SPECTRE_V2_CMD_RETPOLINE_AMD:
if (IS_ENABLED(CONFIG_RETPOLINE))
goto retpoline_amd;


[tip:x86/pti] x86/spectre: Check CONFIG_RETPOLINE in command line parser

2018-01-30 Thread tip-bot for Dou Liyang
Commit-ID:  9471eee9186a46893726e22ebb54cade3f9bc043
Gitweb: https://git.kernel.org/tip/9471eee9186a46893726e22ebb54cade3f9bc043
Author: Dou Liyang 
AuthorDate: Tue, 30 Jan 2018 14:13:50 +0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 30 Jan 2018 15:30:35 +0100

x86/spectre: Check CONFIG_RETPOLINE in command line parser

The spectre_v2 option 'auto' does not check whether CONFIG_RETPOLINE is
enabled. As a consequence it fails to emit the appropriate warning and sets
feature flags which have no effect at all.

Add the missing IS_ENABLED() check.

Fixes: da285121560e ("x86/spectre: Add boot time option to select Spectre v2 
mitigation")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: a...@linux.intel.com
Cc: pet...@infradead.org
Cc: Tomohiro" 
Cc: dave.han...@intel.com
Cc: b...@alien8.de
Cc: ar...@linux.intel.com
Cc: d...@amazon.co.uk
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/f5892721-7528-3647-08fb-f8d10e65a...@cn.fujitsu.com

---
 arch/x86/kernel/cpu/bugs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 3bfb2b2..400c34e 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -213,10 +213,10 @@ static void __init spectre_v2_select_mitigation(void)
return;
 
case SPECTRE_V2_CMD_FORCE:
-   /* FALLTRHU */
case SPECTRE_V2_CMD_AUTO:
-   goto retpoline_auto;
-
+   if (IS_ENABLED(CONFIG_RETPOLINE))
+   goto retpoline_auto;
+   break;
case SPECTRE_V2_CMD_RETPOLINE_AMD:
if (IS_ENABLED(CONFIG_RETPOLINE))
goto retpoline_amd;


[tip:x86/urgent] x86/apic: Update the 'apic=' description of setting APIC driver

2017-12-28 Thread tip-bot for Dou Liyang
Commit-ID:  64e05d118e357bb52a084b609436acf292ce7944
Gitweb: https://git.kernel.org/tip/64e05d118e357bb52a084b609436acf292ce7944
Author: Dou Liyang 
AuthorDate: Mon, 4 Dec 2017 12:03:13 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 28 Dec 2017 12:32:07 +0100

x86/apic: Update the 'apic=' description of setting APIC driver

There are two consumers of apic=: the APIC debug level and the low
level generic architecture code, but Linux just documented the first
one.

Append the second description.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: pet...@infradead.org
Cc: rdun...@infradead.org
Cc: cor...@lwn.net
Link: https://lkml.kernel.org/r/20171204040313.24824-2-douly.f...@cn.fujitsu.com

---
 Documentation/admin-guide/kernel-parameters.txt | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index b74e133..852fb11 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -328,11 +328,15 @@
not play well with APC CPU idle - disable it if you have
APC and your system crashes randomly.
 
-   apic=   [APIC,X86-32] Advanced Programmable Interrupt Controller
+   apic=   [APIC,X86] Advanced Programmable Interrupt Controller
Change the output verbosity whilst booting
Format: { quiet (default) | verbose | debug }
Change the amount of debugging information output
when initialising the APIC and IO-APIC components.
+   For X86-32, this can also be used to specify an APIC
+   driver name.
+   Format: apic=driver_name
+   Examples: apic=bigsmp
 
apic_extnmi=[APIC,X86] External NMI delivery setting
Format: { bsp (default) | all | none }


[tip:x86/urgent] x86/apic: Update the 'apic=' description of setting APIC driver

2017-12-28 Thread tip-bot for Dou Liyang
Commit-ID:  64e05d118e357bb52a084b609436acf292ce7944
Gitweb: https://git.kernel.org/tip/64e05d118e357bb52a084b609436acf292ce7944
Author: Dou Liyang 
AuthorDate: Mon, 4 Dec 2017 12:03:13 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 28 Dec 2017 12:32:07 +0100

x86/apic: Update the 'apic=' description of setting APIC driver

There are two consumers of apic=: the APIC debug level and the low
level generic architecture code, but Linux just documented the first
one.

Append the second description.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: pet...@infradead.org
Cc: rdun...@infradead.org
Cc: cor...@lwn.net
Link: https://lkml.kernel.org/r/20171204040313.24824-2-douly.f...@cn.fujitsu.com

---
 Documentation/admin-guide/kernel-parameters.txt | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index b74e133..852fb11 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -328,11 +328,15 @@
not play well with APC CPU idle - disable it if you have
APC and your system crashes randomly.
 
-   apic=   [APIC,X86-32] Advanced Programmable Interrupt Controller
+   apic=   [APIC,X86] Advanced Programmable Interrupt Controller
Change the output verbosity whilst booting
Format: { quiet (default) | verbose | debug }
Change the amount of debugging information output
when initialising the APIC and IO-APIC components.
+   For X86-32, this can also be used to specify an APIC
+   driver name.
+   Format: apic=driver_name
+   Examples: apic=bigsmp
 
apic_extnmi=[APIC,X86] External NMI delivery setting
Format: { bsp (default) | all | none }


[tip:x86/urgent] x86/apic: Avoid wrong warning when parsing 'apic=' in X86-32 case

2017-12-28 Thread tip-bot for Dou Liyang
Commit-ID:  4fcab6693445cfb84f2b65868c58043535090e52
Gitweb: https://git.kernel.org/tip/4fcab6693445cfb84f2b65868c58043535090e52
Author: Dou Liyang 
AuthorDate: Mon, 4 Dec 2017 12:03:12 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 28 Dec 2017 12:32:06 +0100

x86/apic: Avoid wrong warning when parsing 'apic=' in X86-32 case

There are two consumers of apic=:
  apic_set_verbosity() for setting the APIC debug level;
  parse_apic() for registering APIC driver by hand.

X86-32 supports both of them, but sometimes, kernel issues a weird warning.
eg: when kernel was booted up with 'apic=bigsmp' in command line,
early_param would warn like that:

...
[0.00] APIC Verbosity level bigsmp not recognised use apic=verbose or 
apic=debug
[0.00] Malformed early option 'apic'
...

Wrap the warning code in CONFIG_X86_64 case to avoid this.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: pet...@infradead.org
Cc: rdun...@infradead.org
Cc: cor...@lwn.net
Link: https://lkml.kernel.org/r/20171204040313.24824-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 6e272f3..880441f 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2626,11 +2626,13 @@ static int __init apic_set_verbosity(char *arg)
apic_verbosity = APIC_DEBUG;
else if (strcmp("verbose", arg) == 0)
apic_verbosity = APIC_VERBOSE;
+#ifdef CONFIG_X86_64
else {
pr_warning("APIC Verbosity level %s not recognised"
" use apic=verbose or apic=debug\n", arg);
return -EINVAL;
}
+#endif
 
return 0;
 }


[tip:x86/urgent] x86/apic: Avoid wrong warning when parsing 'apic=' in X86-32 case

2017-12-28 Thread tip-bot for Dou Liyang
Commit-ID:  4fcab6693445cfb84f2b65868c58043535090e52
Gitweb: https://git.kernel.org/tip/4fcab6693445cfb84f2b65868c58043535090e52
Author: Dou Liyang 
AuthorDate: Mon, 4 Dec 2017 12:03:12 +0800
Committer:  Thomas Gleixner 
CommitDate: Thu, 28 Dec 2017 12:32:06 +0100

x86/apic: Avoid wrong warning when parsing 'apic=' in X86-32 case

There are two consumers of apic=:
  apic_set_verbosity() for setting the APIC debug level;
  parse_apic() for registering APIC driver by hand.

X86-32 supports both of them, but sometimes, kernel issues a weird warning.
eg: when kernel was booted up with 'apic=bigsmp' in command line,
early_param would warn like that:

...
[0.00] APIC Verbosity level bigsmp not recognised use apic=verbose or 
apic=debug
[0.00] Malformed early option 'apic'
...

Wrap the warning code in CONFIG_X86_64 case to avoid this.

Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: pet...@infradead.org
Cc: rdun...@infradead.org
Cc: cor...@lwn.net
Link: https://lkml.kernel.org/r/20171204040313.24824-1-douly.f...@cn.fujitsu.com

---
 arch/x86/kernel/apic/apic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 6e272f3..880441f 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2626,11 +2626,13 @@ static int __init apic_set_verbosity(char *arg)
apic_verbosity = APIC_DEBUG;
else if (strcmp("verbose", arg) == 0)
apic_verbosity = APIC_VERBOSE;
+#ifdef CONFIG_X86_64
else {
pr_warning("APIC Verbosity level %s not recognised"
" use apic=verbose or apic=debug\n", arg);
return -EINVAL;
}
+#endif
 
return 0;
 }


[tip:timers/urgent] timekeeping: Eliminate the stale declaration of ktime_get_raw_and_real_ts64()

2017-11-13 Thread tip-bot for Dou Liyang
Commit-ID:  8a7a8e1eab929eb3a5b735a788a23b9731139046
Gitweb: https://git.kernel.org/tip/8a7a8e1eab929eb3a5b735a788a23b9731139046
Author: Dou Liyang 
AuthorDate: Mon, 13 Nov 2017 13:49:04 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Nov 2017 17:35:27 +0100

timekeeping: Eliminate the stale declaration of ktime_get_raw_and_real_ts64()

Commit ba26621e63ce got rid of ktime_get_raw_and_real_ts64(), but left its
declaration behind.

Remove it.

Fixes: ba26621e63ce ("time: Remove duplicated code in ktime_get_raw_and_real()")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: Christopher S. Hall 
Cc: joe...@google.com
Cc: a...@arndb.de
Cc: gre...@linuxfoundation.org
Cc: john.stu...@linaro.org
Cc: deepa.ker...@gmail.com
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/1510552144-20831-1-git-send-email-douly.f...@cn.fujitsu.com

---
 include/linux/timekeeping.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 0021575..51293e1 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -273,12 +273,6 @@ extern bool timekeeping_rtc_skipresume(void);
 extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
 
 /*
- * PPS accessor
- */
-extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw,
-   struct timespec64 *ts_real);
-
-/*
  * struct system_time_snapshot - simultaneous raw/real time capture with
  * counter value
  * @cycles:Clocksource counter value to produce the system times


[tip:timers/urgent] timekeeping: Eliminate the stale declaration of ktime_get_raw_and_real_ts64()

2017-11-13 Thread tip-bot for Dou Liyang
Commit-ID:  8a7a8e1eab929eb3a5b735a788a23b9731139046
Gitweb: https://git.kernel.org/tip/8a7a8e1eab929eb3a5b735a788a23b9731139046
Author: Dou Liyang 
AuthorDate: Mon, 13 Nov 2017 13:49:04 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Nov 2017 17:35:27 +0100

timekeeping: Eliminate the stale declaration of ktime_get_raw_and_real_ts64()

Commit ba26621e63ce got rid of ktime_get_raw_and_real_ts64(), but left its
declaration behind.

Remove it.

Fixes: ba26621e63ce ("time: Remove duplicated code in ktime_get_raw_and_real()")
Signed-off-by: Dou Liyang 
Signed-off-by: Thomas Gleixner 
Cc: Christopher S. Hall 
Cc: joe...@google.com
Cc: a...@arndb.de
Cc: gre...@linuxfoundation.org
Cc: john.stu...@linaro.org
Cc: deepa.ker...@gmail.com
Cc: sta...@vger.kernel.org
Link: 
https://lkml.kernel.org/r/1510552144-20831-1-git-send-email-douly.f...@cn.fujitsu.com

---
 include/linux/timekeeping.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 0021575..51293e1 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -273,12 +273,6 @@ extern bool timekeeping_rtc_skipresume(void);
 extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
 
 /*
- * PPS accessor
- */
-extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw,
-   struct timespec64 *ts_real);
-
-/*
  * struct system_time_snapshot - simultaneous raw/real time capture with
  * counter value
  * @cycles:Clocksource counter value to produce the system times


[tip:x86/timers] x86/tsc: Mark cyc2ns_init() and detect_art() __init

2017-11-10 Thread tip-bot for Dou Liyang
Commit-ID:  120fc3fbb7787fb70240190cc9c113d1f6523c42
Gitweb: https://git.kernel.org/tip/120fc3fbb7787fb70240190cc9c113d1f6523c42
Author: Dou Liyang 
AuthorDate: Wed, 8 Nov 2017 18:09:52 +0800
Committer:  Ingo Molnar 
CommitDate: Fri, 10 Nov 2017 10:02:08 +0100

x86/tsc: Mark cyc2ns_init() and detect_art() __init

These two functions are only called by tsc_init(), which is an __init
function during boot time, so mark them __init as well.

Signed-off-by: Dou Liyang 
Acked-by: Thomas Gleixner 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1510135792-17429-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/tsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index f1326c0..416de29 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -112,7 +112,7 @@ static void cyc2ns_data_init(struct cyc2ns_data *data)
data->cyc2ns_offset = 0;
 }
 
-static void cyc2ns_init(int cpu)
+static void __init cyc2ns_init(int cpu)
 {
struct cyc2ns *c2n = _cpu(cyc2ns, cpu);
 
@@ -955,7 +955,7 @@ core_initcall(cpufreq_register_tsc_scaling);
 /*
  * If ART is present detect the numerator:denominator to convert to TSC
  */
-static void detect_art(void)
+static void __init detect_art(void)
 {
unsigned int unused[2];
 


[tip:x86/timers] x86/tsc: Mark cyc2ns_init() and detect_art() __init

2017-11-10 Thread tip-bot for Dou Liyang
Commit-ID:  120fc3fbb7787fb70240190cc9c113d1f6523c42
Gitweb: https://git.kernel.org/tip/120fc3fbb7787fb70240190cc9c113d1f6523c42
Author: Dou Liyang 
AuthorDate: Wed, 8 Nov 2017 18:09:52 +0800
Committer:  Ingo Molnar 
CommitDate: Fri, 10 Nov 2017 10:02:08 +0100

x86/tsc: Mark cyc2ns_init() and detect_art() __init

These two functions are only called by tsc_init(), which is an __init
function during boot time, so mark them __init as well.

Signed-off-by: Dou Liyang 
Acked-by: Thomas Gleixner 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1510135792-17429-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/tsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index f1326c0..416de29 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -112,7 +112,7 @@ static void cyc2ns_data_init(struct cyc2ns_data *data)
data->cyc2ns_offset = 0;
 }
 
-static void cyc2ns_init(int cpu)
+static void __init cyc2ns_init(int cpu)
 {
struct cyc2ns *c2n = _cpu(cyc2ns, cpu);
 
@@ -955,7 +955,7 @@ core_initcall(cpufreq_register_tsc_scaling);
 /*
  * If ART is present detect the numerator:denominator to convert to TSC
  */
-static void detect_art(void)
+static void __init detect_art(void)
 {
unsigned int unused[2];
 


[tip:locking/core] x86/paravirt: Set up the virt_spin_lock_key after static keys get initialized

2017-10-30 Thread tip-bot for Dou Liyang
Commit-ID:  ca5d376e17072c1b60c3fee66f3be58ef018952d
Gitweb: https://git.kernel.org/tip/ca5d376e17072c1b60c3fee66f3be58ef018952d
Author: Dou Liyang 
AuthorDate: Sat, 28 Oct 2017 14:06:44 +0800
Committer:  Ingo Molnar 
CommitDate: Mon, 30 Oct 2017 09:17:29 +0100

x86/paravirt: Set up the virt_spin_lock_key after static keys get initialized

Commit:

  9043442b43b1 ("locking/paravirt: Use new static key for controlling call of 
virt_spin_lock()")

sets the static virt_spin_lock_key to a value before jump_label_init()
has been called, which will result in a WARN().

Reorder the initialization sequence:

 - Move the native_pv_lock_init() into native_smp_prepare_cpus()
 - set the value in xen_init_lock_cpu()

to avoid calling into the not yet initialized static keys subsystem.

Suggested-by: Juergen Gross 
Reported-by: Juergen Gross 
Signed-off-by: Dou Liyang 
Reviewed-by: Juergen Gross 
Acked-by: Thomas Gleixner 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: boris.ostrov...@oracle.com
Cc: b...@suse.de
Cc: l...@kernel.org
Cc: vkuzn...@redhat.com
Cc: xen-de...@lists.xenproject.org
Link: 
http://lkml.kernel.org/r/1509170804-3813-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/smpboot.c | 3 ++-
 arch/x86/xen/spinlock.c   | 6 --
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 361f916..198416d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1358,6 +1358,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
pr_info("CPU0: ");
print_cpu_info(_data(0));
 
+   native_pv_lock_init();
+
uv_system_init();
 
set_mtrr_aps_delayed_init();
@@ -1385,7 +1387,6 @@ void __init native_smp_prepare_boot_cpu(void)
/* already set me in cpu_online_mask in boot_cpu_init() */
cpumask_set_cpu(me, cpu_callout_mask);
cpu_set_state_online(me);
-   native_pv_lock_init();
 }
 
 void __init native_smp_cpus_done(unsigned int max_cpus)
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index e8ab80a..1e1462d 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
int irq;
char *name;
 
-   if (!xen_pvspin)
+   if (!xen_pvspin) {
+   if (cpu == 0)
+   static_branch_disable(_spin_lock_key);
return;
+   }
 
WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on 
IRQ%d!\n",
 cpu, per_cpu(lock_kicker_irq, cpu));
@@ -130,7 +133,6 @@ void __init xen_init_spinlocks(void)
 
if (!xen_pvspin) {
printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
-   static_branch_disable(_spin_lock_key);
return;
}
printk(KERN_DEBUG "xen: PV spinlocks enabled\n");


[tip:locking/core] x86/paravirt: Set up the virt_spin_lock_key after static keys get initialized

2017-10-30 Thread tip-bot for Dou Liyang
Commit-ID:  ca5d376e17072c1b60c3fee66f3be58ef018952d
Gitweb: https://git.kernel.org/tip/ca5d376e17072c1b60c3fee66f3be58ef018952d
Author: Dou Liyang 
AuthorDate: Sat, 28 Oct 2017 14:06:44 +0800
Committer:  Ingo Molnar 
CommitDate: Mon, 30 Oct 2017 09:17:29 +0100

x86/paravirt: Set up the virt_spin_lock_key after static keys get initialized

Commit:

  9043442b43b1 ("locking/paravirt: Use new static key for controlling call of 
virt_spin_lock()")

sets the static virt_spin_lock_key to a value before jump_label_init()
has been called, which will result in a WARN().

Reorder the initialization sequence:

 - Move the native_pv_lock_init() into native_smp_prepare_cpus()
 - set the value in xen_init_lock_cpu()

to avoid calling into the not yet initialized static keys subsystem.

Suggested-by: Juergen Gross 
Reported-by: Juergen Gross 
Signed-off-by: Dou Liyang 
Reviewed-by: Juergen Gross 
Acked-by: Thomas Gleixner 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: boris.ostrov...@oracle.com
Cc: b...@suse.de
Cc: l...@kernel.org
Cc: vkuzn...@redhat.com
Cc: xen-de...@lists.xenproject.org
Link: 
http://lkml.kernel.org/r/1509170804-3813-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/smpboot.c | 3 ++-
 arch/x86/xen/spinlock.c   | 6 --
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 361f916..198416d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1358,6 +1358,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
pr_info("CPU0: ");
print_cpu_info(_data(0));
 
+   native_pv_lock_init();
+
uv_system_init();
 
set_mtrr_aps_delayed_init();
@@ -1385,7 +1387,6 @@ void __init native_smp_prepare_boot_cpu(void)
/* already set me in cpu_online_mask in boot_cpu_init() */
cpumask_set_cpu(me, cpu_callout_mask);
cpu_set_state_online(me);
-   native_pv_lock_init();
 }
 
 void __init native_smp_cpus_done(unsigned int max_cpus)
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index e8ab80a..1e1462d 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
int irq;
char *name;
 
-   if (!xen_pvspin)
+   if (!xen_pvspin) {
+   if (cpu == 0)
+   static_branch_disable(_spin_lock_key);
return;
+   }
 
WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on 
IRQ%d!\n",
 cpu, per_cpu(lock_kicker_irq, cpu));
@@ -130,7 +133,6 @@ void __init xen_init_spinlocks(void)
 
if (!xen_pvspin) {
printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
-   static_branch_disable(_spin_lock_key);
return;
}
printk(KERN_DEBUG "xen: PV spinlocks enabled\n");


[tip:sched/core] x86/tsc: Append the 'tsc=' description for the 'tsc=unstable' boot parameter

2017-10-10 Thread tip-bot for Dou Liyang
Commit-ID:  6be53520ad8f87dc748f381e4e8e6a846a4b466b
Gitweb: https://git.kernel.org/tip/6be53520ad8f87dc748f381e4e8e6a846a4b466b
Author: Dou Liyang 
AuthorDate: Mon, 9 Oct 2017 17:03:33 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 10 Oct 2017 11:45:42 +0200

x86/tsc: Append the 'tsc=' description for the 'tsc=unstable' boot parameter

Commit:

  8309f86cd41e ("x86/tsc: Provide 'tsc=unstable' boot parameter")

added a new 'tsc=unstable' parameter, but didn't document it.

Document it.

Signed-off-by: Dou Liyang 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: 
Cc: 
Cc: 
Cc: Linus Torvalds 
Cc: Mike Galbraith 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1507539813-11420-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 0549662..6b99c8b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4194,6 +4194,9 @@
Used to run time disable IRQ_TIME_ACCOUNTING on any
platforms where RDTSC is slow and this accounting
can add overhead.
+   [x86] unstable: mark the TSC clocksource as unstable, 
this
+   marks the TSC unconditionally unstable at bootup and
+   avoids any further wobbles once the TSC watchdog 
notices.
 
turbografx.map[2|3]=[HW,JOY]
TurboGraFX parallel port interface


[tip:sched/core] x86/tsc: Append the 'tsc=' description for the 'tsc=unstable' boot parameter

2017-10-10 Thread tip-bot for Dou Liyang
Commit-ID:  6be53520ad8f87dc748f381e4e8e6a846a4b466b
Gitweb: https://git.kernel.org/tip/6be53520ad8f87dc748f381e4e8e6a846a4b466b
Author: Dou Liyang 
AuthorDate: Mon, 9 Oct 2017 17:03:33 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 10 Oct 2017 11:45:42 +0200

x86/tsc: Append the 'tsc=' description for the 'tsc=unstable' boot parameter

Commit:

  8309f86cd41e ("x86/tsc: Provide 'tsc=unstable' boot parameter")

added a new 'tsc=unstable' parameter, but didn't document it.

Document it.

Signed-off-by: Dou Liyang 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: 
Cc: 
Cc: 
Cc: Linus Torvalds 
Cc: Mike Galbraith 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1507539813-11420-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 0549662..6b99c8b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4194,6 +4194,9 @@
Used to run time disable IRQ_TIME_ACCOUNTING on any
platforms where RDTSC is slow and this accounting
can add overhead.
+   [x86] unstable: mark the TSC clocksource as unstable, 
this
+   marks the TSC unconditionally unstable at bootup and
+   avoids any further wobbles once the TSC watchdog 
notices.
 
turbografx.map[2|3]=[HW,JOY]
TurboGraFX parallel port interface


[tip:x86/urgent] x86/cpu: Remove unused and undefined __generic_processor_info() declaration

2017-09-11 Thread tip-bot for Dou Liyang
Commit-ID:  e2329b4252f373c244e75928be38bf1dd45b35da
Gitweb: http://git.kernel.org/tip/e2329b4252f373c244e75928be38bf1dd45b35da
Author: Dou Liyang 
AuthorDate: Mon, 11 Sep 2017 11:43:23 +0800
Committer:  Ingo Molnar 
CommitDate: Mon, 11 Sep 2017 08:16:37 +0200

x86/cpu: Remove unused and undefined __generic_processor_info() declaration

The following revert:

  2b85b3d22920 ("x86/acpi: Restore the order of CPU IDs")

... got rid of __generic_processor_info(), but forgot to remove its
declaration in mpspec.h.

Remove the declaration and update the comments as well.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1505101403-29100-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/mpspec.h | 1 -
 arch/x86/kernel/apic/apic.c   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index 831eb78..c471ca1 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -86,7 +86,6 @@ static inline void 
e820__memblock_alloc_reserved_mpc_new(void) { }
 #endif
 
 int generic_processor_info(int apicid, int version);
-int __generic_processor_info(int apicid, int version, bool enabled);
 
 #define PHYSID_ARRAY_SIZE  BITS_TO_LONGS(MAX_LOCAL_APIC)
 
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 7834f73..6e19ef1 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2130,7 +2130,7 @@ int generic_processor_info(int apicid, int version)
 * Since fixing handling of boot_cpu_physical_apicid requires
 * another discussion and tests on each platform, we leave it
 * for now and here we use read_apic_id() directly in this
-* function, __generic_processor_info().
+* function, generic_processor_info().
 */
if (disabled_cpu_apicid != BAD_APICID &&
disabled_cpu_apicid != read_apic_id() &&


[tip:x86/urgent] x86/cpu: Remove unused and undefined __generic_processor_info() declaration

2017-09-11 Thread tip-bot for Dou Liyang
Commit-ID:  e2329b4252f373c244e75928be38bf1dd45b35da
Gitweb: http://git.kernel.org/tip/e2329b4252f373c244e75928be38bf1dd45b35da
Author: Dou Liyang 
AuthorDate: Mon, 11 Sep 2017 11:43:23 +0800
Committer:  Ingo Molnar 
CommitDate: Mon, 11 Sep 2017 08:16:37 +0200

x86/cpu: Remove unused and undefined __generic_processor_info() declaration

The following revert:

  2b85b3d22920 ("x86/acpi: Restore the order of CPU IDs")

... got rid of __generic_processor_info(), but forgot to remove its
declaration in mpspec.h.

Remove the declaration and update the comments as well.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1505101403-29100-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/mpspec.h | 1 -
 arch/x86/kernel/apic/apic.c   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index 831eb78..c471ca1 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -86,7 +86,6 @@ static inline void 
e820__memblock_alloc_reserved_mpc_new(void) { }
 #endif
 
 int generic_processor_info(int apicid, int version);
-int __generic_processor_info(int apicid, int version, bool enabled);
 
 #define PHYSID_ARRAY_SIZE  BITS_TO_LONGS(MAX_LOCAL_APIC)
 
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 7834f73..6e19ef1 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2130,7 +2130,7 @@ int generic_processor_info(int apicid, int version)
 * Since fixing handling of boot_cpu_physical_apicid requires
 * another discussion and tests on each platform, we leave it
 * for now and here we use read_apic_id() directly in this
-* function, __generic_processor_info().
+* function, generic_processor_info().
 */
if (disabled_cpu_apicid != BAD_APICID &&
disabled_cpu_apicid != read_apic_id() &&


[tip:sched/core] x86/topology: Remove the unused parent_node() macro

2017-07-27 Thread tip-bot for Dou Liyang
Commit-ID:  dbe04493eddfaa89756ec9af8dde56206290182a
Gitweb: http://git.kernel.org/tip/dbe04493eddfaa89756ec9af8dde56206290182a
Author: Dou Liyang 
AuthorDate: Wed, 26 Jul 2017 21:34:35 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 27 Jul 2017 10:53:00 +0200

x86/topology: Remove the unused parent_node() macro

Commit:

  a7be6e5a7f8d ("mm: drop useless local parameters of __register_one_node()")

... removed the last user of parent_node(), so remove the macro.

Reported-by: Michael Ellerman 
Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1501076076-1974-11-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/topology.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 6358a85..c1d2a98 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -75,12 +75,6 @@ static inline const struct cpumask *cpumask_of_node(int node)
 
 extern void setup_node_to_cpumask_map(void);
 
-/*
- * Returns the number of the node containing Node 'node'. This
- * architecture is flat, so it is a pretty simple function!
- */
-#define parent_node(node) (node)
-
 #define pcibus_to_node(bus) __pcibus_to_node(bus)
 
 extern int __node_distance(int, int);


[tip:sched/core] x86/topology: Remove the unused parent_node() macro

2017-07-27 Thread tip-bot for Dou Liyang
Commit-ID:  dbe04493eddfaa89756ec9af8dde56206290182a
Gitweb: http://git.kernel.org/tip/dbe04493eddfaa89756ec9af8dde56206290182a
Author: Dou Liyang 
AuthorDate: Wed, 26 Jul 2017 21:34:35 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 27 Jul 2017 10:53:00 +0200

x86/topology: Remove the unused parent_node() macro

Commit:

  a7be6e5a7f8d ("mm: drop useless local parameters of __register_one_node()")

... removed the last user of parent_node(), so remove the macro.

Reported-by: Michael Ellerman 
Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1501076076-1974-11-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/topology.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 6358a85..c1d2a98 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -75,12 +75,6 @@ static inline const struct cpumask *cpumask_of_node(int node)
 
 extern void setup_node_to_cpumask_map(void);
 
-/*
- * Returns the number of the node containing Node 'node'. This
- * architecture is flat, so it is a pretty simple function!
- */
-#define parent_node(node) (node)
-
 #define pcibus_to_node(bus) __pcibus_to_node(bus)
 
 extern int __node_distance(int, int);


[tip:x86/apic] x86/apic: Make arch_init_msi/htirq_domain __init

2017-06-22 Thread tip-bot for Dou Liyang
Commit-ID:  538ac46c64a6bc61e71982091fc1eef0026f322e
Gitweb: http://git.kernel.org/tip/538ac46c64a6bc61e71982091fc1eef0026f322e
Author: Dou Liyang 
AuthorDate: Thu, 22 Jun 2017 11:15:41 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 22 Jun 2017 10:34:42 +0200

x86/apic: Make arch_init_msi/htirq_domain __init

These two functions are only called by arch_early_irq_init(), which
is an __init function, so mark them __init as well.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1498101341-10182-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/htirq.c | 2 +-
 arch/x86/kernel/apic/msi.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/htirq.c b/arch/x86/kernel/apic/htirq.c
index ae50d34..81ff489 100644
--- a/arch/x86/kernel/apic/htirq.c
+++ b/arch/x86/kernel/apic/htirq.c
@@ -150,7 +150,7 @@ static const struct irq_domain_ops htirq_domain_ops = {
.deactivate = htirq_domain_deactivate,
 };
 
-void arch_init_htirq_domain(struct irq_domain *parent)
+void __init arch_init_htirq_domain(struct irq_domain *parent)
 {
if (disable_apic)
return;
diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
index c61aec7..4c5d188 100644
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -136,7 +136,7 @@ static struct msi_domain_info pci_msi_domain_info = {
.handler_name   = "edge",
 };
 
-void arch_init_msi_domain(struct irq_domain *parent)
+void __init arch_init_msi_domain(struct irq_domain *parent)
 {
if (disable_apic)
return;


[tip:x86/apic] x86/apic: Make arch_init_msi/htirq_domain __init

2017-06-22 Thread tip-bot for Dou Liyang
Commit-ID:  538ac46c64a6bc61e71982091fc1eef0026f322e
Gitweb: http://git.kernel.org/tip/538ac46c64a6bc61e71982091fc1eef0026f322e
Author: Dou Liyang 
AuthorDate: Thu, 22 Jun 2017 11:15:41 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 22 Jun 2017 10:34:42 +0200

x86/apic: Make arch_init_msi/htirq_domain __init

These two functions are only called by arch_early_irq_init(), which
is an __init function, so mark them __init as well.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1498101341-10182-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/htirq.c | 2 +-
 arch/x86/kernel/apic/msi.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/htirq.c b/arch/x86/kernel/apic/htirq.c
index ae50d34..81ff489 100644
--- a/arch/x86/kernel/apic/htirq.c
+++ b/arch/x86/kernel/apic/htirq.c
@@ -150,7 +150,7 @@ static const struct irq_domain_ops htirq_domain_ops = {
.deactivate = htirq_domain_deactivate,
 };
 
-void arch_init_htirq_domain(struct irq_domain *parent)
+void __init arch_init_htirq_domain(struct irq_domain *parent)
 {
if (disable_apic)
return;
diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
index c61aec7..4c5d188 100644
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -136,7 +136,7 @@ static struct msi_domain_info pci_msi_domain_info = {
.handler_name   = "edge",
 };
 
-void arch_init_msi_domain(struct irq_domain *parent)
+void __init arch_init_msi_domain(struct irq_domain *parent)
 {
if (disable_apic)
return;


[tip:x86/apic] x86/apic: Make init_legacy_irqs() __init

2017-06-22 Thread tip-bot for Dou Liyang
Commit-ID:  a884d25f383133c845d23c2cce929ba15994ca62
Gitweb: http://git.kernel.org/tip/a884d25f383133c845d23c2cce929ba15994ca62
Author: Dou Liyang 
AuthorDate: Wed, 21 Jun 2017 18:14:21 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 22 Jun 2017 10:34:41 +0200

x86/apic: Make init_legacy_irqs() __init

This function is only called by arch_early_irq_init(), which is an
__init function, so mark the child function __init as well.

In addition mark it inline for the !CONFIG_X86_IO_APIC case.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1498040061-5332-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/vector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index f3557a1..e66d8e4 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -405,7 +405,7 @@ int __init arch_probe_nr_irqs(void)
 }
 
 #ifdef CONFIG_X86_IO_APIC
-static void init_legacy_irqs(void)
+static void __init init_legacy_irqs(void)
 {
int i, node = cpu_to_node(0);
struct apic_chip_data *data;
@@ -424,7 +424,7 @@ static void init_legacy_irqs(void)
}
 }
 #else
-static void init_legacy_irqs(void) { }
+static inline void init_legacy_irqs(void) { }
 #endif
 
 int __init arch_early_irq_init(void)


[tip:x86/apic] x86/apic: Make init_legacy_irqs() __init

2017-06-22 Thread tip-bot for Dou Liyang
Commit-ID:  a884d25f383133c845d23c2cce929ba15994ca62
Gitweb: http://git.kernel.org/tip/a884d25f383133c845d23c2cce929ba15994ca62
Author: Dou Liyang 
AuthorDate: Wed, 21 Jun 2017 18:14:21 +0800
Committer:  Ingo Molnar 
CommitDate: Thu, 22 Jun 2017 10:34:41 +0200

x86/apic: Make init_legacy_irqs() __init

This function is only called by arch_early_irq_init(), which is an
__init function, so mark the child function __init as well.

In addition mark it inline for the !CONFIG_X86_IO_APIC case.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1498040061-5332-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/vector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index f3557a1..e66d8e4 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -405,7 +405,7 @@ int __init arch_probe_nr_irqs(void)
 }
 
 #ifdef CONFIG_X86_IO_APIC
-static void init_legacy_irqs(void)
+static void __init init_legacy_irqs(void)
 {
int i, node = cpu_to_node(0);
struct apic_chip_data *data;
@@ -424,7 +424,7 @@ static void init_legacy_irqs(void)
}
 }
 #else
-static void init_legacy_irqs(void) { }
+static inline void init_legacy_irqs(void) { }
 #endif
 
 int __init arch_early_irq_init(void)


[tip:x86/timers] x86/time: Make setup_default_timer_irq() static

2017-06-13 Thread tip-bot for Dou Liyang
Commit-ID:  b1b4f2fe68393f80480545b5e67a50f7bda8e9a7
Gitweb: http://git.kernel.org/tip/b1b4f2fe68393f80480545b5e67a50f7bda8e9a7
Author: Dou Liyang 
AuthorDate: Tue, 13 Jun 2017 10:30:29 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 13 Jun 2017 08:42:09 +0200

x86/time: Make setup_default_timer_irq() static

This function isn't used outside of time.c, so let's mark it static.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1497321029-29049-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/setup.h | 1 -
 arch/x86/kernel/time.c   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index ac1d5da..e4585a3 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -44,7 +44,6 @@ extern unsigned long saved_video_mode;
 
 extern void reserve_standard_io_resources(void);
 extern void i386_reserve_resources(void);
-extern void setup_default_timer_irq(void);
 
 #ifdef CONFIG_X86_INTEL_MID
 extern void x86_intel_mid_early_setup(void);
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index d39c091..e0754cd 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -66,7 +66,7 @@ static struct irqaction irq0  = {
.name = "timer"
 };
 
-void __init setup_default_timer_irq(void)
+static void __init setup_default_timer_irq(void)
 {
if (!nr_legacy_irqs())
return;


[tip:x86/timers] x86/time: Make setup_default_timer_irq() static

2017-06-13 Thread tip-bot for Dou Liyang
Commit-ID:  b1b4f2fe68393f80480545b5e67a50f7bda8e9a7
Gitweb: http://git.kernel.org/tip/b1b4f2fe68393f80480545b5e67a50f7bda8e9a7
Author: Dou Liyang 
AuthorDate: Tue, 13 Jun 2017 10:30:29 +0800
Committer:  Ingo Molnar 
CommitDate: Tue, 13 Jun 2017 08:42:09 +0200

x86/time: Make setup_default_timer_irq() static

This function isn't used outside of time.c, so let's mark it static.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1497321029-29049-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/setup.h | 1 -
 arch/x86/kernel/time.c   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index ac1d5da..e4585a3 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -44,7 +44,6 @@ extern unsigned long saved_video_mode;
 
 extern void reserve_standard_io_resources(void);
 extern void i386_reserve_resources(void);
-extern void setup_default_timer_irq(void);
 
 #ifdef CONFIG_X86_INTEL_MID
 extern void x86_intel_mid_early_setup(void);
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index d39c091..e0754cd 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -66,7 +66,7 @@ static struct irqaction irq0  = {
.name = "timer"
 };
 
-void __init setup_default_timer_irq(void)
+static void __init setup_default_timer_irq(void)
 {
if (!nr_legacy_irqs())
return;


[tip:x86/cleanups] x86/irq: Remove a redundant #ifdef directive

2017-04-14 Thread tip-bot for Dou Liyang
Commit-ID:  0ccecd95e797f0c383a43278fcca74d47cd8a785
Gitweb: http://git.kernel.org/tip/0ccecd95e797f0c383a43278fcca74d47cd8a785
Author: Dou Liyang 
AuthorDate: Mon, 10 Apr 2017 16:05:00 +0800
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Apr 2017 22:43:01 +0200

x86/irq: Remove a redundant #ifdef directive

The call to irq_ctx_init() is wrapped in #ifdef CONFIG_X86_32.

The declaration of irq_ctx_init in irq.h provides already a stub inline for
the X86_32=n case.

Remove the redundant #ifdef in the code.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Link: 
http://lkml.kernel.org/r/1491811500-30307-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/irqinit.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 1423ab1..7468c69 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -195,7 +195,5 @@ void __init native_init_IRQ(void)
if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs())
setup_irq(2, );
 
-#ifdef CONFIG_X86_32
irq_ctx_init(smp_processor_id());
-#endif
 }


[tip:x86/cleanups] x86/irq: Remove a redundant #ifdef directive

2017-04-14 Thread tip-bot for Dou Liyang
Commit-ID:  0ccecd95e797f0c383a43278fcca74d47cd8a785
Gitweb: http://git.kernel.org/tip/0ccecd95e797f0c383a43278fcca74d47cd8a785
Author: Dou Liyang 
AuthorDate: Mon, 10 Apr 2017 16:05:00 +0800
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Apr 2017 22:43:01 +0200

x86/irq: Remove a redundant #ifdef directive

The call to irq_ctx_init() is wrapped in #ifdef CONFIG_X86_32.

The declaration of irq_ctx_init in irq.h provides already a stub inline for
the X86_32=n case.

Remove the redundant #ifdef in the code.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Link: 
http://lkml.kernel.org/r/1491811500-30307-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/irqinit.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 1423ab1..7468c69 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -195,7 +195,5 @@ void __init native_init_IRQ(void)
if (!acpi_ioapic && !of_ioapic && nr_legacy_irqs())
setup_irq(2, );
 
-#ifdef CONFIG_X86_32
irq_ctx_init(smp_processor_id());
-#endif
 }


[tip:x86/cleanups] x86/smp: Remove the redundant #ifdef CONFIG_SMP directive

2017-04-14 Thread tip-bot for Dou Liyang
Commit-ID:  7b6e106276fcc803e397f9b1bd4c272055c7cf5a
Gitweb: http://git.kernel.org/tip/7b6e106276fcc803e397f9b1bd4c272055c7cf5a
Author: Dou Liyang 
AuthorDate: Sun, 9 Apr 2017 18:46:46 +0800
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Apr 2017 22:43:00 +0200

x86/smp: Remove the redundant #ifdef CONFIG_SMP directive

The !CONFIG_X86_LOCAL_APIC section in smp.h wraps the define of
hard_smp_processor_id() into #ifndef CONFIG_SMP. But Kconfig has:

  config X86_LOCAL_APIC
def_bool y
depends on X86_64 || SMP || X86_32_NON_STANDARD ...

Therefore SMP can't be 'y' when X86_LOCAL_APIC == 'n'.

Remove the redundant #ifndef CONFIG_SMP.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Cc: jaswin...@infradead.org
Link: 
http://lkml.kernel.org/r/1491734806-15413-2-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/smp.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index f64aaa7..47103ec 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -188,11 +188,7 @@ static inline int logical_smp_processor_id(void)
 extern int hard_smp_processor_id(void);
 
 #else /* CONFIG_X86_LOCAL_APIC */
-
-# ifndef CONFIG_SMP
-#  define hard_smp_processor_id()  0
-# endif
-
+#define hard_smp_processor_id()0
 #endif /* CONFIG_X86_LOCAL_APIC */
 
 #ifdef CONFIG_DEBUG_NMI_SELFTEST


[tip:x86/cleanups] x86/smp: Remove the redundant #ifdef CONFIG_SMP directive

2017-04-14 Thread tip-bot for Dou Liyang
Commit-ID:  7b6e106276fcc803e397f9b1bd4c272055c7cf5a
Gitweb: http://git.kernel.org/tip/7b6e106276fcc803e397f9b1bd4c272055c7cf5a
Author: Dou Liyang 
AuthorDate: Sun, 9 Apr 2017 18:46:46 +0800
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Apr 2017 22:43:00 +0200

x86/smp: Remove the redundant #ifdef CONFIG_SMP directive

The !CONFIG_X86_LOCAL_APIC section in smp.h wraps the define of
hard_smp_processor_id() into #ifndef CONFIG_SMP. But Kconfig has:

  config X86_LOCAL_APIC
def_bool y
depends on X86_64 || SMP || X86_32_NON_STANDARD ...

Therefore SMP can't be 'y' when X86_LOCAL_APIC == 'n'.

Remove the redundant #ifndef CONFIG_SMP.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Cc: jaswin...@infradead.org
Link: 
http://lkml.kernel.org/r/1491734806-15413-2-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/smp.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index f64aaa7..47103ec 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -188,11 +188,7 @@ static inline int logical_smp_processor_id(void)
 extern int hard_smp_processor_id(void);
 
 #else /* CONFIG_X86_LOCAL_APIC */
-
-# ifndef CONFIG_SMP
-#  define hard_smp_processor_id()  0
-# endif
-
+#define hard_smp_processor_id()0
 #endif /* CONFIG_X86_LOCAL_APIC */
 
 #ifdef CONFIG_DEBUG_NMI_SELFTEST


[tip:x86/cleanups] x86/smp: Reduce code duplication

2017-04-14 Thread tip-bot for Dou Liyang
Commit-ID:  0f08c3b22996c91cff62c96cf4b3db88902e12a9
Gitweb: http://git.kernel.org/tip/0f08c3b22996c91cff62c96cf4b3db88902e12a9
Author: Dou Liyang 
AuthorDate: Sun, 9 Apr 2017 18:46:45 +0800
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Apr 2017 22:43:00 +0200

x86/smp: Reduce code duplication

The CONFIG_X86_32_SMP and CONFIG_X86_64_SMP sections in smp.h contain
duplicate defines.

Merge them and only put the difference into an #ifdeff'ed section.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Cc: jaswin...@infradead.org
Link: 
http://lkml.kernel.org/r/1491734806-15413-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/smp.h | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 026ea82..f64aaa7 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -149,6 +149,19 @@ void smp_store_cpu_info(int id);
 #define cpu_physical_id(cpu)   per_cpu(x86_cpu_to_apicid, cpu)
 #define cpu_acpi_id(cpu)   per_cpu(x86_cpu_to_acpiid, cpu)
 
+/*
+ * This function is needed by all SMP systems. It must _always_ be valid
+ * from the initial startup. We map APIC_BASE very early in page_setup(),
+ * so this is correct in the x86 case.
+ */
+#define raw_smp_processor_id() (this_cpu_read(cpu_number))
+
+#ifdef CONFIG_X86_32
+extern int safe_smp_processor_id(void);
+#else
+# define safe_smp_processor_id()   smp_processor_id()
+#endif
+
 #else /* !CONFIG_SMP */
 #define wbinvd_on_cpu(cpu) wbinvd()
 static inline int wbinvd_on_all_cpus(void)
@@ -161,22 +174,6 @@ static inline int wbinvd_on_all_cpus(void)
 
 extern unsigned disabled_cpus;
 
-#ifdef CONFIG_X86_32_SMP
-/*
- * This function is needed by all SMP systems. It must _always_ be valid
- * from the initial startup. We map APIC_BASE very early in page_setup(),
- * so this is correct in the x86 case.
- */
-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
-extern int safe_smp_processor_id(void);
-
-#elif defined(CONFIG_X86_64_SMP)
-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
-
-#define safe_smp_processor_id()smp_processor_id()
-
-#endif
-
 #ifdef CONFIG_X86_LOCAL_APIC
 
 #ifndef CONFIG_X86_64


[tip:x86/cleanups] x86/smp: Reduce code duplication

2017-04-14 Thread tip-bot for Dou Liyang
Commit-ID:  0f08c3b22996c91cff62c96cf4b3db88902e12a9
Gitweb: http://git.kernel.org/tip/0f08c3b22996c91cff62c96cf4b3db88902e12a9
Author: Dou Liyang 
AuthorDate: Sun, 9 Apr 2017 18:46:45 +0800
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Apr 2017 22:43:00 +0200

x86/smp: Reduce code duplication

The CONFIG_X86_32_SMP and CONFIG_X86_64_SMP sections in smp.h contain
duplicate defines.

Merge them and only put the difference into an #ifdeff'ed section.

[ tglx: Massaged changelog ]

Signed-off-by: Dou Liyang 
Cc: jaswin...@infradead.org
Link: 
http://lkml.kernel.org/r/1491734806-15413-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/smp.h | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 026ea82..f64aaa7 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -149,6 +149,19 @@ void smp_store_cpu_info(int id);
 #define cpu_physical_id(cpu)   per_cpu(x86_cpu_to_apicid, cpu)
 #define cpu_acpi_id(cpu)   per_cpu(x86_cpu_to_acpiid, cpu)
 
+/*
+ * This function is needed by all SMP systems. It must _always_ be valid
+ * from the initial startup. We map APIC_BASE very early in page_setup(),
+ * so this is correct in the x86 case.
+ */
+#define raw_smp_processor_id() (this_cpu_read(cpu_number))
+
+#ifdef CONFIG_X86_32
+extern int safe_smp_processor_id(void);
+#else
+# define safe_smp_processor_id()   smp_processor_id()
+#endif
+
 #else /* !CONFIG_SMP */
 #define wbinvd_on_cpu(cpu) wbinvd()
 static inline int wbinvd_on_all_cpus(void)
@@ -161,22 +174,6 @@ static inline int wbinvd_on_all_cpus(void)
 
 extern unsigned disabled_cpus;
 
-#ifdef CONFIG_X86_32_SMP
-/*
- * This function is needed by all SMP systems. It must _always_ be valid
- * from the initial startup. We map APIC_BASE very early in page_setup(),
- * so this is correct in the x86 case.
- */
-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
-extern int safe_smp_processor_id(void);
-
-#elif defined(CONFIG_X86_64_SMP)
-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
-
-#define safe_smp_processor_id()smp_processor_id()
-
-#endif
-
 #ifdef CONFIG_X86_LOCAL_APIC
 
 #ifndef CONFIG_X86_64


[tip:x86/apic] x86/apic: Fix a comment in init_apic_mappings()

2017-03-13 Thread tip-bot for Dou Liyang
Commit-ID:  5ba039a55498d78a787edaf8cc915f29a17cecf3
Gitweb: http://git.kernel.org/tip/5ba039a55498d78a787edaf8cc915f29a17cecf3
Author: Dou Liyang 
AuthorDate: Mon, 6 Mar 2017 21:08:10 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Mar 2017 21:42:11 +0100

x86/apic: Fix a comment in init_apic_mappings()

commit c0104d38a740 ("x86, apic: Unify identical register_lapic_address()
functions") renames acpi_register_lapic_address to register_lapic_address.

But acpi_register_lapic_address remains in a comment, and renaming it to
register_lapic_address is not suitable for this comment.

Remove acpi_register_lapic_address and rewrite the comment.

[ tglx: LAPIC address can be registered either by ACPI/MADT or MP info ]

Signed-off-by: Dou Liyang 
Cc: ying...@kernel.org
Link: 
http://lkml.kernel.org/r/1488805690-5055-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index f3034ba..192e909 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1789,8 +1789,8 @@ void __init init_apic_mappings(void)
apic_phys = mp_lapic_addr;
 
/*
-* acpi lapic path already maps that address in
-* acpi_register_lapic_address()
+* If the system has ACPI MADT tables or MP info, the LAPIC
+* address is already registered.
 */
if (!acpi_lapic && !smp_found_config)
register_lapic_address(apic_phys);


[tip:x86/apic] x86/apic: Fix a comment in init_apic_mappings()

2017-03-13 Thread tip-bot for Dou Liyang
Commit-ID:  5ba039a55498d78a787edaf8cc915f29a17cecf3
Gitweb: http://git.kernel.org/tip/5ba039a55498d78a787edaf8cc915f29a17cecf3
Author: Dou Liyang 
AuthorDate: Mon, 6 Mar 2017 21:08:10 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Mar 2017 21:42:11 +0100

x86/apic: Fix a comment in init_apic_mappings()

commit c0104d38a740 ("x86, apic: Unify identical register_lapic_address()
functions") renames acpi_register_lapic_address to register_lapic_address.

But acpi_register_lapic_address remains in a comment, and renaming it to
register_lapic_address is not suitable for this comment.

Remove acpi_register_lapic_address and rewrite the comment.

[ tglx: LAPIC address can be registered either by ACPI/MADT or MP info ]

Signed-off-by: Dou Liyang 
Cc: ying...@kernel.org
Link: 
http://lkml.kernel.org/r/1488805690-5055-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index f3034ba..192e909 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1789,8 +1789,8 @@ void __init init_apic_mappings(void)
apic_phys = mp_lapic_addr;
 
/*
-* acpi lapic path already maps that address in
-* acpi_register_lapic_address()
+* If the system has ACPI MADT tables or MP info, the LAPIC
+* address is already registered.
 */
if (!acpi_lapic && !smp_found_config)
register_lapic_address(apic_phys);


[tip:timers/core] x86/apic: Fix a comment in init_apic_mappings()

2017-03-13 Thread tip-bot for Dou Liyang
Commit-ID:  ad258524b64756834f5fe23620beedb7c3609dc8
Gitweb: http://git.kernel.org/tip/ad258524b64756834f5fe23620beedb7c3609dc8
Author: Dou Liyang 
AuthorDate: Mon, 6 Mar 2017 21:08:10 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Mar 2017 21:40:14 +0100

x86/apic: Fix a comment in init_apic_mappings()

commit c0104d38a740 ("x86, apic: Unify identical register_lapic_address()
functions") renames acpi_register_lapic_address to register_lapic_address.

But acpi_register_lapic_address remains in a comment, and renaming it to
register_lapic_address is not suitable for this comment.

Remove acpi_register_lapic_address and rewrite the comment.

[ tglx: LAPIC address can be registered either by ACPI/MADT or MP info ]

Signed-off-by: Dou Liyang 
Cc: ying...@kernel.org
Link: 
http://lkml.kernel.org/r/1488805690-5055-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aee7ded..100c43f 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1789,8 +1789,8 @@ void __init init_apic_mappings(void)
apic_phys = mp_lapic_addr;
 
/*
-* acpi lapic path already maps that address in
-* acpi_register_lapic_address()
+* If the system has ACPI MADT tables or MP info, the LAPIC
+* address is already registered.
 */
if (!acpi_lapic && !smp_found_config)
register_lapic_address(apic_phys);


[tip:timers/core] x86/apic: Fix a comment in init_apic_mappings()

2017-03-13 Thread tip-bot for Dou Liyang
Commit-ID:  ad258524b64756834f5fe23620beedb7c3609dc8
Gitweb: http://git.kernel.org/tip/ad258524b64756834f5fe23620beedb7c3609dc8
Author: Dou Liyang 
AuthorDate: Mon, 6 Mar 2017 21:08:10 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Mar 2017 21:40:14 +0100

x86/apic: Fix a comment in init_apic_mappings()

commit c0104d38a740 ("x86, apic: Unify identical register_lapic_address()
functions") renames acpi_register_lapic_address to register_lapic_address.

But acpi_register_lapic_address remains in a comment, and renaming it to
register_lapic_address is not suitable for this comment.

Remove acpi_register_lapic_address and rewrite the comment.

[ tglx: LAPIC address can be registered either by ACPI/MADT or MP info ]

Signed-off-by: Dou Liyang 
Cc: ying...@kernel.org
Link: 
http://lkml.kernel.org/r/1488805690-5055-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/apic/apic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aee7ded..100c43f 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1789,8 +1789,8 @@ void __init init_apic_mappings(void)
apic_phys = mp_lapic_addr;
 
/*
-* acpi lapic path already maps that address in
-* acpi_register_lapic_address()
+* If the system has ACPI MADT tables or MP info, the LAPIC
+* address is already registered.
 */
if (!acpi_lapic && !smp_found_config)
register_lapic_address(apic_phys);


[tip:x86/apic] x86/apic: Remove the SET_APIC_ID(x) macro

2017-03-13 Thread tip-bot for Dou Liyang
Commit-ID:  5d64d209c4f672e221ea304106b30793f10d95a4
Gitweb: http://git.kernel.org/tip/5d64d209c4f672e221ea304106b30793f10d95a4
Author: Dou Liyang 
AuthorDate: Wed, 8 Mar 2017 19:07:50 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Mar 2017 21:28:38 +0100

x86/apic: Remove the SET_APIC_ID(x) macro

The SET_APIC_ID() macro obfusates the code. Remove it to increase
readability and add a comment to the apic struct to document that the
callback is required on 64-bit.

Signed-off-by: Dou Liyang 
Link: 
http://lkml.kernel.org/r/1488971270-14359-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/apic.h | 7 +--
 arch/x86/kernel/apic/apic.c | 2 +-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 730ef65..bdffcd9 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -252,12 +252,6 @@ static inline int x2apic_enabled(void) { return 0; }
 #definex2apic_supported()  (0)
 #endif /* !CONFIG_X86_X2APIC */
 
-#ifdef CONFIG_X86_64
-#defineSET_APIC_ID(x)  (apic->set_apic_id(x))
-#else
-
-#endif
-
 /*
  * Copyright 2004 James Cleverdon, IBM.
  * Subject to the GNU Public License, v.2
@@ -299,6 +293,7 @@ struct apic {
int (*phys_pkg_id)(int cpuid_apic, int index_msb);
 
unsigned int (*get_apic_id)(unsigned long x);
+   /* Can't be NULL on 64-bit */
unsigned long (*set_apic_id)(unsigned int id);
 
int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aee7ded..f3034ba 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2249,7 +2249,7 @@ void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, 
u32 v))
 static void __init apic_bsp_up_setup(void)
 {
 #ifdef CONFIG_X86_64
-   apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid));
+   apic_write(APIC_ID, apic->set_apic_id(boot_cpu_physical_apicid));
 #else
/*
 * Hack: In case of kdump, after a crash, kernel might be booting


[tip:x86/apic] x86/apic: Remove the SET_APIC_ID(x) macro

2017-03-13 Thread tip-bot for Dou Liyang
Commit-ID:  5d64d209c4f672e221ea304106b30793f10d95a4
Gitweb: http://git.kernel.org/tip/5d64d209c4f672e221ea304106b30793f10d95a4
Author: Dou Liyang 
AuthorDate: Wed, 8 Mar 2017 19:07:50 +0800
Committer:  Thomas Gleixner 
CommitDate: Mon, 13 Mar 2017 21:28:38 +0100

x86/apic: Remove the SET_APIC_ID(x) macro

The SET_APIC_ID() macro obfusates the code. Remove it to increase
readability and add a comment to the apic struct to document that the
callback is required on 64-bit.

Signed-off-by: Dou Liyang 
Link: 
http://lkml.kernel.org/r/1488971270-14359-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/include/asm/apic.h | 7 +--
 arch/x86/kernel/apic/apic.c | 2 +-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 730ef65..bdffcd9 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -252,12 +252,6 @@ static inline int x2apic_enabled(void) { return 0; }
 #definex2apic_supported()  (0)
 #endif /* !CONFIG_X86_X2APIC */
 
-#ifdef CONFIG_X86_64
-#defineSET_APIC_ID(x)  (apic->set_apic_id(x))
-#else
-
-#endif
-
 /*
  * Copyright 2004 James Cleverdon, IBM.
  * Subject to the GNU Public License, v.2
@@ -299,6 +293,7 @@ struct apic {
int (*phys_pkg_id)(int cpuid_apic, int index_msb);
 
unsigned int (*get_apic_id)(unsigned long x);
+   /* Can't be NULL on 64-bit */
unsigned long (*set_apic_id)(unsigned int id);
 
int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aee7ded..f3034ba 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2249,7 +2249,7 @@ void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, 
u32 v))
 static void __init apic_bsp_up_setup(void)
 {
 #ifdef CONFIG_X86_64
-   apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid));
+   apic_write(APIC_ID, apic->set_apic_id(boot_cpu_physical_apicid));
 #else
/*
 * Hack: In case of kdump, after a crash, kernel might be booting


[tip:x86/acpi] acpi/processor: Check for duplicate processor ids at hotplug time

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  a77d6cd968497792e072b74dff45b891ba778ddb
Gitweb: http://git.kernel.org/tip/a77d6cd968497792e072b74dff45b891ba778ddb
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:27 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:20 +0100

acpi/processor: Check for duplicate processor ids at hotplug time

The check for duplicate processor ids happens at boot time based on the
ACPI table contents, but the final sanity checks for a processor happen
at hotplug time.

At hotplug time, where the physical information is available, which might
differ from the ACPI table information, a check for duplicate processor
ids is missing.

Add it to the hotplug checks and rename the function so it better
reflects its purpose.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-6-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 drivers/acpi/acpi_processor.c | 13 ++---
 include/linux/acpi.h  |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 9a98d7e..0143135 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -280,6 +280,13 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
pr->acpi_id = value;
}
 
+   if (acpi_duplicate_processor_id(pr->acpi_id)) {
+   dev_err(>dev,
+   "Failed to get unique processor _UID (0x%x)\n",
+   pr->acpi_id);
+   return -ENODEV;
+   }
+
pr->phys_id = acpi_get_phys_id(pr->handle, device_declaration,
pr->acpi_id);
if (invalid_phys_cpuid(pr->phys_id))
@@ -580,7 +587,7 @@ static struct acpi_scan_handler processor_container_handler 
= {
 static int nr_unique_ids __initdata;
 
 /* The number of the duplicate processor IDs */
-static int nr_duplicate_ids __initdata;
+static int nr_duplicate_ids;
 
 /* Used to store the unique processor IDs */
 static int unique_processor_ids[] __initdata = {
@@ -588,7 +595,7 @@ static int unique_processor_ids[] __initdata = {
 };
 
 /* Used to store the duplicate processor IDs */
-static int duplicate_processor_ids[] __initdata = {
+static int duplicate_processor_ids[] = {
[0 ... NR_CPUS - 1] = -1,
 };
 
@@ -679,7 +686,7 @@ void __init acpi_processor_check_duplicates(void)
NULL, NULL);
 }
 
-bool __init acpi_processor_validate_proc_id(int proc_id)
+bool acpi_duplicate_processor_id(int proc_id)
 {
int i;
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 63a7519..9b05886 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -287,7 +287,7 @@ static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id)
 }
 
 /* Validate the processor object's proc_id */
-bool acpi_processor_validate_proc_id(int proc_id);
+bool acpi_duplicate_processor_id(int proc_id);
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 /* Arch dependent functions for cpu hotplug support */


[tip:x86/acpi] acpi/processor: Check for duplicate processor ids at hotplug time

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  a77d6cd968497792e072b74dff45b891ba778ddb
Gitweb: http://git.kernel.org/tip/a77d6cd968497792e072b74dff45b891ba778ddb
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:27 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:20 +0100

acpi/processor: Check for duplicate processor ids at hotplug time

The check for duplicate processor ids happens at boot time based on the
ACPI table contents, but the final sanity checks for a processor happen
at hotplug time.

At hotplug time, where the physical information is available, which might
differ from the ACPI table information, a check for duplicate processor
ids is missing.

Add it to the hotplug checks and rename the function so it better
reflects its purpose.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-6-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 drivers/acpi/acpi_processor.c | 13 ++---
 include/linux/acpi.h  |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 9a98d7e..0143135 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -280,6 +280,13 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
pr->acpi_id = value;
}
 
+   if (acpi_duplicate_processor_id(pr->acpi_id)) {
+   dev_err(>dev,
+   "Failed to get unique processor _UID (0x%x)\n",
+   pr->acpi_id);
+   return -ENODEV;
+   }
+
pr->phys_id = acpi_get_phys_id(pr->handle, device_declaration,
pr->acpi_id);
if (invalid_phys_cpuid(pr->phys_id))
@@ -580,7 +587,7 @@ static struct acpi_scan_handler processor_container_handler 
= {
 static int nr_unique_ids __initdata;
 
 /* The number of the duplicate processor IDs */
-static int nr_duplicate_ids __initdata;
+static int nr_duplicate_ids;
 
 /* Used to store the unique processor IDs */
 static int unique_processor_ids[] __initdata = {
@@ -588,7 +595,7 @@ static int unique_processor_ids[] __initdata = {
 };
 
 /* Used to store the duplicate processor IDs */
-static int duplicate_processor_ids[] __initdata = {
+static int duplicate_processor_ids[] = {
[0 ... NR_CPUS - 1] = -1,
 };
 
@@ -679,7 +686,7 @@ void __init acpi_processor_check_duplicates(void)
NULL, NULL);
 }
 
-bool __init acpi_processor_validate_proc_id(int proc_id)
+bool acpi_duplicate_processor_id(int proc_id)
 {
int i;
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 63a7519..9b05886 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -287,7 +287,7 @@ static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id)
 }
 
 /* Validate the processor object's proc_id */
-bool acpi_processor_validate_proc_id(int proc_id);
+bool acpi_duplicate_processor_id(int proc_id);
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 /* Arch dependent functions for cpu hotplug support */


[tip:x86/acpi] acpi/processor: Implement DEVICE operator for processor enumeration

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  8c8cb30f49b86333d8e036e1945cf1a78c03577e
Gitweb: http://git.kernel.org/tip/8c8cb30f49b86333d8e036e1945cf1a78c03577e
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:26 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:20 +0100

acpi/processor: Implement DEVICE operator for processor enumeration

ACPI allows to declare processors either with the PROCESSOR or with the
DEVICE operator. The current implementation handles only the PROCESSOR
operator.

On a system which uses the DEVICE operator for processor enumeration the
evaluation fails.

Check for the ACPI type of the ACPI handle and evaluate PROCESSOR and
DEVICE types separately.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-5-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 drivers/acpi/acpi_processor.c | 39 ---
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 5d208a9..9a98d7e 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -633,25 +633,50 @@ static acpi_status __init 
acpi_processor_ids_walk(acpi_handle handle,
  void **rv)
 {
acpi_status status;
+   acpi_object_type acpi_type;
+   unsigned long long uid;
union acpi_object object = { 0 };
struct acpi_buffer buffer = { sizeof(union acpi_object),  };
 
-   status = acpi_evaluate_object(handle, NULL, NULL, );
+   status = acpi_get_type(handle, _type);
if (ACPI_FAILURE(status))
-   acpi_handle_info(handle, "Not get the processor object\n");
-   else
-   processor_validated_ids_update(object.processor.proc_id);
+   return false;
+
+   switch (acpi_type) {
+   case ACPI_TYPE_PROCESSOR:
+   status = acpi_evaluate_object(handle, NULL, NULL, );
+   if (ACPI_FAILURE(status))
+   goto err;
+   uid = object.processor.proc_id;
+   break;
+
+   case ACPI_TYPE_DEVICE:
+   status = acpi_evaluate_integer(handle, "_UID", NULL, );
+   if (ACPI_FAILURE(status))
+   goto err;
+   break;
+   default:
+   goto err;
+   }
+
+   processor_validated_ids_update(uid);
+   return true;
+
+err:
+   acpi_handle_info(handle, "Invalid processor object\n");
+   return false;
 
-   return AE_OK;
 }
 
-static void __init acpi_processor_check_duplicates(void)
+void __init acpi_processor_check_duplicates(void)
 {
-   /* Search all processor nodes in ACPI namespace */
+   /* check the correctness for all processors in ACPI namespace */
acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
acpi_processor_ids_walk,
NULL, NULL, NULL);
+   acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk,
+   NULL, NULL);
 }
 
 bool __init acpi_processor_validate_proc_id(int proc_id)


[tip:x86/acpi] acpi/processor: Implement DEVICE operator for processor enumeration

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  8c8cb30f49b86333d8e036e1945cf1a78c03577e
Gitweb: http://git.kernel.org/tip/8c8cb30f49b86333d8e036e1945cf1a78c03577e
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:26 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:20 +0100

acpi/processor: Implement DEVICE operator for processor enumeration

ACPI allows to declare processors either with the PROCESSOR or with the
DEVICE operator. The current implementation handles only the PROCESSOR
operator.

On a system which uses the DEVICE operator for processor enumeration the
evaluation fails.

Check for the ACPI type of the ACPI handle and evaluate PROCESSOR and
DEVICE types separately.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-5-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 drivers/acpi/acpi_processor.c | 39 ---
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 5d208a9..9a98d7e 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -633,25 +633,50 @@ static acpi_status __init 
acpi_processor_ids_walk(acpi_handle handle,
  void **rv)
 {
acpi_status status;
+   acpi_object_type acpi_type;
+   unsigned long long uid;
union acpi_object object = { 0 };
struct acpi_buffer buffer = { sizeof(union acpi_object),  };
 
-   status = acpi_evaluate_object(handle, NULL, NULL, );
+   status = acpi_get_type(handle, _type);
if (ACPI_FAILURE(status))
-   acpi_handle_info(handle, "Not get the processor object\n");
-   else
-   processor_validated_ids_update(object.processor.proc_id);
+   return false;
+
+   switch (acpi_type) {
+   case ACPI_TYPE_PROCESSOR:
+   status = acpi_evaluate_object(handle, NULL, NULL, );
+   if (ACPI_FAILURE(status))
+   goto err;
+   uid = object.processor.proc_id;
+   break;
+
+   case ACPI_TYPE_DEVICE:
+   status = acpi_evaluate_integer(handle, "_UID", NULL, );
+   if (ACPI_FAILURE(status))
+   goto err;
+   break;
+   default:
+   goto err;
+   }
+
+   processor_validated_ids_update(uid);
+   return true;
+
+err:
+   acpi_handle_info(handle, "Invalid processor object\n");
+   return false;
 
-   return AE_OK;
 }
 
-static void __init acpi_processor_check_duplicates(void)
+void __init acpi_processor_check_duplicates(void)
 {
-   /* Search all processor nodes in ACPI namespace */
+   /* check the correctness for all processors in ACPI namespace */
acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
acpi_processor_ids_walk,
NULL, NULL, NULL);
+   acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk,
+   NULL, NULL);
 }
 
 bool __init acpi_processor_validate_proc_id(int proc_id)


[tip:x86/acpi] Revert"x86/acpi: Enable MADT APIs to return disabled apicids"

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  09c3f2bd5c7e5f18687663acb6adc6b167484ca5
Gitweb: http://git.kernel.org/tip/09c3f2bd5c7e5f18687663acb6adc6b167484ca5
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:24 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:18 +0100

Revert"x86/acpi: Enable MADT APIs to return disabled apicids"

Revert: 8ad893faf2ea ("x86/acpi: Enable MADT APIs to return disabled apicids")

Remove the leftovers of the boot time 'cpuid <-> nodeid' mapping approach.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-3-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 drivers/acpi/processor_core.c | 60 ---
 1 file changed, 22 insertions(+), 38 deletions(-)

diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a843862..b933061 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -32,12 +32,12 @@ static struct acpi_table_madt *get_madt_table(void)
 }
 
 static int map_lapic_id(struct acpi_subtable_header *entry,
-u32 acpi_id, phys_cpuid_t *apic_id, bool ignore_disabled)
+u32 acpi_id, phys_cpuid_t *apic_id)
 {
struct acpi_madt_local_apic *lapic =
container_of(entry, struct acpi_madt_local_apic, header);
 
-   if (ignore_disabled && !(lapic->lapic_flags & ACPI_MADT_ENABLED))
+   if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
if (lapic->processor_id != acpi_id)
@@ -48,13 +48,12 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
 }
 
 static int map_x2apic_id(struct acpi_subtable_header *entry,
-   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id,
-   bool ignore_disabled)
+   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
 {
struct acpi_madt_local_x2apic *apic =
container_of(entry, struct acpi_madt_local_x2apic, header);
 
-   if (ignore_disabled && !(apic->lapic_flags & ACPI_MADT_ENABLED))
+   if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
if (device_declaration && (apic->uid == acpi_id)) {
@@ -66,13 +65,12 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
 }
 
 static int map_lsapic_id(struct acpi_subtable_header *entry,
-   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id,
-   bool ignore_disabled)
+   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
 {
struct acpi_madt_local_sapic *lsapic =
container_of(entry, struct acpi_madt_local_sapic, header);
 
-   if (ignore_disabled && !(lsapic->lapic_flags & ACPI_MADT_ENABLED))
+   if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
if (device_declaration) {
@@ -89,13 +87,12 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
  * Retrieve the ARM CPU physical identifier (MPIDR)
  */
 static int map_gicc_mpidr(struct acpi_subtable_header *entry,
-   int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr,
-   bool ignore_disabled)
+   int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr)
 {
struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
 
-   if (ignore_disabled && !(gicc->flags & ACPI_MADT_ENABLED))
+   if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
/* device_declaration means Device object in DSDT, in the
@@ -112,7 +109,7 @@ static int map_gicc_mpidr(struct acpi_subtable_header 
*entry,
 }
 
 static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt,
-  int type, u32 acpi_id, bool ignore_disabled)
+  int type, u32 acpi_id)
 {
unsigned long madt_end, entry;
phys_cpuid_t phys_id = PHYS_CPUID_INVALID;  /* CPU hardware ID */
@@ -130,20 +127,16 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt 
*madt,
struct acpi_subtable_header *header =
(struct acpi_subtable_header *)entry;
if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
-   if (!map_lapic_id(header, acpi_id, _id,
- ignore_disabled))
+   if (!map_lapic_id(header, acpi_id, _id))
break;
} else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) {
-   if (!map_x2apic_id(header, type, acpi_id, _id,
- 

[tip:x86/acpi] Revert"x86/acpi: Enable MADT APIs to return disabled apicids"

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  09c3f2bd5c7e5f18687663acb6adc6b167484ca5
Gitweb: http://git.kernel.org/tip/09c3f2bd5c7e5f18687663acb6adc6b167484ca5
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:24 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:18 +0100

Revert"x86/acpi: Enable MADT APIs to return disabled apicids"

Revert: 8ad893faf2ea ("x86/acpi: Enable MADT APIs to return disabled apicids")

Remove the leftovers of the boot time 'cpuid <-> nodeid' mapping approach.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-3-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 drivers/acpi/processor_core.c | 60 ---
 1 file changed, 22 insertions(+), 38 deletions(-)

diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a843862..b933061 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -32,12 +32,12 @@ static struct acpi_table_madt *get_madt_table(void)
 }
 
 static int map_lapic_id(struct acpi_subtable_header *entry,
-u32 acpi_id, phys_cpuid_t *apic_id, bool ignore_disabled)
+u32 acpi_id, phys_cpuid_t *apic_id)
 {
struct acpi_madt_local_apic *lapic =
container_of(entry, struct acpi_madt_local_apic, header);
 
-   if (ignore_disabled && !(lapic->lapic_flags & ACPI_MADT_ENABLED))
+   if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
if (lapic->processor_id != acpi_id)
@@ -48,13 +48,12 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
 }
 
 static int map_x2apic_id(struct acpi_subtable_header *entry,
-   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id,
-   bool ignore_disabled)
+   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
 {
struct acpi_madt_local_x2apic *apic =
container_of(entry, struct acpi_madt_local_x2apic, header);
 
-   if (ignore_disabled && !(apic->lapic_flags & ACPI_MADT_ENABLED))
+   if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
if (device_declaration && (apic->uid == acpi_id)) {
@@ -66,13 +65,12 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
 }
 
 static int map_lsapic_id(struct acpi_subtable_header *entry,
-   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id,
-   bool ignore_disabled)
+   int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
 {
struct acpi_madt_local_sapic *lsapic =
container_of(entry, struct acpi_madt_local_sapic, header);
 
-   if (ignore_disabled && !(lsapic->lapic_flags & ACPI_MADT_ENABLED))
+   if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
if (device_declaration) {
@@ -89,13 +87,12 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
  * Retrieve the ARM CPU physical identifier (MPIDR)
  */
 static int map_gicc_mpidr(struct acpi_subtable_header *entry,
-   int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr,
-   bool ignore_disabled)
+   int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr)
 {
struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
 
-   if (ignore_disabled && !(gicc->flags & ACPI_MADT_ENABLED))
+   if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
 
/* device_declaration means Device object in DSDT, in the
@@ -112,7 +109,7 @@ static int map_gicc_mpidr(struct acpi_subtable_header 
*entry,
 }
 
 static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt,
-  int type, u32 acpi_id, bool ignore_disabled)
+  int type, u32 acpi_id)
 {
unsigned long madt_end, entry;
phys_cpuid_t phys_id = PHYS_CPUID_INVALID;  /* CPU hardware ID */
@@ -130,20 +127,16 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt 
*madt,
struct acpi_subtable_header *header =
(struct acpi_subtable_header *)entry;
if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
-   if (!map_lapic_id(header, acpi_id, _id,
- ignore_disabled))
+   if (!map_lapic_id(header, acpi_id, _id))
break;
} else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) {
-   if (!map_x2apic_id(header, type, acpi_id, _id,
-  ignore_disabled))
+   if (!map_x2apic_id(header, type, acpi_id, _id))
  

[tip:x86/acpi] x86/acpi: Restore the order of CPU IDs

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  2b85b3d22920db7473e5fed5719e7955c0ec323e
Gitweb: http://git.kernel.org/tip/2b85b3d22920db7473e5fed5719e7955c0ec323e
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:25 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:19 +0100

x86/acpi: Restore the order of CPU IDs

The following commits:

  f7c28833c2 ("x86/acpi: Enable acpi to register all possible cpus at
boot time") and 8f54969dc8 ("x86/acpi: Introduce persistent storage
for cpuid <-> apicid mapping")

... registered all the possible CPUs at boot time via ACPI tables to
make the mapping of cpuid <-> apicid fixed. Both enabled and disabled
CPUs could have a logical CPU ID after boot time.

But, ACPI tables are unreliable. the number amd order of Local APIC
entries which depends on the firmware is often inconsistent with the
physical devices. Even if they are consistent, The disabled CPUs which
take up some logical CPU IDs will also make the order discontinuous.

Revert the part of disabled CPUs registration, keep the allocation
logic of logical CPU IDs and also keep some code location changes.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-4-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/acpi/boot.c |  7 ++-
 arch/x86/kernel/apic/apic.c | 26 +++---
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index f6b0e87..b2879cc23 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -179,10 +179,15 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 
enabled)
return -EINVAL;
}
 
+   if (!enabled) {
+   ++disabled_cpus;
+   return -EINVAL;
+   }
+
if (boot_cpu_physical_apicid != -1U)
ver = boot_cpu_apic_version;
 
-   cpu = __generic_processor_info(id, ver, enabled);
+   cpu = generic_processor_info(id, ver);
if (cpu >= 0)
early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
 
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aee7ded..8ccb7ef 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2063,7 +2063,7 @@ static int allocate_logical_cpuid(int apicid)
return nr_logical_cpuids++;
 }
 
-int __generic_processor_info(int apicid, int version, bool enabled)
+int generic_processor_info(int apicid, int version)
 {
int cpu, max = nr_cpu_ids;
bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2121,11 +2121,9 @@ int __generic_processor_info(int apicid, int version, 
bool enabled)
if (num_processors >= nr_cpu_ids) {
int thiscpu = max + disabled_cpus;
 
-   if (enabled) {
-   pr_warning("APIC: NR_CPUS/possible_cpus limit of %i "
-  "reached. Processor %d/0x%x ignored.\n",
-  max, thiscpu, apicid);
-   }
+   pr_warning("APIC: NR_CPUS/possible_cpus limit of %i "
+  "reached. Processor %d/0x%x ignored.\n",
+  max, thiscpu, apicid);
 
disabled_cpus++;
return -EINVAL;
@@ -2177,23 +2175,13 @@ int __generic_processor_info(int apicid, int version, 
bool enabled)
apic->x86_32_early_logical_apicid(cpu);
 #endif
set_cpu_possible(cpu, true);
-
-   if (enabled) {
-   num_processors++;
-   physid_set(apicid, phys_cpu_present_map);
-   set_cpu_present(cpu, true);
-   } else {
-   disabled_cpus++;
-   }
+   physid_set(apicid, phys_cpu_present_map);
+   set_cpu_present(cpu, true);
+   num_processors++;
 
return cpu;
 }
 
-int generic_processor_info(int apicid, int version)
-{
-   return __generic_processor_info(apicid, version, true);
-}
-
 int hard_smp_processor_id(void)
 {
return read_apic_id();


[tip:x86/acpi] x86/acpi: Restore the order of CPU IDs

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  2b85b3d22920db7473e5fed5719e7955c0ec323e
Gitweb: http://git.kernel.org/tip/2b85b3d22920db7473e5fed5719e7955c0ec323e
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:25 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:19 +0100

x86/acpi: Restore the order of CPU IDs

The following commits:

  f7c28833c2 ("x86/acpi: Enable acpi to register all possible cpus at
boot time") and 8f54969dc8 ("x86/acpi: Introduce persistent storage
for cpuid <-> apicid mapping")

... registered all the possible CPUs at boot time via ACPI tables to
make the mapping of cpuid <-> apicid fixed. Both enabled and disabled
CPUs could have a logical CPU ID after boot time.

But, ACPI tables are unreliable. the number amd order of Local APIC
entries which depends on the firmware is often inconsistent with the
physical devices. Even if they are consistent, The disabled CPUs which
take up some logical CPU IDs will also make the order discontinuous.

Revert the part of disabled CPUs registration, keep the allocation
logic of logical CPU IDs and also keep some code location changes.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-4-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/acpi/boot.c |  7 ++-
 arch/x86/kernel/apic/apic.c | 26 +++---
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index f6b0e87..b2879cc23 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -179,10 +179,15 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 
enabled)
return -EINVAL;
}
 
+   if (!enabled) {
+   ++disabled_cpus;
+   return -EINVAL;
+   }
+
if (boot_cpu_physical_apicid != -1U)
ver = boot_cpu_apic_version;
 
-   cpu = __generic_processor_info(id, ver, enabled);
+   cpu = generic_processor_info(id, ver);
if (cpu >= 0)
early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
 
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index aee7ded..8ccb7ef 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2063,7 +2063,7 @@ static int allocate_logical_cpuid(int apicid)
return nr_logical_cpuids++;
 }
 
-int __generic_processor_info(int apicid, int version, bool enabled)
+int generic_processor_info(int apicid, int version)
 {
int cpu, max = nr_cpu_ids;
bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2121,11 +2121,9 @@ int __generic_processor_info(int apicid, int version, 
bool enabled)
if (num_processors >= nr_cpu_ids) {
int thiscpu = max + disabled_cpus;
 
-   if (enabled) {
-   pr_warning("APIC: NR_CPUS/possible_cpus limit of %i "
-  "reached. Processor %d/0x%x ignored.\n",
-  max, thiscpu, apicid);
-   }
+   pr_warning("APIC: NR_CPUS/possible_cpus limit of %i "
+  "reached. Processor %d/0x%x ignored.\n",
+  max, thiscpu, apicid);
 
disabled_cpus++;
return -EINVAL;
@@ -2177,23 +2175,13 @@ int __generic_processor_info(int apicid, int version, 
bool enabled)
apic->x86_32_early_logical_apicid(cpu);
 #endif
set_cpu_possible(cpu, true);
-
-   if (enabled) {
-   num_processors++;
-   physid_set(apicid, phys_cpu_present_map);
-   set_cpu_present(cpu, true);
-   } else {
-   disabled_cpus++;
-   }
+   physid_set(apicid, phys_cpu_present_map);
+   set_cpu_present(cpu, true);
+   num_processors++;
 
return cpu;
 }
 
-int generic_processor_info(int apicid, int version)
-{
-   return __generic_processor_info(apicid, version, true);
-}
-
 int hard_smp_processor_id(void)
 {
return read_apic_id();


[tip:x86/acpi] Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting"

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  c962cff17dfa11f4a8227ac16de2b28aea3312e4
Gitweb: http://git.kernel.org/tip/c962cff17dfa11f4a8227ac16de2b28aea3312e4
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:23 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:18 +0100

Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting"

Revert: dc6db24d2476 ("x86/acpi: Set persistent cpuid <-> nodeid mapping when 
booting")

The mapping of "cpuid <-> nodeid" is established at boot time via ACPI
tables to keep associations of workqueues and other node related items
consistent across cpu hotplug.

But, ACPI tables are unreliable and failures with that boot time mapping
have been reported on machines where the ACPI table and the physical
information which is retrieved at actual hotplug is inconsistent.

Revert the mapping implementation so it can be replaced with a less error
prone approach.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-2-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/acpi/boot.c   |  2 +-
 drivers/acpi/acpi_processor.c |  5 ---
 drivers/acpi/bus.c|  1 -
 drivers/acpi/processor_core.c | 73 ---
 include/linux/acpi.h  |  3 --
 5 files changed, 1 insertion(+), 83 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index ae32838..f6b0e87 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -710,7 +710,7 @@ static void __init acpi_set_irq_model_ioapic(void)
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 #include 
 
-int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
 {
 #ifdef CONFIG_ACPI_NUMA
int nid;
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 4467a80..5d208a9 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -182,11 +182,6 @@ int __weak arch_register_cpu(int cpu)
 
 void __weak arch_unregister_cpu(int cpu) {}
 
-int __weak acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
-{
-   return -ENODEV;
-}
-
 static int acpi_processor_hotadd_init(struct acpi_processor *pr)
 {
unsigned long long sta;
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 80cb5eb..34fbe02 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1249,7 +1249,6 @@ static int __init acpi_init(void)
acpi_wakeup_device_init();
acpi_debugger_init();
acpi_setup_sb_notify_handler();
-   acpi_set_processor_mapping();
return 0;
 }
 
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 611a558..a843862 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -278,79 +278,6 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 
acpi_id)
 }
 EXPORT_SYMBOL_GPL(acpi_get_cpuid);
 
-#ifdef CONFIG_ACPI_HOTPLUG_CPU
-static bool __init
-map_processor(acpi_handle handle, phys_cpuid_t *phys_id, int *cpuid)
-{
-   int type, id;
-   u32 acpi_id;
-   acpi_status status;
-   acpi_object_type acpi_type;
-   unsigned long long tmp;
-   union acpi_object object = { 0 };
-   struct acpi_buffer buffer = { sizeof(union acpi_object),  };
-
-   status = acpi_get_type(handle, _type);
-   if (ACPI_FAILURE(status))
-   return false;
-
-   switch (acpi_type) {
-   case ACPI_TYPE_PROCESSOR:
-   status = acpi_evaluate_object(handle, NULL, NULL, );
-   if (ACPI_FAILURE(status))
-   return false;
-   acpi_id = object.processor.proc_id;
-
-   /* validate the acpi_id */
-   if(acpi_processor_validate_proc_id(acpi_id))
-   return false;
-   break;
-   case ACPI_TYPE_DEVICE:
-   status = acpi_evaluate_integer(handle, "_UID", NULL, );
-   if (ACPI_FAILURE(status))
-   return false;
-   acpi_id = tmp;
-   break;
-   default:
-   return false;
-   }
-
-   type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
-
-   *phys_id = __acpi_get_phys_id(handle, type, acpi_id, false);
-   id = acpi_map_cpuid(*phys_id, acpi_id);
-
-   if (id < 0)
-   return false;
-   *cpuid = id;
-   return true;
-}
-
-static acpi_status __init
-set_processor_node_mapping(acpi_handle handle, u32 lvl, void *context,
-  void **rv)
-{
-   phys_cpuid_t phys_id;
-   int cpu_id;
-
-   if (!map_processor(handle, _id, _id))
-   return AE_ERROR;
-
-  

[tip:x86/acpi] Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting"

2017-03-11 Thread tip-bot for Dou Liyang
Commit-ID:  c962cff17dfa11f4a8227ac16de2b28aea3312e4
Gitweb: http://git.kernel.org/tip/c962cff17dfa11f4a8227ac16de2b28aea3312e4
Author: Dou Liyang 
AuthorDate: Fri, 3 Mar 2017 16:02:23 +0800
Committer:  Thomas Gleixner 
CommitDate: Sat, 11 Mar 2017 14:41:18 +0100

Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting"

Revert: dc6db24d2476 ("x86/acpi: Set persistent cpuid <-> nodeid mapping when 
booting")

The mapping of "cpuid <-> nodeid" is established at boot time via ACPI
tables to keep associations of workqueues and other node related items
consistent across cpu hotplug.

But, ACPI tables are unreliable and failures with that boot time mapping
have been reported on machines where the ACPI table and the physical
information which is retrieved at actual hotplug is inconsistent.

Revert the mapping implementation so it can be replaced with a less error
prone approach.

Signed-off-by: Dou Liyang 
Tested-by: Xiaolong Ye 
Cc: r...@rjwysocki.net
Cc: linux-a...@vger.kernel.org
Cc: guzhe...@huawei.com
Cc: izumi.t...@jp.fujitsu.com
Cc: l...@kernel.org
Link: 
http://lkml.kernel.org/r/1488528147-2279-2-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Thomas Gleixner 

---
 arch/x86/kernel/acpi/boot.c   |  2 +-
 drivers/acpi/acpi_processor.c |  5 ---
 drivers/acpi/bus.c|  1 -
 drivers/acpi/processor_core.c | 73 ---
 include/linux/acpi.h  |  3 --
 5 files changed, 1 insertion(+), 83 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index ae32838..f6b0e87 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -710,7 +710,7 @@ static void __init acpi_set_irq_model_ioapic(void)
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 #include 
 
-int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
 {
 #ifdef CONFIG_ACPI_NUMA
int nid;
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 4467a80..5d208a9 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -182,11 +182,6 @@ int __weak arch_register_cpu(int cpu)
 
 void __weak arch_unregister_cpu(int cpu) {}
 
-int __weak acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
-{
-   return -ENODEV;
-}
-
 static int acpi_processor_hotadd_init(struct acpi_processor *pr)
 {
unsigned long long sta;
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 80cb5eb..34fbe02 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1249,7 +1249,6 @@ static int __init acpi_init(void)
acpi_wakeup_device_init();
acpi_debugger_init();
acpi_setup_sb_notify_handler();
-   acpi_set_processor_mapping();
return 0;
 }
 
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 611a558..a843862 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -278,79 +278,6 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 
acpi_id)
 }
 EXPORT_SYMBOL_GPL(acpi_get_cpuid);
 
-#ifdef CONFIG_ACPI_HOTPLUG_CPU
-static bool __init
-map_processor(acpi_handle handle, phys_cpuid_t *phys_id, int *cpuid)
-{
-   int type, id;
-   u32 acpi_id;
-   acpi_status status;
-   acpi_object_type acpi_type;
-   unsigned long long tmp;
-   union acpi_object object = { 0 };
-   struct acpi_buffer buffer = { sizeof(union acpi_object),  };
-
-   status = acpi_get_type(handle, _type);
-   if (ACPI_FAILURE(status))
-   return false;
-
-   switch (acpi_type) {
-   case ACPI_TYPE_PROCESSOR:
-   status = acpi_evaluate_object(handle, NULL, NULL, );
-   if (ACPI_FAILURE(status))
-   return false;
-   acpi_id = object.processor.proc_id;
-
-   /* validate the acpi_id */
-   if(acpi_processor_validate_proc_id(acpi_id))
-   return false;
-   break;
-   case ACPI_TYPE_DEVICE:
-   status = acpi_evaluate_integer(handle, "_UID", NULL, );
-   if (ACPI_FAILURE(status))
-   return false;
-   acpi_id = tmp;
-   break;
-   default:
-   return false;
-   }
-
-   type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
-
-   *phys_id = __acpi_get_phys_id(handle, type, acpi_id, false);
-   id = acpi_map_cpuid(*phys_id, acpi_id);
-
-   if (id < 0)
-   return false;
-   *cpuid = id;
-   return true;
-}
-
-static acpi_status __init
-set_processor_node_mapping(acpi_handle handle, u32 lvl, void *context,
-  void **rv)
-{
-   phys_cpuid_t phys_id;
-   int cpu_id;
-
-   if (!map_processor(handle, _id, _id))
-   return AE_ERROR;
-
-   acpi_map_cpu2node(handle, cpu_id, phys_id);
-   return AE_OK;
-}
-
-void __init 

[tip:x86/urgent] x86/apic: Simplify enable_IR_x2apic(), remove try_to_enable_IR()

2017-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  11277aabcbbe13916151af897d29a5e9f71ca73f
Gitweb: http://git.kernel.org/tip/11277aabcbbe13916151af897d29a5e9f71ca73f
Author: Dou Liyang 
AuthorDate: Thu, 23 Feb 2017 17:16:41 +0800
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:09:09 +0100

x86/apic: Simplify enable_IR_x2apic(), remove try_to_enable_IR()

The following commit:

  2e63ad4bd5dd ("x86/apic: Do not init irq remapping if ioapic is disabled")

... added a check for skipped IO-APIC setup to enable_IR_x2apic(), but this
check is also duplicated in try_to_enable_IR() - and it will never succeed in
calling irq_remapping_enable().

Remove the whole irq_remapping_enable() complication: if the IO-APIC is
disabled we cannot enable IRQ remapping.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: b...@alien8.de
Cc: nicsta...@gmail.com
Cc: wanpeng...@hotmail.com
Link: 
http://lkml.kernel.org/r/1487841401-1543-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 11088b8..aee7ded 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1610,24 +1610,15 @@ static inline void try_to_enable_x2apic(int remap_mode) 
{ }
 static inline void __x2apic_enable(void) { }
 #endif /* !CONFIG_X86_X2APIC */
 
-static int __init try_to_enable_IR(void)
-{
-#ifdef CONFIG_X86_IO_APIC
-   if (!x2apic_enabled() && skip_ioapic_setup) {
-   pr_info("Not enabling interrupt remapping due to skipped 
IO-APIC setup\n");
-   return -1;
-   }
-#endif
-   return irq_remapping_enable();
-}
-
 void __init enable_IR_x2apic(void)
 {
unsigned long flags;
int ret, ir_stat;
 
-   if (skip_ioapic_setup)
+   if (skip_ioapic_setup) {
+   pr_info("Not enabling interrupt remapping due to skipped 
IO-APIC setup\n");
return;
+   }
 
ir_stat = irq_remapping_prepare();
if (ir_stat < 0 && !x2apic_supported())
@@ -1645,7 +1636,7 @@ void __init enable_IR_x2apic(void)
 
/* If irq_remapping_prepare() succeeded, try to enable it */
if (ir_stat >= 0)
-   ir_stat = try_to_enable_IR();
+   ir_stat = irq_remapping_enable();
/* ir_stat contains the remap mode or an error code */
try_to_enable_x2apic(ir_stat);
 


[tip:x86/urgent] x86/apic: Simplify enable_IR_x2apic(), remove try_to_enable_IR()

2017-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  11277aabcbbe13916151af897d29a5e9f71ca73f
Gitweb: http://git.kernel.org/tip/11277aabcbbe13916151af897d29a5e9f71ca73f
Author: Dou Liyang 
AuthorDate: Thu, 23 Feb 2017 17:16:41 +0800
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:09:09 +0100

x86/apic: Simplify enable_IR_x2apic(), remove try_to_enable_IR()

The following commit:

  2e63ad4bd5dd ("x86/apic: Do not init irq remapping if ioapic is disabled")

... added a check for skipped IO-APIC setup to enable_IR_x2apic(), but this
check is also duplicated in try_to_enable_IR() - and it will never succeed in
calling irq_remapping_enable().

Remove the whole irq_remapping_enable() complication: if the IO-APIC is
disabled we cannot enable IRQ remapping.

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: b...@alien8.de
Cc: nicsta...@gmail.com
Cc: wanpeng...@hotmail.com
Link: 
http://lkml.kernel.org/r/1487841401-1543-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/apic.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 11088b8..aee7ded 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1610,24 +1610,15 @@ static inline void try_to_enable_x2apic(int remap_mode) 
{ }
 static inline void __x2apic_enable(void) { }
 #endif /* !CONFIG_X86_X2APIC */
 
-static int __init try_to_enable_IR(void)
-{
-#ifdef CONFIG_X86_IO_APIC
-   if (!x2apic_enabled() && skip_ioapic_setup) {
-   pr_info("Not enabling interrupt remapping due to skipped 
IO-APIC setup\n");
-   return -1;
-   }
-#endif
-   return irq_remapping_enable();
-}
-
 void __init enable_IR_x2apic(void)
 {
unsigned long flags;
int ret, ir_stat;
 
-   if (skip_ioapic_setup)
+   if (skip_ioapic_setup) {
+   pr_info("Not enabling interrupt remapping due to skipped 
IO-APIC setup\n");
return;
+   }
 
ir_stat = irq_remapping_prepare();
if (ir_stat < 0 && !x2apic_supported())
@@ -1645,7 +1636,7 @@ void __init enable_IR_x2apic(void)
 
/* If irq_remapping_prepare() succeeded, try to enable it */
if (ir_stat >= 0)
-   ir_stat = try_to_enable_IR();
+   ir_stat = irq_remapping_enable();
/* ir_stat contains the remap mode or an error code */
try_to_enable_x2apic(ir_stat);
 


[tip:x86/urgent] x86/apic: Fix a warning message in logical CPU IDs allocation

2017-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  bb3f0a52630c84807fca9bdd76ac2f5dcec82689
Gitweb: http://git.kernel.org/tip/bb3f0a52630c84807fca9bdd76ac2f5dcec82689
Author: Dou Liyang 
AuthorDate: Tue, 28 Feb 2017 13:50:52 +0800
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:09:08 +0100

x86/apic: Fix a warning message in logical CPU IDs allocation

The current warning message in allocate_logical_cpuid() is somewhat confusing:

  Only 1 processors supported.Processor 2/0x2 and the rest are ignored.

As it might imply that there's only one CPU in the system - while what we ran
into here is a kernel limitation.

Fix the warning message to clarify all that:

  APIC: NR_CPUS/possible_cpus limit of 2 reached. Processor 2/0x2 and the rest 
are ignored.

( Also update the error return from -1 to -EINVAL, which is the more
  canonical return value. )

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: b...@alien8.de
Cc: nicsta...@gmail.com
Cc: wanpeng...@hotmail.com
Link: 
http://lkml.kernel.org/r/1488261052-25753-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/apic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 4261b32..11088b8 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2062,10 +2062,10 @@ static int allocate_logical_cpuid(int apicid)
 
/* Allocate a new cpuid. */
if (nr_logical_cpuids >= nr_cpu_ids) {
-   WARN_ONCE(1, "Only %d processors supported."
+   WARN_ONCE(1, "APIC: NR_CPUS/possible_cpus limit of %i reached. "
 "Processor %d/0x%x and the rest are ignored.\n",
-nr_cpu_ids - 1, nr_logical_cpuids, apicid);
-   return -1;
+nr_cpu_ids, nr_logical_cpuids, apicid);
+   return -EINVAL;
}
 
cpuid_to_apicid[nr_logical_cpuids] = apicid;


[tip:x86/urgent] x86/apic: Fix a warning message in logical CPU IDs allocation

2017-03-01 Thread tip-bot for Dou Liyang
Commit-ID:  bb3f0a52630c84807fca9bdd76ac2f5dcec82689
Gitweb: http://git.kernel.org/tip/bb3f0a52630c84807fca9bdd76ac2f5dcec82689
Author: Dou Liyang 
AuthorDate: Tue, 28 Feb 2017 13:50:52 +0800
Committer:  Ingo Molnar 
CommitDate: Wed, 1 Mar 2017 10:09:08 +0100

x86/apic: Fix a warning message in logical CPU IDs allocation

The current warning message in allocate_logical_cpuid() is somewhat confusing:

  Only 1 processors supported.Processor 2/0x2 and the rest are ignored.

As it might imply that there's only one CPU in the system - while what we ran
into here is a kernel limitation.

Fix the warning message to clarify all that:

  APIC: NR_CPUS/possible_cpus limit of 2 reached. Processor 2/0x2 and the rest 
are ignored.

( Also update the error return from -1 to -EINVAL, which is the more
  canonical return value. )

Signed-off-by: Dou Liyang 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: b...@alien8.de
Cc: nicsta...@gmail.com
Cc: wanpeng...@hotmail.com
Link: 
http://lkml.kernel.org/r/1488261052-25753-1-git-send-email-douly.f...@cn.fujitsu.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/apic/apic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 4261b32..11088b8 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2062,10 +2062,10 @@ static int allocate_logical_cpuid(int apicid)
 
/* Allocate a new cpuid. */
if (nr_logical_cpuids >= nr_cpu_ids) {
-   WARN_ONCE(1, "Only %d processors supported."
+   WARN_ONCE(1, "APIC: NR_CPUS/possible_cpus limit of %i reached. "
 "Processor %d/0x%x and the rest are ignored.\n",
-nr_cpu_ids - 1, nr_logical_cpuids, apicid);
-   return -1;
+nr_cpu_ids, nr_logical_cpuids, apicid);
+   return -EINVAL;
}
 
cpuid_to_apicid[nr_logical_cpuids] = apicid;


  1   2   >