Commit f589e9bf authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next

Pull sparc updates from David Miller:

 1) Hibernation support, as well as removal of excess interrupt
    twiddling in MMU context allocation on sparc64 from Kirill Tkhai.

 2) Kill references to __ARCH_WANT_UNLOCKED_CTXSW.

 3) Sparc32 LEON bug fixes from Daniel Hellstrom and Andreas Larsson.

 4) Provide cmpxchg64(), from Geert Uytterhoeven.

 5) Device refcount and registry bug fixes from Federico Vaga and Wei
    Yongjun.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next:
  serial: sunsu: add missing platform_driver_unregister() when module exit
  sparc32, leon: Do not overwrite previously set irq flow handlers
  sparc/kernel/vio.c: add put_device() after device_find_child()
  sparc64: Do not save/restore interrupts in get_new_mmu_context()
  sparc: Consistently use 'wr' and 'rd' instructions for ASRs.
  sparc64: Kill __ARCH_WANT_UNLOCKED_CTXSW
  sparc64: Provide cmpxchg64()
  sparc64: Do not change num_physpages during initmem freeing
  sparc64: Hibernation support
  sparc,leon: updated GRPCI2 config name
  sparc,leon: support for GRPCI1 PCI host bridge controller
  sparc32,leon: add support for PCI busn resource for GRPCI2
