Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mips_5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux

Pull MIPS changes from Paul Burton:
"Nothing too big or scary in here:

- Support mremap() for the VDSO, primarily to allow CRIU to restore
the VDSO to its checkpointed location.

- Restore the MIPS32 cBPF JIT, after having reverted the enablement
of the eBPF JIT for MIPS32 systems in the 5.5 cycle.

- Improve cop0 counter synchronization behaviour whilst onlining CPUs
by running with interrupts disabled.

- Better match FPU behaviour when emulating multiply-accumulate
instructions on pre-r6 systems that implement IEEE754-2008 style
MACs.

- Loongson64 kernels now build using the MIPS64r2 ISA, allowing them
to take advantage of instructions introduced by r2.

- Support for the Ingenic X1000 SoC & the really nice little CU Neo
development board that's using it.

- Support for WMAC on GARDENA Smart Gateway devices.

- Lots of cleanup & refactoring of SGI IP27 (Origin 2*) support in
preparation for introducing IP35 (Origin 3*) support.

- Various Kconfig & Makefile cleanups"

* tag 'mips_5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (60 commits)
MIPS: PCI: Add detection of IOC3 on IO7, IO8, IO9 and Fuel
MIPS: Loongson64: Disable exec hazard
MIPS: Loongson64: Bump ISA level to MIPSR2
MIPS: Make DIEI support as a config option
MIPS: OCTEON: octeon-irq: fix spelling mistake "to" -> "too"
MIPS: asm: local: add barriers for Loongson
MIPS: Loongson64: Select mac2008 only feature
MIPS: Add MAC2008 Support
Revert "MIPS: Add custom serial.h with BASE_BAUD override for generic kernel"
MIPS: sort MIPS and MIPS_GENERIC Kconfig selects alphabetically (again)
MIPS: make CPU_HAS_LOAD_STORE_LR opt-out
MIPS: generic: don't unconditionally select PINCTRL
MIPS: don't explicitly select LIBFDT in Kconfig
MIPS: sync-r4k: do slave counter synchronization with disabled HW interrupts
MIPS: SGI-IP30: Check for valid pointer before using it
MIPS: syscalls: fix indentation of the 'SYSNR' message
MIPS: boot: fix typo in 'vmlinux.lzma.its' target
MIPS: fix indentation of the 'RELOCS' message
dt-bindings: Document loongson vendor-prefix
MIPS: CU1000-Neo: Refresh defconfig to support HWMON and WiFi.
...

+3889 -1240
+35
Documentation/devicetree/bindings/mips/ingenic/devices.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mips/ingenic/devices.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Ingenic XBurst based Platforms Device Tree Bindings 8 + 9 + maintainers: 10 + - 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com> 11 + description: | 12 + Devices with a Ingenic XBurst CPU shall have the following properties. 13 + 14 + properties: 15 + $nodename: 16 + const: '/' 17 + compatible: 18 + oneOf: 19 + 20 + - description: Qi Hardware Ben NanoNote 21 + items: 22 + - const: qi,lb60 23 + 24 + - description: Game Consoles Worldwide GCW Zero 25 + items: 26 + - const: gcw,zero 27 + 28 + - description: MIPS Creator CI20 29 + items: 30 + - const: img,ci20 31 + 32 + - description: YSH & ATIL General Board CU Neo 33 + items: 34 + - const: yna,cu1000-neo 35 + ...
+4
Documentation/devicetree/bindings/vendor-prefixes.yaml
··· 555 555 description: Logic PD, Inc. 556 556 "^longcheer,.*": 557 557 description: Longcheer Technology (Shanghai) Co., Ltd. 558 + "^loongson,.*": 559 + description: Loongson Technology Corporation Limited 558 560 "^lsi,.*": 559 561 description: LSI Corp. (LSI Logic) 560 562 "^lwn,.*": ··· 1086 1084 description: Shenzhen Xunlong Software CO.,Limited 1087 1085 "^xylon,.*": 1088 1086 description: Xylon 1087 + "^yna,.*": 1088 + description: YSH & ATIL 1089 1089 "^yones-toptech,.*": 1090 1090 description: Yones Toptech Co., Ltd. 1091 1091 "^ysoft,.*":
-1
MAINTAINERS
··· 11116 11116 MIPS 11117 11117 M: Ralf Baechle <ralf@linux-mips.org> 11118 11118 M: Paul Burton <paulburton@kernel.org> 11119 - M: James Hogan <jhogan@kernel.org> 11120 11119 L: linux-mips@vger.kernel.org 11121 11120 W: http://www.linux-mips.org/ 11122 11121 T: git git://git.linux-mips.org/pub/scm/ralf/linux.git
+39 -45
arch/mips/Kconfig
··· 5 5 select ARCH_32BIT_OFF_T if !64BIT 6 6 select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT 7 7 select ARCH_CLOCKSOURCE_DATA 8 + select ARCH_HAS_FORTIFY_SOURCE 9 + select ARCH_HAS_KCOV 10 + select ARCH_HAS_PTE_SPECIAL if !(32BIT && CPU_HAS_RIXI) 8 11 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 9 12 select ARCH_HAS_UBSAN_SANITIZE_ALL 10 - select ARCH_HAS_FORTIFY_SOURCE 11 13 select ARCH_SUPPORTS_UPROBES 12 14 select ARCH_USE_BUILTIN_BSWAP 13 15 select ARCH_USE_CMPXCHG_LOCKREF if 64BIT ··· 49 47 select HAVE_ARCH_TRACEHOOK 50 48 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES 51 49 select HAVE_ASM_MODVERSIONS 52 - select HAVE_EBPF_JIT if 64BIT && !CPU_MICROMIPS && TARGET_ISA_REV >= 2 50 + select HAVE_CBPF_JIT if !64BIT && !CPU_MICROMIPS 53 51 select HAVE_CONTEXT_TRACKING 54 52 select HAVE_COPY_THREAD_TLS 55 53 select HAVE_C_RECORDMCOUNT ··· 57 55 select HAVE_DEBUG_STACKOVERFLOW 58 56 select HAVE_DMA_CONTIGUOUS 59 57 select HAVE_DYNAMIC_FTRACE 58 + select HAVE_EBPF_JIT if 64BIT && !CPU_MICROMIPS && TARGET_ISA_REV >= 2 60 59 select HAVE_EXIT_THREAD 61 60 select HAVE_FAST_GUP 62 61 select HAVE_FTRACE_MCOUNT_RECORD 63 62 select HAVE_FUNCTION_GRAPH_TRACER 64 63 select HAVE_FUNCTION_TRACER 64 + select HAVE_GCC_PLUGINS 65 + select HAVE_GENERIC_VDSO 65 66 select HAVE_IDE 66 67 select HAVE_IOREMAP_PROT 67 68 select HAVE_IRQ_EXIT_ON_IRQ_STACK ··· 83 78 select HAVE_STACKPROTECTOR 84 79 select HAVE_SYSCALL_TRACEPOINTS 85 80 select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP 86 - select HAVE_GENERIC_VDSO 87 81 select IRQ_FORCED_THREADING 88 82 select ISA if EISA 89 - select MODULES_USE_ELF_RELA if MODULES && 64BIT 90 83 select MODULES_USE_ELF_REL if MODULES 84 + select MODULES_USE_ELF_RELA if MODULES && 64BIT 91 85 select PERF_USE_VMALLOC 92 86 select RTC_LIB 93 87 select SYSCTL_EXCEPTION_TRACE 94 88 select VIRT_TO_BUS 95 - select ARCH_HAS_PTE_SPECIAL if !(32BIT && CPU_HAS_RIXI) 96 - select ARCH_HAS_KCOV 97 - select HAVE_GCC_PLUGINS 98 89 99 90 menu "Machine selection" 100 91 ··· 105 104 select CEVT_R4K 106 105 select CLKSRC_MIPS_GIC 107 106 select COMMON_CLK 108 - select CPU_MIPSR2_IRQ_VI 109 107 select CPU_MIPSR2_IRQ_EI 108 + select CPU_MIPSR2_IRQ_VI 110 109 select CSRC_R4K 111 110 select DMA_PERDEV_COHERENT 112 111 select HAVE_PCI 113 112 select IRQ_MIPS_CPU 114 - select LIBFDT 115 113 select MIPS_AUTO_PFN_OFFSET 116 114 select MIPS_CPU_SCACHE 117 115 select MIPS_GIC 118 116 select MIPS_L1_CACHE_SHIFT_7 119 117 select NO_EXCEPT_FILL 120 118 select PCI_DRIVERS_GENERIC 121 - select PINCTRL 122 119 select SMP_UP if SMP 123 120 select SWAP_IO_SPACE 124 121 select SYS_HAS_CPU_MIPS32_R1 ··· 131 132 select SYS_SUPPORTS_HIGHMEM 132 133 select SYS_SUPPORTS_LITTLE_ENDIAN 133 134 select SYS_SUPPORTS_MICROMIPS 134 - select SYS_SUPPORTS_MIPS_CPS 135 135 select SYS_SUPPORTS_MIPS16 136 + select SYS_SUPPORTS_MIPS_CPS 136 137 select SYS_SUPPORTS_MULTITHREADING 137 138 select SYS_SUPPORTS_RELOCATABLE 138 139 select SYS_SUPPORTS_SMARTMIPS 140 + select UHI_BOOT 139 141 select USB_EHCI_BIG_ENDIAN_DESC if CPU_BIG_ENDIAN 140 142 select USB_EHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN 141 143 select USB_OHCI_BIG_ENDIAN_DESC if CPU_BIG_ENDIAN ··· 144 144 select USB_UHCI_BIG_ENDIAN_DESC if CPU_BIG_ENDIAN 145 145 select USB_UHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN 146 146 select USE_OF 147 - select UHI_BOOT 148 147 help 149 148 Select this to build a kernel which aims to support multiple boards, 150 149 generally using a flattened device tree passed from the bootloader ··· 402 403 select GENERIC_IRQ_CHIP 403 404 select BUILTIN_DTB if MIPS_NO_APPENDED_DTB 404 405 select USE_OF 405 - select LIBFDT 406 406 407 407 config LANTIQ 408 408 bool "Lantiq based platforms" ··· 508 510 select DMA_NONCOHERENT 509 511 select GPIOLIB 510 512 select IRQ_MIPS_CPU 511 - select LIBFDT 512 513 select MFD_SYSCON 513 514 select MIPS_CPU_SCACHE 514 515 select MIPS_GIC ··· 545 548 select I8253 546 549 select I8259 547 550 select IRQ_MIPS_CPU 548 - select LIBFDT 549 551 select MIPS_BONITO64 550 552 select MIPS_CPU_SCACHE 551 553 select MIPS_GIC ··· 976 980 select ZONE_DMA32 977 981 select HOLES_IN_ZONE 978 982 select GPIOLIB 979 - select LIBFDT 980 983 select USE_OF 981 984 select ARCH_SPARSEMEM_ENABLE 982 985 select SYS_SUPPORTS_SMP ··· 1218 1223 def_bool n 1219 1224 1220 1225 config GENERIC_CSUM 1221 - bool 1222 - default y if !CPU_HAS_LOAD_STORE_LR 1226 + def_bool CPU_NO_LOAD_STORE_LR 1223 1227 1224 1228 config GENERIC_ISA_DMA 1225 1229 bool ··· 1436 1442 bool "Loongson 64-bit CPU" 1437 1443 depends on SYS_HAS_CPU_LOONGSON64 1438 1444 select ARCH_HAS_PHYS_TO_DMA 1445 + select CPU_MIPSR2 1446 + select CPU_HAS_PREFETCH 1439 1447 select CPU_SUPPORTS_64BIT_KERNEL 1440 1448 select CPU_SUPPORTS_HIGHMEM 1441 1449 select CPU_SUPPORTS_HUGEPAGES 1442 1450 select CPU_SUPPORTS_MSA 1443 - select CPU_HAS_LOAD_STORE_LR 1451 + select CPU_DIEI_BROKEN if !LOONGSON3_ENHANCEMENT 1452 + select CPU_MIPSR2_IRQ_VI 1444 1453 select WEAK_ORDERING 1445 1454 select WEAK_REORDERING_BEYOND_LLSC 1446 1455 select MIPS_ASID_BITS_VARIABLE ··· 1461 1464 config LOONGSON3_ENHANCEMENT 1462 1465 bool "New Loongson-3 CPU Enhancements" 1463 1466 default n 1464 - select CPU_MIPSR2 1465 - select CPU_HAS_PREFETCH 1466 1467 depends on CPU_LOONGSON64 1467 1468 help 1468 1469 New Loongson-3 cores (since Loongson-3A R2, as opposed to Loongson-3A ··· 1537 1542 bool "MIPS32 Release 1" 1538 1543 depends on SYS_HAS_CPU_MIPS32_R1 1539 1544 select CPU_HAS_PREFETCH 1540 - select CPU_HAS_LOAD_STORE_LR 1541 1545 select CPU_SUPPORTS_32BIT_KERNEL 1542 1546 select CPU_SUPPORTS_HIGHMEM 1543 1547 help ··· 1554 1560 bool "MIPS32 Release 2" 1555 1561 depends on SYS_HAS_CPU_MIPS32_R2 1556 1562 select CPU_HAS_PREFETCH 1557 - select CPU_HAS_LOAD_STORE_LR 1558 1563 select CPU_SUPPORTS_32BIT_KERNEL 1559 1564 select CPU_SUPPORTS_HIGHMEM 1560 1565 select CPU_SUPPORTS_MSA ··· 1569 1576 bool "MIPS32 Release 6" 1570 1577 depends on SYS_HAS_CPU_MIPS32_R6 1571 1578 select CPU_HAS_PREFETCH 1579 + select CPU_NO_LOAD_STORE_LR 1572 1580 select CPU_SUPPORTS_32BIT_KERNEL 1573 1581 select CPU_SUPPORTS_HIGHMEM 1574 1582 select CPU_SUPPORTS_MSA ··· 1585 1591 bool "MIPS64 Release 1" 1586 1592 depends on SYS_HAS_CPU_MIPS64_R1 1587 1593 select CPU_HAS_PREFETCH 1588 - select CPU_HAS_LOAD_STORE_LR 1589 1594 select CPU_SUPPORTS_32BIT_KERNEL 1590 1595 select CPU_SUPPORTS_64BIT_KERNEL 1591 1596 select CPU_SUPPORTS_HIGHMEM ··· 1604 1611 bool "MIPS64 Release 2" 1605 1612 depends on SYS_HAS_CPU_MIPS64_R2 1606 1613 select CPU_HAS_PREFETCH 1607 - select CPU_HAS_LOAD_STORE_LR 1608 1614 select CPU_SUPPORTS_32BIT_KERNEL 1609 1615 select CPU_SUPPORTS_64BIT_KERNEL 1610 1616 select CPU_SUPPORTS_HIGHMEM ··· 1621 1629 bool "MIPS64 Release 6" 1622 1630 depends on SYS_HAS_CPU_MIPS64_R6 1623 1631 select CPU_HAS_PREFETCH 1632 + select CPU_NO_LOAD_STORE_LR 1624 1633 select CPU_SUPPORTS_32BIT_KERNEL 1625 1634 select CPU_SUPPORTS_64BIT_KERNEL 1626 1635 select CPU_SUPPORTS_HIGHMEM ··· 1639 1646 bool "R3000" 1640 1647 depends on SYS_HAS_CPU_R3000 1641 1648 select CPU_HAS_WB 1642 - select CPU_HAS_LOAD_STORE_LR 1643 1649 select CPU_R3K_TLB 1644 1650 select CPU_SUPPORTS_32BIT_KERNEL 1645 1651 select CPU_SUPPORTS_HIGHMEM ··· 1654 1662 bool "R39XX" 1655 1663 depends on SYS_HAS_CPU_TX39XX 1656 1664 select CPU_SUPPORTS_32BIT_KERNEL 1657 - select CPU_HAS_LOAD_STORE_LR 1658 1665 select CPU_R3K_TLB 1659 1666 1660 1667 config CPU_VR41XX ··· 1661 1670 depends on SYS_HAS_CPU_VR41XX 1662 1671 select CPU_SUPPORTS_32BIT_KERNEL 1663 1672 select CPU_SUPPORTS_64BIT_KERNEL 1664 - select CPU_HAS_LOAD_STORE_LR 1665 1673 help 1666 1674 The options selects support for the NEC VR4100 series of processors. 1667 1675 Only choose this option if you have one of these processors as a ··· 1673 1683 select CPU_SUPPORTS_32BIT_KERNEL 1674 1684 select CPU_SUPPORTS_64BIT_KERNEL 1675 1685 select CPU_SUPPORTS_HUGEPAGES 1676 - select CPU_HAS_LOAD_STORE_LR 1677 1686 help 1678 1687 MIPS Technologies R4000-series processors other than 4300, including 1679 1688 the R4000, R4400, R4600, and 4700. ··· 1681 1692 bool "R49XX" 1682 1693 depends on SYS_HAS_CPU_TX49XX 1683 1694 select CPU_HAS_PREFETCH 1684 - select CPU_HAS_LOAD_STORE_LR 1685 1695 select CPU_SUPPORTS_32BIT_KERNEL 1686 1696 select CPU_SUPPORTS_64BIT_KERNEL 1687 1697 select CPU_SUPPORTS_HUGEPAGES ··· 1691 1703 select CPU_SUPPORTS_32BIT_KERNEL 1692 1704 select CPU_SUPPORTS_64BIT_KERNEL 1693 1705 select CPU_SUPPORTS_HUGEPAGES 1694 - select CPU_HAS_LOAD_STORE_LR 1695 1706 help 1696 1707 MIPS Technologies R5000-series processors other than the Nevada. 1697 1708 ··· 1700 1713 select CPU_SUPPORTS_32BIT_KERNEL 1701 1714 select CPU_SUPPORTS_64BIT_KERNEL 1702 1715 select CPU_SUPPORTS_HUGEPAGES 1703 - select CPU_HAS_LOAD_STORE_LR 1704 1716 help 1705 1717 NEC VR5500 and VR5500A series processors implement 64-bit MIPS IV 1706 1718 instruction set. ··· 1710 1724 select CPU_SUPPORTS_32BIT_KERNEL 1711 1725 select CPU_SUPPORTS_64BIT_KERNEL 1712 1726 select CPU_SUPPORTS_HUGEPAGES 1713 - select CPU_HAS_LOAD_STORE_LR 1714 1727 help 1715 1728 QED / PMC-Sierra RM52xx-series ("Nevada") processors. 1716 1729 ··· 1717 1732 bool "R10000" 1718 1733 depends on SYS_HAS_CPU_R10000 1719 1734 select CPU_HAS_PREFETCH 1720 - select CPU_HAS_LOAD_STORE_LR 1721 1735 select CPU_SUPPORTS_32BIT_KERNEL 1722 1736 select CPU_SUPPORTS_64BIT_KERNEL 1723 1737 select CPU_SUPPORTS_HIGHMEM ··· 1728 1744 bool "RM7000" 1729 1745 depends on SYS_HAS_CPU_RM7000 1730 1746 select CPU_HAS_PREFETCH 1731 - select CPU_HAS_LOAD_STORE_LR 1732 1747 select CPU_SUPPORTS_32BIT_KERNEL 1733 1748 select CPU_SUPPORTS_64BIT_KERNEL 1734 1749 select CPU_SUPPORTS_HIGHMEM ··· 1736 1753 config CPU_SB1 1737 1754 bool "SB1" 1738 1755 depends on SYS_HAS_CPU_SB1 1739 - select CPU_HAS_LOAD_STORE_LR 1740 1756 select CPU_SUPPORTS_32BIT_KERNEL 1741 1757 select CPU_SUPPORTS_64BIT_KERNEL 1742 1758 select CPU_SUPPORTS_HIGHMEM ··· 1746 1764 bool "Cavium Octeon processor" 1747 1765 depends on SYS_HAS_CPU_CAVIUM_OCTEON 1748 1766 select CPU_HAS_PREFETCH 1749 - select CPU_HAS_LOAD_STORE_LR 1750 1767 select CPU_SUPPORTS_64BIT_KERNEL 1751 1768 select WEAK_ORDERING 1752 1769 select CPU_SUPPORTS_HIGHMEM ··· 1775 1794 select WEAK_ORDERING 1776 1795 select CPU_SUPPORTS_HIGHMEM 1777 1796 select CPU_HAS_PREFETCH 1778 - select CPU_HAS_LOAD_STORE_LR 1779 1797 select CPU_SUPPORTS_CPUFREQ 1780 1798 select MIPS_EXTERNAL_TIMER 1781 1799 help ··· 1783 1803 config CPU_XLR 1784 1804 bool "Netlogic XLR SoC" 1785 1805 depends on SYS_HAS_CPU_XLR 1786 - select CPU_HAS_LOAD_STORE_LR 1787 1806 select CPU_SUPPORTS_32BIT_KERNEL 1788 1807 select CPU_SUPPORTS_64BIT_KERNEL 1789 1808 select CPU_SUPPORTS_HIGHMEM ··· 1801 1822 select WEAK_ORDERING 1802 1823 select WEAK_REORDERING_BEYOND_LLSC 1803 1824 select CPU_HAS_PREFETCH 1804 - select CPU_HAS_LOAD_STORE_LR 1805 1825 select CPU_MIPSR2 1806 1826 select CPU_SUPPORTS_HUGEPAGES 1807 1827 select MIPS_ASID_BITS_VARIABLE ··· 1906 1928 select CPU_SUPPORTS_HIGHMEM 1907 1929 select CPU_SUPPORTS_HUGEPAGES 1908 1930 select ARCH_HAS_PHYS_TO_DMA 1909 - select CPU_HAS_LOAD_STORE_LR 1910 1931 1911 1932 config CPU_LOONGSON32 1912 1933 bool 1913 1934 select CPU_MIPS32 1914 1935 select CPU_MIPSR2 1915 1936 select CPU_HAS_PREFETCH 1916 - select CPU_HAS_LOAD_STORE_LR 1917 1937 select CPU_SUPPORTS_32BIT_KERNEL 1918 1938 select CPU_SUPPORTS_HIGHMEM 1919 1939 select CPU_SUPPORTS_CPUFREQ ··· 2086 2110 bool 2087 2111 default y if CPU_MIPS32_R2 || CPU_MIPS64_R2 || CPU_CAVIUM_OCTEON 2088 2112 select CPU_HAS_RIXI 2113 + select CPU_HAS_DIEI if !CPU_DIEI_BROKEN 2089 2114 select MIPS_SPRAM 2090 2115 2091 2116 config CPU_MIPSR6 2092 2117 bool 2093 2118 default y if CPU_MIPS32_R6 || CPU_MIPS64_R6 2094 2119 select CPU_HAS_RIXI 2120 + select CPU_HAS_DIEI if !CPU_DIEI_BROKEN 2095 2121 select HAVE_ARCH_BITREVERSE 2096 2122 select MIPS_ASID_BITS_VARIABLE 2097 2123 select MIPS_CRC_SUPPORT ··· 2553 2575 config XKS01 2554 2576 bool 2555 2577 2578 + config CPU_HAS_DIEI 2579 + depends on !CPU_DIEI_BROKEN 2580 + bool 2581 + 2582 + config CPU_DIEI_BROKEN 2583 + bool 2584 + 2556 2585 config CPU_HAS_RIXI 2557 2586 bool 2558 2587 2559 - config CPU_HAS_LOAD_STORE_LR 2588 + config CPU_NO_LOAD_STORE_LR 2560 2589 bool 2561 2590 help 2562 - CPU has support for unaligned load and store instructions: 2591 + CPU lacks support for unaligned load and store instructions: 2563 2592 LWL, LWR, SWL, SWR (Load/store word left/right). 2564 - LDL, LDR, SDL, SDR (Load/store doubleword left/right, for 64bit systems). 2593 + LDL, LDR, SDL, SDR (Load/store doubleword left/right, for 64bit 2594 + systems). 2565 2595 2566 2596 # 2567 2597 # Vectored interrupt mode is an R2 feature ··· 2681 2695 2682 2696 config SYS_SUPPORTS_NUMA 2683 2697 bool 2698 + 2699 + config HAVE_SETUP_PER_CPU_AREA 2700 + def_bool y 2701 + depends on NUMA 2702 + 2703 + config NEED_PER_CPU_EMBED_FIRST_CHUNK 2704 + def_bool y 2705 + depends on NUMA 2684 2706 2685 2707 config RELOCATABLE 2686 2708 bool "Relocatable kernel"
+1 -1
arch/mips/boot/Makefile
··· 123 123 targets += vmlinux.its 124 124 targets += vmlinux.gz.its 125 125 targets += vmlinux.bz2.its 126 - targets += vmlinux.lzmo.its 126 + targets += vmlinux.lzma.its 127 127 targets += vmlinux.lzo.its 128 128 129 129 quiet_cmd_cpp_its_S = ITS $@
+1
arch/mips/boot/dts/ingenic/Makefile
··· 2 2 dtb-$(CONFIG_JZ4740_QI_LB60) += qi_lb60.dtb 3 3 dtb-$(CONFIG_JZ4770_GCW0) += gcw0.dtb 4 4 dtb-$(CONFIG_JZ4780_CI20) += ci20.dtb 5 + dtb-$(CONFIG_X1000_CU1000_NEO) += cu1000-neo.dtb 5 6 6 7 obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y))
+170
arch/mips/boot/dts/ingenic/cu1000-neo.dts
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /dts-v1/; 3 + 4 + #include "x1000.dtsi" 5 + #include <dt-bindings/gpio/gpio.h> 6 + #include <dt-bindings/clock/ingenic,tcu.h> 7 + #include <dt-bindings/interrupt-controller/irq.h> 8 + 9 + / { 10 + compatible = "yna,cu1000-neo", "ingenic,x1000"; 11 + model = "YSH & ATIL General Board CU Neo"; 12 + 13 + aliases { 14 + serial2 = &uart2; 15 + }; 16 + 17 + chosen { 18 + stdout-path = "serial2:115200n8"; 19 + }; 20 + 21 + memory { 22 + device_type = "memory"; 23 + reg = <0x0 0x04000000>; 24 + }; 25 + 26 + wlan_pwrseq: msc1-pwrseq { 27 + compatible = "mmc-pwrseq-simple"; 28 + 29 + clocks = <&lpoclk>; 30 + clock-names = "ext_clock"; 31 + 32 + reset-gpios = <&gpc 17 GPIO_ACTIVE_LOW>; 33 + post-power-on-delay-ms = <200>; 34 + 35 + lpoclk: ap6212a { 36 + compatible = "fixed-clock"; 37 + #clock-cells = <0>; 38 + clock-frequency = <32768>; 39 + }; 40 + }; 41 + }; 42 + 43 + &exclk { 44 + clock-frequency = <24000000>; 45 + }; 46 + 47 + &tcu { 48 + /* 1500 kHz for the system timer and clocksource */ 49 + assigned-clocks = <&tcu TCU_CLK_TIMER0>, <&tcu TCU_CLK_TIMER2>; 50 + assigned-clock-rates = <1500000>, <1500000>; 51 + 52 + /* Use channel #0 for the system timer channel #2 for the clocksource */ 53 + ingenic,pwm-channels-mask = <0xfa>; 54 + }; 55 + 56 + &i2c0 { 57 + status = "okay"; 58 + 59 + clock-frequency = <400000>; 60 + 61 + pinctrl-names = "default"; 62 + pinctrl-0 = <&pins_i2c0>; 63 + 64 + ads7830@48 { 65 + compatible = "ti,ads7830"; 66 + reg = <0x48>; 67 + }; 68 + }; 69 + 70 + &uart2 { 71 + pinctrl-names = "default"; 72 + pinctrl-0 = <&pins_uart2>; 73 + 74 + status = "okay"; 75 + }; 76 + 77 + &mac { 78 + phy-mode = "rmii"; 79 + phy-handle = <&lan8720a>; 80 + 81 + pinctrl-names = "default"; 82 + pinctrl-0 = <&pins_mac>; 83 + 84 + snps,reset-gpio = <&gpc 23 GPIO_ACTIVE_LOW>; /* PC23 */ 85 + snps,reset-active-low; 86 + snps,reset-delays-us = <0 10000 30000>; 87 + 88 + status = "okay"; 89 + }; 90 + 91 + &mdio { 92 + status = "okay"; 93 + 94 + lan8720a: ethernet-phy@0 { 95 + compatible = "ethernet-phy-id0007.c0f0", "ethernet-phy-ieee802.3-c22"; 96 + reg = <0>; 97 + }; 98 + }; 99 + 100 + &msc0 { 101 + bus-width = <8>; 102 + max-frequency = <50000000>; 103 + 104 + pinctrl-names = "default"; 105 + pinctrl-0 = <&pins_msc0>; 106 + 107 + non-removable; 108 + 109 + status = "okay"; 110 + }; 111 + 112 + &msc1 { 113 + bus-width = <4>; 114 + max-frequency = <50000000>; 115 + 116 + pinctrl-names = "default"; 117 + pinctrl-0 = <&pins_msc1>; 118 + 119 + #address-cells = <1>; 120 + #size-cells = <0>; 121 + 122 + non-removable; 123 + 124 + mmc-pwrseq = <&wlan_pwrseq>; 125 + 126 + status = "okay"; 127 + 128 + ap6212a: wifi@1 { 129 + compatible = "brcm,bcm4329-fmac"; 130 + reg = <1>; 131 + 132 + interrupt-parent = <&gpc>; 133 + interrupts = <16 IRQ_TYPE_EDGE_FALLING>; 134 + interrupt-names = "host-wake"; 135 + 136 + brcm,drive-strength = <10>; 137 + }; 138 + }; 139 + 140 + &pinctrl { 141 + pins_i2c0: i2c0 { 142 + function = "i2c0"; 143 + groups = "i2c0-data"; 144 + bias-disable; 145 + }; 146 + 147 + pins_uart2: uart2 { 148 + function = "uart2"; 149 + groups = "uart2-data-d"; 150 + bias-disable; 151 + }; 152 + 153 + pins_mac: mac { 154 + function = "mac"; 155 + groups = "mac"; 156 + bias-disable; 157 + }; 158 + 159 + pins_msc0: msc0 { 160 + function = "mmc0"; 161 + groups = "mmc0-1bit", "mmc0-4bit", "mmc0-8bit"; 162 + bias-disable; 163 + }; 164 + 165 + pins_msc1: msc1 { 166 + function = "mmc1"; 167 + groups = "mmc1-1bit", "mmc1-4bit"; 168 + bias-disable; 169 + }; 170 + };
+317
arch/mips/boot/dts/ingenic/x1000.dtsi
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <dt-bindings/clock/x1000-cgu.h> 3 + #include <dt-bindings/dma/x1000-dma.h> 4 + 5 + / { 6 + #address-cells = <1>; 7 + #size-cells = <1>; 8 + compatible = "ingenic,x1000", "ingenic,x1000e"; 9 + 10 + cpuintc: interrupt-controller { 11 + #address-cells = <0>; 12 + #interrupt-cells = <1>; 13 + interrupt-controller; 14 + compatible = "mti,cpu-interrupt-controller"; 15 + }; 16 + 17 + intc: interrupt-controller@10001000 { 18 + compatible = "ingenic,x1000-intc", "ingenic,jz4780-intc"; 19 + reg = <0x10001000 0x50>; 20 + 21 + interrupt-controller; 22 + #interrupt-cells = <1>; 23 + 24 + interrupt-parent = <&cpuintc>; 25 + interrupts = <2>; 26 + }; 27 + 28 + exclk: ext { 29 + compatible = "fixed-clock"; 30 + #clock-cells = <0>; 31 + }; 32 + 33 + rtclk: rtc { 34 + compatible = "fixed-clock"; 35 + #clock-cells = <0>; 36 + clock-frequency = <32768>; 37 + }; 38 + 39 + cgu: x1000-cgu@10000000 { 40 + compatible = "ingenic,x1000-cgu"; 41 + reg = <0x10000000 0x100>; 42 + 43 + #clock-cells = <1>; 44 + 45 + clocks = <&exclk>, <&rtclk>; 46 + clock-names = "ext", "rtc"; 47 + }; 48 + 49 + tcu: timer@10002000 { 50 + compatible = "ingenic,x1000-tcu", 51 + "ingenic,jz4770-tcu", 52 + "simple-mfd"; 53 + reg = <0x10002000 0x1000>; 54 + #address-cells = <1>; 55 + #size-cells = <1>; 56 + ranges = <0x0 0x10002000 0x1000>; 57 + 58 + #clock-cells = <1>; 59 + 60 + clocks = <&cgu X1000_CLK_RTCLK 61 + &cgu X1000_CLK_EXCLK 62 + &cgu X1000_CLK_PCLK>; 63 + clock-names = "rtc", "ext", "pclk"; 64 + 65 + interrupt-controller; 66 + #interrupt-cells = <1>; 67 + 68 + interrupt-parent = <&intc>; 69 + interrupts = <27 26 25>; 70 + 71 + wdt: watchdog@0 { 72 + compatible = "ingenic,x1000-watchdog", "ingenic,jz4780-watchdog"; 73 + reg = <0x0 0x10>; 74 + 75 + clocks = <&cgu X1000_CLK_RTCLK>; 76 + clock-names = "wdt"; 77 + }; 78 + }; 79 + 80 + rtc: rtc@10003000 { 81 + compatible = "ingenic,x1000-rtc", "ingenic,jz4780-rtc"; 82 + reg = <0x10003000 0x4c>; 83 + 84 + interrupt-parent = <&intc>; 85 + interrupts = <32>; 86 + 87 + clocks = <&cgu X1000_CLK_RTCLK>; 88 + clock-names = "rtc"; 89 + }; 90 + 91 + pinctrl: pin-controller@10010000 { 92 + compatible = "ingenic,x1000-pinctrl"; 93 + reg = <0x10010000 0x800>; 94 + #address-cells = <1>; 95 + #size-cells = <0>; 96 + 97 + gpa: gpio@0 { 98 + compatible = "ingenic,x1000-gpio"; 99 + reg = <0>; 100 + 101 + gpio-controller; 102 + gpio-ranges = <&pinctrl 0 0 32>; 103 + #gpio-cells = <2>; 104 + 105 + interrupt-controller; 106 + #interrupt-cells = <2>; 107 + 108 + interrupt-parent = <&intc>; 109 + interrupts = <17>; 110 + }; 111 + 112 + gpb: gpio@1 { 113 + compatible = "ingenic,x1000-gpio"; 114 + reg = <1>; 115 + 116 + gpio-controller; 117 + gpio-ranges = <&pinctrl 0 32 32>; 118 + #gpio-cells = <2>; 119 + 120 + interrupt-controller; 121 + #interrupt-cells = <2>; 122 + 123 + interrupt-parent = <&intc>; 124 + interrupts = <16>; 125 + }; 126 + 127 + gpc: gpio@2 { 128 + compatible = "ingenic,x1000-gpio"; 129 + reg = <2>; 130 + 131 + gpio-controller; 132 + gpio-ranges = <&pinctrl 0 64 32>; 133 + #gpio-cells = <2>; 134 + 135 + interrupt-controller; 136 + #interrupt-cells = <2>; 137 + 138 + interrupt-parent = <&intc>; 139 + interrupts = <15>; 140 + }; 141 + 142 + gpd: gpio@3 { 143 + compatible = "ingenic,x1000-gpio"; 144 + reg = <3>; 145 + 146 + gpio-controller; 147 + gpio-ranges = <&pinctrl 0 96 32>; 148 + #gpio-cells = <2>; 149 + 150 + interrupt-controller; 151 + #interrupt-cells = <2>; 152 + 153 + interrupt-parent = <&intc>; 154 + interrupts = <14>; 155 + }; 156 + }; 157 + 158 + i2c0: i2c-controller@10050000 { 159 + compatible = "ingenic,x1000-i2c"; 160 + reg = <0x10050000 0x1000>; 161 + 162 + #address-cells = <1>; 163 + #size-cells = <0>; 164 + 165 + interrupt-parent = <&intc>; 166 + interrupts = <60>; 167 + 168 + clocks = <&cgu X1000_CLK_I2C0>; 169 + 170 + status = "disabled"; 171 + }; 172 + 173 + i2c1: i2c-controller@10051000 { 174 + compatible = "ingenic,x1000-i2c"; 175 + reg = <0x10051000 0x1000>; 176 + 177 + #address-cells = <1>; 178 + #size-cells = <0>; 179 + 180 + interrupt-parent = <&intc>; 181 + interrupts = <59>; 182 + 183 + clocks = <&cgu X1000_CLK_I2C1>; 184 + 185 + status = "disabled"; 186 + }; 187 + 188 + i2c2: i2c-controller@10052000 { 189 + compatible = "ingenic,x1000-i2c"; 190 + reg = <0x10052000 0x1000>; 191 + 192 + #address-cells = <1>; 193 + #size-cells = <0>; 194 + 195 + interrupt-parent = <&intc>; 196 + interrupts = <58>; 197 + 198 + clocks = <&cgu X1000_CLK_I2C2>; 199 + 200 + status = "disabled"; 201 + }; 202 + 203 + uart0: serial@10030000 { 204 + compatible = "ingenic,x1000-uart"; 205 + reg = <0x10030000 0x100>; 206 + 207 + interrupt-parent = <&intc>; 208 + interrupts = <51>; 209 + 210 + clocks = <&exclk>, <&cgu X1000_CLK_UART0>; 211 + clock-names = "baud", "module"; 212 + 213 + status = "disabled"; 214 + }; 215 + 216 + uart1: serial@10031000 { 217 + compatible = "ingenic,x1000-uart"; 218 + reg = <0x10031000 0x100>; 219 + 220 + interrupt-parent = <&intc>; 221 + interrupts = <50>; 222 + 223 + clocks = <&exclk>, <&cgu X1000_CLK_UART1>; 224 + clock-names = "baud", "module"; 225 + 226 + status = "disabled"; 227 + }; 228 + 229 + uart2: serial@10032000 { 230 + compatible = "ingenic,x1000-uart"; 231 + reg = <0x10032000 0x100>; 232 + 233 + interrupt-parent = <&intc>; 234 + interrupts = <49>; 235 + 236 + clocks = <&exclk>, <&cgu X1000_CLK_UART2>; 237 + clock-names = "baud", "module"; 238 + 239 + status = "disabled"; 240 + }; 241 + 242 + pdma: dma-controller@13420000 { 243 + compatible = "ingenic,x1000-dma"; 244 + reg = <0x13420000 0x400 245 + 0x13421000 0x40>; 246 + #dma-cells = <2>; 247 + 248 + interrupt-parent = <&intc>; 249 + interrupts = <10>; 250 + 251 + clocks = <&cgu X1000_CLK_PDMA>; 252 + }; 253 + 254 + mac: ethernet@134b0000 { 255 + compatible = "ingenic,x1000-mac", "snps,dwmac"; 256 + reg = <0x134b0000 0x2000>; 257 + 258 + interrupt-parent = <&intc>; 259 + interrupts = <55>; 260 + interrupt-names = "macirq"; 261 + 262 + clocks = <&cgu X1000_CLK_MAC>; 263 + clock-names = "stmmaceth"; 264 + 265 + status = "disabled"; 266 + 267 + mdio: mdio { 268 + compatible = "snps,dwmac-mdio"; 269 + #address-cells = <1>; 270 + #size-cells = <0>; 271 + 272 + status = "disabled"; 273 + }; 274 + }; 275 + 276 + msc0: mmc@13450000 { 277 + compatible = "ingenic,x1000-mmc"; 278 + reg = <0x13450000 0x1000>; 279 + 280 + interrupt-parent = <&intc>; 281 + interrupts = <37>; 282 + 283 + clocks = <&cgu X1000_CLK_MSC0>; 284 + clock-names = "mmc"; 285 + 286 + cap-sd-highspeed; 287 + cap-mmc-highspeed; 288 + cap-sdio-irq; 289 + 290 + dmas = <&pdma X1000_DMA_MSC0_RX 0xffffffff>, 291 + <&pdma X1000_DMA_MSC0_TX 0xffffffff>; 292 + dma-names = "rx", "tx"; 293 + 294 + status = "disabled"; 295 + }; 296 + 297 + msc1: mmc@13460000 { 298 + compatible = "ingenic,x1000-mmc"; 299 + reg = <0x13460000 0x1000>; 300 + 301 + interrupt-parent = <&intc>; 302 + interrupts = <36>; 303 + 304 + clocks = <&cgu X1000_CLK_MSC1>; 305 + clock-names = "mmc"; 306 + 307 + cap-sd-highspeed; 308 + cap-mmc-highspeed; 309 + cap-sdio-irq; 310 + 311 + dmas = <&pdma X1000_DMA_MSC1_RX 0xffffffff>, 312 + <&pdma X1000_DMA_MSC1_TX 0xffffffff>; 313 + dma-names = "rx", "tx"; 314 + 315 + status = "disabled"; 316 + }; 317 + };
+8
arch/mips/boot/dts/ralink/gardena_smart_gateway_mt7688.dts
··· 177 177 pinctrl-names = "default"; 178 178 pinctrl-0 = <&pinmux_i2s_gpio>; /* GPIO0..3 */ 179 179 180 + fifo-size = <8>; 181 + tx-threshold = <8>; 182 + 180 183 rts-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; 181 184 cts-gpios = <&gpio 2 GPIO_ACTIVE_LOW>; 182 185 }; ··· 197 194 198 195 &watchdog { 199 196 status = "okay"; 197 + }; 198 + 199 + &wmac { 200 + status = "okay"; 201 + mediatek,mtd-eeprom = <&factory 0x0000>; 200 202 };
+10
arch/mips/boot/dts/ralink/mt7628a.dtsi
··· 285 285 interrupt-parent = <&intc>; 286 286 interrupts = <18>; 287 287 }; 288 + 289 + wmac: wmac@10300000 { 290 + compatible = "mediatek,mt7628-wmac"; 291 + reg = <0x10300000 0x100000>; 292 + 293 + interrupt-parent = <&cpuintc>; 294 + interrupts = <6>; 295 + 296 + status = "disabled"; 297 + }; 288 298 };
+1 -1
arch/mips/cavium-octeon/octeon-irq.c
··· 2193 2193 struct octeon_irq_cib_chip_data *cd; 2194 2194 2195 2195 if (hw >= host_data->max_bits) { 2196 - pr_err("ERROR: %s mapping %u is to big!\n", 2196 + pr_err("ERROR: %s mapping %u is too big!\n", 2197 2197 irq_domain_get_of_node(d)->name, (unsigned)hw); 2198 2198 return -EINVAL; 2199 2199 }
+117
arch/mips/configs/cu1000-neo_defconfig
··· 1 + CONFIG_LOCALVERSION_AUTO=y 2 + CONFIG_KERNEL_GZIP=y 3 + CONFIG_SYSVIPC=y 4 + CONFIG_NO_HZ_IDLE=y 5 + CONFIG_HIGH_RES_TIMERS=y 6 + CONFIG_PREEMPT=y 7 + CONFIG_IKCONFIG=y 8 + CONFIG_IKCONFIG_PROC=y 9 + CONFIG_LOG_BUF_SHIFT=14 10 + CONFIG_CGROUPS=y 11 + CONFIG_MEMCG=y 12 + CONFIG_MEMCG_KMEM=y 13 + CONFIG_CGROUP_SCHED=y 14 + CONFIG_CGROUP_FREEZER=y 15 + CONFIG_CGROUP_DEVICE=y 16 + CONFIG_CGROUP_CPUACCT=y 17 + CONFIG_NAMESPACES=y 18 + CONFIG_USER_NS=y 19 + CONFIG_CC_OPTIMIZE_FOR_SIZE=y 20 + CONFIG_SYSCTL_SYSCALL=y 21 + CONFIG_KALLSYMS_ALL=y 22 + CONFIG_EMBEDDED=y 23 + # CONFIG_VM_EVENT_COUNTERS is not set 24 + # CONFIG_COMPAT_BRK is not set 25 + CONFIG_SLAB=y 26 + CONFIG_MACH_INGENIC=y 27 + CONFIG_X1000_CU1000_NEO=y 28 + CONFIG_HIGHMEM=y 29 + CONFIG_HZ_100=y 30 + # CONFIG_SECCOMP is not set 31 + # CONFIG_SUSPEND is not set 32 + # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 33 + # CONFIG_COMPACTION is not set 34 + CONFIG_CMA=y 35 + CONFIG_CMA_AREAS=7 36 + CONFIG_NET=y 37 + CONFIG_PACKET=y 38 + CONFIG_UNIX=y 39 + CONFIG_INET=y 40 + CONFIG_CFG80211=y 41 + CONFIG_UEVENT_HELPER=y 42 + CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 43 + CONFIG_DEVTMPFS=y 44 + # CONFIG_FW_LOADER is not set 45 + # CONFIG_ALLOW_DEV_COREDUMP is not set 46 + CONFIG_NETDEVICES=y 47 + CONFIG_STMMAC_ETH=y 48 + CONFIG_SMSC_PHY=y 49 + CONFIG_BRCMFMAC=y 50 + # CONFIG_INPUT_MOUSEDEV is not set 51 + # CONFIG_INPUT_KEYBOARD is not set 52 + # CONFIG_INPUT_MOUSE is not set 53 + # CONFIG_SERIO is not set 54 + CONFIG_VT_HW_CONSOLE_BINDING=y 55 + CONFIG_LEGACY_PTY_COUNT=2 56 + CONFIG_SERIAL_EARLYCON=y 57 + CONFIG_SERIAL_8250=y 58 + CONFIG_SERIAL_8250_CONSOLE=y 59 + CONFIG_SERIAL_8250_NR_UARTS=3 60 + CONFIG_SERIAL_8250_RUNTIME_UARTS=3 61 + CONFIG_SERIAL_8250_INGENIC=y 62 + CONFIG_SERIAL_OF_PLATFORM=y 63 + # CONFIG_HW_RANDOM is not set 64 + CONFIG_I2C=y 65 + CONFIG_I2C_JZ4780=y 66 + CONFIG_GPIO_SYSFS=y 67 + CONFIG_SENSORS_ADS7828=y 68 + CONFIG_WATCHDOG=y 69 + CONFIG_JZ4740_WDT=y 70 + # CONFIG_LCD_CLASS_DEVICE is not set 71 + # CONFIG_BACKLIGHT_CLASS_DEVICE is not set 72 + # CONFIG_VGA_CONSOLE is not set 73 + # CONFIG_HID is not set 74 + # CONFIG_USB_SUPPORT is not set 75 + CONFIG_MMC=y 76 + CONFIG_MMC_JZ4740=y 77 + CONFIG_RTC_CLASS=y 78 + CONFIG_RTC_DRV_JZ4740=y 79 + CONFIG_DMADEVICES=y 80 + CONFIG_DMA_JZ4780=y 81 + # CONFIG_IOMMU_SUPPORT is not set 82 + CONFIG_NVMEM=y 83 + CONFIG_NVMEM_SYSFS=y 84 + CONFIG_EXT4_FS=y 85 + # CONFIG_DNOTIFY is not set 86 + CONFIG_AUTOFS_FS=y 87 + CONFIG_PROC_KCORE=y 88 + # CONFIG_PROC_PAGE_MONITOR is not set 89 + CONFIG_TMPFS=y 90 + CONFIG_CONFIGFS_FS=y 91 + CONFIG_NFS_FS=y 92 + CONFIG_NLS=y 93 + CONFIG_NLS_CODEPAGE_936=y 94 + CONFIG_NLS_CODEPAGE_950=y 95 + CONFIG_NLS_ASCII=y 96 + CONFIG_NLS_ISO8859_1=y 97 + CONFIG_NLS_UTF8=y 98 + CONFIG_CRYPTO_ECHAINIV=y 99 + CONFIG_CRYPTO_AES=y 100 + CONFIG_CRYPTO_DEFLATE=y 101 + CONFIG_CRYPTO_LZO=y 102 + CONFIG_PRINTK_TIME=y 103 + CONFIG_CONSOLE_LOGLEVEL_DEFAULT=15 104 + CONFIG_CONSOLE_LOGLEVEL_QUIET=15 105 + CONFIG_MESSAGE_LOGLEVEL_DEFAULT=7 106 + CONFIG_DEBUG_INFO=y 107 + CONFIG_STRIP_ASM_SYMS=y 108 + CONFIG_DEBUG_FS=y 109 + CONFIG_MAGIC_SYSRQ=y 110 + CONFIG_PANIC_ON_OOPS=y 111 + CONFIG_PANIC_TIMEOUT=10 112 + # CONFIG_SCHED_DEBUG is not set 113 + # CONFIG_DEBUG_PREEMPT is not set 114 + CONFIG_STACKTRACE=y 115 + # CONFIG_FTRACE is not set 116 + CONFIG_CMDLINE_BOOL=y 117 + CONFIG_CMDLINE="earlycon clk_ignore_unused"
+1
arch/mips/configs/generic/board-ocelot.config
··· 41 41 CONFIG_SPI_DW_MMIO=y 42 42 CONFIG_SPI_SPIDEV=y 43 43 44 + CONFIG_PINCTRL=y 44 45 CONFIG_PINCTRL_OCELOT=y 45 46 46 47 CONFIG_GPIO_SYSFS=y
+1
arch/mips/include/asm/Kbuild
··· 19 19 generic-y += qrwlock.h 20 20 generic-y += qspinlock.h 21 21 generic-y += sections.h 22 + generic-y += serial.h 22 23 generic-y += trace_clock.h 23 24 generic-y += unaligned.h 24 25 generic-y += user.h
+1
arch/mips/include/asm/bootinfo.h
··· 81 81 #define MACH_INGENIC_JZ4770 2 /* JZ4770 SOC */ 82 82 #define MACH_INGENIC_JZ4780 3 /* JZ4780 SOC */ 83 83 #define MACH_INGENIC_X1000 4 /* X1000 SOC */ 84 + #define MACH_INGENIC_X1830 5 /* X1830 SOC */ 84 85 85 86 extern char *system_type; 86 87 const char *get_system_type(void);
+4
arch/mips/include/asm/cpu-features.h
··· 555 555 # define cpu_has_perf __opt(MIPS_CPU_PERF) 556 556 #endif 557 557 558 + #ifndef cpu_has_mac2008_only 559 + # define cpu_has_mac2008_only __opt(MIPS_CPU_MAC_2008_ONLY) 560 + #endif 561 + 558 562 #ifdef CONFIG_SMP 559 563 /* 560 564 * Some systems share FTLB RAMs between threads within a core (siblings in
+4 -2
arch/mips/include/asm/cpu.h
··· 46 46 #define PRID_COMP_NETLOGIC 0x0c0000 47 47 #define PRID_COMP_CAVIUM 0x0d0000 48 48 #define PRID_COMP_LOONGSON 0x140000 49 - #define PRID_COMP_INGENIC_D0 0xd00000 /* JZ4740, JZ4750 */ 49 + #define PRID_COMP_INGENIC_D0 0xd00000 /* JZ4740, JZ4750, X1830 */ 50 50 #define PRID_COMP_INGENIC_D1 0xd10000 /* JZ4770, JZ4775, X1000 */ 51 51 #define PRID_COMP_INGENIC_E1 0xe10000 /* JZ4780 */ 52 52 ··· 185 185 * These are the PRID's for when 23:16 == PRID_COMP_INGENIC_* 186 186 */ 187 187 188 - #define PRID_IMP_XBURST 0x0200 188 + #define PRID_IMP_XBURST_REV1 0x0200 /* XBurst with MXU SIMD ISA */ 189 + #define PRID_IMP_XBURST_REV2 0x0100 /* XBurst with MXU2 SIMD ISA */ 189 190 190 191 /* 191 192 * These are the PRID's for when 23:16 == PRID_COMP_NETLOGIC ··· 416 415 #define MIPS_CPU_MT_PER_TC_PERF_COUNTERS \ 417 416 BIT_ULL(56) /* CPU has perf counters implemented per TC (MIPSMT ASE) */ 418 417 #define MIPS_CPU_MMID BIT_ULL(57) /* CPU supports MemoryMapIDs */ 418 + #define MIPS_CPU_MAC_2008_ONLY BIT_ULL(58) /* CPU Only support MAC2008 Fused multiply-add instruction */ 419 419 420 420 /* 421 421 * CPU ASE encodings
-2
arch/mips/include/asm/gio_device.h
··· 32 32 }; 33 33 #define to_gio_driver(drv) container_of(drv, struct gio_driver, driver) 34 34 35 - extern const struct gio_device_id *gio_match_device(const struct gio_device_id *, 36 - const struct gio_device *); 37 35 extern struct gio_device *gio_dev_get(struct gio_device *); 38 36 extern void gio_dev_put(struct gio_device *); 39 37
+2 -2
arch/mips/include/asm/hazards.h
··· 23 23 * TLB hazards 24 24 */ 25 25 #if (defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6)) && \ 26 - !defined(CONFIG_CPU_CAVIUM_OCTEON) && !defined(CONFIG_LOONGSON3_ENHANCEMENT) 26 + !defined(CONFIG_CPU_CAVIUM_OCTEON) && !defined(CONFIG_CPU_LOONGSON64) 27 27 28 28 /* 29 29 * MIPSR2 defines ehb for hazard avoidance ··· 158 158 } while (0) 159 159 160 160 #elif defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_CPU_CAVIUM_OCTEON) || \ 161 - defined(CONFIG_CPU_LOONGSON2EF) || defined(CONFIG_LOONGSON3_ENHANCEMENT) || \ 161 + defined(CONFIG_CPU_LOONGSON2EF) || defined(CONFIG_CPU_LOONGSON64) || \ 162 162 defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_R5500) || defined(CONFIG_CPU_XLR) 163 163 164 164 /*
+3 -3
arch/mips/include/asm/irqflags.h
··· 18 18 #include <asm/compiler.h> 19 19 #include <asm/hazards.h> 20 20 21 - #if defined(CONFIG_CPU_MIPSR2) || defined (CONFIG_CPU_MIPSR6) 21 + #if defined(CONFIG_CPU_HAS_DIEI) 22 22 23 23 static inline void arch_local_irq_disable(void) 24 24 { ··· 94 94 void arch_local_irq_disable(void); 95 95 unsigned long arch_local_irq_save(void); 96 96 void arch_local_irq_restore(unsigned long flags); 97 - #endif /* CONFIG_CPU_MIPSR2 || CONFIG_CPU_MIPSR6 */ 97 + #endif /* CONFIG_CPU_HAS_DIEI */ 98 98 99 99 static inline void arch_local_irq_enable(void) 100 100 { ··· 102 102 " .set push \n" 103 103 " .set reorder \n" 104 104 " .set noat \n" 105 - #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6) 105 + #if defined(CONFIG_CPU_HAS_DIEI) 106 106 " ei \n" 107 107 #else 108 108 " mfc0 $1,$12 \n"
+4
arch/mips/include/asm/local.h
··· 37 37 __asm__ __volatile__( 38 38 " .set push \n" 39 39 " .set arch=r4000 \n" 40 + __SYNC(full, loongson3_war) " \n" 40 41 "1:" __LL "%1, %2 # local_add_return \n" 41 42 " addu %0, %1, %3 \n" 42 43 __SC "%0, %2 \n" ··· 53 52 __asm__ __volatile__( 54 53 " .set push \n" 55 54 " .set "MIPS_ISA_ARCH_LEVEL" \n" 55 + __SYNC(full, loongson3_war) " \n" 56 56 "1:" __LL "%1, %2 # local_add_return \n" 57 57 " addu %0, %1, %3 \n" 58 58 __SC "%0, %2 \n" ··· 86 84 __asm__ __volatile__( 87 85 " .set push \n" 88 86 " .set arch=r4000 \n" 87 + __SYNC(full, loongson3_war) " \n" 89 88 "1:" __LL "%1, %2 # local_sub_return \n" 90 89 " subu %0, %1, %3 \n" 91 90 __SC "%0, %2 \n" ··· 102 99 __asm__ __volatile__( 103 100 " .set push \n" 104 101 " .set "MIPS_ISA_ARCH_LEVEL" \n" 102 + __SYNC(full, loongson3_war) " \n" 105 103 "1:" __LL "%1, %2 # local_sub_return \n" 106 104 " subu %0, %1, %3 \n" 107 105 __SC "%0, %2 \n"
+1 -11
arch/mips/include/asm/mach-ip27/kernel-entry-init.h
··· 10 10 #define __ASM_MACH_IP27_KERNEL_ENTRY_H 11 11 12 12 #include <asm/sn/addrs.h> 13 - #include <asm/sn/sn0/hubni.h> 13 + #include <asm/sn/agent.h> 14 14 #include <asm/sn/klkernvars.h> 15 - 16 - /* 17 - * Returns the local nasid into res. 18 - */ 19 - .macro GET_NASID_ASM res 20 - dli \res, LOCAL_HUB_ADDR(NI_STATUS_REV_ID) 21 - ld \res, (\res) 22 - and \res, NSRI_NODEID_MASK 23 - dsrl \res, NSRI_NODEID_SHFT 24 - .endm 25 15 26 16 /* 27 17 * TLB bits
+2 -2
arch/mips/include/asm/mach-ip27/mangle-port.h
··· 8 8 #ifndef __ASM_MACH_IP27_MANGLE_PORT_H 9 9 #define __ASM_MACH_IP27_MANGLE_PORT_H 10 10 11 - #define __swizzle_addr_b(port) (port) 11 + #define __swizzle_addr_b(port) ((port) ^ 3) 12 12 #define __swizzle_addr_w(port) ((port) ^ 2) 13 13 #define __swizzle_addr_l(port) (port) 14 14 #define __swizzle_addr_q(port) (port) ··· 20 20 # define ioswabl(a, x) (x) 21 21 # define __mem_ioswabl(a, x) cpu_to_le32(x) 22 22 # define ioswabq(a, x) (x) 23 - # define __mem_ioswabq(a, x) cpu_to_le32(x) 23 + # define __mem_ioswabq(a, x) cpu_to_le64(x) 24 24 25 25 #endif /* __ASM_MACH_IP27_MANGLE_PORT_H */
+2 -2
arch/mips/include/asm/mach-ip27/mmzone.h
··· 4 4 5 5 #include <asm/sn/addrs.h> 6 6 #include <asm/sn/arch.h> 7 - #include <asm/sn/hub.h> 7 + #include <asm/sn/agent.h> 8 + #include <asm/sn/klkernvars.h> 8 9 9 10 #define pa_to_nid(addr) NASID_GET(addr) 10 11 ··· 13 12 kern_vars_t kern_vars; 14 13 DECLARE_BITMAP(h_bigwin_used, HUB_NUM_BIG_WINDOW); 15 14 cpumask_t h_cpus; 16 - unsigned long slice_map; 17 15 }; 18 16 19 17 struct node_data {
+1 -1
arch/mips/include/asm/mach-ip27/topology.h
··· 2 2 #ifndef _ASM_MACH_TOPOLOGY_H 3 3 #define _ASM_MACH_TOPOLOGY_H 1 4 4 5 - #include <asm/sn/hub.h> 6 5 #include <asm/sn/types.h> 7 6 #include <asm/mmzone.h> 8 7 9 8 struct cpuinfo_ip27 { 10 9 nasid_t p_nasid; /* my node ID in numa-as-id-space */ 10 + unsigned short p_speed; /* cpu speed in MHz */ 11 11 unsigned char p_slice; /* Physical position on node board */ 12 12 }; 13 13
+2
arch/mips/include/asm/mach-loongson64/cpu-feature-overrides.h
··· 46 46 #define cpu_has_wsbh 1 47 47 #define cpu_has_ic_fills_f_dc 1 48 48 #define cpu_hwrena_impl_bits 0xc0000000 49 + #define cpu_has_mac2008_only 1 50 + #define cpu_has_mips_r2_exec_hazard 0 49 51 50 52 #endif /* __ASM_MACH_LOONGSON64_CPU_FEATURE_OVERRIDES_H */
+3
arch/mips/include/asm/mipsregs.h
··· 1101 1101 /* 1102 1102 * Bits 22:20 of the FPU Status Register will be read as 0, 1103 1103 * and should be written as zero. 1104 + * MAC2008 was removed in Release 5 so we still treat it as 1105 + * reserved. 1104 1106 */ 1105 1107 #define FPU_CSR_RSVD (_ULCAST_(7) << 20) 1106 1108 1109 + #define FPU_CSR_MAC2008 (_ULCAST_(1) << 20) 1107 1110 #define FPU_CSR_ABS2008 (_ULCAST_(1) << 19) 1108 1111 #define FPU_CSR_NAN2008 (_ULCAST_(1) << 18) 1109 1112
+2 -1
arch/mips/include/asm/pci/bridge.h
··· 806 806 unsigned long baddr; 807 807 unsigned long intr_addr; 808 808 struct irq_domain *domain; 809 - unsigned int pci_int[8]; 809 + unsigned int pci_int[8][2]; 810 + unsigned int int_mapping[8][2]; 810 811 u32 ioc3_sid[8]; 811 812 nasid_t nasid; 812 813 };
-18
arch/mips/include/asm/serial.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (C) 2017 MIPS Tech, LLC 4 - */ 5 - #ifndef __ASM__SERIAL_H 6 - #define __ASM__SERIAL_H 7 - 8 - #ifdef CONFIG_MIPS_GENERIC 9 - /* 10 - * Generic kernels cannot know a correct value for all platforms at 11 - * compile time. Set it to 0 to prevent 8250_early using it 12 - */ 13 - #define BASE_BAUD 0 14 - #else 15 - #include <asm-generic/serial.h> 16 - #endif 17 - 18 - #endif /* __ASM__SERIAL_H */
-3
arch/mips/include/asm/sn/arch.h
··· 25 25 #define INVALID_MODULE (moduleid_t)-1 26 26 #define INVALID_PARTID (partid_t)-1 27 27 28 - extern nasid_t get_nasid(void); 29 - extern int get_cpu_slice(cpuid_t); 30 - 31 28 #endif /* _ASM_SN_ARCH_H */
-17
arch/mips/include/asm/sn/hub.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __ASM_SN_HUB_H 3 - #define __ASM_SN_HUB_H 4 - 5 - #include <linux/types.h> 6 - #include <linux/cpumask.h> 7 - #include <asm/sn/types.h> 8 - #include <asm/sn/io.h> 9 - #include <asm/sn/klkernvars.h> 10 - #include <asm/xtalk/xtalk.h> 11 - 12 - /* ip27-hubio.c */ 13 - extern unsigned long hub_pio_map(nasid_t nasid, xwidgetnum_t widget, 14 - unsigned long xtalk_addr, size_t size); 15 - extern void hub_pio_init(nasid_t nasid); 16 - 17 - #endif /* __ASM_SN_HUB_H */
-17
arch/mips/include/asm/sn/intr.h
··· 8 8 #ifndef __ASM_SN_INTR_H 9 9 #define __ASM_SN_INTR_H 10 10 11 - /* Number of interrupt levels associated with each interrupt register. */ 12 - #define N_INTPEND_BITS 64 13 - 14 - #define INT_PEND0_BASELVL 0 15 - #define INT_PEND1_BASELVL 64 16 - 17 - #define N_INTPENDJUNK_BITS 8 18 - #define INTPENDJUNK_CLRBIT 0x80 19 - 20 11 /* 21 12 * Macros to manipulate the interrupt register on the calling hub chip. 22 13 */ ··· 75 84 #define CPU_RESCHED_B_IRQ 8 76 85 #define CPU_CALL_A_IRQ 9 77 86 #define CPU_CALL_B_IRQ 10 78 - #define MSC_MESG_INTR 11 79 - #define BASE_PCI_IRQ 12 80 - 81 - /* 82 - * INT_PEND0 again, bits determined by hardware / hardcoded: 83 - */ 84 - #define SDISK_INTR 63 /* SABLE name */ 85 - #define IP_PEND0_6_63 63 /* What is this bit? */ 86 87 87 88 /* 88 89 * INT_PEND1 hard-coded bits:
+23 -19
arch/mips/include/asm/sn/ioc3.h
··· 21 21 22 22 /* SUPERIO uart register map */ 23 23 struct ioc3_uartregs { 24 + u8 iu_lcr; 24 25 union { 25 - u8 iu_rbr; /* read only, DLAB == 0 */ 26 - u8 iu_thr; /* write only, DLAB == 0 */ 27 - u8 iu_dll; /* DLAB == 1 */ 26 + u8 iu_iir; /* read only */ 27 + u8 iu_fcr; /* write only */ 28 28 }; 29 29 union { 30 30 u8 iu_ier; /* DLAB == 0 */ 31 31 u8 iu_dlm; /* DLAB == 1 */ 32 32 }; 33 33 union { 34 - u8 iu_iir; /* read only */ 35 - u8 iu_fcr; /* write only */ 34 + u8 iu_rbr; /* read only, DLAB == 0 */ 35 + u8 iu_thr; /* write only, DLAB == 0 */ 36 + u8 iu_dll; /* DLAB == 1 */ 36 37 }; 37 - u8 iu_lcr; 38 - u8 iu_mcr; 39 - u8 iu_lsr; 40 - u8 iu_msr; 41 38 u8 iu_scr; 39 + u8 iu_msr; 40 + u8 iu_lsr; 41 + u8 iu_mcr; 42 42 }; 43 43 44 44 struct ioc3_sioregs { 45 45 u8 fill[0x141]; /* starts at 0x141 */ 46 46 47 - u8 uartc; 48 47 u8 kbdcg; 48 + u8 uartc; 49 49 50 - u8 fill0[0x150 - 0x142 - 1]; 50 + u8 fill0[0x151 - 0x142 - 1]; 51 51 52 - u8 pp_data; 53 - u8 pp_dsr; 54 52 u8 pp_dcr; 53 + u8 pp_dsr; 54 + u8 pp_data; 55 55 56 - u8 fill1[0x158 - 0x152 - 1]; 56 + u8 fill1[0x159 - 0x153 - 1]; 57 57 58 - u8 pp_fifa; 59 - u8 pp_cfgb; 60 58 u8 pp_ecr; 59 + u8 pp_cfgb; 60 + u8 pp_fifa; 61 61 62 - u8 fill2[0x168 - 0x15a - 1]; 62 + u8 fill2[0x16a - 0x15b - 1]; 63 63 64 - u8 rtcad; 65 64 u8 rtcdat; 65 + u8 rtcad; 66 66 67 - u8 fill3[0x170 - 0x169 - 1]; 67 + u8 fill3[0x170 - 0x16b - 1]; 68 68 69 69 struct ioc3_uartregs uartb; /* 0x20170 */ 70 70 struct ioc3_uartregs uarta; /* 0x20178 */ ··· 598 598 #define IOC3_SUBSYS_IP30_SYSBOARD 0xc304 599 599 #define IOC3_SUBSYS_MENET 0xc305 600 600 #define IOC3_SUBSYS_MENET4 0xc306 601 + #define IOC3_SUBSYS_IO7 0xc307 602 + #define IOC3_SUBSYS_IO8 0xc308 603 + #define IOC3_SUBSYS_IO9 0xc309 604 + #define IOC3_SUBSYS_IP34_SYSBOARD 0xc30A 601 605 602 606 #endif /* MIPS_SN_IOC3_H */
-4
arch/mips/include/asm/sn/klconfig.h
··· 889 889 extern lboard_t *find_lboard(lboard_t *start, unsigned char type); 890 890 extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type); 891 891 extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type); 892 - extern klcpu_t *nasid_slice_to_cpuinfo(nasid_t, int); 893 892 extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class); 894 - 895 - 896 - extern klcpu_t *sn_get_cpuinfo(cpuid_t cpu); 897 893 898 894 #endif /* _ASM_SN_KLCONFIG_H */
+6 -187
arch/mips/include/asm/sn/kldir.h
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Derived from IRIX <sys/SN/kldir.h>, revision 1.21. 7 - * 8 - * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc. 9 - * Copyright (C) 1999, 2000 by Ralf Baechle 10 - */ 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 11 3 #ifndef _ASM_SN_KLDIR_H 12 4 #define _ASM_SN_KLDIR_H 13 5 14 - 15 - /* 16 - * The kldir memory area resides at a fixed place in each node's memory and 17 - * provides pointers to most other IP27 memory areas. This allows us to 18 - * resize and/or relocate memory areas at a later time without breaking all 19 - * firmware and kernels that use them. Indices in the array are 20 - * permanently dedicated to areas listed below. Some memory areas (marked 21 - * below) reside at a permanently fixed location, but are included in the 22 - * directory for completeness. 23 - */ 24 - 25 6 #define KLDIR_MAGIC 0x434d5f53505f5357 26 7 27 - /* 28 - * The upper portion of the memory map applies during boot 29 - * only and is overwritten by IRIX/SYMMON. 30 - * 31 - * MEMORY MAP PER NODE 32 - * 33 - * 0x2000000 (32M) +-----------------------------------------+ 34 - * | IO6 BUFFERS FOR FLASH ENET IOC3 | 35 - * 0x1F80000 (31.5M) +-----------------------------------------+ 36 - * | IO6 TEXT/DATA/BSS/stack | 37 - * 0x1C00000 (30M) +-----------------------------------------+ 38 - * | IO6 PROM DEBUG TEXT/DATA/BSS/stack | 39 - * 0x0800000 (28M) +-----------------------------------------+ 40 - * | IP27 PROM TEXT/DATA/BSS/stack | 41 - * 0x1B00000 (27M) +-----------------------------------------+ 42 - * | IP27 CFG | 43 - * 0x1A00000 (26M) +-----------------------------------------+ 44 - * | Graphics PROM | 45 - * 0x1800000 (24M) +-----------------------------------------+ 46 - * | 3rd Party PROM drivers | 47 - * 0x1600000 (22M) +-----------------------------------------+ 48 - * | | 49 - * | Free | 50 - * | | 51 - * +-----------------------------------------+ 52 - * | UNIX DEBUG Version | 53 - * 0x190000 (2M--) +-----------------------------------------+ 54 - * | SYMMON | 55 - * | (For UNIX Debug only) | 56 - * 0x34000 (208K) +-----------------------------------------+ 57 - * | SYMMON STACK [NUM_CPU_PER_NODE] | 58 - * | (For UNIX Debug only) | 59 - * 0x25000 (148K) +-----------------------------------------+ 60 - * | KLCONFIG - II (temp) | 61 - * | | 62 - * | ---------------------------- | 63 - * | | 64 - * | UNIX NON-DEBUG Version | 65 - * 0x19000 (100K) +-----------------------------------------+ 66 - * 67 - * 68 - * The lower portion of the memory map contains information that is 69 - * permanent and is used by the IP27PROM, IO6PROM and IRIX. 70 - * 71 - * 0x19000 (100K) +-----------------------------------------+ 72 - * | | 73 - * | PI Error Spools (32K) | 74 - * | | 75 - * 0x12000 (72K) +-----------------------------------------+ 76 - * | Unused | 77 - * 0x11c00 (71K) +-----------------------------------------+ 78 - * | CPU 1 NMI Eframe area | 79 - * 0x11a00 (70.5K) +-----------------------------------------+ 80 - * | CPU 0 NMI Eframe area | 81 - * 0x11800 (70K) +-----------------------------------------+ 82 - * | CPU 1 NMI Register save area | 83 - * 0x11600 (69.5K) +-----------------------------------------+ 84 - * | CPU 0 NMI Register save area | 85 - * 0x11400 (69K) +-----------------------------------------+ 86 - * | GDA (1k) | 87 - * 0x11000 (68K) +-----------------------------------------+ 88 - * | Early cache Exception stack | 89 - * | and/or | 90 - * | kernel/io6prom nmi registers | 91 - * 0x10800 (66k) +-----------------------------------------+ 92 - * | cache error eframe | 93 - * 0x10400 (65K) +-----------------------------------------+ 94 - * | Exception Handlers (UALIAS copy) | 95 - * 0x10000 (64K) +-----------------------------------------+ 96 - * | | 97 - * | | 98 - * | KLCONFIG - I (permanent) (48K) | 99 - * | | 100 - * | | 101 - * | | 102 - * 0x4000 (16K) +-----------------------------------------+ 103 - * | NMI Handler (Protected Page) | 104 - * 0x3000 (12K) +-----------------------------------------+ 105 - * | ARCS PVECTORS (master node only) | 106 - * 0x2c00 (11K) +-----------------------------------------+ 107 - * | ARCS TVECTORS (master node only) | 108 - * 0x2800 (10K) +-----------------------------------------+ 109 - * | LAUNCH [NUM_CPU] | 110 - * 0x2400 (9K) +-----------------------------------------+ 111 - * | Low memory directory (KLDIR) | 112 - * 0x2000 (8K) +-----------------------------------------+ 113 - * | ARCS SPB (1K) | 114 - * 0x1000 (4K) +-----------------------------------------+ 115 - * | Early cache Exception stack | 116 - * | and/or | 117 - * | kernel/io6prom nmi registers | 118 - * 0x800 (2k) +-----------------------------------------+ 119 - * | cache error eframe | 120 - * 0x400 (1K) +-----------------------------------------+ 121 - * | Exception Handlers | 122 - * 0x0 (0K) +-----------------------------------------+ 123 - */ 124 - 125 - #ifdef __ASSEMBLY__ 126 8 #define KLDIR_OFF_MAGIC 0x00 127 9 #define KLDIR_OFF_OFFSET 0x08 128 10 #define KLDIR_OFF_POINTER 0x10 129 11 #define KLDIR_OFF_SIZE 0x18 130 12 #define KLDIR_OFF_COUNT 0x20 131 13 #define KLDIR_OFF_STRIDE 0x28 132 - #endif /* __ASSEMBLY__ */ 133 - 134 - /* 135 - * This is defined here because IP27_SYMMON_STK_SIZE must be at least what 136 - * we define here. Since it's set up in the prom. We can't redefine it later 137 - * and expect more space to be allocated. The way to find out the true size 138 - * of the symmon stacks is to divide SYMMON_STK_SIZE by SYMMON_STK_STRIDE 139 - * for a particular node. 140 - */ 141 - #define SYMMON_STACK_SIZE 0x8000 142 - 143 - #if defined(PROM) 144 - 145 - /* 146 - * These defines are prom version dependent. No code other than the IP27 147 - * prom should attempt to use these values. 148 - */ 149 - #define IP27_LAUNCH_OFFSET 0x2400 150 - #define IP27_LAUNCH_SIZE 0x400 151 - #define IP27_LAUNCH_COUNT 2 152 - #define IP27_LAUNCH_STRIDE 0x200 153 - 154 - #define IP27_KLCONFIG_OFFSET 0x4000 155 - #define IP27_KLCONFIG_SIZE 0xc000 156 - #define IP27_KLCONFIG_COUNT 1 157 - #define IP27_KLCONFIG_STRIDE 0 158 - 159 - #define IP27_NMI_OFFSET 0x3000 160 - #define IP27_NMI_SIZE 0x40 161 - #define IP27_NMI_COUNT 2 162 - #define IP27_NMI_STRIDE 0x40 163 - 164 - #define IP27_PI_ERROR_OFFSET 0x12000 165 - #define IP27_PI_ERROR_SIZE 0x4000 166 - #define IP27_PI_ERROR_COUNT 1 167 - #define IP27_PI_ERROR_STRIDE 0 168 - 169 - #define IP27_SYMMON_STK_OFFSET 0x25000 170 - #define IP27_SYMMON_STK_SIZE 0xe000 171 - #define IP27_SYMMON_STK_COUNT 2 172 - /* IP27_SYMMON_STK_STRIDE must be >= SYMMON_STACK_SIZE */ 173 - #define IP27_SYMMON_STK_STRIDE 0x7000 174 - 175 - #define IP27_FREEMEM_OFFSET 0x19000 176 - #define IP27_FREEMEM_SIZE -1 177 - #define IP27_FREEMEM_COUNT 1 178 - #define IP27_FREEMEM_STRIDE 0 179 - 180 - #endif /* PROM */ 181 - /* 182 - * There will be only one of these in a partition so the IO6 must set it up. 183 - */ 184 - #define IO6_GDA_OFFSET 0x11000 185 - #define IO6_GDA_SIZE 0x400 186 - #define IO6_GDA_COUNT 1 187 - #define IO6_GDA_STRIDE 0 188 - 189 - /* 190 - * save area of kernel nmi regs in the prom format 191 - */ 192 - #define IP27_NMI_KREGS_OFFSET 0x11400 193 - #define IP27_NMI_KREGS_CPU_SIZE 0x200 194 - /* 195 - * save area of kernel nmi regs in eframe format 196 - */ 197 - #define IP27_NMI_EFRAME_OFFSET 0x11800 198 - #define IP27_NMI_EFRAME_SIZE 0x200 199 14 200 15 #define KLDIR_ENT_SIZE 0x40 201 16 #define KLDIR_MAX_ENTRIES (0x400 / 0x40) ··· 28 213 entry to store partition info. Refer to klpart.h for this. */ 29 214 } kldir_ent_t; 30 215 #endif /* !__ASSEMBLY__ */ 216 + 217 + #ifdef CONFIG_SGI_IP27 218 + #include <asm/sn/sn0/kldir.h> 219 + #endif 31 220 32 221 #endif /* _ASM_SN_KLDIR_H */
+22
arch/mips/include/asm/sn/sn0/hub.h
··· 37 37 #define UATTR_MSPEC 2 38 38 #define UATTR_UNCAC 3 39 39 40 + #ifdef __ASSEMBLY__ 41 + /* 42 + * Returns the local nasid into res. 43 + */ 44 + .macro GET_NASID_ASM res 45 + dli \res, LOCAL_HUB_ADDR(NI_STATUS_REV_ID) 46 + ld \res, (\res) 47 + and \res, NSRI_NODEID_MASK 48 + dsrl \res, NSRI_NODEID_SHFT 49 + .endm 50 + #else 51 + 52 + /* 53 + * get_nasid() returns the physical node id number of the caller. 54 + */ 55 + static inline nasid_t get_nasid(void) 56 + { 57 + return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK) 58 + >> NSRI_NODEID_SHFT); 59 + } 60 + #endif 61 + 40 62 #endif /* _ASM_SN_SN0_HUB_H */
+8
arch/mips/include/asm/sn/sn0/hubni.h
··· 250 250 #define NI_LLP_CB_MAX 0xff 251 251 #define NI_LLP_SN_MAX 0xff 252 252 253 + static inline int get_region_shift(void) 254 + { 255 + if (LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK) 256 + return NASID_TO_FINEREG_SHFT; 257 + 258 + return NASID_TO_COARSEREG_SHFT; 259 + } 260 + 253 261 #endif /* !__ASSEMBLY__ */ 254 262 255 263 #endif /* _ASM_SGI_SN0_HUBNI_H */
-85
arch/mips/include/asm/sn/sn0/ip27.h
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Derived from IRIX <sys/SN/SN0/IP27.h>. 7 - * 8 - * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc. 9 - * Copyright (C) 1999, 2006 by Ralf Baechle 10 - */ 11 - #ifndef _ASM_SN_SN0_IP27_H 12 - #define _ASM_SN_SN0_IP27_H 13 - 14 - #include <asm/mipsregs.h> 15 - 16 - /* 17 - * Simple definitions for the masks which remove SW bits from pte. 18 - */ 19 - 20 - #define TLBLO_HWBITSHIFT 0 /* Shift value, for masking */ 21 - 22 - #ifndef __ASSEMBLY__ 23 - 24 - #define CAUSE_BERRINTR IE_IRQ5 25 - 26 - #define ECCF_CACHE_ERR 0 27 - #define ECCF_TAGLO 1 28 - #define ECCF_ECC 2 29 - #define ECCF_ERROREPC 3 30 - #define ECCF_PADDR 4 31 - #define ECCF_SIZE (5 * sizeof(long)) 32 - 33 - #endif /* !__ASSEMBLY__ */ 34 - 35 - #ifdef __ASSEMBLY__ 36 - 37 - /* 38 - * KL_GET_CPUNUM (similar to EV_GET_SPNUM for EVEREST platform) reads 39 - * the processor number of the calling processor. The proc parameters 40 - * must be a register. 41 - */ 42 - #define KL_GET_CPUNUM(proc) \ 43 - dli proc, LOCAL_HUB(0); \ 44 - ld proc, PI_CPU_NUM(proc) 45 - 46 - #endif /* __ASSEMBLY__ */ 47 - 48 - /* 49 - * R10000 status register interrupt bit mask usage for IP27. 50 - */ 51 - #define SRB_SWTIMO IE_SW0 /* 0x0100 */ 52 - #define SRB_NET IE_SW1 /* 0x0200 */ 53 - #define SRB_DEV0 IE_IRQ0 /* 0x0400 */ 54 - #define SRB_DEV1 IE_IRQ1 /* 0x0800 */ 55 - #define SRB_TIMOCLK IE_IRQ2 /* 0x1000 */ 56 - #define SRB_PROFCLK IE_IRQ3 /* 0x2000 */ 57 - #define SRB_ERR IE_IRQ4 /* 0x4000 */ 58 - #define SRB_SCHEDCLK IE_IRQ5 /* 0x8000 */ 59 - 60 - #define SR_IBIT_HI SRB_DEV0 61 - #define SR_IBIT_PROF SRB_PROFCLK 62 - 63 - #define SRB_SWTIMO_IDX 0 64 - #define SRB_NET_IDX 1 65 - #define SRB_DEV0_IDX 2 66 - #define SRB_DEV1_IDX 3 67 - #define SRB_TIMOCLK_IDX 4 68 - #define SRB_PROFCLK_IDX 5 69 - #define SRB_ERR_IDX 6 70 - #define SRB_SCHEDCLK_IDX 7 71 - 72 - #define NUM_CAUSE_INTRS 8 73 - 74 - #define SCACHE_LINESIZE 128 75 - #define SCACHE_LINEMASK (SCACHE_LINESIZE - 1) 76 - 77 - #include <asm/sn/addrs.h> 78 - 79 - #define LED_CYCLE_MASK 0x0f 80 - #define LED_CYCLE_SHFT 4 81 - 82 - #define SEND_NMI(_nasid, _slice) \ 83 - REMOTE_HUB_S((_nasid), (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1) 84 - 85 - #endif /* _ASM_SN_SN0_IP27_H */
+186
arch/mips/include/asm/sn/sn0/kldir.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Derived from IRIX <sys/SN/kldir.h>, revision 1.21. 4 + * 5 + * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc. 6 + * Copyright (C) 1999, 2000 by Ralf Baechle 7 + */ 8 + #ifndef _ASM_SN_SN0_KLDIR_H 9 + #define _ASM_SN_SN0_KLDIR_H 10 + 11 + 12 + /* 13 + * The kldir memory area resides at a fixed place in each node's memory and 14 + * provides pointers to most other IP27 memory areas. This allows us to 15 + * resize and/or relocate memory areas at a later time without breaking all 16 + * firmware and kernels that use them. Indices in the array are 17 + * permanently dedicated to areas listed below. Some memory areas (marked 18 + * below) reside at a permanently fixed location, but are included in the 19 + * directory for completeness. 20 + */ 21 + 22 + /* 23 + * The upper portion of the memory map applies during boot 24 + * only and is overwritten by IRIX/SYMMON. 25 + * 26 + * MEMORY MAP PER NODE 27 + * 28 + * 0x2000000 (32M) +-----------------------------------------+ 29 + * | IO6 BUFFERS FOR FLASH ENET IOC3 | 30 + * 0x1F80000 (31.5M) +-----------------------------------------+ 31 + * | IO6 TEXT/DATA/BSS/stack | 32 + * 0x1C00000 (30M) +-----------------------------------------+ 33 + * | IO6 PROM DEBUG TEXT/DATA/BSS/stack | 34 + * 0x0800000 (28M) +-----------------------------------------+ 35 + * | IP27 PROM TEXT/DATA/BSS/stack | 36 + * 0x1B00000 (27M) +-----------------------------------------+ 37 + * | IP27 CFG | 38 + * 0x1A00000 (26M) +-----------------------------------------+ 39 + * | Graphics PROM | 40 + * 0x1800000 (24M) +-----------------------------------------+ 41 + * | 3rd Party PROM drivers | 42 + * 0x1600000 (22M) +-----------------------------------------+ 43 + * | | 44 + * | Free | 45 + * | | 46 + * +-----------------------------------------+ 47 + * | UNIX DEBUG Version | 48 + * 0x190000 (2M--) +-----------------------------------------+ 49 + * | SYMMON | 50 + * | (For UNIX Debug only) | 51 + * 0x34000 (208K) +-----------------------------------------+ 52 + * | SYMMON STACK [NUM_CPU_PER_NODE] | 53 + * | (For UNIX Debug only) | 54 + * 0x25000 (148K) +-----------------------------------------+ 55 + * | KLCONFIG - II (temp) | 56 + * | | 57 + * | ---------------------------- | 58 + * | | 59 + * | UNIX NON-DEBUG Version | 60 + * 0x19000 (100K) +-----------------------------------------+ 61 + * 62 + * 63 + * The lower portion of the memory map contains information that is 64 + * permanent and is used by the IP27PROM, IO6PROM and IRIX. 65 + * 66 + * 0x19000 (100K) +-----------------------------------------+ 67 + * | | 68 + * | PI Error Spools (32K) | 69 + * | | 70 + * 0x12000 (72K) +-----------------------------------------+ 71 + * | Unused | 72 + * 0x11c00 (71K) +-----------------------------------------+ 73 + * | CPU 1 NMI Eframe area | 74 + * 0x11a00 (70.5K) +-----------------------------------------+ 75 + * | CPU 0 NMI Eframe area | 76 + * 0x11800 (70K) +-----------------------------------------+ 77 + * | CPU 1 NMI Register save area | 78 + * 0x11600 (69.5K) +-----------------------------------------+ 79 + * | CPU 0 NMI Register save area | 80 + * 0x11400 (69K) +-----------------------------------------+ 81 + * | GDA (1k) | 82 + * 0x11000 (68K) +-----------------------------------------+ 83 + * | Early cache Exception stack | 84 + * | and/or | 85 + * | kernel/io6prom nmi registers | 86 + * 0x10800 (66k) +-----------------------------------------+ 87 + * | cache error eframe | 88 + * 0x10400 (65K) +-----------------------------------------+ 89 + * | Exception Handlers (UALIAS copy) | 90 + * 0x10000 (64K) +-----------------------------------------+ 91 + * | | 92 + * | | 93 + * | KLCONFIG - I (permanent) (48K) | 94 + * | | 95 + * | | 96 + * | | 97 + * 0x4000 (16K) +-----------------------------------------+ 98 + * | NMI Handler (Protected Page) | 99 + * 0x3000 (12K) +-----------------------------------------+ 100 + * | ARCS PVECTORS (master node only) | 101 + * 0x2c00 (11K) +-----------------------------------------+ 102 + * | ARCS TVECTORS (master node only) | 103 + * 0x2800 (10K) +-----------------------------------------+ 104 + * | LAUNCH [NUM_CPU] | 105 + * 0x2400 (9K) +-----------------------------------------+ 106 + * | Low memory directory (KLDIR) | 107 + * 0x2000 (8K) +-----------------------------------------+ 108 + * | ARCS SPB (1K) | 109 + * 0x1000 (4K) +-----------------------------------------+ 110 + * | Early cache Exception stack | 111 + * | and/or | 112 + * | kernel/io6prom nmi registers | 113 + * 0x800 (2k) +-----------------------------------------+ 114 + * | cache error eframe | 115 + * 0x400 (1K) +-----------------------------------------+ 116 + * | Exception Handlers | 117 + * 0x0 (0K) +-----------------------------------------+ 118 + */ 119 + 120 + /* 121 + * This is defined here because IP27_SYMMON_STK_SIZE must be at least what 122 + * we define here. Since it's set up in the prom. We can't redefine it later 123 + * and expect more space to be allocated. The way to find out the true size 124 + * of the symmon stacks is to divide SYMMON_STK_SIZE by SYMMON_STK_STRIDE 125 + * for a particular node. 126 + */ 127 + #define SYMMON_STACK_SIZE 0x8000 128 + 129 + #if defined(PROM) 130 + 131 + /* 132 + * These defines are prom version dependent. No code other than the IP27 133 + * prom should attempt to use these values. 134 + */ 135 + #define IP27_LAUNCH_OFFSET 0x2400 136 + #define IP27_LAUNCH_SIZE 0x400 137 + #define IP27_LAUNCH_COUNT 2 138 + #define IP27_LAUNCH_STRIDE 0x200 139 + 140 + #define IP27_KLCONFIG_OFFSET 0x4000 141 + #define IP27_KLCONFIG_SIZE 0xc000 142 + #define IP27_KLCONFIG_COUNT 1 143 + #define IP27_KLCONFIG_STRIDE 0 144 + 145 + #define IP27_NMI_OFFSET 0x3000 146 + #define IP27_NMI_SIZE 0x40 147 + #define IP27_NMI_COUNT 2 148 + #define IP27_NMI_STRIDE 0x40 149 + 150 + #define IP27_PI_ERROR_OFFSET 0x12000 151 + #define IP27_PI_ERROR_SIZE 0x4000 152 + #define IP27_PI_ERROR_COUNT 1 153 + #define IP27_PI_ERROR_STRIDE 0 154 + 155 + #define IP27_SYMMON_STK_OFFSET 0x25000 156 + #define IP27_SYMMON_STK_SIZE 0xe000 157 + #define IP27_SYMMON_STK_COUNT 2 158 + /* IP27_SYMMON_STK_STRIDE must be >= SYMMON_STACK_SIZE */ 159 + #define IP27_SYMMON_STK_STRIDE 0x7000 160 + 161 + #define IP27_FREEMEM_OFFSET 0x19000 162 + #define IP27_FREEMEM_SIZE -1 163 + #define IP27_FREEMEM_COUNT 1 164 + #define IP27_FREEMEM_STRIDE 0 165 + 166 + #endif /* PROM */ 167 + /* 168 + * There will be only one of these in a partition so the IO6 must set it up. 169 + */ 170 + #define IO6_GDA_OFFSET 0x11000 171 + #define IO6_GDA_SIZE 0x400 172 + #define IO6_GDA_COUNT 1 173 + #define IO6_GDA_STRIDE 0 174 + 175 + /* 176 + * save area of kernel nmi regs in the prom format 177 + */ 178 + #define IP27_NMI_KREGS_OFFSET 0x11400 179 + #define IP27_NMI_KREGS_CPU_SIZE 0x200 180 + /* 181 + * save area of kernel nmi regs in eframe format 182 + */ 183 + #define IP27_NMI_EFRAME_OFFSET 0x11800 184 + #define IP27_NMI_EFRAME_SIZE 0x200 185 + 186 + #endif /* _ASM_SN_SN0_KLDIR_H */
-19
arch/mips/include/asm/sn/sn_private.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __ASM_SN_SN_PRIVATE_H 3 - #define __ASM_SN_SN_PRIVATE_H 4 - 5 - #include <asm/sn/types.h> 6 - 7 - extern nasid_t master_nasid; 8 - 9 - extern void cpu_node_probe(void); 10 - extern void hub_rtc_init(nasid_t nasid); 11 - extern void cpu_time_init(void); 12 - extern void per_cpu_init(void); 13 - extern void install_cpu_nmi_handler(int slice); 14 - extern void install_ipi(void); 15 - extern void setup_replication_mask(void); 16 - extern void replicate_kernel_text(void); 17 - extern unsigned long node_getfirstfree(nasid_t nasid); 18 - 19 - #endif /* __ASM_SN_SN_PRIVATE_H */
+4
arch/mips/include/asm/sn/types.h
··· 11 11 12 12 #include <linux/types.h> 13 13 14 + #ifndef __ASSEMBLY__ 15 + 14 16 typedef unsigned long cpuid_t; 15 17 typedef signed short nasid_t; /* node id in numa-as-id space */ 16 18 typedef signed char partid_t; /* partition ID type */ 17 19 typedef signed short moduleid_t; /* user-visible module number type */ 18 20 19 21 typedef dev_t vertex_hdl_t; /* hardware graph vertex handle */ 22 + 23 + #endif 20 24 21 25 #endif /* _ASM_SN_TYPES_H */
+10
arch/mips/jz4740/Kconfig
··· 16 16 bool "MIPS Creator CI20" 17 17 select MACH_JZ4780 18 18 19 + config X1000_CU1000_NEO 20 + bool "YSH & ATIL CU1000 Module with Neo backplane" 21 + select MACH_X1000 22 + 19 23 endchoice 20 24 21 25 config MACH_JZ4740 ··· 33 29 select SYS_SUPPORTS_HIGHMEM 34 30 35 31 config MACH_JZ4780 32 + bool 33 + select MIPS_CPU_SCACHE 34 + select SYS_HAS_CPU_MIPS32_R2 35 + select SYS_SUPPORTS_HIGHMEM 36 + 37 + config MACH_X1000 36 38 bool 37 39 select MIPS_CPU_SCACHE 38 40 select SYS_HAS_CPU_MIPS32_R2
+4
arch/mips/jz4740/setup.c
··· 44 44 45 45 static unsigned long __init get_board_mach_type(const void *fdt) 46 46 { 47 + if (!fdt_node_check_compatible(fdt, 0, "ingenic,x1830")) 48 + return MACH_INGENIC_X1830; 47 49 if (!fdt_node_check_compatible(fdt, 0, "ingenic,x1000")) 48 50 return MACH_INGENIC_X1000; 49 51 if (!fdt_node_check_compatible(fdt, 0, "ingenic,jz4780")) ··· 88 86 const char *get_system_type(void) 89 87 { 90 88 switch (mips_machtype) { 89 + case MACH_INGENIC_X1830: 90 + return "X1830"; 91 91 case MACH_INGENIC_X1000: 92 92 return "X1000"; 93 93 case MACH_INGENIC_JZ4780:
+51 -30
arch/mips/kernel/cpu-probe.c
··· 102 102 if (fir & MIPS_FPIR_HAS2008) { 103 103 fcsr = read_32bit_cp1_register(CP1_STATUS); 104 104 105 - fcsr0 = fcsr & ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008); 105 + /* 106 + * MAC2008 toolchain never landed in real world, so we're only 107 + * testing wether it can be disabled and don't try to enabled 108 + * it. 109 + */ 110 + fcsr0 = fcsr & ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008 | FPU_CSR_MAC2008); 106 111 write_32bit_cp1_register(CP1_STATUS, fcsr0); 107 112 fcsr0 = read_32bit_cp1_register(CP1_STATUS); 108 113 ··· 116 111 fcsr1 = read_32bit_cp1_register(CP1_STATUS); 117 112 118 113 write_32bit_cp1_register(CP1_STATUS, fcsr); 114 + 115 + if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2)) { 116 + /* 117 + * The bit for MAC2008 might be reused by R6 in future, 118 + * so we only test for R2-R5. 119 + */ 120 + if (fcsr0 & FPU_CSR_MAC2008) 121 + c->options |= MIPS_CPU_MAC_2008_ONLY; 122 + } 119 123 120 124 if (!(fcsr0 & FPU_CSR_NAN2008)) 121 125 c->options |= MIPS_CPU_NAN_LEGACY; ··· 1974 1960 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter); 1975 1961 1976 1962 switch (c->processor_id & PRID_IMP_MASK) { 1977 - case PRID_IMP_XBURST: 1978 - c->cputype = CPU_XBURST; 1979 - c->writecombine = _CACHE_UNCACHED_ACCELERATED; 1980 - __cpu_name[cpu] = "Ingenic JZRISC"; 1963 + case PRID_IMP_XBURST_REV1: 1964 + 1981 1965 /* 1982 1966 * The XBurst core by default attempts to avoid branch target 1983 1967 * buffer lookups by detecting & special casing loops. This ··· 1983 1971 * Set cp0 config7 bit 4 to disable this feature. 1984 1972 */ 1985 1973 set_c0_config7(MIPS_CONF7_BTB_LOOP_EN); 1974 + 1975 + switch (c->processor_id & PRID_COMP_MASK) { 1976 + 1977 + /* 1978 + * The config0 register in the XBurst CPUs with a processor ID of 1979 + * PRID_COMP_INGENIC_D0 report themselves as MIPS32r2 compatible, 1980 + * but they don't actually support this ISA. 1981 + */ 1982 + case PRID_COMP_INGENIC_D0: 1983 + c->isa_level &= ~MIPS_CPU_ISA_M32R2; 1984 + break; 1985 + 1986 + /* 1987 + * The config0 register in the XBurst CPUs with a processor ID of 1988 + * PRID_COMP_INGENIC_D1 has an abandoned huge page tlb mode, this 1989 + * mode is not compatible with the MIPS standard, it will cause 1990 + * tlbmiss and into an infinite loop (line 21 in the tlb-funcs.S) 1991 + * when starting the init process. After chip reset, the default 1992 + * is HPTLB mode, Write 0xa9000000 to cp0 register 5 sel 4 to 1993 + * switch back to VTLB mode to prevent getting stuck. 1994 + */ 1995 + case PRID_COMP_INGENIC_D1: 1996 + write_c0_page_ctrl(XBURST_PAGECTRL_HPTLB_DIS); 1997 + break; 1998 + 1999 + default: 2000 + break; 2001 + } 2002 + /* fall-through */ 2003 + case PRID_IMP_XBURST_REV2: 2004 + c->cputype = CPU_XBURST; 2005 + c->writecombine = _CACHE_UNCACHED_ACCELERATED; 2006 + __cpu_name[cpu] = "Ingenic XBurst"; 1986 2007 break; 2008 + 1987 2009 default: 1988 2010 panic("Unknown Ingenic Processor ID!"); 1989 - break; 1990 - } 1991 - 1992 - switch (c->processor_id & PRID_COMP_MASK) { 1993 - /* 1994 - * The config0 register in the XBurst CPUs with a processor ID of 1995 - * PRID_COMP_INGENIC_D1 has an abandoned huge page tlb mode, this 1996 - * mode is not compatible with the MIPS standard, it will cause 1997 - * tlbmiss and into an infinite loop (line 21 in the tlb-funcs.S) 1998 - * when starting the init process. After chip reset, the default 1999 - * is HPTLB mode, Write 0xa9000000 to cp0 register 5 sel 4 to 2000 - * switch back to VTLB mode to prevent getting stuck. 2001 - */ 2002 - case PRID_COMP_INGENIC_D1: 2003 - write_c0_page_ctrl(XBURST_PAGECTRL_HPTLB_DIS); 2004 - break; 2005 - /* 2006 - * The config0 register in the XBurst CPUs with a processor ID of 2007 - * PRID_COMP_INGENIC_D0 report themselves as MIPS32r2 compatible, 2008 - * but they don't actually support this ISA. 2009 - */ 2010 - case PRID_COMP_INGENIC_D0: 2011 - c->isa_level &= ~MIPS_CPU_ISA_M32R2; 2012 - break; 2013 - default: 2014 2011 break; 2015 2012 } 2016 2013 }
+2 -4
arch/mips/kernel/setup.c
··· 515 515 ret = request_resource(res, &crashk_res); 516 516 if (!ret) 517 517 pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n", 518 - (unsigned long)((crashk_res.end - 519 - crashk_res.start + 1) >> 20), 518 + (unsigned long)(resource_size(&crashk_res) >> 20), 520 519 (unsigned long)(crashk_res.start >> 20)); 521 520 } 522 521 #else /* !defined(CONFIG_KEXEC) */ ··· 697 698 mips_parse_crashkernel(); 698 699 #ifdef CONFIG_KEXEC 699 700 if (crashk_res.start != crashk_res.end) 700 - memblock_reserve(crashk_res.start, 701 - crashk_res.end - crashk_res.start + 1); 701 + memblock_reserve(crashk_res.start, resource_size(&crashk_res)); 702 702 #endif 703 703 device_tree_init(); 704 704 sparse_init();
+5
arch/mips/kernel/sync-r4k.c
··· 90 90 void synchronise_count_slave(int cpu) 91 91 { 92 92 int i; 93 + unsigned long flags; 94 + 95 + local_irq_save(flags); 93 96 94 97 /* 95 98 * Not every cpu is online at the time this gets called, ··· 116 113 } 117 114 /* Arrange for an interrupt in a short while */ 118 115 write_c0_compare(read_c0_count() + COUNTON); 116 + 117 + local_irq_restore(flags); 119 118 } 120 119 #undef NR_LOOPS
+1 -1
arch/mips/kernel/syscalls/Makefile
··· 18 18 '$(syshdr_pfx_$(basetarget))' \ 19 19 '$(syshdr_offset_$(basetarget))' 20 20 21 - quiet_cmd_sysnr = SYSNR $@ 21 + quiet_cmd_sysnr = SYSNR $@ 22 22 cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \ 23 23 '$(sysnr_abis_$(basetarget))' \ 24 24 '$(sysnr_pfx_$(basetarget))' \
+18 -18
arch/mips/kernel/unaligned.c
··· 131 131 : "r" (addr), "i" (-EFAULT)); \ 132 132 } while(0) 133 133 134 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 134 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 135 135 #define _LoadW(addr, value, res, type) \ 136 136 do { \ 137 137 __asm__ __volatile__ ( \ ··· 152 152 : "r" (addr), "i" (-EFAULT)); \ 153 153 } while(0) 154 154 155 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 155 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 156 156 /* For CPUs without lwl instruction */ 157 157 #define _LoadW(addr, value, res, type) \ 158 158 do { \ ··· 187 187 : "r" (addr), "i" (-EFAULT)); \ 188 188 } while(0) 189 189 190 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 190 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 191 191 192 192 #define _LoadHWU(addr, value, res, type) \ 193 193 do { \ ··· 213 213 : "r" (addr), "i" (-EFAULT)); \ 214 214 } while(0) 215 215 216 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 216 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 217 217 #define _LoadWU(addr, value, res, type) \ 218 218 do { \ 219 219 __asm__ __volatile__ ( \ ··· 256 256 : "r" (addr), "i" (-EFAULT)); \ 257 257 } while(0) 258 258 259 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 259 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 260 260 /* For CPUs without lwl and ldl instructions */ 261 261 #define _LoadWU(addr, value, res, type) \ 262 262 do { \ ··· 340 340 : "r" (addr), "i" (-EFAULT)); \ 341 341 } while(0) 342 342 343 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 343 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 344 344 345 345 346 346 #define _StoreHW(addr, value, res, type) \ ··· 366 366 : "r" (value), "r" (addr), "i" (-EFAULT));\ 367 367 } while(0) 368 368 369 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 369 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 370 370 #define _StoreW(addr, value, res, type) \ 371 371 do { \ 372 372 __asm__ __volatile__ ( \ ··· 407 407 : "r" (value), "r" (addr), "i" (-EFAULT)); \ 408 408 } while(0) 409 409 410 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 410 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 411 411 #define _StoreW(addr, value, res, type) \ 412 412 do { \ 413 413 __asm__ __volatile__ ( \ ··· 483 483 : "memory"); \ 484 484 } while(0) 485 485 486 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 486 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 487 487 488 488 #else /* __BIG_ENDIAN */ 489 489 ··· 509 509 : "r" (addr), "i" (-EFAULT)); \ 510 510 } while(0) 511 511 512 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 512 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 513 513 #define _LoadW(addr, value, res, type) \ 514 514 do { \ 515 515 __asm__ __volatile__ ( \ ··· 530 530 : "r" (addr), "i" (-EFAULT)); \ 531 531 } while(0) 532 532 533 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 533 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 534 534 /* For CPUs without lwl instruction */ 535 535 #define _LoadW(addr, value, res, type) \ 536 536 do { \ ··· 565 565 : "r" (addr), "i" (-EFAULT)); \ 566 566 } while(0) 567 567 568 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 568 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 569 569 570 570 571 571 #define _LoadHWU(addr, value, res, type) \ ··· 592 592 : "r" (addr), "i" (-EFAULT)); \ 593 593 } while(0) 594 594 595 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 595 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 596 596 #define _LoadWU(addr, value, res, type) \ 597 597 do { \ 598 598 __asm__ __volatile__ ( \ ··· 635 635 : "r" (addr), "i" (-EFAULT)); \ 636 636 } while(0) 637 637 638 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 638 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 639 639 /* For CPUs without lwl and ldl instructions */ 640 640 #define _LoadWU(addr, value, res, type) \ 641 641 do { \ ··· 718 718 : "=&r" (value), "=r" (res) \ 719 719 : "r" (addr), "i" (-EFAULT)); \ 720 720 } while(0) 721 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 721 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 722 722 723 723 #define _StoreHW(addr, value, res, type) \ 724 724 do { \ ··· 743 743 : "r" (value), "r" (addr), "i" (-EFAULT));\ 744 744 } while(0) 745 745 746 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 746 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 747 747 #define _StoreW(addr, value, res, type) \ 748 748 do { \ 749 749 __asm__ __volatile__ ( \ ··· 784 784 : "r" (value), "r" (addr), "i" (-EFAULT)); \ 785 785 } while(0) 786 786 787 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 787 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 788 788 /* For CPUs without swl and sdl instructions */ 789 789 #define _StoreW(addr, value, res, type) \ 790 790 do { \ ··· 861 861 : "memory"); \ 862 862 } while(0) 863 863 864 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 864 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 865 865 #endif 866 866 867 867 #define LoadHWU(addr, value, res) _LoadHWU(addr, value, res, kernel)
+7 -7
arch/mips/lib/memcpy.S
··· 301 301 and t0, src, ADDRMASK 302 302 PREFS( 0, 2*32(src) ) 303 303 PREFD( 1, 2*32(dst) ) 304 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 304 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 305 305 bnez t1, .Ldst_unaligned\@ 306 306 nop 307 307 bnez t0, .Lsrc_unaligned_dst_aligned\@ 308 - #else 308 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 309 309 or t0, t0, t1 310 310 bnez t0, .Lcopy_unaligned_bytes\@ 311 - #endif 311 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 312 312 /* 313 313 * use delay slot for fall-through 314 314 * src and dst are aligned; need to compute rem ··· 389 389 bne rem, len, 1b 390 390 .set noreorder 391 391 392 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 392 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 393 393 /* 394 394 * src and dst are aligned, need to copy rem bytes (rem < NBYTES) 395 395 * A loop would do only a byte at a time with possible branch ··· 491 491 bne len, rem, 1b 492 492 .set noreorder 493 493 494 - #endif /* CONFIG_CPU_HAS_LOAD_STORE_LR */ 494 + #endif /* !CONFIG_CPU_NO_LOAD_STORE_LR */ 495 495 .Lcopy_bytes_checklen\@: 496 496 beqz len, .Ldone\@ 497 497 nop ··· 520 520 jr ra 521 521 nop 522 522 523 - #ifndef CONFIG_CPU_HAS_LOAD_STORE_LR 523 + #ifdef CONFIG_CPU_NO_LOAD_STORE_LR 524 524 .Lcopy_unaligned_bytes\@: 525 525 1: 526 526 COPY_BYTE(0) ··· 534 534 ADD src, src, 8 535 535 b 1b 536 536 ADD dst, dst, 8 537 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 537 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 538 538 .if __memcpy == 1 539 539 END(memcpy) 540 540 .set __memcpy, 0
+8 -8
arch/mips/lib/memset.S
··· 115 115 #endif 116 116 .set reorder 117 117 118 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 118 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 119 119 R10KCBARRIER(0(ra)) 120 120 #ifdef __MIPSEB__ 121 121 EX(LONG_S_L, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */ ··· 125 125 PTR_SUBU a0, t0 /* long align ptr */ 126 126 PTR_ADDU a2, t0 /* correct size */ 127 127 128 - #else /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 128 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 129 129 #define STORE_BYTE(N) \ 130 130 EX(sb, a1, N(a0), .Lbyte_fixup\@); \ 131 131 .set noreorder; \ ··· 150 150 ori a0, STORMASK 151 151 xori a0, STORMASK 152 152 PTR_ADDIU a0, STORSIZE 153 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 153 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 154 154 1: ori t1, a2, 0x3f /* # of full blocks */ 155 155 xori t1, 0x3f 156 156 andi t0, a2, 0x40-STORSIZE ··· 185 185 186 186 .set noreorder 187 187 beqz a2, 1f 188 - #ifdef CONFIG_CPU_HAS_LOAD_STORE_LR 188 + #ifndef CONFIG_CPU_NO_LOAD_STORE_LR 189 189 PTR_ADDU a0, a2 /* What's left */ 190 190 .set reorder 191 191 R10KCBARRIER(0(ra)) ··· 194 194 #else 195 195 EX(LONG_S_L, a1, -1(a0), .Llast_fixup\@) 196 196 #endif 197 - #else 197 + #else /* CONFIG_CPU_NO_LOAD_STORE_LR */ 198 198 PTR_SUBU t0, $0, a2 199 199 .set reorder 200 200 move a2, zero /* No remaining longs */ ··· 211 211 EX(sb, a1, 6(a0), .Lbyte_fixup\@) 212 212 #endif 213 213 0: 214 - #endif 214 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 215 215 1: move a2, zero 216 216 jr ra 217 217 ··· 234 234 .hidden __memset 235 235 .endif 236 236 237 - #ifndef CONFIG_CPU_HAS_LOAD_STORE_LR 237 + #ifdef CONFIG_CPU_NO_LOAD_STORE_LR 238 238 .Lbyte_fixup\@: 239 239 /* 240 240 * unset_bytes = (#bytes - (#unaligned bytes)) - (-#unaligned bytes remaining + 1) + 1 ··· 243 243 PTR_SUBU a2, t0 244 244 PTR_ADDIU a2, 1 245 245 jr ra 246 - #endif /* !CONFIG_CPU_HAS_LOAD_STORE_LR */ 246 + #endif /* CONFIG_CPU_NO_LOAD_STORE_LR */ 247 247 248 248 .Lfirst_fixup\@: 249 249 /* unset_bytes already in a2 */
+2 -2
arch/mips/lib/mips-atomic.c
··· 15 15 #include <linux/export.h> 16 16 #include <linux/stringify.h> 17 17 18 - #if !defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_CPU_MIPSR6) 18 + #if !defined(CONFIG_CPU_HAS_DIEI) 19 19 20 20 /* 21 21 * For cli() we have to insert nops to make sure that the new value ··· 110 110 } 111 111 EXPORT_SYMBOL(arch_local_irq_restore); 112 112 113 - #endif /* !CONFIG_CPU_MIPSR2 && !CONFIG_CPU_MIPSR6 */ 113 + #endif /* !CONFIG_CPU_HAS_DIEI */
+1 -1
arch/mips/loongson2ef/common/pm.c
··· 91 91 92 92 static void loongson_suspend_enter(void) 93 93 { 94 - static unsigned int cached_cpu_freq; 94 + unsigned int cached_cpu_freq; 95 95 96 96 /* setup wakeup events via enabling the IRQs */ 97 97 setup_wakeup_events();
+1 -1
arch/mips/loongson64/numa.c
··· 75 75 loongson_sysconf.cores_per_package; 76 76 77 77 if (col == row) 78 - return 0; 78 + return LOCAL_DISTANCE; 79 79 else if (package_row == package_col) 80 80 return 40; 81 81 else
+3
arch/mips/loongson64/platform.c
··· 27 27 continue; 28 28 29 29 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); 30 + if (!pdev) 31 + return -ENOMEM; 32 + 30 33 pdev->name = loongson_sysconf.sensors[i].name; 31 34 pdev->id = loongson_sysconf.sensors[i].id; 32 35 pdev->dev.platform_data = &loongson_sysconf.sensors[i];
+31 -7
arch/mips/math-emu/cp1emu.c
··· 1514 1514 break; 1515 1515 1516 1516 case madd_s_op: 1517 - handler = fpemu_sp_madd; 1517 + if (cpu_has_mac2008_only) 1518 + handler = ieee754sp_madd; 1519 + else 1520 + handler = fpemu_sp_madd; 1518 1521 goto scoptop; 1519 1522 case msub_s_op: 1520 - handler = fpemu_sp_msub; 1523 + if (cpu_has_mac2008_only) 1524 + handler = ieee754sp_msub; 1525 + else 1526 + handler = fpemu_sp_msub; 1521 1527 goto scoptop; 1522 1528 case nmadd_s_op: 1523 - handler = fpemu_sp_nmadd; 1529 + if (cpu_has_mac2008_only) 1530 + handler = ieee754sp_nmadd; 1531 + else 1532 + handler = fpemu_sp_nmadd; 1524 1533 goto scoptop; 1525 1534 case nmsub_s_op: 1526 - handler = fpemu_sp_nmsub; 1535 + if (cpu_has_mac2008_only) 1536 + handler = ieee754sp_nmsub; 1537 + else 1538 + handler = fpemu_sp_nmsub; 1527 1539 goto scoptop; 1528 1540 1529 1541 scoptop: ··· 1622 1610 break; 1623 1611 1624 1612 case madd_d_op: 1625 - handler = fpemu_dp_madd; 1613 + if (cpu_has_mac2008_only) 1614 + handler = ieee754dp_madd; 1615 + else 1616 + handler = fpemu_dp_madd; 1626 1617 goto dcoptop; 1627 1618 case msub_d_op: 1628 - handler = fpemu_dp_msub; 1619 + if (cpu_has_mac2008_only) 1620 + handler = ieee754dp_msub; 1621 + else 1622 + handler = fpemu_dp_msub; 1629 1623 goto dcoptop; 1630 1624 case nmadd_d_op: 1631 - handler = fpemu_dp_nmadd; 1625 + if (cpu_has_mac2008_only) 1626 + handler = ieee754dp_nmadd; 1627 + else 1628 + handler = fpemu_dp_nmadd; 1632 1629 goto dcoptop; 1633 1630 case nmsub_d_op: 1631 + if (cpu_has_mac2008_only) 1632 + handler = ieee754dp_nmsub; 1633 + else 1634 1634 handler = fpemu_dp_nmsub; 1635 1635 goto dcoptop; 1636 1636
+35 -18
arch/mips/math-emu/dp_maddf.c
··· 68 68 69 69 ieee754_clearcx(); 70 70 71 + rs = xs ^ ys; 72 + if (flags & MADDF_NEGATE_PRODUCT) 73 + rs ^= 1; 74 + if (flags & MADDF_NEGATE_ADDITION) 75 + zs ^= 1; 76 + 71 77 /* 72 78 * Handle the cases when at least one of x, y or z is a NaN. 73 79 * Order of precedence is sNaN, qNaN and z, x, y. ··· 110 104 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): 111 105 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): 112 106 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): 113 - if ((zc == IEEE754_CLASS_INF) && 114 - ((!(flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))) || 115 - ((flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))))) { 107 + if ((zc == IEEE754_CLASS_INF) && (zs != rs)) { 116 108 /* 117 109 * Cases of addition of infinities with opposite signs 118 110 * or subtraction of infinities with same signs. ··· 120 116 } 121 117 /* 122 118 * z is here either not an infinity, or an infinity having the 123 - * same sign as product (x*y) (in case of MADDF.D instruction) 124 - * or product -(x*y) (in MSUBF.D case). The result must be an 125 - * infinity, and its sign is determined only by the value of 126 - * (flags & MADDF_NEGATE_PRODUCT) and the signs of x and y. 119 + * same sign as product (x*y). The result must be an infinity, 120 + * and its sign is determined only by the sign of product (x*y). 127 121 */ 128 - if (flags & MADDF_NEGATE_PRODUCT) 129 - return ieee754dp_inf(1 ^ (xs ^ ys)); 130 - else 131 - return ieee754dp_inf(xs ^ ys); 122 + return ieee754dp_inf(rs); 132 123 133 124 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): 134 125 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): ··· 134 135 return ieee754dp_inf(zs); 135 136 if (zc == IEEE754_CLASS_ZERO) { 136 137 /* Handle cases +0 + (-0) and similar ones. */ 137 - if ((!(flags & MADDF_NEGATE_PRODUCT) 138 - && (zs == (xs ^ ys))) || 139 - ((flags & MADDF_NEGATE_PRODUCT) 140 - && (zs != (xs ^ ys)))) 138 + if (zs == rs) 141 139 /* 142 140 * Cases of addition of zeros of equal signs 143 141 * or subtraction of zeroes of opposite signs. ··· 183 187 assert(ym & DP_HIDDEN_BIT); 184 188 185 189 re = xe + ye; 186 - rs = xs ^ ys; 187 - if (flags & MADDF_NEGATE_PRODUCT) 188 - rs ^= 1; 189 190 190 191 /* shunt to top of word */ 191 192 xm <<= 64 - (DP_FBITS + 1); ··· 329 336 } 330 337 331 338 union ieee754dp ieee754dp_msubf(union ieee754dp z, union ieee754dp x, 339 + union ieee754dp y) 340 + { 341 + return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT); 342 + } 343 + 344 + union ieee754dp ieee754dp_madd(union ieee754dp z, union ieee754dp x, 345 + union ieee754dp y) 346 + { 347 + return _dp_maddf(z, x, y, 0); 348 + } 349 + 350 + union ieee754dp ieee754dp_msub(union ieee754dp z, union ieee754dp x, 351 + union ieee754dp y) 352 + { 353 + return _dp_maddf(z, x, y, MADDF_NEGATE_ADDITION); 354 + } 355 + 356 + union ieee754dp ieee754dp_nmadd(union ieee754dp z, union ieee754dp x, 357 + union ieee754dp y) 358 + { 359 + return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT|MADDF_NEGATE_ADDITION); 360 + } 361 + 362 + union ieee754dp ieee754dp_nmsub(union ieee754dp z, union ieee754dp x, 332 363 union ieee754dp y) 333 364 { 334 365 return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
+16
arch/mips/math-emu/ieee754.h
··· 68 68 union ieee754sp y); 69 69 union ieee754sp ieee754sp_msubf(union ieee754sp z, union ieee754sp x, 70 70 union ieee754sp y); 71 + union ieee754sp ieee754sp_madd(union ieee754sp z, union ieee754sp x, 72 + union ieee754sp y); 73 + union ieee754sp ieee754sp_msub(union ieee754sp z, union ieee754sp x, 74 + union ieee754sp y); 75 + union ieee754sp ieee754sp_nmadd(union ieee754sp z, union ieee754sp x, 76 + union ieee754sp y); 77 + union ieee754sp ieee754sp_nmsub(union ieee754sp z, union ieee754sp x, 78 + union ieee754sp y); 71 79 int ieee754sp_2008class(union ieee754sp x); 72 80 union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y); 73 81 union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y); ··· 110 102 union ieee754dp ieee754dp_maddf(union ieee754dp z, union ieee754dp x, 111 103 union ieee754dp y); 112 104 union ieee754dp ieee754dp_msubf(union ieee754dp z, union ieee754dp x, 105 + union ieee754dp y); 106 + union ieee754dp ieee754dp_madd(union ieee754dp z, union ieee754dp x, 107 + union ieee754dp y); 108 + union ieee754dp ieee754dp_msub(union ieee754dp z, union ieee754dp x, 109 + union ieee754dp y); 110 + union ieee754dp ieee754dp_nmadd(union ieee754dp z, union ieee754dp x, 111 + union ieee754dp y); 112 + union ieee754dp ieee754dp_nmsub(union ieee754dp z, union ieee754dp x, 113 113 union ieee754dp y); 114 114 int ieee754dp_2008class(union ieee754dp x); 115 115 union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y);
+1
arch/mips/math-emu/ieee754int.h
··· 16 16 17 17 enum maddf_flags { 18 18 MADDF_NEGATE_PRODUCT = 1 << 0, 19 + MADDF_NEGATE_ADDITION = 1 << 1, 19 20 }; 20 21 21 22 static inline void ieee754_clearcx(void)
+35 -18
arch/mips/math-emu/sp_maddf.c
··· 36 36 37 37 ieee754_clearcx(); 38 38 39 + rs = xs ^ ys; 40 + if (flags & MADDF_NEGATE_PRODUCT) 41 + rs ^= 1; 42 + if (flags & MADDF_NEGATE_ADDITION) 43 + zs ^= 1; 44 + 39 45 /* 40 46 * Handle the cases when at least one of x, y or z is a NaN. 41 47 * Order of precedence is sNaN, qNaN and z, x, y. ··· 79 73 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): 80 74 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): 81 75 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): 82 - if ((zc == IEEE754_CLASS_INF) && 83 - ((!(flags & MADDF_NEGATE_PRODUCT) && (zs != (xs ^ ys))) || 84 - ((flags & MADDF_NEGATE_PRODUCT) && (zs == (xs ^ ys))))) { 76 + if ((zc == IEEE754_CLASS_INF) && (zs != rs)) { 85 77 /* 86 78 * Cases of addition of infinities with opposite signs 87 79 * or subtraction of infinities with same signs. ··· 89 85 } 90 86 /* 91 87 * z is here either not an infinity, or an infinity having the 92 - * same sign as product (x*y) (in case of MADDF.D instruction) 93 - * or product -(x*y) (in MSUBF.D case). The result must be an 94 - * infinity, and its sign is determined only by the value of 95 - * (flags & MADDF_NEGATE_PRODUCT) and the signs of x and y. 88 + * same sign as product (x*y). The result must be an infinity, 89 + * and its sign is determined only by the sign of product (x*y). 96 90 */ 97 - if (flags & MADDF_NEGATE_PRODUCT) 98 - return ieee754sp_inf(1 ^ (xs ^ ys)); 99 - else 100 - return ieee754sp_inf(xs ^ ys); 91 + return ieee754sp_inf(rs); 101 92 102 93 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): 103 94 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): ··· 103 104 return ieee754sp_inf(zs); 104 105 if (zc == IEEE754_CLASS_ZERO) { 105 106 /* Handle cases +0 + (-0) and similar ones. */ 106 - if ((!(flags & MADDF_NEGATE_PRODUCT) 107 - && (zs == (xs ^ ys))) || 108 - ((flags & MADDF_NEGATE_PRODUCT) 109 - && (zs != (xs ^ ys)))) 107 + if (zs == rs) 110 108 /* 111 109 * Cases of addition of zeros of equal signs 112 110 * or subtraction of zeroes of opposite signs. ··· 154 158 assert(ym & SP_HIDDEN_BIT); 155 159 156 160 re = xe + ye; 157 - rs = xs ^ ys; 158 - if (flags & MADDF_NEGATE_PRODUCT) 159 - rs ^= 1; 160 161 161 162 /* Multiple 24 bit xm and ym to give 48 bit results */ 162 163 rm64 = (uint64_t)xm * ym; ··· 249 256 } 250 257 251 258 union ieee754sp ieee754sp_msubf(union ieee754sp z, union ieee754sp x, 259 + union ieee754sp y) 260 + { 261 + return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT); 262 + } 263 + 264 + union ieee754sp ieee754sp_madd(union ieee754sp z, union ieee754sp x, 265 + union ieee754sp y) 266 + { 267 + return _sp_maddf(z, x, y, 0); 268 + } 269 + 270 + union ieee754sp ieee754sp_msub(union ieee754sp z, union ieee754sp x, 271 + union ieee754sp y) 272 + { 273 + return _sp_maddf(z, x, y, MADDF_NEGATE_ADDITION); 274 + } 275 + 276 + union ieee754sp ieee754sp_nmadd(union ieee754sp z, union ieee754sp x, 277 + union ieee754sp y) 278 + { 279 + return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT|MADDF_NEGATE_ADDITION); 280 + } 281 + 282 + union ieee754sp ieee754sp_nmsub(union ieee754sp z, union ieee754sp x, 252 283 union ieee754sp y) 253 284 { 254 285 return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
+45
arch/mips/mm/init.c
··· 508 508 free_initmem_default(POISON_FREE_INITMEM); 509 509 } 510 510 511 + #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA 512 + unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; 513 + EXPORT_SYMBOL(__per_cpu_offset); 514 + 515 + static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) 516 + { 517 + return node_distance(cpu_to_node(from), cpu_to_node(to)); 518 + } 519 + 520 + static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, 521 + size_t align) 522 + { 523 + return memblock_alloc_try_nid(size, align, __pa(MAX_DMA_ADDRESS), 524 + MEMBLOCK_ALLOC_ACCESSIBLE, 525 + cpu_to_node(cpu)); 526 + } 527 + 528 + static void __init pcpu_fc_free(void *ptr, size_t size) 529 + { 530 + memblock_free_early(__pa(ptr), size); 531 + } 532 + 533 + void __init setup_per_cpu_areas(void) 534 + { 535 + unsigned long delta; 536 + unsigned int cpu; 537 + int rc; 538 + 539 + /* 540 + * Always reserve area for module percpu variables. That's 541 + * what the legacy allocator did. 542 + */ 543 + rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE, 544 + PERCPU_DYNAMIC_RESERVE, PAGE_SIZE, 545 + pcpu_cpu_distance, 546 + pcpu_fc_alloc, pcpu_fc_free); 547 + if (rc < 0) 548 + panic("Failed to initialize percpu areas."); 549 + 550 + delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start; 551 + for_each_possible_cpu(cpu) 552 + __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu]; 553 + } 554 + #endif 555 + 511 556 #ifndef CONFIG_MIPS_PGD_C0_CONTEXT 512 557 unsigned long pgd_current[NR_CPUS]; 513 558 #endif
+1
arch/mips/net/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 # MIPS networking code 3 3 4 + obj-$(CONFIG_MIPS_CBPF_JIT) += bpf_jit.o bpf_jit_asm.o 4 5 obj-$(CONFIG_MIPS_EBPF_JIT) += ebpf_jit.o
+1270
arch/mips/net/bpf_jit.c
··· 1 + /* 2 + * Just-In-Time compiler for BPF filters on MIPS 3 + * 4 + * Copyright (c) 2014 Imagination Technologies Ltd. 5 + * Author: Markos Chandras <markos.chandras@imgtec.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; version 2 of the License. 10 + */ 11 + 12 + #include <linux/bitops.h> 13 + #include <linux/compiler.h> 14 + #include <linux/errno.h> 15 + #include <linux/filter.h> 16 + #include <linux/if_vlan.h> 17 + #include <linux/moduleloader.h> 18 + #include <linux/netdevice.h> 19 + #include <linux/string.h> 20 + #include <linux/slab.h> 21 + #include <linux/types.h> 22 + #include <asm/asm.h> 23 + #include <asm/bitops.h> 24 + #include <asm/cacheflush.h> 25 + #include <asm/cpu-features.h> 26 + #include <asm/uasm.h> 27 + 28 + #include "bpf_jit.h" 29 + 30 + /* ABI 31 + * r_skb_hl SKB header length 32 + * r_data SKB data pointer 33 + * r_off Offset 34 + * r_A BPF register A 35 + * r_X BPF register X 36 + * r_skb *skb 37 + * r_M *scratch memory 38 + * r_skb_len SKB length 39 + * 40 + * On entry (*bpf_func)(*skb, *filter) 41 + * a0 = MIPS_R_A0 = skb; 42 + * a1 = MIPS_R_A1 = filter; 43 + * 44 + * Stack 45 + * ... 46 + * M[15] 47 + * M[14] 48 + * M[13] 49 + * ... 50 + * M[0] <-- r_M 51 + * saved reg k-1 52 + * saved reg k-2 53 + * ... 54 + * saved reg 0 <-- r_sp 55 + * <no argument area> 56 + * 57 + * Packet layout 58 + * 59 + * <--------------------- len ------------------------> 60 + * <--skb-len(r_skb_hl)-->< ----- skb->data_len ------> 61 + * ---------------------------------------------------- 62 + * | skb->data | 63 + * ---------------------------------------------------- 64 + */ 65 + 66 + #define ptr typeof(unsigned long) 67 + 68 + #define SCRATCH_OFF(k) (4 * (k)) 69 + 70 + /* JIT flags */ 71 + #define SEEN_CALL (1 << BPF_MEMWORDS) 72 + #define SEEN_SREG_SFT (BPF_MEMWORDS + 1) 73 + #define SEEN_SREG_BASE (1 << SEEN_SREG_SFT) 74 + #define SEEN_SREG(x) (SEEN_SREG_BASE << (x)) 75 + #define SEEN_OFF SEEN_SREG(2) 76 + #define SEEN_A SEEN_SREG(3) 77 + #define SEEN_X SEEN_SREG(4) 78 + #define SEEN_SKB SEEN_SREG(5) 79 + #define SEEN_MEM SEEN_SREG(6) 80 + /* SEEN_SK_DATA also implies skb_hl an skb_len */ 81 + #define SEEN_SKB_DATA (SEEN_SREG(7) | SEEN_SREG(1) | SEEN_SREG(0)) 82 + 83 + /* Arguments used by JIT */ 84 + #define ARGS_USED_BY_JIT 2 /* only applicable to 64-bit */ 85 + 86 + #define SBIT(x) (1 << (x)) /* Signed version of BIT() */ 87 + 88 + /** 89 + * struct jit_ctx - JIT context 90 + * @skf: The sk_filter 91 + * @prologue_bytes: Number of bytes for prologue 92 + * @idx: Instruction index 93 + * @flags: JIT flags 94 + * @offsets: Instruction offsets 95 + * @target: Memory location for the compiled filter 96 + */ 97 + struct jit_ctx { 98 + const struct bpf_prog *skf; 99 + unsigned int prologue_bytes; 100 + u32 idx; 101 + u32 flags; 102 + u32 *offsets; 103 + u32 *target; 104 + }; 105 + 106 + 107 + static inline int optimize_div(u32 *k) 108 + { 109 + /* power of 2 divides can be implemented with right shift */ 110 + if (!(*k & (*k-1))) { 111 + *k = ilog2(*k); 112 + return 1; 113 + } 114 + 115 + return 0; 116 + } 117 + 118 + static inline void emit_jit_reg_move(ptr dst, ptr src, struct jit_ctx *ctx); 119 + 120 + /* Simply emit the instruction if the JIT memory space has been allocated */ 121 + #define emit_instr(ctx, func, ...) \ 122 + do { \ 123 + if ((ctx)->target != NULL) { \ 124 + u32 *p = &(ctx)->target[ctx->idx]; \ 125 + uasm_i_##func(&p, ##__VA_ARGS__); \ 126 + } \ 127 + (ctx)->idx++; \ 128 + } while (0) 129 + 130 + /* 131 + * Similar to emit_instr but it must be used when we need to emit 132 + * 32-bit or 64-bit instructions 133 + */ 134 + #define emit_long_instr(ctx, func, ...) \ 135 + do { \ 136 + if ((ctx)->target != NULL) { \ 137 + u32 *p = &(ctx)->target[ctx->idx]; \ 138 + UASM_i_##func(&p, ##__VA_ARGS__); \ 139 + } \ 140 + (ctx)->idx++; \ 141 + } while (0) 142 + 143 + /* Determine if immediate is within the 16-bit signed range */ 144 + static inline bool is_range16(s32 imm) 145 + { 146 + return !(imm >= SBIT(15) || imm < -SBIT(15)); 147 + } 148 + 149 + static inline void emit_addu(unsigned int dst, unsigned int src1, 150 + unsigned int src2, struct jit_ctx *ctx) 151 + { 152 + emit_instr(ctx, addu, dst, src1, src2); 153 + } 154 + 155 + static inline void emit_nop(struct jit_ctx *ctx) 156 + { 157 + emit_instr(ctx, nop); 158 + } 159 + 160 + /* Load a u32 immediate to a register */ 161 + static inline void emit_load_imm(unsigned int dst, u32 imm, struct jit_ctx *ctx) 162 + { 163 + if (ctx->target != NULL) { 164 + /* addiu can only handle s16 */ 165 + if (!is_range16(imm)) { 166 + u32 *p = &ctx->target[ctx->idx]; 167 + uasm_i_lui(&p, r_tmp_imm, (s32)imm >> 16); 168 + p = &ctx->target[ctx->idx + 1]; 169 + uasm_i_ori(&p, dst, r_tmp_imm, imm & 0xffff); 170 + } else { 171 + u32 *p = &ctx->target[ctx->idx]; 172 + uasm_i_addiu(&p, dst, r_zero, imm); 173 + } 174 + } 175 + ctx->idx++; 176 + 177 + if (!is_range16(imm)) 178 + ctx->idx++; 179 + } 180 + 181 + static inline void emit_or(unsigned int dst, unsigned int src1, 182 + unsigned int src2, struct jit_ctx *ctx) 183 + { 184 + emit_instr(ctx, or, dst, src1, src2); 185 + } 186 + 187 + static inline void emit_ori(unsigned int dst, unsigned src, u32 imm, 188 + struct jit_ctx *ctx) 189 + { 190 + if (imm >= BIT(16)) { 191 + emit_load_imm(r_tmp, imm, ctx); 192 + emit_or(dst, src, r_tmp, ctx); 193 + } else { 194 + emit_instr(ctx, ori, dst, src, imm); 195 + } 196 + } 197 + 198 + static inline void emit_daddiu(unsigned int dst, unsigned int src, 199 + int imm, struct jit_ctx *ctx) 200 + { 201 + /* 202 + * Only used for stack, so the imm is relatively small 203 + * and it fits in 15-bits 204 + */ 205 + emit_instr(ctx, daddiu, dst, src, imm); 206 + } 207 + 208 + static inline void emit_addiu(unsigned int dst, unsigned int src, 209 + u32 imm, struct jit_ctx *ctx) 210 + { 211 + if (!is_range16(imm)) { 212 + emit_load_imm(r_tmp, imm, ctx); 213 + emit_addu(dst, r_tmp, src, ctx); 214 + } else { 215 + emit_instr(ctx, addiu, dst, src, imm); 216 + } 217 + } 218 + 219 + static inline void emit_and(unsigned int dst, unsigned int src1, 220 + unsigned int src2, struct jit_ctx *ctx) 221 + { 222 + emit_instr(ctx, and, dst, src1, src2); 223 + } 224 + 225 + static inline void emit_andi(unsigned int dst, unsigned int src, 226 + u32 imm, struct jit_ctx *ctx) 227 + { 228 + /* If imm does not fit in u16 then load it to register */ 229 + if (imm >= BIT(16)) { 230 + emit_load_imm(r_tmp, imm, ctx); 231 + emit_and(dst, src, r_tmp, ctx); 232 + } else { 233 + emit_instr(ctx, andi, dst, src, imm); 234 + } 235 + } 236 + 237 + static inline void emit_xor(unsigned int dst, unsigned int src1, 238 + unsigned int src2, struct jit_ctx *ctx) 239 + { 240 + emit_instr(ctx, xor, dst, src1, src2); 241 + } 242 + 243 + static inline void emit_xori(ptr dst, ptr src, u32 imm, struct jit_ctx *ctx) 244 + { 245 + /* If imm does not fit in u16 then load it to register */ 246 + if (imm >= BIT(16)) { 247 + emit_load_imm(r_tmp, imm, ctx); 248 + emit_xor(dst, src, r_tmp, ctx); 249 + } else { 250 + emit_instr(ctx, xori, dst, src, imm); 251 + } 252 + } 253 + 254 + static inline void emit_stack_offset(int offset, struct jit_ctx *ctx) 255 + { 256 + emit_long_instr(ctx, ADDIU, r_sp, r_sp, offset); 257 + } 258 + 259 + static inline void emit_subu(unsigned int dst, unsigned int src1, 260 + unsigned int src2, struct jit_ctx *ctx) 261 + { 262 + emit_instr(ctx, subu, dst, src1, src2); 263 + } 264 + 265 + static inline void emit_neg(unsigned int reg, struct jit_ctx *ctx) 266 + { 267 + emit_subu(reg, r_zero, reg, ctx); 268 + } 269 + 270 + static inline void emit_sllv(unsigned int dst, unsigned int src, 271 + unsigned int sa, struct jit_ctx *ctx) 272 + { 273 + emit_instr(ctx, sllv, dst, src, sa); 274 + } 275 + 276 + static inline void emit_sll(unsigned int dst, unsigned int src, 277 + unsigned int sa, struct jit_ctx *ctx) 278 + { 279 + /* sa is 5-bits long */ 280 + if (sa >= BIT(5)) 281 + /* Shifting >= 32 results in zero */ 282 + emit_jit_reg_move(dst, r_zero, ctx); 283 + else 284 + emit_instr(ctx, sll, dst, src, sa); 285 + } 286 + 287 + static inline void emit_srlv(unsigned int dst, unsigned int src, 288 + unsigned int sa, struct jit_ctx *ctx) 289 + { 290 + emit_instr(ctx, srlv, dst, src, sa); 291 + } 292 + 293 + static inline void emit_srl(unsigned int dst, unsigned int src, 294 + unsigned int sa, struct jit_ctx *ctx) 295 + { 296 + /* sa is 5-bits long */ 297 + if (sa >= BIT(5)) 298 + /* Shifting >= 32 results in zero */ 299 + emit_jit_reg_move(dst, r_zero, ctx); 300 + else 301 + emit_instr(ctx, srl, dst, src, sa); 302 + } 303 + 304 + static inline void emit_slt(unsigned int dst, unsigned int src1, 305 + unsigned int src2, struct jit_ctx *ctx) 306 + { 307 + emit_instr(ctx, slt, dst, src1, src2); 308 + } 309 + 310 + static inline void emit_sltu(unsigned int dst, unsigned int src1, 311 + unsigned int src2, struct jit_ctx *ctx) 312 + { 313 + emit_instr(ctx, sltu, dst, src1, src2); 314 + } 315 + 316 + static inline void emit_sltiu(unsigned dst, unsigned int src, 317 + unsigned int imm, struct jit_ctx *ctx) 318 + { 319 + /* 16 bit immediate */ 320 + if (!is_range16((s32)imm)) { 321 + emit_load_imm(r_tmp, imm, ctx); 322 + emit_sltu(dst, src, r_tmp, ctx); 323 + } else { 324 + emit_instr(ctx, sltiu, dst, src, imm); 325 + } 326 + 327 + } 328 + 329 + /* Store register on the stack */ 330 + static inline void emit_store_stack_reg(ptr reg, ptr base, 331 + unsigned int offset, 332 + struct jit_ctx *ctx) 333 + { 334 + emit_long_instr(ctx, SW, reg, offset, base); 335 + } 336 + 337 + static inline void emit_store(ptr reg, ptr base, unsigned int offset, 338 + struct jit_ctx *ctx) 339 + { 340 + emit_instr(ctx, sw, reg, offset, base); 341 + } 342 + 343 + static inline void emit_load_stack_reg(ptr reg, ptr base, 344 + unsigned int offset, 345 + struct jit_ctx *ctx) 346 + { 347 + emit_long_instr(ctx, LW, reg, offset, base); 348 + } 349 + 350 + static inline void emit_load(unsigned int reg, unsigned int base, 351 + unsigned int offset, struct jit_ctx *ctx) 352 + { 353 + emit_instr(ctx, lw, reg, offset, base); 354 + } 355 + 356 + static inline void emit_load_byte(unsigned int reg, unsigned int base, 357 + unsigned int offset, struct jit_ctx *ctx) 358 + { 359 + emit_instr(ctx, lb, reg, offset, base); 360 + } 361 + 362 + static inline void emit_half_load(unsigned int reg, unsigned int base, 363 + unsigned int offset, struct jit_ctx *ctx) 364 + { 365 + emit_instr(ctx, lh, reg, offset, base); 366 + } 367 + 368 + static inline void emit_half_load_unsigned(unsigned int reg, unsigned int base, 369 + unsigned int offset, struct jit_ctx *ctx) 370 + { 371 + emit_instr(ctx, lhu, reg, offset, base); 372 + } 373 + 374 + static inline void emit_mul(unsigned int dst, unsigned int src1, 375 + unsigned int src2, struct jit_ctx *ctx) 376 + { 377 + emit_instr(ctx, mul, dst, src1, src2); 378 + } 379 + 380 + static inline void emit_div(unsigned int dst, unsigned int src, 381 + struct jit_ctx *ctx) 382 + { 383 + if (ctx->target != NULL) { 384 + u32 *p = &ctx->target[ctx->idx]; 385 + uasm_i_divu(&p, dst, src); 386 + p = &ctx->target[ctx->idx + 1]; 387 + uasm_i_mflo(&p, dst); 388 + } 389 + ctx->idx += 2; /* 2 insts */ 390 + } 391 + 392 + static inline void emit_mod(unsigned int dst, unsigned int src, 393 + struct jit_ctx *ctx) 394 + { 395 + if (ctx->target != NULL) { 396 + u32 *p = &ctx->target[ctx->idx]; 397 + uasm_i_divu(&p, dst, src); 398 + p = &ctx->target[ctx->idx + 1]; 399 + uasm_i_mfhi(&p, dst); 400 + } 401 + ctx->idx += 2; /* 2 insts */ 402 + } 403 + 404 + static inline void emit_dsll(unsigned int dst, unsigned int src, 405 + unsigned int sa, struct jit_ctx *ctx) 406 + { 407 + emit_instr(ctx, dsll, dst, src, sa); 408 + } 409 + 410 + static inline void emit_dsrl32(unsigned int dst, unsigned int src, 411 + unsigned int sa, struct jit_ctx *ctx) 412 + { 413 + emit_instr(ctx, dsrl32, dst, src, sa); 414 + } 415 + 416 + static inline void emit_wsbh(unsigned int dst, unsigned int src, 417 + struct jit_ctx *ctx) 418 + { 419 + emit_instr(ctx, wsbh, dst, src); 420 + } 421 + 422 + /* load pointer to register */ 423 + static inline void emit_load_ptr(unsigned int dst, unsigned int src, 424 + int imm, struct jit_ctx *ctx) 425 + { 426 + /* src contains the base addr of the 32/64-pointer */ 427 + emit_long_instr(ctx, LW, dst, imm, src); 428 + } 429 + 430 + /* load a function pointer to register */ 431 + static inline void emit_load_func(unsigned int reg, ptr imm, 432 + struct jit_ctx *ctx) 433 + { 434 + if (IS_ENABLED(CONFIG_64BIT)) { 435 + /* At this point imm is always 64-bit */ 436 + emit_load_imm(r_tmp, (u64)imm >> 32, ctx); 437 + emit_dsll(r_tmp_imm, r_tmp, 16, ctx); /* left shift by 16 */ 438 + emit_ori(r_tmp, r_tmp_imm, (imm >> 16) & 0xffff, ctx); 439 + emit_dsll(r_tmp_imm, r_tmp, 16, ctx); /* left shift by 16 */ 440 + emit_ori(reg, r_tmp_imm, imm & 0xffff, ctx); 441 + } else { 442 + emit_load_imm(reg, imm, ctx); 443 + } 444 + } 445 + 446 + /* Move to real MIPS register */ 447 + static inline void emit_reg_move(ptr dst, ptr src, struct jit_ctx *ctx) 448 + { 449 + emit_long_instr(ctx, ADDU, dst, src, r_zero); 450 + } 451 + 452 + /* Move to JIT (32-bit) register */ 453 + static inline void emit_jit_reg_move(ptr dst, ptr src, struct jit_ctx *ctx) 454 + { 455 + emit_addu(dst, src, r_zero, ctx); 456 + } 457 + 458 + /* Compute the immediate value for PC-relative branches. */ 459 + static inline u32 b_imm(unsigned int tgt, struct jit_ctx *ctx) 460 + { 461 + if (ctx->target == NULL) 462 + return 0; 463 + 464 + /* 465 + * We want a pc-relative branch. We only do forward branches 466 + * so tgt is always after pc. tgt is the instruction offset 467 + * we want to jump to. 468 + 469 + * Branch on MIPS: 470 + * I: target_offset <- sign_extend(offset) 471 + * I+1: PC += target_offset (delay slot) 472 + * 473 + * ctx->idx currently points to the branch instruction 474 + * but the offset is added to the delay slot so we need 475 + * to subtract 4. 476 + */ 477 + return ctx->offsets[tgt] - 478 + (ctx->idx * 4 - ctx->prologue_bytes) - 4; 479 + } 480 + 481 + static inline void emit_bcond(int cond, unsigned int reg1, unsigned int reg2, 482 + unsigned int imm, struct jit_ctx *ctx) 483 + { 484 + if (ctx->target != NULL) { 485 + u32 *p = &ctx->target[ctx->idx]; 486 + 487 + switch (cond) { 488 + case MIPS_COND_EQ: 489 + uasm_i_beq(&p, reg1, reg2, imm); 490 + break; 491 + case MIPS_COND_NE: 492 + uasm_i_bne(&p, reg1, reg2, imm); 493 + break; 494 + case MIPS_COND_ALL: 495 + uasm_i_b(&p, imm); 496 + break; 497 + default: 498 + pr_warn("%s: Unhandled branch conditional: %d\n", 499 + __func__, cond); 500 + } 501 + } 502 + ctx->idx++; 503 + } 504 + 505 + static inline void emit_b(unsigned int imm, struct jit_ctx *ctx) 506 + { 507 + emit_bcond(MIPS_COND_ALL, r_zero, r_zero, imm, ctx); 508 + } 509 + 510 + static inline void emit_jalr(unsigned int link, unsigned int reg, 511 + struct jit_ctx *ctx) 512 + { 513 + emit_instr(ctx, jalr, link, reg); 514 + } 515 + 516 + static inline void emit_jr(unsigned int reg, struct jit_ctx *ctx) 517 + { 518 + emit_instr(ctx, jr, reg); 519 + } 520 + 521 + static inline u16 align_sp(unsigned int num) 522 + { 523 + /* Double word alignment for 32-bit, quadword for 64-bit */ 524 + unsigned int align = IS_ENABLED(CONFIG_64BIT) ? 16 : 8; 525 + num = (num + (align - 1)) & -align; 526 + return num; 527 + } 528 + 529 + static void save_bpf_jit_regs(struct jit_ctx *ctx, unsigned offset) 530 + { 531 + int i = 0, real_off = 0; 532 + u32 sflags, tmp_flags; 533 + 534 + /* Adjust the stack pointer */ 535 + if (offset) 536 + emit_stack_offset(-align_sp(offset), ctx); 537 + 538 + tmp_flags = sflags = ctx->flags >> SEEN_SREG_SFT; 539 + /* sflags is essentially a bitmap */ 540 + while (tmp_flags) { 541 + if ((sflags >> i) & 0x1) { 542 + emit_store_stack_reg(MIPS_R_S0 + i, r_sp, real_off, 543 + ctx); 544 + real_off += SZREG; 545 + } 546 + i++; 547 + tmp_flags >>= 1; 548 + } 549 + 550 + /* save return address */ 551 + if (ctx->flags & SEEN_CALL) { 552 + emit_store_stack_reg(r_ra, r_sp, real_off, ctx); 553 + real_off += SZREG; 554 + } 555 + 556 + /* Setup r_M leaving the alignment gap if necessary */ 557 + if (ctx->flags & SEEN_MEM) { 558 + if (real_off % (SZREG * 2)) 559 + real_off += SZREG; 560 + emit_long_instr(ctx, ADDIU, r_M, r_sp, real_off); 561 + } 562 + } 563 + 564 + static void restore_bpf_jit_regs(struct jit_ctx *ctx, 565 + unsigned int offset) 566 + { 567 + int i, real_off = 0; 568 + u32 sflags, tmp_flags; 569 + 570 + tmp_flags = sflags = ctx->flags >> SEEN_SREG_SFT; 571 + /* sflags is a bitmap */ 572 + i = 0; 573 + while (tmp_flags) { 574 + if ((sflags >> i) & 0x1) { 575 + emit_load_stack_reg(MIPS_R_S0 + i, r_sp, real_off, 576 + ctx); 577 + real_off += SZREG; 578 + } 579 + i++; 580 + tmp_flags >>= 1; 581 + } 582 + 583 + /* restore return address */ 584 + if (ctx->flags & SEEN_CALL) 585 + emit_load_stack_reg(r_ra, r_sp, real_off, ctx); 586 + 587 + /* Restore the sp and discard the scrach memory */ 588 + if (offset) 589 + emit_stack_offset(align_sp(offset), ctx); 590 + } 591 + 592 + static unsigned int get_stack_depth(struct jit_ctx *ctx) 593 + { 594 + int sp_off = 0; 595 + 596 + 597 + /* How may s* regs do we need to preserved? */ 598 + sp_off += hweight32(ctx->flags >> SEEN_SREG_SFT) * SZREG; 599 + 600 + if (ctx->flags & SEEN_MEM) 601 + sp_off += 4 * BPF_MEMWORDS; /* BPF_MEMWORDS are 32-bit */ 602 + 603 + if (ctx->flags & SEEN_CALL) 604 + sp_off += SZREG; /* Space for our ra register */ 605 + 606 + return sp_off; 607 + } 608 + 609 + static void build_prologue(struct jit_ctx *ctx) 610 + { 611 + int sp_off; 612 + 613 + /* Calculate the total offset for the stack pointer */ 614 + sp_off = get_stack_depth(ctx); 615 + save_bpf_jit_regs(ctx, sp_off); 616 + 617 + if (ctx->flags & SEEN_SKB) 618 + emit_reg_move(r_skb, MIPS_R_A0, ctx); 619 + 620 + if (ctx->flags & SEEN_SKB_DATA) { 621 + /* Load packet length */ 622 + emit_load(r_skb_len, r_skb, offsetof(struct sk_buff, len), 623 + ctx); 624 + emit_load(r_tmp, r_skb, offsetof(struct sk_buff, data_len), 625 + ctx); 626 + /* Load the data pointer */ 627 + emit_load_ptr(r_skb_data, r_skb, 628 + offsetof(struct sk_buff, data), ctx); 629 + /* Load the header length */ 630 + emit_subu(r_skb_hl, r_skb_len, r_tmp, ctx); 631 + } 632 + 633 + if (ctx->flags & SEEN_X) 634 + emit_jit_reg_move(r_X, r_zero, ctx); 635 + 636 + /* 637 + * Do not leak kernel data to userspace, we only need to clear 638 + * r_A if it is ever used. In fact if it is never used, we 639 + * will not save/restore it, so clearing it in this case would 640 + * corrupt the state of the caller. 641 + */ 642 + if (bpf_needs_clear_a(&ctx->skf->insns[0]) && 643 + (ctx->flags & SEEN_A)) 644 + emit_jit_reg_move(r_A, r_zero, ctx); 645 + } 646 + 647 + static void build_epilogue(struct jit_ctx *ctx) 648 + { 649 + unsigned int sp_off; 650 + 651 + /* Calculate the total offset for the stack pointer */ 652 + 653 + sp_off = get_stack_depth(ctx); 654 + restore_bpf_jit_regs(ctx, sp_off); 655 + 656 + /* Return */ 657 + emit_jr(r_ra, ctx); 658 + emit_nop(ctx); 659 + } 660 + 661 + #define CHOOSE_LOAD_FUNC(K, func) \ 662 + ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative : func) : \ 663 + func##_positive) 664 + 665 + static int build_body(struct jit_ctx *ctx) 666 + { 667 + const struct bpf_prog *prog = ctx->skf; 668 + const struct sock_filter *inst; 669 + unsigned int i, off, condt; 670 + u32 k, b_off __maybe_unused; 671 + u8 (*sk_load_func)(unsigned long *skb, int offset); 672 + 673 + for (i = 0; i < prog->len; i++) { 674 + u16 code; 675 + 676 + inst = &(prog->insns[i]); 677 + pr_debug("%s: code->0x%02x, jt->0x%x, jf->0x%x, k->0x%x\n", 678 + __func__, inst->code, inst->jt, inst->jf, inst->k); 679 + k = inst->k; 680 + code = bpf_anc_helper(inst); 681 + 682 + if (ctx->target == NULL) 683 + ctx->offsets[i] = ctx->idx * 4; 684 + 685 + switch (code) { 686 + case BPF_LD | BPF_IMM: 687 + /* A <- k ==> li r_A, k */ 688 + ctx->flags |= SEEN_A; 689 + emit_load_imm(r_A, k, ctx); 690 + break; 691 + case BPF_LD | BPF_W | BPF_LEN: 692 + BUILD_BUG_ON(sizeof_field(struct sk_buff, len) != 4); 693 + /* A <- len ==> lw r_A, offset(skb) */ 694 + ctx->flags |= SEEN_SKB | SEEN_A; 695 + off = offsetof(struct sk_buff, len); 696 + emit_load(r_A, r_skb, off, ctx); 697 + break; 698 + case BPF_LD | BPF_MEM: 699 + /* A <- M[k] ==> lw r_A, offset(M) */ 700 + ctx->flags |= SEEN_MEM | SEEN_A; 701 + emit_load(r_A, r_M, SCRATCH_OFF(k), ctx); 702 + break; 703 + case BPF_LD | BPF_W | BPF_ABS: 704 + /* A <- P[k:4] */ 705 + sk_load_func = CHOOSE_LOAD_FUNC(k, sk_load_word); 706 + goto load; 707 + case BPF_LD | BPF_H | BPF_ABS: 708 + /* A <- P[k:2] */ 709 + sk_load_func = CHOOSE_LOAD_FUNC(k, sk_load_half); 710 + goto load; 711 + case BPF_LD | BPF_B | BPF_ABS: 712 + /* A <- P[k:1] */ 713 + sk_load_func = CHOOSE_LOAD_FUNC(k, sk_load_byte); 714 + load: 715 + emit_load_imm(r_off, k, ctx); 716 + load_common: 717 + ctx->flags |= SEEN_CALL | SEEN_OFF | 718 + SEEN_SKB | SEEN_A | SEEN_SKB_DATA; 719 + 720 + emit_load_func(r_s0, (ptr)sk_load_func, ctx); 721 + emit_reg_move(MIPS_R_A0, r_skb, ctx); 722 + emit_jalr(MIPS_R_RA, r_s0, ctx); 723 + /* Load second argument to delay slot */ 724 + emit_reg_move(MIPS_R_A1, r_off, ctx); 725 + /* Check the error value */ 726 + emit_bcond(MIPS_COND_EQ, r_ret, 0, b_imm(i + 1, ctx), 727 + ctx); 728 + /* Load return register on DS for failures */ 729 + emit_reg_move(r_ret, r_zero, ctx); 730 + /* Return with error */ 731 + emit_b(b_imm(prog->len, ctx), ctx); 732 + emit_nop(ctx); 733 + break; 734 + case BPF_LD | BPF_W | BPF_IND: 735 + /* A <- P[X + k:4] */ 736 + sk_load_func = sk_load_word; 737 + goto load_ind; 738 + case BPF_LD | BPF_H | BPF_IND: 739 + /* A <- P[X + k:2] */ 740 + sk_load_func = sk_load_half; 741 + goto load_ind; 742 + case BPF_LD | BPF_B | BPF_IND: 743 + /* A <- P[X + k:1] */ 744 + sk_load_func = sk_load_byte; 745 + load_ind: 746 + ctx->flags |= SEEN_OFF | SEEN_X; 747 + emit_addiu(r_off, r_X, k, ctx); 748 + goto load_common; 749 + case BPF_LDX | BPF_IMM: 750 + /* X <- k */ 751 + ctx->flags |= SEEN_X; 752 + emit_load_imm(r_X, k, ctx); 753 + break; 754 + case BPF_LDX | BPF_MEM: 755 + /* X <- M[k] */ 756 + ctx->flags |= SEEN_X | SEEN_MEM; 757 + emit_load(r_X, r_M, SCRATCH_OFF(k), ctx); 758 + break; 759 + case BPF_LDX | BPF_W | BPF_LEN: 760 + /* X <- len */ 761 + ctx->flags |= SEEN_X | SEEN_SKB; 762 + off = offsetof(struct sk_buff, len); 763 + emit_load(r_X, r_skb, off, ctx); 764 + break; 765 + case BPF_LDX | BPF_B | BPF_MSH: 766 + /* X <- 4 * (P[k:1] & 0xf) */ 767 + ctx->flags |= SEEN_X | SEEN_CALL | SEEN_SKB; 768 + /* Load offset to a1 */ 769 + emit_load_func(r_s0, (ptr)sk_load_byte, ctx); 770 + /* 771 + * This may emit two instructions so it may not fit 772 + * in the delay slot. So use a0 in the delay slot. 773 + */ 774 + emit_load_imm(MIPS_R_A1, k, ctx); 775 + emit_jalr(MIPS_R_RA, r_s0, ctx); 776 + emit_reg_move(MIPS_R_A0, r_skb, ctx); /* delay slot */ 777 + /* Check the error value */ 778 + emit_bcond(MIPS_COND_NE, r_ret, 0, 779 + b_imm(prog->len, ctx), ctx); 780 + emit_reg_move(r_ret, r_zero, ctx); 781 + /* We are good */ 782 + /* X <- P[1:K] & 0xf */ 783 + emit_andi(r_X, r_A, 0xf, ctx); 784 + /* X << 2 */ 785 + emit_b(b_imm(i + 1, ctx), ctx); 786 + emit_sll(r_X, r_X, 2, ctx); /* delay slot */ 787 + break; 788 + case BPF_ST: 789 + /* M[k] <- A */ 790 + ctx->flags |= SEEN_MEM | SEEN_A; 791 + emit_store(r_A, r_M, SCRATCH_OFF(k), ctx); 792 + break; 793 + case BPF_STX: 794 + /* M[k] <- X */ 795 + ctx->flags |= SEEN_MEM | SEEN_X; 796 + emit_store(r_X, r_M, SCRATCH_OFF(k), ctx); 797 + break; 798 + case BPF_ALU | BPF_ADD | BPF_K: 799 + /* A += K */ 800 + ctx->flags |= SEEN_A; 801 + emit_addiu(r_A, r_A, k, ctx); 802 + break; 803 + case BPF_ALU | BPF_ADD | BPF_X: 804 + /* A += X */ 805 + ctx->flags |= SEEN_A | SEEN_X; 806 + emit_addu(r_A, r_A, r_X, ctx); 807 + break; 808 + case BPF_ALU | BPF_SUB | BPF_K: 809 + /* A -= K */ 810 + ctx->flags |= SEEN_A; 811 + emit_addiu(r_A, r_A, -k, ctx); 812 + break; 813 + case BPF_ALU | BPF_SUB | BPF_X: 814 + /* A -= X */ 815 + ctx->flags |= SEEN_A | SEEN_X; 816 + emit_subu(r_A, r_A, r_X, ctx); 817 + break; 818 + case BPF_ALU | BPF_MUL | BPF_K: 819 + /* A *= K */ 820 + /* Load K to scratch register before MUL */ 821 + ctx->flags |= SEEN_A; 822 + emit_load_imm(r_s0, k, ctx); 823 + emit_mul(r_A, r_A, r_s0, ctx); 824 + break; 825 + case BPF_ALU | BPF_MUL | BPF_X: 826 + /* A *= X */ 827 + ctx->flags |= SEEN_A | SEEN_X; 828 + emit_mul(r_A, r_A, r_X, ctx); 829 + break; 830 + case BPF_ALU | BPF_DIV | BPF_K: 831 + /* A /= k */ 832 + if (k == 1) 833 + break; 834 + if (optimize_div(&k)) { 835 + ctx->flags |= SEEN_A; 836 + emit_srl(r_A, r_A, k, ctx); 837 + break; 838 + } 839 + ctx->flags |= SEEN_A; 840 + emit_load_imm(r_s0, k, ctx); 841 + emit_div(r_A, r_s0, ctx); 842 + break; 843 + case BPF_ALU | BPF_MOD | BPF_K: 844 + /* A %= k */ 845 + if (k == 1) { 846 + ctx->flags |= SEEN_A; 847 + emit_jit_reg_move(r_A, r_zero, ctx); 848 + } else { 849 + ctx->flags |= SEEN_A; 850 + emit_load_imm(r_s0, k, ctx); 851 + emit_mod(r_A, r_s0, ctx); 852 + } 853 + break; 854 + case BPF_ALU | BPF_DIV | BPF_X: 855 + /* A /= X */ 856 + ctx->flags |= SEEN_X | SEEN_A; 857 + /* Check if r_X is zero */ 858 + emit_bcond(MIPS_COND_EQ, r_X, r_zero, 859 + b_imm(prog->len, ctx), ctx); 860 + emit_load_imm(r_ret, 0, ctx); /* delay slot */ 861 + emit_div(r_A, r_X, ctx); 862 + break; 863 + case BPF_ALU | BPF_MOD | BPF_X: 864 + /* A %= X */ 865 + ctx->flags |= SEEN_X | SEEN_A; 866 + /* Check if r_X is zero */ 867 + emit_bcond(MIPS_COND_EQ, r_X, r_zero, 868 + b_imm(prog->len, ctx), ctx); 869 + emit_load_imm(r_ret, 0, ctx); /* delay slot */ 870 + emit_mod(r_A, r_X, ctx); 871 + break; 872 + case BPF_ALU | BPF_OR | BPF_K: 873 + /* A |= K */ 874 + ctx->flags |= SEEN_A; 875 + emit_ori(r_A, r_A, k, ctx); 876 + break; 877 + case BPF_ALU | BPF_OR | BPF_X: 878 + /* A |= X */ 879 + ctx->flags |= SEEN_A; 880 + emit_ori(r_A, r_A, r_X, ctx); 881 + break; 882 + case BPF_ALU | BPF_XOR | BPF_K: 883 + /* A ^= k */ 884 + ctx->flags |= SEEN_A; 885 + emit_xori(r_A, r_A, k, ctx); 886 + break; 887 + case BPF_ANC | SKF_AD_ALU_XOR_X: 888 + case BPF_ALU | BPF_XOR | BPF_X: 889 + /* A ^= X */ 890 + ctx->flags |= SEEN_A; 891 + emit_xor(r_A, r_A, r_X, ctx); 892 + break; 893 + case BPF_ALU | BPF_AND | BPF_K: 894 + /* A &= K */ 895 + ctx->flags |= SEEN_A; 896 + emit_andi(r_A, r_A, k, ctx); 897 + break; 898 + case BPF_ALU | BPF_AND | BPF_X: 899 + /* A &= X */ 900 + ctx->flags |= SEEN_A | SEEN_X; 901 + emit_and(r_A, r_A, r_X, ctx); 902 + break; 903 + case BPF_ALU | BPF_LSH | BPF_K: 904 + /* A <<= K */ 905 + ctx->flags |= SEEN_A; 906 + emit_sll(r_A, r_A, k, ctx); 907 + break; 908 + case BPF_ALU | BPF_LSH | BPF_X: 909 + /* A <<= X */ 910 + ctx->flags |= SEEN_A | SEEN_X; 911 + emit_sllv(r_A, r_A, r_X, ctx); 912 + break; 913 + case BPF_ALU | BPF_RSH | BPF_K: 914 + /* A >>= K */ 915 + ctx->flags |= SEEN_A; 916 + emit_srl(r_A, r_A, k, ctx); 917 + break; 918 + case BPF_ALU | BPF_RSH | BPF_X: 919 + ctx->flags |= SEEN_A | SEEN_X; 920 + emit_srlv(r_A, r_A, r_X, ctx); 921 + break; 922 + case BPF_ALU | BPF_NEG: 923 + /* A = -A */ 924 + ctx->flags |= SEEN_A; 925 + emit_neg(r_A, ctx); 926 + break; 927 + case BPF_JMP | BPF_JA: 928 + /* pc += K */ 929 + emit_b(b_imm(i + k + 1, ctx), ctx); 930 + emit_nop(ctx); 931 + break; 932 + case BPF_JMP | BPF_JEQ | BPF_K: 933 + /* pc += ( A == K ) ? pc->jt : pc->jf */ 934 + condt = MIPS_COND_EQ | MIPS_COND_K; 935 + goto jmp_cmp; 936 + case BPF_JMP | BPF_JEQ | BPF_X: 937 + ctx->flags |= SEEN_X; 938 + /* pc += ( A == X ) ? pc->jt : pc->jf */ 939 + condt = MIPS_COND_EQ | MIPS_COND_X; 940 + goto jmp_cmp; 941 + case BPF_JMP | BPF_JGE | BPF_K: 942 + /* pc += ( A >= K ) ? pc->jt : pc->jf */ 943 + condt = MIPS_COND_GE | MIPS_COND_K; 944 + goto jmp_cmp; 945 + case BPF_JMP | BPF_JGE | BPF_X: 946 + ctx->flags |= SEEN_X; 947 + /* pc += ( A >= X ) ? pc->jt : pc->jf */ 948 + condt = MIPS_COND_GE | MIPS_COND_X; 949 + goto jmp_cmp; 950 + case BPF_JMP | BPF_JGT | BPF_K: 951 + /* pc += ( A > K ) ? pc->jt : pc->jf */ 952 + condt = MIPS_COND_GT | MIPS_COND_K; 953 + goto jmp_cmp; 954 + case BPF_JMP | BPF_JGT | BPF_X: 955 + ctx->flags |= SEEN_X; 956 + /* pc += ( A > X ) ? pc->jt : pc->jf */ 957 + condt = MIPS_COND_GT | MIPS_COND_X; 958 + jmp_cmp: 959 + /* Greater or Equal */ 960 + if ((condt & MIPS_COND_GE) || 961 + (condt & MIPS_COND_GT)) { 962 + if (condt & MIPS_COND_K) { /* K */ 963 + ctx->flags |= SEEN_A; 964 + emit_sltiu(r_s0, r_A, k, ctx); 965 + } else { /* X */ 966 + ctx->flags |= SEEN_A | 967 + SEEN_X; 968 + emit_sltu(r_s0, r_A, r_X, ctx); 969 + } 970 + /* A < (K|X) ? r_scrach = 1 */ 971 + b_off = b_imm(i + inst->jf + 1, ctx); 972 + emit_bcond(MIPS_COND_NE, r_s0, r_zero, b_off, 973 + ctx); 974 + emit_nop(ctx); 975 + /* A > (K|X) ? scratch = 0 */ 976 + if (condt & MIPS_COND_GT) { 977 + /* Checking for equality */ 978 + ctx->flags |= SEEN_A | SEEN_X; 979 + if (condt & MIPS_COND_K) 980 + emit_load_imm(r_s0, k, ctx); 981 + else 982 + emit_jit_reg_move(r_s0, r_X, 983 + ctx); 984 + b_off = b_imm(i + inst->jf + 1, ctx); 985 + emit_bcond(MIPS_COND_EQ, r_A, r_s0, 986 + b_off, ctx); 987 + emit_nop(ctx); 988 + /* Finally, A > K|X */ 989 + b_off = b_imm(i + inst->jt + 1, ctx); 990 + emit_b(b_off, ctx); 991 + emit_nop(ctx); 992 + } else { 993 + /* A >= (K|X) so jump */ 994 + b_off = b_imm(i + inst->jt + 1, ctx); 995 + emit_b(b_off, ctx); 996 + emit_nop(ctx); 997 + } 998 + } else { 999 + /* A == K|X */ 1000 + if (condt & MIPS_COND_K) { /* K */ 1001 + ctx->flags |= SEEN_A; 1002 + emit_load_imm(r_s0, k, ctx); 1003 + /* jump true */ 1004 + b_off = b_imm(i + inst->jt + 1, ctx); 1005 + emit_bcond(MIPS_COND_EQ, r_A, r_s0, 1006 + b_off, ctx); 1007 + emit_nop(ctx); 1008 + /* jump false */ 1009 + b_off = b_imm(i + inst->jf + 1, 1010 + ctx); 1011 + emit_bcond(MIPS_COND_NE, r_A, r_s0, 1012 + b_off, ctx); 1013 + emit_nop(ctx); 1014 + } else { /* X */ 1015 + /* jump true */ 1016 + ctx->flags |= SEEN_A | SEEN_X; 1017 + b_off = b_imm(i + inst->jt + 1, 1018 + ctx); 1019 + emit_bcond(MIPS_COND_EQ, r_A, r_X, 1020 + b_off, ctx); 1021 + emit_nop(ctx); 1022 + /* jump false */ 1023 + b_off = b_imm(i + inst->jf + 1, ctx); 1024 + emit_bcond(MIPS_COND_NE, r_A, r_X, 1025 + b_off, ctx); 1026 + emit_nop(ctx); 1027 + } 1028 + } 1029 + break; 1030 + case BPF_JMP | BPF_JSET | BPF_K: 1031 + ctx->flags |= SEEN_A; 1032 + /* pc += (A & K) ? pc -> jt : pc -> jf */ 1033 + emit_load_imm(r_s1, k, ctx); 1034 + emit_and(r_s0, r_A, r_s1, ctx); 1035 + /* jump true */ 1036 + b_off = b_imm(i + inst->jt + 1, ctx); 1037 + emit_bcond(MIPS_COND_NE, r_s0, r_zero, b_off, ctx); 1038 + emit_nop(ctx); 1039 + /* jump false */ 1040 + b_off = b_imm(i + inst->jf + 1, ctx); 1041 + emit_b(b_off, ctx); 1042 + emit_nop(ctx); 1043 + break; 1044 + case BPF_JMP | BPF_JSET | BPF_X: 1045 + ctx->flags |= SEEN_X | SEEN_A; 1046 + /* pc += (A & X) ? pc -> jt : pc -> jf */ 1047 + emit_and(r_s0, r_A, r_X, ctx); 1048 + /* jump true */ 1049 + b_off = b_imm(i + inst->jt + 1, ctx); 1050 + emit_bcond(MIPS_COND_NE, r_s0, r_zero, b_off, ctx); 1051 + emit_nop(ctx); 1052 + /* jump false */ 1053 + b_off = b_imm(i + inst->jf + 1, ctx); 1054 + emit_b(b_off, ctx); 1055 + emit_nop(ctx); 1056 + break; 1057 + case BPF_RET | BPF_A: 1058 + ctx->flags |= SEEN_A; 1059 + if (i != prog->len - 1) 1060 + /* 1061 + * If this is not the last instruction 1062 + * then jump to the epilogue 1063 + */ 1064 + emit_b(b_imm(prog->len, ctx), ctx); 1065 + emit_reg_move(r_ret, r_A, ctx); /* delay slot */ 1066 + break; 1067 + case BPF_RET | BPF_K: 1068 + /* 1069 + * It can emit two instructions so it does not fit on 1070 + * the delay slot. 1071 + */ 1072 + emit_load_imm(r_ret, k, ctx); 1073 + if (i != prog->len - 1) { 1074 + /* 1075 + * If this is not the last instruction 1076 + * then jump to the epilogue 1077 + */ 1078 + emit_b(b_imm(prog->len, ctx), ctx); 1079 + emit_nop(ctx); 1080 + } 1081 + break; 1082 + case BPF_MISC | BPF_TAX: 1083 + /* X = A */ 1084 + ctx->flags |= SEEN_X | SEEN_A; 1085 + emit_jit_reg_move(r_X, r_A, ctx); 1086 + break; 1087 + case BPF_MISC | BPF_TXA: 1088 + /* A = X */ 1089 + ctx->flags |= SEEN_A | SEEN_X; 1090 + emit_jit_reg_move(r_A, r_X, ctx); 1091 + break; 1092 + /* AUX */ 1093 + case BPF_ANC | SKF_AD_PROTOCOL: 1094 + /* A = ntohs(skb->protocol */ 1095 + ctx->flags |= SEEN_SKB | SEEN_OFF | SEEN_A; 1096 + BUILD_BUG_ON(sizeof_field(struct sk_buff, 1097 + protocol) != 2); 1098 + off = offsetof(struct sk_buff, protocol); 1099 + emit_half_load(r_A, r_skb, off, ctx); 1100 + #ifdef CONFIG_CPU_LITTLE_ENDIAN 1101 + /* This needs little endian fixup */ 1102 + if (cpu_has_wsbh) { 1103 + /* R2 and later have the wsbh instruction */ 1104 + emit_wsbh(r_A, r_A, ctx); 1105 + } else { 1106 + /* Get first byte */ 1107 + emit_andi(r_tmp_imm, r_A, 0xff, ctx); 1108 + /* Shift it */ 1109 + emit_sll(r_tmp, r_tmp_imm, 8, ctx); 1110 + /* Get second byte */ 1111 + emit_srl(r_tmp_imm, r_A, 8, ctx); 1112 + emit_andi(r_tmp_imm, r_tmp_imm, 0xff, ctx); 1113 + /* Put everyting together in r_A */ 1114 + emit_or(r_A, r_tmp, r_tmp_imm, ctx); 1115 + } 1116 + #endif 1117 + break; 1118 + case BPF_ANC | SKF_AD_CPU: 1119 + ctx->flags |= SEEN_A | SEEN_OFF; 1120 + /* A = current_thread_info()->cpu */ 1121 + BUILD_BUG_ON(sizeof_field(struct thread_info, 1122 + cpu) != 4); 1123 + off = offsetof(struct thread_info, cpu); 1124 + /* $28/gp points to the thread_info struct */ 1125 + emit_load(r_A, 28, off, ctx); 1126 + break; 1127 + case BPF_ANC | SKF_AD_IFINDEX: 1128 + /* A = skb->dev->ifindex */ 1129 + case BPF_ANC | SKF_AD_HATYPE: 1130 + /* A = skb->dev->type */ 1131 + ctx->flags |= SEEN_SKB | SEEN_A; 1132 + off = offsetof(struct sk_buff, dev); 1133 + /* Load *dev pointer */ 1134 + emit_load_ptr(r_s0, r_skb, off, ctx); 1135 + /* error (0) in the delay slot */ 1136 + emit_bcond(MIPS_COND_EQ, r_s0, r_zero, 1137 + b_imm(prog->len, ctx), ctx); 1138 + emit_reg_move(r_ret, r_zero, ctx); 1139 + if (code == (BPF_ANC | SKF_AD_IFINDEX)) { 1140 + BUILD_BUG_ON(sizeof_field(struct net_device, ifindex) != 4); 1141 + off = offsetof(struct net_device, ifindex); 1142 + emit_load(r_A, r_s0, off, ctx); 1143 + } else { /* (code == (BPF_ANC | SKF_AD_HATYPE) */ 1144 + BUILD_BUG_ON(sizeof_field(struct net_device, type) != 2); 1145 + off = offsetof(struct net_device, type); 1146 + emit_half_load_unsigned(r_A, r_s0, off, ctx); 1147 + } 1148 + break; 1149 + case BPF_ANC | SKF_AD_MARK: 1150 + ctx->flags |= SEEN_SKB | SEEN_A; 1151 + BUILD_BUG_ON(sizeof_field(struct sk_buff, mark) != 4); 1152 + off = offsetof(struct sk_buff, mark); 1153 + emit_load(r_A, r_skb, off, ctx); 1154 + break; 1155 + case BPF_ANC | SKF_AD_RXHASH: 1156 + ctx->flags |= SEEN_SKB | SEEN_A; 1157 + BUILD_BUG_ON(sizeof_field(struct sk_buff, hash) != 4); 1158 + off = offsetof(struct sk_buff, hash); 1159 + emit_load(r_A, r_skb, off, ctx); 1160 + break; 1161 + case BPF_ANC | SKF_AD_VLAN_TAG: 1162 + ctx->flags |= SEEN_SKB | SEEN_A; 1163 + BUILD_BUG_ON(sizeof_field(struct sk_buff, 1164 + vlan_tci) != 2); 1165 + off = offsetof(struct sk_buff, vlan_tci); 1166 + emit_half_load_unsigned(r_A, r_skb, off, ctx); 1167 + break; 1168 + case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT: 1169 + ctx->flags |= SEEN_SKB | SEEN_A; 1170 + emit_load_byte(r_A, r_skb, PKT_VLAN_PRESENT_OFFSET(), ctx); 1171 + if (PKT_VLAN_PRESENT_BIT) 1172 + emit_srl(r_A, r_A, PKT_VLAN_PRESENT_BIT, ctx); 1173 + if (PKT_VLAN_PRESENT_BIT < 7) 1174 + emit_andi(r_A, r_A, 1, ctx); 1175 + break; 1176 + case BPF_ANC | SKF_AD_PKTTYPE: 1177 + ctx->flags |= SEEN_SKB; 1178 + 1179 + emit_load_byte(r_tmp, r_skb, PKT_TYPE_OFFSET(), ctx); 1180 + /* Keep only the last 3 bits */ 1181 + emit_andi(r_A, r_tmp, PKT_TYPE_MAX, ctx); 1182 + #ifdef __BIG_ENDIAN_BITFIELD 1183 + /* Get the actual packet type to the lower 3 bits */ 1184 + emit_srl(r_A, r_A, 5, ctx); 1185 + #endif 1186 + break; 1187 + case BPF_ANC | SKF_AD_QUEUE: 1188 + ctx->flags |= SEEN_SKB | SEEN_A; 1189 + BUILD_BUG_ON(sizeof_field(struct sk_buff, 1190 + queue_mapping) != 2); 1191 + BUILD_BUG_ON(offsetof(struct sk_buff, 1192 + queue_mapping) > 0xff); 1193 + off = offsetof(struct sk_buff, queue_mapping); 1194 + emit_half_load_unsigned(r_A, r_skb, off, ctx); 1195 + break; 1196 + default: 1197 + pr_debug("%s: Unhandled opcode: 0x%02x\n", __FILE__, 1198 + inst->code); 1199 + return -1; 1200 + } 1201 + } 1202 + 1203 + /* compute offsets only during the first pass */ 1204 + if (ctx->target == NULL) 1205 + ctx->offsets[i] = ctx->idx * 4; 1206 + 1207 + return 0; 1208 + } 1209 + 1210 + void bpf_jit_compile(struct bpf_prog *fp) 1211 + { 1212 + struct jit_ctx ctx; 1213 + unsigned int alloc_size, tmp_idx; 1214 + 1215 + if (!bpf_jit_enable) 1216 + return; 1217 + 1218 + memset(&ctx, 0, sizeof(ctx)); 1219 + 1220 + ctx.offsets = kcalloc(fp->len + 1, sizeof(*ctx.offsets), GFP_KERNEL); 1221 + if (ctx.offsets == NULL) 1222 + return; 1223 + 1224 + ctx.skf = fp; 1225 + 1226 + if (build_body(&ctx)) 1227 + goto out; 1228 + 1229 + tmp_idx = ctx.idx; 1230 + build_prologue(&ctx); 1231 + ctx.prologue_bytes = (ctx.idx - tmp_idx) * 4; 1232 + /* just to complete the ctx.idx count */ 1233 + build_epilogue(&ctx); 1234 + 1235 + alloc_size = 4 * ctx.idx; 1236 + ctx.target = module_alloc(alloc_size); 1237 + if (ctx.target == NULL) 1238 + goto out; 1239 + 1240 + /* Clean it */ 1241 + memset(ctx.target, 0, alloc_size); 1242 + 1243 + ctx.idx = 0; 1244 + 1245 + /* Generate the actual JIT code */ 1246 + build_prologue(&ctx); 1247 + build_body(&ctx); 1248 + build_epilogue(&ctx); 1249 + 1250 + /* Update the icache */ 1251 + flush_icache_range((ptr)ctx.target, (ptr)(ctx.target + ctx.idx)); 1252 + 1253 + if (bpf_jit_enable > 1) 1254 + /* Dump JIT code */ 1255 + bpf_jit_dump(fp->len, alloc_size, 2, ctx.target); 1256 + 1257 + fp->bpf_func = (void *)ctx.target; 1258 + fp->jited = 1; 1259 + 1260 + out: 1261 + kfree(ctx.offsets); 1262 + } 1263 + 1264 + void bpf_jit_free(struct bpf_prog *fp) 1265 + { 1266 + if (fp->jited) 1267 + module_memfree(fp->bpf_func); 1268 + 1269 + bpf_prog_unlock_free(fp); 1270 + }
+285
arch/mips/net/bpf_jit_asm.S
··· 1 + /* 2 + * bpf_jib_asm.S: Packet/header access helper functions for MIPS/MIPS64 BPF 3 + * compiler. 4 + * 5 + * Copyright (C) 2015 Imagination Technologies Ltd. 6 + * Author: Markos Chandras <markos.chandras@imgtec.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; version 2 of the License. 11 + */ 12 + 13 + #include <asm/asm.h> 14 + #include <asm/isa-rev.h> 15 + #include <asm/regdef.h> 16 + #include "bpf_jit.h" 17 + 18 + /* ABI 19 + * 20 + * r_skb_hl skb header length 21 + * r_skb_data skb data 22 + * r_off(a1) offset register 23 + * r_A BPF register A 24 + * r_X PF register X 25 + * r_skb(a0) *skb 26 + * r_M *scratch memory 27 + * r_skb_le skb length 28 + * r_s0 Scratch register 0 29 + * r_s1 Scratch register 1 30 + * 31 + * On entry: 32 + * a0: *skb 33 + * a1: offset (imm or imm + X) 34 + * 35 + * All non-BPF-ABI registers are free for use. On return, we only 36 + * care about r_ret. The BPF-ABI registers are assumed to remain 37 + * unmodified during the entire filter operation. 38 + */ 39 + 40 + #define skb a0 41 + #define offset a1 42 + #define SKF_LL_OFF (-0x200000) /* Can't include linux/filter.h in assembly */ 43 + 44 + /* We know better :) so prevent assembler reordering etc */ 45 + .set noreorder 46 + 47 + #define is_offset_negative(TYPE) \ 48 + /* If offset is negative we have more work to do */ \ 49 + slti t0, offset, 0; \ 50 + bgtz t0, bpf_slow_path_##TYPE##_neg; \ 51 + /* Be careful what follows in DS. */ 52 + 53 + #define is_offset_in_header(SIZE, TYPE) \ 54 + /* Reading from header? */ \ 55 + addiu $r_s0, $r_skb_hl, -SIZE; \ 56 + slt t0, $r_s0, offset; \ 57 + bgtz t0, bpf_slow_path_##TYPE; \ 58 + 59 + LEAF(sk_load_word) 60 + is_offset_negative(word) 61 + FEXPORT(sk_load_word_positive) 62 + is_offset_in_header(4, word) 63 + /* Offset within header boundaries */ 64 + PTR_ADDU t1, $r_skb_data, offset 65 + .set reorder 66 + lw $r_A, 0(t1) 67 + .set noreorder 68 + #ifdef CONFIG_CPU_LITTLE_ENDIAN 69 + # if MIPS_ISA_REV >= 2 70 + wsbh t0, $r_A 71 + rotr $r_A, t0, 16 72 + # else 73 + sll t0, $r_A, 24 74 + srl t1, $r_A, 24 75 + srl t2, $r_A, 8 76 + or t0, t0, t1 77 + andi t2, t2, 0xff00 78 + andi t1, $r_A, 0xff00 79 + or t0, t0, t2 80 + sll t1, t1, 8 81 + or $r_A, t0, t1 82 + # endif 83 + #endif 84 + jr $r_ra 85 + move $r_ret, zero 86 + END(sk_load_word) 87 + 88 + LEAF(sk_load_half) 89 + is_offset_negative(half) 90 + FEXPORT(sk_load_half_positive) 91 + is_offset_in_header(2, half) 92 + /* Offset within header boundaries */ 93 + PTR_ADDU t1, $r_skb_data, offset 94 + lhu $r_A, 0(t1) 95 + #ifdef CONFIG_CPU_LITTLE_ENDIAN 96 + # if MIPS_ISA_REV >= 2 97 + wsbh $r_A, $r_A 98 + # else 99 + sll t0, $r_A, 8 100 + srl t1, $r_A, 8 101 + andi t0, t0, 0xff00 102 + or $r_A, t0, t1 103 + # endif 104 + #endif 105 + jr $r_ra 106 + move $r_ret, zero 107 + END(sk_load_half) 108 + 109 + LEAF(sk_load_byte) 110 + is_offset_negative(byte) 111 + FEXPORT(sk_load_byte_positive) 112 + is_offset_in_header(1, byte) 113 + /* Offset within header boundaries */ 114 + PTR_ADDU t1, $r_skb_data, offset 115 + lbu $r_A, 0(t1) 116 + jr $r_ra 117 + move $r_ret, zero 118 + END(sk_load_byte) 119 + 120 + /* 121 + * call skb_copy_bits: 122 + * (prototype in linux/skbuff.h) 123 + * 124 + * int skb_copy_bits(sk_buff *skb, int offset, void *to, int len) 125 + * 126 + * o32 mandates we leave 4 spaces for argument registers in case 127 + * the callee needs to use them. Even though we don't care about 128 + * the argument registers ourselves, we need to allocate that space 129 + * to remain ABI compliant since the callee may want to use that space. 130 + * We also allocate 2 more spaces for $r_ra and our return register (*to). 131 + * 132 + * n64 is a bit different. The *caller* will allocate the space to preserve 133 + * the arguments. So in 64-bit kernels, we allocate the 4-arg space for no 134 + * good reason but it does not matter that much really. 135 + * 136 + * (void *to) is returned in r_s0 137 + * 138 + */ 139 + #ifdef CONFIG_CPU_LITTLE_ENDIAN 140 + #define DS_OFFSET(SIZE) (4 * SZREG) 141 + #else 142 + #define DS_OFFSET(SIZE) ((4 * SZREG) + (4 - SIZE)) 143 + #endif 144 + #define bpf_slow_path_common(SIZE) \ 145 + /* Quick check. Are we within reasonable boundaries? */ \ 146 + LONG_ADDIU $r_s1, $r_skb_len, -SIZE; \ 147 + sltu $r_s0, offset, $r_s1; \ 148 + beqz $r_s0, fault; \ 149 + /* Load 4th argument in DS */ \ 150 + LONG_ADDIU a3, zero, SIZE; \ 151 + PTR_ADDIU $r_sp, $r_sp, -(6 * SZREG); \ 152 + PTR_LA t0, skb_copy_bits; \ 153 + PTR_S $r_ra, (5 * SZREG)($r_sp); \ 154 + /* Assign low slot to a2 */ \ 155 + PTR_ADDIU a2, $r_sp, DS_OFFSET(SIZE); \ 156 + jalr t0; \ 157 + /* Reset our destination slot (DS but it's ok) */ \ 158 + INT_S zero, (4 * SZREG)($r_sp); \ 159 + /* \ 160 + * skb_copy_bits returns 0 on success and -EFAULT \ 161 + * on error. Our data live in a2. Do not bother with \ 162 + * our data if an error has been returned. \ 163 + */ \ 164 + /* Restore our frame */ \ 165 + PTR_L $r_ra, (5 * SZREG)($r_sp); \ 166 + INT_L $r_s0, (4 * SZREG)($r_sp); \ 167 + bltz v0, fault; \ 168 + PTR_ADDIU $r_sp, $r_sp, 6 * SZREG; \ 169 + move $r_ret, zero; \ 170 + 171 + NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp) 172 + bpf_slow_path_common(4) 173 + #ifdef CONFIG_CPU_LITTLE_ENDIAN 174 + # if MIPS_ISA_REV >= 2 175 + wsbh t0, $r_s0 176 + jr $r_ra 177 + rotr $r_A, t0, 16 178 + # else 179 + sll t0, $r_s0, 24 180 + srl t1, $r_s0, 24 181 + srl t2, $r_s0, 8 182 + or t0, t0, t1 183 + andi t2, t2, 0xff00 184 + andi t1, $r_s0, 0xff00 185 + or t0, t0, t2 186 + sll t1, t1, 8 187 + jr $r_ra 188 + or $r_A, t0, t1 189 + # endif 190 + #else 191 + jr $r_ra 192 + move $r_A, $r_s0 193 + #endif 194 + 195 + END(bpf_slow_path_word) 196 + 197 + NESTED(bpf_slow_path_half, (6 * SZREG), $r_sp) 198 + bpf_slow_path_common(2) 199 + #ifdef CONFIG_CPU_LITTLE_ENDIAN 200 + # if MIPS_ISA_REV >= 2 201 + jr $r_ra 202 + wsbh $r_A, $r_s0 203 + # else 204 + sll t0, $r_s0, 8 205 + andi t1, $r_s0, 0xff00 206 + andi t0, t0, 0xff00 207 + srl t1, t1, 8 208 + jr $r_ra 209 + or $r_A, t0, t1 210 + # endif 211 + #else 212 + jr $r_ra 213 + move $r_A, $r_s0 214 + #endif 215 + 216 + END(bpf_slow_path_half) 217 + 218 + NESTED(bpf_slow_path_byte, (6 * SZREG), $r_sp) 219 + bpf_slow_path_common(1) 220 + jr $r_ra 221 + move $r_A, $r_s0 222 + 223 + END(bpf_slow_path_byte) 224 + 225 + /* 226 + * Negative entry points 227 + */ 228 + .macro bpf_is_end_of_data 229 + li t0, SKF_LL_OFF 230 + /* Reading link layer data? */ 231 + slt t1, offset, t0 232 + bgtz t1, fault 233 + /* Be careful what follows in DS. */ 234 + .endm 235 + /* 236 + * call skb_copy_bits: 237 + * (prototype in linux/filter.h) 238 + * 239 + * void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, 240 + * int k, unsigned int size) 241 + * 242 + * see above (bpf_slow_path_common) for ABI restrictions 243 + */ 244 + #define bpf_negative_common(SIZE) \ 245 + PTR_ADDIU $r_sp, $r_sp, -(6 * SZREG); \ 246 + PTR_LA t0, bpf_internal_load_pointer_neg_helper; \ 247 + PTR_S $r_ra, (5 * SZREG)($r_sp); \ 248 + jalr t0; \ 249 + li a2, SIZE; \ 250 + PTR_L $r_ra, (5 * SZREG)($r_sp); \ 251 + /* Check return pointer */ \ 252 + beqz v0, fault; \ 253 + PTR_ADDIU $r_sp, $r_sp, 6 * SZREG; \ 254 + /* Preserve our pointer */ \ 255 + move $r_s0, v0; \ 256 + /* Set return value */ \ 257 + move $r_ret, zero; \ 258 + 259 + bpf_slow_path_word_neg: 260 + bpf_is_end_of_data 261 + NESTED(sk_load_word_negative, (6 * SZREG), $r_sp) 262 + bpf_negative_common(4) 263 + jr $r_ra 264 + lw $r_A, 0($r_s0) 265 + END(sk_load_word_negative) 266 + 267 + bpf_slow_path_half_neg: 268 + bpf_is_end_of_data 269 + NESTED(sk_load_half_negative, (6 * SZREG), $r_sp) 270 + bpf_negative_common(2) 271 + jr $r_ra 272 + lhu $r_A, 0($r_s0) 273 + END(sk_load_half_negative) 274 + 275 + bpf_slow_path_byte_neg: 276 + bpf_is_end_of_data 277 + NESTED(sk_load_byte_negative, (6 * SZREG), $r_sp) 278 + bpf_negative_common(1) 279 + jr $r_ra 280 + lbu $r_A, 0($r_s0) 281 + END(sk_load_byte_negative) 282 + 283 + fault: 284 + jr $r_ra 285 + addiu $r_ret, zero, 1
+1 -1
arch/mips/pci/pci-ip27.c
··· 10 10 #include <asm/sn/addrs.h> 11 11 #include <asm/sn/types.h> 12 12 #include <asm/sn/klconfig.h> 13 - #include <asm/sn/hub.h> 13 + #include <asm/sn/agent.h> 14 14 #include <asm/sn/ioc3.h> 15 15 #include <asm/pci/bridge.h> 16 16
+48 -4
arch/mips/pci/pci-xtalk-bridge.c
··· 437 437 struct irq_alloc_info info; 438 438 int irq; 439 439 440 - irq = bc->pci_int[slot]; 440 + switch (pin) { 441 + case PCI_INTERRUPT_UNKNOWN: 442 + case PCI_INTERRUPT_INTA: 443 + case PCI_INTERRUPT_INTC: 444 + pin = 0; 445 + break; 446 + case PCI_INTERRUPT_INTB: 447 + case PCI_INTERRUPT_INTD: 448 + pin = 1; 449 + } 450 + 451 + irq = bc->pci_int[slot][pin]; 441 452 if (irq == -1) { 442 453 info.ctrl = bc; 443 454 info.nasid = bc->nasid; 444 - info.pin = slot; 455 + info.pin = bc->int_mapping[slot][pin]; 445 456 446 457 irq = irq_domain_alloc_irqs(bc->domain, 1, bc->nasid, &info); 447 458 if (irq < 0) 448 459 return irq; 449 460 450 - bc->pci_int[slot] = irq; 461 + bc->pci_int[slot][pin] = irq; 451 462 } 452 463 return irq; 453 464 } ··· 469 458 { 470 459 bc->ioc3_sid[2] = IOC3_SID(IOC3_SUBSYS_IP27_BASEIO6G); 471 460 bc->ioc3_sid[6] = IOC3_SID(IOC3_SUBSYS_IP27_MIO); 461 + bc->int_mapping[2][1] = 4; 462 + bc->int_mapping[6][1] = 6; 472 463 } 473 464 474 465 static void bridge_setup_ip27_baseio(struct bridge_controller *bc) 475 466 { 476 467 bc->ioc3_sid[2] = IOC3_SID(IOC3_SUBSYS_IP27_BASEIO); 468 + bc->int_mapping[2][1] = 4; 477 469 } 478 470 479 471 static void bridge_setup_ip29_baseio(struct bridge_controller *bc) 480 472 { 481 473 bc->ioc3_sid[2] = IOC3_SID(IOC3_SUBSYS_IP29_SYSBOARD); 474 + bc->int_mapping[2][1] = 3; 482 475 } 483 476 484 477 static void bridge_setup_ip30_sysboard(struct bridge_controller *bc) 485 478 { 486 479 bc->ioc3_sid[2] = IOC3_SID(IOC3_SUBSYS_IP30_SYSBOARD); 480 + bc->int_mapping[2][1] = 4; 487 481 } 488 482 489 483 static void bridge_setup_menet(struct bridge_controller *bc) ··· 497 481 bc->ioc3_sid[1] = IOC3_SID(IOC3_SUBSYS_MENET); 498 482 bc->ioc3_sid[2] = IOC3_SID(IOC3_SUBSYS_MENET); 499 483 bc->ioc3_sid[3] = IOC3_SID(IOC3_SUBSYS_MENET4); 484 + } 485 + 486 + static void bridge_setup_io7(struct bridge_controller *bc) 487 + { 488 + bc->ioc3_sid[4] = IOC3_SID(IOC3_SUBSYS_IO7); 489 + } 490 + 491 + static void bridge_setup_io8(struct bridge_controller *bc) 492 + { 493 + bc->ioc3_sid[4] = IOC3_SID(IOC3_SUBSYS_IO8); 494 + } 495 + 496 + static void bridge_setup_io9(struct bridge_controller *bc) 497 + { 498 + bc->ioc3_sid[1] = IOC3_SID(IOC3_SUBSYS_IO9); 499 + } 500 + 501 + static void bridge_setup_ip34_fuel_sysboard(struct bridge_controller *bc) 502 + { 503 + bc->ioc3_sid[4] = IOC3_SID(IOC3_SUBSYS_IP34_SYSBOARD); 500 504 } 501 505 502 506 #define BRIDGE_BOARD_SETUP(_partno, _setup) \ ··· 536 500 BRIDGE_BOARD_SETUP("030-0887-", bridge_setup_ip30_sysboard), 537 501 BRIDGE_BOARD_SETUP("030-1467-", bridge_setup_ip30_sysboard), 538 502 BRIDGE_BOARD_SETUP("030-0873-", bridge_setup_menet), 503 + BRIDGE_BOARD_SETUP("030-1557-", bridge_setup_io7), 504 + BRIDGE_BOARD_SETUP("030-1673-", bridge_setup_io8), 505 + BRIDGE_BOARD_SETUP("030-1771-", bridge_setup_io9), 506 + BRIDGE_BOARD_SETUP("030-1707-", bridge_setup_ip34_fuel_sysboard), 539 507 }; 540 508 541 509 static void bridge_setup_board(struct bridge_controller *bc, char *partnum) ··· 695 655 696 656 for (slot = 0; slot < 8; slot++) { 697 657 bridge_set(bc, b_device[slot].reg, BRIDGE_DEV_SWAP_DIR); 698 - bc->pci_int[slot] = -1; 658 + bc->pci_int[slot][0] = -1; 659 + bc->pci_int[slot][1] = -1; 660 + /* default interrupt pin mapping */ 661 + bc->int_mapping[slot][0] = slot; 662 + bc->int_mapping[slot][1] = slot ^ 4; 699 663 } 700 664 bridge_read(bc, b_wid_tflush); /* wait until Bridge PIO complete */ 701 665
+2
arch/mips/ralink/ill_acc.c
··· 67 67 irq = irq_of_parse_and_map(np, 0); 68 68 if (!irq) { 69 69 dev_err(&pdev->dev, "failed to get irq\n"); 70 + put_device(&pdev->dev); 70 71 return -EINVAL; 71 72 } 72 73 73 74 if (request_irq(irq, ill_acc_irq_handler, 0, "ill_acc", &pdev->dev)) { 74 75 dev_err(&pdev->dev, "failed to request irq\n"); 76 + put_device(&pdev->dev); 75 77 return -EINVAL; 76 78 } 77 79
+3 -3
arch/mips/sgi-ip22/ip22-gio.c
··· 47 47 * Used by a driver to check whether an of_device present in the 48 48 * system is in its list of supported devices. 49 49 */ 50 - const struct gio_device_id *gio_match_device(const struct gio_device_id *match, 51 - const struct gio_device *dev) 50 + static const struct gio_device_id * 51 + gio_match_device(const struct gio_device_id *match, 52 + const struct gio_device *dev) 52 53 { 53 54 const struct gio_device_id *ids; 54 55 ··· 59 58 60 59 return NULL; 61 60 } 62 - EXPORT_SYMBOL_GPL(gio_match_device); 63 61 64 62 struct gio_device *gio_dev_get(struct gio_device *dev) 65 63 {
+21 -19
arch/mips/sgi-ip27/ip27-berr.c
··· 16 16 17 17 #include <asm/ptrace.h> 18 18 #include <asm/sn/addrs.h> 19 + #include <asm/sn/agent.h> 19 20 #include <asm/sn/arch.h> 20 - #include <asm/sn/sn0/hub.h> 21 21 #include <asm/tlbdebug.h> 22 22 #include <asm/traps.h> 23 23 #include <linux/uaccess.h> ··· 30 30 { "WERR", "Uncached Partial Write", "PWERR", "Write Timeout", 31 31 NULL, NULL, NULL, NULL } 32 32 }; 33 - int wrb = errst1 & PI_ERR_ST1_WRBRRB_MASK; 33 + union pi_err_stat0 st0; 34 + union pi_err_stat1 st1; 34 35 35 - if (!(errst0 & PI_ERR_ST0_VALID_MASK)) { 36 - printk("Hub does not contain valid error information\n"); 36 + st0.pi_stat0_word = errst0; 37 + st1.pi_stat1_word = errst1; 38 + 39 + if (!st0.pi_stat0_fmt.s0_valid) { 40 + pr_info("Hub does not contain valid error information\n"); 37 41 return; 38 42 } 39 43 40 - 41 - printk("Hub has valid error information:\n"); 42 - if (errst0 & PI_ERR_ST0_OVERRUN_MASK) 43 - printk("Overrun is set. Error stack may contain additional " 44 + pr_info("Hub has valid error information:\n"); 45 + if (st0.pi_stat0_fmt.s0_ovr_run) 46 + pr_info("Overrun is set. Error stack may contain additional " 44 47 "information.\n"); 45 - printk("Hub error address is %08lx\n", 46 - (errst0 & PI_ERR_ST0_ADDR_MASK) >> (PI_ERR_ST0_ADDR_SHFT - 3)); 47 - printk("Incoming message command 0x%lx\n", 48 - (errst0 & PI_ERR_ST0_CMD_MASK) >> PI_ERR_ST0_CMD_SHFT); 49 - printk("Supplemental field of incoming message is 0x%lx\n", 50 - (errst0 & PI_ERR_ST0_SUPPL_MASK) >> PI_ERR_ST0_SUPPL_SHFT); 51 - printk("T5 Rn (for RRB only) is 0x%lx\n", 52 - (errst0 & PI_ERR_ST0_REQNUM_MASK) >> PI_ERR_ST0_REQNUM_SHFT); 53 - printk("Error type is %s\n", err_type[wrb] 54 - [(errst0 & PI_ERR_ST0_TYPE_MASK) >> PI_ERR_ST0_TYPE_SHFT] 55 - ? : "invalid"); 48 + pr_info("Hub error address is %08lx\n", 49 + (unsigned long)st0.pi_stat0_fmt.s0_addr); 50 + pr_info("Incoming message command 0x%lx\n", 51 + (unsigned long)st0.pi_stat0_fmt.s0_cmd); 52 + pr_info("Supplemental field of incoming message is 0x%lx\n", 53 + (unsigned long)st0.pi_stat0_fmt.s0_supl); 54 + pr_info("T5 Rn (for RRB only) is 0x%lx\n", 55 + (unsigned long)st0.pi_stat0_fmt.s0_t5_req); 56 + pr_info("Error type is %s\n", err_type[st1.pi_stat1_fmt.s1_rw_rb] 57 + [st0.pi_stat0_fmt.s0_err_type] ? : "invalid"); 56 58 } 57 59 58 60 int ip27_be_handler(struct pt_regs *regs, int is_fixup)
+11 -1
arch/mips/sgi-ip27/ip27-common.h
··· 3 3 #ifndef __IP27_COMMON_H 4 4 #define __IP27_COMMON_H 5 5 6 - extern void ip27_reboot_setup(void); 6 + extern nasid_t master_nasid; 7 + 8 + extern void cpu_node_probe(void); 7 9 extern void hub_rt_clock_event_init(void); 10 + extern void hub_rtc_init(nasid_t nasid); 11 + extern void install_cpu_nmi_handler(int slice); 12 + extern void install_ipi(void); 13 + extern void ip27_reboot_setup(void); 8 14 extern const struct plat_smp_ops ip27_smp_ops; 15 + extern unsigned long node_getfirstfree(nasid_t nasid); 16 + extern void per_cpu_init(void); 17 + extern void replicate_kernel_text(void); 18 + extern void setup_replication_mask(void); 9 19 10 20 #endif /* __IP27_COMMON_H */
+3 -2
arch/mips/sgi-ip27/ip27-console.c
··· 9 9 #include <asm/page.h> 10 10 #include <asm/setup.h> 11 11 #include <asm/sn/addrs.h> 12 - #include <asm/sn/sn0/hub.h> 12 + #include <asm/sn/agent.h> 13 13 #include <asm/sn/klconfig.h> 14 14 #include <asm/sn/ioc3.h> 15 - #include <asm/sn/sn_private.h> 16 15 17 16 #include <linux/serial.h> 18 17 #include <linux/serial_core.h> 18 + 19 + #include "ip27-common.h" 19 20 20 21 #define IOC3_CLK (22000000 / 3) 21 22 #define IOC3_FLAGS (0)
+5 -3
arch/mips/sgi-ip27/ip27-hubio.c
··· 11 11 #include <linux/mmzone.h> 12 12 #include <asm/sn/addrs.h> 13 13 #include <asm/sn/arch.h> 14 - #include <asm/sn/hub.h> 14 + #include <asm/sn/agent.h> 15 + #include <asm/sn/io.h> 16 + #include <asm/xtalk/xtalk.h> 15 17 16 18 17 19 static int force_fire_and_forget = 1; ··· 84 82 */ 85 83 static void hub_setup_prb(nasid_t nasid, int prbnum, int credits) 86 84 { 87 - iprb_t prb; 85 + union iprb_u prb; 88 86 int prb_offset; 89 87 90 88 /* ··· 137 135 static void hub_set_piomode(nasid_t nasid) 138 136 { 139 137 u64 ii_iowa; 140 - hubii_wcr_t ii_wcr; 138 + union hubii_wcr_u ii_wcr; 141 139 unsigned i; 142 140 143 141 ii_iowa = REMOTE_HUB_L(nasid, IIO_OUTWIDGET_ACCESS);
+3 -22
arch/mips/sgi-ip27/ip27-init.c
··· 19 19 #include <asm/pgtable.h> 20 20 #include <asm/sgialib.h> 21 21 #include <asm/time.h> 22 + #include <asm/sn/agent.h> 22 23 #include <asm/sn/types.h> 23 - #include <asm/sn/sn0/addrs.h> 24 - #include <asm/sn/sn0/hubni.h> 25 - #include <asm/sn/sn0/hubio.h> 26 24 #include <asm/sn/klconfig.h> 27 25 #include <asm/sn/ioc3.h> 28 26 #include <asm/mipsregs.h> 29 27 #include <asm/sn/gda.h> 30 - #include <asm/sn/hub.h> 31 28 #include <asm/sn/intr.h> 32 29 #include <asm/current.h> 33 30 #include <asm/processor.h> 34 31 #include <asm/mmu_context.h> 35 32 #include <asm/thread_info.h> 36 33 #include <asm/sn/launch.h> 37 - #include <asm/sn/sn_private.h> 38 - #include <asm/sn/sn0/ip27.h> 39 34 #include <asm/sn/mapped_kernel.h> 40 35 41 36 #include "ip27-common.h" ··· 72 77 void per_cpu_init(void) 73 78 { 74 79 int cpu = smp_processor_id(); 75 - int slice = LOCAL_HUB_L(PI_CPU_NUM); 76 80 nasid_t nasid = get_nasid(); 77 - struct hub_data *hub = hub_data(nasid); 78 - 79 - if (test_and_set_bit(slice, &hub->slice_map)) 80 - return; 81 81 82 82 clear_c0_status(ST0_IM); 83 83 84 84 per_hub_init(nasid); 85 85 86 - cpu_time_init(); 86 + pr_info("CPU %d clock is %dMHz.\n", cpu, sn_cpu_info[cpu].p_speed); 87 + 87 88 install_ipi(); 88 89 89 90 /* Install our NMI handler if symmon hasn't installed one. */ ··· 87 96 88 97 enable_percpu_irq(IP27_HUB_PEND0_IRQ, IRQ_TYPE_NONE); 89 98 enable_percpu_irq(IP27_HUB_PEND1_IRQ, IRQ_TYPE_NONE); 90 - } 91 - 92 - /* 93 - * get_nasid() returns the physical node id number of the caller. 94 - */ 95 - nasid_t 96 - get_nasid(void) 97 - { 98 - return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK) 99 - >> NSRI_NODEID_SHFT); 100 99 } 101 100 102 101 void __init plat_mem_setup(void)
+1 -4
arch/mips/sgi-ip27/ip27-irq.c
··· 19 19 #include <asm/sn/addrs.h> 20 20 #include <asm/sn/agent.h> 21 21 #include <asm/sn/arch.h> 22 - #include <asm/sn/hub.h> 23 22 #include <asm/sn/intr.h> 24 23 #include <asm/sn/irq_alloc.h> 25 24 ··· 287 288 * Mark these as reserved right away so they won't be used accidentally 288 289 * later. 289 290 */ 290 - for (i = 0; i <= BASE_PCI_IRQ; i++) 291 + for (i = 0; i <= CPU_CALL_B_IRQ; i++) 291 292 set_bit(i, hub_irq_map); 292 - 293 - set_bit(IP_PEND0_6_63, hub_irq_map); 294 293 295 294 for (i = NI_BRDCAST_ERR_A; i <= MSC_PANIC_INTR; i++) 296 295 set_bit(i, hub_irq_map);
-51
arch/mips/sgi-ip27/ip27-klconfig.c
··· 72 72 /* Didn't find it. */ 73 73 return (lboard_t *)NULL; 74 74 } 75 - 76 - klcpu_t *nasid_slice_to_cpuinfo(nasid_t nasid, int slice) 77 - { 78 - lboard_t *brd; 79 - klcpu_t *acpu; 80 - 81 - if (!(brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27))) 82 - return (klcpu_t *)NULL; 83 - 84 - if (!(acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU))) 85 - return (klcpu_t *)NULL; 86 - 87 - do { 88 - if ((acpu->cpu_info.physid) == slice) 89 - return acpu; 90 - } while ((acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu, 91 - KLSTRUCT_CPU))); 92 - return (klcpu_t *)NULL; 93 - } 94 - 95 - klcpu_t *sn_get_cpuinfo(cpuid_t cpu) 96 - { 97 - nasid_t nasid; 98 - int slice; 99 - klcpu_t *acpu; 100 - 101 - if (!(cpu < MAXCPUS)) { 102 - printk("sn_get_cpuinfo: illegal cpuid 0x%lx\n", cpu); 103 - return NULL; 104 - } 105 - 106 - nasid = cputonasid(cpu); 107 - if (nasid == INVALID_NASID) 108 - return NULL; 109 - 110 - for (slice = 0; slice < CPUS_PER_NODE; slice++) { 111 - acpu = nasid_slice_to_cpuinfo(nasid, slice); 112 - if (acpu && acpu->cpu_info.virtid == cpu) 113 - return acpu; 114 - } 115 - return NULL; 116 - } 117 - 118 - int get_cpu_slice(cpuid_t cpu) 119 - { 120 - klcpu_t *acpu; 121 - 122 - if ((acpu = sn_get_cpuinfo(cpu)) == NULL) 123 - return -1; 124 - return acpu->cpu_info.physid; 125 - }
+8 -8
arch/mips/sgi-ip27/ip27-klnuma.c
··· 16 16 #include <asm/sn/types.h> 17 17 #include <asm/sn/arch.h> 18 18 #include <asm/sn/gda.h> 19 - #include <asm/sn/hub.h> 20 19 #include <asm/sn/mapped_kernel.h> 21 - #include <asm/sn/sn_private.h> 22 20 23 - static cpumask_t ktext_repmask; 21 + #include "ip27-common.h" 22 + 23 + static nodemask_t ktext_repmask; 24 24 25 25 /* 26 26 * XXX - This needs to be much smarter about where it puts copies of the ··· 30 30 void __init setup_replication_mask(void) 31 31 { 32 32 /* Set only the master cnode's bit. The master cnode is always 0. */ 33 - cpumask_clear(&ktext_repmask); 34 - cpumask_set_cpu(0, &ktext_repmask); 33 + nodes_clear(ktext_repmask); 34 + node_set(0, ktext_repmask); 35 35 36 36 #ifdef CONFIG_REPLICATE_KTEXT 37 37 #ifndef CONFIG_MAPPED_KERNEL ··· 44 44 if (nasid == 0) 45 45 continue; 46 46 /* Advertise that we have a copy of the kernel */ 47 - cpumask_set_cpu(nasid, &ktext_repmask); 47 + node_set(nasid, ktext_repmask); 48 48 } 49 49 } 50 50 #endif ··· 98 98 continue; 99 99 100 100 /* Check if this node should get a copy of the kernel */ 101 - if (cpumask_test_cpu(client_nasid, &ktext_repmask)) { 101 + if (node_isset(client_nasid, ktext_repmask)) { 102 102 server_nasid = client_nasid; 103 103 copy_kernel(server_nasid); 104 104 } ··· 122 122 loadbase += 16777216; 123 123 #endif 124 124 offset = PAGE_ALIGN((unsigned long)(&_end)) - loadbase; 125 - if ((nasid == 0) || (cpumask_test_cpu(nasid, &ktext_repmask))) 125 + if ((nasid == 0) || (node_isset(nasid, ktext_repmask))) 126 126 return TO_NODE(nasid, offset) >> PAGE_SHIFT; 127 127 else 128 128 return KDM_TO_PHYS(PAGE_ALIGN(SYMMON_STK_ADDR(nasid, 0))) >> PAGE_SHIFT;
+22 -35
arch/mips/sgi-ip27/ip27-memory.c
··· 25 25 #include <asm/sections.h> 26 26 27 27 #include <asm/sn/arch.h> 28 - #include <asm/sn/hub.h> 28 + #include <asm/sn/agent.h> 29 29 #include <asm/sn/klconfig.h> 30 - #include <asm/sn/sn_private.h> 31 30 31 + #include "ip27-common.h" 32 32 33 33 #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) 34 34 #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) ··· 37 37 38 38 EXPORT_SYMBOL(__node_data); 39 39 40 - static int fine_mode; 41 - 42 - static int is_fine_dirmode(void) 40 + static u64 gen_region_mask(void) 43 41 { 44 - return ((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK) >> NSRI_REGIONSIZE_SHFT) & REGIONSIZE_FINE; 45 - } 46 - 47 - static u64 get_region(nasid_t nasid) 48 - { 49 - if (fine_mode) 50 - return nasid >> NASID_TO_FINEREG_SHFT; 51 - else 52 - return nasid >> NASID_TO_COARSEREG_SHFT; 53 - } 54 - 55 - static u64 region_mask; 56 - 57 - static void gen_region_mask(u64 *region_mask) 58 - { 42 + int region_shift; 43 + u64 region_mask; 59 44 nasid_t nasid; 60 45 61 - (*region_mask) = 0; 62 - for_each_online_node(nasid) { 63 - (*region_mask) |= 1ULL << get_region(nasid); 64 - } 46 + region_shift = get_region_shift(); 47 + region_mask = 0; 48 + for_each_online_node(nasid) 49 + region_mask |= BIT_ULL(nasid >> region_shift); 50 + 51 + return region_mask; 65 52 } 66 53 67 54 #define rou_rflag rou_flags ··· 135 148 } while ((brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER))); 136 149 } 137 150 151 + if (nasid_a == nasid_b) 152 + return LOCAL_DISTANCE; 153 + 154 + if (router_a == router_b) 155 + return LOCAL_DISTANCE + 1; 156 + 138 157 if (router_a == NULL) { 139 158 pr_info("node_distance: router_a NULL\n"); 140 - return -1; 159 + return 255; 141 160 } 142 161 if (router_b == NULL) { 143 162 pr_info("node_distance: router_b NULL\n"); 144 - return -1; 163 + return 255; 145 164 } 146 - 147 - if (nasid_a == nasid_b) 148 - return 0; 149 - 150 - if (router_a == router_b) 151 - return 1; 152 165 153 166 router_distance = 100; 154 167 router_recurse(router_a, router_b, 2); 155 168 156 - return router_distance; 169 + return LOCAL_DISTANCE + router_distance; 157 170 } 158 171 159 172 static void __init init_topology_matrix(void) ··· 268 281 269 282 static void __init mlreset(void) 270 283 { 284 + u64 region_mask; 271 285 nasid_t nasid; 272 286 273 287 master_nasid = get_nasid(); 274 - fine_mode = is_fine_dirmode(); 275 288 276 289 /* 277 290 * Probe for all CPUs - this creates the cpumask and sets up the ··· 284 297 init_topology_matrix(); 285 298 dump_topology(); 286 299 287 - gen_region_mask(&region_mask); 300 + region_mask = gen_region_mask(); 288 301 289 302 setup_replication_mask(); 290 303
+4 -1
arch/mips/sgi-ip27/ip27-nmi.c
··· 9 9 #include <asm/sn/addrs.h> 10 10 #include <asm/sn/nmi.h> 11 11 #include <asm/sn/arch.h> 12 - #include <asm/sn/sn0/hub.h> 12 + #include <asm/sn/agent.h> 13 13 14 14 #if 0 15 15 #define NODE_NUM_CPUS(n) CNODE_NUM_CPUS(n) 16 16 #else 17 17 #define NODE_NUM_CPUS(n) CPUS_PER_NODE 18 18 #endif 19 + 20 + #define SEND_NMI(_nasid, _slice) \ 21 + REMOTE_HUB_S((_nasid), (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1) 19 22 20 23 typedef unsigned long machreg_t; 21 24
+1 -1
arch/mips/sgi-ip27/ip27-reset.c
··· 22 22 #include <asm/reboot.h> 23 23 #include <asm/sgialib.h> 24 24 #include <asm/sn/addrs.h> 25 + #include <asm/sn/agent.h> 25 26 #include <asm/sn/arch.h> 26 27 #include <asm/sn/gda.h> 27 - #include <asm/sn/sn0/hub.h> 28 28 29 29 #include "ip27-common.h" 30 30
+11 -22
arch/mips/sgi-ip27/ip27-smp.c
··· 15 15 #include <asm/page.h> 16 16 #include <asm/processor.h> 17 17 #include <asm/ptrace.h> 18 + #include <asm/sn/agent.h> 18 19 #include <asm/sn/arch.h> 19 20 #include <asm/sn/gda.h> 20 21 #include <asm/sn/intr.h> 21 22 #include <asm/sn/klconfig.h> 22 23 #include <asm/sn/launch.h> 23 24 #include <asm/sn/mapped_kernel.h> 24 - #include <asm/sn/sn_private.h> 25 25 #include <asm/sn/types.h> 26 - #include <asm/sn/sn0/hubpi.h> 27 - #include <asm/sn/sn0/hubio.h> 28 - #include <asm/sn/sn0/ip27.h> 29 26 30 27 #include "ip27-common.h" 31 28 32 - /* 33 - * Takes as first input the PROM assigned cpu id, and the kernel 34 - * assigned cpu id as the second. 35 - */ 36 - static void alloc_cpupda(nasid_t nasid, cpuid_t cpu, int cpunum) 29 + static int node_scan_cpus(nasid_t nasid, int highest) 37 30 { 38 - cputonasid(cpunum) = nasid; 39 - cputoslice(cpunum) = get_cpu_slice(cpu); 40 - } 41 - 42 - static int do_cpumask(nasid_t nasid, int highest) 43 - { 44 - static int tot_cpus_found = 0; 31 + static int cpus_found; 45 32 lboard_t *brd; 46 33 klcpu_t *acpu; 47 - int cpus_found = 0; 48 34 cpuid_t cpuid; 49 35 50 36 brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27); ··· 41 55 cpuid = acpu->cpu_info.virtid; 42 56 /* Only let it join in if it's marked enabled */ 43 57 if ((acpu->cpu_info.flags & KLINFO_ENABLE) && 44 - (tot_cpus_found != NR_CPUS)) { 58 + (cpus_found != NR_CPUS)) { 45 59 if (cpuid > highest) 46 60 highest = cpuid; 47 61 set_cpu_possible(cpuid, true); 48 - alloc_cpupda(nasid, cpuid, tot_cpus_found); 62 + cputonasid(cpus_found) = nasid; 63 + cputoslice(cpus_found) = acpu->cpu_info.physid; 64 + sn_cpu_info[cpus_found].p_speed = 65 + acpu->cpu_speed; 49 66 cpus_found++; 50 - tot_cpus_found++; 51 67 } 52 68 acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu, 53 69 KLSTRUCT_CPU); ··· 75 87 if (nasid == INVALID_NASID) 76 88 break; 77 89 node_set_online(nasid); 78 - highest = do_cpumask(nasid, highest); 90 + highest = node_scan_cpus(nasid, highest); 79 91 } 80 92 81 93 printk("Discovered %d cpus on %d nodes\n", highest + 1, num_online_nodes()); ··· 168 180 /* 169 181 * PROM sets up system, that boot cpu is always first CPU on nasid 0 170 182 */ 171 - alloc_cpupda(0, 0, 0); 183 + cputonasid(0) = 0; 184 + cputoslice(0) = LOCAL_HUB_L(PI_CPU_NUM); 172 185 } 173 186 174 187 static void __init ip27_prepare_cpus(unsigned int max_cpus)
+3 -45
arch/mips/sgi-ip27/ip27-timer.c
··· 25 25 #include <asm/sn/klconfig.h> 26 26 #include <asm/sn/arch.h> 27 27 #include <asm/sn/addrs.h> 28 - #include <asm/sn/sn_private.h> 29 - #include <asm/sn/sn0/ip27.h> 30 - #include <asm/sn/sn0/hub.h> 28 + #include <asm/sn/agent.h> 29 + 30 + #include "ip27-common.h" 31 31 32 32 #define TICK_SIZE (tick_nsec / 1000) 33 33 34 34 /* Includes for ioc3_init(). */ 35 35 #include <asm/sn/types.h> 36 - #include <asm/sn/sn0/addrs.h> 37 - #include <asm/sn/sn0/hubni.h> 38 - #include <asm/sn/sn0/hubio.h> 39 36 #include <asm/pci/bridge.h> 40 37 41 38 #include "ip27-common.h" ··· 150 153 hub_rt_clock_event_init(); 151 154 } 152 155 153 - void cpu_time_init(void) 154 - { 155 - lboard_t *board; 156 - klcpu_t *cpu; 157 - int cpuid; 158 - 159 - /* Don't use ARCS. ARCS is fragile. Klconfig is simple and sane. */ 160 - board = find_lboard(KL_CONFIG_INFO(get_nasid()), KLTYPE_IP27); 161 - if (!board) 162 - panic("Can't find board info for myself."); 163 - 164 - cpuid = LOCAL_HUB_L(PI_CPU_NUM) ? IP27_CPU0_INDEX : IP27_CPU1_INDEX; 165 - cpu = (klcpu_t *) KLCF_COMP(board, cpuid); 166 - if (!cpu) 167 - panic("No information about myself?"); 168 - 169 - printk("CPU %d clock is %dMHz.\n", smp_processor_id(), cpu->cpu_speed); 170 - } 171 - 172 156 void hub_rtc_init(nasid_t nasid) 173 157 { 174 158 ··· 168 190 LOCAL_HUB_S(PI_RT_PEND_B, 0); 169 191 } 170 192 } 171 - 172 - static int __init sgi_ip27_rtc_devinit(void) 173 - { 174 - struct resource res; 175 - 176 - memset(&res, 0, sizeof(res)); 177 - res.start = XPHYSADDR(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base + 178 - IOC3_BYTEBUS_DEV0); 179 - res.end = res.start + 32767; 180 - res.flags = IORESOURCE_MEM; 181 - 182 - return IS_ERR(platform_device_register_simple("rtc-m48t35", -1, 183 - &res, 1)); 184 - } 185 - 186 - /* 187 - * kludge make this a device_initcall after ioc3 resource conflicts 188 - * are resolved 189 - */ 190 - late_initcall(sgi_ip27_rtc_devinit);
-1
arch/mips/sgi-ip27/ip27-xtalk.c
··· 15 15 #include <asm/sn/addrs.h> 16 16 #include <asm/sn/types.h> 17 17 #include <asm/sn/klconfig.h> 18 - #include <asm/sn/hub.h> 19 18 #include <asm/pci/bridge.h> 20 19 #include <asm/xtalk/xtalk.h> 21 20
+3 -2
arch/mips/sgi-ip30/ip30-irq.c
··· 232 232 return; 233 233 234 234 irqd = irq_domain_get_irq_data(domain, virq); 235 - clear_bit(irqd->hwirq, heart_irq_map); 236 - if (irqd && irqd->chip_data) 235 + if (irqd) { 236 + clear_bit(irqd->hwirq, heart_irq_map); 237 237 kfree(irqd->chip_data); 238 + } 238 239 } 239 240 240 241 static const struct irq_domain_ops heart_domain_ops = {
+13
arch/mips/vdso/genvdso.c
··· 251 251 fprintf(out_file, "#include <linux/linkage.h>\n"); 252 252 fprintf(out_file, "#include <linux/mm.h>\n"); 253 253 fprintf(out_file, "#include <asm/vdso.h>\n"); 254 + fprintf(out_file, "static int vdso_mremap(\n"); 255 + fprintf(out_file, " const struct vm_special_mapping *sm,\n"); 256 + fprintf(out_file, " struct vm_area_struct *new_vma)\n"); 257 + fprintf(out_file, "{\n"); 258 + fprintf(out_file, " unsigned long new_size =\n"); 259 + fprintf(out_file, " new_vma->vm_end - new_vma->vm_start;\n"); 260 + fprintf(out_file, " if (vdso_image.size != new_size)\n"); 261 + fprintf(out_file, " return -EINVAL;\n"); 262 + fprintf(out_file, " current->mm->context.vdso =\n"); 263 + fprintf(out_file, " (void __user *)(new_vma->vm_start);\n"); 264 + fprintf(out_file, " return 0;\n"); 265 + fprintf(out_file, "}\n"); 254 266 255 267 /* Write out the stripped VDSO data. */ 256 268 fprintf(out_file, ··· 287 275 fprintf(out_file, "\t.mapping = {\n"); 288 276 fprintf(out_file, "\t\t.name = \"[vdso]\",\n"); 289 277 fprintf(out_file, "\t\t.pages = vdso_pages,\n"); 278 + fprintf(out_file, "\t\t.mremap = vdso_mremap,\n"); 290 279 fprintf(out_file, "\t},\n"); 291 280 292 281 /* Calculate and write symbol offsets to <output file> */
+13
drivers/mfd/Kconfig
··· 2004 2004 Select this to get support for the Supervisory Processor 2005 2005 device found on several devices in RAVE line of hardware. 2006 2006 2007 + config SGI_MFD_IOC3 2008 + tristate "SGI IOC3 core driver" 2009 + depends on PCI && MIPS && 64BIT 2010 + select MFD_CORE 2011 + help 2012 + This option enables basic support for the SGI IOC3-based 2013 + controller cards. This option does not enable any specific 2014 + functions on such a card, but provides necessary infrastructure 2015 + for other drivers to utilize. 2016 + 2017 + If you have an SGI Origin, Octane, or a PCI IOC3 card, 2018 + then say Y. Otherwise say N. 2019 + 2007 2020 endmenu 2008 2021 endif
+1
drivers/mfd/Makefile
··· 255 255 obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o 256 256 obj-$(CONFIG_MFD_STMFX) += stmfx.o 257 257 258 + obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
+669
drivers/mfd/ioc3.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * SGI IOC3 multifunction device driver 4 + * 5 + * Copyright (C) 2018, 2019 Thomas Bogendoerfer <tbogendoerfer@suse.de> 6 + * 7 + * Based on work by: 8 + * Stanislaw Skowronek <skylark@unaligned.org> 9 + * Joshua Kinard <kumba@gentoo.org> 10 + * Brent Casavant <bcasavan@sgi.com> - IOC4 master driver 11 + * Pat Gefre <pfg@sgi.com> - IOC3 serial port IRQ demuxer 12 + */ 13 + 14 + #include <linux/delay.h> 15 + #include <linux/errno.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/mfd/core.h> 18 + #include <linux/module.h> 19 + #include <linux/pci.h> 20 + #include <linux/platform_device.h> 21 + #include <linux/platform_data/sgi-w1.h> 22 + #include <linux/rtc/ds1685.h> 23 + 24 + #include <asm/pci/bridge.h> 25 + #include <asm/sn/ioc3.h> 26 + 27 + #define IOC3_IRQ_SERIAL_A 6 28 + #define IOC3_IRQ_SERIAL_B 15 29 + #define IOC3_IRQ_KBD 22 30 + 31 + /* Bitmask for selecting which IRQs are level triggered */ 32 + #define IOC3_LVL_MASK (BIT(IOC3_IRQ_SERIAL_A) | BIT(IOC3_IRQ_SERIAL_B)) 33 + 34 + #define M48T35_REG_SIZE 32768 /* size of m48t35 registers */ 35 + 36 + /* 1.2 us latency timer (40 cycles at 33 MHz) */ 37 + #define IOC3_LATENCY 40 38 + 39 + struct ioc3_priv_data { 40 + struct irq_domain *domain; 41 + struct ioc3 __iomem *regs; 42 + struct pci_dev *pdev; 43 + int domain_irq; 44 + }; 45 + 46 + static void ioc3_irq_ack(struct irq_data *d) 47 + { 48 + struct ioc3_priv_data *ipd = irq_data_get_irq_chip_data(d); 49 + unsigned int hwirq = irqd_to_hwirq(d); 50 + 51 + writel(BIT(hwirq), &ipd->regs->sio_ir); 52 + } 53 + 54 + static void ioc3_irq_mask(struct irq_data *d) 55 + { 56 + struct ioc3_priv_data *ipd = irq_data_get_irq_chip_data(d); 57 + unsigned int hwirq = irqd_to_hwirq(d); 58 + 59 + writel(BIT(hwirq), &ipd->regs->sio_iec); 60 + } 61 + 62 + static void ioc3_irq_unmask(struct irq_data *d) 63 + { 64 + struct ioc3_priv_data *ipd = irq_data_get_irq_chip_data(d); 65 + unsigned int hwirq = irqd_to_hwirq(d); 66 + 67 + writel(BIT(hwirq), &ipd->regs->sio_ies); 68 + } 69 + 70 + static struct irq_chip ioc3_irq_chip = { 71 + .name = "IOC3", 72 + .irq_ack = ioc3_irq_ack, 73 + .irq_mask = ioc3_irq_mask, 74 + .irq_unmask = ioc3_irq_unmask, 75 + }; 76 + 77 + static int ioc3_irq_domain_map(struct irq_domain *d, unsigned int irq, 78 + irq_hw_number_t hwirq) 79 + { 80 + /* Set level IRQs for every interrupt contained in IOC3_LVL_MASK */ 81 + if (BIT(hwirq) & IOC3_LVL_MASK) 82 + irq_set_chip_and_handler(irq, &ioc3_irq_chip, handle_level_irq); 83 + else 84 + irq_set_chip_and_handler(irq, &ioc3_irq_chip, handle_edge_irq); 85 + 86 + irq_set_chip_data(irq, d->host_data); 87 + return 0; 88 + } 89 + 90 + static void ioc3_irq_domain_unmap(struct irq_domain *d, unsigned int irq) 91 + { 92 + irq_set_chip_and_handler(irq, NULL, NULL); 93 + irq_set_chip_data(irq, NULL); 94 + } 95 + 96 + static const struct irq_domain_ops ioc3_irq_domain_ops = { 97 + .map = ioc3_irq_domain_map, 98 + .unmap = ioc3_irq_domain_unmap, 99 + }; 100 + 101 + static void ioc3_irq_handler(struct irq_desc *desc) 102 + { 103 + struct irq_domain *domain = irq_desc_get_handler_data(desc); 104 + struct ioc3_priv_data *ipd = domain->host_data; 105 + struct ioc3 __iomem *regs = ipd->regs; 106 + u32 pending, mask; 107 + unsigned int irq; 108 + 109 + pending = readl(&regs->sio_ir); 110 + mask = readl(&regs->sio_ies); 111 + pending &= mask; /* Mask off not enabled interrupts */ 112 + 113 + if (pending) { 114 + irq = irq_find_mapping(domain, __ffs(pending)); 115 + if (irq) 116 + generic_handle_irq(irq); 117 + } else { 118 + spurious_interrupt(); 119 + } 120 + } 121 + 122 + /* 123 + * System boards/BaseIOs use more interrupt pins of the bridge ASIC 124 + * to which the IOC3 is connected. Since the IOC3 MFD driver 125 + * knows wiring of these extra pins, we use the map_irq function 126 + * to get interrupts activated 127 + */ 128 + static int ioc3_map_irq(struct pci_dev *pdev, int slot, int pin) 129 + { 130 + struct pci_host_bridge *hbrg = pci_find_host_bridge(pdev->bus); 131 + 132 + return hbrg->map_irq(pdev, slot, pin); 133 + } 134 + 135 + static int ioc3_irq_domain_setup(struct ioc3_priv_data *ipd, int irq) 136 + { 137 + struct irq_domain *domain; 138 + struct fwnode_handle *fn; 139 + 140 + fn = irq_domain_alloc_named_fwnode("IOC3"); 141 + if (!fn) 142 + goto err; 143 + 144 + domain = irq_domain_create_linear(fn, 24, &ioc3_irq_domain_ops, ipd); 145 + if (!domain) 146 + goto err; 147 + 148 + irq_domain_free_fwnode(fn); 149 + ipd->domain = domain; 150 + 151 + irq_set_chained_handler_and_data(irq, ioc3_irq_handler, domain); 152 + ipd->domain_irq = irq; 153 + return 0; 154 + 155 + err: 156 + dev_err(&ipd->pdev->dev, "irq domain setup failed\n"); 157 + return -ENOMEM; 158 + } 159 + 160 + static struct resource ioc3_uarta_resources[] = { 161 + DEFINE_RES_MEM(offsetof(struct ioc3, sregs.uarta), 162 + sizeof_field(struct ioc3, sregs.uarta)), 163 + DEFINE_RES_IRQ(IOC3_IRQ_SERIAL_A) 164 + }; 165 + 166 + static struct resource ioc3_uartb_resources[] = { 167 + DEFINE_RES_MEM(offsetof(struct ioc3, sregs.uartb), 168 + sizeof_field(struct ioc3, sregs.uartb)), 169 + DEFINE_RES_IRQ(IOC3_IRQ_SERIAL_B) 170 + }; 171 + 172 + static struct mfd_cell ioc3_serial_cells[] = { 173 + { 174 + .name = "ioc3-serial8250", 175 + .resources = ioc3_uarta_resources, 176 + .num_resources = ARRAY_SIZE(ioc3_uarta_resources), 177 + }, 178 + { 179 + .name = "ioc3-serial8250", 180 + .resources = ioc3_uartb_resources, 181 + .num_resources = ARRAY_SIZE(ioc3_uartb_resources), 182 + } 183 + }; 184 + 185 + static int ioc3_serial_setup(struct ioc3_priv_data *ipd) 186 + { 187 + int ret; 188 + 189 + /* Set gpio pins for RS232/RS422 mode selection */ 190 + writel(GPCR_UARTA_MODESEL | GPCR_UARTB_MODESEL, 191 + &ipd->regs->gpcr_s); 192 + /* Select RS232 mode for uart a */ 193 + writel(0, &ipd->regs->gppr[6]); 194 + /* Select RS232 mode for uart b */ 195 + writel(0, &ipd->regs->gppr[7]); 196 + 197 + /* Switch both ports to 16650 mode */ 198 + writel(readl(&ipd->regs->port_a.sscr) & ~SSCR_DMA_EN, 199 + &ipd->regs->port_a.sscr); 200 + writel(readl(&ipd->regs->port_b.sscr) & ~SSCR_DMA_EN, 201 + &ipd->regs->port_b.sscr); 202 + udelay(1000); /* Wait until mode switch is done */ 203 + 204 + ret = mfd_add_devices(&ipd->pdev->dev, PLATFORM_DEVID_AUTO, 205 + ioc3_serial_cells, ARRAY_SIZE(ioc3_serial_cells), 206 + &ipd->pdev->resource[0], 0, ipd->domain); 207 + if (ret) { 208 + dev_err(&ipd->pdev->dev, "Failed to add 16550 subdevs\n"); 209 + return ret; 210 + } 211 + 212 + return 0; 213 + } 214 + 215 + static struct resource ioc3_kbd_resources[] = { 216 + DEFINE_RES_MEM(offsetof(struct ioc3, serio), 217 + sizeof_field(struct ioc3, serio)), 218 + DEFINE_RES_IRQ(IOC3_IRQ_KBD) 219 + }; 220 + 221 + static struct mfd_cell ioc3_kbd_cells[] = { 222 + { 223 + .name = "ioc3-kbd", 224 + .resources = ioc3_kbd_resources, 225 + .num_resources = ARRAY_SIZE(ioc3_kbd_resources), 226 + } 227 + }; 228 + 229 + static int ioc3_kbd_setup(struct ioc3_priv_data *ipd) 230 + { 231 + int ret; 232 + 233 + ret = mfd_add_devices(&ipd->pdev->dev, PLATFORM_DEVID_AUTO, 234 + ioc3_kbd_cells, ARRAY_SIZE(ioc3_kbd_cells), 235 + &ipd->pdev->resource[0], 0, ipd->domain); 236 + if (ret) { 237 + dev_err(&ipd->pdev->dev, "Failed to add 16550 subdevs\n"); 238 + return ret; 239 + } 240 + 241 + return 0; 242 + } 243 + 244 + static struct resource ioc3_eth_resources[] = { 245 + DEFINE_RES_MEM(offsetof(struct ioc3, eth), 246 + sizeof_field(struct ioc3, eth)), 247 + DEFINE_RES_MEM(offsetof(struct ioc3, ssram), 248 + sizeof_field(struct ioc3, ssram)), 249 + DEFINE_RES_IRQ(0) 250 + }; 251 + 252 + static struct resource ioc3_w1_resources[] = { 253 + DEFINE_RES_MEM(offsetof(struct ioc3, mcr), 254 + sizeof_field(struct ioc3, mcr)), 255 + }; 256 + static struct sgi_w1_platform_data ioc3_w1_platform_data; 257 + 258 + static struct mfd_cell ioc3_eth_cells[] = { 259 + { 260 + .name = "ioc3-eth", 261 + .resources = ioc3_eth_resources, 262 + .num_resources = ARRAY_SIZE(ioc3_eth_resources), 263 + }, 264 + { 265 + .name = "sgi_w1", 266 + .resources = ioc3_w1_resources, 267 + .num_resources = ARRAY_SIZE(ioc3_w1_resources), 268 + .platform_data = &ioc3_w1_platform_data, 269 + .pdata_size = sizeof(ioc3_w1_platform_data), 270 + } 271 + }; 272 + 273 + static int ioc3_eth_setup(struct ioc3_priv_data *ipd) 274 + { 275 + int ret; 276 + 277 + /* Enable One-Wire bus */ 278 + writel(GPCR_MLAN_EN, &ipd->regs->gpcr_s); 279 + 280 + /* Generate unique identifier */ 281 + snprintf(ioc3_w1_platform_data.dev_id, 282 + sizeof(ioc3_w1_platform_data.dev_id), "ioc3-%012llx", 283 + ipd->pdev->resource->start); 284 + 285 + ret = mfd_add_devices(&ipd->pdev->dev, PLATFORM_DEVID_AUTO, 286 + ioc3_eth_cells, ARRAY_SIZE(ioc3_eth_cells), 287 + &ipd->pdev->resource[0], ipd->pdev->irq, NULL); 288 + if (ret) { 289 + dev_err(&ipd->pdev->dev, "Failed to add ETH/W1 subdev\n"); 290 + return ret; 291 + } 292 + 293 + return 0; 294 + } 295 + 296 + static struct resource ioc3_m48t35_resources[] = { 297 + DEFINE_RES_MEM(IOC3_BYTEBUS_DEV0, M48T35_REG_SIZE) 298 + }; 299 + 300 + static struct mfd_cell ioc3_m48t35_cells[] = { 301 + { 302 + .name = "rtc-m48t35", 303 + .resources = ioc3_m48t35_resources, 304 + .num_resources = ARRAY_SIZE(ioc3_m48t35_resources), 305 + } 306 + }; 307 + 308 + static int ioc3_m48t35_setup(struct ioc3_priv_data *ipd) 309 + { 310 + int ret; 311 + 312 + ret = mfd_add_devices(&ipd->pdev->dev, PLATFORM_DEVID_AUTO, 313 + ioc3_m48t35_cells, ARRAY_SIZE(ioc3_m48t35_cells), 314 + &ipd->pdev->resource[0], 0, ipd->domain); 315 + if (ret) 316 + dev_err(&ipd->pdev->dev, "Failed to add M48T35 subdev\n"); 317 + 318 + return ret; 319 + } 320 + 321 + static struct ds1685_rtc_platform_data ip30_rtc_platform_data = { 322 + .bcd_mode = false, 323 + .no_irq = false, 324 + .uie_unsupported = true, 325 + .access_type = ds1685_reg_indirect, 326 + }; 327 + 328 + static struct resource ioc3_rtc_ds1685_resources[] = { 329 + DEFINE_RES_MEM(IOC3_BYTEBUS_DEV1, 1), 330 + DEFINE_RES_MEM(IOC3_BYTEBUS_DEV2, 1), 331 + DEFINE_RES_IRQ(0) 332 + }; 333 + 334 + static struct mfd_cell ioc3_ds1685_cells[] = { 335 + { 336 + .name = "rtc-ds1685", 337 + .resources = ioc3_rtc_ds1685_resources, 338 + .num_resources = ARRAY_SIZE(ioc3_rtc_ds1685_resources), 339 + .platform_data = &ip30_rtc_platform_data, 340 + .pdata_size = sizeof(ip30_rtc_platform_data), 341 + .id = PLATFORM_DEVID_NONE, 342 + } 343 + }; 344 + 345 + static int ioc3_ds1685_setup(struct ioc3_priv_data *ipd) 346 + { 347 + int ret, irq; 348 + 349 + irq = ioc3_map_irq(ipd->pdev, 6, 0); 350 + 351 + ret = mfd_add_devices(&ipd->pdev->dev, 0, ioc3_ds1685_cells, 352 + ARRAY_SIZE(ioc3_ds1685_cells), 353 + &ipd->pdev->resource[0], irq, NULL); 354 + if (ret) 355 + dev_err(&ipd->pdev->dev, "Failed to add DS1685 subdev\n"); 356 + 357 + return ret; 358 + }; 359 + 360 + 361 + static struct resource ioc3_leds_resources[] = { 362 + DEFINE_RES_MEM(offsetof(struct ioc3, gppr[0]), 363 + sizeof_field(struct ioc3, gppr[0])), 364 + DEFINE_RES_MEM(offsetof(struct ioc3, gppr[1]), 365 + sizeof_field(struct ioc3, gppr[1])), 366 + }; 367 + 368 + static struct mfd_cell ioc3_led_cells[] = { 369 + { 370 + .name = "ip30-leds", 371 + .resources = ioc3_leds_resources, 372 + .num_resources = ARRAY_SIZE(ioc3_leds_resources), 373 + .id = PLATFORM_DEVID_NONE, 374 + } 375 + }; 376 + 377 + static int ioc3_led_setup(struct ioc3_priv_data *ipd) 378 + { 379 + int ret; 380 + 381 + ret = mfd_add_devices(&ipd->pdev->dev, 0, ioc3_led_cells, 382 + ARRAY_SIZE(ioc3_led_cells), 383 + &ipd->pdev->resource[0], 0, ipd->domain); 384 + if (ret) 385 + dev_err(&ipd->pdev->dev, "Failed to add LED subdev\n"); 386 + 387 + return ret; 388 + } 389 + 390 + static int ip27_baseio_setup(struct ioc3_priv_data *ipd) 391 + { 392 + int ret, io_irq; 393 + 394 + io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn), 395 + PCI_INTERRUPT_INTB); 396 + ret = ioc3_irq_domain_setup(ipd, io_irq); 397 + if (ret) 398 + return ret; 399 + 400 + ret = ioc3_eth_setup(ipd); 401 + if (ret) 402 + return ret; 403 + 404 + ret = ioc3_serial_setup(ipd); 405 + if (ret) 406 + return ret; 407 + 408 + return ioc3_m48t35_setup(ipd); 409 + } 410 + 411 + static int ip27_baseio6g_setup(struct ioc3_priv_data *ipd) 412 + { 413 + int ret, io_irq; 414 + 415 + io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn), 416 + PCI_INTERRUPT_INTB); 417 + ret = ioc3_irq_domain_setup(ipd, io_irq); 418 + if (ret) 419 + return ret; 420 + 421 + ret = ioc3_eth_setup(ipd); 422 + if (ret) 423 + return ret; 424 + 425 + ret = ioc3_serial_setup(ipd); 426 + if (ret) 427 + return ret; 428 + 429 + ret = ioc3_m48t35_setup(ipd); 430 + if (ret) 431 + return ret; 432 + 433 + return ioc3_kbd_setup(ipd); 434 + } 435 + 436 + static int ip27_mio_setup(struct ioc3_priv_data *ipd) 437 + { 438 + int ret; 439 + 440 + ret = ioc3_irq_domain_setup(ipd, ipd->pdev->irq); 441 + if (ret) 442 + return ret; 443 + 444 + ret = ioc3_serial_setup(ipd); 445 + if (ret) 446 + return ret; 447 + 448 + return ioc3_kbd_setup(ipd); 449 + } 450 + 451 + static int ip30_sysboard_setup(struct ioc3_priv_data *ipd) 452 + { 453 + int ret, io_irq; 454 + 455 + io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn), 456 + PCI_INTERRUPT_INTB); 457 + ret = ioc3_irq_domain_setup(ipd, io_irq); 458 + if (ret) 459 + return ret; 460 + 461 + ret = ioc3_eth_setup(ipd); 462 + if (ret) 463 + return ret; 464 + 465 + ret = ioc3_serial_setup(ipd); 466 + if (ret) 467 + return ret; 468 + 469 + ret = ioc3_kbd_setup(ipd); 470 + if (ret) 471 + return ret; 472 + 473 + ret = ioc3_ds1685_setup(ipd); 474 + if (ret) 475 + return ret; 476 + 477 + return ioc3_led_setup(ipd); 478 + } 479 + 480 + static int ioc3_menet_setup(struct ioc3_priv_data *ipd) 481 + { 482 + int ret, io_irq; 483 + 484 + io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn), 485 + PCI_INTERRUPT_INTB); 486 + ret = ioc3_irq_domain_setup(ipd, io_irq); 487 + if (ret) 488 + return ret; 489 + 490 + ret = ioc3_eth_setup(ipd); 491 + if (ret) 492 + return ret; 493 + 494 + return ioc3_serial_setup(ipd); 495 + } 496 + 497 + static int ioc3_menet4_setup(struct ioc3_priv_data *ipd) 498 + { 499 + return ioc3_eth_setup(ipd); 500 + } 501 + 502 + static int ioc3_cad_duo_setup(struct ioc3_priv_data *ipd) 503 + { 504 + int ret, io_irq; 505 + 506 + io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn), 507 + PCI_INTERRUPT_INTB); 508 + ret = ioc3_irq_domain_setup(ipd, io_irq); 509 + if (ret) 510 + return ret; 511 + 512 + ret = ioc3_eth_setup(ipd); 513 + if (ret) 514 + return ret; 515 + 516 + return ioc3_kbd_setup(ipd); 517 + } 518 + 519 + /* Helper macro for filling ioc3_info array */ 520 + #define IOC3_SID(_name, _sid, _setup) \ 521 + { \ 522 + .name = _name, \ 523 + .sid = PCI_VENDOR_ID_SGI | (IOC3_SUBSYS_ ## _sid << 16), \ 524 + .setup = _setup, \ 525 + } 526 + 527 + static struct { 528 + const char *name; 529 + u32 sid; 530 + int (*setup)(struct ioc3_priv_data *ipd); 531 + } ioc3_infos[] = { 532 + IOC3_SID("IP27 BaseIO6G", IP27_BASEIO6G, &ip27_baseio6g_setup), 533 + IOC3_SID("IP27 MIO", IP27_MIO, &ip27_mio_setup), 534 + IOC3_SID("IP27 BaseIO", IP27_BASEIO, &ip27_baseio_setup), 535 + IOC3_SID("IP29 System Board", IP29_SYSBOARD, &ip27_baseio6g_setup), 536 + IOC3_SID("IP30 System Board", IP30_SYSBOARD, &ip30_sysboard_setup), 537 + IOC3_SID("MENET", MENET, &ioc3_menet_setup), 538 + IOC3_SID("MENET4", MENET4, &ioc3_menet4_setup) 539 + }; 540 + #undef IOC3_SID 541 + 542 + static int ioc3_setup(struct ioc3_priv_data *ipd) 543 + { 544 + u32 sid; 545 + int i; 546 + 547 + /* Clear IRQs */ 548 + writel(~0, &ipd->regs->sio_iec); 549 + writel(~0, &ipd->regs->sio_ir); 550 + writel(0, &ipd->regs->eth.eier); 551 + writel(~0, &ipd->regs->eth.eisr); 552 + 553 + /* Read subsystem vendor id and subsystem id */ 554 + pci_read_config_dword(ipd->pdev, PCI_SUBSYSTEM_VENDOR_ID, &sid); 555 + 556 + for (i = 0; i < ARRAY_SIZE(ioc3_infos); i++) 557 + if (sid == ioc3_infos[i].sid) { 558 + pr_info("ioc3: %s\n", ioc3_infos[i].name); 559 + return ioc3_infos[i].setup(ipd); 560 + } 561 + 562 + /* Treat everything not identified by PCI subid as CAD DUO */ 563 + pr_info("ioc3: CAD DUO\n"); 564 + return ioc3_cad_duo_setup(ipd); 565 + } 566 + 567 + static int ioc3_mfd_probe(struct pci_dev *pdev, 568 + const struct pci_device_id *pci_id) 569 + { 570 + struct ioc3_priv_data *ipd; 571 + struct ioc3 __iomem *regs; 572 + int ret; 573 + 574 + ret = pci_enable_device(pdev); 575 + if (ret) 576 + return ret; 577 + 578 + pci_write_config_byte(pdev, PCI_LATENCY_TIMER, IOC3_LATENCY); 579 + pci_set_master(pdev); 580 + 581 + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 582 + if (ret) { 583 + pr_err("%s: No usable DMA configuration, aborting.\n", 584 + pci_name(pdev)); 585 + goto out_disable_device; 586 + } 587 + 588 + /* Set up per-IOC3 data */ 589 + ipd = devm_kzalloc(&pdev->dev, sizeof(struct ioc3_priv_data), 590 + GFP_KERNEL); 591 + if (!ipd) { 592 + ret = -ENOMEM; 593 + goto out_disable_device; 594 + } 595 + ipd->pdev = pdev; 596 + 597 + /* 598 + * Map all IOC3 registers. These are shared between subdevices 599 + * so the main IOC3 module manages them. 600 + */ 601 + regs = pci_ioremap_bar(pdev, 0); 602 + if (!regs) { 603 + dev_warn(&pdev->dev, "ioc3: Unable to remap PCI BAR for %s.\n", 604 + pci_name(pdev)); 605 + ret = -ENOMEM; 606 + goto out_disable_device; 607 + } 608 + ipd->regs = regs; 609 + 610 + /* Track PCI-device specific data */ 611 + pci_set_drvdata(pdev, ipd); 612 + 613 + ret = ioc3_setup(ipd); 614 + if (ret) { 615 + /* Remove all already added MFD devices */ 616 + mfd_remove_devices(&ipd->pdev->dev); 617 + if (ipd->domain) { 618 + irq_domain_remove(ipd->domain); 619 + free_irq(ipd->domain_irq, (void *)ipd); 620 + } 621 + pci_iounmap(pdev, regs); 622 + goto out_disable_device; 623 + } 624 + 625 + return 0; 626 + 627 + out_disable_device: 628 + pci_disable_device(pdev); 629 + return ret; 630 + } 631 + 632 + static void ioc3_mfd_remove(struct pci_dev *pdev) 633 + { 634 + struct ioc3_priv_data *ipd; 635 + 636 + ipd = pci_get_drvdata(pdev); 637 + 638 + /* Clear and disable all IRQs */ 639 + writel(~0, &ipd->regs->sio_iec); 640 + writel(~0, &ipd->regs->sio_ir); 641 + 642 + /* Release resources */ 643 + mfd_remove_devices(&ipd->pdev->dev); 644 + if (ipd->domain) { 645 + irq_domain_remove(ipd->domain); 646 + free_irq(ipd->domain_irq, (void *)ipd); 647 + } 648 + pci_iounmap(pdev, ipd->regs); 649 + pci_disable_device(pdev); 650 + } 651 + 652 + static struct pci_device_id ioc3_mfd_id_table[] = { 653 + { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, PCI_ANY_ID, PCI_ANY_ID }, 654 + { 0, }, 655 + }; 656 + MODULE_DEVICE_TABLE(pci, ioc3_mfd_id_table); 657 + 658 + static struct pci_driver ioc3_mfd_driver = { 659 + .name = "IOC3", 660 + .id_table = ioc3_mfd_id_table, 661 + .probe = ioc3_mfd_probe, 662 + .remove = ioc3_mfd_remove, 663 + }; 664 + 665 + module_pci_driver(ioc3_mfd_driver); 666 + 667 + MODULE_AUTHOR("Thomas Bogendoerfer <tbogendoerfer@suse.de>"); 668 + MODULE_DESCRIPTION("SGI IOC3 MFD driver"); 669 + MODULE_LICENSE("GPL v2");
+3 -2
drivers/net/ethernet/sgi/Kconfig
··· 6 6 config NET_VENDOR_SGI 7 7 bool "SGI devices" 8 8 default y 9 - depends on (PCI && SGI_IP27) || SGI_IP32 9 + depends on (PCI && SGI_MFD_IOC3) || SGI_IP32 10 10 ---help--- 11 11 If you have a network (Ethernet) card belonging to this class, say Y. 12 12 ··· 19 19 20 20 config SGI_IOC3_ETH 21 21 bool "SGI IOC3 Ethernet" 22 - depends on PCI && SGI_IP27 22 + depends on PCI && SGI_MFD_IOC3 23 + select CRC16 23 24 select CRC32 24 25 select MII 25 26 ---help---
+98 -448
drivers/net/ethernet/sgi/ioc3-eth.c
··· 14 14 * o Use prefetching for large packets. What is a good lower limit for 15 15 * prefetching? 16 16 * o Use hardware checksums. 17 - * o Convert to using a IOC3 meta driver. 18 17 * o Which PHYs might possibly be attached to the IOC3 in real live, 19 18 * which workarounds are required for them? Do we ever have Lucent's? 20 19 * o For the 2.5 branch kill the mii-tool ioctls. ··· 27 28 #include <linux/mm.h> 28 29 #include <linux/errno.h> 29 30 #include <linux/module.h> 30 - #include <linux/pci.h> 31 + #include <linux/init.h> 32 + #include <linux/crc16.h> 31 33 #include <linux/crc32.h> 32 34 #include <linux/mii.h> 33 35 #include <linux/in.h> ··· 37 37 #include <linux/tcp.h> 38 38 #include <linux/udp.h> 39 39 #include <linux/gfp.h> 40 - 41 - #ifdef CONFIG_SERIAL_8250 42 - #include <linux/serial_core.h> 43 - #include <linux/serial_8250.h> 44 - #include <linux/serial_reg.h> 45 - #endif 46 - 47 40 #include <linux/netdevice.h> 48 41 #include <linux/etherdevice.h> 49 42 #include <linux/ethtool.h> 50 43 #include <linux/skbuff.h> 51 44 #include <linux/dma-mapping.h> 45 + #include <linux/platform_device.h> 46 + #include <linux/nvmem-consumer.h> 52 47 53 48 #include <net/ip.h> 54 49 55 - #include <asm/byteorder.h> 56 - #include <asm/pgtable.h> 57 - #include <linux/uaccess.h> 58 - #include <asm/sn/types.h> 59 50 #include <asm/sn/ioc3.h> 60 51 #include <asm/pci/bridge.h> 52 + 53 + #define CRC16_INIT 0 54 + #define CRC16_VALID 0xb001 61 55 62 56 /* Number of RX buffers. This is tunable in the range of 16 <= x < 512. 63 57 * The value must be a power of two. ··· 79 85 /* Private per NIC data of the driver. */ 80 86 struct ioc3_private { 81 87 struct ioc3_ethregs *regs; 82 - struct ioc3 *all_regs; 83 88 struct device *dma_dev; 84 89 u32 *ssram; 85 90 unsigned long *rxr; /* pointer to receiver ring */ ··· 97 104 spinlock_t ioc3_lock; 98 105 struct mii_if_info mii; 99 106 100 - struct net_device *dev; 101 - struct pci_dev *pdev; 102 - 103 107 /* Members used by autonegotiation */ 104 108 struct timer_list ioc3_timer; 105 109 }; ··· 113 123 static void ioc3_free_rx_bufs(struct ioc3_private *ip); 114 124 static inline void ioc3_clean_tx_ring(struct ioc3_private *ip); 115 125 116 - static const char ioc3_str[] = "IOC3 Ethernet"; 117 126 static const struct ethtool_ops ioc3_ethtool_ops; 118 - 119 127 120 128 static inline unsigned long aligned_rx_skb_addr(unsigned long addr) 121 129 { ··· 167 179 #define ERBAR_VAL 0 168 180 #endif 169 181 170 - #define IOC3_SIZE 0x100000 171 - 172 - static inline u32 mcr_pack(u32 pulse, u32 sample) 182 + static int ioc3eth_nvmem_match(struct device *dev, const void *data) 173 183 { 174 - return (pulse << 10) | (sample << 2); 175 - } 184 + const char *name = dev_name(dev); 185 + const char *prefix = data; 186 + int prefix_len; 176 187 177 - static int nic_wait(u32 __iomem *mcr) 178 - { 179 - u32 m; 188 + prefix_len = strlen(prefix); 189 + if (strlen(name) < (prefix_len + 3)) 190 + return 0; 180 191 181 - do { 182 - m = readl(mcr); 183 - } while (!(m & 2)); 192 + if (memcmp(prefix, name, prefix_len) != 0) 193 + return 0; 184 194 185 - return m & 1; 186 - } 187 - 188 - static int nic_reset(u32 __iomem *mcr) 189 - { 190 - int presence; 191 - 192 - writel(mcr_pack(500, 65), mcr); 193 - presence = nic_wait(mcr); 194 - 195 - writel(mcr_pack(0, 500), mcr); 196 - nic_wait(mcr); 197 - 198 - return presence; 199 - } 200 - 201 - static inline int nic_read_bit(u32 __iomem *mcr) 202 - { 203 - int result; 204 - 205 - writel(mcr_pack(6, 13), mcr); 206 - result = nic_wait(mcr); 207 - writel(mcr_pack(0, 100), mcr); 208 - nic_wait(mcr); 209 - 210 - return result; 211 - } 212 - 213 - static inline void nic_write_bit(u32 __iomem *mcr, int bit) 214 - { 215 - if (bit) 216 - writel(mcr_pack(6, 110), mcr); 217 - else 218 - writel(mcr_pack(80, 30), mcr); 219 - 220 - nic_wait(mcr); 221 - } 222 - 223 - /* Read a byte from an iButton device 224 - */ 225 - static u32 nic_read_byte(u32 __iomem *mcr) 226 - { 227 - u32 result = 0; 228 - int i; 229 - 230 - for (i = 0; i < 8; i++) 231 - result = (result >> 1) | (nic_read_bit(mcr) << 7); 232 - 233 - return result; 234 - } 235 - 236 - /* Write a byte to an iButton device 237 - */ 238 - static void nic_write_byte(u32 __iomem *mcr, int byte) 239 - { 240 - int i, bit; 241 - 242 - for (i = 8; i; i--) { 243 - bit = byte & 1; 244 - byte >>= 1; 245 - 246 - nic_write_bit(mcr, bit); 247 - } 248 - } 249 - 250 - static u64 nic_find(u32 __iomem *mcr, int *last) 251 - { 252 - int a, b, index, disc; 253 - u64 address = 0; 254 - 255 - nic_reset(mcr); 256 - /* Search ROM. */ 257 - nic_write_byte(mcr, 0xf0); 258 - 259 - /* Algorithm from ``Book of iButton Standards''. */ 260 - for (index = 0, disc = 0; index < 64; index++) { 261 - a = nic_read_bit(mcr); 262 - b = nic_read_bit(mcr); 263 - 264 - if (a && b) { 265 - pr_warn("NIC search failed (not fatal).\n"); 266 - *last = 0; 267 - return 0; 268 - } 269 - 270 - if (!a && !b) { 271 - if (index == *last) { 272 - address |= 1UL << index; 273 - } else if (index > *last) { 274 - address &= ~(1UL << index); 275 - disc = index; 276 - } else if ((address & (1UL << index)) == 0) { 277 - disc = index; 278 - } 279 - nic_write_bit(mcr, address & (1UL << index)); 280 - continue; 281 - } else { 282 - if (a) 283 - address |= 1UL << index; 284 - else 285 - address &= ~(1UL << index); 286 - nic_write_bit(mcr, a); 287 - continue; 288 - } 289 - } 290 - 291 - *last = disc; 292 - 293 - return address; 294 - } 295 - 296 - static int nic_init(u32 __iomem *mcr) 297 - { 298 - const char *unknown = "unknown"; 299 - const char *type = unknown; 300 - u8 crc; 301 - u8 serial[6]; 302 - int save = 0, i; 303 - 304 - while (1) { 305 - u64 reg; 306 - 307 - reg = nic_find(mcr, &save); 308 - 309 - switch (reg & 0xff) { 310 - case 0x91: 311 - type = "DS1981U"; 312 - break; 313 - default: 314 - if (save == 0) { 315 - /* Let the caller try again. */ 316 - return -1; 317 - } 318 - continue; 319 - } 320 - 321 - nic_reset(mcr); 322 - 323 - /* Match ROM. */ 324 - nic_write_byte(mcr, 0x55); 325 - for (i = 0; i < 8; i++) 326 - nic_write_byte(mcr, (reg >> (i << 3)) & 0xff); 327 - 328 - reg >>= 8; /* Shift out type. */ 329 - for (i = 0; i < 6; i++) { 330 - serial[i] = reg & 0xff; 331 - reg >>= 8; 332 - } 333 - crc = reg & 0xff; 334 - break; 335 - } 336 - 337 - pr_info("Found %s NIC", type); 338 - if (type != unknown) 339 - pr_cont(" registration number %pM, CRC %02x", serial, crc); 340 - pr_cont(".\n"); 195 + /* found nvmem device which is attached to our ioc3 196 + * now check for one wire family code 09, 89 and 91 197 + */ 198 + if (memcmp(name + prefix_len, "09-", 3) == 0) 199 + return 1; 200 + if (memcmp(name + prefix_len, "89-", 3) == 0) 201 + return 1; 202 + if (memcmp(name + prefix_len, "91-", 3) == 0) 203 + return 1; 341 204 342 205 return 0; 343 206 } 344 207 345 - /* Read the NIC (Number-In-a-Can) device used to store the MAC address on 346 - * SN0 / SN00 nodeboards and PCI cards. 347 - */ 348 - static void ioc3_get_eaddr_nic(struct ioc3_private *ip) 208 + static int ioc3eth_get_mac_addr(struct resource *res, u8 mac_addr[6]) 349 209 { 350 - u32 __iomem *mcr = &ip->all_regs->mcr; 351 - int tries = 2; /* There may be some problem with the battery? */ 352 - u8 nic[14]; 210 + struct nvmem_device *nvmem; 211 + char prefix[24]; 212 + u8 prom[16]; 213 + int ret; 353 214 int i; 354 215 355 - writel(1 << 21, &ip->all_regs->gpcr_s); 216 + snprintf(prefix, sizeof(prefix), "ioc3-%012llx-", 217 + res->start & ~0xffff); 356 218 357 - while (tries--) { 358 - if (!nic_init(mcr)) 359 - break; 360 - udelay(500); 361 - } 219 + nvmem = nvmem_device_find(prefix, ioc3eth_nvmem_match); 220 + if (IS_ERR(nvmem)) 221 + return PTR_ERR(nvmem); 362 222 363 - if (tries < 0) { 364 - pr_err("Failed to read MAC address\n"); 365 - return; 366 - } 223 + ret = nvmem_device_read(nvmem, 0, 16, prom); 224 + nvmem_device_put(nvmem); 225 + if (ret < 0) 226 + return ret; 367 227 368 - /* Read Memory. */ 369 - nic_write_byte(mcr, 0xf0); 370 - nic_write_byte(mcr, 0x00); 371 - nic_write_byte(mcr, 0x00); 228 + /* check, if content is valid */ 229 + if (prom[0] != 0x0a || 230 + crc16(CRC16_INIT, prom, 13) != CRC16_VALID) 231 + return -EINVAL; 372 232 373 - for (i = 13; i >= 0; i--) 374 - nic[i] = nic_read_byte(mcr); 233 + for (i = 0; i < 6; i++) 234 + mac_addr[i] = prom[10 - i]; 375 235 376 - for (i = 2; i < 8; i++) 377 - ip->dev->dev_addr[i - 2] = nic[i]; 378 - } 379 - 380 - /* Ok, this is hosed by design. It's necessary to know what machine the 381 - * NIC is in in order to know how to read the NIC address. We also have 382 - * to know if it's a PCI card or a NIC in on the node board ... 383 - */ 384 - static void ioc3_get_eaddr(struct ioc3_private *ip) 385 - { 386 - ioc3_get_eaddr_nic(ip); 387 - 388 - pr_info("Ethernet address is %pM.\n", ip->dev->dev_addr); 236 + return 0; 389 237 } 390 238 391 239 static void __ioc3_set_mac_address(struct net_device *dev) ··· 594 770 u16 word; 595 771 596 772 for (i = 0; i < 32; i++) { 597 - word = ioc3_mdio_read(ip->dev, i, MII_PHYSID1); 773 + word = ioc3_mdio_read(ip->mii.dev, i, MII_PHYSID1); 598 774 599 775 if (word != 0xffff && word != 0x0000) { 600 776 found = 1; ··· 799 975 { 800 976 struct ioc3_private *ip = netdev_priv(dev); 801 977 802 - if (request_irq(dev->irq, ioc3_interrupt, IRQF_SHARED, ioc3_str, dev)) { 803 - netdev_err(dev, "Can't get irq %d\n", dev->irq); 804 - 805 - return -EAGAIN; 806 - } 807 - 808 978 ip->ehar_h = 0; 809 979 ip->ehar_l = 0; 810 980 ··· 831 1013 return 0; 832 1014 } 833 1015 834 - /* MENET cards have four IOC3 chips, which are attached to two sets of 835 - * PCI slot resources each: the primary connections are on slots 836 - * 0..3 and the secondaries are on 4..7 837 - * 838 - * All four ethernets are brought out to connectors; six serial ports 839 - * (a pair from each of the first three IOC3s) are brought out to 840 - * MiniDINs; all other subdevices are left swinging in the wind, leave 841 - * them disabled. 842 - */ 843 - 844 - static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot) 845 - { 846 - struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0)); 847 - int ret = 0; 848 - 849 - if (dev) { 850 - if (dev->vendor == PCI_VENDOR_ID_SGI && 851 - dev->device == PCI_DEVICE_ID_SGI_IOC3) 852 - ret = 1; 853 - pci_dev_put(dev); 854 - } 855 - 856 - return ret; 857 - } 858 - 859 - static int ioc3_is_menet(struct pci_dev *pdev) 860 - { 861 - return !pdev->bus->parent && 862 - ioc3_adjacent_is_ioc3(pdev, 0) && 863 - ioc3_adjacent_is_ioc3(pdev, 1) && 864 - ioc3_adjacent_is_ioc3(pdev, 2); 865 - } 866 - 867 - #ifdef CONFIG_SERIAL_8250 868 - /* Note about serial ports and consoles: 869 - * For console output, everyone uses the IOC3 UARTA (offset 0x178) 870 - * connected to the master node (look in ip27_setup_console() and 871 - * ip27prom_console_write()). 872 - * 873 - * For serial (/dev/ttyS0 etc), we can not have hardcoded serial port 874 - * addresses on a partitioned machine. Since we currently use the ioc3 875 - * serial ports, we use dynamic serial port discovery that the serial.c 876 - * driver uses for pci/pnp ports (there is an entry for the SGI ioc3 877 - * boards in pci_boards[]). Unfortunately, UARTA's pio address is greater 878 - * than UARTB's, although UARTA on o200s has traditionally been known as 879 - * port 0. So, we just use one serial port from each ioc3 (since the 880 - * serial driver adds addresses to get to higher ports). 881 - * 882 - * The first one to do a register_console becomes the preferred console 883 - * (if there is no kernel command line console= directive). /dev/console 884 - * (ie 5, 1) is then "aliased" into the device number returned by the 885 - * "device" routine referred to in this console structure 886 - * (ip27prom_console_dev). 887 - * 888 - * Also look in ip27-pci.c:pci_fixup_ioc3() for some comments on working 889 - * around ioc3 oddities in this respect. 890 - * 891 - * The IOC3 serials use a 22MHz clock rate with an additional divider which 892 - * can be programmed in the SCR register if the DLAB bit is set. 893 - * 894 - * Register to interrupt zero because we share the interrupt with 895 - * the serial driver which we don't properly support yet. 896 - * 897 - * Can't use UPF_IOREMAP as the whole of IOC3 resources have already been 898 - * registered. 899 - */ 900 - static void ioc3_8250_register(struct ioc3_uartregs __iomem *uart) 901 - { 902 - #define COSMISC_CONSTANT 6 903 - 904 - struct uart_8250_port port = { 905 - .port = { 906 - .irq = 0, 907 - .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, 908 - .iotype = UPIO_MEM, 909 - .regshift = 0, 910 - .uartclk = (22000000 << 1) / COSMISC_CONSTANT, 911 - 912 - .membase = (unsigned char __iomem *)uart, 913 - .mapbase = (unsigned long)uart, 914 - } 915 - }; 916 - unsigned char lcr; 917 - 918 - lcr = readb(&uart->iu_lcr); 919 - writeb(lcr | UART_LCR_DLAB, &uart->iu_lcr); 920 - writeb(COSMISC_CONSTANT, &uart->iu_scr); 921 - writeb(lcr, &uart->iu_lcr); 922 - readb(&uart->iu_lcr); 923 - serial8250_register_8250_port(&port); 924 - } 925 - 926 - static void ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3) 927 - { 928 - u32 sio_iec; 929 - 930 - /* We need to recognice and treat the fourth MENET serial as it 931 - * does not have an SuperIO chip attached to it, therefore attempting 932 - * to access it will result in bus errors. We call something an 933 - * MENET if PCI slot 0, 1, 2 and 3 of a master PCI bus all have an IOC3 934 - * in it. This is paranoid but we want to avoid blowing up on a 935 - * showhorn PCI box that happens to have 4 IOC3 cards in it so it's 936 - * not paranoid enough ... 937 - */ 938 - if (ioc3_is_menet(pdev) && PCI_SLOT(pdev->devfn) == 3) 939 - return; 940 - 941 - /* Switch IOC3 to PIO mode. It probably already was but let's be 942 - * paranoid 943 - */ 944 - writel(GPCR_UARTA_MODESEL | GPCR_UARTB_MODESEL, &ioc3->gpcr_s); 945 - readl(&ioc3->gpcr_s); 946 - writel(0, &ioc3->gppr[6]); 947 - readl(&ioc3->gppr[6]); 948 - writel(0, &ioc3->gppr[7]); 949 - readl(&ioc3->gppr[7]); 950 - writel(readl(&ioc3->port_a.sscr) & ~SSCR_DMA_EN, &ioc3->port_a.sscr); 951 - readl(&ioc3->port_a.sscr); 952 - writel(readl(&ioc3->port_b.sscr) & ~SSCR_DMA_EN, &ioc3->port_b.sscr); 953 - readl(&ioc3->port_b.sscr); 954 - /* Disable all SA/B interrupts except for SA/B_INT in SIO_IEC. */ 955 - sio_iec = readl(&ioc3->sio_iec); 956 - sio_iec &= ~(SIO_IR_SA_TX_MT | SIO_IR_SA_RX_FULL | 957 - SIO_IR_SA_RX_HIGH | SIO_IR_SA_RX_TIMER | 958 - SIO_IR_SA_DELTA_DCD | SIO_IR_SA_DELTA_CTS | 959 - SIO_IR_SA_TX_EXPLICIT | SIO_IR_SA_MEMERR); 960 - sio_iec |= SIO_IR_SA_INT; 961 - sio_iec &= ~(SIO_IR_SB_TX_MT | SIO_IR_SB_RX_FULL | 962 - SIO_IR_SB_RX_HIGH | SIO_IR_SB_RX_TIMER | 963 - SIO_IR_SB_DELTA_DCD | SIO_IR_SB_DELTA_CTS | 964 - SIO_IR_SB_TX_EXPLICIT | SIO_IR_SB_MEMERR); 965 - sio_iec |= SIO_IR_SB_INT; 966 - writel(sio_iec, &ioc3->sio_iec); 967 - writel(0, &ioc3->port_a.sscr); 968 - writel(0, &ioc3->port_b.sscr); 969 - 970 - ioc3_8250_register(&ioc3->sregs.uarta); 971 - ioc3_8250_register(&ioc3->sregs.uartb); 972 - } 973 - #endif 974 - 975 1016 static const struct net_device_ops ioc3_netdev_ops = { 976 1017 .ndo_open = ioc3_open, 977 1018 .ndo_stop = ioc3_close, ··· 843 1166 .ndo_set_mac_address = ioc3_set_mac_address, 844 1167 }; 845 1168 846 - static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 1169 + static int ioc3eth_probe(struct platform_device *pdev) 847 1170 { 848 - unsigned int sw_physid1, sw_physid2; 849 - struct net_device *dev = NULL; 1171 + u32 sw_physid1, sw_physid2, vendor, model, rev; 850 1172 struct ioc3_private *ip; 851 - struct ioc3 *ioc3; 852 - unsigned long ioc3_base, ioc3_size; 853 - u32 vendor, model, rev; 1173 + struct net_device *dev; 1174 + struct resource *regs; 1175 + u8 mac_addr[6]; 854 1176 int err; 855 1177 856 - /* Configure DMA attributes. */ 857 - err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 858 - if (err) { 859 - pr_err("%s: No usable DMA configuration, aborting.\n", 860 - pci_name(pdev)); 861 - goto out; 862 - } 863 - 864 - if (pci_enable_device(pdev)) 865 - return -ENODEV; 1178 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1179 + /* get mac addr from one wire prom */ 1180 + if (ioc3eth_get_mac_addr(regs, mac_addr)) 1181 + return -EPROBE_DEFER; /* not available yet */ 866 1182 867 1183 dev = alloc_etherdev(sizeof(struct ioc3_private)); 868 - if (!dev) { 869 - err = -ENOMEM; 870 - goto out_disable; 871 - } 872 - 873 - err = pci_request_regions(pdev, "ioc3"); 874 - if (err) 875 - goto out_free; 1184 + if (!dev) 1185 + return -ENOMEM; 876 1186 877 1187 SET_NETDEV_DEV(dev, &pdev->dev); 878 1188 879 1189 ip = netdev_priv(dev); 880 - ip->dev = dev; 881 - ip->dma_dev = &pdev->dev; 882 - 883 - dev->irq = pdev->irq; 884 - 885 - ioc3_base = pci_resource_start(pdev, 0); 886 - ioc3_size = pci_resource_len(pdev, 0); 887 - ioc3 = (struct ioc3 *)ioremap(ioc3_base, ioc3_size); 888 - if (!ioc3) { 889 - pr_err("ioc3eth(%s): ioremap failed, goodbye.\n", 890 - pci_name(pdev)); 1190 + ip->dma_dev = pdev->dev.parent; 1191 + ip->regs = devm_platform_ioremap_resource(pdev, 0); 1192 + if (!ip->regs) { 891 1193 err = -ENOMEM; 892 - goto out_res; 1194 + goto out_free; 893 1195 } 894 - ip->regs = &ioc3->eth; 895 - ip->ssram = ioc3->ssram; 896 - ip->all_regs = ioc3; 897 1196 898 - #ifdef CONFIG_SERIAL_8250 899 - ioc3_serial_probe(pdev, ioc3); 900 - #endif 1197 + ip->ssram = devm_platform_ioremap_resource(pdev, 1); 1198 + if (!ip->ssram) { 1199 + err = -ENOMEM; 1200 + goto out_free; 1201 + } 1202 + 1203 + dev->irq = platform_get_irq(pdev, 0); 1204 + if (dev->irq < 0) { 1205 + err = dev->irq; 1206 + goto out_free; 1207 + } 1208 + 1209 + if (devm_request_irq(&pdev->dev, dev->irq, ioc3_interrupt, 1210 + IRQF_SHARED, "ioc3-eth", dev)) { 1211 + dev_err(&pdev->dev, "Can't get irq %d\n", dev->irq); 1212 + err = -ENODEV; 1213 + goto out_free; 1214 + } 901 1215 902 1216 spin_lock_init(&ip->ioc3_lock); 903 1217 timer_setup(&ip->ioc3_timer, ioc3_timer, 0); ··· 918 1250 919 1251 ioc3_init(dev); 920 1252 921 - ip->pdev = pdev; 922 - 923 1253 ip->mii.phy_id_mask = 0x1f; 924 1254 ip->mii.reg_num_mask = 0x1f; 925 1255 ip->mii.dev = dev; ··· 927 1261 ioc3_mii_init(ip); 928 1262 929 1263 if (ip->mii.phy_id == -1) { 930 - pr_err("ioc3-eth(%s): Didn't find a PHY, goodbye.\n", 931 - pci_name(pdev)); 1264 + netdev_err(dev, "Didn't find a PHY, goodbye.\n"); 932 1265 err = -ENODEV; 933 1266 goto out_stop; 934 1267 } 935 1268 936 1269 ioc3_mii_start(ip); 937 1270 ioc3_ssram_disc(ip); 938 - ioc3_get_eaddr(ip); 1271 + memcpy(dev->dev_addr, mac_addr, ETH_ALEN); 939 1272 940 1273 /* The IOC3-specific entries in the device structure. */ 941 1274 dev->watchdog_timeo = 5 * HZ; ··· 971 1306 if (ip->tx_ring) 972 1307 dma_free_coherent(ip->dma_dev, TX_RING_SIZE, ip->tx_ring, 973 1308 ip->txr_dma); 974 - out_res: 975 - pci_release_regions(pdev); 976 1309 out_free: 977 1310 free_netdev(dev); 978 - out_disable: 979 - /* We should call pci_disable_device(pdev); here if the IOC3 wasn't 980 - * such a weird device ... 981 - */ 982 - out: 983 1311 return err; 984 1312 } 985 1313 986 - static void ioc3_remove_one(struct pci_dev *pdev) 1314 + static int ioc3eth_remove(struct platform_device *pdev) 987 1315 { 988 - struct net_device *dev = pci_get_drvdata(pdev); 1316 + struct net_device *dev = platform_get_drvdata(pdev); 989 1317 struct ioc3_private *ip = netdev_priv(dev); 990 1318 991 1319 dma_free_coherent(ip->dma_dev, RX_RING_SIZE, ip->rxr, ip->rxr_dma); ··· 986 1328 987 1329 unregister_netdev(dev); 988 1330 del_timer_sync(&ip->ioc3_timer); 989 - 990 - iounmap(ip->all_regs); 991 - pci_release_regions(pdev); 992 1331 free_netdev(dev); 993 - /* We should call pci_disable_device(pdev); here if the IOC3 wasn't 994 - * such a weird device ... 995 - */ 1332 + 1333 + return 0; 996 1334 } 997 1335 998 - static const struct pci_device_id ioc3_pci_tbl[] = { 999 - { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, PCI_ANY_ID, PCI_ANY_ID }, 1000 - { 0 } 1001 - }; 1002 - MODULE_DEVICE_TABLE(pci, ioc3_pci_tbl); 1003 - 1004 - static struct pci_driver ioc3_driver = { 1005 - .name = "ioc3-eth", 1006 - .id_table = ioc3_pci_tbl, 1007 - .probe = ioc3_probe, 1008 - .remove = ioc3_remove_one, 1009 - }; 1010 1336 1011 1337 static netdev_tx_t ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev) 1012 1338 { ··· 1172 1530 static void ioc3_get_drvinfo(struct net_device *dev, 1173 1531 struct ethtool_drvinfo *info) 1174 1532 { 1175 - struct ioc3_private *ip = netdev_priv(dev); 1176 - 1177 1533 strlcpy(info->driver, IOC3_NAME, sizeof(info->driver)); 1178 1534 strlcpy(info->version, IOC3_VERSION, sizeof(info->version)); 1179 - strlcpy(info->bus_info, pci_name(ip->pdev), sizeof(info->bus_info)); 1535 + strlcpy(info->bus_info, pci_name(to_pci_dev(dev->dev.parent)), 1536 + sizeof(info->bus_info)); 1180 1537 } 1181 1538 1182 1539 static int ioc3_get_link_ksettings(struct net_device *dev, ··· 1287 1646 spin_unlock_irq(&ip->ioc3_lock); 1288 1647 } 1289 1648 1290 - module_pci_driver(ioc3_driver); 1649 + static struct platform_driver ioc3eth_driver = { 1650 + .probe = ioc3eth_probe, 1651 + .remove = ioc3eth_remove, 1652 + .driver = { 1653 + .name = "ioc3-eth", 1654 + } 1655 + }; 1656 + 1657 + module_platform_driver(ioc3eth_driver); 1658 + 1291 1659 MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>"); 1292 1660 MODULE_DESCRIPTION("SGI IOC3 Ethernet driver"); 1293 1661 MODULE_LICENSE("GPL");
+11
drivers/rtc/rtc-m48t35.c
··· 20 20 21 21 struct m48t35_rtc { 22 22 u8 pad[0x7ff8]; /* starts at 0x7ff8 */ 23 + #ifdef CONFIG_SGI_IP27 24 + u8 hour; 25 + u8 min; 26 + u8 sec; 27 + u8 control; 28 + u8 year; 29 + u8 month; 30 + u8 date; 31 + u8 day; 32 + #else 23 33 u8 control; 24 34 u8 sec; 25 35 u8 min; ··· 38 28 u8 date; 39 29 u8 month; 40 30 u8 year; 31 + #endif 41 32 }; 42 33 43 34 #define M48T35_RTC_SET 0x80
+1 -3
drivers/soc/lantiq/fpi-bus.c
··· 28 28 { 29 29 struct device *dev = &pdev->dev; 30 30 struct device_node *np = dev->of_node; 31 - struct resource *res_xbar; 32 31 struct regmap *rcu_regmap; 33 32 void __iomem *xbar_membase; 34 33 u32 rcu_ahb_endianness_reg_offset; 35 34 int ret; 36 35 37 - res_xbar = platform_get_resource(pdev, IORESOURCE_MEM, 0); 38 - xbar_membase = devm_ioremap_resource(dev, res_xbar); 36 + xbar_membase = devm_platform_ioremap_resource(pdev, 0); 39 37 if (IS_ERR(xbar_membase)) 40 38 return PTR_ERR(xbar_membase); 41 39
+2 -3
drivers/tc/tc-driver.c
··· 56 56 * system is in its list of supported devices. Returns the matching 57 57 * tc_device_id structure or %NULL if there is no match. 58 58 */ 59 - const struct tc_device_id *tc_match_device(struct tc_driver *tdrv, 60 - struct tc_dev *tdev) 59 + static const struct tc_device_id *tc_match_device(struct tc_driver *tdrv, 60 + struct tc_dev *tdev) 61 61 { 62 62 const struct tc_device_id *id = tdrv->id_table; 63 63 ··· 71 71 } 72 72 return NULL; 73 73 } 74 - EXPORT_SYMBOL(tc_match_device); 75 74 76 75 /** 77 76 * tc_bus_match - Tell if a device structure has a matching
+98
drivers/tty/serial/8250/8250_ioc3.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * SGI IOC3 8250 UART driver 4 + * 5 + * Copyright (C) 2019 Thomas Bogendoerfer <tbogendoerfer@suse.de> 6 + * 7 + * based on code Copyright (C) 2005 Stanislaw Skowronek <skylark@unaligned.org> 8 + * Copyright (C) 2014 Joshua Kinard <kumba@gentoo.org> 9 + */ 10 + 11 + #include <linux/module.h> 12 + #include <linux/errno.h> 13 + #include <linux/io.h> 14 + #include <linux/platform_device.h> 15 + 16 + #include "8250.h" 17 + 18 + #define IOC3_UARTCLK (22000000 / 3) 19 + 20 + struct ioc3_8250_data { 21 + int line; 22 + }; 23 + 24 + static unsigned int ioc3_serial_in(struct uart_port *p, int offset) 25 + { 26 + return readb(p->membase + (offset ^ 3)); 27 + } 28 + 29 + static void ioc3_serial_out(struct uart_port *p, int offset, int value) 30 + { 31 + writeb(value, p->membase + (offset ^ 3)); 32 + } 33 + 34 + static int serial8250_ioc3_probe(struct platform_device *pdev) 35 + { 36 + struct ioc3_8250_data *data; 37 + struct uart_8250_port up; 38 + struct resource *r; 39 + void __iomem *membase; 40 + int irq, line; 41 + 42 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 43 + if (!r) 44 + return -ENODEV; 45 + 46 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 47 + if (!data) 48 + return -ENOMEM; 49 + 50 + membase = devm_ioremap_nocache(&pdev->dev, r->start, resource_size(r)); 51 + if (!membase) 52 + return -ENOMEM; 53 + 54 + irq = platform_get_irq(pdev, 0); 55 + if (irq < 0) 56 + irq = 0; /* no interrupt -> use polling */ 57 + 58 + /* Register serial ports with 8250.c */ 59 + memset(&up, 0, sizeof(struct uart_8250_port)); 60 + up.port.iotype = UPIO_MEM; 61 + up.port.uartclk = IOC3_UARTCLK; 62 + up.port.type = PORT_16550A; 63 + up.port.irq = irq; 64 + up.port.flags = (UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ); 65 + up.port.dev = &pdev->dev; 66 + up.port.membase = membase; 67 + up.port.mapbase = r->start; 68 + up.port.serial_in = ioc3_serial_in; 69 + up.port.serial_out = ioc3_serial_out; 70 + line = serial8250_register_8250_port(&up); 71 + if (line < 0) 72 + return line; 73 + 74 + platform_set_drvdata(pdev, data); 75 + return 0; 76 + } 77 + 78 + static int serial8250_ioc3_remove(struct platform_device *pdev) 79 + { 80 + struct ioc3_8250_data *data = platform_get_drvdata(pdev); 81 + 82 + serial8250_unregister_port(data->line); 83 + return 0; 84 + } 85 + 86 + static struct platform_driver serial8250_ioc3_driver = { 87 + .probe = serial8250_ioc3_probe, 88 + .remove = serial8250_ioc3_remove, 89 + .driver = { 90 + .name = "ioc3-serial8250", 91 + } 92 + }; 93 + 94 + module_platform_driver(serial8250_ioc3_driver); 95 + 96 + MODULE_AUTHOR("Thomas Bogendoerfer <tbogendoerfer@suse.de>"); 97 + MODULE_DESCRIPTION("SGI IOC3 8250 UART driver"); 98 + MODULE_LICENSE("GPL");
+11
drivers/tty/serial/8250/Kconfig
··· 381 381 port hardware found on the Emma Mobile line of processors. 382 382 If unsure, say N. 383 383 384 + config SERIAL_8250_IOC3 385 + tristate "SGI IOC3 8250 UART support" 386 + depends on SGI_MFD_IOC3 && SERIAL_8250 387 + select SERIAL_8250_EXTENDED 388 + select SERIAL_8250_SHARE_IRQ 389 + help 390 + Enable this if you have a SGI Origin or Octane machine. This module 391 + provides basic serial support by directly driving the UART chip 392 + behind the IOC3 device on those systems. Maximum baud speed is 393 + 38400bps using this driver. 394 + 384 395 config SERIAL_8250_RT288X 385 396 bool "Ralink RT288x/RT305x/RT3662/RT3883 serial port support" 386 397 depends on SERIAL_8250
+1
drivers/tty/serial/8250/Makefile
··· 28 28 obj-$(CONFIG_SERIAL_8250_MEN_MCB) += 8250_men_mcb.o 29 29 obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o 30 30 obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o 31 + obj-$(CONFIG_SERIAL_8250_IOC3) += 8250_ioc3.o 31 32 obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o 32 33 obj-$(CONFIG_SERIAL_8250_LPC18XX) += 8250_lpc18xx.o 33 34 obj-$(CONFIG_SERIAL_8250_MT6577) += 8250_mtk.o