License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2007-05-26 06:49:59 +08:00
|
|
|
/* mdesc.c: Sun4V machine description handling.
|
|
|
|
*
|
2008-02-14 11:22:23 +08:00
|
|
|
* Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
|
2007-05-26 06:49:59 +08:00
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/log2.h>
|
2007-07-13 04:47:50 +08:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/slab.h>
|
2007-07-14 15:54:55 +08:00
|
|
|
#include <linux/mm.h>
|
2007-08-16 12:02:23 +08:00
|
|
|
#include <linux/miscdevice.h>
|
2018-10-31 06:09:25 +08:00
|
|
|
#include <linux/memblock.h>
|
2011-07-19 03:57:46 +08:00
|
|
|
#include <linux/export.h>
|
2017-10-20 15:57:57 +08:00
|
|
|
#include <linux/refcount.h>
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2008-12-27 07:33:07 +08:00
|
|
|
#include <asm/cpudata.h>
|
2007-05-26 06:49:59 +08:00
|
|
|
#include <asm/hypervisor.h>
|
|
|
|
#include <asm/mdesc.h>
|
|
|
|
#include <asm/prom.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2007-05-26 06:49:59 +08:00
|
|
|
#include <asm/oplib.h>
|
|
|
|
#include <asm/smp.h>
|
2018-02-22 01:15:48 +08:00
|
|
|
#include <asm/adi.h>
|
2007-05-26 06:49:59 +08:00
|
|
|
|
|
|
|
/* Unlike the OBP device tree, the machine description is a full-on
|
|
|
|
* DAG. An arbitrary number of ARCs are possible from one
|
|
|
|
* node to other nodes and thus we can't use the OBP device_node
|
|
|
|
* data structure to represent these nodes inside of the kernel.
|
|
|
|
*
|
|
|
|
* Actually, it isn't even a DAG, because there are back pointers
|
|
|
|
* which create cycles in the graph.
|
|
|
|
*
|
|
|
|
* mdesc_hdr and mdesc_elem describe the layout of the data structure
|
|
|
|
* we get from the Hypervisor.
|
|
|
|
*/
|
|
|
|
struct mdesc_hdr {
|
|
|
|
u32 version; /* Transport version */
|
|
|
|
u32 node_sz; /* node block size */
|
|
|
|
u32 name_sz; /* name block size */
|
|
|
|
u32 data_sz; /* data block size */
|
2007-07-13 04:47:50 +08:00
|
|
|
} __attribute__((aligned(16)));
|
2007-05-26 06:49:59 +08:00
|
|
|
|
|
|
|
struct mdesc_elem {
|
|
|
|
u8 tag;
|
|
|
|
#define MD_LIST_END 0x00
|
|
|
|
#define MD_NODE 0x4e
|
|
|
|
#define MD_NODE_END 0x45
|
|
|
|
#define MD_NOOP 0x20
|
|
|
|
#define MD_PROP_ARC 0x61
|
|
|
|
#define MD_PROP_VAL 0x76
|
|
|
|
#define MD_PROP_STR 0x73
|
|
|
|
#define MD_PROP_DATA 0x64
|
|
|
|
u8 name_len;
|
|
|
|
u16 resv;
|
|
|
|
u32 name_offset;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 data_len;
|
|
|
|
u32 data_offset;
|
|
|
|
} data;
|
|
|
|
u64 val;
|
|
|
|
} d;
|
|
|
|
};
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_mem_ops {
|
|
|
|
struct mdesc_handle *(*alloc)(unsigned int mdesc_size);
|
|
|
|
void (*free)(struct mdesc_handle *handle);
|
|
|
|
};
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_handle {
|
|
|
|
struct list_head list;
|
|
|
|
struct mdesc_mem_ops *mops;
|
|
|
|
void *self_base;
|
2017-10-20 15:57:57 +08:00
|
|
|
refcount_t refcnt;
|
2007-07-13 04:47:50 +08:00
|
|
|
unsigned int handle_size;
|
|
|
|
struct mdesc_hdr mdesc;
|
|
|
|
};
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2017-06-24 02:58:32 +08:00
|
|
|
typedef int (*mdesc_node_info_get_f)(struct mdesc_handle *, u64,
|
|
|
|
union md_node_info *);
|
|
|
|
typedef void (*mdesc_node_info_rel_f)(union md_node_info *);
|
|
|
|
typedef bool (*mdesc_node_match_f)(union md_node_info *, union md_node_info *);
|
|
|
|
|
|
|
|
struct md_node_ops {
|
|
|
|
char *name;
|
|
|
|
mdesc_node_info_get_f get_info;
|
|
|
|
mdesc_node_info_rel_f rel_info;
|
|
|
|
mdesc_node_match_f node_match;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int get_vdev_port_node_info(struct mdesc_handle *md, u64 node,
|
|
|
|
union md_node_info *node_info);
|
|
|
|
static void rel_vdev_port_node_info(union md_node_info *node_info);
|
|
|
|
static bool vdev_port_node_match(union md_node_info *a_node_info,
|
|
|
|
union md_node_info *b_node_info);
|
|
|
|
|
|
|
|
static int get_ds_port_node_info(struct mdesc_handle *md, u64 node,
|
|
|
|
union md_node_info *node_info);
|
|
|
|
static void rel_ds_port_node_info(union md_node_info *node_info);
|
|
|
|
static bool ds_port_node_match(union md_node_info *a_node_info,
|
|
|
|
union md_node_info *b_node_info);
|
|
|
|
|
|
|
|
/* supported node types which can be registered */
|
|
|
|
static struct md_node_ops md_node_ops_table[] = {
|
|
|
|
{"virtual-device-port", get_vdev_port_node_info,
|
|
|
|
rel_vdev_port_node_info, vdev_port_node_match},
|
|
|
|
{"domain-services-port", get_ds_port_node_info,
|
|
|
|
rel_ds_port_node_info, ds_port_node_match},
|
|
|
|
{NULL, NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void mdesc_get_node_ops(const char *node_name,
|
|
|
|
mdesc_node_info_get_f *get_info_f,
|
|
|
|
mdesc_node_info_rel_f *rel_info_f,
|
|
|
|
mdesc_node_match_f *match_f)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (get_info_f)
|
|
|
|
*get_info_f = NULL;
|
|
|
|
|
|
|
|
if (rel_info_f)
|
|
|
|
*rel_info_f = NULL;
|
|
|
|
|
|
|
|
if (match_f)
|
|
|
|
*match_f = NULL;
|
|
|
|
|
|
|
|
if (!node_name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; md_node_ops_table[i].name != NULL; i++) {
|
|
|
|
if (strcmp(md_node_ops_table[i].name, node_name) == 0) {
|
|
|
|
if (get_info_f)
|
|
|
|
*get_info_f = md_node_ops_table[i].get_info;
|
|
|
|
|
|
|
|
if (rel_info_f)
|
|
|
|
*rel_info_f = md_node_ops_table[i].rel_info;
|
|
|
|
|
|
|
|
if (match_f)
|
|
|
|
*match_f = md_node_ops_table[i].node_match;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static void mdesc_handle_init(struct mdesc_handle *hp,
|
|
|
|
unsigned int handle_size,
|
|
|
|
void *base)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
BUG_ON(((unsigned long)&hp->mdesc) & (16UL - 1));
|
|
|
|
|
|
|
|
memset(hp, 0, handle_size);
|
|
|
|
INIT_LIST_HEAD(&hp->list);
|
|
|
|
hp->self_base = base;
|
2017-10-20 15:57:57 +08:00
|
|
|
refcount_set(&hp->refcnt, 1);
|
2007-07-13 04:47:50 +08:00
|
|
|
hp->handle_size = handle_size;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 12:36:09 +08:00
|
|
|
static struct mdesc_handle * __init mdesc_memblock_alloc(unsigned int mdesc_size)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
unsigned int handle_size, alloc_size;
|
2008-02-14 11:22:23 +08:00
|
|
|
struct mdesc_handle *hp;
|
|
|
|
unsigned long paddr;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
handle_size = (sizeof(struct mdesc_handle) -
|
|
|
|
sizeof(struct mdesc_hdr) +
|
|
|
|
mdesc_size);
|
|
|
|
alloc_size = PAGE_ALIGN(handle_size);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
memblock: rename memblock_alloc{_nid,_try_nid} to memblock_phys_alloc*
Make it explicit that the caller gets a physical address rather than a
virtual one.
This will also allow using meblock_alloc prefix for memblock allocations
returning virtual address, which is done in the following patches.
The conversion is done using the following semantic patch:
@@
expression e1, e2, e3;
@@
(
- memblock_alloc(e1, e2)
+ memblock_phys_alloc(e1, e2)
|
- memblock_alloc_nid(e1, e2, e3)
+ memblock_phys_alloc_nid(e1, e2, e3)
|
- memblock_alloc_try_nid(e1, e2, e3)
+ memblock_phys_alloc_try_nid(e1, e2, e3)
)
Link: http://lkml.kernel.org/r/1536927045-23536-7-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Serge Semin <fancer.lancer@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-31 06:07:59 +08:00
|
|
|
paddr = memblock_phys_alloc(alloc_size, PAGE_SIZE);
|
2007-07-13 04:47:50 +08:00
|
|
|
|
2008-02-14 11:22:23 +08:00
|
|
|
hp = NULL;
|
|
|
|
if (paddr) {
|
|
|
|
hp = __va(paddr);
|
|
|
|
mdesc_handle_init(hp, handle_size, hp);
|
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
return hp;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2011-03-31 08:37:56 +08:00
|
|
|
static void __init mdesc_memblock_free(struct mdesc_handle *hp)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2009-12-11 17:16:46 +08:00
|
|
|
unsigned int alloc_size;
|
|
|
|
unsigned long start;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2017-10-20 15:57:57 +08:00
|
|
|
BUG_ON(refcount_read(&hp->refcnt) != 0);
|
2007-07-13 04:47:50 +08:00
|
|
|
BUG_ON(!list_empty(&hp->list));
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2009-12-11 17:16:46 +08:00
|
|
|
alloc_size = PAGE_ALIGN(hp->handle_size);
|
|
|
|
start = __pa(hp);
|
2018-10-31 06:09:25 +08:00
|
|
|
memblock_free_late(start, alloc_size);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 12:36:09 +08:00
|
|
|
static struct mdesc_mem_ops memblock_mdesc_ops = {
|
|
|
|
.alloc = mdesc_memblock_alloc,
|
|
|
|
.free = mdesc_memblock_free,
|
2007-07-13 04:47:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct mdesc_handle *mdesc_kmalloc(unsigned int mdesc_size)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
unsigned int handle_size;
|
2015-04-15 06:47:11 +08:00
|
|
|
struct mdesc_handle *hp;
|
|
|
|
unsigned long addr;
|
2007-07-13 04:47:50 +08:00
|
|
|
void *base;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
handle_size = (sizeof(struct mdesc_handle) -
|
|
|
|
sizeof(struct mdesc_hdr) +
|
|
|
|
mdesc_size);
|
2017-07-13 05:36:45 +08:00
|
|
|
base = kmalloc(handle_size + 15, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
|
2017-06-24 02:58:33 +08:00
|
|
|
if (!base)
|
|
|
|
return NULL;
|
2007-07-13 04:47:50 +08:00
|
|
|
|
2015-04-15 06:47:11 +08:00
|
|
|
addr = (unsigned long)base;
|
|
|
|
addr = (addr + 15UL) & ~15UL;
|
|
|
|
hp = (struct mdesc_handle *) addr;
|
2007-07-13 04:47:50 +08:00
|
|
|
|
2015-04-15 06:47:11 +08:00
|
|
|
mdesc_handle_init(hp, handle_size, base);
|
2007-07-13 04:47:50 +08:00
|
|
|
|
2015-04-15 06:47:11 +08:00
|
|
|
return hp;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static void mdesc_kfree(struct mdesc_handle *hp)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2017-10-20 15:57:57 +08:00
|
|
|
BUG_ON(refcount_read(&hp->refcnt) != 0);
|
2007-07-13 04:47:50 +08:00
|
|
|
BUG_ON(!list_empty(&hp->list));
|
|
|
|
|
|
|
|
kfree(hp->self_base);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static struct mdesc_mem_ops kmalloc_mdesc_memops = {
|
|
|
|
.alloc = mdesc_kmalloc,
|
|
|
|
.free = mdesc_kfree,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct mdesc_handle *mdesc_alloc(unsigned int mdesc_size,
|
|
|
|
struct mdesc_mem_ops *mops)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_handle *hp = mops->alloc(mdesc_size);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
if (hp)
|
|
|
|
hp->mops = mops;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
return hp;
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static void mdesc_free(struct mdesc_handle *hp)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
hp->mops->free(hp);
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static struct mdesc_handle *cur_mdesc;
|
|
|
|
static LIST_HEAD(mdesc_zombie_list);
|
|
|
|
static DEFINE_SPINLOCK(mdesc_lock);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_handle *mdesc_grab(void)
|
|
|
|
{
|
|
|
|
struct mdesc_handle *hp;
|
|
|
|
unsigned long flags;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
spin_lock_irqsave(&mdesc_lock, flags);
|
|
|
|
hp = cur_mdesc;
|
|
|
|
if (hp)
|
2017-10-20 15:57:57 +08:00
|
|
|
refcount_inc(&hp->refcnt);
|
2007-07-13 04:47:50 +08:00
|
|
|
spin_unlock_irqrestore(&mdesc_lock, flags);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
return hp;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
EXPORT_SYMBOL(mdesc_grab);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
void mdesc_release(struct mdesc_handle *hp)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
unsigned long flags;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
spin_lock_irqsave(&mdesc_lock, flags);
|
2017-10-20 15:57:57 +08:00
|
|
|
if (refcount_dec_and_test(&hp->refcnt)) {
|
2007-07-13 04:47:50 +08:00
|
|
|
list_del_init(&hp->list);
|
|
|
|
hp->mops->free(hp);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
spin_unlock_irqrestore(&mdesc_lock, flags);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
EXPORT_SYMBOL(mdesc_release);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-18 12:37:35 +08:00
|
|
|
static DEFINE_MUTEX(mdesc_mutex);
|
|
|
|
static struct mdesc_notifier_client *client_list;
|
|
|
|
|
|
|
|
void mdesc_register_notifier(struct mdesc_notifier_client *client)
|
|
|
|
{
|
2017-06-24 02:58:37 +08:00
|
|
|
bool supported = false;
|
2007-07-18 12:37:35 +08:00
|
|
|
u64 node;
|
2017-06-24 02:58:37 +08:00
|
|
|
int i;
|
2007-07-18 12:37:35 +08:00
|
|
|
|
|
|
|
mutex_lock(&mdesc_mutex);
|
2017-06-24 02:58:37 +08:00
|
|
|
|
|
|
|
/* check to see if the node is supported for registration */
|
|
|
|
for (i = 0; md_node_ops_table[i].name != NULL; i++) {
|
|
|
|
if (strcmp(md_node_ops_table[i].name, client->node_name) == 0) {
|
|
|
|
supported = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!supported) {
|
|
|
|
pr_err("MD: %s node not supported\n", client->node_name);
|
|
|
|
mutex_unlock(&mdesc_mutex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-18 12:37:35 +08:00
|
|
|
client->next = client_list;
|
|
|
|
client_list = client;
|
|
|
|
|
|
|
|
mdesc_for_each_node_by_name(cur_mdesc, node, client->node_name)
|
2017-06-24 02:58:34 +08:00
|
|
|
client->add(cur_mdesc, node, client->node_name);
|
2007-07-18 12:37:35 +08:00
|
|
|
|
|
|
|
mutex_unlock(&mdesc_mutex);
|
|
|
|
}
|
|
|
|
|
2007-07-19 06:15:45 +08:00
|
|
|
static const u64 *parent_cfg_handle(struct mdesc_handle *hp, u64 node)
|
|
|
|
{
|
|
|
|
const u64 *id;
|
|
|
|
u64 a;
|
|
|
|
|
|
|
|
id = NULL;
|
|
|
|
mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) {
|
|
|
|
u64 target;
|
|
|
|
|
|
|
|
target = mdesc_arc_target(hp, a);
|
|
|
|
id = mdesc_get_property(hp, target,
|
|
|
|
"cfg-handle", NULL);
|
|
|
|
if (id)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2017-06-24 02:58:32 +08:00
|
|
|
static int get_vdev_port_node_info(struct mdesc_handle *md, u64 node,
|
|
|
|
union md_node_info *node_info)
|
|
|
|
{
|
|
|
|
const u64 *parent_cfg_hdlp;
|
|
|
|
const char *name;
|
|
|
|
const u64 *idp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual device nodes are distinguished by:
|
|
|
|
* 1. "id" property
|
|
|
|
* 2. "name" property
|
|
|
|
* 3. parent node "cfg-handle" property
|
|
|
|
*/
|
|
|
|
idp = mdesc_get_property(md, node, "id", NULL);
|
|
|
|
name = mdesc_get_property(md, node, "name", NULL);
|
|
|
|
parent_cfg_hdlp = parent_cfg_handle(md, node);
|
|
|
|
|
|
|
|
if (!idp || !name || !parent_cfg_hdlp)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
node_info->vdev_port.id = *idp;
|
|
|
|
node_info->vdev_port.name = kstrdup_const(name, GFP_KERNEL);
|
2019-05-31 09:24:18 +08:00
|
|
|
if (!node_info->vdev_port.name)
|
|
|
|
return -1;
|
2017-06-24 02:58:32 +08:00
|
|
|
node_info->vdev_port.parent_cfg_hdl = *parent_cfg_hdlp;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rel_vdev_port_node_info(union md_node_info *node_info)
|
|
|
|
{
|
|
|
|
if (node_info && node_info->vdev_port.name) {
|
|
|
|
kfree_const(node_info->vdev_port.name);
|
|
|
|
node_info->vdev_port.name = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool vdev_port_node_match(union md_node_info *a_node_info,
|
|
|
|
union md_node_info *b_node_info)
|
|
|
|
{
|
|
|
|
if (a_node_info->vdev_port.id != b_node_info->vdev_port.id)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (a_node_info->vdev_port.parent_cfg_hdl !=
|
|
|
|
b_node_info->vdev_port.parent_cfg_hdl)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (strncmp(a_node_info->vdev_port.name,
|
|
|
|
b_node_info->vdev_port.name, MDESC_MAX_STR_LEN) != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_ds_port_node_info(struct mdesc_handle *md, u64 node,
|
|
|
|
union md_node_info *node_info)
|
|
|
|
{
|
|
|
|
const u64 *idp;
|
|
|
|
|
|
|
|
/* DS port nodes use the "id" property to distinguish them */
|
|
|
|
idp = mdesc_get_property(md, node, "id", NULL);
|
|
|
|
if (!idp)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
node_info->ds_port.id = *idp;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rel_ds_port_node_info(union md_node_info *node_info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ds_port_node_match(union md_node_info *a_node_info,
|
|
|
|
union md_node_info *b_node_info)
|
|
|
|
{
|
|
|
|
if (a_node_info->ds_port.id != b_node_info->ds_port.id)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-07-18 12:37:35 +08:00
|
|
|
/* Run 'func' on nodes which are in A but not in B. */
|
|
|
|
static void invoke_on_missing(const char *name,
|
|
|
|
struct mdesc_handle *a,
|
|
|
|
struct mdesc_handle *b,
|
2017-06-24 02:58:34 +08:00
|
|
|
void (*func)(struct mdesc_handle *, u64,
|
|
|
|
const char *node_name))
|
2007-07-18 12:37:35 +08:00
|
|
|
{
|
2017-06-24 02:58:34 +08:00
|
|
|
mdesc_node_info_get_f get_info_func;
|
|
|
|
mdesc_node_info_rel_f rel_info_func;
|
|
|
|
mdesc_node_match_f node_match_func;
|
|
|
|
union md_node_info a_node_info;
|
|
|
|
union md_node_info b_node_info;
|
|
|
|
bool found;
|
|
|
|
u64 a_node;
|
|
|
|
u64 b_node;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the get_info, rel_info and node_match ops for the given
|
|
|
|
* node name
|
|
|
|
*/
|
|
|
|
mdesc_get_node_ops(name, &get_info_func, &rel_info_func,
|
|
|
|
&node_match_func);
|
|
|
|
|
|
|
|
/* If we didn't find a match, the node type is not supported */
|
|
|
|
if (!get_info_func || !rel_info_func || !node_match_func) {
|
|
|
|
pr_err("MD: %s node type is not supported\n", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdesc_for_each_node_by_name(a, a_node, name) {
|
|
|
|
found = false;
|
2007-07-18 12:37:35 +08:00
|
|
|
|
2017-06-24 02:58:34 +08:00
|
|
|
rv = get_info_func(a, a_node, &a_node_info);
|
|
|
|
if (rv != 0) {
|
|
|
|
pr_err("MD: Cannot find 1 or more required match properties for %s node.\n",
|
|
|
|
name);
|
2007-07-19 06:15:45 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-06-24 02:58:34 +08:00
|
|
|
/* Check each node in B for node matching a_node */
|
|
|
|
mdesc_for_each_node_by_name(b, b_node, name) {
|
|
|
|
rv = get_info_func(b, b_node, &b_node_info);
|
|
|
|
if (rv != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (node_match_func(&a_node_info, &b_node_info)) {
|
|
|
|
found = true;
|
|
|
|
rel_info_func(&b_node_info);
|
2007-07-18 12:37:35 +08:00
|
|
|
break;
|
|
|
|
}
|
2017-06-24 02:58:34 +08:00
|
|
|
|
|
|
|
rel_info_func(&b_node_info);
|
2007-07-18 12:37:35 +08:00
|
|
|
}
|
2017-06-24 02:58:34 +08:00
|
|
|
|
|
|
|
rel_info_func(&a_node_info);
|
|
|
|
|
2007-07-18 12:37:35 +08:00
|
|
|
if (!found)
|
2017-06-24 02:58:34 +08:00
|
|
|
func(a, a_node, name);
|
2007-07-18 12:37:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void notify_one(struct mdesc_notifier_client *p,
|
|
|
|
struct mdesc_handle *old_hp,
|
|
|
|
struct mdesc_handle *new_hp)
|
|
|
|
{
|
|
|
|
invoke_on_missing(p->node_name, old_hp, new_hp, p->remove);
|
|
|
|
invoke_on_missing(p->node_name, new_hp, old_hp, p->add);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mdesc_notify_clients(struct mdesc_handle *old_hp,
|
|
|
|
struct mdesc_handle *new_hp)
|
|
|
|
{
|
|
|
|
struct mdesc_notifier_client *p = client_list;
|
|
|
|
|
|
|
|
while (p) {
|
|
|
|
notify_one(p, old_hp, new_hp);
|
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-17 07:50:36 +08:00
|
|
|
void mdesc_update(void)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
unsigned long len, real_len, status;
|
|
|
|
struct mdesc_handle *hp, *orig_hp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2007-07-18 12:37:35 +08:00
|
|
|
mutex_lock(&mdesc_mutex);
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
(void) sun4v_mach_desc(0UL, 0UL, &len);
|
|
|
|
|
|
|
|
hp = mdesc_alloc(len, &kmalloc_mdesc_memops);
|
|
|
|
if (!hp) {
|
|
|
|
printk(KERN_ERR "MD: mdesc alloc fails\n");
|
2007-07-18 12:37:35 +08:00
|
|
|
goto out;
|
2007-07-13 04:47:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len);
|
|
|
|
if (status != HV_EOK || real_len > len) {
|
|
|
|
printk(KERN_ERR "MD: mdesc reread fails with %lu\n",
|
|
|
|
status);
|
2017-10-20 15:57:57 +08:00
|
|
|
refcount_dec(&hp->refcnt);
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_free(hp);
|
2007-07-18 12:37:35 +08:00
|
|
|
goto out;
|
2007-07-13 04:47:50 +08:00
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
spin_lock_irqsave(&mdesc_lock, flags);
|
|
|
|
orig_hp = cur_mdesc;
|
|
|
|
cur_mdesc = hp;
|
2007-07-18 12:37:35 +08:00
|
|
|
spin_unlock_irqrestore(&mdesc_lock, flags);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-18 12:37:35 +08:00
|
|
|
mdesc_notify_clients(orig_hp, hp);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&mdesc_lock, flags);
|
2017-10-20 15:57:57 +08:00
|
|
|
if (refcount_dec_and_test(&orig_hp->refcnt))
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_free(orig_hp);
|
|
|
|
else
|
|
|
|
list_add(&orig_hp->list, &mdesc_zombie_list);
|
|
|
|
spin_unlock_irqrestore(&mdesc_lock, flags);
|
2007-07-18 12:37:35 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&mdesc_mutex);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2017-06-24 02:58:32 +08:00
|
|
|
u64 mdesc_get_node(struct mdesc_handle *hp, const char *node_name,
|
|
|
|
union md_node_info *node_info)
|
|
|
|
{
|
|
|
|
mdesc_node_info_get_f get_info_func;
|
|
|
|
mdesc_node_info_rel_f rel_info_func;
|
|
|
|
mdesc_node_match_f node_match_func;
|
|
|
|
union md_node_info hp_node_info;
|
|
|
|
u64 hp_node;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
if (hp == NULL || node_name == NULL || node_info == NULL)
|
|
|
|
return MDESC_NODE_NULL;
|
|
|
|
|
|
|
|
/* Find the ops for the given node name */
|
|
|
|
mdesc_get_node_ops(node_name, &get_info_func, &rel_info_func,
|
|
|
|
&node_match_func);
|
|
|
|
|
|
|
|
/* If we didn't find ops for the given node name, it is not supported */
|
|
|
|
if (!get_info_func || !rel_info_func || !node_match_func) {
|
|
|
|
pr_err("MD: %s node is not supported\n", node_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdesc_for_each_node_by_name(hp, hp_node, node_name) {
|
|
|
|
rv = get_info_func(hp, hp_node, &hp_node_info);
|
|
|
|
if (rv != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (node_match_func(node_info, &hp_node_info))
|
|
|
|
break;
|
|
|
|
|
|
|
|
rel_info_func(&hp_node_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
rel_info_func(&hp_node_info);
|
|
|
|
|
|
|
|
return hp_node;
|
|
|
|
}
|
2017-06-24 02:58:39 +08:00
|
|
|
EXPORT_SYMBOL(mdesc_get_node);
|
2017-06-24 02:58:32 +08:00
|
|
|
|
|
|
|
int mdesc_get_node_info(struct mdesc_handle *hp, u64 node,
|
|
|
|
const char *node_name, union md_node_info *node_info)
|
|
|
|
{
|
|
|
|
mdesc_node_info_get_f get_info_func;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
if (hp == NULL || node == MDESC_NODE_NULL ||
|
|
|
|
node_name == NULL || node_info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Find the get_info op for the given node name */
|
|
|
|
mdesc_get_node_ops(node_name, &get_info_func, NULL, NULL);
|
|
|
|
|
|
|
|
/* If we didn't find a get_info_func, the node name is not supported */
|
|
|
|
if (get_info_func == NULL) {
|
|
|
|
pr_err("MD: %s node is not supported\n", node_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = get_info_func(hp, node, node_info);
|
|
|
|
if (rv != 0) {
|
|
|
|
pr_err("MD: Cannot find 1 or more required match properties for %s node.\n",
|
|
|
|
node_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-06-24 02:58:39 +08:00
|
|
|
EXPORT_SYMBOL(mdesc_get_node_info);
|
2017-06-24 02:58:32 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static struct mdesc_elem *node_block(struct mdesc_hdr *mdesc)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
|
|
|
return (struct mdesc_elem *) (mdesc + 1);
|
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static void *name_block(struct mdesc_hdr *mdesc)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
|
|
|
return ((void *) node_block(mdesc)) + mdesc->node_sz;
|
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
static void *data_block(struct mdesc_hdr *mdesc)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
|
|
|
return ((void *) name_block(mdesc)) + mdesc->name_sz;
|
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 mdesc_node_by_name(struct mdesc_handle *hp,
|
|
|
|
u64 from_node, const char *name)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_elem *ep = node_block(&hp->mdesc);
|
|
|
|
const char *names = name_block(&hp->mdesc);
|
|
|
|
u64 last_node = hp->mdesc.node_sz / 16;
|
|
|
|
u64 ret;
|
|
|
|
|
2007-07-17 07:50:36 +08:00
|
|
|
if (from_node == MDESC_NODE_NULL) {
|
|
|
|
ret = from_node = 0;
|
|
|
|
} else if (from_node >= last_node) {
|
2007-07-13 04:47:50 +08:00
|
|
|
return MDESC_NODE_NULL;
|
2007-07-17 07:50:36 +08:00
|
|
|
} else {
|
|
|
|
ret = ep[from_node].d.val;
|
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
|
|
|
|
while (ret < last_node) {
|
|
|
|
if (ep[ret].tag != MD_NODE)
|
|
|
|
return MDESC_NODE_NULL;
|
|
|
|
if (!strcmp(names + ep[ret].name_offset, name))
|
|
|
|
break;
|
|
|
|
ret = ep[ret].d.val;
|
|
|
|
}
|
|
|
|
if (ret >= last_node)
|
|
|
|
ret = MDESC_NODE_NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mdesc_node_by_name);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
const void *mdesc_get_property(struct mdesc_handle *hp, u64 node,
|
|
|
|
const char *name, int *lenp)
|
|
|
|
{
|
|
|
|
const char *names = name_block(&hp->mdesc);
|
|
|
|
u64 last_node = hp->mdesc.node_sz / 16;
|
|
|
|
void *data = data_block(&hp->mdesc);
|
|
|
|
struct mdesc_elem *ep;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
if (node == MDESC_NODE_NULL || node >= last_node)
|
|
|
|
return NULL;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
ep = node_block(&hp->mdesc) + node;
|
|
|
|
ep++;
|
|
|
|
for (; ep->tag != MD_NODE_END; ep++) {
|
|
|
|
void *val = NULL;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
switch (ep->tag) {
|
|
|
|
case MD_PROP_VAL:
|
|
|
|
val = &ep->d.val;
|
|
|
|
len = 8;
|
2007-05-26 06:49:59 +08:00
|
|
|
break;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
case MD_PROP_STR:
|
|
|
|
case MD_PROP_DATA:
|
|
|
|
val = data + ep->d.data.data_offset;
|
|
|
|
len = ep->d.data.data_len;
|
|
|
|
break;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
default:
|
2007-05-26 06:49:59 +08:00
|
|
|
break;
|
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
if (!val)
|
|
|
|
continue;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
if (!strcmp(names + ep->name_offset, name)) {
|
|
|
|
if (lenp)
|
|
|
|
*lenp = len;
|
|
|
|
return val;
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mdesc_get_property);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 mdesc_next_arc(struct mdesc_handle *hp, u64 from, const char *arc_type)
|
|
|
|
{
|
|
|
|
struct mdesc_elem *ep, *base = node_block(&hp->mdesc);
|
|
|
|
const char *names = name_block(&hp->mdesc);
|
|
|
|
u64 last_node = hp->mdesc.node_sz / 16;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
if (from == MDESC_NODE_NULL || from >= last_node)
|
|
|
|
return MDESC_NODE_NULL;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
ep = base + from;
|
|
|
|
|
|
|
|
ep++;
|
|
|
|
for (; ep->tag != MD_NODE_END; ep++) {
|
|
|
|
if (ep->tag != MD_PROP_ARC)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp(names + ep->name_offset, arc_type))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return ep - base;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
|
|
|
|
return MDESC_NODE_NULL;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
EXPORT_SYMBOL(mdesc_next_arc);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_elem *ep, *base = node_block(&hp->mdesc);
|
|
|
|
|
|
|
|
ep = base + arc;
|
|
|
|
|
|
|
|
return ep->d.val;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
EXPORT_SYMBOL(mdesc_arc_target);
|
|
|
|
|
|
|
|
const char *mdesc_node_name(struct mdesc_handle *hp, u64 node)
|
|
|
|
{
|
|
|
|
struct mdesc_elem *ep, *base = node_block(&hp->mdesc);
|
|
|
|
const char *names = name_block(&hp->mdesc);
|
|
|
|
u64 last_node = hp->mdesc.node_sz / 16;
|
|
|
|
|
|
|
|
if (node == MDESC_NODE_NULL || node >= last_node)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ep = base + node;
|
|
|
|
if (ep->tag != MD_NODE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return names + ep->name_offset;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mdesc_node_name);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2011-08-05 17:38:27 +08:00
|
|
|
static u64 max_cpus = 64;
|
|
|
|
|
2007-05-26 06:49:59 +08:00
|
|
|
static void __init report_platform_properties(void)
|
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_handle *hp = mdesc_grab();
|
|
|
|
u64 pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "platform");
|
2007-05-26 06:49:59 +08:00
|
|
|
const char *s;
|
|
|
|
const u64 *v;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
if (pn == MDESC_NODE_NULL) {
|
2007-05-26 06:49:59 +08:00
|
|
|
prom_printf("No platform node in machine-description.\n");
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
s = mdesc_get_property(hp, pn, "banner-name", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
printk("PLATFORM: banner-name [%s]\n", s);
|
2007-07-13 04:47:50 +08:00
|
|
|
s = mdesc_get_property(hp, pn, "name", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
printk("PLATFORM: name [%s]\n", s);
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "hostid", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (v)
|
2009-01-07 05:19:28 +08:00
|
|
|
printk("PLATFORM: hostid [%08llx]\n", *v);
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "serial#", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (v)
|
2009-01-07 05:19:28 +08:00
|
|
|
printk("PLATFORM: serial# [%08llx]\n", *v);
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "stick-frequency", NULL);
|
2009-01-07 05:19:28 +08:00
|
|
|
printk("PLATFORM: stick-frequency [%08llx]\n", *v);
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "mac-address", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (v)
|
2009-01-07 05:19:28 +08:00
|
|
|
printk("PLATFORM: mac-address [%llx]\n", *v);
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "watchdog-resolution", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (v)
|
2009-01-07 05:19:28 +08:00
|
|
|
printk("PLATFORM: watchdog-resolution [%llu ms]\n", *v);
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "watchdog-max-timeout", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (v)
|
2009-01-07 05:19:28 +08:00
|
|
|
printk("PLATFORM: watchdog-max-timeout [%llu ms]\n", *v);
|
2007-07-13 04:47:50 +08:00
|
|
|
v = mdesc_get_property(hp, pn, "max-cpus", NULL);
|
2011-08-05 17:38:27 +08:00
|
|
|
if (v) {
|
|
|
|
max_cpus = *v;
|
|
|
|
printk("PLATFORM: max-cpus [%llu]\n", max_cpus);
|
|
|
|
}
|
2007-07-13 04:47:50 +08:00
|
|
|
|
[SPARC64]: Initial LDOM cpu hotplug support.
Only adding cpus is supports at the moment, removal
will come next.
When new cpus are configured, the machine description is
updated. When we get the configure request we pass in a
cpu mask of to-be-added cpus to the mdesc CPU node parser
so it only fetches information for those cpus. That code
also proceeds to update the SMT/multi-core scheduling bitmaps.
cpu_up() does all the work and we return the status back
over the DS channel.
CPUs via dr-cpu need to be booted straight out of the
hypervisor, and this requires:
1) A new trampoline mechanism. CPUs are booted straight
out of the hypervisor with MMU disabled and running in
physical addresses with no mappings installed in the TLB.
The new hvtramp.S code sets up the critical cpu state,
installs the locked TLB mappings for the kernel, and
turns the MMU on. It then proceeds to follow the logic
of the existing trampoline.S SMP cpu bringup code.
2) All calls into OBP have to be disallowed when domaining
is enabled. Since cpus boot straight into the kernel from
the hypervisor, OBP has no state about that cpu and therefore
cannot handle being invoked on that cpu.
Luckily it's only a handful of interfaces which can be called
after the OBP device tree is obtained. For example, rebooting,
halting, powering-off, and setting options node variables.
CPU removal support will require some infrastructure changes
here. Namely we'll have to process the requests via a true
kernel thread instead of in a workqueue. workqueues run on
a per-cpu thread, but when unconfiguring we might need to
force the thread to execute on another cpu if the current cpu
is the one being removed. Removal of a cpu also causes the kernel
to destroy that cpu's workqueue running thread.
Another issue on removal is that we may have interrupts still
pointing to the cpu-to-be-removed. So new code will be needed
to walk the active INO list and retarget those cpus as-needed.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-14 07:03:42 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
{
|
|
|
|
int max_cpu, i;
|
|
|
|
|
|
|
|
if (v) {
|
|
|
|
max_cpu = *v;
|
|
|
|
if (max_cpu > NR_CPUS)
|
|
|
|
max_cpu = NR_CPUS;
|
|
|
|
} else {
|
|
|
|
max_cpu = NR_CPUS;
|
|
|
|
}
|
|
|
|
for (i = 0; i < max_cpu; i++)
|
2009-03-16 12:10:23 +08:00
|
|
|
set_cpu_possible(i, true);
|
[SPARC64]: Initial LDOM cpu hotplug support.
Only adding cpus is supports at the moment, removal
will come next.
When new cpus are configured, the machine description is
updated. When we get the configure request we pass in a
cpu mask of to-be-added cpus to the mdesc CPU node parser
so it only fetches information for those cpus. That code
also proceeds to update the SMT/multi-core scheduling bitmaps.
cpu_up() does all the work and we return the status back
over the DS channel.
CPUs via dr-cpu need to be booted straight out of the
hypervisor, and this requires:
1) A new trampoline mechanism. CPUs are booted straight
out of the hypervisor with MMU disabled and running in
physical addresses with no mappings installed in the TLB.
The new hvtramp.S code sets up the critical cpu state,
installs the locked TLB mappings for the kernel, and
turns the MMU on. It then proceeds to follow the logic
of the existing trampoline.S SMP cpu bringup code.
2) All calls into OBP have to be disallowed when domaining
is enabled. Since cpus boot straight into the kernel from
the hypervisor, OBP has no state about that cpu and therefore
cannot handle being invoked on that cpu.
Luckily it's only a handful of interfaces which can be called
after the OBP device tree is obtained. For example, rebooting,
halting, powering-off, and setting options node variables.
CPU removal support will require some infrastructure changes
here. Namely we'll have to process the requests via a true
kernel thread instead of in a workqueue. workqueues run on
a per-cpu thread, but when unconfiguring we might need to
force the thread to execute on another cpu if the current cpu
is the one being removed. Removal of a cpu also causes the kernel
to destroy that cpu's workqueue running thread.
Another issue on removal is that we may have interrupts still
pointing to the cpu-to-be-removed. So new code will be needed
to walk the active INO list and retarget those cpus as-needed.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-14 07:03:42 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_release(hp);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
const u64 *level = mdesc_get_property(hp, mp, "level", NULL);
|
|
|
|
const u64 *size = mdesc_get_property(hp, mp, "size", NULL);
|
|
|
|
const u64 *line_size = mdesc_get_property(hp, mp, "line-size", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
const char *type;
|
|
|
|
int type_len;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
type = mdesc_get_property(hp, mp, "type", &type_len);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
|
|
|
switch (*level) {
|
|
|
|
case 1:
|
2007-08-08 09:46:36 +08:00
|
|
|
if (of_find_in_proplist(type, "instn", type_len)) {
|
2007-05-26 06:49:59 +08:00
|
|
|
c->icache_size = *size;
|
|
|
|
c->icache_line_size = *line_size;
|
2007-08-08 09:46:36 +08:00
|
|
|
} else if (of_find_in_proplist(type, "data", type_len)) {
|
2007-05-26 06:49:59 +08:00
|
|
|
c->dcache_size = *size;
|
|
|
|
c->dcache_line_size = *line_size;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
c->ecache_size = *size;
|
|
|
|
c->ecache_line_size = *line_size;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*level == 1) {
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 a;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) {
|
|
|
|
u64 target = mdesc_arc_target(hp, a);
|
|
|
|
const char *name = mdesc_node_name(hp, target);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
if (!strcmp(name, "cache"))
|
|
|
|
fill_in_one_cache(c, hp, target);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
static void find_back_node_value(struct mdesc_handle *hp, u64 node,
|
|
|
|
char *srch_val,
|
|
|
|
void (*func)(struct mdesc_handle *, u64, int),
|
|
|
|
u64 val, int depth)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2015-04-23 00:28:31 +08:00
|
|
|
u64 arc;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
/* Since we have an estimate of recursion depth, do a sanity check. */
|
|
|
|
if (depth == 0)
|
|
|
|
return;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
mdesc_for_each_arc(arc, hp, node, MDESC_ARC_TYPE_BACK) {
|
|
|
|
u64 n = mdesc_arc_target(hp, arc);
|
|
|
|
const char *name = mdesc_node_name(hp, n);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
if (!strcmp(srch_val, name))
|
|
|
|
(*func)(hp, n, val);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
find_back_node_value(hp, n, srch_val, func, val, depth-1);
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
static void __mark_core_id(struct mdesc_handle *hp, u64 node,
|
|
|
|
int core_id)
|
|
|
|
{
|
|
|
|
const u64 *id = mdesc_get_property(hp, node, "id", NULL);
|
|
|
|
|
|
|
|
if (*id < num_possible_cpus())
|
|
|
|
cpu_data(*id).core_id = core_id;
|
|
|
|
}
|
|
|
|
|
2016-10-20 08:33:29 +08:00
|
|
|
static void __mark_max_cache_id(struct mdesc_handle *hp, u64 node,
|
|
|
|
int max_cache_id)
|
2015-04-23 00:28:31 +08:00
|
|
|
{
|
|
|
|
const u64 *id = mdesc_get_property(hp, node, "id", NULL);
|
|
|
|
|
2016-10-20 08:33:29 +08:00
|
|
|
if (*id < num_possible_cpus()) {
|
|
|
|
cpu_data(*id).max_cache_id = max_cache_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On systems without explicit socket descriptions socket
|
|
|
|
* is max_cache_id
|
|
|
|
*/
|
|
|
|
cpu_data(*id).sock_id = max_cache_id;
|
|
|
|
}
|
2015-04-23 00:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mark_core_ids(struct mdesc_handle *hp, u64 mp,
|
|
|
|
int core_id)
|
|
|
|
{
|
|
|
|
find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10);
|
|
|
|
}
|
|
|
|
|
2016-10-20 08:33:29 +08:00
|
|
|
static void mark_max_cache_ids(struct mdesc_handle *hp, u64 mp,
|
|
|
|
int max_cache_id)
|
2015-04-23 00:28:31 +08:00
|
|
|
{
|
2016-10-20 08:33:29 +08:00
|
|
|
find_back_node_value(hp, mp, "cpu", __mark_max_cache_id,
|
|
|
|
max_cache_id, 10);
|
2015-04-23 00:28:31 +08:00
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void set_core_ids(struct mdesc_handle *hp)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
|
|
|
int idx;
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 mp;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
|
|
|
idx = 1;
|
2015-04-23 00:28:31 +08:00
|
|
|
|
|
|
|
/* Identify unique cores by looking for cpus backpointed to by
|
|
|
|
* level 1 instruction caches.
|
|
|
|
*/
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_for_each_node_by_name(hp, mp, "cache") {
|
|
|
|
const u64 *level;
|
2007-05-26 06:49:59 +08:00
|
|
|
const char *type;
|
|
|
|
int len;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
level = mdesc_get_property(hp, mp, "level", NULL);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (*level != 1)
|
|
|
|
continue;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
type = mdesc_get_property(hp, mp, "type", &len);
|
2007-08-08 09:46:36 +08:00
|
|
|
if (!of_find_in_proplist(type, "instn", len))
|
2007-05-26 06:49:59 +08:00
|
|
|
continue;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mark_core_ids(hp, mp, idx);
|
2015-04-23 00:28:31 +08:00
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-20 08:33:29 +08:00
|
|
|
static int set_max_cache_ids_by_cache(struct mdesc_handle *hp, int level)
|
2015-04-23 00:28:31 +08:00
|
|
|
{
|
|
|
|
u64 mp;
|
|
|
|
int idx = 1;
|
|
|
|
int fnd = 0;
|
|
|
|
|
2016-10-20 08:33:29 +08:00
|
|
|
/**
|
|
|
|
* Identify unique highest level of shared cache by looking for cpus
|
|
|
|
* backpointed to by shared level N caches.
|
2015-04-23 00:28:31 +08:00
|
|
|
*/
|
|
|
|
mdesc_for_each_node_by_name(hp, mp, "cache") {
|
|
|
|
const u64 *cur_lvl;
|
|
|
|
|
|
|
|
cur_lvl = mdesc_get_property(hp, mp, "level", NULL);
|
|
|
|
if (*cur_lvl != level)
|
|
|
|
continue;
|
2016-10-20 08:33:29 +08:00
|
|
|
mark_max_cache_ids(hp, mp, idx);
|
2015-04-23 00:28:31 +08:00
|
|
|
idx++;
|
|
|
|
fnd = 1;
|
|
|
|
}
|
|
|
|
return fnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_sock_ids_by_socket(struct mdesc_handle *hp, u64 mp)
|
|
|
|
{
|
|
|
|
int idx = 1;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
mdesc_for_each_node_by_name(hp, mp, "socket") {
|
|
|
|
u64 a;
|
|
|
|
|
|
|
|
mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) {
|
|
|
|
u64 t = mdesc_arc_target(hp, a);
|
|
|
|
const char *name;
|
|
|
|
const u64 *id;
|
|
|
|
|
|
|
|
name = mdesc_node_name(hp, t);
|
|
|
|
if (strcmp(name, "cpu"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
id = mdesc_get_property(hp, t, "id", NULL);
|
|
|
|
if (*id < num_possible_cpus())
|
|
|
|
cpu_data(*id).sock_id = idx;
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-23 00:28:31 +08:00
|
|
|
static void set_sock_ids(struct mdesc_handle *hp)
|
|
|
|
{
|
|
|
|
u64 mp;
|
|
|
|
|
2016-10-20 08:33:29 +08:00
|
|
|
/**
|
|
|
|
* Find the highest level of shared cache which pre-T7 is also
|
|
|
|
* the socket.
|
2015-04-23 00:28:31 +08:00
|
|
|
*/
|
2016-10-20 08:33:29 +08:00
|
|
|
if (!set_max_cache_ids_by_cache(hp, 3))
|
|
|
|
set_max_cache_ids_by_cache(hp, 2);
|
|
|
|
|
|
|
|
/* If machine description exposes sockets data use it.*/
|
2015-04-23 00:28:31 +08:00
|
|
|
mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets");
|
|
|
|
if (mp != MDESC_NODE_NULL)
|
2016-10-20 08:33:29 +08:00
|
|
|
set_sock_ids_by_socket(hp, mp);
|
2015-04-23 00:28:31 +08:00
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id)
|
2007-06-05 08:01:39 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 a;
|
2007-06-05 08:01:39 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) {
|
|
|
|
u64 t = mdesc_arc_target(hp, a);
|
|
|
|
const char *name;
|
2007-06-05 08:01:39 +08:00
|
|
|
const u64 *id;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
name = mdesc_node_name(hp, t);
|
|
|
|
if (strcmp(name, "cpu"))
|
2007-06-05 08:01:39 +08:00
|
|
|
continue;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
id = mdesc_get_property(hp, t, "id", NULL);
|
2007-06-05 08:01:39 +08:00
|
|
|
if (*id < NR_CPUS)
|
|
|
|
cpu_data(*id).proc_id = proc_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name)
|
2007-06-05 08:01:39 +08:00
|
|
|
{
|
|
|
|
int idx;
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 mp;
|
2007-06-05 08:01:39 +08:00
|
|
|
|
|
|
|
idx = 0;
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_for_each_node_by_name(hp, mp, exec_unit_name) {
|
2007-06-05 08:01:39 +08:00
|
|
|
const char *type;
|
|
|
|
int len;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
type = mdesc_get_property(hp, mp, "type", &len);
|
2007-08-08 09:46:36 +08:00
|
|
|
if (!of_find_in_proplist(type, "int", len) &&
|
|
|
|
!of_find_in_proplist(type, "integer", len))
|
2007-06-05 08:01:39 +08:00
|
|
|
continue;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mark_proc_ids(hp, mp, idx);
|
2007-06-05 08:01:39 +08:00
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void set_proc_ids(struct mdesc_handle *hp)
|
2007-06-05 08:01:39 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
__set_proc_ids(hp, "exec_unit");
|
|
|
|
__set_proc_ids(hp, "exec-unit");
|
2007-06-05 08:01:39 +08:00
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void get_one_mondo_bits(const u64 *p, unsigned int *mask,
|
|
|
|
unsigned long def, unsigned long max)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
|
|
|
u64 val;
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
goto use_default;
|
|
|
|
val = *p;
|
|
|
|
|
|
|
|
if (!val || val >= 64)
|
|
|
|
goto use_default;
|
|
|
|
|
2011-08-05 17:38:27 +08:00
|
|
|
if (val > max)
|
|
|
|
val = max;
|
|
|
|
|
2007-05-26 06:49:59 +08:00
|
|
|
*mask = ((1U << val) * 64U) - 1U;
|
|
|
|
return;
|
|
|
|
|
|
|
|
use_default:
|
|
|
|
*mask = ((1U << def) * 64U) - 1U;
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void get_mondo_data(struct mdesc_handle *hp, u64 mp,
|
|
|
|
struct trap_per_cpu *tb)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2011-08-05 17:38:27 +08:00
|
|
|
static int printed;
|
2007-05-26 06:49:59 +08:00
|
|
|
const u64 *val;
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL);
|
2011-08-05 17:38:27 +08:00
|
|
|
get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7, ilog2(max_cpus * 2));
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL);
|
2011-08-05 17:38:27 +08:00
|
|
|
get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7, 8);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL);
|
2011-08-05 17:38:27 +08:00
|
|
|
get_one_mondo_bits(val, &tb->resum_qmask, 6, 7);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL);
|
2011-08-05 17:38:27 +08:00
|
|
|
get_one_mondo_bits(val, &tb->nonresum_qmask, 2, 2);
|
|
|
|
if (!printed++) {
|
|
|
|
pr_info("SUN4V: Mondo queue sizes "
|
|
|
|
"[cpu(%u) dev(%u) r(%u) nr(%u)]\n",
|
|
|
|
tb->cpu_mondo_qmask + 1,
|
|
|
|
tb->dev_mondo_qmask + 1,
|
|
|
|
tb->resum_qmask + 1,
|
|
|
|
tb->nonresum_qmask + 1);
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void *mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask)
|
2007-05-26 06:49:59 +08:00
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_handle *hp = mdesc_grab();
|
2009-04-09 10:55:47 +08:00
|
|
|
void *ret = NULL;
|
2007-07-13 04:47:50 +08:00
|
|
|
u64 mp;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_for_each_node_by_name(hp, mp, "cpu") {
|
|
|
|
const u64 *id = mdesc_get_property(hp, mp, "id", NULL);
|
2009-04-09 10:55:47 +08:00
|
|
|
int cpuid = *id;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
2007-09-17 05:45:06 +08:00
|
|
|
if (cpuid >= NR_CPUS) {
|
|
|
|
printk(KERN_WARNING "Ignoring CPU %d which is "
|
|
|
|
">= NR_CPUS (%d)\n",
|
|
|
|
cpuid, NR_CPUS);
|
2007-05-26 06:49:59 +08:00
|
|
|
continue;
|
2007-09-17 05:45:06 +08:00
|
|
|
}
|
2011-05-17 04:38:07 +08:00
|
|
|
if (!cpumask_test_cpu(cpuid, mask))
|
2007-05-26 06:49:59 +08:00
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
|
2009-04-09 10:55:47 +08:00
|
|
|
ret = func(hp, mp, cpuid, arg);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
mdesc_release(hp);
|
|
|
|
return ret;
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid,
|
|
|
|
void *arg)
|
2009-04-09 10:55:47 +08:00
|
|
|
{
|
|
|
|
ncpus_probed++;
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
set_cpu_present(cpuid, true);
|
|
|
|
#endif
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
void mdesc_populate_present_mask(cpumask_t *mask)
|
2009-04-09 10:55:47 +08:00
|
|
|
{
|
|
|
|
if (tlb_type != hypervisor)
|
|
|
|
return;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2009-04-09 10:55:47 +08:00
|
|
|
ncpus_probed = 0;
|
|
|
|
mdesc_iterate_over_cpus(record_one_cpu, NULL, mask);
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2012-09-07 10:01:25 +08:00
|
|
|
static void * __init check_one_pgsz(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg)
|
|
|
|
{
|
|
|
|
const u64 *pgsz_prop = mdesc_get_property(hp, mp, "mmu-page-size-list", NULL);
|
|
|
|
unsigned long *pgsz_mask = arg;
|
|
|
|
u64 val;
|
|
|
|
|
|
|
|
val = (HV_PGSZ_MASK_8K | HV_PGSZ_MASK_64K |
|
|
|
|
HV_PGSZ_MASK_512K | HV_PGSZ_MASK_4MB);
|
|
|
|
if (pgsz_prop)
|
|
|
|
val = *pgsz_prop;
|
|
|
|
|
|
|
|
if (!*pgsz_mask)
|
|
|
|
*pgsz_mask = val;
|
|
|
|
else
|
|
|
|
*pgsz_mask &= val;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask)
|
|
|
|
{
|
|
|
|
*pgsz_mask = 0;
|
|
|
|
mdesc_iterate_over_cpus(check_one_pgsz, pgsz_mask, mask);
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid,
|
|
|
|
void *arg)
|
2009-04-09 10:55:47 +08:00
|
|
|
{
|
|
|
|
const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL);
|
|
|
|
struct trap_per_cpu *tb;
|
|
|
|
cpuinfo_sparc *c;
|
|
|
|
u64 a;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2009-04-09 10:55:47 +08:00
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
/* On uniprocessor we only want the values for the
|
|
|
|
* real physical cpu the kernel booted onto, however
|
|
|
|
* cpu_data() only has one entry at index 0.
|
|
|
|
*/
|
|
|
|
if (cpuid != real_hard_smp_processor_id())
|
|
|
|
return NULL;
|
|
|
|
cpuid = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
c = &cpu_data(cpuid);
|
|
|
|
c->clock_tick = *cfreq;
|
|
|
|
|
|
|
|
tb = &trap_block[cpuid];
|
|
|
|
get_mondo_data(hp, mp, tb);
|
|
|
|
|
|
|
|
mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) {
|
|
|
|
u64 j, t = mdesc_arc_target(hp, a);
|
|
|
|
const char *t_name;
|
|
|
|
|
|
|
|
t_name = mdesc_node_name(hp, t);
|
|
|
|
if (!strcmp(t_name, "cache")) {
|
|
|
|
fill_in_one_cache(c, hp, t);
|
|
|
|
continue;
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2009-04-09 10:55:47 +08:00
|
|
|
mdesc_for_each_arc(j, hp, t, MDESC_ARC_TYPE_FWD) {
|
|
|
|
u64 n = mdesc_arc_target(hp, j);
|
|
|
|
const char *n_name;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2009-04-09 10:55:47 +08:00
|
|
|
n_name = mdesc_node_name(hp, n);
|
|
|
|
if (!strcmp(n_name, "cache"))
|
|
|
|
fill_in_one_cache(c, hp, n);
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2009-04-09 10:55:47 +08:00
|
|
|
c->core_id = 0;
|
|
|
|
c->proc_id = -1;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
sparc: delete __cpuinit/__CPUINIT usage from all users
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/sparc uses of the __cpuinit macros from
C files and removes __CPUINIT from assembly files. Note that even
though arch/sparc/kernel/trampoline_64.S has instances of ".previous"
in it, they are all paired off against explicit ".section" directives,
and not implicitly paired with __CPUINIT (unlike mips and arm were).
[1] https://lkml.org/lkml/2013/5/20/589
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 03:43:14 +08:00
|
|
|
void mdesc_fill_in_cpu_data(cpumask_t *mask)
|
2009-04-09 10:55:47 +08:00
|
|
|
{
|
|
|
|
struct mdesc_handle *hp;
|
|
|
|
|
2009-04-01 18:15:11 +08:00
|
|
|
mdesc_iterate_over_cpus(fill_in_one_cpu, NULL, mask);
|
2009-04-09 10:55:47 +08:00
|
|
|
|
|
|
|
hp = mdesc_grab();
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
set_core_ids(hp);
|
|
|
|
set_proc_ids(hp);
|
2015-04-23 00:28:31 +08:00
|
|
|
set_sock_ids(hp);
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_release(hp);
|
2009-04-09 10:55:47 +08:00
|
|
|
|
|
|
|
smp_fill_in_sib_core_maps();
|
2007-05-26 06:49:59 +08:00
|
|
|
}
|
|
|
|
|
2014-07-18 23:15:40 +08:00
|
|
|
/* mdesc_open() - Grab a reference to mdesc_handle when /dev/mdesc is
|
|
|
|
* opened. Hold this reference until /dev/mdesc is closed to ensure
|
|
|
|
* mdesc data structure is not released underneath us. Store the
|
|
|
|
* pointer to mdesc structure in private_data for read and seek to use
|
|
|
|
*/
|
|
|
|
static int mdesc_open(struct inode *inode, struct file *file)
|
2007-08-16 12:02:23 +08:00
|
|
|
{
|
|
|
|
struct mdesc_handle *hp = mdesc_grab();
|
|
|
|
|
|
|
|
if (!hp)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2014-07-18 23:15:40 +08:00
|
|
|
file->private_data = hp;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t mdesc_read(struct file *file, char __user *buf,
|
|
|
|
size_t len, loff_t *offp)
|
|
|
|
{
|
|
|
|
struct mdesc_handle *hp = file->private_data;
|
|
|
|
unsigned char *mdesc;
|
|
|
|
int bytes_left, count = len;
|
|
|
|
|
|
|
|
if (*offp >= hp->handle_size)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
bytes_left = hp->handle_size - *offp;
|
|
|
|
if (count > bytes_left)
|
|
|
|
count = bytes_left;
|
|
|
|
|
|
|
|
mdesc = (unsigned char *)&hp->mdesc;
|
|
|
|
mdesc += *offp;
|
|
|
|
if (!copy_to_user(buf, mdesc, count)) {
|
|
|
|
*offp += count;
|
|
|
|
return count;
|
|
|
|
} else {
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
2007-08-16 12:02:23 +08:00
|
|
|
|
2014-07-18 23:15:40 +08:00
|
|
|
static loff_t mdesc_llseek(struct file *file, loff_t offset, int whence)
|
|
|
|
{
|
2015-12-06 11:04:48 +08:00
|
|
|
struct mdesc_handle *hp = file->private_data;
|
2014-07-18 23:15:40 +08:00
|
|
|
|
2015-12-06 11:04:48 +08:00
|
|
|
return no_seek_end_llseek_size(file, offset, whence, hp->handle_size);
|
2014-07-18 23:15:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mdesc_close() - /dev/mdesc is being closed, release the reference to
|
|
|
|
* mdesc structure.
|
|
|
|
*/
|
|
|
|
static int mdesc_close(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
mdesc_release(file->private_data);
|
|
|
|
return 0;
|
2007-08-16 12:02:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations mdesc_fops = {
|
2014-07-18 23:15:40 +08:00
|
|
|
.open = mdesc_open,
|
|
|
|
.read = mdesc_read,
|
|
|
|
.llseek = mdesc_llseek,
|
|
|
|
.release = mdesc_close,
|
|
|
|
.owner = THIS_MODULE,
|
2007-08-16 12:02:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct miscdevice mdesc_misc = {
|
|
|
|
.minor = MISC_DYNAMIC_MINOR,
|
|
|
|
.name = "mdesc",
|
|
|
|
.fops = &mdesc_fops,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init mdesc_misc_init(void)
|
|
|
|
{
|
|
|
|
return misc_register(&mdesc_misc);
|
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(mdesc_misc_init);
|
|
|
|
|
2007-05-26 06:49:59 +08:00
|
|
|
void __init sun4v_mdesc_init(void)
|
|
|
|
{
|
2007-07-13 04:47:50 +08:00
|
|
|
struct mdesc_handle *hp;
|
2007-05-26 06:49:59 +08:00
|
|
|
unsigned long len, real_len, status;
|
|
|
|
|
|
|
|
(void) sun4v_mach_desc(0UL, 0UL, &len);
|
|
|
|
|
|
|
|
printk("MDESC: Size is %lu bytes.\n", len);
|
|
|
|
|
2010-07-12 12:36:09 +08:00
|
|
|
hp = mdesc_alloc(len, &memblock_mdesc_ops);
|
2007-07-13 04:47:50 +08:00
|
|
|
if (hp == NULL) {
|
|
|
|
prom_printf("MDESC: alloc of %lu bytes failed.\n", len);
|
|
|
|
prom_halt();
|
|
|
|
}
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len);
|
2007-05-26 06:49:59 +08:00
|
|
|
if (status != HV_EOK || real_len > len) {
|
|
|
|
prom_printf("sun4v_mach_desc fails, err(%lu), "
|
|
|
|
"len(%lu), real_len(%lu)\n",
|
|
|
|
status, len, real_len);
|
2007-07-13 04:47:50 +08:00
|
|
|
mdesc_free(hp);
|
2007-05-26 06:49:59 +08:00
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
2007-07-13 04:47:50 +08:00
|
|
|
cur_mdesc = hp;
|
2007-05-26 06:49:59 +08:00
|
|
|
|
2018-02-22 01:15:48 +08:00
|
|
|
mdesc_adi_init();
|
2007-05-26 06:49:59 +08:00
|
|
|
report_platform_properties();
|
|
|
|
}
|