1. 23 Apr, 2021 6 commits
  2. 21 Apr, 2021 8 commits
    • Maciej W. Rozycki's avatar
      lib/math/test_div64: Fix error message formatting · 182dd5ba
      Maciej W. Rozycki authored
      Align the expected result with one actually produced for easier visual
      comparison; this has to take into account what the format specifiers
      will actually produce rather than the characters they consist of.  E.g.:
      
      test_div64: ERROR: 10000000ab275080 / 00000009 => 01c71c71da20d00e,00000002
      test_div64: ERROR: expected value              => 0000000013045e47,00000001
      
      (with a failure induced by setting bit #60 of the divident).
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      182dd5ba
    • xiaochuan mao's avatar
      mips/bootinfo:correct some comments of fw_arg · 6f3377bc
      xiaochuan mao authored
      from arch/mips/kernel/head.S we know that use a0~a3 for fw_arg0~fw_arg3
      there is some code from head.S:
      	LONG_S		a0, fw_arg0		# firmware arguments
      	LONG_S		a1, fw_arg1
      	LONG_S		a2, fw_arg2
      	LONG_S		a3, fw_arg3
      Signed-off-by: default avatarxiaochuan mao <maoxiaochuan@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      6f3377bc
    • Maciej W. Rozycki's avatar
      MIPS: Avoid DIVU in `__div64_32' is result would be zero · c1d337d4
      Maciej W. Rozycki authored
      We already check the high part of the divident against zero to avoid the
      costly DIVU instruction in that case, needed to reduce the high part of
      the divident, so we may well check against the divisor instead and set
      the high part of the quotient to zero right away.  We need to treat the
      high part the divident in that case though as the remainder that would
      be calculated by the DIVU instruction we avoided.
      
      This has passed correctness verification with test_div64 and reduced the
      module's average execution time down to 1.0445s and 0.2619s from 1.0668s
      and 0.2629s respectively for an R3400 CPU @40MHz and a 5Kc CPU @160MHz.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      c1d337d4
    • Maciej W. Rozycki's avatar
      MIPS: Reinstate platform `__div64_32' handler · c49f71f6
      Maciej W. Rozycki authored
      Our current MIPS platform `__div64_32' handler is inactive, because it
      is incorrectly only enabled for 64-bit configurations, for which generic
      `do_div' code does not call it anyway.
      
      The handler is not suitable for being called from there though as it
      only calculates 32 bits of the quotient under the assumption the 64-bit
      divident has been suitably reduced.  Code for such reduction used to be
      there, however it has been incorrectly removed with commit c21004cd
      ("MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0."), which should
      have only updated an obsoleted constraint for an inline asm involving
      $hi and $lo register outputs, while possibly wiring the original MIPS
      variant of the `do_div' macro as `__div64_32' handler for the generic
      `do_div' implementation
      
      Correct the handler as follows then:
      
      - Revert most of the commit referred, however retaining the current
        formatting, except for the final two instructions of the inline asm
        sequence, which the original commit missed.  Omit the original 64-bit
        parts though.
      
      - Rename the original `do_div' macro to `__div64_32'.  Use the combined
        `x' constraint referring to the MD accumulator as a whole, replacing
        the original individual `h' and `l' constraints used for $hi and $lo
        registers respectively, of which `h' has been obsoleted with GCC 4.4.
        Update surrounding code accordingly.
      
        We have since removed support for GCC versions before 4.9, so no need
        for a special arrangement here; GCC has supported the `x' constraint
        since forever anyway, or at least going back to 1991.
      
      - Rename the `__base' local variable in `__div64_32' to `__radix' to
        avoid a conflict with a local variable in `do_div'.
      
      - Actually enable this code for 32-bit rather than 64-bit configurations
        by qualifying it with BITS_PER_LONG being 32 instead of 64.  Include
        <asm/bitsperlong.h> for this macro rather than <linux/types.h> as we
        don't need anything else.
      
      - Finally include <asm-generic/div64.h> last rather than first.
      
      This has passed correctness verification with test_div64 and reduced the
      module's average execution time down to 1.0668s and 0.2629s from 2.1529s
      and 0.5647s respectively for an R3400 CPU @40MHz and a 5Kc CPU @160MHz.
      For a reference 64-bit `do_div' code where we have the DDIVU instruction
      available to do the whole calculation right away averages at 0.0660s for
      the latter CPU.
      
      Fixes: c21004cd ("MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0.")
      Reported-by: default avatarHuacai Chen <chenhuacai@kernel.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Cc: stable@vger.kernel.org # v2.6.30+
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      c49f71f6
    • Maciej W. Rozycki's avatar
      div64: Correct inline documentation for `do_div' · f2875832
      Maciej W. Rozycki authored
      Correct inline documentation for `do_div', which is a function-like
      macro the `n' parameter of which has the semantics of a C++ reference:
      it is both read and written in the context of the caller without an
      explicit dereference such as with a pointer.
      
      In the C programming language it has no equivalent for proper functions,
      in terms of which the documentation expresses the semantics of `do_div',
      but substituting a pointer in documentation is misleading, and using the
      C++ notation should at least raise the reader's attention and encourage
      to seek explanation even if the C++ semantics is not readily understood.
      
      While at it observe that "semantics" is an uncountable noun, so refer to
      it with a singular rather than plural verb.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      f2875832
    • Maciej W. Rozycki's avatar
      lib/math: Add a `do_div' test module · 5086ea4b
      Maciej W. Rozycki authored
      Implement a module for correctness and performance evaluation for the
      `do_div' function, often handled in an optimised manner by platform
      code.  Use a somewhat randomly generated set of inputs that is supposed
      to be representative, using the same set of divisors twice, expressed as
      a constant and as a variable each, so as to verify the implementation
      for both cases should they be handled by different code execution paths.
      Reference results were produced with GNU bc.
      
      At the conclusion output the total execution time elapsed.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      5086ea4b
    • zhaoxiao's avatar
      MIPS: Makefile: Replace -pg with CC_FLAGS_FTRACE · 1b6bc35a
      zhaoxiao authored
      This patch replaces the "open-coded" -pg compile flag with a CC_FLAGS_FTRACE
      makefile variable which architectures can override if a different option
      should be used for code generation.
      Signed-off-by: default avatarzhaoxiao <zhaoxiao@uniontech.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      1b6bc35a
    • Ilya Lipnitskiy's avatar
      MIPS: pci-legacy: revert "use generic pci_enable_resources" · 987b4207
      Ilya Lipnitskiy authored
      This mostly reverts commit 99bca615 ("MIPS: pci-legacy: use generic
      pci_enable_resources"). Fixes regressions such as:
        ata_piix 0000:00:0a.1: can't enable device: BAR 0 [io  0x01f0-0x01f7] not
      	claimed
        ata_piix: probe of 0000:00:0a.1 failed with error -22
      
      The only changes from the strict revert are to fix checkpatch errors:
        ERROR: spaces required around that '=' (ctx:VxV)
        #33: FILE: arch/mips/pci/pci-legacy.c:252:
        +	for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
       	        ^
      
        ERROR: do not use assignment in if condition
        #67: FILE: arch/mips/pci/pci-legacy.c:284:
        +	if ((err = pcibios_enable_resources(dev, mask)) < 0)
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      987b4207
  3. 16 Apr, 2021 9 commits
    • Huacai Chen's avatar
      MIPS: Loongson64: Add kexec/kdump support · 6ce48897
      Huacai Chen authored
      Add kexec/kdump support for Loongson64 by:
      1, Provide Loongson-specific kexec functions: loongson_kexec_prepare(),
         loongson_kexec_shutdown() and loongson_crash_shutdown();
      2, Provide Loongson-specific assembly code in kexec_smp_wait();
      
      To start Loongson64, The boot CPU needs 3 parameters:
      fw_arg0: the number of arguments in cmdline (i.e., argc).
      fw_arg1: structure holds cmdline such as "root=/dev/sda1 console=tty"
               (i.e., argv).
      fw_arg2: environment (i.e., envp, additional boot parameters from LEFI).
      
      Non-boot CPUs do not need one parameter as the IPI mailbox base address.
      They query their own IPI mailbox to get PC, SP and GP in a loopi, until
      the boot CPU brings them up.
      
      loongson_kexec_prepare(): Setup cmdline for kexec/kdump. The kexec/kdump
      cmdline comes from kexec's "append" option string. This structure will
      be parsed in fw_init_cmdline() of arch/mips/fw/lib/cmdline.c. Both image
      ->control_code_page and the cmdline need to be in a safe memory region
      (memory allocated by the old kernel may be corrupted by the new kernel).
      In order to maintain compatibility for the old firmware, the low 2MB is
      reserverd and safe for Loongson. So let KEXEC_CTRL_CODE and KEXEC_ARGV_
      ADDR be here. LEFI parameters may be corrupted at runtime, so backup it
      at mips_reboot_setup(), and then restore it at loongson_kexec_shutdown()
      /loongson_crash_shutdown().
      
      loongson_kexec_shutdown(): Wake up all present CPUs and let them go to
      reboot_code_buffer. Pass the kexec parameters to kexec_args.
      
      loongson_crash_shutdown(): Pass the kdump parameters to kexec_args.
      
      The assembly part in kexec_smp_wait provide a routine as BIOS does, in
      order to keep secondary CPUs in a querying loop.
      
      The layout of low 2MB memory in our design:
      0x80000000, the first MB, the first 64K, Exception vectors
      0x80010000, the first MB, the second 64K, STR (suspend) data
      0x80020000, the first MB, the third and fourth 64K, UEFI HOB
      0x80040000, the first MB, the fifth 64K, RT-Thread for SMC
      0x80100000, the second MB, the first 64K, KEXEC code
      0x80108000, the second MB, the second 64K, KEXEC data
      
      Cc: Eric Biederman <ebiederm@xmission.com>
      Tested-by: default avatarJinyang He <hejinyang@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@kernel.org>
      Signed-off-by: default avatarJinyang He <hejinyang@loongson.cn>
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      6ce48897
    • Ilya Lipnitskiy's avatar
      MIPS: pci-legacy: use generic pci_enable_resources · 99bca615
      Ilya Lipnitskiy authored
      Follow the reasoning from commit 842de40d ("PCI: add generic
      pci_enable_resources()"):
      
        The only functional difference from the MIPS version is that the
        generic one uses "!r->parent" to check for resource collisions
        instead of "!r->start && r->end".
      
      That should have no effect on any pci-legacy driver.
      Suggested-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      99bca615
    • Ilya Lipnitskiy's avatar
      MIPS: pci-legacy: remove busn_resource field · 0af83d2e
      Ilya Lipnitskiy authored
      No drivers set the busn_resource field in the pci_controller struct.
      Commit 7ee214b5 ("MIPS: PCI: Remove unused busn_offset") almost
      removed it over 3 years ago. Remove it for good to free up memory and
      eliminate messages like:
        pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      0af83d2e
    • Ilya Lipnitskiy's avatar
      MIPS: pci-legacy: remove redundant info messages · 317f553b
      Ilya Lipnitskiy authored
      Remove the following pci-legacy message:
        PCI host bridge /pci@440000/host-bridge ranges:
         MEM 0x0000000020000000..0x000000002fffffff
          IO 0x0000000000460000..0x000000000046ffff
      
      It is followed shortly by the same data from pci_register_host_bridge:
        PCI host bridge to bus 0000:00
        pci_bus 0000:00: root bus resource [mem 0x20000000-0x2fffffff]
        pci_bus 0000:00: root bus resource [io  0x460000-0x46ffff]
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      317f553b
    • Ilya Lipnitskiy's avatar
      MIPS: pci-legacy: stop using of_pci_range_to_resource · 3ecb9dc1
      Ilya Lipnitskiy authored
      Mirror commit aeba3731 ("powerpc/pci: Fix IO space breakage after
      of_pci_range_to_resource() change").
      
      Most MIPS platforms do not define PCI_IOBASE, nor implement
      pci_address_to_pio(). Moreover, IO_SPACE_LIMIT is 0xffff for most MIPS
      platforms. of_pci_range_to_resource passes the _start address_ of the IO
      range into pci_address_to_pio, which then checks it against
      IO_SPACE_LIMIT and fails, because for MIPS platforms that use
      pci-legacy (pci-lantiq, pci-rt3883, pci-mt7620), IO ranges start much
      higher than 0xffff.
      
      In fact, pci-mt7621 in staging already works around this problem, see
      commit 09dd629e ("staging: mt7621-pci: fix io space and properly set
      resource limits")
      
      So just stop using of_pci_range_to_resource, which does not work for
      MIPS.
      
      Fixes PCI errors like:
        pci_bus 0000:00: root bus resource [io  0xffffffff]
      
      Fixes: 0b0b0893 ("of/pci: Fix the conversion of IO ranges into IO resources")
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Cc: Liviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      3ecb9dc1
    • Ilya Lipnitskiy's avatar
      MIPS: pci-rt3883: more accurate DT error messages · 2f802e17
      Ilya Lipnitskiy authored
      Existing strings do not make sense: one is always NULL and the other
      refers to the wrong parent node.
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      2f802e17
    • Ilya Lipnitskiy's avatar
      MIPS: pci-rt3883: trivial: remove unused variable · becb0425
      Ilya Lipnitskiy authored
      Fixes the following compiler warning:
        warning: unused variable 'flags' [-Wunused-variable]
      
      Fixes: e5067c71 ("MIPS: pci-rt3883: Remove odd locking in PCI config space access code")
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Acked-by: default avatarSergey Ryazanov <ryazanov.s.a@gmail.com>
      Cc: trivial@kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      becb0425
    • Ilya Lipnitskiy's avatar
      MIPS: pci-rt2880: remove unneeded locks · 791a7be2
      Ilya Lipnitskiy authored
      Mirror pci-rt3883 fix from commit e5067c71 ("MIPS: pci-rt3883:
      Remove odd locking in PCI config space access code"). pci-rt2880 shares
      the driver layout with pci-rt3883 and the same reasons apply.
      
      Caller (generic PCI code) already does proper locking, so no need to add
      another one here. Local PCI read/write functions are never called
      simultaneously, also they do not require synchronization with the PCI
      controller ops, since they are used before the controller registration.
      Suggested-by: default avatarSergey Ryazanov <ryazanov.s.a@gmail.com>
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Reviewed-by: default avatarSergey Ryazanov <ryazanov.s.a@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      791a7be2
    • Ilya Lipnitskiy's avatar
      MIPS: pci-rt2880: fix slot 0 configuration · 8e98b697
      Ilya Lipnitskiy authored
      pci_fixup_irqs() used to call pcibios_map_irq on every PCI device, which
      for RT2880 included bus 0 slot 0. After pci_fixup_irqs() got removed,
      only slots/funcs with devices attached would be called. While arguably
      the right thing, that left no chance for this driver to ever initialize
      slot 0, effectively bricking PCI and USB on RT2880 devices such as the
      Belkin F5D8235-4 v1.
      
      Slot 0 configuration needs to happen after PCI bus enumeration, but
      before any device at slot 0x11 (func 0 or 1) is talked to. That was
      determined empirically by testing on a Belkin F5D8235-4 v1 device. A
      minimal BAR 0 config write followed by read, then setting slot 0
      PCI_COMMAND to MASTER | IO | MEMORY is all that seems to be required for
      proper functionality.
      
      Tested by ensuring that full- and high-speed USB devices get enumerated
      on the Belkin F5D8235-4 v1 (with an out of tree DTS file from OpenWrt).
      
      Fixes: 04c81c72 ("MIPS: PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks")
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Tobias Wolf <dev-NTEO@vplace.de>
      Cc: <stable@vger.kernel.org> # v4.14+
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      8e98b697
  4. 15 Apr, 2021 1 commit
  5. 13 Apr, 2021 1 commit
  6. 12 Apr, 2021 4 commits
  7. 09 Apr, 2021 1 commit
  8. 07 Apr, 2021 1 commit
  9. 06 Apr, 2021 9 commits