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 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
2008-07-03 03:50:26 +07:00
|
|
|
#include <linux/topology.h>
|
x86: fix: make PCI ECS for AMD CPUs hotplug capable
Until now, PCI ECS setup was performed at boot time only and for cpus
that are enabled then. This patch fixes this and adds cpu hotplug.
Tests sequence (check if ECS bit is set when bringing cpu online again):
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
# ( perl -e 'sysseek(STDOUT, 0xC001001F, 0); print pack "l*", 8, 0x00400010' ) > /dev/cpu/1/msr
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00400010
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 1 > /sys/devices/system/cpu/cpu1/online
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-23 01:23:38 +07:00
|
|
|
#include <linux/cpu.h>
|
2010-02-10 16:20:07 +07:00
|
|
|
#include <linux/range.h>
|
|
|
|
|
2011-01-10 23:20:23 +07:00
|
|
|
#include <asm/amd_nb.h>
|
2008-12-27 20:02:28 +07:00
|
|
|
#include <asm/pci_x86.h>
|
2008-06-13 01:19:23 +07:00
|
|
|
|
x86: get mp_bus_to_node early
Currently, on an amd k8 system with multi ht chains, the numa_node of
pci devices under /sys/devices/pci0000:80/* is always 0, even if that
chain is on node 1 or 2 or 3.
Workaround: pcibus_to_node(bus) is used when we want to get the node that
pci_device is on.
In struct device, we already have numa_node member, and we could use
dev_to_node()/set_dev_node() to get and set numa_node in the device.
set_dev_node is called in pci_device_add() with pcibus_to_node(bus),
and pcibus_to_node uses bus->sysdata for nodeid.
The problem is when pci_add_device is called, bus->sysdata is not assigned
correct nodeid yet. The result is that numa_node will always be 0.
pcibios_scan_root and pci_scan_root could take sysdata. So we need to get
mp_bus_to_node mapping before these two are called, and thus
get_mp_bus_to_node could get correct node for sysdata in root bus.
In scanning of the root bus, all child busses will take parent bus sysdata.
So all pci_device->dev.numa_node will be assigned correctly and automatically.
Later we could use dev_to_node(&pci_dev->dev) to get numa_node, and we
could also could make other bus specific device get the correct numa_node
too.
This is an updated version of pci_sysdata and Jeff's pci_domain patch.
[ mingo@elte.hu: build fix ]
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-02-19 18:20:09 +07:00
|
|
|
#include <asm/pci-direct.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-10-05 11:54:24 +07:00
|
|
|
#include "bus_numa.h"
|
|
|
|
|
2014-05-08 23:44:19 +07:00
|
|
|
#define AMD_NB_F0_NODE_ID 0x60
|
|
|
|
#define AMD_NB_F0_UNIT_ID 0x64
|
|
|
|
#define AMD_NB_F1_CONFIG_MAP_REG 0xe0
|
|
|
|
|
|
|
|
#define RANGE_NUM 16
|
|
|
|
#define AMD_NB_F1_CONFIG_MAP_RANGES 4
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-05-08 23:44:19 +07:00
|
|
|
struct amd_hostbridge {
|
2008-02-19 18:21:20 +07:00
|
|
|
u32 bus;
|
|
|
|
u32 slot;
|
|
|
|
u32 device;
|
|
|
|
};
|
|
|
|
|
2014-05-08 23:44:19 +07:00
|
|
|
/*
|
|
|
|
* IMPORTANT NOTE:
|
|
|
|
* hb_probes[] and early_root_info_init() is in maintenance mode.
|
|
|
|
* It only supports K8, Fam10h, Fam11h, and Fam15h_00h-0fh .
|
|
|
|
* Future processor will rely on information in ACPI.
|
|
|
|
*/
|
|
|
|
static struct amd_hostbridge hb_probes[] __initdata = {
|
|
|
|
{ 0, 0x18, 0x1100 }, /* K8 */
|
|
|
|
{ 0, 0x18, 0x1200 }, /* Family10h */
|
|
|
|
{ 0xff, 0, 0x1200 }, /* Family10h */
|
|
|
|
{ 0, 0x18, 0x1300 }, /* Family11h */
|
|
|
|
{ 0, 0x18, 0x1600 }, /* Family15h */
|
2008-02-19 18:21:20 +07:00
|
|
|
};
|
|
|
|
|
2012-04-03 08:31:54 +07:00
|
|
|
static struct pci_root_info __init *find_pci_root_info(int node, int link)
|
|
|
|
{
|
|
|
|
struct pci_root_info *info;
|
|
|
|
|
|
|
|
/* find the position */
|
|
|
|
list_for_each_entry(info, &pci_root_infos, list)
|
|
|
|
if (info->node == node && info->link == link)
|
|
|
|
return info;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/**
|
2014-05-08 23:44:19 +07:00
|
|
|
* early_root_info_init()
|
x86: get mp_bus_to_node early
Currently, on an amd k8 system with multi ht chains, the numa_node of
pci devices under /sys/devices/pci0000:80/* is always 0, even if that
chain is on node 1 or 2 or 3.
Workaround: pcibus_to_node(bus) is used when we want to get the node that
pci_device is on.
In struct device, we already have numa_node member, and we could use
dev_to_node()/set_dev_node() to get and set numa_node in the device.
set_dev_node is called in pci_device_add() with pcibus_to_node(bus),
and pcibus_to_node uses bus->sysdata for nodeid.
The problem is when pci_add_device is called, bus->sysdata is not assigned
correct nodeid yet. The result is that numa_node will always be 0.
pcibios_scan_root and pci_scan_root could take sysdata. So we need to get
mp_bus_to_node mapping before these two are called, and thus
get_mp_bus_to_node could get correct node for sysdata in root bus.
In scanning of the root bus, all child busses will take parent bus sysdata.
So all pci_device->dev.numa_node will be assigned correctly and automatically.
Later we could use dev_to_node(&pci_dev->dev) to get numa_node, and we
could also could make other bus specific device get the correct numa_node
too.
This is an updated version of pci_sysdata and Jeff's pci_domain patch.
[ mingo@elte.hu: build fix ]
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-02-19 18:20:09 +07:00
|
|
|
* called before pcibios_scan_root and pci_scan_bus
|
2014-05-08 23:44:19 +07:00
|
|
|
* fills the mp_bus_to_cpumask array based according
|
|
|
|
* to the LDT Bus Number Registers found in the northbridge.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2014-05-08 23:44:19 +07:00
|
|
|
static int __init early_root_info_init(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-02-19 18:21:20 +07:00
|
|
|
int i;
|
|
|
|
unsigned bus;
|
x86: get mp_bus_to_node early
Currently, on an amd k8 system with multi ht chains, the numa_node of
pci devices under /sys/devices/pci0000:80/* is always 0, even if that
chain is on node 1 or 2 or 3.
Workaround: pcibus_to_node(bus) is used when we want to get the node that
pci_device is on.
In struct device, we already have numa_node member, and we could use
dev_to_node()/set_dev_node() to get and set numa_node in the device.
set_dev_node is called in pci_device_add() with pcibus_to_node(bus),
and pcibus_to_node uses bus->sysdata for nodeid.
The problem is when pci_add_device is called, bus->sysdata is not assigned
correct nodeid yet. The result is that numa_node will always be 0.
pcibios_scan_root and pci_scan_root could take sysdata. So we need to get
mp_bus_to_node mapping before these two are called, and thus
get_mp_bus_to_node could get correct node for sysdata in root bus.
In scanning of the root bus, all child busses will take parent bus sysdata.
So all pci_device->dev.numa_node will be assigned correctly and automatically.
Later we could use dev_to_node(&pci_dev->dev) to get numa_node, and we
could also could make other bus specific device get the correct numa_node
too.
This is an updated version of pci_sysdata and Jeff's pci_domain patch.
[ mingo@elte.hu: build fix ]
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-02-19 18:20:09 +07:00
|
|
|
unsigned slot;
|
2008-02-19 18:15:08 +07:00
|
|
|
int node;
|
2008-02-19 18:21:20 +07:00
|
|
|
int link;
|
|
|
|
int def_node;
|
|
|
|
int def_link;
|
|
|
|
struct pci_root_info *info;
|
|
|
|
u32 reg;
|
2010-02-10 16:20:10 +07:00
|
|
|
u64 start;
|
|
|
|
u64 end;
|
2010-02-10 16:20:07 +07:00
|
|
|
struct range range[RANGE_NUM];
|
2008-02-19 18:21:20 +07:00
|
|
|
u64 val;
|
|
|
|
u32 address;
|
2010-02-10 16:20:09 +07:00
|
|
|
bool found;
|
2012-01-06 04:27:19 +07:00
|
|
|
struct resource fam10h_mmconf_res, *fam10h_mmconf;
|
|
|
|
u64 fam10h_mmconf_start;
|
|
|
|
u64 fam10h_mmconf_end;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
x86: get mp_bus_to_node early
Currently, on an amd k8 system with multi ht chains, the numa_node of
pci devices under /sys/devices/pci0000:80/* is always 0, even if that
chain is on node 1 or 2 or 3.
Workaround: pcibus_to_node(bus) is used when we want to get the node that
pci_device is on.
In struct device, we already have numa_node member, and we could use
dev_to_node()/set_dev_node() to get and set numa_node in the device.
set_dev_node is called in pci_device_add() with pcibus_to_node(bus),
and pcibus_to_node uses bus->sysdata for nodeid.
The problem is when pci_add_device is called, bus->sysdata is not assigned
correct nodeid yet. The result is that numa_node will always be 0.
pcibios_scan_root and pci_scan_root could take sysdata. So we need to get
mp_bus_to_node mapping before these two are called, and thus
get_mp_bus_to_node could get correct node for sysdata in root bus.
In scanning of the root bus, all child busses will take parent bus sysdata.
So all pci_device->dev.numa_node will be assigned correctly and automatically.
Later we could use dev_to_node(&pci_dev->dev) to get numa_node, and we
could also could make other bus specific device get the correct numa_node
too.
This is an updated version of pci_sysdata and Jeff's pci_domain patch.
[ mingo@elte.hu: build fix ]
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-02-19 18:20:09 +07:00
|
|
|
if (!early_pci_allowed())
|
|
|
|
return -1;
|
|
|
|
|
2010-02-10 16:20:09 +07:00
|
|
|
found = false;
|
2014-05-08 23:44:19 +07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(hb_probes); i++) {
|
2008-02-19 18:21:20 +07:00
|
|
|
u32 id;
|
|
|
|
u16 device;
|
|
|
|
u16 vendor;
|
2008-02-19 18:15:08 +07:00
|
|
|
|
2014-05-08 23:44:19 +07:00
|
|
|
bus = hb_probes[i].bus;
|
|
|
|
slot = hb_probes[i].slot;
|
2008-02-19 18:21:20 +07:00
|
|
|
id = read_pci_config(bus, slot, 0, PCI_VENDOR_ID);
|
|
|
|
vendor = id & 0xffff;
|
|
|
|
device = (id>>16) & 0xffff;
|
2014-05-08 23:44:19 +07:00
|
|
|
|
|
|
|
if (vendor != PCI_VENDOR_ID_AMD)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (hb_probes[i].device == device) {
|
2010-02-10 16:20:09 +07:00
|
|
|
found = true;
|
2008-02-19 18:21:20 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-10 16:20:09 +07:00
|
|
|
if (!found)
|
2008-02-19 18:21:20 +07:00
|
|
|
return 0;
|
2008-02-19 18:15:08 +07:00
|
|
|
|
2014-05-08 23:44:18 +07:00
|
|
|
/*
|
|
|
|
* We should learn topology and routing information from _PXM and
|
|
|
|
* _CRS methods in the ACPI namespace. We extract node numbers
|
|
|
|
* here to work around BIOSes that don't supply _PXM.
|
|
|
|
*/
|
2014-05-08 23:44:19 +07:00
|
|
|
for (i = 0; i < AMD_NB_F1_CONFIG_MAP_RANGES; i++) {
|
2008-02-19 18:21:20 +07:00
|
|
|
int min_bus;
|
|
|
|
int max_bus;
|
2014-05-08 23:44:19 +07:00
|
|
|
reg = read_pci_config(bus, slot, 1,
|
|
|
|
AMD_NB_F1_CONFIG_MAP_REG + (i << 2));
|
2008-02-19 18:15:08 +07:00
|
|
|
|
|
|
|
/* Check if that register is enabled for bus range */
|
2008-02-19 18:21:20 +07:00
|
|
|
if ((reg & 7) != 3)
|
2008-02-19 18:15:08 +07:00
|
|
|
continue;
|
|
|
|
|
2008-02-19 18:21:20 +07:00
|
|
|
min_bus = (reg >> 16) & 0xff;
|
|
|
|
max_bus = (reg >> 24) & 0xff;
|
|
|
|
node = (reg >> 4) & 0x07;
|
|
|
|
link = (reg >> 8) & 0x03;
|
|
|
|
|
2012-04-03 08:31:54 +07:00
|
|
|
info = alloc_pci_root_info(min_bus, max_bus, node, link);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2014-05-08 23:44:18 +07:00
|
|
|
/*
|
|
|
|
* The following code extracts routing information for use on old
|
|
|
|
* systems where Linux doesn't automatically use host bridge _CRS
|
|
|
|
* methods (or when the user specifies "pci=nocrs").
|
|
|
|
*
|
|
|
|
* We only do this through Fam11h, because _CRS should be enough on
|
|
|
|
* newer systems.
|
|
|
|
*/
|
|
|
|
if (boot_cpu_data.x86 > 0x11)
|
|
|
|
return 0;
|
|
|
|
|
2008-02-19 18:21:20 +07:00
|
|
|
/* get the default node and link for left over res */
|
2014-05-08 23:44:19 +07:00
|
|
|
reg = read_pci_config(bus, slot, 0, AMD_NB_F0_NODE_ID);
|
2008-02-19 18:21:20 +07:00
|
|
|
def_node = (reg >> 8) & 0x07;
|
2014-05-08 23:44:19 +07:00
|
|
|
reg = read_pci_config(bus, slot, 0, AMD_NB_F0_UNIT_ID);
|
2008-02-19 18:21:20 +07:00
|
|
|
def_link = (reg >> 8) & 0x03;
|
|
|
|
|
|
|
|
memset(range, 0, sizeof(range));
|
2010-02-10 16:20:13 +07:00
|
|
|
add_range(range, RANGE_NUM, 0, 0, 0xffff + 1);
|
2008-02-19 18:21:20 +07:00
|
|
|
/* io port resource */
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
reg = read_pci_config(bus, slot, 1, 0xc0 + (i << 3));
|
|
|
|
if (!(reg & 3))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
start = reg & 0xfff000;
|
|
|
|
reg = read_pci_config(bus, slot, 1, 0xc4 + (i << 3));
|
|
|
|
node = reg & 0x07;
|
|
|
|
link = (reg >> 4) & 0x03;
|
|
|
|
end = (reg & 0xfff000) | 0xfff;
|
|
|
|
|
2012-04-03 08:31:54 +07:00
|
|
|
info = find_pci_root_info(node, link);
|
|
|
|
if (!info)
|
2008-02-19 18:21:20 +07:00
|
|
|
continue; /* not found */
|
|
|
|
|
2008-03-06 16:15:31 +07:00
|
|
|
printk(KERN_DEBUG "node %d link %d: io port [%llx, %llx]\n",
|
2010-02-10 16:20:10 +07:00
|
|
|
node, link, start, end);
|
2008-04-13 15:41:58 +07:00
|
|
|
|
|
|
|
/* kernel only handle 16 bit only */
|
|
|
|
if (end > 0xffff)
|
|
|
|
end = 0xffff;
|
|
|
|
update_res(info, start, end, IORESOURCE_IO, 1);
|
2010-02-10 16:20:13 +07:00
|
|
|
subtract_range(range, RANGE_NUM, start, end + 1);
|
2008-02-19 18:21:20 +07:00
|
|
|
}
|
|
|
|
/* add left over io port range to def node/link, [0, 0xffff] */
|
|
|
|
/* find the position */
|
2012-04-03 08:31:54 +07:00
|
|
|
info = find_pci_root_info(def_node, def_link);
|
|
|
|
if (info) {
|
2008-02-19 18:21:20 +07:00
|
|
|
for (i = 0; i < RANGE_NUM; i++) {
|
|
|
|
if (!range[i].end)
|
|
|
|
continue;
|
|
|
|
|
2010-02-10 16:20:13 +07:00
|
|
|
update_res(info, range[i].start, range[i].end - 1,
|
2008-02-19 18:21:20 +07:00
|
|
|
IORESOURCE_IO, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(range, 0, sizeof(range));
|
|
|
|
/* 0xfd00000000-0xffffffffff for HT */
|
2010-02-10 16:20:13 +07:00
|
|
|
end = cap_resource((0xfdULL<<32) - 1);
|
|
|
|
end++;
|
|
|
|
add_range(range, RANGE_NUM, 0, 0, end);
|
2008-02-19 18:21:20 +07:00
|
|
|
|
|
|
|
/* need to take out [0, TOM) for RAM*/
|
|
|
|
address = MSR_K8_TOP_MEM1;
|
|
|
|
rdmsrl(address, val);
|
2008-05-13 07:40:39 +07:00
|
|
|
end = (val & 0xffffff800000ULL);
|
2010-02-10 16:20:10 +07:00
|
|
|
printk(KERN_INFO "TOM: %016llx aka %lldM\n", end, end>>20);
|
2008-02-19 18:21:20 +07:00
|
|
|
if (end < (1ULL<<32))
|
2010-02-10 16:20:13 +07:00
|
|
|
subtract_range(range, RANGE_NUM, 0, end);
|
2008-02-19 18:21:20 +07:00
|
|
|
|
2008-03-06 16:15:31 +07:00
|
|
|
/* get mmconfig */
|
2012-01-06 04:27:19 +07:00
|
|
|
fam10h_mmconf = amd_get_mmconfig_range(&fam10h_mmconf_res);
|
2008-03-06 16:15:31 +07:00
|
|
|
/* need to take out mmconf range */
|
2012-01-06 04:27:19 +07:00
|
|
|
if (fam10h_mmconf) {
|
|
|
|
printk(KERN_DEBUG "Fam 10h mmconf %pR\n", fam10h_mmconf);
|
|
|
|
fam10h_mmconf_start = fam10h_mmconf->start;
|
|
|
|
fam10h_mmconf_end = fam10h_mmconf->end;
|
2010-02-10 16:20:13 +07:00
|
|
|
subtract_range(range, RANGE_NUM, fam10h_mmconf_start,
|
|
|
|
fam10h_mmconf_end + 1);
|
2012-01-06 04:27:19 +07:00
|
|
|
} else {
|
|
|
|
fam10h_mmconf_start = 0;
|
|
|
|
fam10h_mmconf_end = 0;
|
2008-03-06 16:15:31 +07:00
|
|
|
}
|
|
|
|
|
2008-02-19 18:21:20 +07:00
|
|
|
/* mmio resource */
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
reg = read_pci_config(bus, slot, 1, 0x80 + (i << 3));
|
|
|
|
if (!(reg & 3))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
start = reg & 0xffffff00; /* 39:16 on 31:8*/
|
|
|
|
start <<= 8;
|
|
|
|
reg = read_pci_config(bus, slot, 1, 0x84 + (i << 3));
|
|
|
|
node = reg & 0x07;
|
|
|
|
link = (reg >> 4) & 0x03;
|
|
|
|
end = (reg & 0xffffff00);
|
|
|
|
end <<= 8;
|
|
|
|
end |= 0xffff;
|
|
|
|
|
2012-04-03 08:31:54 +07:00
|
|
|
info = find_pci_root_info(node, link);
|
2008-02-19 18:21:20 +07:00
|
|
|
|
2012-04-03 08:31:54 +07:00
|
|
|
if (!info)
|
|
|
|
continue;
|
2008-03-06 16:15:31 +07:00
|
|
|
|
|
|
|
printk(KERN_DEBUG "node %d link %d: mmio [%llx, %llx]",
|
2010-02-10 16:20:10 +07:00
|
|
|
node, link, start, end);
|
2008-03-06 16:15:31 +07:00
|
|
|
/*
|
|
|
|
* some sick allocation would have range overlap with fam10h
|
|
|
|
* mmconf range, so need to update start and end.
|
|
|
|
*/
|
|
|
|
if (fam10h_mmconf_end) {
|
|
|
|
int changed = 0;
|
|
|
|
u64 endx = 0;
|
|
|
|
if (start >= fam10h_mmconf_start &&
|
|
|
|
start <= fam10h_mmconf_end) {
|
|
|
|
start = fam10h_mmconf_end + 1;
|
|
|
|
changed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end >= fam10h_mmconf_start &&
|
|
|
|
end <= fam10h_mmconf_end) {
|
|
|
|
end = fam10h_mmconf_start - 1;
|
|
|
|
changed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start < fam10h_mmconf_start &&
|
|
|
|
end > fam10h_mmconf_end) {
|
|
|
|
/* we got a hole */
|
|
|
|
endx = fam10h_mmconf_start - 1;
|
|
|
|
update_res(info, start, endx, IORESOURCE_MEM, 0);
|
2010-02-10 16:20:13 +07:00
|
|
|
subtract_range(range, RANGE_NUM, start,
|
|
|
|
endx + 1);
|
2010-02-10 16:20:10 +07:00
|
|
|
printk(KERN_CONT " ==> [%llx, %llx]", start, endx);
|
2008-03-06 16:15:31 +07:00
|
|
|
start = fam10h_mmconf_end + 1;
|
|
|
|
changed = 1;
|
|
|
|
}
|
|
|
|
if (changed) {
|
|
|
|
if (start <= end) {
|
2010-02-10 16:20:10 +07:00
|
|
|
printk(KERN_CONT " %s [%llx, %llx]", endx ? "and" : "==>", start, end);
|
2008-03-06 16:15:31 +07:00
|
|
|
} else {
|
|
|
|
printk(KERN_CONT "%s\n", endx?"":" ==> none");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-10 16:20:11 +07:00
|
|
|
update_res(info, cap_resource(start), cap_resource(end),
|
|
|
|
IORESOURCE_MEM, 1);
|
2010-02-10 16:20:13 +07:00
|
|
|
subtract_range(range, RANGE_NUM, start, end + 1);
|
2008-03-06 16:15:31 +07:00
|
|
|
printk(KERN_CONT "\n");
|
2008-02-19 18:21:20 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* need to take out [4G, TOM2) for RAM*/
|
|
|
|
/* SYS_CFG */
|
|
|
|
address = MSR_K8_SYSCFG;
|
|
|
|
rdmsrl(address, val);
|
|
|
|
/* TOP_MEM2 is enabled? */
|
|
|
|
if (val & (1<<21)) {
|
|
|
|
/* TOP_MEM2 */
|
|
|
|
address = MSR_K8_TOP_MEM2;
|
|
|
|
rdmsrl(address, val);
|
2008-05-13 07:40:39 +07:00
|
|
|
end = (val & 0xffffff800000ULL);
|
2010-02-10 16:20:10 +07:00
|
|
|
printk(KERN_INFO "TOM2: %016llx aka %lldM\n", end, end>>20);
|
2010-02-10 16:20:13 +07:00
|
|
|
subtract_range(range, RANGE_NUM, 1ULL<<32, end);
|
2008-02-19 18:21:20 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* add left over mmio range to def node/link ?
|
|
|
|
* that is tricky, just record range in from start_min to 4G
|
|
|
|
*/
|
2012-04-03 08:31:54 +07:00
|
|
|
info = find_pci_root_info(def_node, def_link);
|
|
|
|
if (info) {
|
2008-02-19 18:21:20 +07:00
|
|
|
for (i = 0; i < RANGE_NUM; i++) {
|
|
|
|
if (!range[i].end)
|
|
|
|
continue;
|
|
|
|
|
2010-02-10 16:20:11 +07:00
|
|
|
update_res(info, cap_resource(range[i].start),
|
2010-02-10 16:20:13 +07:00
|
|
|
cap_resource(range[i].end - 1),
|
2008-02-19 18:21:20 +07:00
|
|
|
IORESOURCE_MEM, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-03 08:31:54 +07:00
|
|
|
list_for_each_entry(info, &pci_root_infos, list) {
|
2008-02-19 18:21:20 +07:00
|
|
|
int busnum;
|
2012-04-03 08:31:54 +07:00
|
|
|
struct pci_root_res *root_res;
|
2008-02-19 18:21:20 +07:00
|
|
|
|
2012-05-18 08:51:12 +07:00
|
|
|
busnum = info->busn.start;
|
|
|
|
printk(KERN_DEBUG "bus: %pR on node %x link %x\n",
|
|
|
|
&info->busn, info->node, info->link);
|
2012-04-03 08:31:54 +07:00
|
|
|
list_for_each_entry(root_res, &info->resources, list)
|
|
|
|
printk(KERN_DEBUG "bus: %02x %pR\n",
|
|
|
|
busnum, &root_res->res);
|
2008-02-19 18:21:20 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-13 01:19:23 +07:00
|
|
|
#define ENABLE_CF8_EXT_CFG (1ULL << 46)
|
|
|
|
|
2016-11-18 01:35:41 +07:00
|
|
|
static int amd_bus_cpu_online(unsigned int cpu)
|
2008-06-13 01:19:23 +07:00
|
|
|
{
|
|
|
|
u64 reg;
|
2016-11-18 01:35:41 +07:00
|
|
|
|
2008-06-13 01:19:23 +07:00
|
|
|
rdmsrl(MSR_AMD64_NB_CFG, reg);
|
|
|
|
if (!(reg & ENABLE_CF8_EXT_CFG)) {
|
|
|
|
reg |= ENABLE_CF8_EXT_CFG;
|
|
|
|
wrmsrl(MSR_AMD64_NB_CFG, reg);
|
|
|
|
}
|
2016-11-18 01:35:41 +07:00
|
|
|
return 0;
|
2008-06-13 01:19:23 +07:00
|
|
|
}
|
|
|
|
|
2011-01-10 23:20:23 +07:00
|
|
|
static void __init pci_enable_pci_io_ecs(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_AMD_NB
|
|
|
|
unsigned int i, n;
|
|
|
|
|
|
|
|
for (n = i = 0; !n && amd_nb_bus_dev_ranges[i].dev_limit; ++i) {
|
|
|
|
u8 bus = amd_nb_bus_dev_ranges[i].bus;
|
|
|
|
u8 slot = amd_nb_bus_dev_ranges[i].dev_base;
|
|
|
|
u8 limit = amd_nb_bus_dev_ranges[i].dev_limit;
|
|
|
|
|
|
|
|
for (; slot < limit; ++slot) {
|
|
|
|
u32 val = read_pci_config(bus, slot, 3, 0);
|
|
|
|
|
|
|
|
if (!early_is_amd_nb(val))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
val = read_pci_config(bus, slot, 3, 0x8c);
|
|
|
|
if (!(val & (ENABLE_CF8_EXT_CFG >> 32))) {
|
|
|
|
val |= ENABLE_CF8_EXT_CFG >> 32;
|
|
|
|
write_pci_config(bus, slot, 3, 0x8c, val);
|
|
|
|
}
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
x86: fix: make PCI ECS for AMD CPUs hotplug capable
Until now, PCI ECS setup was performed at boot time only and for cpus
that are enabled then. This patch fixes this and adds cpu hotplug.
Tests sequence (check if ECS bit is set when bringing cpu online again):
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
# ( perl -e 'sysseek(STDOUT, 0xC001001F, 0); print pack "l*", 8, 0x00400010' ) > /dev/cpu/1/msr
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00400010
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 1 > /sys/devices/system/cpu/cpu1/online
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-23 01:23:38 +07:00
|
|
|
static int __init pci_io_ecs_init(void)
|
|
|
|
{
|
2016-11-18 01:35:41 +07:00
|
|
|
int ret;
|
x86: fix: make PCI ECS for AMD CPUs hotplug capable
Until now, PCI ECS setup was performed at boot time only and for cpus
that are enabled then. This patch fixes this and adds cpu hotplug.
Tests sequence (check if ECS bit is set when bringing cpu online again):
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
# ( perl -e 'sysseek(STDOUT, 0xC001001F, 0); print pack "l*", 8, 0x00400010' ) > /dev/cpu/1/msr
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00400010
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 1 > /sys/devices/system/cpu/cpu1/online
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-23 01:23:38 +07:00
|
|
|
|
2008-06-13 01:19:23 +07:00
|
|
|
/* assume all cpus from fam10h have IO ECS */
|
2014-05-08 23:44:19 +07:00
|
|
|
if (boot_cpu_data.x86 < 0x10)
|
2008-06-13 01:19:23 +07:00
|
|
|
return 0;
|
x86: fix: make PCI ECS for AMD CPUs hotplug capable
Until now, PCI ECS setup was performed at boot time only and for cpus
that are enabled then. This patch fixes this and adds cpu hotplug.
Tests sequence (check if ECS bit is set when bringing cpu online again):
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
# ( perl -e 'sysseek(STDOUT, 0xC001001F, 0); print pack "l*", 8, 0x00400010' ) > /dev/cpu/1/msr
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00400010
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 1 > /sys/devices/system/cpu/cpu1/online
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-23 01:23:38 +07:00
|
|
|
|
2011-01-10 23:20:23 +07:00
|
|
|
/* Try the PCI method first. */
|
|
|
|
if (early_pci_allowed())
|
|
|
|
pci_enable_pci_io_ecs();
|
|
|
|
|
2016-11-18 01:35:41 +07:00
|
|
|
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "pci/amd_bus:online",
|
|
|
|
amd_bus_cpu_online, NULL);
|
|
|
|
WARN_ON(ret < 0);
|
2014-03-11 03:38:43 +07:00
|
|
|
|
2008-06-13 01:19:23 +07:00
|
|
|
pci_probe |= PCI_HAS_IO_ECS;
|
x86: fix: make PCI ECS for AMD CPUs hotplug capable
Until now, PCI ECS setup was performed at boot time only and for cpus
that are enabled then. This patch fixes this and adds cpu hotplug.
Tests sequence (check if ECS bit is set when bringing cpu online again):
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
# ( perl -e 'sysseek(STDOUT, 0xC001001F, 0); print pack "l*", 8, 0x00400010' ) > /dev/cpu/1/msr
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00400010
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 1 > /sys/devices/system/cpu/cpu1/online
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-23 01:23:38 +07:00
|
|
|
|
2008-06-13 01:19:23 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-23 01:23:37 +07:00
|
|
|
static int __init amd_postcore_init(void)
|
|
|
|
{
|
|
|
|
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
|
|
|
|
return 0;
|
|
|
|
|
2014-05-08 23:44:19 +07:00
|
|
|
early_root_info_init();
|
x86: fix: make PCI ECS for AMD CPUs hotplug capable
Until now, PCI ECS setup was performed at boot time only and for cpus
that are enabled then. This patch fixes this and adds cpu hotplug.
Tests sequence (check if ECS bit is set when bringing cpu online again):
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
# ( perl -e 'sysseek(STDOUT, 0xC001001F, 0); print pack "l*", 8, 0x00400010' ) > /dev/cpu/1/msr
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00400010
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 1 > /sys/devices/system/cpu/cpu1/online
# ( perl -e 'sysseek(STDIN, 0xC001001F, 0)'; hexdump -n 8 -e '2/4 "%08x " "\n"' ) < /dev/cpu/1/msr
00000008 00404010
Reported-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-08-23 01:23:38 +07:00
|
|
|
pci_io_ecs_init();
|
2008-08-23 01:23:37 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
postcore_initcall(amd_postcore_init);
|