Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223421
b: refs/heads/master
c: 2ba16c4
h: refs/heads/master
i:
  223419: 7aec3ef
v: v3
  • Loading branch information
Linus Torvalds committed Dec 18, 2010
1 parent 0f20552 commit bba6001
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 191 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 081d835fa4ce70ad1e42ac76de850a49e23a1557
refs/heads/master: 2ba16c4f456eb63f54b1d8b065377d41a1cd6a14
5 changes: 0 additions & 5 deletions trunk/Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2175,11 +2175,6 @@ and is between 256 and 4096 characters. It is defined in the file
reset_devices [KNL] Force drivers to reset the underlying device
during initialization.

resource_alloc_from_bottom
Allocate new resources from the beginning of available
space, not the end. If you need to use this, please
report a bug.

resume= [SWSUSP]
Specify the partition device for software suspend

Expand Down
3 changes: 3 additions & 0 deletions trunk/arch/x86/include/asm/e820.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ struct e820map {
#define BIOS_BEGIN 0x000a0000
#define BIOS_END 0x00100000

#define BIOS_ROM_BASE 0xffe00000
#define BIOS_ROM_END 0xffffffff

#ifdef __KERNEL__
/* see comment in arch/x86/kernel/e820.c */
extern struct e820map e820;
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o
obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o
obj-y += tsc.o io_delay.o rtc.o
obj-y += pci-iommu_table.o
obj-y += resource.o

obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
obj-y += process.o
Expand Down
48 changes: 48 additions & 0 deletions trunk/arch/x86/kernel/resource.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <linux/ioport.h>
#include <asm/e820.h>

static void resource_clip(struct resource *res, resource_size_t start,
resource_size_t end)
{
resource_size_t low = 0, high = 0;

if (res->end < start || res->start > end)
return; /* no conflict */

if (res->start < start)
low = start - res->start;

if (res->end > end)
high = res->end - end;

/* Keep the area above or below the conflict, whichever is larger */
if (low > high)
res->end = start - 1;
else
res->start = end + 1;
}

static void remove_e820_regions(struct resource *avail)
{
int i;
struct e820entry *entry;

for (i = 0; i < e820.nr_map; i++) {
entry = &e820.map[i];

resource_clip(avail, entry->addr,
entry->addr + entry->size - 1);
}
}

void arch_remove_reservations(struct resource *avail)
{
/* Trim out BIOS areas (low 1MB and high 2MB) and E820 regions */
if (avail->flags & IORESOURCE_MEM) {
if (avail->start < BIOS_END)
avail->start = BIOS_END;
resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);

remove_e820_regions(avail);
}
}
1 change: 0 additions & 1 deletion trunk/arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ void __init setup_arch(char **cmdline_p)

x86_init.oem.arch_setup();

resource_alloc_from_bottom = 0;
iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
setup_memory_map();
parse_setup_data();
Expand Down
18 changes: 5 additions & 13 deletions trunk/arch/x86/pci/i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,13 @@ pcibios_align_resource(void *data, const struct resource *res,
resource_size_t size, resource_size_t align)
{
struct pci_dev *dev = data;
resource_size_t start = round_down(res->end - size + 1, align);
resource_size_t start = res->start;

if (res->flags & IORESOURCE_IO) {

/*
* If we're avoiding ISA aliases, the largest contiguous I/O
* port space is 256 bytes. Clearing bits 9 and 10 preserves
* all 256-byte and smaller alignments, so the result will
* still be correctly aligned.
*/
if (!skip_isa_ioresource_align(dev))
start &= ~0x300;
} else if (res->flags & IORESOURCE_MEM) {
if (start < BIOS_END)
start = res->end; /* fail; no space */
if (skip_isa_ioresource_align(dev))
return start;
if (start & 0x300)
start = (start + 0x3ff) & ~0x3ff;
}
return start;
}
Expand Down
81 changes: 5 additions & 76 deletions trunk/drivers/pci/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,77 +64,6 @@ void pci_bus_remove_resources(struct pci_bus *bus)
}
}

static bool pci_bus_resource_better(struct resource *res1, bool pos1,
struct resource *res2, bool pos2)
{
/* If exactly one is positive decode, always prefer that one */
if (pos1 != pos2)
return pos1 ? true : false;

/* Prefer the one that contains the highest address */
if (res1->end != res2->end)
return (res1->end > res2->end) ? true : false;

/* Otherwise, prefer the one with highest "center of gravity" */
if (res1->start != res2->start)
return (res1->start > res2->start) ? true : false;

/* Otherwise, choose one arbitrarily (but consistently) */
return (res1 > res2) ? true : false;
}

static bool pci_bus_resource_positive(struct pci_bus *bus, struct resource *res)
{
struct pci_bus_resource *bus_res;

/*
* This relies on the fact that pci_bus.resource[] refers to P2P or
* CardBus bridge base/limit registers, which are always positively
* decoded. The pci_bus.resources list contains host bridge or
* subtractively decoded resources.
*/
list_for_each_entry(bus_res, &bus->resources, list) {
if (bus_res->res == res)
return (bus_res->flags & PCI_SUBTRACTIVE_DECODE) ?
false : true;
}
return true;
}

/*
* Find the next-best bus resource after the cursor "res". If the cursor is
* NULL, return the best resource. "Best" means that we prefer positive
* decode regions over subtractive decode, then those at higher addresses.
*/
static struct resource *pci_bus_find_resource_prev(struct pci_bus *bus,
unsigned int type,
struct resource *res)
{
bool res_pos, r_pos, prev_pos = false;
struct resource *r, *prev = NULL;
int i;

res_pos = pci_bus_resource_positive(bus, res);
pci_bus_for_each_resource(bus, r, i) {
if (!r)
continue;

if ((r->flags & IORESOURCE_TYPE_BITS) != type)
continue;

r_pos = pci_bus_resource_positive(bus, r);
if (!res || pci_bus_resource_better(res, res_pos, r, r_pos)) {
if (!prev || pci_bus_resource_better(r, r_pos,
prev, prev_pos)) {
prev = r;
prev_pos = r_pos;
}
}
}

return prev;
}

/**
* pci_bus_alloc_resource - allocate a resource from a parent bus
* @bus: PCI bus
Expand All @@ -160,20 +89,20 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
resource_size_t),
void *alignf_data)
{
int ret = -ENOMEM;
int i, ret = -ENOMEM;
struct resource *r;
resource_size_t max = -1;
unsigned int type = res->flags & IORESOURCE_TYPE_BITS;

type_mask |= IORESOURCE_IO | IORESOURCE_MEM;

/* don't allocate too high if the pref mem doesn't support 64bit*/
if (!(res->flags & IORESOURCE_MEM_64))
max = PCIBIOS_MAX_MEM_32;

/* Look for space at highest addresses first */
r = pci_bus_find_resource_prev(bus, type, NULL);
for ( ; r; r = pci_bus_find_resource_prev(bus, type, r)) {
pci_bus_for_each_resource(bus, r, i) {
if (!r)
continue;

/* type_mask must match */
if ((res->flags ^ r->flags) & type_mask)
continue;
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/pci/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,9 @@ static void __devinit nvbridge_check_legacy_irq_routing(struct pci_dev *dev)
{
u32 cfg;

if (!pci_find_capability(dev, PCI_CAP_ID_HT))
return;

pci_read_config_dword(dev, 0x74, &cfg);

if (cfg & ((1 << 2) | (1 << 15))) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/ioport.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ struct resource_list {
/* PC/ISA/whatever - the normal PC address spaces: IO and memory */
extern struct resource ioport_resource;
extern struct resource iomem_resource;
extern int resource_alloc_from_bottom;

extern struct resource *request_resource_conflict(struct resource *root, struct resource *new);
extern int request_resource(struct resource *root, struct resource *new);
Expand All @@ -124,6 +123,7 @@ extern void reserve_region_with_split(struct resource *root,
extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
extern int insert_resource(struct resource *parent, struct resource *new);
extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
extern void arch_remove_reservations(struct resource *avail);
extern int allocate_resource(struct resource *root, struct resource *new,
resource_size_t size, resource_size_t min,
resource_size_t max, resource_size_t align,
Expand Down
Loading

0 comments on commit bba6001

Please sign in to comment.