06 Oct, 2016

8 commits

  • The default i8259 polling function (i8259_irq) is nicely generic but is
    fairly costly. Platforms often provide an alternative means of polling
    for an i8259 interrupt, and when using the i8259 without device tree
    have typically just chained its parent interrupt to their own handler
    function. In order to allow for platform-specific polling functions to
    be used in cases where the driver is probed via device tree, provide an
    i8259_set_poll function that accepts a pointer to an alternative poll
    function that will override the default.

    Signed-off-by: Paul Burton
    Acked-by: Thomas Gleixner
    Cc: Jason Cooper
    Cc: Marc Zyngier
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14270/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Mapping the parent IRQ will use a virq number which may conflict with
    the hardcoded I8259A_IRQ_BASE..I8259A_IRQ_BASE+15 range that the i8259
    driver expects to be free. If this occurs then we'll hit errors when
    adding the i8259 IRQ domain, since one of its virq numbers will already
    be in use.

    Avoid this by adding the i8259 domain before mapping the parent IRQ,
    such that the i8259 virq numbers become used before the parent interrupt
    controller gets a chance to use any of them.

    Signed-off-by: Paul Burton
    Acked-by: Thomas Gleixner
    Cc: Marc Zyngier
    Cc: Jason Cooper
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14269/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • The SEAD3 board defines a custom implementation of read_persistent_clock
    which does exactly the same dummy operation as the generic weak version.
    Remove the not really implemented custom version.

    Signed-off-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14064/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe the img-ascii-lcd driver using device tree in order to display a
    message on the SEAD3 board's LCD display, and remove the platform code
    that was formerly performing this function. This removes more platform
    code and moves SEAD3 further towards being entirely DT-based.

    Signed-off-by: Paul Burton
    Cc: Jacek Anaszewski
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14063/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Add a driver for simple ASCII LCD displays found on the MIPS Boston,
    Malta & SEAD3 development boards. The Boston display is an independent
    memory mapped device with a simple memory mapped 8 byte register space
    containing the 8 ASCII characters to display. The Malta display is
    exposed as part of the Malta board registers, and provides 8 registers
    each of which corresponds to one of the ASCII characters to display. The
    SEAD3 display is slightly more complex, exposing an interface to an
    S6A0069 LCD controller via registers provided by the boards CPLD.
    However although the displays differ in their register interface, we
    require similar functionality on each board so abstracting away the
    differences within a single driver allows us to share a significant
    amount of code & ensure consistent behaviour.

    The driver displays the Linux kernel version as the default message, but
    allows the message to be changed via a character device. Messages longer
    then the number of characters that the display can show will scroll.

    This provides different behaviour to the existing LCD display code for
    the MIPS Malta or MIPS SEAD3 platforms in the following ways:

    - The default string to display is not "LINUX ON MALTA" or "LINUX ON
    SEAD3" but "Linux" followed by the version number of the kernel
    (UTS_RELEASE).

    - Since that string tends to be significantly longer it scrolls twice
    as fast, moving every 500ms rather than every 1s.

    - The LCD won't be updated until the driver is probed, so it doesn't
    provide the early "LINUX" string.

    Signed-off-by: Paul Burton
    Cc: Mauro Carvalho Chehab
    Cc: Miguel Ojeda Sandonis
    Cc: Guenter Roeck
    Cc: David S. Miller
    Cc: Greg Kroah-Hartman
    Cc: Geert Uytterhoeven
    Cc: Andrew Morton
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14062/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Add documentation for a devicetree binding for the simple ASCII LCD
    displays found on development boards such as the MIPS Boston, MIPS Malta
    & MIPS SEAD3 from Imagination Technologies.

    Signed-off-by: Paul Burton
    Acked-by: Rob Herring
    Cc: Mauro Carvalho Chehab
    Cc: Guenter Roeck
    Cc: David S. Miller
    Cc: Greg Kroah-Hartman
    Cc: Geert Uytterhoeven
    Cc: Mark Rutland
    Cc: Andrew Morton
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14061/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • The SEAD3 board no longer uses the cobalt_lcdfb driver, so remove the
    SEAD3-specific code from it.

    Signed-off-by: Paul Burton
    Acked-by: Tomi Valkeinen
    Cc: Ondrej Zary
    Cc: Arnd Bergmann
    Cc: Robert Jarzmik
    Cc: Maciej W. Rozycki
    Cc: Ezequiel Garcia
    Cc: Tomi Valkeinen
    Cc: Jean-Christophe Plagniol-Villard
    Cc: Geert Uytterhoeven
    Cc: Simon Horman
    Cc: linux-mips@linux-mips.org
    Cc: linux-fbdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14060/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • The 2 line * 16 character LCD display on the SEAD3 board has no real use
    as a framebuffer device. It's far too small to produce any meaningful
    output if used as the kernel console, SEAD3 is a development board that
    will essentially always have a far more useful UART connection & the
    code in sead3-display.c will overwrite whatever's on the display every
    second anyway. Remove this unused code.

    Signed-off-by: Paul Burton
    Cc: Jacek Anaszewski
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14059/
    Signed-off-by: Ralf Baechle

    Paul Burton
     

05 Oct, 2016

23 commits

  • Parse the memsize argument provided by the bootloader in the DT shim
    code, allowing the user to override it on the command line. This places
    all of the DT manipulation code into sead3-dtshim.c.

    Signed-off-by: Paul Burton
    Cc: Matt Redfearn
    Cc: Rob Herring
    Cc: Kefeng Wang
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14058/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Remove the custom platform code to restart when instructed to power off,
    instead relying upon the generic restart-poweroff driver probed via DT
    to do the same thing.

    Remove also the halt implementation, which is incorrect. The generic
    MIPS version will hang the system as halt should.

    Signed-off-by: Paul Burton
    Cc: Jacek Anaszewski
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14057/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Remove the SEAD3 implementation of _machine_restart & instead make use
    of the generic syscon-reboot driver probed via device tree.

    Signed-off-by: Paul Burton
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14056/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe a driver for the PLED & FLED LEDs found on the SEAD3 board using
    the register-bit-led driver via device tree, rather than a custom driver
    via platform code. Enable support for the register-bit-led driver & its
    prerequisite syscon in sead3_defconfig.

    Signed-off-by: Paul Burton
    Cc: Jacek Anaszewski
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14054/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe the system parallel flash using device tree rather than platform
    code, in order to reduce the amount of the latter.

    Signed-off-by: Paul Burton
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14053/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • The SEAD-3 board is now probing its EHCI controller using the generic
    EHCI driver & its generic-ehci device tree binding. Remove the unused
    SEAD-3 specific EHCI code.

    Signed-off-by: Paul Burton
    Acked-by: Alan Stern
    Cc: Greg Kroah-Hartman
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-usb@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14052/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe the SEAD3 EHCI controller using the generic-ehci driver & device
    tree rather than platform code, in order to reduce the amount of the
    latter.

    Now that no devices probed from platform code require interrupts, remove
    the retrieval of the IRQ domain & sead3int.h.

    Signed-off-by: Paul Burton
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14051/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe the smsc911x ethernet controller using device tree rather than
    platform code, reducing the amount of the latter.

    Signed-off-by: Paul Burton
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14050/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Stop selecting SYS_HAS_EARLY_PRINTK & remove the custom support for
    early output to the ns16550a UARTs, instead relying upon generic
    ns16550a earlycon support. This reduces the amount of platform code
    required for SEAD3 without losing any functionality.

    Signed-off-by: Paul Burton
    Cc: Jacek Anaszewski
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14049/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe the UARTs on SEAD3 boards using device tree rather than platform
    code, in order to reduce the amount of the latter. This requires that
    CONFIG_SERIAL_OF_PLATFORM be enabled, so enable it in sead3_defconfig.
    The SEAD3 DT shim code is extended to read bootloader environment
    variables to determine the appropriate UART & mode for kernel console
    output & set the stdout-path property of the chosen node accordingly.

    In contrast to the old platform code, which appears to have only ever
    set "console=ttyS0,38400n8r" with the code in console_config never
    having an effect, this will honor the "yamontty" environment variable to
    select between the 2 UARTs on the board and then check the "modetty0" or
    "modetty1" variable as appropriate to determine the UART configuration.

    Signed-off-by: Paul Burton
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14048/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Probe the CPU interrupt controller & optional Global Interrupt
    Controller (GIC) using devicetree rather than platform code. Because the
    bootloader on SEAD3 does not provide a device tree to the kernel & the
    device tree is always built in, we patch out the GIC node during boot if
    we detect that a GIC is not present in the system.

    The appropriate IRQ domain is discovered by platform code setting up
    device IRQ numbers temporarily. It will be removed by further patches
    which move the devices towards being probed via device tree.

    No behavioural change is intended by this patch.

    Signed-off-by: Paul Burton
    Cc: Matt Redfearn
    Cc: Kefeng Wang
    Cc: Jacek Anaszewski
    Cc: Rob Herring
    Cc: Mark Rutland
    Cc: linux-mips@linux-mips.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14047/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Split the obj-y entries for SEAD3 onto a line each, so that they're more
    independent & can be modified more clearly by later commits.

    Signed-off-by: Paul Burton
    Cc: Jacek Anaszewski
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14046/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • The MIPS Coherent Processing System (CPS) power management code has
    previously generated code used to enter low power idle states once
    during boot for all CPUs. This has the drawback that if a CPU is present
    in the system but not being used (for example due to the maxcpus kernel
    parameter) then we encounter problems due to not having probed that CPU
    for information about its type & properties. The result of this is that
    we generate entry code which is both unused, potentially entirely
    invalid & likely to be unsuitable for the CPU in question anyway.

    Avoid this by generating idle state entry code only when a CPU is
    brought online. This way we only ever generate code for CPUs that we
    know we've probed the properties of, and that will actually be used.

    [ralf@linux-mips.org: Resolve merge conflict.]

    Signed-off-by: Paul Burton
    Cc: Adam Buchbinder
    Cc: Masahiro Yamada
    Cc: Markos Chandras
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14259/
    Signed-off-by: Ralf Baechle

    Paul Burton
     
  • Historically a lot of these existed because we did not have
    a distinction between what was modular code and what was providing
    support to modules via EXPORT_SYMBOL and friends. That changed
    when we forked out support for the latter into the export.h file.

    This means we should be able to reduce the usage of module.h
    in code that is obj-y Makefile or bool Kconfig. In the case of
    kvm where it is modular, we can extend that to also include files
    that are building basic support functionality but not related
    to loading or registering the final module; such files also have
    no need whatsoever for module.h

    The advantage in removing such instances is that module.h itself
    sources about 15 other headers; adding significantly to what we feed
    cpp, and it can obscure what headers we are effectively using.

    Since module.h was the source for init.h (for __init) and for
    export.h (for EXPORT_SYMBOL) we consider each instance for the
    presence of either and replace as needed. In this case, we did
    not need to add either to any files.

    Signed-off-by: Paul Gortmaker
    Acked-by: James Hogan
    Acked-by: Paolo Bonzini
    Cc: "Radim Krčmář"
    Cc: kvm@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14036/
    Signed-off-by: Ralf Baechle

    Paul Gortmaker
     
  • Historically a lot of these existed because we did not have
    a distinction between what was modular code and what was providing
    support to modules via EXPORT_SYMBOL and friends. That changed
    when we forked out support for the latter into the export.h file.

    This means we should be able to reduce the usage of module.h
    in code that is obj-y Makefile or bool Kconfig. The advantage
    in doing so is that module.h itself sources about 15 other headers;
    adding significantly to what we feed cpp, and it can obscure what
    headers we are effectively using.

    Since module.h was the source for init.h (for __init) and for
    export.h (for EXPORT_SYMBOL) we consider each obj-y/bool instance
    for the presence of either and replace as needed.

    We also needed to remove the no-op MODULE_DEVICE_TABLE usage in
    several instances to permit removal of the module.h include. The
    files in these instances were all controlled by bool Kconfig.

    In one instance, module_param was being used so we transition the
    module.h include onto a moduleparam.h include.

    Signed-off-by: Paul Gortmaker
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14035/
    Signed-off-by: Ralf Baechle

    Paul Gortmaker
     
  • Historically a lot of these existed because we did not have
    a distinction between what was modular code and what was providing
    support to modules via EXPORT_SYMBOL and friends. That changed
    when we forked out support for the latter into the export.h file.

    This means we should be able to reduce the usage of module.h
    in code that is obj-y Makefile or bool Kconfig. The advantage
    in doing so is that module.h itself sources about 15 other headers;
    adding significantly to what we feed cpp, and it can obscure what
    headers we are effectively using.

    Since module.h was the source for init.h (for __init) and for
    export.h (for EXPORT_SYMBOL) we consider each obj-y/bool instance
    for the presence of either and replace as needed.

    The compiler.h additions are for an implict presence of the
    "notrace" which module.h brought in but export.h does not.

    Signed-off-by: Paul Gortmaker
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14034/
    Signed-off-by: Ralf Baechle

    Paul Gortmaker
     
  • Historically a lot of these existed because we did not have
    a distinction between what was modular code and what was providing
    support to modules via EXPORT_SYMBOL and friends. That changed
    when we forked out support for the latter into the export.h file.

    This means we should be able to reduce the usage of module.h
    in code that is obj-y Makefile or bool Kconfig. The advantage
    in doing so is that module.h itself sources about 15 other headers;
    adding significantly to what we feed cpp, and it can obscure what
    headers we are effectively using.

    Since module.h was the source for init.h (for __init) and for
    export.h (for EXPORT_SYMBOL) we consider each obj-y/bool instance
    for the presence of either and replace as needed.

    Signed-off-by: Paul Gortmaker
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14033/
    Signed-off-by: Ralf Baechle

    Paul Gortmaker
     
  • Historically a lot of these existed because we did not have
    a distinction between what was modular code and what was providing
    support to modules via EXPORT_SYMBOL and friends. That changed
    when we forked out support for the latter into the export.h file.

    This means we should be able to reduce the usage of module.h
    in code that is obj-y Makefile or bool Kconfig. The advantage
    in doing so is that module.h itself sources about 15 other headers;
    adding significantly to what we feed cpp, and it can obscure what
    headers we are effectively using.

    Since module.h was the source for init.h (for __init) and for
    export.h (for EXPORT_SYMBOL) we consider each obj-y/bool instance
    for the presence of either and replace as needed.

    In the case of the n32/o32 files, we have to get rid of a couple
    no-op MODULE_ tags to facilitate the module.h removal. They piggy
    back off the fs/ elf binary support, which is also a bool Kconfig.

    Signed-off-by: Paul Gortmaker
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14032/
    Signed-off-by: Ralf Baechle

    Paul Gortmaker
     
  • Signed-off-by: Ralf Baechle

    Ralf Baechle
     
  • For the MIPS remote processor implementation, we need additional IPIs to
    talk to the remote processor. Since MIPS GIC reserves exactly the right
    number of IPI IRQs required by Linux for the number of VPs in the
    system, this is not possible without releasing some recources.

    This commit introduces mips_smp_ipi_allocate() which allocates IPIs to a
    given cpumask. It is called as normal with the cpu_possible_mask at
    bootup to initialise IPIs to all CPUs. mips_smp_ipi_free() may then be
    used to free IPIs to a subset of those CPUs so that their hardware
    resources can be reused.

    Signed-off-by: Matt Redfearn
    Cc: Bjorn Andersson
    Cc: Ohad Ben-Cohen
    Cc: Thomas Gleixner
    Cc: Lisa Parratt
    Cc: James Hogan
    Cc: Qais Yousef
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Cc: linux-remoteproc@vger.kernel.org
    Cc: lisa.parratt@imgtec.com
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14285/
    Signed-off-by: Ralf Baechle

    Matt Redfearn
     
  • When adding a wired entry to the TLB via add_wired_entry, the tlb is
    flushed with local_flush_tlb_all, which on CPUs with TLBINV results in
    the new wired entry being flushed again.

    Behavior of the TLBINV instruction applies to all applicable TLB entries
    and is unaffected by the setting of the Wired register. Therefore if
    the TLB has any wired entries, fall back to iterating over the entries
    rather than blasting them all using TLBINVF.

    Signed-off-by: Matt Redfearn
    Cc: Bjorn Andersson
    Cc: Ohad Ben-Cohen
    Cc: Thomas Gleixner
    Cc: lisa.parratt@imgtec.com
    Cc: Hugh Dickins
    Cc: Huacai Chen
    Cc: David S. Miller
    Cc: James Hogan
    Cc: Paul Burton
    Cc: Andrew Morton
    Cc: linux-mips@linux-mips.org
    Cc: linux-remoteproc@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14283/
    Signed-off-by: Ralf Baechle

    Matt Redfearn
     
  • flush_icache_range() flushes icache lines in a protected fashion for
    kernel addresses, however this isn't correct with EVA where protected
    cache ops only operate on user addresses, making flush_icache_range()
    ineffective.

    Split the implementations of __flush_icache_user_range() from
    flush_icache_range(), changing the normal flush_icache_range() to use
    unprotected normal cache ops.

    Signed-off-by: James Hogan
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14156/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • Convert KVM dynamic translation of guest instructions to flush icache
    for guest mapped addresses using the new
    __local_flush_icache_user_range() API to allow the more generic
    flush_icache_range() to be changed to work on kernel addresses only.

    Signed-off-by: James Hogan
    Cc: Ralf Baechle
    Cc: Paolo Bonzini
    Cc: "Radim Krčmář"
    Cc: linux-mips@linux-mips.org
    Cc: kvm@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14155/
    Signed-off-by: Ralf Baechle

    James Hogan
     

04 Oct, 2016

9 commits

  • Update arch_uprobe_copy_ixol() to use the kmap_atomic() based kernel
    address to flush the icache with flush_icache_range(), rather than the
    user mapping. We have the kernel mapping available anyway and this
    avoids having to switch to using the new __flush_icache_user_range() for
    the sake of Enhanced Virtual Addressing (EVA) where flush_icache_range()
    will become ineffective on user addresses.

    Signed-off-by: James Hogan
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14154/
    Patchwork: https://patchwork.linux-mips.org/patch/14308/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • The cacheflush(2) system call uses flush_icache_range() to flush a range
    of usermode addresses from the icache, so change it to utilise the new
    __flush_icache_user_range() API to allow the more generic
    flush_icache_range() to be changed to work on kernel addresses only.

    Signed-off-by: James Hogan
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14153/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • flush_icache_range() is used for both user addresses (i.e.
    cacheflush(2)), and kernel addresses (as the API documentation
    describes).

    This isn't really suitable however for Enhanced Virtual Addressing (EVA)
    where cache operations on usermode addresses must use a different
    instruction, and the protected cache ops assume user addresses, making
    flush_icache_range() ineffective on kernel addresses.

    Split out a new __flush_icache_user_range() and
    __local_flush_icache_user_range() for users which actually want to flush
    usermode addresses (note that flush_icache_user_range() already exists
    on various architectures but with different arguments).

    The implementation of flush_icache_range() will be changed in an
    upcoming commit to use unprotected normal cache ops so as to always work
    on the kernel mode address space.

    Signed-off-by: James Hogan
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14152/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • The EVA conditional bc_wback_inv() at the end of flush_icache_range() to
    flush the modified code all the way back to RAM was apparently there for
    debug purposes and to accommodate the Malta EVA configuration which
    makes use of a physical alias, and didn't use the CP0_EBase.WG (Write
    Gate) bit to put the exception vector in the same physical alias where
    the exception vector code is written and is being flushed.

    Now that CP0_EBase.WG is used, lets drop this flush.

    Signed-off-by: James Hogan
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14151/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • On CPUs which support the EBase WG (write gate) flag, the most
    significant bits of the exception base can be changed. Firmware running
    on a VP(E) using MIPS rproc may change EBase to point into the user
    segment where the firmware is located such that it can service
    interrupts. When control is transferred back to the kernel the EBase
    must be switched back into the kernel segment, such that the kernel's
    exception vectors are used.

    Similarly when vectored interrupts (vint) or vectored external interrupt
    controllers (veic) are enabled an exception vector is allocated from
    bootmem, and written to the EBase register. Due to the WG flag being
    clear, only bits 29:12 will be written. Asside from the rproc case above
    this is normally fine (as it will usually be a low allocation within the
    KSeg0 range, however when Enhanced Virtual Addressing (EVA) is enabled
    the allocation may be outside of the traditional KSeg0/KSeg1 address
    range, resulting in the wrong EBase being written.

    Correct both cases (configure_exception_vector() for the boot CPU, and
    per_cpu_trap_init() for secondary CPUs) to write EBase with the WG flag
    first if supported.

    On the Malta EVA configuration, KSeg0 is mapped to physical address 0,
    and memory is allocated from the KUSeg segment which is mapped to
    physical address 0x80000000, which physically aliases the RAM at 0. This
    only worked due to the exception base address aliasing the same
    underlying RAM that was written to & cache flushed, and due to
    flush_icache_range() going beyond the call of duty and flushing from the
    L2 cache too (due to the differing physical addresses).

    Signed-off-by: Matt Redfearn
    Signed-off-by: James Hogan
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14150/
    Signed-off-by: Ralf Baechle

    Matt Redfearn
     
  • When allocating boot memory for the exception vector when vectored
    interrupts (vint) or vectored external interrupt controllers (veic) are
    enabled, try to ensure that the virtual address resides in KSeg0 (and
    WARN should that not be possible).

    This will be helpful on MIPS64 cores supporting the CP0_EBase Write Gate
    (WG) bit once we start using the WG bit to write the full ebase into
    CP0_EBase, as we ideally need to avoid hitting the architecturally
    poorly defined exception base for Cache Errors when CP0_EBase is in
    XKPhys.

    An exception is made for Enhanced Virtual Addressing (EVA) kernels which
    allow segments to be rearranged and to become uncached during cache
    error handling, making it valid for ebase to be elsewhere.

    Signed-off-by: James Hogan
    Cc: Matt Redfearn
    Cc: Leonid Yegoshin
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14149/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • When reading the CP0_EBase register containing the WG (write gate) bit,
    the ebase variable should be set to the full value of the register, i.e.
    on a 64-bit kernel the full 64-bit width of the register via
    read_cp0_ebase_64(), and on a 32-bit kernel the full 32-bit width
    including bits 31:30 which may be writeable.

    Signed-off-by: James Hogan
    Signed-off-by: Matt Redfearn
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/14148/
    Signed-off-by: Ralf Baechle

    James Hogan
     
  • This patch enables the MIPS CPS driver for MIPSr6 CPUs.

    Signed-off-by: Matt Redfearn
    Reviewed-by: Paul Burton
    Reviewed-by: Daniel Lezcano
    Cc: Rafael J. Wysocki
    Cc: linux-mips@linux-mips.org
    Cc: linux-pm@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Patchwork: https://patchwork.linux-mips.org/patch/14228/
    Signed-off-by: Ralf Baechle

    Matt Redfearn
     
  • All calls to mips_cpc_lock_other should be wrapped in
    mips_cm_lock_other. This only matters if the system has CM3 and is using
    cpu idle, since otherwise a) the CPC lock is sufficent for CM < 3 and b)
    any systems with CM > 3 have not been able to use cpu idle until now.

    Signed-off-by: Matt Redfearn
    Reviewed-by: Paul Burton
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Cc: Thomas Gleixner
    Cc: James Hogan
    Cc: Qais Yousef
    Patchwork: https://patchwork.linux-mips.org/patch/14227/
    Signed-off-by: Ralf Baechle

    Matt Redfearn