Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
Browse files Browse the repository at this point in the history
* master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6:
  [SPARC64]: Handle ISA devices with no 'regs' property.
  [SPARC64]: Update defconfig.
  [SPARC64]: Fix of_iounmap() region release.
  [SPARC64]: Fix "mem=xxx" handling.
  • Loading branch information
Linus Torvalds committed Dec 31, 2006
2 parents b836267 + f4060c0 commit 9d572ec
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 155 deletions.
2 changes: 1 addition & 1 deletion arch/sparc/kernel/ioport.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void __iomem *of_ioremap(struct resource *res, unsigned long offset,
}
EXPORT_SYMBOL(of_ioremap);

void of_iounmap(void __iomem *base, unsigned long size)
void of_iounmap(struct resource *res, void __iomem *base, unsigned long size)
{
iounmap(base);
}
Expand Down
34 changes: 26 additions & 8 deletions arch/sparc64/defconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.19
# Sat Dec 9 15:41:30 2006
# Linux kernel version: 2.6.20-rc2
# Thu Dec 28 15:09:49 2006
#
CONFIG_SPARC=y
CONFIG_SPARC64=y
Expand Down Expand Up @@ -334,7 +334,7 @@ CONFIG_BLK_DEV_LOOP=m
CONFIG_BLK_DEV_CRYPTOLOOP=m
CONFIG_BLK_DEV_NBD=m
# CONFIG_BLK_DEV_SX8 is not set
CONFIG_BLK_DEV_UB=m
# CONFIG_BLK_DEV_UB is not set
# CONFIG_BLK_DEV_RAM is not set
# CONFIG_BLK_DEV_INITRD is not set
CONFIG_CDROM_PKTCDVD=m
Expand Down Expand Up @@ -840,6 +840,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_LM92 is not set
# CONFIG_SENSORS_MAX1619 is not set
# CONFIG_SENSORS_PC87360 is not set
# CONFIG_SENSORS_PC87427 is not set
# CONFIG_SENSORS_SIS5595 is not set
# CONFIG_SENSORS_SMSC47M1 is not set
# CONFIG_SENSORS_SMSC47M192 is not set
Expand All @@ -850,6 +851,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_W83781D is not set
# CONFIG_SENSORS_W83791D is not set
# CONFIG_SENSORS_W83792D is not set
# CONFIG_SENSORS_W83793 is not set
# CONFIG_SENSORS_W83L785TS is not set
# CONFIG_SENSORS_W83627HF is not set
# CONFIG_SENSORS_W83627EHF is not set
Expand Down Expand Up @@ -962,7 +964,6 @@ CONFIG_SND_VERBOSE_PROCFS=y
#
CONFIG_SND_MPU401_UART=m
CONFIG_SND_AC97_CODEC=m
CONFIG_SND_AC97_BUS=m
CONFIG_SND_DUMMY=m
CONFIG_SND_VIRMIDI=m
CONFIG_SND_MTPAV=m
Expand Down Expand Up @@ -1045,6 +1046,7 @@ CONFIG_SND_SUN_CS4231=m
# Open Sound System
#
# CONFIG_SOUND_PRIME is not set
CONFIG_AC97_BUS=m

#
# HID Devices
Expand Down Expand Up @@ -1096,7 +1098,19 @@ CONFIG_USB_UHCI_HCD=m
#
# may also be needed; see USB_STORAGE Help for more information
#
# CONFIG_USB_STORAGE is not set
CONFIG_USB_STORAGE=m
# CONFIG_USB_STORAGE_DEBUG is not set
# CONFIG_USB_STORAGE_DATAFAB is not set
# CONFIG_USB_STORAGE_FREECOM is not set
# CONFIG_USB_STORAGE_ISD200 is not set
# CONFIG_USB_STORAGE_DPCM is not set
# CONFIG_USB_STORAGE_USBAT is not set
# CONFIG_USB_STORAGE_SDDR09 is not set
# CONFIG_USB_STORAGE_SDDR55 is not set
# CONFIG_USB_STORAGE_JUMPSHOT is not set
# CONFIG_USB_STORAGE_ALAUDA is not set
# CONFIG_USB_STORAGE_ONETOUCH is not set
# CONFIG_USB_STORAGE_KARMA is not set
# CONFIG_USB_LIBUSUAL is not set

#
Expand Down Expand Up @@ -1221,6 +1235,10 @@ CONFIG_USB_HIDDEV=y
# DMA Devices
#

#
# Virtualization
#

#
# Misc Linux/SPARC drivers
#
Expand Down Expand Up @@ -1397,6 +1415,8 @@ CONFIG_PRINTK_TIME=y
CONFIG_ENABLE_MUST_CHECK=y
CONFIG_MAGIC_SYSRQ=y
# CONFIG_UNUSED_SYMBOLS is not set
CONFIG_DEBUG_FS=y
# CONFIG_HEADERS_CHECK is not set
CONFIG_DEBUG_KERNEL=y
CONFIG_LOG_BUF_SHIFT=18
CONFIG_DETECT_SOFTLOCKUP=y
Expand All @@ -1414,12 +1434,9 @@ CONFIG_SCHEDSTATS=y
# CONFIG_DEBUG_KOBJECT is not set
CONFIG_DEBUG_BUGVERBOSE=y
# CONFIG_DEBUG_INFO is not set
CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_VM is not set
# CONFIG_DEBUG_LIST is not set
# CONFIG_UNWIND_INFO is not set
CONFIG_FORCED_INLINING=y
# CONFIG_HEADERS_CHECK is not set
# CONFIG_RCU_TORTURE_TEST is not set
# CONFIG_LKDTM is not set
# CONFIG_DEBUG_STACK_USAGE is not set
Expand Down Expand Up @@ -1489,3 +1506,4 @@ CONFIG_LIBCRC32C=m
CONFIG_ZLIB_INFLATE=y
CONFIG_ZLIB_DEFLATE=y
CONFIG_PLIST=y
CONFIG_IOMAP_COPY=y
20 changes: 8 additions & 12 deletions arch/sparc64/kernel/isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ static void __init report_dev(struct sparc_isa_device *isa_dev, int child)
printk(" [%s", isa_dev->prom_node->name);
}

static struct linux_prom_registers * __init
isa_dev_get_resource(struct sparc_isa_device *isa_dev)
static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev)
{
struct linux_prom_registers *pregs;
unsigned long base, len;
int prop_len;

pregs = of_get_property(isa_dev->prom_node, "reg", &prop_len);
if (!pregs)
return;

/* Only the first one is interesting. */
len = pregs[0].reg_size;
Expand All @@ -44,12 +45,9 @@ isa_dev_get_resource(struct sparc_isa_device *isa_dev)

request_resource(&isa_dev->bus->parent->io_space,
&isa_dev->resource);

return pregs;
}

static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev,
struct linux_prom_registers *pregs)
static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev)
{
struct of_device *op = of_find_device_by_node(isa_dev->prom_node);

Expand All @@ -69,7 +67,6 @@ static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)

printk(" ->");
while (dp) {
struct linux_prom_registers *regs;
struct sparc_isa_device *isa_dev;

isa_dev = kzalloc(sizeof(*isa_dev), GFP_KERNEL);
Expand All @@ -85,8 +82,8 @@ static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)
isa_dev->bus = parent_isa_dev->bus;
isa_dev->prom_node = dp;

regs = isa_dev_get_resource(isa_dev);
isa_dev_get_irq(isa_dev, regs);
isa_dev_get_resource(isa_dev);
isa_dev_get_irq(isa_dev);

report_dev(isa_dev, 1);

Expand All @@ -99,7 +96,6 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
struct device_node *dp = isa_br->prom_node->child;

while (dp) {
struct linux_prom_registers *regs;
struct sparc_isa_device *isa_dev;

isa_dev = kzalloc(sizeof(*isa_dev), GFP_KERNEL);
Expand Down Expand Up @@ -137,8 +133,8 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
isa_dev->bus = isa_br;
isa_dev->prom_node = dp;

regs = isa_dev_get_resource(isa_dev);
isa_dev_get_irq(isa_dev, regs);
isa_dev_get_resource(isa_dev);
isa_dev_get_irq(isa_dev);

report_dev(isa_dev, 0);

Expand Down
7 changes: 5 additions & 2 deletions arch/sparc64/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned lo
}
EXPORT_SYMBOL(of_ioremap);

void of_iounmap(void __iomem *base, unsigned long size)
void of_iounmap(struct resource *res, void __iomem *base, unsigned long size)
{
release_region((unsigned long) base, size);
if (res->flags & IORESOURCE_MEM)
release_mem_region((unsigned long) base, size);
else
release_region((unsigned long) base, size);
}
EXPORT_SYMBOL(of_iounmap);

Expand Down
147 changes: 124 additions & 23 deletions arch/sparc64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,115 @@ static unsigned long __init choose_bootmap_pfn(unsigned long start_pfn,
prom_halt();
}

static void __init trim_pavail(unsigned long *cur_size_p,
unsigned long *end_of_phys_p)
{
unsigned long to_trim = *cur_size_p - cmdline_memory_size;
unsigned long avoid_start, avoid_end;
int i;

to_trim = PAGE_ALIGN(to_trim);

avoid_start = avoid_end = 0;
#ifdef CONFIG_BLK_DEV_INITRD
avoid_start = initrd_start;
avoid_end = PAGE_ALIGN(initrd_end);
#endif

/* Trim some pavail[] entries in order to satisfy the
* requested "mem=xxx" kernel command line specification.
*
* We must not trim off the kernel image area nor the
* initial ramdisk range (if any). Also, we must not trim
* any pavail[] entry down to zero in order to preserve
* the invariant that all pavail[] entries have a non-zero
* size which is assumed by all of the code in here.
*/
for (i = 0; i < pavail_ents; i++) {
unsigned long start, end, kern_end;
unsigned long trim_low, trim_high, n;

kern_end = PAGE_ALIGN(kern_base + kern_size);

trim_low = start = pavail[i].phys_addr;
trim_high = end = start + pavail[i].reg_size;

if (kern_base >= start &&
kern_base < end) {
trim_low = kern_base;
if (kern_end >= end)
continue;
}
if (kern_end >= start &&
kern_end < end) {
trim_high = kern_end;
}
if (avoid_start &&
avoid_start >= start &&
avoid_start < end) {
if (trim_low > avoid_start)
trim_low = avoid_start;
if (avoid_end >= end)
continue;
}
if (avoid_end &&
avoid_end >= start &&
avoid_end < end) {
if (trim_high < avoid_end)
trim_high = avoid_end;
}

if (trim_high <= trim_low)
continue;

if (trim_low == start && trim_high == end) {
/* Whole chunk is available for trimming.
* Trim all except one page, in order to keep
* entry non-empty.
*/
n = (end - start) - PAGE_SIZE;
if (n > to_trim)
n = to_trim;

if (n) {
pavail[i].phys_addr += n;
pavail[i].reg_size -= n;
to_trim -= n;
}
} else {
n = (trim_low - start);
if (n > to_trim)
n = to_trim;

if (n) {
pavail[i].phys_addr += n;
pavail[i].reg_size -= n;
to_trim -= n;
}
if (to_trim) {
n = end - trim_high;
if (n > to_trim)
n = to_trim;
if (n) {
pavail[i].reg_size -= n;
to_trim -= n;
}
}
}

if (!to_trim)
break;
}

/* Recalculate. */
*cur_size_p = 0UL;
for (i = 0; i < pavail_ents; i++) {
*end_of_phys_p = pavail[i].phys_addr +
pavail[i].reg_size;
*cur_size_p += pavail[i].reg_size;
}
}

static unsigned long __init bootmem_init(unsigned long *pages_avail,
unsigned long phys_base)
{
Expand All @@ -889,31 +998,13 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
end_of_phys_memory = pavail[i].phys_addr +
pavail[i].reg_size;
bytes_avail += pavail[i].reg_size;
if (cmdline_memory_size) {
if (bytes_avail > cmdline_memory_size) {
unsigned long slack = bytes_avail - cmdline_memory_size;

bytes_avail -= slack;
end_of_phys_memory -= slack;

pavail[i].reg_size -= slack;
if ((long)pavail[i].reg_size <= 0L) {
pavail[i].phys_addr = 0xdeadbeefUL;
pavail[i].reg_size = 0UL;
pavail_ents = i;
} else {
pavail[i+1].reg_size = 0Ul;
pavail[i+1].phys_addr = 0xdeadbeefUL;
pavail_ents = i + 1;
}
break;
}
}
}

*pages_avail = bytes_avail >> PAGE_SHIFT;

end_pfn = end_of_phys_memory >> PAGE_SHIFT;
/* Determine the location of the initial ramdisk before trying
* to honor the "mem=xxx" command line argument. We must know
* where the kernel image and the ramdisk image are so that we
* do not trim those two areas from the physical memory map.
*/

#ifdef CONFIG_BLK_DEV_INITRD
/* Now have to check initial ramdisk, so that bootmap does not overwrite it */
Expand All @@ -932,6 +1023,16 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
}
}
#endif

if (cmdline_memory_size &&
bytes_avail > cmdline_memory_size)
trim_pavail(&bytes_avail,
&end_of_phys_memory);

*pages_avail = bytes_avail >> PAGE_SHIFT;

end_pfn = end_of_phys_memory >> PAGE_SHIFT;

/* Initialize the boot-time allocator. */
max_pfn = max_low_pfn = end_pfn;
min_low_pfn = (phys_base >> PAGE_SHIFT);
Expand Down
Loading

0 comments on commit 9d572ec

Please sign in to comment.