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
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Low-Level PCI Access for i386 machines
|
|
|
|
*
|
|
|
|
* Copyright 1993, 1994 Drew Eckhardt
|
|
|
|
* Visionary Computing
|
|
|
|
* (Unix and Linux consulting and custom programming)
|
|
|
|
* Drew@Colorado.EDU
|
|
|
|
* +1 (303) 786-7975
|
|
|
|
*
|
|
|
|
* Drew's work was sponsored by:
|
|
|
|
* iX Multiuser Multitasking Magazine
|
|
|
|
* Hannover, Germany
|
|
|
|
* hm@ix.de
|
|
|
|
*
|
|
|
|
* Copyright 1997--2000 Martin Mares <mj@ucw.cz>
|
|
|
|
*
|
|
|
|
* For more information, please consult the following manuals (look at
|
|
|
|
* http://www.pcisig.com/ for how to get them):
|
|
|
|
*
|
|
|
|
* PCI BIOS Specification
|
|
|
|
* PCI Local Bus Specification
|
|
|
|
* PCI to PCI Bridge Specification
|
|
|
|
* PCI System Design Guide
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
2011-05-27 00:22:53 +08:00
|
|
|
#include <linux/export.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/errno.h>
|
2018-10-31 06:09:49 +08:00
|
|
|
#include <linux/memblock.h>
|
2008-03-19 08:00:19 +08:00
|
|
|
|
|
|
|
#include <asm/pat.h>
|
2017-01-27 17:27:10 +08:00
|
|
|
#include <asm/e820/api.h>
|
2008-12-27 21:02:28 +08:00
|
|
|
#include <asm/pci_x86.h>
|
2009-07-11 00:36:20 +08:00
|
|
|
#include <asm/io_apic.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
2011-11-22 02:54:13 +08:00
|
|
|
/*
|
|
|
|
* This list of dynamic mappings is for temporarily maintaining
|
|
|
|
* original BIOS BAR addresses for possible reinstatement.
|
|
|
|
*/
|
|
|
|
struct pcibios_fwaddrmap {
|
|
|
|
struct list_head list;
|
|
|
|
struct pci_dev *dev;
|
|
|
|
resource_size_t fw_addr[DEVICE_COUNT_RESOURCE];
|
|
|
|
};
|
|
|
|
|
|
|
|
static LIST_HEAD(pcibios_fwaddrmappings);
|
|
|
|
static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock);
|
2012-11-04 12:39:28 +08:00
|
|
|
static bool pcibios_fw_addr_done;
|
2011-11-22 02:54:13 +08:00
|
|
|
|
|
|
|
/* Must be called with 'pcibios_fwaddrmap_lock' lock held. */
|
|
|
|
static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
struct pcibios_fwaddrmap *map;
|
|
|
|
|
2018-10-05 14:45:38 +08:00
|
|
|
lockdep_assert_held(&pcibios_fwaddrmap_lock);
|
2012-03-03 03:45:01 +08:00
|
|
|
|
2011-11-22 02:54:13 +08:00
|
|
|
list_for_each_entry(map, &pcibios_fwaddrmappings, list)
|
|
|
|
if (map->dev == dev)
|
|
|
|
return map;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct pcibios_fwaddrmap *map;
|
|
|
|
|
2012-11-04 12:39:28 +08:00
|
|
|
if (pcibios_fw_addr_done)
|
|
|
|
return;
|
|
|
|
|
2011-11-22 02:54:13 +08:00
|
|
|
spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
map = pcibios_fwaddrmap_lookup(dev);
|
|
|
|
if (!map) {
|
|
|
|
spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
map = kzalloc(sizeof(*map), GFP_KERNEL);
|
|
|
|
if (!map)
|
|
|
|
return;
|
|
|
|
|
|
|
|
map->dev = pci_dev_get(dev);
|
|
|
|
map->fw_addr[idx] = fw_addr;
|
|
|
|
INIT_LIST_HEAD(&map->list);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
list_add_tail(&map->list, &pcibios_fwaddrmappings);
|
|
|
|
} else
|
|
|
|
map->fw_addr[idx] = fw_addr;
|
|
|
|
spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct pcibios_fwaddrmap *map;
|
|
|
|
resource_size_t fw_addr = 0;
|
|
|
|
|
2012-11-04 12:39:28 +08:00
|
|
|
if (pcibios_fw_addr_done)
|
|
|
|
return 0;
|
|
|
|
|
2011-11-22 02:54:13 +08:00
|
|
|
spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
map = pcibios_fwaddrmap_lookup(dev);
|
|
|
|
if (map)
|
|
|
|
fw_addr = map->fw_addr[idx];
|
|
|
|
spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
|
|
|
|
return fw_addr;
|
|
|
|
}
|
|
|
|
|
2012-11-04 12:39:28 +08:00
|
|
|
static void __init pcibios_fw_addr_list_del(void)
|
2011-11-22 02:54:13 +08:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct pcibios_fwaddrmap *entry, *next;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
|
|
|
|
list_for_each_entry_safe(entry, next, &pcibios_fwaddrmappings, list) {
|
|
|
|
list_del(&entry->list);
|
|
|
|
pci_dev_put(entry->dev);
|
|
|
|
kfree(entry);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
|
2012-11-04 12:39:28 +08:00
|
|
|
pcibios_fw_addr_done = true;
|
2011-11-22 02:54:13 +08:00
|
|
|
}
|
|
|
|
|
2007-10-04 06:56:14 +08:00
|
|
|
static int
|
|
|
|
skip_isa_ioresource_align(struct pci_dev *dev) {
|
|
|
|
|
|
|
|
if ((pci_probe & PCI_CAN_SKIP_ISA_ALIGN) &&
|
2007-10-09 07:24:16 +08:00
|
|
|
!(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA))
|
2007-10-04 06:56:14 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* We need to avoid collisions with `mirrored' VGA ports
|
|
|
|
* and other strange ISA hardware, so we always want the
|
|
|
|
* addresses to be allocated in the 0x000-0x0ff region
|
|
|
|
* modulo 0x400.
|
|
|
|
*
|
|
|
|
* Why? Because some silly external IO cards only decode
|
|
|
|
* the low 10 bits of the IO address. The 0x00-0xff region
|
|
|
|
* is reserved for motherboard devices that decode all 16
|
|
|
|
* bits, so it's ok to allocate at, say, 0x2800-0x28ff,
|
|
|
|
* but we want to try to avoid allocating at 0x2900-0x2bff
|
|
|
|
* which might have be mirrored at 0x0100-0x03ff..
|
|
|
|
*/
|
2010-01-02 00:40:49 +08:00
|
|
|
resource_size_t
|
2010-01-02 00:40:50 +08:00
|
|
|
pcibios_align_resource(void *data, const struct resource *res,
|
2006-06-13 08:06:02 +08:00
|
|
|
resource_size_t size, resource_size_t align)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-04 06:56:14 +08:00
|
|
|
struct pci_dev *dev = data;
|
2010-12-17 01:38:31 +08:00
|
|
|
resource_size_t start = res->start;
|
2007-10-04 06:56:14 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (res->flags & IORESOURCE_IO) {
|
2010-12-17 01:38:31 +08:00
|
|
|
if (skip_isa_ioresource_align(dev))
|
|
|
|
return start;
|
|
|
|
if (start & 0x300)
|
|
|
|
start = (start + 0x3ff) & ~0x3ff;
|
2014-07-16 16:00:57 +08:00
|
|
|
} else if (res->flags & IORESOURCE_MEM) {
|
|
|
|
/* The low 1MB range is reserved for ISA cards */
|
|
|
|
if (start < BIOS_END)
|
|
|
|
start = BIOS_END;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2010-01-02 00:40:49 +08:00
|
|
|
return start;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-29 16:06:10 +08:00
|
|
|
EXPORT_SYMBOL(pcibios_align_resource);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle resources of PCI devices. If the world were perfect, we could
|
|
|
|
* just allocate all the resource regions and do nothing more. It isn't.
|
|
|
|
* On the other hand, we cannot just re-allocate all devices, as it would
|
|
|
|
* require us to know lots of host bridge internals. So we attempt to
|
|
|
|
* keep as much of the original configuration as possible, but tweak it
|
|
|
|
* when it's found to be wrong.
|
|
|
|
*
|
|
|
|
* Known BIOS problems we have to work around:
|
|
|
|
* - I/O or memory regions not configured
|
|
|
|
* - regions configured, but not enabled in the command register
|
|
|
|
* - bogus I/O addresses above 64K used
|
|
|
|
* - expansion ROMs left enabled (this may sound harmless, but given
|
|
|
|
* the fact the PCI specs explicitly allow address decoders to be
|
|
|
|
* shared between expansion ROMs and other resource regions, it's
|
|
|
|
* at least dangerous)
|
2010-06-04 04:43:03 +08:00
|
|
|
* - bad resource sizes or overlaps with other regions
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Our solution:
|
|
|
|
* (1) Allocate resources for all buses behind PCI-to-PCI bridges.
|
|
|
|
* This gives us fixed barriers on where we can allocate.
|
|
|
|
* (2) Allocate resources for all enabled devices. If there is
|
|
|
|
* a collision, just mark the resource as unallocated. Also
|
|
|
|
* disable expansion ROMs during this step.
|
|
|
|
* (3) Try to allocate resources for disabled devices. If the
|
|
|
|
* resources were assigned correctly, everything goes well,
|
|
|
|
* if they weren't, they won't disturb allocation of other
|
|
|
|
* resources.
|
|
|
|
* (4) Assign new addresses to resources which were either
|
|
|
|
* not configured at all or misconfigured. If explicitly
|
|
|
|
* requested by the user, configure expansion ROM address
|
|
|
|
* as well.
|
|
|
|
*/
|
|
|
|
|
2012-11-04 12:39:29 +08:00
|
|
|
static void pcibios_allocate_bridge_resources(struct pci_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int idx;
|
2009-06-18 04:33:35 +08:00
|
|
|
struct resource *r;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-11-04 12:39:24 +08:00
|
|
|
for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
|
|
|
|
r = &dev->resource[idx];
|
|
|
|
if (!r->flags)
|
|
|
|
continue;
|
2013-07-03 22:04:48 +08:00
|
|
|
if (r->parent) /* Already allocated */
|
|
|
|
continue;
|
2015-01-16 06:21:49 +08:00
|
|
|
if (!r->start || pci_claim_bridge_resource(dev, idx) < 0) {
|
2012-11-04 12:39:24 +08:00
|
|
|
/*
|
|
|
|
* Something is wrong with the region.
|
|
|
|
* Invalidate the resource to prevent
|
|
|
|
* child resource allocations in this
|
|
|
|
* range.
|
|
|
|
*/
|
|
|
|
r->start = r->end = 0;
|
|
|
|
r->flags = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-04 12:39:29 +08:00
|
|
|
static void pcibios_allocate_bus_resources(struct pci_bus *bus)
|
2012-11-04 12:39:24 +08:00
|
|
|
{
|
2012-11-04 12:39:26 +08:00
|
|
|
struct pci_bus *child;
|
2012-11-04 12:39:24 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Depth-First Search on bus tree */
|
2012-11-04 12:39:26 +08:00
|
|
|
if (bus->self)
|
|
|
|
pcibios_allocate_bridge_resources(bus->self);
|
|
|
|
list_for_each_entry(child, &bus->children, node)
|
|
|
|
pcibios_allocate_bus_resources(child);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-11-25 10:05:12 +08:00
|
|
|
struct pci_check_idx_range {
|
|
|
|
int start;
|
|
|
|
int end;
|
|
|
|
};
|
|
|
|
|
2012-11-04 12:39:29 +08:00
|
|
|
static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-11-25 10:05:12 +08:00
|
|
|
int idx, disabled, i;
|
2005-04-17 06:20:36 +08:00
|
|
|
u16 command;
|
2009-06-18 04:33:35 +08:00
|
|
|
struct resource *r;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-11-25 10:05:12 +08:00
|
|
|
struct pci_check_idx_range idx_range[] = {
|
|
|
|
{ PCI_STD_RESOURCES, PCI_STD_RESOURCE_END },
|
|
|
|
#ifdef CONFIG_PCI_IOV
|
|
|
|
{ PCI_IOV_RESOURCES, PCI_IOV_RESOURCE_END },
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2012-11-04 12:39:25 +08:00
|
|
|
pci_read_config_word(dev, PCI_COMMAND, &command);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(idx_range); i++)
|
2009-11-25 10:05:12 +08:00
|
|
|
for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
r = &dev->resource[idx];
|
2012-11-04 12:39:25 +08:00
|
|
|
if (r->parent) /* Already allocated */
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
2012-11-04 12:39:25 +08:00
|
|
|
if (!r->start) /* Address not assigned at all */
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
if (r->flags & IORESOURCE_IO)
|
|
|
|
disabled = !(command & PCI_COMMAND_IO);
|
|
|
|
else
|
|
|
|
disabled = !(command & PCI_COMMAND_MEMORY);
|
|
|
|
if (pass == disabled) {
|
2009-10-28 03:26:47 +08:00
|
|
|
dev_dbg(&dev->dev,
|
2009-11-05 01:32:57 +08:00
|
|
|
"BAR %d: reserving %pr (d=%d, p=%d)\n",
|
2009-10-28 03:26:47 +08:00
|
|
|
idx, r, disabled, pass);
|
2009-06-18 04:33:35 +08:00
|
|
|
if (pci_claim_resource(dev, idx) < 0) {
|
2014-04-15 05:30:09 +08:00
|
|
|
if (r->flags & IORESOURCE_PCI_FIXED) {
|
|
|
|
dev_info(&dev->dev, "BAR %d %pR is immovable\n",
|
|
|
|
idx, r);
|
|
|
|
} else {
|
|
|
|
/* We'll assign a new address later */
|
|
|
|
pcibios_save_fw_addr(dev,
|
|
|
|
idx, r->start);
|
|
|
|
r->end -= r->start;
|
|
|
|
r->start = 0;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-04 12:39:25 +08:00
|
|
|
if (!pass) {
|
|
|
|
r = &dev->resource[PCI_ROM_RESOURCE];
|
|
|
|
if (r->flags & IORESOURCE_ROM_ENABLE) {
|
|
|
|
/* Turn the ROM off, leave the resource region,
|
|
|
|
* but keep it unregistered. */
|
|
|
|
u32 reg;
|
|
|
|
dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
|
|
|
|
r->flags &= ~IORESOURCE_ROM_ENABLE;
|
|
|
|
pci_read_config_dword(dev, dev->rom_base_reg, ®);
|
|
|
|
pci_write_config_dword(dev, dev->rom_base_reg,
|
2006-10-18 01:17:58 +08:00
|
|
|
reg & ~PCI_ROM_ADDRESS_ENABLE);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-04 12:39:29 +08:00
|
|
|
static void pcibios_allocate_resources(struct pci_bus *bus, int pass)
|
2012-11-04 12:39:25 +08:00
|
|
|
{
|
2012-11-04 12:39:26 +08:00
|
|
|
struct pci_dev *dev;
|
|
|
|
struct pci_bus *child;
|
2012-11-04 12:39:25 +08:00
|
|
|
|
2012-11-04 12:39:26 +08:00
|
|
|
list_for_each_entry(dev, &bus->devices, bus_list) {
|
2012-11-04 12:39:25 +08:00
|
|
|
pcibios_allocate_dev_resources(dev, pass);
|
2012-11-04 12:39:26 +08:00
|
|
|
|
|
|
|
child = dev->subordinate;
|
|
|
|
if (child)
|
|
|
|
pcibios_allocate_resources(child, pass);
|
|
|
|
}
|
2012-11-04 12:39:25 +08:00
|
|
|
}
|
|
|
|
|
2012-11-04 12:39:29 +08:00
|
|
|
static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-06-18 04:33:35 +08:00
|
|
|
struct resource *r;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-11-04 12:39:27 +08:00
|
|
|
/*
|
|
|
|
* Try to use BIOS settings for ROMs, otherwise let
|
|
|
|
* pci_assign_unassigned_resources() allocate the new
|
|
|
|
* addresses.
|
|
|
|
*/
|
|
|
|
r = &dev->resource[PCI_ROM_RESOURCE];
|
|
|
|
if (!r->flags || !r->start)
|
|
|
|
return;
|
2013-07-03 22:04:48 +08:00
|
|
|
if (r->parent) /* Already allocated */
|
|
|
|
return;
|
2012-11-04 12:39:27 +08:00
|
|
|
|
|
|
|
if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
|
|
|
|
r->end -= r->start;
|
|
|
|
r->start = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-11-04 12:39:27 +08:00
|
|
|
}
|
2012-11-04 12:39:29 +08:00
|
|
|
static void pcibios_allocate_rom_resources(struct pci_bus *bus)
|
2012-11-04 12:39:27 +08:00
|
|
|
{
|
|
|
|
struct pci_dev *dev;
|
|
|
|
struct pci_bus *child;
|
|
|
|
|
|
|
|
list_for_each_entry(dev, &bus->devices, bus_list) {
|
|
|
|
pcibios_allocate_dev_rom_resource(dev);
|
|
|
|
|
|
|
|
child = dev->subordinate;
|
|
|
|
if (child)
|
|
|
|
pcibios_allocate_rom_resources(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init pcibios_assign_resources(void)
|
|
|
|
{
|
|
|
|
struct pci_bus *bus;
|
|
|
|
|
|
|
|
if (!(pci_probe & PCI_ASSIGN_ROMS))
|
|
|
|
list_for_each_entry(bus, &pci_root_buses, node)
|
|
|
|
pcibios_allocate_rom_resources(bus);
|
2005-08-30 22:48:52 +08:00
|
|
|
|
|
|
|
pci_assign_unassigned_resources();
|
2011-11-22 02:54:19 +08:00
|
|
|
pcibios_fw_addr_list_del();
|
2005-08-30 22:48:52 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-15 06:13:48 +08:00
|
|
|
/**
|
|
|
|
* called in fs_initcall (one below subsys_initcall),
|
|
|
|
* give a chance for motherboard reserve resources
|
|
|
|
*/
|
|
|
|
fs_initcall(pcibios_assign_resources);
|
|
|
|
|
2012-11-04 12:39:30 +08:00
|
|
|
void pcibios_resource_survey_bus(struct pci_bus *bus)
|
|
|
|
{
|
|
|
|
dev_printk(KERN_DEBUG, &bus->dev, "Allocating resources\n");
|
|
|
|
|
|
|
|
pcibios_allocate_bus_resources(bus);
|
|
|
|
|
|
|
|
pcibios_allocate_resources(bus, 0);
|
|
|
|
pcibios_allocate_resources(bus, 1);
|
|
|
|
|
|
|
|
if (!(pci_probe & PCI_ASSIGN_ROMS))
|
|
|
|
pcibios_allocate_rom_resources(bus);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
void __init pcibios_resource_survey(void)
|
|
|
|
{
|
2012-11-04 12:39:26 +08:00
|
|
|
struct pci_bus *bus;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
DBG("PCI: Allocating resources\n");
|
2012-11-04 12:39:26 +08:00
|
|
|
|
|
|
|
list_for_each_entry(bus, &pci_root_buses, node)
|
|
|
|
pcibios_allocate_bus_resources(bus);
|
|
|
|
|
|
|
|
list_for_each_entry(bus, &pci_root_buses, node)
|
|
|
|
pcibios_allocate_resources(bus, 0);
|
|
|
|
list_for_each_entry(bus, &pci_root_buses, node)
|
|
|
|
pcibios_allocate_resources(bus, 1);
|
2008-08-29 14:09:23 +08:00
|
|
|
|
2017-01-29 05:41:14 +08:00
|
|
|
e820__reserve_resources_late();
|
2009-07-11 00:36:20 +08:00
|
|
|
/*
|
|
|
|
* Insert the IO APIC resources after PCI initialization has
|
2011-03-18 03:24:16 +08:00
|
|
|
* occurred to handle IO APICS that are mapped in on a BAR in
|
2009-07-11 00:36:20 +08:00
|
|
|
* PCI space, but before trying to assign unassigned pci res.
|
|
|
|
*/
|
|
|
|
ioapic_insert_resources();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|