These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / s390 / char / sclp_cmd.c
index 7be7821..806239c 100644 (file)
@@ -25,6 +25,7 @@
 #include <asm/setup.h>
 #include <asm/page.h>
 #include <asm/sclp.h>
+#include <asm/numa.h>
 
 #include "sclp.h"
 
@@ -92,8 +93,8 @@ struct read_cpu_info_sccb {
        u8      reserved[4096 - 16];
 } __attribute__((packed, aligned(PAGE_SIZE)));
 
-static void sclp_fill_cpu_info(struct sclp_cpu_info *info,
-                              struct read_cpu_info_sccb *sccb)
+static void sclp_fill_core_info(struct sclp_core_info *info,
+                               struct read_cpu_info_sccb *sccb)
 {
        char *page = (char *) sccb;
 
@@ -101,12 +102,11 @@ static void sclp_fill_cpu_info(struct sclp_cpu_info *info,
        info->configured = sccb->nr_configured;
        info->standby = sccb->nr_standby;
        info->combined = sccb->nr_configured + sccb->nr_standby;
-       info->has_cpu_type = sclp_fac84 & 0x1;
-       memcpy(&info->cpu, page + sccb->offset_configured,
-              info->combined * sizeof(struct sclp_cpu_entry));
+       memcpy(&info->core, page + sccb->offset_configured,
+              info->combined * sizeof(struct sclp_core_entry));
 }
 
-int sclp_get_cpu_info(struct sclp_cpu_info *info)
+int sclp_get_core_info(struct sclp_core_info *info)
 {
        int rc;
        struct read_cpu_info_sccb *sccb;
@@ -127,7 +127,7 @@ int sclp_get_cpu_info(struct sclp_cpu_info *info)
                rc = -EIO;
                goto out;
        }
-       sclp_fill_cpu_info(info, sccb);
+       sclp_fill_core_info(info, sccb);
 out:
        free_page((unsigned long) sccb);
        return rc;
@@ -137,7 +137,7 @@ struct cpu_configure_sccb {
        struct sccb_header header;
 } __attribute__((packed, aligned(8)));
 
-static int do_cpu_configure(sclp_cmdw_t cmd)
+static int do_core_configure(sclp_cmdw_t cmd)
 {
        struct cpu_configure_sccb *sccb;
        int rc;
@@ -171,14 +171,14 @@ out:
        return rc;
 }
 
-int sclp_cpu_configure(u8 cpu)
+int sclp_core_configure(u8 core)
 {
-       return do_cpu_configure(SCLP_CMDW_CONFIGURE_CPU | cpu << 8);
+       return do_core_configure(SCLP_CMDW_CONFIGURE_CPU | core << 8);
 }
 
-int sclp_cpu_deconfigure(u8 cpu)
+int sclp_core_deconfigure(u8 core)
 {
-       return do_cpu_configure(SCLP_CMDW_DECONFIGURE_CPU | cpu << 8);
+       return do_core_configure(SCLP_CMDW_DECONFIGURE_CPU | core << 8);
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
@@ -186,7 +186,7 @@ int sclp_cpu_deconfigure(u8 cpu)
 static DEFINE_MUTEX(sclp_mem_mutex);
 static LIST_HEAD(sclp_mem_list);
 static u8 sclp_max_storage_id;
-static unsigned long sclp_storage_ids[256 / BITS_PER_LONG];
+static DECLARE_BITMAP(sclp_storage_ids, 256);
 static int sclp_mem_state_changed;
 
 struct memory_increment {
@@ -202,14 +202,14 @@ struct assign_storage_sccb {
 
 int arch_get_memory_phys_device(unsigned long start_pfn)
 {
-       if (!sclp_rzm)
+       if (!sclp.rzm)
                return 0;
-       return PFN_PHYS(start_pfn) >> ilog2(sclp_rzm);
+       return PFN_PHYS(start_pfn) >> ilog2(sclp.rzm);
 }
 
 static unsigned long long rn2addr(u16 rn)
 {
-       return (unsigned long long) (rn - 1) * sclp_rzm;
+       return (unsigned long long) (rn - 1) * sclp.rzm;
 }
 
 static int do_assign_storage(sclp_cmdw_t cmd, u16 rn)
@@ -250,7 +250,7 @@ static int sclp_assign_storage(u16 rn)
        if (rc)
                return rc;
        start = rn2addr(rn);
-       storage_key_init_range(start, start + sclp_rzm);
+       storage_key_init_range(start, start + sclp.rzm);
        return 0;
 }
 
@@ -309,7 +309,7 @@ static int sclp_mem_change_state(unsigned long start, unsigned long size,
                istart = rn2addr(incr->rn);
                if (start + size - 1 < istart)
                        break;
-               if (start > istart + sclp_rzm - 1)
+               if (start > istart + sclp.rzm - 1)
                        continue;
                if (online)
                        rc |= sclp_assign_storage(incr->rn);
@@ -330,7 +330,7 @@ static bool contains_standby_increment(unsigned long start, unsigned long end)
                istart = rn2addr(incr->rn);
                if (end - 1 < istart)
                        continue;
-               if (start > istart + sclp_rzm - 1)
+               if (start > istart + sclp.rzm - 1)
                        continue;
                if (incr->standby)
                        return true;
@@ -389,11 +389,11 @@ static struct notifier_block sclp_mem_nb = {
 };
 
 static void __init align_to_block_size(unsigned long long *start,
-                                      unsigned long long *size)
+                                      unsigned long long *size,
+                                      unsigned long long alignment)
 {
-       unsigned long long start_align, size_align, alignment;
+       unsigned long long start_align, size_align;
 
-       alignment = memory_block_size_bytes();
        start_align = roundup(*start, alignment);
        size_align = rounddown(*start + *size, alignment) - start_align;
 
@@ -405,8 +405,8 @@ static void __init align_to_block_size(unsigned long long *start,
 
 static void __init add_memory_merged(u16 rn)
 {
+       unsigned long long start, size, addr, block_size;
        static u16 first_rn, num;
-       unsigned long long start, size;
 
        if (rn && first_rn && (first_rn + num == rn)) {
                num++;
@@ -415,7 +415,7 @@ static void __init add_memory_merged(u16 rn)
        if (!first_rn)
                goto skip_add;
        start = rn2addr(first_rn);
-       size = (unsigned long long) num * sclp_rzm;
+       size = (unsigned long long) num * sclp.rzm;
        if (start >= VMEM_MAX_PHYS)
                goto skip_add;
        if (start + size > VMEM_MAX_PHYS)
@@ -424,9 +424,12 @@ static void __init add_memory_merged(u16 rn)
                goto skip_add;
        if (memory_end_set && (start + size > memory_end))
                size = memory_end - start;
-       align_to_block_size(&start, &size);
-       if (size)
-               add_memory(0, start, size);
+       block_size = memory_block_size_bytes();
+       align_to_block_size(&start, &size, block_size);
+       if (!size)
+               goto skip_add;
+       for (addr = start; addr < start + size; addr += block_size)
+               add_memory(numa_pfn_to_nid(PFN_DOWN(addr)), addr, block_size);
 skip_add:
        first_rn = rn;
        num = 1;
@@ -465,7 +468,7 @@ static void __init insert_increment(u16 rn, int standby, int assigned)
        }
        if (!assigned)
                new_incr->rn = last_rn + 1;
-       if (new_incr->rn > sclp_rnmax) {
+       if (new_incr->rn > sclp.rnmax) {
                kfree(new_incr);
                return;
        }
@@ -508,7 +511,7 @@ static int __init sclp_detect_standby_memory(void)
 
        if (OLDMEM_BASE) /* No standby memory in kdump mode */
                return 0;
-       if ((sclp_facilities & 0xe00000000000ULL) != 0xe00000000000ULL)
+       if ((sclp.facilities & 0xe00000000000ULL) != 0xe00000000000ULL)
                return 0;
        rc = -ENOMEM;
        sccb = (void *) __get_free_page(GFP_KERNEL | GFP_DMA);
@@ -550,7 +553,7 @@ static int __init sclp_detect_standby_memory(void)
        }
        if (rc || list_empty(&sclp_mem_list))
                goto out;
-       for (i = 1; i <= sclp_rnmax - assigned; i++)
+       for (i = 1; i <= sclp.rnmax - assigned; i++)
                insert_increment(0, 1, 0);
        rc = register_memory_notifier(&sclp_mem_nb);
        if (rc)
@@ -753,8 +756,3 @@ out:
        free_page((unsigned long) sccb);
        return rc;
 }
-
-bool sclp_has_sprp(void)
-{
-       return !!(sclp_fac84 & 0x2);
-}