parents 17319295 048c9acc
...@@ -99,6 +99,9 @@ config HAVE_LATENCYTOP_SUPPORT ...@@ -99,6 +99,9 @@ config HAVE_LATENCYTOP_SUPPORT
bool bool
default y if SPARC64 default y if SPARC64
config ARCH_HIBERNATION_POSSIBLE
def_bool y if SPARC64
config AUDIT_ARCH config AUDIT_ARCH
bool bool
default y default y
...@@ -303,6 +306,10 @@ config ARCH_SPARSEMEM_DEFAULT ...@@ -303,6 +306,10 @@ config ARCH_SPARSEMEM_DEFAULT
source "mm/Kconfig" source "mm/Kconfig"
if SPARC64
source "kernel/power/Kconfig"
endif
config SCHED_SMT config SCHED_SMT
bool "SMT (Hyperthreading) scheduler support" bool "SMT (Hyperthreading) scheduler support"
depends on SPARC64 && SMP depends on SPARC64 && SMP
...@@ -472,7 +479,18 @@ config LEON_PCI ...@@ -472,7 +479,18 @@ config LEON_PCI
depends on PCI && SPARC_LEON depends on PCI && SPARC_LEON
default y default y
config GRPCI2 config SPARC_GRPCI1
bool "GRPCI Host Bridge Support"
depends on LEON_PCI
default y
help
Say Y here to include the GRPCI Host Bridge Driver. The GRPCI
PCI host controller is typically found in GRLIB SPARC32/LEON
systems. The driver has one property (all_pci_errors) controlled
from the bootloader that makes the GRPCI to generate interrupts
on detected PCI Parity and System errors.
config SPARC_GRPCI2
bool "GRPCI2 Host Bridge Support" bool "GRPCI2 Host Bridge Support"
depends on LEON_PCI depends on LEON_PCI
default y default y
......
...@@ -57,6 +57,7 @@ core-y += arch/sparc/ ...@@ -57,6 +57,7 @@ core-y += arch/sparc/
libs-y += arch/sparc/prom/ libs-y += arch/sparc/prom/
libs-y += arch/sparc/lib/ libs-y += arch/sparc/lib/
drivers-$(CONFIG_PM) += arch/sparc/power/
drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/ drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/
boot := arch/sparc/boot boot := arch/sparc/boot
......
...@@ -141,5 +141,6 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr, ...@@ -141,5 +141,6 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
cmpxchg_local((ptr), (o), (n)); \ cmpxchg_local((ptr), (o), (n)); \
}) })
#define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n))
#endif /* __ARCH_SPARC64_CMPXCHG__ */ #endif /* __ARCH_SPARC64_CMPXCHG__ */
...@@ -55,15 +55,15 @@ ...@@ -55,15 +55,15 @@
/* The Get Condition Codes software trap for userland. */ /* The Get Condition Codes software trap for userland. */
#define GETCC_TRAP \ #define GETCC_TRAP \
b getcc_trap_handler; mov %psr, %l0; nop; nop; b getcc_trap_handler; rd %psr, %l0; nop; nop;
/* The Set Condition Codes software trap for userland. */ /* The Set Condition Codes software trap for userland. */
#define SETCC_TRAP \ #define SETCC_TRAP \
b setcc_trap_handler; mov %psr, %l0; nop; nop; b setcc_trap_handler; rd %psr, %l0; nop; nop;
/* The Get PSR software trap for userland. */ /* The Get PSR software trap for userland. */
#define GETPSR_TRAP \ #define GETPSR_TRAP \
mov %psr, %i0; jmp %l2; rett %l2 + 4; nop; rd %psr, %i0; jmp %l2; rett %l2 + 4; nop;
/* This is for hard interrupts from level 1-14, 15 is non-maskable (nmi) and /* This is for hard interrupts from level 1-14, 15 is non-maskable (nmi) and
* gets handled with another macro. * gets handled with another macro.
......
/*
* hibernate.h: Hibernaton support specific for sparc64.
*
* Copyright (C) 2013 Kirill V Tkhai (tkhai@yandex.ru)
*/
#ifndef ___SPARC_HIBERNATE_H
#define ___SPARC_HIBERNATE_H
struct saved_context {
unsigned long fp;
unsigned long cwp;
unsigned long wstate;
unsigned long tick;
unsigned long pstate;
unsigned long g4;
unsigned long g5;
unsigned long g6;
};
#endif
...@@ -12,6 +12,7 @@ struct leon_pci_info { ...@@ -12,6 +12,7 @@ struct leon_pci_info {
struct pci_ops *ops; struct pci_ops *ops;
struct resource io_space; struct resource io_space;
struct resource mem_space; struct resource mem_space;
struct resource busn;
int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin); int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
}; };
......
...@@ -68,7 +68,7 @@ extern void smp_tsb_sync(struct mm_struct *mm); ...@@ -68,7 +68,7 @@ extern void smp_tsb_sync(struct mm_struct *mm);
extern void __flush_tlb_mm(unsigned long, unsigned long); extern void __flush_tlb_mm(unsigned long, unsigned long);
/* Switch the current MM context. Interrupts are disabled. */ /* Switch the current MM context. */
static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, struct task_struct *tsk) static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, struct task_struct *tsk)
{ {
unsigned long ctx_valid, flags; unsigned long ctx_valid, flags;
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/page.h> #include <asm/page.h>
/* Don't hold the runqueue lock over context switch */
#define __ARCH_WANT_UNLOCKED_CTXSW
/* The sparc has no problems with write protection */ /* The sparc has no problems with write protection */
#define wp_works_ok 1 #define wp_works_ok 1
#define wp_works_ok__is_a_macro /* for versions in ksyms.c */ #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
......
...@@ -74,7 +74,8 @@ obj-y += dma.o ...@@ -74,7 +74,8 @@ obj-y += dma.o
obj-$(CONFIG_PCIC_PCI) += pcic.o obj-$(CONFIG_PCIC_PCI) += pcic.o
obj-$(CONFIG_LEON_PCI) += leon_pci.o obj-$(CONFIG_LEON_PCI) += leon_pci.o
obj-$(CONFIG_GRPCI2) += leon_pci_grpci2.o obj-$(CONFIG_SPARC_GRPCI2)+= leon_pci_grpci2.o
obj-$(CONFIG_SPARC_GRPCI1)+= leon_pci_grpci1.o
obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o
obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
// #include <linux/mm.h> // #include <linux/mm.h>
#include <linux/kbuild.h> #include <linux/kbuild.h>
#include <asm/hibernate.h>
#ifdef CONFIG_SPARC32 #ifdef CONFIG_SPARC32
int sparc32_foo(void) int sparc32_foo(void)
{ {
...@@ -24,6 +26,19 @@ int sparc32_foo(void) ...@@ -24,6 +26,19 @@ int sparc32_foo(void)
#else #else
int sparc64_foo(void) int sparc64_foo(void)
{ {
#ifdef CONFIG_HIBERNATION
BLANK();
OFFSET(SC_REG_FP, saved_context, fp);
OFFSET(SC_REG_CWP, saved_context, cwp);
OFFSET(SC_REG_WSTATE, saved_context, wstate);
OFFSET(SC_REG_TICK, saved_context, tick);
OFFSET(SC_REG_PSTATE, saved_context, pstate);
OFFSET(SC_REG_G4, saved_context, g4);
OFFSET(SC_REG_G5, saved_context, g5);
OFFSET(SC_REG_G6, saved_context, g6);
#endif
return 0; return 0;
} }
#endif #endif
......
...@@ -213,6 +213,7 @@ unsigned int leon_build_device_irq(unsigned int real_irq, ...@@ -213,6 +213,7 @@ unsigned int leon_build_device_irq(unsigned int real_irq,
{ {
unsigned int irq; unsigned int irq;
unsigned long mask; unsigned long mask;
struct irq_desc *desc;
irq = 0; irq = 0;
mask = leon_get_irqmask(real_irq); mask = leon_get_irqmask(real_irq);
...@@ -226,9 +227,12 @@ unsigned int leon_build_device_irq(unsigned int real_irq, ...@@ -226,9 +227,12 @@ unsigned int leon_build_device_irq(unsigned int real_irq,
if (do_ack) if (do_ack)
mask |= LEON_DO_ACK_HW; mask |= LEON_DO_ACK_HW;
desc = irq_to_desc(irq);
if (!desc || !desc->handle_irq || desc->handle_irq == handle_bad_irq) {
irq_set_chip_and_handler_name(irq, &leon_irq, irq_set_chip_and_handler_name(irq, &leon_irq,
flow_handler, name); flow_handler, name);
irq_set_chip_data(irq, (void *)mask); irq_set_chip_data(irq, (void *)mask);
}
out: out:
return irq; return irq;
......
...@@ -29,6 +29,8 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) ...@@ -29,6 +29,8 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
pci_add_resource_offset(&resources, &info->io_space, pci_add_resource_offset(&resources, &info->io_space,
info->io_space.start - 0x1000); info->io_space.start - 0x1000);
pci_add_resource(&resources, &info->mem_space); pci_add_resource(&resources, &info->mem_space);
info->busn.flags = IORESOURCE_BUS;
pci_add_resource(&resources, &info->busn);
root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
&resources); &resources);
......
This diff is collapsed.
...@@ -799,6 +799,11 @@ static int grpci2_of_probe(struct platform_device *ofdev) ...@@ -799,6 +799,11 @@ static int grpci2_of_probe(struct platform_device *ofdev)
if (request_resource(&ioport_resource, &priv->info.io_space) < 0) if (request_resource(&ioport_resource, &priv->info.io_space) < 0)
goto err4; goto err4;
/* setup maximum supported PCI buses */
priv->info.busn.name = "GRPCI2 busn";
priv->info.busn.start = 0;
priv->info.busn.end = 255;
grpci2_hw_init(priv); grpci2_hw_init(priv);
/* /*
......
...@@ -48,7 +48,7 @@ void pmc_leon_idle_fixup(void) ...@@ -48,7 +48,7 @@ void pmc_leon_idle_fixup(void)
*/ */
register unsigned int address = (unsigned int)leon3_irqctrl_regs; register unsigned int address = (unsigned int)leon3_irqctrl_regs;
__asm__ __volatile__ ( __asm__ __volatile__ (
"mov %%g0, %%asr19\n" "wr %%g0, %%asr19\n"
"lda [%0] %1, %%g0\n" "lda [%0] %1, %%g0\n"
: :
: "r"(address), "i"(ASI_LEON_BYPASS)); : "r"(address), "i"(ASI_LEON_BYPASS));
...@@ -61,7 +61,7 @@ void pmc_leon_idle_fixup(void) ...@@ -61,7 +61,7 @@ void pmc_leon_idle_fixup(void)
void pmc_leon_idle(void) void pmc_leon_idle(void)
{ {
/* For systems without power-down, this will be no-op */ /* For systems without power-down, this will be no-op */
__asm__ __volatile__ ("mov %g0, %asr19\n\t"); __asm__ __volatile__ ("wr %g0, %asr19\n\t");
} }
/* Install LEON Power Down function */ /* Install LEON Power Down function */
......
...@@ -342,6 +342,7 @@ static void vio_remove(struct mdesc_handle *hp, u64 node) ...@@ -342,6 +342,7 @@ static void vio_remove(struct mdesc_handle *hp, u64 node)
printk(KERN_INFO "VIO: Removing device %s\n", dev_name(dev)); printk(KERN_INFO "VIO: Removing device %s\n", dev_name(dev));
device_unregister(dev); device_unregister(dev);
put_device(dev);
} }
} }
......
...@@ -681,10 +681,9 @@ void get_new_mmu_context(struct mm_struct *mm) ...@@ -681,10 +681,9 @@ void get_new_mmu_context(struct mm_struct *mm)
{ {
unsigned long ctx, new_ctx; unsigned long ctx, new_ctx;
unsigned long orig_pgsz_bits; unsigned long orig_pgsz_bits;
unsigned long flags;
int new_version; int new_version;
spin_lock_irqsave(&ctx_alloc_lock, flags); spin_lock(&ctx_alloc_lock);
orig_pgsz_bits = (mm->context.sparc64_ctx_val & CTX_PGSZ_MASK); orig_pgsz_bits = (mm->context.sparc64_ctx_val & CTX_PGSZ_MASK);
ctx = (tlb_context_cache + 1) & CTX_NR_MASK; ctx = (tlb_context_cache + 1) & CTX_NR_MASK;
new_ctx = find_next_zero_bit(mmu_context_bmap, 1 << CTX_NR_BITS, ctx); new_ctx = find_next_zero_bit(mmu_context_bmap, 1 << CTX_NR_BITS, ctx);
...@@ -720,7 +719,7 @@ void get_new_mmu_context(struct mm_struct *mm) ...@@ -720,7 +719,7 @@ void get_new_mmu_context(struct mm_struct *mm)
out: out:
tlb_context_cache = new_ctx; tlb_context_cache = new_ctx;
mm->context.sparc64_ctx_val = new_ctx | orig_pgsz_bits; mm->context.sparc64_ctx_val = new_ctx | orig_pgsz_bits;
spin_unlock_irqrestore(&ctx_alloc_lock, flags); spin_unlock(&ctx_alloc_lock);
if (unlikely(new_version)) if (unlikely(new_version))
smp_new_mmu_context_version(); smp_new_mmu_context_version();
...@@ -2125,7 +2124,6 @@ void free_initmem(void) ...@@ -2125,7 +2124,6 @@ void free_initmem(void)
ClearPageReserved(p); ClearPageReserved(p);
init_page_count(p); init_page_count(p);
__free_page(p); __free_page(p);
num_physpages++;
totalram_pages++; totalram_pages++;
} }
} }
...@@ -2142,7 +2140,6 @@ void free_initrd_mem(unsigned long start, unsigned long end) ...@@ -2142,7 +2140,6 @@ void free_initrd_mem(unsigned long start, unsigned long end)
ClearPageReserved(p); ClearPageReserved(p);
init_page_count(p); init_page_count(p);
__free_page(p); __free_page(p);
num_physpages++;
totalram_pages++; totalram_pages++;
} }
} }
......
# Makefile for Sparc-specific hibernate files.
obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate_asm.o
/*
* hibernate.c: Hibernaton support specific for sparc64.
*
* Copyright (C) 2013 Kirill V Tkhai (tkhai@yandex.ru)
*/
#include <linux/mm.h>
#include <asm/hibernate.h>
#include <asm/visasm.h>
#include <asm/page.h>
#include <asm/tlb.h>
/* References to section boundaries */
extern const void __nosave_begin, __nosave_end;
struct saved_context saved_context;
/*
* pfn_is_nosave - check if given pfn is in the 'nosave' section
*/
int pfn_is_nosave(unsigned long pfn)
{
unsigned long nosave_begin_pfn = PFN_DOWN((unsigned long)&__nosave_begin);
unsigned long nosave_end_pfn = PFN_DOWN((unsigned long)&__nosave_end);
return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
}
void save_processor_state(void)
{
save_and_clear_fpu();
}
void restore_processor_state(void)
{
struct mm_struct *mm = current->active_mm;
load_secondary_context(mm);
tsb_context_switch(mm);
}
/*
* hibernate_asm.S: Hibernaton support specific for sparc64.
*
* Copyright (C) 2013 Kirill V Tkhai (tkhai@yandex.ru)
*/
#include <linux/linkage.h>
#include <asm/asm-offsets.h>
#include <asm/cpudata.h>
#include <asm/page.h>
ENTRY(swsusp_arch_suspend)
save %sp, -128, %sp
save %sp, -128, %sp
flushw
setuw saved_context, %g3
/* Save window regs */
rdpr %cwp, %g2
stx %g2, [%g3 + SC_REG_CWP]
rdpr %wstate, %g2
stx %g2, [%g3 + SC_REG_WSTATE]
stx %fp, [%g3 + SC_REG_FP]
/* Save state regs */
rdpr %tick, %g2
stx %g2, [%g3 + SC_REG_TICK]
rdpr %pstate, %g2
stx %g2, [%g3 + SC_REG_PSTATE]
/* Save global regs */
stx %g4, [%g3 + SC_REG_G4]
stx %g5, [%g3 + SC_REG_G5]
stx %g6, [%g3 + SC_REG_G6]
call swsusp_save
nop
mov %o0, %i0
restore
mov %o0, %i0
ret
restore
ENTRY(swsusp_arch_resume)
/* Write restore_pblist to %l0 */
sethi %hi(restore_pblist), %l0
ldx [%l0 + %lo(restore_pblist)], %l0
call __flush_tlb_all
nop
/* Write PAGE_OFFSET to %g7 */
sethi %uhi(PAGE_OFFSET), %g7
sllx %g7, 32, %g7
setuw (PAGE_SIZE-8), %g3
/* Use MMU Bypass */
rd %asi, %g1
wr %g0, ASI_PHYS_USE_EC, %asi
ba fill_itlb
nop
pbe_loop:
cmp %l0, %g0
be restore_ctx
sub %l0, %g7, %l0
ldxa [%l0 ] %asi, %l1 /* address */
ldxa [%l0 + 8] %asi, %l2 /* orig_address */
/* phys addr */
sub %l1, %g7, %l1
sub %l2, %g7, %l2
mov %g3, %l3 /* PAGE_SIZE-8 */
copy_loop:
ldxa [%l1 + %l3] ASI_PHYS_USE_EC, %g2
stxa %g2, [%l2 + %l3] ASI_PHYS_USE_EC
cmp %l3, %g0
bne copy_loop
sub %l3, 8, %l3
/* next pbe */
ba pbe_loop
ldxa [%l0 + 16] %asi, %l0
restore_ctx:
setuw saved_context, %g3
/* Restore window regs */
wrpr %g0, 0, %canrestore
wrpr %g0, 0, %otherwin
wrpr %g0, 6, %cansave
wrpr %g0, 0, %cleanwin
ldxa [%g3 + SC_REG_CWP] %asi, %g2
wrpr %g2, %cwp
ldxa [%g3 + SC_REG_WSTATE] %asi, %g2
wrpr %g2, %wstate
ldxa [%g3 + SC_REG_FP] %asi, %fp
/* Restore state regs */
ldxa [%g3 + SC_REG_PSTATE] %asi, %g2
wrpr %g2, %pstate
ldxa [%g3 + SC_REG_TICK] %asi, %g2
wrpr %g2, %tick
/* Restore global regs */
ldxa [%g3 + SC_REG_G4] %asi, %g4
ldxa [%g3 + SC_REG_G5] %asi, %g5
ldxa [%g3 + SC_REG_G6] %asi, %g6
wr %g1, %g0, %asi
restore
restore
wrpr %g0, 14, %pil
retl
mov %g0, %o0
fill_itlb:
ba pbe_loop
wrpr %g0, 15, %pil
...@@ -1592,6 +1592,7 @@ static int __init sunsu_init(void) ...@@ -1592,6 +1592,7 @@ static int __init sunsu_init(void)
static void __exit sunsu_exit(void) static void __exit sunsu_exit(void)
{ {
platform_driver_unregister(&su_driver);
if (sunsu_reg.nr) if (sunsu_reg.nr)
sunserial_unregister_minors(&sunsu_reg, sunsu_reg.nr); sunserial_unregister_minors(&sunsu_reg, sunsu_reg.nr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment