[PATCH] ARC: Don't mess with endianess settings

2020-01-20 Thread Alexey Brodkin
There seem to be not that much sense in explicitly setting endianess
flags for the tools as we assume the tool with required endianess is
used. I.e. we use LE tools for building for LE targets and BE tools
for BE targets.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/config.mk | 10 --
 1 file changed, 10 deletions(-)

diff --git a/arch/arc/config.mk b/arch/arc/config.mk
index 18005d9993..4b8a0870eb 100644
--- a/arch/arc/config.mk
+++ b/arch/arc/config.mk
@@ -8,16 +8,6 @@ else
 CONFIG_SYS_BIG_ENDIAN = 1
 endif
 
-ifdef CONFIG_SYS_LITTLE_ENDIAN
-PLATFORM_LDFLAGS += -EL
-PLATFORM_CPPFLAGS += -mlittle-endian
-endif
-
-ifdef CONFIG_SYS_BIG_ENDIAN
-PLATFORM_LDFLAGS += -EB
-PLATFORM_CPPFLAGS += -mbig-endian
-endif
-
 ifdef CONFIG_ARC_MMU_VER
 CONFIG_MMU = 1
 endif
-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] ARC: Switch to generic accessors

2020-01-20 Thread Alexey Brodkin
First of all U-Boot is not that performance oriented as real run-time
software like OS or user bare-metal app so we may afford being not super
fast as we only being executed once. That in return allows us to be more
universal and support wider variety of devices.

And looking forward that will significantly reduce maintenance and simplify
support of newer architectures.

And while at it we add quad-word accessors like readq(), writeq() etc.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/io.h | 204 +-
 1 file changed, 75 insertions(+), 129 deletions(-)

diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index fa844b54f4..70d050590d 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ * Copyright (C) 2013-2014, 2020 Synopsys, Inc. All rights reserved.
  */
 
 #ifndef __ASM_ARC_IO_H
@@ -54,135 +54,98 @@ static inline void sync(void)
/* Not yet implemented */
 }
 
-static inline u8 __raw_readb(const volatile void __iomem *addr)
-{
-   u8 b;
+#define __arch_getb(a) (*(unsigned char *)(a))
+#define __arch_getw(a) (*(unsigned short *)(a))
+#define __arch_getl(a) (*(unsigned int *)(a))
+#define __arch_getq(a) (*(unsigned long long *)(a))
 
-   __asm__ __volatile__("ldb%U1%0, %1\n"
-: "=r" (b)
-: "m" (*(volatile u8 __force *)addr)
-: "memory");
-   return b;
-}
+#define __arch_putb(v, a)  (*(unsigned char *)(a) = (v))
+#define __arch_putw(v, a)  (*(unsigned short *)(a) = (v))
+#define __arch_putl(v, a)  (*(unsigned int *)(a) = (v))
+#define __arch_putq(v, a)  (*(unsigned long long *)(a) = (v))
 
-static inline u16 __raw_readw(const volatile void __iomem *addr)
-{
-   u16 s;
+#define __raw_writeb(v, a) __arch_putb(v, a)
+#define __raw_writew(v, a) __arch_putw(v, a)
+#define __raw_writel(v, a) __arch_putl(v, a)
+#define __raw_writeq(v, a) __arch_putq(v, a)
 
-   __asm__ __volatile__("ldw%U1%0, %1\n"
-: "=r" (s)
-: "m" (*(volatile u16 __force *)addr)
-: "memory");
-   return s;
-}
+#define __raw_readb(a) __arch_getb(a)
+#define __raw_readw(a) __arch_getw(a)
+#define __raw_readl(a) __arch_getl(a)
+#define __raw_readq(a) __arch_getq(a)
 
-static inline u32 __raw_readl(const volatile void __iomem *addr)
+static inline void __raw_writesb(unsigned long addr, const void *data,
+int bytelen)
 {
-   u32 w;
+   u8 *buf = (uint8_t *)data;
 
-   __asm__ __volatile__("ld%U1 %0, %1\n"
-: "=r" (w)
-: "m" (*(volatile u32 __force *)addr)
-: "memory");
-   return w;
+   while (bytelen--)
+   __arch_putb(*buf++, addr);
 }
 
-static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
+static inline void __raw_writesw(unsigned long addr, const void *data,
+int wordlen)
 {
-   __asm__ __volatile__("stb%U1%0, %1\n"
-:
-: "r" (b), "m" (*(volatile u8 __force *)addr)
-: "memory");
-}
+   u16 *buf = (uint16_t *)data;
 
-static inline void __raw_writew(u16 s, volatile void __iomem *addr)
-{
-   __asm__ __volatile__("stw%U1%0, %1\n"
-:
-: "r" (s), "m" (*(volatile u16 __force *)addr)
-: "memory");
+   while (wordlen--)
+   __arch_putw(*buf++, addr);
 }
 
-static inline void __raw_writel(u32 w, volatile void __iomem *addr)
+static inline void __raw_writesl(unsigned long addr, const void *data,
+int longlen)
 {
-   __asm__ __volatile__("st%U1 %0, %1\n"
-:
-: "r" (w), "m" (*(volatile u32 __force *)addr)
-: "memory");
-}
+   u32 *buf = (uint32_t *)data;
 
-static inline int __raw_readsb(unsigned int addr, void *data, int bytelen)
-{
-   __asm__ __volatile__ ("1:ld.di  r8, [r0]\n"
- "sub.fr2, r2, 1\n"
- "bnz.d1b\n"
- "stb.ab   r8, [r1, 1]\n"
- :
- : "r" (addr), "r" (data), "r" (bytelen)
- : "r8");
-   return bytelen;
+   while (longlen--)
+   __arch_putl(*buf++, addr);
 }
 
-static inline int __raw_readsw(unsigned int addr, void *data, int wordlen)
+static inline void __raw_readsb(unsigned long addr, void *data, int bytelen)
 {
-  

[PATCH 0/3] Improvements for ARC simulation platform

2020-01-20 Thread Alexey Brodkin
Along with some clean-up we make 2 important changes:
 1. Switch to more standard 16550 UART instead of our custom "ARC UART".
This paves the way for using this board in QEMU.

 2. Now when nSIM virtual board is usable in QEMU we add support of Virtio
NIC & block device similarly as we did that in the Linux kernel [1].

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=94b8beb972c524f42078281c9950ed3a946455fa

Alexey Brodkin (3):
  ARC: nSIM: switch from ARC UART to DW UART
  ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking
  ARC: nsim_hs38: Add support of Virtio NET & BLK

 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 48 +++
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 +
 board/synopsys/nsim/Makefile  |  7 ++
 board/synopsys/nsim/nsim.c| 26 +
 configs/nsim_700_defconfig|  9 
 configs/nsim_700be_defconfig  |  9 
 configs/nsim_hs38_defconfig   | 17 ++
 configs/nsim_hs38be_defconfig |  9 
 10 files changed, 115 insertions(+), 23 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 3/3] ARC: nsim_hs38: Add support of Virtio NET & BLK

2020-01-20 Thread Alexey Brodkin
Given now nsim_hs38 configuration is usable on QEMU and in QEMU
we have Virtio working perfectly fine the next logical step
is to add support of supported & known to work net & bkl to this
config.

Note so far we don't have device tree descriptions synced from
the mainline Linux kernel (which we'll need to do anyway at some point)
and as of now we keep U-Boot's device trees as minimalistic as possible
in nSIM description we had to add core's interrupt controller node and
set it as everyone's interrupt-parent. That's required to make buildman
happy. Otherwise it complains like that:
>8
w+arch/arc/dts/nsim.dtb: Warning (interrupts_property): /virtio@f010: 
Missing interrupt-parent
>8

Signed-off-by: Alexey Brodkin 
---
 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 36 
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 ++
 board/synopsys/nsim/Makefile  |  7 +++
 board/synopsys/nsim/nsim.c| 26 ++
 configs/nsim_hs38_defconfig   |  9 +
 7 files changed, 89 insertions(+), 2 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 0cb97207db..545fc3e243 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -160,7 +160,7 @@ config TARGET_TB100
bool "Support tb100"
 
 config TARGET_NSIM
-   bool "Support standalone nSIM & Free nSIM"
+   bool "Support ARC simulation & prototyping platforms"
 
 config TARGET_AXS101
bool "Support Synopsys Designware SDP board AXS101"
@@ -184,10 +184,10 @@ config TARGET_IOT_DEVKIT
 endchoice
 
 source "board/abilis/tb100/Kconfig"
-source "board/synopsys/Kconfig"
 source "board/synopsys/axs10x/Kconfig"
 source "board/synopsys/emsdp/Kconfig"
 source "board/synopsys/hsdk/Kconfig"
 source "board/synopsys/iot_devkit/Kconfig"
+source "board/synopsys/nsim/Kconfig"
 
 endmenu
diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index a3f3964d35..a902c4c4fa 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -8,6 +8,7 @@
 
 / {
model = "snps,nsim";
+   interrupt-parent = <&core_intc>;
 
aliases {
console = &uart0;
@@ -20,6 +21,12 @@
clock-frequency = <7000>;
u-boot,dm-pre-reloc;
};
+
+   core_intc: interrupt-controller {
+   compatible = "snps,archs-intc";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   };
};
 
uart0: serial@f000 {
@@ -30,4 +37,33 @@
clock-frequency = <7000>;
};
 
+   virtio0: virtio@f010 {
+   compatible = "virtio,mmio";
+   reg = <0xf010 0x2000>;
+   interrupts = <31>;
+   };
+
+   virtio1: virtio@f0102000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0102000 0x2000>;
+   interrupts = <32>;
+   };
+
+   virtio2: virtio@f0104000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0104000 0x2000>;
+   interrupts = <33>;
+   };
+
+   virtio3: virtio@f0106000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0106000 0x2000>;
+   interrupts = <34>;
+   };
+
+   virtio4: virtio@f0108000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0108000 0x2000>;
+   interrupts = <35>;
+   };
 };
diff --git a/board/synopsys/Kconfig b/board/synopsys/nsim/Kconfig
similarity index 74%
rename from board/synopsys/Kconfig
rename to board/synopsys/nsim/Kconfig
index 27e5509b26..22287032bf 100644
--- a/board/synopsys/Kconfig
+++ b/board/synopsys/nsim/Kconfig
@@ -1,5 +1,8 @@
 if TARGET_NSIM
 
+config SYS_BOARD
+   default "nsim"
+
 config SYS_VENDOR
default "synopsys"
 
diff --git a/board/synopsys/nsim/MAINTAINERS b/board/synopsys/nsim/MAINTAINERS
new file mode 100644
index 00..ed4b9a9e78
--- /dev/null
+++ b/board/synopsys/nsim/MAINTAINERS
@@ -0,0 +1,6 @@
+EM DEVELOPMENT KIT BOARD
+M: Alexey Brodkin 
+S: Maintained
+F: arch/arc/dts/nsim.dts
+F: board/synopsys/nsim/
+F: configs/nsim_*_defconfig
diff --git a/board/synopsys/nsim/Makefile b/board/synopsys/nsim/Makefile
new file mode 100644
index 00..6aaa73
--- /dev/null
+++ b/board/synopsys/nsim/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2020 Synopsys, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y  += nsim.o
diff --git a/board/synopsys/nsim/nsim.c b/board/synopsys/nsim/nsim.c
new file mode 100644
index 0

[PATCH 1/3] ARC: nSIM: switch from ARC UART to DW UART

2020-01-20 Thread Alexey Brodkin
Since v2019.06 DesingWare nSIM supports DesignWare UART simulation
and so we may switch from pretty unusual ARC UART to much more standard
DesignWare UART (which in case of U-Boot is just an ordinary 16650 UART).

This among other things makes built dinaries compatible with our other
platforms to name a few: FPGA-based HAPS boards, QEMU and even ZeBU.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/dts/nsim.dts | 12 +++-
 configs/nsim_700_defconfig|  8 
 configs/nsim_700be_defconfig  |  8 
 configs/nsim_hs38_defconfig   |  8 
 configs/nsim_hs38be_defconfig |  8 
 5 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index 243ecb178e..a3f3964d35 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2015-2016, 2019 Synopsys, Inc. (www.synopsys.com)
  */
 /dts-v1/;
 
@@ -10,7 +10,7 @@
model = "snps,nsim";
 
aliases {
-   console = &arcuart0;
+   console = &uart0;
};
 
cpu_card {
@@ -22,9 +22,11 @@
};
};
 
-   arcuart0: serial@0xc0fc1000 {
-   compatible = "snps,arc-uart";
-   reg = <0xc0fc1000 0x100>;
+   uart0: serial@f000 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0xf000 0x1000>;
+   reg-shift = <2>;
+   reg-io-width = <4>;
clock-frequency = <7000>;
};
 
diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 5633113b09..2d4a58b178 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -1,13 +1,13 @@
 CONFIG_ARC=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -16,6 +16,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 40f7ec7e1f..61eea91449 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 2820a6fca3..ce68de3251 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_ISA_ARCV2=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index e533fae2b1..5d2ea59d52 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -3,13 +3,13 @@ CONFIG_ISA_ARCV2=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -18,6 +18,6 @@ CONFIG_DEFAULT_DEVICE_TREE="ns

[PATCH 2/3] ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking

2020-01-20 Thread Alexey Brodkin
We don't have yet any brc700 or big-enadian platforms with networking
support to run this particular configuration.

Whenever QEMU for ARC supports arc700 or big-endian targets we may revisit
this one.

Signed-off-by: Alexey Brodkin 
---
 configs/nsim_700_defconfig| 1 +
 configs/nsim_700be_defconfig  | 1 +
 configs/nsim_hs38be_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 2d4a58b178..6a38e2c246 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -14,6 +14,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 61eea91449..d3ed84a415 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -15,6 +15,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index 5d2ea59d52..b074b4ca98 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -16,6 +16,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[RFC 0/2] Import and use non-atomic bit-ops

2020-01-20 Thread Alexey Brodkin
The following bitops are implemented pretty similarly for many
arches and now when we faced a need in them on ARC I guess there's
no point in copy-pasting them yet another time but instead it might
be better re-use generic version from the Linux kernel.

Since we had non of those bitops for ARC inclusion of imported header
works perfectly fine. As for other arches I do see they use a bit different
implementation but those might be just older versions etc.

Sobefore breaking stuff for other arches I'd like to get some feedback
from maintainers. Or we may just import proposed header and switch to
its usage arch-by-arch whenever people feel kile cleaning-up their bitops.

Alexey Brodkin (2):
  include: Import non-atomic.h from Linux
  ARC: Add support of bitops via generic implementation

 arch/arc/include/asm/bitops.h   |   1 +
 include/asm-generic/bitops/non-atomic.h | 109 
 2 files changed, 110 insertions(+)
 create mode 100644 include/asm-generic/bitops/non-atomic.h

-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[RFC 1/2] include: Import non-atomic.h from Linux

2020-01-20 Thread Alexey Brodkin
This header contains implementations of some common bit ops:
 * __set_bit()/__clear_bit()/__change_bit()/test_bit()
 * __test_and_set_bit()/__test_and_clear_bit()/__test_and_change_bit()

No point in copy-pasting that again & again.

Signed-off-by: Alexey Brodkin 
---
 include/asm-generic/bitops/non-atomic.h | 109 
 1 file changed, 109 insertions(+)
 create mode 100644 include/asm-generic/bitops/non-atomic.h

diff --git a/include/asm-generic/bitops/non-atomic.h 
b/include/asm-generic/bitops/non-atomic.h
new file mode 100644
index 00..9b3be37fff
--- /dev/null
+++ b/include/asm-generic/bitops/non-atomic.h
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_GENERIC_BITOPS_NON_ATOMIC_H_
+#define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_
+
+#include 
+
+/**
+ * __set_bit - Set a bit in memory
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ *
+ * Unlike set_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static inline void __set_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p  |= mask;
+}
+
+static inline void __clear_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p &= ~mask;
+}
+
+/**
+ * __change_bit - Toggle a bit in memory
+ * @nr: the bit to change
+ * @addr: the address to start counting from
+ *
+ * Unlike change_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static inline void __change_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p ^= mask;
+}
+
+/**
+ * __test_and_set_bit - Set a bit and return its old value
+ * @nr: Bit to set
+ * @addr: Address to count from
+ *
+ * This operation is non-atomic and can be reordered.
+ * If two examples of this operation race, one can appear to succeed
+ * but actually fail.  You must protect multiple accesses with a lock.
+ */
+static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
+
+   *p = old | mask;
+   return (old & mask) != 0;
+}
+
+/**
+ * __test_and_clear_bit - Clear a bit and return its old value
+ * @nr: Bit to clear
+ * @addr: Address to count from
+ *
+ * This operation is non-atomic and can be reordered.
+ * If two examples of this operation race, one can appear to succeed
+ * but actually fail.  You must protect multiple accesses with a lock.
+ */
+static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
+
+   *p = old & ~mask;
+   return (old & mask) != 0;
+}
+
+/* WARNING: non atomic and it can be reordered! */
+static inline int __test_and_change_bit(int nr,
+   volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
+
+   *p = old ^ mask;
+   return (old & mask) != 0;
+}
+
+/**
+ * test_bit - Determine whether a bit is set
+ * @nr: bit number to test
+ * @addr: Address to start counting from
+ */
+static inline int test_bit(int nr, const volatile unsigned long *addr)
+{
+   return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG - 1)));
+}
+
+#endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */
-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[RFC 2/2] ARC: Add support of bitops via generic implementation

2020-01-20 Thread Alexey Brodkin
This allows building more things. In particular with
CONFIG_PKCS7_MESSAGE_PARSER=y we saw this:
>8--
lib/crypto/pkcs7_parser.c: In function 'pkcs7_sig_note_authenticated_attr':
lib/crypto/pkcs7_parser.c:489:7: warning: implicit declaration of function 
'__test_and_set_bit' [-Wimplicit-function-declaration]
  489 |   if (__test_and_set_bit(sinfo_has_content_type, &sinfo->aa_set))
  |   ^~
  CC  lib/crc32.o
  CC  lib/ctype.o
  DTB test/overlay/test-fdt-overlay-stacked.dtb.S
  CC  lib/div64.o
lib/crypto/pkcs7_parser.c: In function 'pkcs7_sig_note_set_of_authattrs':
lib/crypto/pkcs7_parser.c:572:7: warning: implicit declaration of function 
'test_bit' [-Wimplicit-function-declaration]
  572 |  if (!test_bit(sinfo_has_content_type, &sinfo->aa_set) ||
...
  LD  u-boot
arc-elf32-ld.bfd: lib/built-in.o: in function 
'pkcs7_sig_note_authenticated_attr':
.../lib/crypto/pkcs7_parser.c:489: undefined reference to '__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:489: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:501: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:501: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:510: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: lib/built-in.o:.../lib/crypto/pkcs7_parser.c:510: more 
undefined references to '__test_and_set_bit' follow
arc-elf32-ld.bfd: lib/built-in.o: in function 'pkcs7_sig_note_set_of_authattrs':
.../lib/crypto/pkcs7_parser.c:572: undefined reference to `test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:572: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:573: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:573: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:579: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: lib/built-in.o:.../lib/crypto/pkcs7_parser.c:579: more 
undefined references to 'test_bit' follow
>8--

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/bitops.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index c6dd28ecef..daa07e80a8 100644
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -19,5 +19,6 @@
 #include 
 #include 
 #include 
+#include 
 
 #endif /* __ASM_ARC_BITOPS_H */
-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [RFC 0/2] Import and use non-atomic bit-ops

2020-01-20 Thread Tom Rini
On Mon, Jan 20, 2020 at 03:43:27PM +0300, Alexey Brodkin wrote:

> The following bitops are implemented pretty similarly for many
> arches and now when we faced a need in them on ARC I guess there's
> no point in copy-pasting them yet another time but instead it might
> be better re-use generic version from the Linux kernel.
> 
> Since we had non of those bitops for ARC inclusion of imported header
> works perfectly fine. As for other arches I do see they use a bit different
> implementation but those might be just older versions etc.
> 
> Sobefore breaking stuff for other arches I'd like to get some feedback
> from maintainers. Or we may just import proposed header and switch to
> its usage arch-by-arch whenever people feel kile cleaning-up their bitops.
> 
> Alexey Brodkin (2):
>   include: Import non-atomic.h from Linux
>   ARC: Add support of bitops via generic implementation
> 
>  arch/arc/include/asm/bitops.h   |   1 +
>  include/asm-generic/bitops/non-atomic.h | 109 
> 
>  2 files changed, 110 insertions(+)
>  create mode 100644 include/asm-generic/bitops/non-atomic.h

I would like to see this as a series to re-sync
include/asm-generic/bitops/ with a more recent Linux Kernel release
(it's from v4.2.3 per git log) and then add non-atomic.h and update
nios2 to use it instead of its own copy.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc