Re: [PATCH] arm: aspeed: Add Aspeed board file with clocksource devicetree fixup

2017-06-20 Thread Jonas Jensen
On 20 June 2017 at 10:06, Linus Walleij  wrote:
> Moxart is deploying the DTBs with the kernel, they go hand-in-hand.
> Backward compatibility with old DTBs here would just be an academic
> exercise.

I've used CONFIG_ARM_APPENDED_DTB=y since the beginning mainly because
UC-7112-LX's proprietary bootloader lacks DTB capabilities (that I'm
aware of).
Compiling both (kernel and dtb) at the same time always made sense to
me, and it does, even when the hardware has a sane bootloader (i.e.
DTB enabled).


   Jonas


Re: [PATCH] arm: aspeed: Add Aspeed board file with clocksource devicetree fixup

2017-06-20 Thread Jonas Jensen
On 20 June 2017 at 10:06, Linus Walleij  wrote:
> Moxart is deploying the DTBs with the kernel, they go hand-in-hand.
> Backward compatibility with old DTBs here would just be an academic
> exercise.

I've used CONFIG_ARM_APPENDED_DTB=y since the beginning mainly because
UC-7112-LX's proprietary bootloader lacks DTB capabilities (that I'm
aware of).
Compiling both (kernel and dtb) at the same time always made sense to
me, and it does, even when the hardware has a sane bootloader (i.e.
DTB enabled).


   Jonas


Re: [PATCH 2/2] drivers/clocksource/fttmr010: Implement delay timer

2017-06-12 Thread Jonas Jensen
 greatest stack depth: 6452 bytes left
[0.889185] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[0.947029] io scheduler noop registered
[0.955454] io scheduler cfq registered (default)
[0.960470] io scheduler mq-deadline registered
[0.966328] io scheduler kyber registered
[0.986690] ftgpio010-gpio 9870.gpio: FTGPIO010 @c289e000 registered
[1.006881] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[1.028261] console [ttyS0] disabled
[1.033357] 9820.uart: ttyS0 at MMIO 0x9820 (irq = 21,
base_baud = 921600) is a 16550A
[1.043679] console [ttyS0] enabled
[1.043679] console [ttyS0] enabled
[1.051850] bootconsole [earlycon0] disabled
[1.051850] bootconsole [earlycon0] disabled
[1.101640] 8000.flash: Found 1 x16 devices at 0x0 in 16-bit
bank. Manufacturer ID 0x89 Chip ID 0x18
[1.112766] Intel/Sharp Extended Query Table at 0x0031
[1.118581] Intel/Sharp Extended Query Table at 0x0031
[1.123882] Using buffer write method
[1.128057] cfi_cmdset_0001: Erase suspend on write enabled
[1.134012] 4 ofpart partitions found on MTD device 8000.flash
[1.140561] Creating 4 MTD partitions on "8000.flash":
[1.146468] 0x-0x0004 : "bootloader"
[1.168490] 0x0004-0x0020 : "linux kernel"
[1.192265] 0x0020-0x00a0 : "root filesystem"
[1.217379] 0x00a0-0x0100 : "user filesystem"
[1.890595] libphy: MOXA ART Ethernet MII: probed
[2.554143] random: fast init done
[2.565768] libphy: MOXA ART Ethernet MII: probed
[2.599346] libphy: Fixed MDIO Bus: probed
[2.649311] moxart-rtc 9000.soc:rtc: rtc core: registered
9000.soc:rtc as rtc0
[2.680285] sdhci: Secure Digital Host Controller Interface driver
[2.689336] sdhci: Copyright(c) Pierre Ossman
[2.764421] sdhci-pltfm: SDHCI platform and OF driver helper
[2.786042] NET: Registered protocol family 17
[2.814928] mmc0: new SDHC card at address e624
[2.822331] console [netcon0] enabled
[2.828128] netconsole: network logging started
[2.839709] mmcblk0: mmc0:e624 SS04G 3.69 GiB
[2.848309] moxart-rtc 9000.soc:rtc: setting system clock to
2017-06-12 11:15:23 UTC (1497266123)
[2.865883]  mmcblk0: p1
[2.885535] EXT4-fs (mmcblk0p1): mounting ext3 file system using
the ext4 subsystem
[4.168117] EXT4-fs (mmcblk0p1): recovery complete
[4.178633] EXT4-fs (mmcblk0p1): mounted filesystem with ordered
data mode. Opts: (null)
[4.187497] VFS: Mounted root (ext3 filesystem) on device 179:1.
[4.226905] devtmpfs: mounted
[4.298371] Freeing unused kernel memory: 1024K
INIT: version 2.88 booting

[2] 
https://bitbucket.org/Kasreyn/linux-next/commits/78456248df9eeb48c963b574f50c7268713ef0b1
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc1-next-20170518-00010-g7845624
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4486 PREEMPT
Fri May 19 14:04:54 CEST 2017
..
[2.543134] 4 ofpart partitions found on MTD device 8000.flash
[2.550035] Creating 4 MTD partitions on "8000.flash":
[2.555941] 0x-0x0004 : "bootloader"
[2.563134] random: fast init done
[2.634452] 0x0004-0x0020 : "linux kernel"
[2.686438] 0x0020-0x00a0 : "root filesystem"
[2.744918] 0x00a0-0x0100 : "user filesystem"

[3] 
https://bitbucket.org/Kasreyn/linux-next/commits/75a5fce74de4172fb6ce32aa1f4e208657013006
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc4-next-20170609-3-g75a5fce
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4550 PREEMPT
Mon Jun 12 13:58:32 CEST 2017
..
[1.185855] 4 ofpart partitions found on MTD device 8000.flash
[1.192166] Creating 4 MTD partitions on "8000.flash":
[1.198093] 0x-0x0004 : "bootloader"
[1.220088] 0x0004-0x0020 : "linux kernel"
[    1.244496] 0x0020-0x00a0 : "root filesystem"
[1.269177] 0x00a0-0x0100 : "user filesystem"


Tested-by: Jonas Jensen <jonas.jen...@gmail.com>


Re: [PATCH 2/2] drivers/clocksource/fttmr010: Implement delay timer

2017-06-12 Thread Jonas Jensen
ytes left
[0.889185] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[0.947029] io scheduler noop registered
[0.955454] io scheduler cfq registered (default)
[0.960470] io scheduler mq-deadline registered
[0.966328] io scheduler kyber registered
[0.986690] ftgpio010-gpio 9870.gpio: FTGPIO010 @c289e000 registered
[1.006881] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[1.028261] console [ttyS0] disabled
[1.033357] 9820.uart: ttyS0 at MMIO 0x9820 (irq = 21,
base_baud = 921600) is a 16550A
[1.043679] console [ttyS0] enabled
[1.043679] console [ttyS0] enabled
[1.051850] bootconsole [earlycon0] disabled
[1.051850] bootconsole [earlycon0] disabled
[1.101640] 8000.flash: Found 1 x16 devices at 0x0 in 16-bit
bank. Manufacturer ID 0x89 Chip ID 0x18
[1.112766] Intel/Sharp Extended Query Table at 0x0031
[1.118581] Intel/Sharp Extended Query Table at 0x0031
[1.123882] Using buffer write method
[1.128057] cfi_cmdset_0001: Erase suspend on write enabled
[1.134012] 4 ofpart partitions found on MTD device 8000.flash
[1.140561] Creating 4 MTD partitions on "8000.flash":
[1.146468] 0x-0x0004 : "bootloader"
[1.168490] 0x0004-0x0020 : "linux kernel"
[1.192265] 0x0020-0x00a0 : "root filesystem"
[1.217379] 0x00a0-0x0100 : "user filesystem"
[1.890595] libphy: MOXA ART Ethernet MII: probed
[2.554143] random: fast init done
[2.565768] libphy: MOXA ART Ethernet MII: probed
[2.599346] libphy: Fixed MDIO Bus: probed
[2.649311] moxart-rtc 9000.soc:rtc: rtc core: registered
9000.soc:rtc as rtc0
[2.680285] sdhci: Secure Digital Host Controller Interface driver
[2.689336] sdhci: Copyright(c) Pierre Ossman
[2.764421] sdhci-pltfm: SDHCI platform and OF driver helper
[2.786042] NET: Registered protocol family 17
[2.814928] mmc0: new SDHC card at address e624
[2.822331] console [netcon0] enabled
[2.828128] netconsole: network logging started
[2.839709] mmcblk0: mmc0:e624 SS04G 3.69 GiB
[2.848309] moxart-rtc 9000.soc:rtc: setting system clock to
2017-06-12 11:15:23 UTC (1497266123)
[2.865883]  mmcblk0: p1
[2.885535] EXT4-fs (mmcblk0p1): mounting ext3 file system using
the ext4 subsystem
[4.168117] EXT4-fs (mmcblk0p1): recovery complete
[4.178633] EXT4-fs (mmcblk0p1): mounted filesystem with ordered
data mode. Opts: (null)
[4.187497] VFS: Mounted root (ext3 filesystem) on device 179:1.
[4.226905] devtmpfs: mounted
[4.298371] Freeing unused kernel memory: 1024K
INIT: version 2.88 booting

[2] 
https://bitbucket.org/Kasreyn/linux-next/commits/78456248df9eeb48c963b574f50c7268713ef0b1
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc1-next-20170518-00010-g7845624
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4486 PREEMPT
Fri May 19 14:04:54 CEST 2017
..
[2.543134] 4 ofpart partitions found on MTD device 8000.flash
[2.550035] Creating 4 MTD partitions on "8000.flash":
[2.555941] 0x-0x0004 : "bootloader"
[2.563134] random: fast init done
[2.634452] 0x0004-0x0020 : "linux kernel"
[2.686438] 0x0020-0x00a0 : "root filesystem"
[2.744918] 0x00a0-0x0100 : "user filesystem"

[3] 
https://bitbucket.org/Kasreyn/linux-next/commits/75a5fce74de4172fb6ce32aa1f4e208657013006
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc4-next-20170609-3-g75a5fce
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4550 PREEMPT
Mon Jun 12 13:58:32 CEST 2017
..
[1.185855] 4 ofpart partitions found on MTD device 8000.flash
[1.192166] Creating 4 MTD partitions on "8000.flash":
[1.198093] 0x-0x0004 : "bootloader"
[1.220088] 0x0004-0x0020 : "linux kernel"
[    1.244496] 0x0020-0x00a0 : "root filesystem"
[1.269177] 0x00a0-0x0100 : "user filesystem"


Tested-by: Jonas Jensen 


[PATCH] ARM: dts: moxart: rename sdhci mmc

2017-05-23 Thread Jonas Jensen
The host driver compatible string changed to "moxa,moxart-mmc" during
the review process while the old name was committed to moxart's dts* files.

Correct the host driver compatible string and also fix the node name.

Signed-off-by: Jonas Jensen <jonas.jen...@gmail.com>
---

Notes:
Applies to next-20170518

 arch/arm/boot/dts/moxart-uc7112lx.dts | 2 +-
 arch/arm/boot/dts/moxart.dtsi | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
index 4a962a2..59d8775 100644
--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -80,7 +80,7 @@
clocks = <>;
 };
 
- {
+ {
status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index e86f8c9..54a3ca2 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -91,8 +91,8 @@
clocks = <_apb>;
};
 
-   sdhci: sdhci@98e0 {
-   compatible = "moxa,moxart-sdhci";
+   mmc: mmc@98e0 {
+   compatible = "moxa,moxart-mmc";
reg = <0x98e0 0x5C>;
interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
clocks = <_apb>;
-- 
1.8.2.1



[PATCH] ARM: dts: moxart: rename sdhci mmc

2017-05-23 Thread Jonas Jensen
The host driver compatible string changed to "moxa,moxart-mmc" during
the review process while the old name was committed to moxart's dts* files.

Correct the host driver compatible string and also fix the node name.

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20170518

 arch/arm/boot/dts/moxart-uc7112lx.dts | 2 +-
 arch/arm/boot/dts/moxart.dtsi | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
index 4a962a2..59d8775 100644
--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -80,7 +80,7 @@
clocks = <>;
 };
 
- {
+ {
status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index e86f8c9..54a3ca2 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -91,8 +91,8 @@
clocks = <_apb>;
};
 
-   sdhci: sdhci@98e0 {
-   compatible = "moxa,moxart-sdhci";
+   mmc: mmc@98e0 {
+   compatible = "moxa,moxart-mmc";
reg = <0x98e0 0x5C>;
interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
clocks = <_apb>;
-- 
1.8.2.1



Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-19 Thread Jonas Jensen
et_order=0
[2.049607] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[2.186448] io scheduler noop registered
[2.199676] io scheduler cfq registered (default)
[2.204813] io scheduler mq-deadline registered
[2.212844] io scheduler kyber registered
[2.273164] ftgpio010-gpio 9870.gpio: FTGPIO010 @c289e000 registered
[2.311358] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[2.392108] console [ttyS0] disabled
[2.403351] 9820.uart: ttyS0 at MMIO 0x9820 (irq = 21,
base_baud = 921600) is a 16550A
[2.417906] console [ttyS0] enabled
[2.417906] console [ttyS0] enabled
[2.425654] bootconsole [earlycon0] disabled
[2.425654] bootconsole [earlycon0] disabled
[2.508660] 8000.flash: Found 1 x16 devices at 0x0 in 16-bit
bank. Manufacturer ID 0x89 Chip ID 0x18
[2.520534] Intel/Sharp Extended Query Table at 0x0031
[2.525990] Intel/Sharp Extended Query Table at 0x0031
[2.531858] Using buffer write method
[2.535736] cfi_cmdset_0001: Erase suspend on write enabled
[2.543134] 4 ofpart partitions found on MTD device 8000.flash
[2.550035] Creating 4 MTD partitions on "8000.flash":
[2.555941] 0x-0x0004 : "bootloader"
[2.563134] random: fast init done
[2.634452] 0x0004-0x0020 : "linux kernel"
[2.686438] 0x0020-0x00a0 : "root filesystem"
[2.744918] 0x00a0-0x0100 : "user filesystem"
[3.460849] libphy: MOXA ART Ethernet MII: probed
[4.147623] libphy: MOXA ART Ethernet MII: probed
[4.194338] libphy: Fixed MDIO Bus: probed
[4.316628] moxart-rtc 9000.soc:rtc: rtc core: registered
9000.soc:rtc as rtc0
[4.396418] sdhci: Secure Digital Host Controller Interface driver
[4.406095] sdhci: Copyright(c) Pierre Ossman
[4.500912] sdhci-pltfm: SDHCI platform and OF driver helper
[4.563980] NET: Registered protocol family 17
[4.575489] mmc0: new SD card at address e624
[4.662702] mmcblk0: mmc0:e624 SD02G 1.84 GiB
[4.722683]  mmcblk0: p1
[4.733139] console [netcon0] enabled
[4.748281] netconsole: network logging started
[4.778193] moxart-rtc 9000.soc:rtc: setting system clock to
2017-05-19 12:59:09 UTC (1495198749)
[4.835127] EXT4-fs (mmcblk0p1): mounting ext3 file system using
the ext4 subsystem
[6.235992] EXT4-fs (mmcblk0p1): recovery complete
[6.254832] EXT4-fs (mmcblk0p1): mounted filesystem with ordered
data mode. Opts: (null)
[6.265796] VFS: Mounted root (ext3 filesystem) on device 179:1.
[6.373316] devtmpfs: mounted
[6.410728] Freeing unused kernel memory: 192K
[6.415430] This architecture does not have kernel memory protection.
INIT: version 2.88 booting


Tested-by: Jonas Jensen <jonas.jen...@gmail.com>


   Jonas


Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-19 Thread Jonas Jensen
version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[2.186448] io scheduler noop registered
[2.199676] io scheduler cfq registered (default)
[2.204813] io scheduler mq-deadline registered
[2.212844] io scheduler kyber registered
[2.273164] ftgpio010-gpio 9870.gpio: FTGPIO010 @c289e000 registered
[2.311358] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[2.392108] console [ttyS0] disabled
[2.403351] 9820.uart: ttyS0 at MMIO 0x9820 (irq = 21,
base_baud = 921600) is a 16550A
[2.417906] console [ttyS0] enabled
[2.417906] console [ttyS0] enabled
[2.425654] bootconsole [earlycon0] disabled
[2.425654] bootconsole [earlycon0] disabled
[2.508660] 8000.flash: Found 1 x16 devices at 0x0 in 16-bit
bank. Manufacturer ID 0x89 Chip ID 0x18
[2.520534] Intel/Sharp Extended Query Table at 0x0031
[2.525990] Intel/Sharp Extended Query Table at 0x0031
[2.531858] Using buffer write method
[2.535736] cfi_cmdset_0001: Erase suspend on write enabled
[2.543134] 4 ofpart partitions found on MTD device 8000.flash
[2.550035] Creating 4 MTD partitions on "8000.flash":
[2.555941] 0x-0x0004 : "bootloader"
[2.563134] random: fast init done
[2.634452] 0x0004-0x0020 : "linux kernel"
[2.686438] 0x0020-0x00a0 : "root filesystem"
[2.744918] 0x00a0-0x0100 : "user filesystem"
[3.460849] libphy: MOXA ART Ethernet MII: probed
[4.147623] libphy: MOXA ART Ethernet MII: probed
[4.194338] libphy: Fixed MDIO Bus: probed
[4.316628] moxart-rtc 9000.soc:rtc: rtc core: registered
9000.soc:rtc as rtc0
[4.396418] sdhci: Secure Digital Host Controller Interface driver
[4.406095] sdhci: Copyright(c) Pierre Ossman
[4.500912] sdhci-pltfm: SDHCI platform and OF driver helper
[4.563980] NET: Registered protocol family 17
[4.575489] mmc0: new SD card at address e624
[4.662702] mmcblk0: mmc0:e624 SD02G 1.84 GiB
[4.722683]  mmcblk0: p1
[4.733139] console [netcon0] enabled
[4.748281] netconsole: network logging started
[4.778193] moxart-rtc 9000.soc:rtc: setting system clock to
2017-05-19 12:59:09 UTC (1495198749)
[4.835127] EXT4-fs (mmcblk0p1): mounting ext3 file system using
the ext4 subsystem
[6.235992] EXT4-fs (mmcblk0p1): recovery complete
[6.254832] EXT4-fs (mmcblk0p1): mounted filesystem with ordered
data mode. Opts: (null)
[6.265796] VFS: Mounted root (ext3 filesystem) on device 179:1.
[6.373316] devtmpfs: mounted
[6.410728] Freeing unused kernel memory: 192K
[6.415430] This architecture does not have kernel memory protection.
INIT: version 2.88 booting


Tested-by: Jonas Jensen 


   Jonas


Re: [PATCH 0/8] clocksource: Generalize Faraday timer

2017-05-18 Thread Jonas Jensen
On 17 May 2017 at 16:05, Linus Walleij <linus.wall...@linaro.org> wrote:
> The patches can be applied as soon as Jonas Jensen and Joel
> Stanley says they work for them.

Thanks! fttmr010 seem to work OK!

I did the usual test on UC-7112-LX [1] after merging
linux-nomadik/fttmr010 into next-20170518.

[1] 
https://bitbucket.org/Kasreyn/linux-next/commits/2904b508ad46bd98b09c11e312c396d672fc7e9a
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc1-next-20170518-00010-g2904b50
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4483 PREEMPT
Thu May 18 11:38:28 CEST 2017
[0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[0.00] CPU: VIVT data cache, VIVT instruction cache
[0.00] OF: fdt: Machine model: MOXA UC-7112-LX
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writeback
[0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[0.00] Kernel command line: console=ttyS0,115200n8 earlyprintk
root=/dev/mmcblk0p1 rw rootwait
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Memory: 19172K/32768K available (3421K kernel code,
156K rwdata, 724K rodata, 192K init, 8587K bss, 13596K reserved, 0K
cma-reserved)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xffc0 - 0xfff0   (3072 kB)
[0.00] vmalloc : 0xc280 - 0xff80   ( 976 MB)
[0.00] lowmem  : 0xc000 - 0xc200   (  32 MB)
[0.00]   .text : 0xc0008000 - 0xc035f700   (3422 kB)
[0.00]   .init : 0xc043 - 0xc046   ( 192 kB)
[0.00]   .data : 0xc046 - 0xc0487360   ( 157 kB)
[0.00].bss : 0xc048ba40 - 0xc0cee7ec   (8588 kB)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Running RCU self tests
[0.00] Preemptible hierarchical RCU implementation.
[0.00] RCU lockdep checking is enabled.
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] clocksource: FTTMR010-TIMER2: mask: 0x
max_cycles: 0x, max_idle_ns: 39817925974 ns
[0.87] sched_clock: 32 bits at 48MHz, resolution 20ns, wraps
every 44739242997ns
[0.009487] Lock dependency validator: Copyright (c) 2006 Red Hat,
Inc., Ingo Molnar
[0.017848] ... MAX_LOCKDEP_SUBCLASSES:  8
[0.024640] ... MAX_LOCK_DEPTH:  48
[0.029566] ... MAX_LOCKDEP_KEYS:8191
[0.034261] ... CLASSHASH_SIZE:  4096
[0.039299] ... MAX_LOCKDEP_ENTRIES: 32768
[0.044069] ... MAX_LOCKDEP_CHAINS:  65536
[0.049183] ... CHAINHASH_SIZE:  32768
[0.053969]  memory used by lock dependency info: 5167 kB
[0.060064]  per task-struct memory footprint: 1536 bytes
[0.072855] kmemleak: Kernel memory leak detector disabled
[0.091073] kmemleak: Early log buffer exceeded (1229), please
increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE
[0.101346] Calibrating delay loop... 143.76 BogoMIPS (lpj=718848)
[0.175662] pid_max: default: 4096 minimum: 301
[0.183736] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.191487] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.217924] CPU: Testing write buffer coherency: ok
[0.250678] Setting up static identity map for 0x8200 - 0x8248
[0.262190] Hierarchical SRCU implementation.
[0.327717] devtmpfs: initialized
[0.407364] DMA-API: preallocated 4096 debug entries
[0.413210] DMA-API: debugging enabled by kernel config
[0.445120] clocksource: jiffies: mask: 0x max_cycles:
0x, max_idle_ns: 1911260446275 ns
[0.458278] kworker/u2:0 (14) used greatest stack depth: 6224 bytes left
[0.467584] futex hash table entries: 16 (order: -3, 704 bytes)
[0.498128] NET: Registered protocol family 16
[0.518378] DMA: preallocated 256 KiB pool for atomic coherent allocations
[0.558707] kworker/u2:1 (17) used greatest stack depth: 5856 bytes left
[1.322437] clocksource: Switched to clocksource FTTMR010-TIMER2
[1.426799] NET: Registered protocol family 2
[1.448712] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[1.457909] TCP bind hash table entries: 1024 (order: 3, 36864 bytes)
[1.468402] TCP: Hash tables configured (established 1024 bind 1024)
[1.479267] UDP hash table entries: 128 (order: 1, 10240 bytes)
[1.487244] UDP-Lite hash table entries: 128 (order: 1, 10240 bytes)
[1.501083] NET: Registered protocol family 1
[1.555364] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[2.067555] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[

Re: [PATCH 0/8] clocksource: Generalize Faraday timer

2017-05-18 Thread Jonas Jensen
On 17 May 2017 at 16:05, Linus Walleij  wrote:
> The patches can be applied as soon as Jonas Jensen and Joel
> Stanley says they work for them.

Thanks! fttmr010 seem to work OK!

I did the usual test on UC-7112-LX [1] after merging
linux-nomadik/fttmr010 into next-20170518.

[1] 
https://bitbucket.org/Kasreyn/linux-next/commits/2904b508ad46bd98b09c11e312c396d672fc7e9a
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc1-next-20170518-00010-g2904b50
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4483 PREEMPT
Thu May 18 11:38:28 CEST 2017
[0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[0.00] CPU: VIVT data cache, VIVT instruction cache
[0.00] OF: fdt: Machine model: MOXA UC-7112-LX
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writeback
[0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[0.00] Kernel command line: console=ttyS0,115200n8 earlyprintk
root=/dev/mmcblk0p1 rw rootwait
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Memory: 19172K/32768K available (3421K kernel code,
156K rwdata, 724K rodata, 192K init, 8587K bss, 13596K reserved, 0K
cma-reserved)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xffc0 - 0xfff0   (3072 kB)
[0.00] vmalloc : 0xc280 - 0xff80   ( 976 MB)
[0.00] lowmem  : 0xc000 - 0xc200   (  32 MB)
[0.00]   .text : 0xc0008000 - 0xc035f700   (3422 kB)
[0.00]   .init : 0xc043 - 0xc046   ( 192 kB)
[0.00]   .data : 0xc046 - 0xc0487360   ( 157 kB)
[0.00].bss : 0xc048ba40 - 0xc0cee7ec   (8588 kB)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Running RCU self tests
[0.00] Preemptible hierarchical RCU implementation.
[0.00] RCU lockdep checking is enabled.
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] clocksource: FTTMR010-TIMER2: mask: 0x
max_cycles: 0x, max_idle_ns: 39817925974 ns
[0.87] sched_clock: 32 bits at 48MHz, resolution 20ns, wraps
every 44739242997ns
[0.009487] Lock dependency validator: Copyright (c) 2006 Red Hat,
Inc., Ingo Molnar
[0.017848] ... MAX_LOCKDEP_SUBCLASSES:  8
[0.024640] ... MAX_LOCK_DEPTH:  48
[0.029566] ... MAX_LOCKDEP_KEYS:8191
[0.034261] ... CLASSHASH_SIZE:  4096
[0.039299] ... MAX_LOCKDEP_ENTRIES: 32768
[0.044069] ... MAX_LOCKDEP_CHAINS:  65536
[0.049183] ... CHAINHASH_SIZE:  32768
[0.053969]  memory used by lock dependency info: 5167 kB
[0.060064]  per task-struct memory footprint: 1536 bytes
[0.072855] kmemleak: Kernel memory leak detector disabled
[0.091073] kmemleak: Early log buffer exceeded (1229), please
increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE
[0.101346] Calibrating delay loop... 143.76 BogoMIPS (lpj=718848)
[0.175662] pid_max: default: 4096 minimum: 301
[0.183736] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.191487] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.217924] CPU: Testing write buffer coherency: ok
[0.250678] Setting up static identity map for 0x8200 - 0x8248
[0.262190] Hierarchical SRCU implementation.
[0.327717] devtmpfs: initialized
[0.407364] DMA-API: preallocated 4096 debug entries
[0.413210] DMA-API: debugging enabled by kernel config
[0.445120] clocksource: jiffies: mask: 0x max_cycles:
0x, max_idle_ns: 1911260446275 ns
[0.458278] kworker/u2:0 (14) used greatest stack depth: 6224 bytes left
[0.467584] futex hash table entries: 16 (order: -3, 704 bytes)
[0.498128] NET: Registered protocol family 16
[0.518378] DMA: preallocated 256 KiB pool for atomic coherent allocations
[0.558707] kworker/u2:1 (17) used greatest stack depth: 5856 bytes left
[1.322437] clocksource: Switched to clocksource FTTMR010-TIMER2
[1.426799] NET: Registered protocol family 2
[1.448712] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[1.457909] TCP bind hash table entries: 1024 (order: 3, 36864 bytes)
[1.468402] TCP: Hash tables configured (established 1024 bind 1024)
[1.479267] UDP hash table entries: 128 (order: 1, 10240 bytes)
[1.487244] UDP-Lite hash table entries: 128 (order: 1, 10240 bytes)
[1.501083] NET: Registered protocol family 1
[1.555364] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[2.067555] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[2.209611] io scheduler noop regi

Re: [PATCH v2] net: moxa: fix TX overrun memory leak

2017-03-28 Thread Jonas Jensen
On 28 March 2017 at 05:50, David Miller  wrote:
> Doing the wakeup unconditionally is very wasteful, you just need to do it
> when enough space has been made available.

Thanks, please see v3.


   Jonas


Re: [PATCH v2] net: moxa: fix TX overrun memory leak

2017-03-28 Thread Jonas Jensen
On 28 March 2017 at 05:50, David Miller  wrote:
> Doing the wakeup unconditionally is very wasteful, you just need to do it
> when enough space has been made available.

Thanks, please see v3.


   Jonas


[PATCH v3] net: moxa: fix TX overrun memory leak

2017-03-28 Thread Jonas Jensen
moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit() stopping the queue at the
end of the circular buffer. Also add a check in moxart_tx_finished()
waking the queue if the buffer has TX_WAKE_THRESHOLD or more
free descriptors.

While we're at it, move spin_lock_irq() to happen before our
descriptor pointer is assigned in moxart_mac_start_xmit().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen <jonas.jen...@gmail.com>
---

Notes:
ChangeLog v2->v3:
- add wakeup threshold
ChangeLog v1->v2:
- stop queue instead of dropping frames

Applies to next-20170310

 drivers/net/ethernet/moxa/moxart_ether.c | 20 ++--
 drivers/net/ethernet/moxa/moxart_ether.h |  1 +
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 06c9f41..6ad44be 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -278,6 +279,13 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
return rx;
 }
 
+static int moxart_tx_queue_space(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return CIRC_SPACE(priv->tx_head, priv->tx_tail, TX_DESC_NUM);
+}
+
 static void moxart_tx_finished(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -297,6 +305,9 @@ static void moxart_tx_finished(struct net_device *ndev)
tx_tail = TX_NEXT(tx_tail);
}
priv->tx_tail = tx_tail;
+   if (netif_queue_stopped(ndev) &&
+   moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD)
+   netif_wake_queue(ndev);
 }
 
 static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
@@ -324,13 +335,18 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
void *desc;
unsigned int len;
-   unsigned int tx_head = priv->tx_head;
+   unsigned int tx_head;
u32 txdes1;
int ret = NETDEV_TX_BUSY;
 
+   spin_lock_irq(>txlock);
+
+   tx_head = priv->tx_head;
desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head);
 
-   spin_lock_irq(>txlock);
+   if (moxart_tx_queue_space(ndev) == 1)
+   netif_stop_queue(ndev);
+
if (moxart_desc_read(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) {
net_dbg_ratelimited("no TX space for packet\n");
priv->stats.tx_dropped++;
diff --git a/drivers/net/ethernet/moxa/moxart_ether.h 
b/drivers/net/ethernet/moxa/moxart_ether.h
index 93a9563..afc32ec 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.h
+++ b/drivers/net/ethernet/moxa/moxart_ether.h
@@ -59,6 +59,7 @@
 #define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK))
 #define TX_BUF_SIZE1600
 #define TX_BUF_SIZE_MAX(TX_DESC1_BUF_SIZE_MASK+1)
+#define TX_WAKE_THRESHOLD  16
 
 #define RX_DESC_NUM64
 #define RX_DESC_NUM_MASK   (RX_DESC_NUM-1)
-- 
1.8.2.1



[PATCH v3] net: moxa: fix TX overrun memory leak

2017-03-28 Thread Jonas Jensen
moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit() stopping the queue at the
end of the circular buffer. Also add a check in moxart_tx_finished()
waking the queue if the buffer has TX_WAKE_THRESHOLD or more
free descriptors.

While we're at it, move spin_lock_irq() to happen before our
descriptor pointer is assigned in moxart_mac_start_xmit().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen 
---

Notes:
ChangeLog v2->v3:
- add wakeup threshold
ChangeLog v1->v2:
- stop queue instead of dropping frames

Applies to next-20170310

 drivers/net/ethernet/moxa/moxart_ether.c | 20 ++--
 drivers/net/ethernet/moxa/moxart_ether.h |  1 +
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 06c9f41..6ad44be 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -278,6 +279,13 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
return rx;
 }
 
+static int moxart_tx_queue_space(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return CIRC_SPACE(priv->tx_head, priv->tx_tail, TX_DESC_NUM);
+}
+
 static void moxart_tx_finished(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -297,6 +305,9 @@ static void moxart_tx_finished(struct net_device *ndev)
tx_tail = TX_NEXT(tx_tail);
}
priv->tx_tail = tx_tail;
+   if (netif_queue_stopped(ndev) &&
+   moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD)
+   netif_wake_queue(ndev);
 }
 
 static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
@@ -324,13 +335,18 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
void *desc;
unsigned int len;
-   unsigned int tx_head = priv->tx_head;
+   unsigned int tx_head;
u32 txdes1;
int ret = NETDEV_TX_BUSY;
 
+   spin_lock_irq(>txlock);
+
+   tx_head = priv->tx_head;
desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head);
 
-   spin_lock_irq(>txlock);
+   if (moxart_tx_queue_space(ndev) == 1)
+   netif_stop_queue(ndev);
+
if (moxart_desc_read(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) {
net_dbg_ratelimited("no TX space for packet\n");
priv->stats.tx_dropped++;
diff --git a/drivers/net/ethernet/moxa/moxart_ether.h 
b/drivers/net/ethernet/moxa/moxart_ether.h
index 93a9563..afc32ec 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.h
+++ b/drivers/net/ethernet/moxa/moxart_ether.h
@@ -59,6 +59,7 @@
 #define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK))
 #define TX_BUF_SIZE1600
 #define TX_BUF_SIZE_MAX(TX_DESC1_BUF_SIZE_MASK+1)
+#define TX_WAKE_THRESHOLD  16
 
 #define RX_DESC_NUM64
 #define RX_DESC_NUM_MASK   (RX_DESC_NUM-1)
-- 
1.8.2.1



[PATCH v2] net: moxa: fix TX overrun memory leak

2017-03-27 Thread Jonas Jensen
moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit() stopping the queue at
the end of the circular buffer. Wake it on completion.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen <jonas.jen...@gmail.com>
---

Notes:
ChangeLog v1->v2:
- stop queue instead of dropping frames

The following trick was used to trigger the leak.

On the host (where this driver runs):
1. iptables-restore /etc/iptables.conf && echo 1 > 
/proc/sys/net/ipv4/ip_forward && ifconfig eth0:0 192.168.5.1
2. cat /dev/zero | nc -l -p 3334

On a client configured with 192.168.5.1 as a gateway:
1. nc -v 192.168.5.1 3334 > /dev/null &
repeat the following multiple times, interrup after a few seconds with 
CTRL+C:
2. wget 
http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-8.7.1-amd64-netinst.iso

Result (especially note columns  and  of kmalloc-192 
and kmalloc-2048):

date && ifconfig && echo 1 > /proc/sys/vm/drop_caches && cat /proc/slabinfo
Fri Mar 24 16:22:54 CET 2017
..
  RX bytes:57737 (56.3 KiB)  TX bytes:6638 (6.4 KiB)
..
 # name
 : tunables  ..
..
kmalloc-8192   8  8   819248 : tunables000 
: slabdata  2  2  0
kmalloc-4096  13 16   409688 : tunables000 
: slabdata  2  2  0
kmalloc-2048  40 40   204884 : tunables000 
: slabdata  5  5  0
kmalloc-1024  94 96   102482 : tunables000 
: slabdata 12 12  0
kmalloc-512  17918451281 : tunables000 
: slabdata 23 23  0
kmalloc-256   76 80256   161 : tunables000 
: slabdata  5  5  0
kmalloc-192  126126192   211 : tunables000 
: slabdata  6  6  0
kmalloc-128  340416128   321 : tunables000 
: slabdata 13 13  0
kmalloc-96  8353   8358 96   421 : tunables000 
: slabdata199199  0
kmalloc-64   313320 64   641 : tunables000 
: slabdata  5  5  0
kmalloc-32  1460   1536 32  1281 : tunables000 
: slabdata 12 12  0

date && ifconfig && echo 1 > /proc/sys/vm/drop_caches && cat /proc/slabinfo
Fri Mar 24 16:26:36 CET 2017
..
  RX bytes:70381213 (67.1 MiB)  TX bytes:86208719 (82.2 MiB)
..
 # name
 : tunables  ..
..
kmalloc-8192   8  8   819248 : tunables000 
: slabdata  2  2  0
kmalloc-4096  13 16   409688 : tunables000 
: slabdata  2  2  0
kmalloc-20482159   2194   204884 : tunables000 
: slabdata275275  0
kmalloc-1024 100104   102482 : tunables000 
: slabdata 13 13  0
kmalloc-512  18218451281 : tunables000 
: slabdata 23 23  0
kmalloc-256   76 80256   161 : tunables000 
: slabdata  5  5  0
kmalloc-192 2638   2667192   211 : tunables000 
: slabdata127127  0
kmalloc-128  344416128   321 : tunables000 
: slabdata 13 13  0
kmalloc-96  8353   8358 96   421 : tunables000 
: slabdata199199  0
kmalloc-64   313320 64   641 : tunables000 
: slabdata  5  5  0
kmalloc-32  1625   1664 32  1281 : tunables000 
: slabdata 13 13  0

Applies to next-20170310

 drivers/net/ethernet/moxa/moxart_ether.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 06c9f41..fa571d5 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -297,6 +298,7 @@ static void moxart_tx_finished(struct net_device *ndev)
tx_tail = TX_NEXT(tx_tail);
}
priv->tx_tail = tx_tail;
+   netif_wake_queue(ndev);
 }
 
 static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
@@ -324,13 +326,19 @@ static int moxart_mac_start_xmit(st

[PATCH v2] net: moxa: fix TX overrun memory leak

2017-03-27 Thread Jonas Jensen
moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit() stopping the queue at
the end of the circular buffer. Wake it on completion.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen 
---

Notes:
ChangeLog v1->v2:
- stop queue instead of dropping frames

The following trick was used to trigger the leak.

On the host (where this driver runs):
1. iptables-restore /etc/iptables.conf && echo 1 > 
/proc/sys/net/ipv4/ip_forward && ifconfig eth0:0 192.168.5.1
2. cat /dev/zero | nc -l -p 3334

On a client configured with 192.168.5.1 as a gateway:
1. nc -v 192.168.5.1 3334 > /dev/null &
repeat the following multiple times, interrup after a few seconds with 
CTRL+C:
2. wget 
http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-8.7.1-amd64-netinst.iso

Result (especially note columns  and  of kmalloc-192 
and kmalloc-2048):

date && ifconfig && echo 1 > /proc/sys/vm/drop_caches && cat /proc/slabinfo
Fri Mar 24 16:22:54 CET 2017
..
  RX bytes:57737 (56.3 KiB)  TX bytes:6638 (6.4 KiB)
..
 # name
 : tunables  ..
..
kmalloc-8192   8  8   819248 : tunables000 
: slabdata  2  2  0
kmalloc-4096  13 16   409688 : tunables000 
: slabdata  2  2  0
kmalloc-2048  40 40   204884 : tunables000 
: slabdata  5  5  0
kmalloc-1024  94 96   102482 : tunables000 
: slabdata 12 12  0
kmalloc-512  17918451281 : tunables000 
: slabdata 23 23  0
kmalloc-256   76 80256   161 : tunables000 
: slabdata  5  5  0
kmalloc-192  126126192   211 : tunables000 
: slabdata  6  6  0
kmalloc-128  340416128   321 : tunables000 
: slabdata 13 13  0
kmalloc-96  8353   8358 96   421 : tunables000 
: slabdata199199  0
kmalloc-64   313320 64   641 : tunables000 
: slabdata  5  5  0
kmalloc-32  1460   1536 32  1281 : tunables000 
: slabdata 12 12  0

date && ifconfig && echo 1 > /proc/sys/vm/drop_caches && cat /proc/slabinfo
Fri Mar 24 16:26:36 CET 2017
..
  RX bytes:70381213 (67.1 MiB)  TX bytes:86208719 (82.2 MiB)
..
 # name
 : tunables  ..
..
kmalloc-8192   8  8   819248 : tunables000 
: slabdata  2  2  0
kmalloc-4096  13 16   409688 : tunables000 
: slabdata  2  2  0
kmalloc-20482159   2194   204884 : tunables000 
: slabdata275275  0
kmalloc-1024 100104   102482 : tunables000 
: slabdata 13 13  0
kmalloc-512  18218451281 : tunables000 
: slabdata 23 23  0
kmalloc-256   76 80256   161 : tunables000 
: slabdata  5  5  0
kmalloc-192 2638   2667192   211 : tunables000 
: slabdata127127  0
kmalloc-128  344416128   321 : tunables000 
: slabdata 13 13  0
kmalloc-96  8353   8358 96   421 : tunables000 
: slabdata199199  0
kmalloc-64   313320 64   641 : tunables000 
: slabdata  5  5  0
kmalloc-32  1625   1664 32  1281 : tunables000 
: slabdata 13 13  0

Applies to next-20170310

 drivers/net/ethernet/moxa/moxart_ether.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 06c9f41..fa571d5 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -297,6 +298,7 @@ static void moxart_tx_finished(struct net_device *ndev)
tx_tail = TX_NEXT(tx_tail);
}
priv->tx_tail = tx_tail;
+   netif_wake_queue(ndev);
 }
 
 static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
@@ -324,13 +326,19 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct 

[PATCH] net: moxa: fix TX overrun memory leak

2015-06-05 Thread Jonas Jensen
moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit(), exit to make sure tx_head
never passes tx_tail.

Move tx_head and place tx_tail within spinlock, avoiding read-write
race that could happen when interrupts hit at the wrong moment.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20150604

 drivers/net/ethernet/moxa/moxart_ether.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index becbb5f..e0af86c 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -312,13 +313,22 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
void __iomem *desc;
unsigned int len;
-   unsigned int tx_head = priv->tx_head;
+   unsigned int tx_head, tx_tail;
u32 txdes1;
int ret = NETDEV_TX_BUSY;
 
+   spin_lock_irq(>txlock);
+
+   tx_head = priv->tx_head;
+   tx_tail = priv->tx_tail;
+
desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head);
 
-   spin_lock_irq(>txlock);
+   if (CIRC_SPACE(tx_head, tx_tail, TX_DESC_NUM) == 0) {
+   priv->stats.tx_dropped++;
+   goto out_unlock;
+   }
+
if (readl(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) {
net_dbg_ratelimited("no TX space for packet\n");
priv->stats.tx_dropped++;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: moxa: fix TX overrun memory leak

2015-06-05 Thread Jonas Jensen
moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit(), exit to make sure tx_head
never passes tx_tail.

Move tx_head and place tx_tail within spinlock, avoiding read-write
race that could happen when interrupts hit at the wrong moment.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20150604

 drivers/net/ethernet/moxa/moxart_ether.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index becbb5f..e0af86c 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,7 @@
 #include linux/of_irq.h
 #include linux/crc32.h
 #include linux/crc32c.h
+#include linux/circ_buf.h
 
 #include moxart_ether.h
 
@@ -312,13 +313,22 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
void __iomem *desc;
unsigned int len;
-   unsigned int tx_head = priv-tx_head;
+   unsigned int tx_head, tx_tail;
u32 txdes1;
int ret = NETDEV_TX_BUSY;
 
+   spin_lock_irq(priv-txlock);
+
+   tx_head = priv-tx_head;
+   tx_tail = priv-tx_tail;
+
desc = priv-tx_desc_base + (TX_REG_DESC_SIZE * tx_head);
 
-   spin_lock_irq(priv-txlock);
+   if (CIRC_SPACE(tx_head, tx_tail, TX_DESC_NUM) == 0) {
+   priv-stats.tx_dropped++;
+   goto out_unlock;
+   }
+
if (readl(desc + TX_REG_OFFSET_DESC0)  TX_DESC0_DMA_OWN) {
net_dbg_ratelimited(no TX space for packet\n);
priv-stats.tx_dropped++;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 1/2] net: moxa: clear TX descriptor length bits

2014-08-25 Thread Jonas Jensen
Thanks for giving feedback.

On 20 August 2014 19:10, Eric Dumazet  wrote:
> Wouldnt it be faster to not use readl() at all here ?

On 22 August 2014 06:39, David Miller  wrote:
> Like others I wonder why the existing descriptor value is being read
> at all.

It makes sense and I have verified, transfers continue to work
clearing the whole thing, see update in v6.


Regards,

   Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-25 Thread Jonas Jensen
Thanks for giving feedback.

On 21 August 2014 23:43, Michał Mirosław  wrote:
> This has implicit: if (!skb) BUG(); There should probably be a return
> or continue inside the if (!skb).

Fixed, see v6 update (broken out to separate patch) which now includes
increment to RX head counter

> dma_sync_single_for_device() is not needed here as CPU does not and
> should not write to the DMA_FROM_DEVICE mapping.

Fixed, this was also broken out, dma_sync_single_for_device() moved to TX path.
Maybe someone can verify this is the correct thing to do.


Regards,

   Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 4/4] net: moxa: continue loop on skb allocation failure

2014-08-25 Thread Jonas Jensen
If netdev_alloc_skb_ip_align() fails, subsequent code will
try to dereference an invalid pointer.

Continue to next descriptor on error.

While we're at it,

1. eliminate the chance of an endless loop, replace the main
   loop with while(rx < budget)

2. use napi_complete() and remove the explicit napi_gro_flush()

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 983d019..2f12c88 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -206,7 +206,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
int rx_head = priv->rx_head;
int rx = 0;
 
-   while (1) {
+   while (rx < budget) {
desc = priv->rx_desc_base + (RX_REG_DESC_SIZE * rx_head);
desc0 = readl(desc + RX_REG_OFFSET_DESC0);
 
@@ -218,7 +218,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
net_dbg_ratelimited("packet error\n");
priv->stats.rx_dropped++;
priv->stats.rx_errors++;
-   continue;
+   goto rx_next;
}
 
len = desc0 & RX_DESC0_FRAME_LEN_MASK;
@@ -235,6 +235,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
net_dbg_ratelimited("netdev_alloc_skb_ip_align 
failed\n");
priv->stats.rx_dropped++;
priv->stats.rx_errors++;
+   goto rx_next;
}
 
memcpy(skb->data, priv->rx_buf[rx_head], len);
@@ -249,18 +250,15 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (desc0 & RX_DESC0_MULTICAST)
priv->stats.multicast++;
 
+rx_next:
writel(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0);
 
rx_head = RX_NEXT(rx_head);
priv->rx_head = rx_head;
-
-   if (rx >= budget)
-   break;
}
 
if (rx < budget) {
-   napi_gro_flush(napi, false);
-   __napi_complete(napi);
+   napi_complete(napi);
}
 
priv->reg_imr |= RPKT_FINISH_M;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/4] net: moxa: synchronize DMA memory

2014-08-25 Thread Jonas Jensen
DMA memory should be synchronized before data is passed
to/from controller.

Add dma_sync_single_for_cpu(.., DMA_FROM_DEVICE) to RX path
and dma_sync_single_for_device(.., DMA_TO_DEVICE) to TX path.

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index d66058d..983d019 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,6 +226,9 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len > RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
+   dma_sync_single_for_cpu(>dev,
+   priv->rx_mapping[rx_head],
+   priv->rx_buf_size, DMA_FROM_DEVICE);
skb = netdev_alloc_skb_ip_align(ndev, len);
 
if (unlikely(!skb)) {
@@ -348,6 +351,9 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
len = ETH_ZLEN;
}
 
+   dma_sync_single_for_device(>dev, priv->tx_mapping[tx_head],
+  priv->tx_buf_size, DMA_TO_DEVICE);
+
txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK);
if (tx_head == TX_DESC_NUM_MASK)
txdes1 |= TX_DESC1_END;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/4] net: moxa: clear DESC1 on ndo_start_xmit()

2014-08-25 Thread Jonas Jensen
TX buffer length is not cleared on ndo_start_xmit().
Failing to do so can bug/hang the controller and
cause TX interrupts to stop altogether.

Remove the readl() and compute a new value for DESC1.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen 
---

Notes:
Changes since v5:

1. remove readl(desc + TX_REG_OFFSET_DESC1) in moxart_mac_start_xmit()
2. compute entirely new values for DESC1
3. set TX_DESC1_END if (tx_head == TX_DESC_NUM_MASK)

Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..eed70d9 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -346,10 +346,9 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
len = ETH_ZLEN;
}
 
-   txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
-   txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
-   txdes1 |= (len & TX_DESC1_BUF_SIZE_MASK);
+   txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK);
+   if (tx_head == TX_DESC_NUM_MASK)
+   txdes1 |= TX_DESC1_END;
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
 
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 2/4] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-25 Thread Jonas Jensen
build_skb() is used to make skbs out of existing RX ring memory
which is bad because the RX ring is allocated only once, on probe.
Memory corruption occur because said memory is reclaimed, i.e.
__kfree_skb() (and eventually put_page()).

Replace build_skb() with netdev_alloc_skb_ip_align() and use memcpy().

Remove SKB_DATA_ALIGN() from RX buffer size while we're at it.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen 
---

Notes:
Changes since v5:

1. broke out DMA synchronization to separate patch

Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index eed70d9..d66058d 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,13 +226,15 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len > RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv->rx_buf[rx_head], priv->rx_buf_size);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
+
if (unlikely(!skb)) {
-   net_dbg_ratelimited("build_skb failed\n");
+   net_dbg_ratelimited("netdev_alloc_skb_ip_align 
failed\n");
priv->stats.rx_dropped++;
priv->stats.rx_errors++;
}
 
+   memcpy(skb->data, priv->rx_buf[rx_head], len);
skb_put(skb, len);
skb->protocol = eth_type_trans(skb, ndev);
napi_gro_receive(>napi, skb);
@@ -464,8 +466,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
spin_lock_init(>txlock);
 
priv->tx_buf_size = TX_BUF_SIZE;
-   priv->rx_buf_size = RX_BUF_SIZE +
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+   priv->rx_buf_size = RX_BUF_SIZE;
 
priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
TX_DESC_NUM, >tx_base,
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 2/4] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-25 Thread Jonas Jensen
build_skb() is used to make skbs out of existing RX ring memory
which is bad because the RX ring is allocated only once, on probe.
Memory corruption occur because said memory is reclaimed, i.e.
__kfree_skb() (and eventually put_page()).

Replace build_skb() with netdev_alloc_skb_ip_align() and use memcpy().

Remove SKB_DATA_ALIGN() from RX buffer size while we're at it.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes since v5:

1. broke out DMA synchronization to separate patch

Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index eed70d9..d66058d 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,13 +226,15 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len  RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv-rx_buf[rx_head], priv-rx_buf_size);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
+
if (unlikely(!skb)) {
-   net_dbg_ratelimited(build_skb failed\n);
+   net_dbg_ratelimited(netdev_alloc_skb_ip_align 
failed\n);
priv-stats.rx_dropped++;
priv-stats.rx_errors++;
}
 
+   memcpy(skb-data, priv-rx_buf[rx_head], len);
skb_put(skb, len);
skb-protocol = eth_type_trans(skb, ndev);
napi_gro_receive(priv-napi, skb);
@@ -464,8 +466,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
spin_lock_init(priv-txlock);
 
priv-tx_buf_size = TX_BUF_SIZE;
-   priv-rx_buf_size = RX_BUF_SIZE +
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+   priv-rx_buf_size = RX_BUF_SIZE;
 
priv-tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
TX_DESC_NUM, priv-tx_base,
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/4] net: moxa: clear DESC1 on ndo_start_xmit()

2014-08-25 Thread Jonas Jensen
TX buffer length is not cleared on ndo_start_xmit().
Failing to do so can bug/hang the controller and
cause TX interrupts to stop altogether.

Remove the readl() and compute a new value for DESC1.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes since v5:

1. remove readl(desc + TX_REG_OFFSET_DESC1) in moxart_mac_start_xmit()
2. compute entirely new values for DESC1
3. set TX_DESC1_END if (tx_head == TX_DESC_NUM_MASK)

Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..eed70d9 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -346,10 +346,9 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
len = ETH_ZLEN;
}
 
-   txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
-   txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
-   txdes1 |= (len  TX_DESC1_BUF_SIZE_MASK);
+   txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len  TX_DESC1_BUF_SIZE_MASK);
+   if (tx_head == TX_DESC_NUM_MASK)
+   txdes1 |= TX_DESC1_END;
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
 
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-25 Thread Jonas Jensen
Thanks for giving feedback.

On 21 August 2014 23:43, Michał Mirosław mir...@gmail.com wrote:
 This has implicit: if (!skb) BUG(); There should probably be a return
 or continue inside the if (!skb).

Fixed, see v6 update (broken out to separate patch) which now includes
increment to RX head counter

 dma_sync_single_for_device() is not needed here as CPU does not and
 should not write to the DMA_FROM_DEVICE mapping.

Fixed, this was also broken out, dma_sync_single_for_device() moved to TX path.
Maybe someone can verify this is the correct thing to do.


Regards,

   Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 4/4] net: moxa: continue loop on skb allocation failure

2014-08-25 Thread Jonas Jensen
If netdev_alloc_skb_ip_align() fails, subsequent code will
try to dereference an invalid pointer.

Continue to next descriptor on error.

While we're at it,

1. eliminate the chance of an endless loop, replace the main
   loop with while(rx  budget)

2. use napi_complete() and remove the explicit napi_gro_flush()

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 983d019..2f12c88 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -206,7 +206,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
int rx_head = priv-rx_head;
int rx = 0;
 
-   while (1) {
+   while (rx  budget) {
desc = priv-rx_desc_base + (RX_REG_DESC_SIZE * rx_head);
desc0 = readl(desc + RX_REG_OFFSET_DESC0);
 
@@ -218,7 +218,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
net_dbg_ratelimited(packet error\n);
priv-stats.rx_dropped++;
priv-stats.rx_errors++;
-   continue;
+   goto rx_next;
}
 
len = desc0  RX_DESC0_FRAME_LEN_MASK;
@@ -235,6 +235,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
net_dbg_ratelimited(netdev_alloc_skb_ip_align 
failed\n);
priv-stats.rx_dropped++;
priv-stats.rx_errors++;
+   goto rx_next;
}
 
memcpy(skb-data, priv-rx_buf[rx_head], len);
@@ -249,18 +250,15 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (desc0  RX_DESC0_MULTICAST)
priv-stats.multicast++;
 
+rx_next:
writel(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0);
 
rx_head = RX_NEXT(rx_head);
priv-rx_head = rx_head;
-
-   if (rx = budget)
-   break;
}
 
if (rx  budget) {
-   napi_gro_flush(napi, false);
-   __napi_complete(napi);
+   napi_complete(napi);
}
 
priv-reg_imr |= RPKT_FINISH_M;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/4] net: moxa: synchronize DMA memory

2014-08-25 Thread Jonas Jensen
DMA memory should be synchronized before data is passed
to/from controller.

Add dma_sync_single_for_cpu(.., DMA_FROM_DEVICE) to RX path
and dma_sync_single_for_device(.., DMA_TO_DEVICE) to TX path.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140825

 drivers/net/ethernet/moxa/moxart_ether.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index d66058d..983d019 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,6 +226,9 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len  RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
+   dma_sync_single_for_cpu(ndev-dev,
+   priv-rx_mapping[rx_head],
+   priv-rx_buf_size, DMA_FROM_DEVICE);
skb = netdev_alloc_skb_ip_align(ndev, len);
 
if (unlikely(!skb)) {
@@ -348,6 +351,9 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
len = ETH_ZLEN;
}
 
+   dma_sync_single_for_device(ndev-dev, priv-tx_mapping[tx_head],
+  priv-tx_buf_size, DMA_TO_DEVICE);
+
txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len  TX_DESC1_BUF_SIZE_MASK);
if (tx_head == TX_DESC_NUM_MASK)
txdes1 |= TX_DESC1_END;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 1/2] net: moxa: clear TX descriptor length bits

2014-08-25 Thread Jonas Jensen
Thanks for giving feedback.

On 20 August 2014 19:10, Eric Dumazet eric.duma...@gmail.com wrote:
 Wouldnt it be faster to not use readl() at all here ?

On 22 August 2014 06:39, David Miller da...@davemloft.net wrote:
 Like others I wonder why the existing descriptor value is being read
 at all.

It makes sense and I have verified, transfers continue to work
clearing the whole thing, see update in v6.


Regards,

   Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-20 Thread Jonas Jensen
On 19 August 2014 20:31, Eric Dumazet  wrote:
> Instead of :
>
> priv->rx_buf_size = RX_BUF_SIZE +
> SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
>
> I think rx_buf_size can now be RX_BUF_SIZE

You're right, that's now a remnant, see update in v5.


> Another point is that priv->stats seems not needed, as ndev->stats could
> be used instead (and remove moxart_mac_get_stats())

I will fix that. I can add it to patches adding support for ethtool /
stats and PHY.

I think I'm supposed to post those closer to the merge window, which
would keep this set about bug fixes only.


Regards,


   Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/2] net: moxa: clear TX descriptor length bits

2014-08-20 Thread Jonas Jensen
TX buffer length is not cleared on ndo_start_xmit().
Failing to do so can bug/hang the controller and
cause TX interrupts to stop altogether.

Add TX_DESC1_BUF_SIZE_MASK to bits that are cleared,
before the TX buffer length is set.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen 
---

Notes:
No changes since v4.

Applies to next-20140820

 drivers/net/ethernet/moxa/moxart_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..aa45607 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -348,7 +348,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE |
+   TX_DESC1_BUF_SIZE_MASK);
txdes1 |= (len & TX_DESC1_BUF_SIZE_MASK);
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-20 Thread Jonas Jensen
build_skb() is used to make skbs out of existing RX ring memory
which is bad because the RX ring is allocated only once, on probe.
Memory corruption occur because said memory is reclaimed, i.e.
__kfree_skb() (and eventually put_page()).

Replace build_skb() with netdev_alloc_skb_ip_align(), use memcpy(),
and synchronize DMA memory before passing skb to napi_gro_receive().

Remove SKB_DATA_ALIGN() from RX buffer size while we're at it.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen 
---

Notes:
Changes since v4:

1. remove SKB_DATA_ALIGN() from RX buffer size

Applies to next-20140820

 drivers/net/ethernet/moxa/moxart_ether.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index aa45607..06a6fce 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,14 +226,21 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len > RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv->rx_buf[rx_head], priv->rx_buf_size);
+   dma_sync_single_for_cpu(>dev,
+   priv->rx_mapping[rx_head],
+   priv->rx_buf_size, DMA_FROM_DEVICE);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
if (unlikely(!skb)) {
-   net_dbg_ratelimited("build_skb failed\n");
+   net_dbg_ratelimited("netdev_alloc_skb_ip_align 
failed\n");
priv->stats.rx_dropped++;
priv->stats.rx_errors++;
}
-
+   memcpy(skb->data, priv->rx_buf[rx_head], len);
skb_put(skb, len);
+   dma_sync_single_for_device(>dev,
+  priv->rx_mapping[rx_head],
+  priv->rx_buf_size, DMA_FROM_DEVICE);
+
skb->protocol = eth_type_trans(skb, ndev);
napi_gro_receive(>napi, skb);
rx++;
@@ -466,8 +473,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
spin_lock_init(>txlock);
 
priv->tx_buf_size = TX_BUF_SIZE;
-   priv->rx_buf_size = RX_BUF_SIZE +
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+   priv->rx_buf_size = RX_BUF_SIZE;
 
priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
TX_DESC_NUM, >tx_base,
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: fs: panic in mnt_set_mountpoint

2014-08-20 Thread Jonas Jensen
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 4246696dc678..a6815027f225 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -736,6 +736,7 @@ static struct mountpoint *new_mountpoint(struct dentry 
> *dentry)
> return ERR_PTR(ret);
> }
>
> +   INIT_HLIST_HEAD(>m_list);
> mp->m_dentry = dentry;
> mp->m_count = 1;
> hlist_add_head(>m_hash, chain);

I can confirm this has been fixed in next-20140820, my boards boot
without panic after rebase (commit: "Merge remote-tracking branch
'vfs/for-next'" - 002561f4e9e40e5444a8776daeaa4e5a718c376c).

Thanks!


   Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: fs: panic in mnt_set_mountpoint

2014-08-20 Thread Jonas Jensen
 diff --git a/fs/namespace.c b/fs/namespace.c
 index 4246696dc678..a6815027f225 100644
 --- a/fs/namespace.c
 +++ b/fs/namespace.c
 @@ -736,6 +736,7 @@ static struct mountpoint *new_mountpoint(struct dentry 
 *dentry)
 return ERR_PTR(ret);
 }

 +   INIT_HLIST_HEAD(mp-m_list);
 mp-m_dentry = dentry;
 mp-m_count = 1;
 hlist_add_head(mp-m_hash, chain);

I can confirm this has been fixed in next-20140820, my boards boot
without panic after rebase (commit: Merge remote-tracking branch
'vfs/for-next' - 002561f4e9e40e5444a8776daeaa4e5a718c376c).

Thanks!


   Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/2] net: moxa: clear TX descriptor length bits

2014-08-20 Thread Jonas Jensen
TX buffer length is not cleared on ndo_start_xmit().
Failing to do so can bug/hang the controller and
cause TX interrupts to stop altogether.

Add TX_DESC1_BUF_SIZE_MASK to bits that are cleared,
before the TX buffer length is set.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
No changes since v4.

Applies to next-20140820

 drivers/net/ethernet/moxa/moxart_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..aa45607 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -348,7 +348,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE |
+   TX_DESC1_BUF_SIZE_MASK);
txdes1 |= (len  TX_DESC1_BUF_SIZE_MASK);
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-20 Thread Jonas Jensen
build_skb() is used to make skbs out of existing RX ring memory
which is bad because the RX ring is allocated only once, on probe.
Memory corruption occur because said memory is reclaimed, i.e.
__kfree_skb() (and eventually put_page()).

Replace build_skb() with netdev_alloc_skb_ip_align(), use memcpy(),
and synchronize DMA memory before passing skb to napi_gro_receive().

Remove SKB_DATA_ALIGN() from RX buffer size while we're at it.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes since v4:

1. remove SKB_DATA_ALIGN() from RX buffer size

Applies to next-20140820

 drivers/net/ethernet/moxa/moxart_ether.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index aa45607..06a6fce 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,14 +226,21 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len  RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv-rx_buf[rx_head], priv-rx_buf_size);
+   dma_sync_single_for_cpu(ndev-dev,
+   priv-rx_mapping[rx_head],
+   priv-rx_buf_size, DMA_FROM_DEVICE);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
if (unlikely(!skb)) {
-   net_dbg_ratelimited(build_skb failed\n);
+   net_dbg_ratelimited(netdev_alloc_skb_ip_align 
failed\n);
priv-stats.rx_dropped++;
priv-stats.rx_errors++;
}
-
+   memcpy(skb-data, priv-rx_buf[rx_head], len);
skb_put(skb, len);
+   dma_sync_single_for_device(ndev-dev,
+  priv-rx_mapping[rx_head],
+  priv-rx_buf_size, DMA_FROM_DEVICE);
+
skb-protocol = eth_type_trans(skb, ndev);
napi_gro_receive(priv-napi, skb);
rx++;
@@ -466,8 +473,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
spin_lock_init(priv-txlock);
 
priv-tx_buf_size = TX_BUF_SIZE;
-   priv-rx_buf_size = RX_BUF_SIZE +
-   SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+   priv-rx_buf_size = RX_BUF_SIZE;
 
priv-tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
TX_DESC_NUM, priv-tx_base,
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-20 Thread Jonas Jensen
On 19 August 2014 20:31, Eric Dumazet eric.duma...@gmail.com wrote:
 Instead of :

 priv-rx_buf_size = RX_BUF_SIZE +
 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));

 I think rx_buf_size can now be RX_BUF_SIZE

You're right, that's now a remnant, see update in v5.


 Another point is that priv-stats seems not needed, as ndev-stats could
 be used instead (and remove moxart_mac_get_stats())

I will fix that. I can add it to patches adding support for ethtool /
stats and PHY.

I think I'm supposed to post those closer to the merge window, which
would keep this set about bug fixes only.


Regards,


   Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-19 Thread Jonas Jensen
build_skb() is used to make skbs out of existing RX ring memory
which is bad because the RX ring is allocated only once, on probe.
Memory corruption occur because said memory is reclaimed, i.e.
__kfree_skb() (and eventually put_page()).

Replace build_skb() with netdev_alloc_skb_ip_align() and use memcpy().
Also, synchronize DMA memory before passing skb to napi_gro_receive().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen 
---

Notes:
The original motivation was to avoid memcpy(), since the memory is
already allocated, why make a copy.

Maybe the copy can be avoided updating RX ring descriptor addresses;
new memory must be allocated just the same, the only difference that
the controller could write directly to it.

This fixes errors due to memory corruption, such as the following,
seen on wget download (or ncftp):

"read error: Bad address"

On receiving error, wget exits without resuming (busybox default).

Changes since v3:

1. commit message reworded

Applies to next-20140818

 drivers/net/ethernet/moxa/moxart_ether.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index aa45607..17c9f0e 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,14 +226,21 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len > RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv->rx_buf[rx_head], priv->rx_buf_size);
+   dma_sync_single_for_cpu(>dev,
+   priv->rx_mapping[rx_head],
+   priv->rx_buf_size, DMA_FROM_DEVICE);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
if (unlikely(!skb)) {
-   net_dbg_ratelimited("build_skb failed\n");
+   net_dbg_ratelimited("netdev_alloc_skb_ip_align 
failed\n");
priv->stats.rx_dropped++;
priv->stats.rx_errors++;
}
-
+   memcpy(skb->data, priv->rx_buf[rx_head], len);
skb_put(skb, len);
+   dma_sync_single_for_device(>dev,
+  priv->rx_mapping[rx_head],
+  priv->rx_buf_size, DMA_FROM_DEVICE);
+
skb->protocol = eth_type_trans(skb, ndev);
napi_gro_receive(>napi, skb);
rx++;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/2] net: moxa: clear TX descriptor length bits

2014-08-19 Thread Jonas Jensen
TX buffer length is not cleared on ndo_start_xmit().
Failing to do so can bug/hang the controller and
cause TX interrupts to stop altogether.

Add TX_DESC1_BUF_SIZE_MASK to bits that are cleared,
before the TX buffer length is set.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen 
---

Notes:
Changes since v3:

1. commit message reworded

Applies to next-20140818

 drivers/net/ethernet/moxa/moxart_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..aa45607 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -348,7 +348,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE |
+   TX_DESC1_BUF_SIZE_MASK);
txdes1 |= (len & TX_DESC1_BUF_SIZE_MASK);
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/2] net: moxa: replace build_skb() with netdev_alloc_skb_ip_align() / memcpy()

2014-08-19 Thread Jonas Jensen
build_skb() is used to make skbs out of existing RX ring memory
which is bad because the RX ring is allocated only once, on probe.
Memory corruption occur because said memory is reclaimed, i.e.
__kfree_skb() (and eventually put_page()).

Replace build_skb() with netdev_alloc_skb_ip_align() and use memcpy().
Also, synchronize DMA memory before passing skb to napi_gro_receive().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
The original motivation was to avoid memcpy(), since the memory is
already allocated, why make a copy.

Maybe the copy can be avoided updating RX ring descriptor addresses;
new memory must be allocated just the same, the only difference that
the controller could write directly to it.

This fixes errors due to memory corruption, such as the following,
seen on wget download (or ncftp):

read error: Bad address

On receiving error, wget exits without resuming (busybox default).

Changes since v3:

1. commit message reworded

Applies to next-20140818

 drivers/net/ethernet/moxa/moxart_ether.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index aa45607..17c9f0e 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,14 +226,21 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len  RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv-rx_buf[rx_head], priv-rx_buf_size);
+   dma_sync_single_for_cpu(ndev-dev,
+   priv-rx_mapping[rx_head],
+   priv-rx_buf_size, DMA_FROM_DEVICE);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
if (unlikely(!skb)) {
-   net_dbg_ratelimited(build_skb failed\n);
+   net_dbg_ratelimited(netdev_alloc_skb_ip_align 
failed\n);
priv-stats.rx_dropped++;
priv-stats.rx_errors++;
}
-
+   memcpy(skb-data, priv-rx_buf[rx_head], len);
skb_put(skb, len);
+   dma_sync_single_for_device(ndev-dev,
+  priv-rx_mapping[rx_head],
+  priv-rx_buf_size, DMA_FROM_DEVICE);
+
skb-protocol = eth_type_trans(skb, ndev);
napi_gro_receive(priv-napi, skb);
rx++;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/2] net: moxa: clear TX descriptor length bits

2014-08-19 Thread Jonas Jensen
TX buffer length is not cleared on ndo_start_xmit().
Failing to do so can bug/hang the controller and
cause TX interrupts to stop altogether.

Add TX_DESC1_BUF_SIZE_MASK to bits that are cleared,
before the TX buffer length is set.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes since v3:

1. commit message reworded

Applies to next-20140818

 drivers/net/ethernet/moxa/moxart_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..aa45607 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -348,7 +348,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE |
+   TX_DESC1_BUF_SIZE_MASK);
txdes1 |= (len  TX_DESC1_BUF_SIZE_MASK);
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


fs: panic in mnt_set_mountpoint

2014-08-18 Thread Jonas Jensen
Hi,

I've run into a kernel panic [1] in next-20140818 you might find interesting.

It surprised me because there was never an error in next-20140815, I
did a search for related panics but it came up empty.

The board boots fine after applying the following:

diff --git a/fs/namespace.c b/fs/namespace.c
index 1a2bbef..b408a9d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -746,7 +746,7 @@ static void put_mountpoint(struct mountpoint *mp)
 {
if (!--mp->m_count) {
struct dentry *dentry = mp->m_dentry;
-   BUG_ON(!hlist_empty(>m_list));
+/* BUG_ON(!hlist_empty(>m_list));*/
spin_lock(>d_lock);
dentry->d_flags &= ~DCACHE_MOUNTED;
spin_unlock(>d_lock);
@@ -810,7 +810,7 @@ void mnt_set_mountpoint(struct mount *mnt,
child_mnt->mnt_mountpoint = dget(mp->m_dentry);
child_mnt->mnt_parent = mnt;
child_mnt->mnt_mp = mp;
-   hlist_add_head(_mnt->mnt_mp_list, >m_list);
+/* hlist_add_head(_mnt->mnt_mp_list, >m_list);*/
 }


[1]
Uncompressing Linux... done, booting the kernel.
[ 0.00] Booting Linux on physical CPU 0x0
[ 0.00] Linux version 3.17.0-rc1-next-20140818+ (i@Ildjarn) (gcc
version 4.9.0 (crosstool-NG 1.19.0) ) #2691 PREEMPT Mon Aug 18
10:58:16 CEST 2014
[ 0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[ 0.00] CPU: VIVT data cache, VIVT instruction cache
[ 0.00] Machine model: MOXA UC-7112-LX
[ 0.00] bootconsole [earlycon0] enabled
[ 0.00] Memory policy: Data cache writeback
[ 0.00] On node 0 totalpages: 8192
[ 0.00] free_area_init_node: node 0, pgdat c035cfb4, node_mem_map c1fba000
[ 0.00] Normal zone: 64 pages used for memmap
[ 0.00] Normal zone: 0 pages reserved
[ 0.00] Normal zone: 8192 pages, LIFO batch:0
[ 0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.00] pcpu-alloc: [0] 0
[ 0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[ 0.00] Kernel command line: console=ttyS0,115200n8 earlyprintk
root=/dev/mmcblk0p1 rw rootwait debug
[ 0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[ 0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.00] Memory: 28852K/32768K available (2718K kernel code, 93K
rwdata, 484K rodata, 115K init, 126K bss, 3916K reserved)
[ 0.00] Virtual kernel memory layout:
[ 0.00] vector : 0x - 0x1000 ( 4 kB)
[ 0.00] fixmap : 0xffc0 - 0xffe0 (2048 kB)
[ 0.00] vmalloc : 0xc280 - 0xff00 ( 968 MB)
[ 0.00] lowmem : 0xc000 - 0xc200 ( 32 MB)
[ 0.00] .text : 0xc0008000 - 0xc0328aec (3203 kB)
[ 0.00] .init : 0xc0329000 - 0xc0345ddc ( 116 kB)
[ 0.00] .data : 0xc0346000 - 0xc035d700 ( 94 kB)
[ 0.00] .bss : 0xc035d700 - 0xc037cf24 ( 127 kB)
[ 0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.00] Preemptible hierarchical RCU implementation.
[ 0.00] NR_IRQS:16 nr_irqs:16 16
[ 0.00] sched_clock: 32 bits at 100 Hz, resolution 1000ns,
wraps every 2147483648000ns
[ 0.01] Calibrating delay loop... 147.86 BogoMIPS (lpj=739328)
[ 0.09] pid_max: default: 4096 minimum: 301
[ 0.09] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.10] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.11] CPU: Testing write buffer coherency: ok
[ 0.12] Setting up static identity map for 0x296938 - 0x296980
[ 0.14] Unhandled fault: alignment exception (0x801) at 0x0003
[ 0.14] Internal error: : 801 [#1] PREEMPT ARM
[ 0.14] CPU: 0 PID: 11 Comm: kdevtmpfs Not tainted
3.17.0-rc1-next-20140818+ #2691
[ 0.14] task: c184a360 ti: c185 task.ti: c185
[ 0.14] PC is at mnt_set_mountpoint+0x8c/0x9c
[ 0.14] LR is at mnt_set_mountpoint+0x70/0x9c
[ 0.14] pc : [] lr : [] psr: a053
[ 0.14] sp : c1851e18 ip : 0001 fp : 
[ 0.14] r10: c1802ae0 r9 : c1802ba0 r8 : 
[ 0.14] r7 : c1402000 r6 : c1842240 r5 : c1842300 r4 : c1802ba0
[ 0.14] r3 :  r2 : c184237c r1 : c1802ba0 r0 : c1402054
[ 0.14] Flags: NzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment kernel
[ 0.14] Control: 397f Table: 4000 DAC: 0017
[ 0.14] Process kdevtmpfs (pid: 11, stack limit = 0xc18501c0)
[ 0.14] Stack: (0xc1851e18 to 0xc1852000)
[ 0.14] 1e00: 000dc1842300
[ 0.14] 1e20:
c1842300c1802ba0c1842240c00a9464c1842300c1802ba0c1842300
[ 0.14] 1e40:
0020c1802ba0c1851e70c1802b00c1852000c00a96a4c0354690
[ 0.14] 1e60:
0020c1842310c034db48c00aad54c1842250c1402000c1851ec4
[ 0.14] 1e80:
c18110008000c02fdfb9
[ 0.14] 1ea0:
c00aafccc1852000c1802aa20200c1802ae0
[ 0.14] 1ec0:
c1802b00c1852000c182bf5cc1851f06c182bf5cc0172950c017299c
[ 

fs: panic in mnt_set_mountpoint

2014-08-18 Thread Jonas Jensen
Hi,

I've run into a kernel panic [1] in next-20140818 you might find interesting.

It surprised me because there was never an error in next-20140815, I
did a search for related panics but it came up empty.

The board boots fine after applying the following:

diff --git a/fs/namespace.c b/fs/namespace.c
index 1a2bbef..b408a9d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -746,7 +746,7 @@ static void put_mountpoint(struct mountpoint *mp)
 {
if (!--mp-m_count) {
struct dentry *dentry = mp-m_dentry;
-   BUG_ON(!hlist_empty(mp-m_list));
+/* BUG_ON(!hlist_empty(mp-m_list));*/
spin_lock(dentry-d_lock);
dentry-d_flags = ~DCACHE_MOUNTED;
spin_unlock(dentry-d_lock);
@@ -810,7 +810,7 @@ void mnt_set_mountpoint(struct mount *mnt,
child_mnt-mnt_mountpoint = dget(mp-m_dentry);
child_mnt-mnt_parent = mnt;
child_mnt-mnt_mp = mp;
-   hlist_add_head(child_mnt-mnt_mp_list, mp-m_list);
+/* hlist_add_head(child_mnt-mnt_mp_list, mp-m_list);*/
 }


[1]
Uncompressing Linux... done, booting the kernel.
[ 0.00] Booting Linux on physical CPU 0x0
[ 0.00] Linux version 3.17.0-rc1-next-20140818+ (i@Ildjarn) (gcc
version 4.9.0 (crosstool-NG 1.19.0) ) #2691 PREEMPT Mon Aug 18
10:58:16 CEST 2014
[ 0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[ 0.00] CPU: VIVT data cache, VIVT instruction cache
[ 0.00] Machine model: MOXA UC-7112-LX
[ 0.00] bootconsole [earlycon0] enabled
[ 0.00] Memory policy: Data cache writeback
[ 0.00] On node 0 totalpages: 8192
[ 0.00] free_area_init_node: node 0, pgdat c035cfb4, node_mem_map c1fba000
[ 0.00] Normal zone: 64 pages used for memmap
[ 0.00] Normal zone: 0 pages reserved
[ 0.00] Normal zone: 8192 pages, LIFO batch:0
[ 0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.00] pcpu-alloc: [0] 0
[ 0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[ 0.00] Kernel command line: console=ttyS0,115200n8 earlyprintk
root=/dev/mmcblk0p1 rw rootwait debug
[ 0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[ 0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.00] Memory: 28852K/32768K available (2718K kernel code, 93K
rwdata, 484K rodata, 115K init, 126K bss, 3916K reserved)
[ 0.00] Virtual kernel memory layout:
[ 0.00] vector : 0x - 0x1000 ( 4 kB)
[ 0.00] fixmap : 0xffc0 - 0xffe0 (2048 kB)
[ 0.00] vmalloc : 0xc280 - 0xff00 ( 968 MB)
[ 0.00] lowmem : 0xc000 - 0xc200 ( 32 MB)
[ 0.00] .text : 0xc0008000 - 0xc0328aec (3203 kB)
[ 0.00] .init : 0xc0329000 - 0xc0345ddc ( 116 kB)
[ 0.00] .data : 0xc0346000 - 0xc035d700 ( 94 kB)
[ 0.00] .bss : 0xc035d700 - 0xc037cf24 ( 127 kB)
[ 0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.00] Preemptible hierarchical RCU implementation.
[ 0.00] NR_IRQS:16 nr_irqs:16 16
[ 0.00] sched_clock: 32 bits at 100 Hz, resolution 1000ns,
wraps every 2147483648000ns
[ 0.01] Calibrating delay loop... 147.86 BogoMIPS (lpj=739328)
[ 0.09] pid_max: default: 4096 minimum: 301
[ 0.09] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.10] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.11] CPU: Testing write buffer coherency: ok
[ 0.12] Setting up static identity map for 0x296938 - 0x296980
[ 0.14] Unhandled fault: alignment exception (0x801) at 0x0003
[ 0.14] Internal error: : 801 [#1] PREEMPT ARM
[ 0.14] CPU: 0 PID: 11 Comm: kdevtmpfs Not tainted
3.17.0-rc1-next-20140818+ #2691
[ 0.14] task: c184a360 ti: c185 task.ti: c185
[ 0.14] PC is at mnt_set_mountpoint+0x8c/0x9c
[ 0.14] LR is at mnt_set_mountpoint+0x70/0x9c
[ 0.14] pc : [c00a8978] lr : [c00a895c] psr: a053
[ 0.14] sp : c1851e18 ip : 0001 fp : 
[ 0.14] r10: c1802ae0 r9 : c1802ba0 r8 : 
[ 0.14] r7 : c1402000 r6 : c1842240 r5 : c1842300 r4 : c1802ba0
[ 0.14] r3 :  r2 : c184237c r1 : c1802ba0 r0 : c1402054
[ 0.14] Flags: NzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment kernel
[ 0.14] Control: 397f Table: 4000 DAC: 0017
[ 0.14] Process kdevtmpfs (pid: 11, stack limit = 0xc18501c0)
[ 0.14] Stack: (0xc1851e18 to 0xc1852000)
[ 0.14] 1e00: 000dc1842300
[ 0.14] 1e20:
c1842300c1802ba0c1842240c00a9464c1842300c1802ba0c1842300
[ 0.14] 1e40:
0020c1802ba0c1851e70c1802b00c1852000c00a96a4c0354690
[ 0.14] 1e60:
0020c1842310c034db48c00aad54c1842250c1402000c1851ec4
[ 0.14] 1e80:
c18110008000c02fdfb9
[ 0.14] 1ea0:
c00aafccc1852000c1802aa20200c1802ae0
[ 0.14] 1ec0:

Re: [RFC PATCH 0/5] watchdog: Add reboot API

2014-05-06 Thread Jonas Jensen
Thanks,

Applied in series: 1, 3, and 4

Patches work on moxa UC-7112-LX hardware.

Tested-by: Jonas Jensen 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH 0/5] watchdog: Add reboot API

2014-05-06 Thread Jonas Jensen
Thanks,

Applied in series: 1, 3, and 4

Patches work on moxa UC-7112-LX hardware.

Tested-by: Jonas Jensen jonas.jen...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: moxart: add select CLKSRC_OF to ARCH_MOXART

2014-04-11 Thread Jonas Jensen
CLKSRC_OF was recently removed from options selected by
ARCH_MULTIPLATFORM, breaking boot on MOXA ART SoCs.

Add it to options selected by ARCH_MOXART.

Signed-off-by: Jonas Jensen 
---

Notes:
see "Merge tag 'cleanup-3.15' of 
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc" 
dfc25e4503aef6b82a1de4a0fbe19aafa8648fbe

Applies to next-20140409

 arch/arm/mach-moxart/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
index 82a4ba8..7b320c6 100644
--- a/arch/arm/mach-moxart/Kconfig
+++ b/arch/arm/mach-moxart/Kconfig
@@ -2,6 +2,7 @@ config ARCH_MOXART
bool "MOXA ART SoC" if ARCH_MULTI_V4
select CPU_FA526
select ARM_DMA_MEM_BUFFERABLE
+   select CLKSRC_OF
select CLKSRC_MMIO
select GENERIC_IRQ_CHIP
select ARCH_REQUIRE_GPIOLIB
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: moxart: add select CLKSRC_OF to ARCH_MOXART

2014-04-11 Thread Jonas Jensen
CLKSRC_OF was recently removed from options selected by
ARCH_MULTIPLATFORM, breaking boot on MOXA ART SoCs.

Add it to options selected by ARCH_MOXART.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
see Merge tag 'cleanup-3.15' of 
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc 
dfc25e4503aef6b82a1de4a0fbe19aafa8648fbe

Applies to next-20140409

 arch/arm/mach-moxart/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
index 82a4ba8..7b320c6 100644
--- a/arch/arm/mach-moxart/Kconfig
+++ b/arch/arm/mach-moxart/Kconfig
@@ -2,6 +2,7 @@ config ARCH_MOXART
bool MOXA ART SoC if ARCH_MULTI_V4
select CPU_FA526
select ARM_DMA_MEM_BUFFERABLE
+   select CLKSRC_OF
select CLKSRC_MMIO
select GENERIC_IRQ_CHIP
select ARCH_REQUIRE_GPIOLIB
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ARM: reinsert ARCH_MULTI_V4 Kconfig option

2014-04-10 Thread Jonas Jensen
On 9 April 2014 18:01, Russell King - ARM Linux  wrote:
> It would be useful to see the register state from the undefined
> instruction exception.  That needs this patch, CONFIG_DEBUG_USER in the
> kernel config enabled, and user_debug=1 passed on the kernel command
> line.

I have done two tests, one with user_debug=1, and one with
user_debug=31, since I expected more information on user_debug=1.

As Arnd pointed out, this is booting into a non-thumb userspace, built
with gcc version 4.9.0 20140316 and buildroot 2014.02.

Buildroot config:
https://code.google.com/p/mkrom-uc7112lx/source/browse/configs/buildroot-2014-02_eglibc-2.17_binutils-2.22_external-toolchain.config

Results:

user_debug=1 ( 
https://bitbucket.org/Kasreyn/linux-next/commits/3a32b929d7a399751c6397f0c973b356c6c9a71d
):

Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 3.14.0-next-20140409+ (i@Ildjarn)
(gcc version 4.9.0 20140316 (experimental) (crosstool-NG 1.19.0) )
#2431 PREEMPT Thu Apr 10 09:12:35 CEST 2014
..
[0.00] Kernel command line: console=ttyS0,115200n8
earlyprintk root=/dev/mmcblk0p1 rw rootwait debug user_debug=1
..
[2.70] Freeing unused kernel memory: 104K (c02f4000 - c030e000)
[3.38] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x000b
[3.38]
[3.38] CPU: 0 PID: 1 Comm: init Not tainted
3.14.0-next-20140409+ #2431
[3.38] [] (unwind_backtrace) from []
(show_stack+0x10/0x14)
[3.38] [] (show_stack) from []
(panic+0x98/0x1f4)
[3.38] [] (panic) from [] (do_exit+0x908/0x938)
[3.38] [] (do_exit) from []
(do_group_exit+0x4c/0xe8)
[3.38] [] (do_group_exit) from []
(get_signal_to_deliver+0x218/0x5f0)
[3.38] [] (get_signal_to_deliver) from
[] (do_signal+0x100/0x48c)
[3.38] [] (do_signal) from []
(do_work_pending+0xd4/0xe4)
[3.38] [] (do_work_pending) from []
(work_pending+0xc/0x20)
[3.38] Rebooting in 10 seconds..

user_debug=31 (
https://bitbucket.org/Kasreyn/linux-next/commits/8ed2db951baca29c6254de328765873fe5457727
):

[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 3.14.0-next-20140409+ (i@Ildjarn)
(gcc version 4.9.0 20140316 (experimental) (crosstool-NG 1.19.0) )
#2431 PREEMPT Thu Apr 10 09:12:35 CEST 2014
[0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[0.00] CPU: VIVT data cache, VIVT instruction cache
[0.00] Machine model: MOXA UC-7112-LX
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writeback
[0.00] On node 0 totalpages: 8192
[0.00] free_area_init_node: node 0, pgdat c0322324,
node_mem_map c1fba000
[0.00]   Normal zone: 64 pages used for memmap
[0.00]   Normal zone: 0 pages reserved
[0.00]   Normal zone: 8192 pages, LIFO batch:0
[0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[0.00] pcpu-alloc: [0] 0
[0.00] Built 1 zonelists in Zone order, mobility grouping
on.  Total pages: 8128
[0.00] Kernel command line: console=ttyS0,115200n8
earlyprintk root=/dev/mmcblk0p1 rw rootwait debug user_debug=31
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Memory: 29092K/32768K available (2542K kernel code,
74K rwdata, 448K rodata, 104K init, 116K bss, 3676K reserved)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xfff0 - 0xfffe   ( 896 kB)
[0.00] vmalloc : 0xc280 - 0xff00   ( 968 MB)
[0.00] lowmem  : 0xc000 - 0xc200   (  32 MB)
[0.00]   .text : 0xc0008000 - 0xc02f3d80   (2992 kB)
[0.00]   .init : 0xc02f4000 - 0xc030e36c   ( 105 kB)
[0.00]   .data : 0xc031 - 0xc0322aa0   (  75 kB)
[0.00].bss : 0xc0322aac - 0xc033fbc0   ( 117 kB)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Preemptible hierarchical RCU implementation.
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] sched_clock: 32 bits at 100 Hz, resolution
1000ns, wraps every 2147483648000ns
[0.01] Calibrating delay loop... 146.84 BogoMIPS (lpj=734208)
[0.10] pid_max: default: 4096 minimum: 301
[0.10] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.11] Mountpoint-cache hash table entries: 1024 (order:
0, 4096 bytes)
[0.12] CPU: Testing write buffer coherency: ok
[0.13] Setting up static 

Re: [PATCH] ARM: reinsert ARCH_MULTI_V4 Kconfig option

2014-04-10 Thread Jonas Jensen
On 9 April 2014 18:01, Russell King - ARM Linux li...@arm.linux.org.uk wrote:
 It would be useful to see the register state from the undefined
 instruction exception.  That needs this patch, CONFIG_DEBUG_USER in the
 kernel config enabled, and user_debug=1 passed on the kernel command
 line.

I have done two tests, one with user_debug=1, and one with
user_debug=31, since I expected more information on user_debug=1.

As Arnd pointed out, this is booting into a non-thumb userspace, built
with gcc version 4.9.0 20140316 and buildroot 2014.02.

Buildroot config:
https://code.google.com/p/mkrom-uc7112lx/source/browse/configs/buildroot-2014-02_eglibc-2.17_binutils-2.22_external-toolchain.config

Results:

user_debug=1 ( 
https://bitbucket.org/Kasreyn/linux-next/commits/3a32b929d7a399751c6397f0c973b356c6c9a71d
):

Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 3.14.0-next-20140409+ (i@Ildjarn)
(gcc version 4.9.0 20140316 (experimental) (crosstool-NG 1.19.0) )
#2431 PREEMPT Thu Apr 10 09:12:35 CEST 2014
..
[0.00] Kernel command line: console=ttyS0,115200n8
earlyprintk root=/dev/mmcblk0p1 rw rootwait debug user_debug=1
..
[2.70] Freeing unused kernel memory: 104K (c02f4000 - c030e000)
[3.38] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x000b
[3.38]
[3.38] CPU: 0 PID: 1 Comm: init Not tainted
3.14.0-next-20140409+ #2431
[3.38] [c000d4e0] (unwind_backtrace) from [c000bcbc]
(show_stack+0x10/0x14)
[3.38] [c000bcbc] (show_stack) from [c0268f74]
(panic+0x98/0x1f4)
[3.38] [c0268f74] (panic) from [c0016bcc] (do_exit+0x908/0x938)
[3.38] [c0016bcc] (do_exit) from [c0016c70]
(do_group_exit+0x4c/0xe8)
[3.38] [c0016c70] (do_group_exit) from [c0022098]
(get_signal_to_deliver+0x218/0x5f0)
[3.38] [c0022098] (get_signal_to_deliver) from
[c000b358] (do_signal+0x100/0x48c)
[3.38] [c000b358] (do_signal) from [c000b8ac]
(do_work_pending+0xd4/0xe4)
[3.38] [c000b8ac] (do_work_pending) from [c000933c]
(work_pending+0xc/0x20)
[3.38] Rebooting in 10 seconds..

user_debug=31 (
https://bitbucket.org/Kasreyn/linux-next/commits/8ed2db951baca29c6254de328765873fe5457727
):

[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 3.14.0-next-20140409+ (i@Ildjarn)
(gcc version 4.9.0 20140316 (experimental) (crosstool-NG 1.19.0) )
#2431 PREEMPT Thu Apr 10 09:12:35 CEST 2014
[0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[0.00] CPU: VIVT data cache, VIVT instruction cache
[0.00] Machine model: MOXA UC-7112-LX
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writeback
[0.00] On node 0 totalpages: 8192
[0.00] free_area_init_node: node 0, pgdat c0322324,
node_mem_map c1fba000
[0.00]   Normal zone: 64 pages used for memmap
[0.00]   Normal zone: 0 pages reserved
[0.00]   Normal zone: 8192 pages, LIFO batch:0
[0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[0.00] pcpu-alloc: [0] 0
[0.00] Built 1 zonelists in Zone order, mobility grouping
on.  Total pages: 8128
[0.00] Kernel command line: console=ttyS0,115200n8
earlyprintk root=/dev/mmcblk0p1 rw rootwait debug user_debug=31
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Memory: 29092K/32768K available (2542K kernel code,
74K rwdata, 448K rodata, 104K init, 116K bss, 3676K reserved)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xfff0 - 0xfffe   ( 896 kB)
[0.00] vmalloc : 0xc280 - 0xff00   ( 968 MB)
[0.00] lowmem  : 0xc000 - 0xc200   (  32 MB)
[0.00]   .text : 0xc0008000 - 0xc02f3d80   (2992 kB)
[0.00]   .init : 0xc02f4000 - 0xc030e36c   ( 105 kB)
[0.00]   .data : 0xc031 - 0xc0322aa0   (  75 kB)
[0.00].bss : 0xc0322aac - 0xc033fbc0   ( 117 kB)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Preemptible hierarchical RCU implementation.
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] sched_clock: 32 bits at 100 Hz, resolution
1000ns, wraps every 2147483648000ns
[0.01] Calibrating delay loop... 146.84 BogoMIPS (lpj=734208)
[0.10] pid_max: default: 4096 minimum: 301
[0.10] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.11] Mountpoint-cache 

Re: [PATCH] ARM: reinsert ARCH_MULTI_V4 Kconfig option

2014-04-09 Thread Jonas Jensen
On 13 December 2013 12:39, Russell King - ARM Linux
 wrote:
> I see what's causing this: the kuser helpers are using "bx lr" to return
> which will be undefined on non-Thumb CPUs.  We generally cope fine with
> non-Thumb CPUs, conditionalising where necessary on HWCAP_THUMB or the
> T bit in the PSR being set.
>
> However, it looks like the kuser helpers got missed.  As a check, please
> look at arch/arm/kernel/entry-armv.S, find the line with:
>
> .macro  usr_ret, reg
>
> and ensure that the mov pc, \reg case always gets used.  Please report
> back.

Uwe and Arnd came up with a solution except it doesn't work when I test it.

The suggested patch is:

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 1879e8d..de15bfd 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -739,6 +739,18 @@ ENDPROC(__switch_to)

.macro  usr_ret, reg
 #ifdef CONFIG_ARM_THUMB
+   /*
+* Having CONFIG_ARM_THUMB isn't a guarantee that the cpu has support
+* for Thumb and so the bx instruction. Use a mov if the address to
+* jump to is 32 bit aligned. (Note that this code is compiled in ARM
+* mode, so this is the right test.)
+*/
+#if defined(CONFIG_CPU_32v4)
+   tst \reg, #3
+   moveq   pc, \reg
+   b   .
+#endif
+
bx  \reg
 #else
mov pc, \reg


With this applied, and the following two possibilities in next-20140403:

[1] ARCH_MULTI_V4 only (no CONFIG_ARM_THUMB)
 CONFIG_CPU_32v4=y

[2] ARCH_MULTI_V4 and ARCH_MULTI_V4T
 CONFIG_ARM_THUMB=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_32v4T=y


Booting a kernel with either option [1] or [2] yield the following results:

[1] works
[2] hangs after "[2.73] Freeing unused kernel memory: 104K
(c02f5000 - c030f000)"


Any help why the moveq doesn't work would be much appreciated.


The commit where this was tested:
https://bitbucket.org/Kasreyn/linux-next/commits/48320cbe0d5a1fb6ada52cea9efd87c7712367cb


Regards,
Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v8] mmc: moxart: Add MOXA ART SD/MMC driver

2014-04-09 Thread Jonas Jensen
Add SD/MMC driver for MOXA ART SoCs.

The "MOXA ART MMC controller" is likely a faraday "ftsdc010",
a controller with support in U-Boot:

http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/mmc/ftsdc010_mci.c

Signed-off-by: Jonas Jensen 
---

Notes:
This has been cleaned up further, especially the return value fiasco in v7.

The "MOXA ART MMC controller" is likely a faraday "ftsdc010" (supported by 
U-Boot [1]).
Registers are the same albeit named slightly different.

I think this can support other "ftsdc010" SoCs with one reservation for
power control, which may need hardware specific changes.

Changes since v7:

1. merge code from U-Boot "ftsdc010" driver [1]

   Specifically how it implements status wait, clock divider, fifo width, 
bus width.

2. return value cleanup, MMC_ERR_TIMEOUT is no longer used or set at the 
top of every request

   i.e. the default (no error) return value (0) is respected.

   Error is only set on actual error, "MMC_ERR_NONE" is no longer used.

3. FIFO size is now read from register (and respected during PIO transfer)
4. supported bus width(s) is now read from register
5. !(of_dma_request_slave_channel()) return value check is wrong,
   IS_ERR() must be used.
6. clean up and remove unused defines / header includes
7. add "faraday,ftsdc010" compatible string (requested by Arnd)

[1] http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/mmc/ftsdc010_mci.c

Applies to next-20140409

 .../devicetree/bindings/mmc/moxa,moxart-mmc.txt|  30 +
 drivers/mmc/host/Kconfig   |   9 +
 drivers/mmc/host/Makefile  |   1 +
 drivers/mmc/host/moxart-mmc.c  | 730 +
 4 files changed, 770 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
 create mode 100644 drivers/mmc/host/moxart-mmc.c

diff --git a/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt 
b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
new file mode 100644
index 000..b638191
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
@@ -0,0 +1,30 @@
+MOXA ART MMC Host Controller Interface
+
+  Inherits from mmc binding[1].
+
+  [1] Documentation/devicetree/bindings/mmc/mmc.txt
+
+Required properties:
+
+- compatible : Must be "moxa,moxart-mmc" or "faraday,ftsdc010"
+- reg :Should contain registers location and length
+- interrupts : Should contain the interrupt number
+- clocks : Should contain phandle for the clock feeding the MMC controller
+
+Optional properties:
+
+- dmas :   Should contain two DMA channels, line request number must be 5 
for
+   both channels
+- dma-names :  Must be "tx", "rx"
+
+Example:
+
+   mmc: mmc@98e0 {
+   compatible = "moxa,moxart-mmc";
+   reg = <0x98e0 0x5C>;
+   interrupts = <5 0>;
+   clocks = <_apb>;
+   dmas =  < 5>,
+   < 5>;
+   dma-names = "tx", "rx";
+   };
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 8aaf8c1..eb93b81 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -283,6 +283,15 @@ config MMC_SDHCI_BCM2835
 
  If unsure, say N.
 
+config MMC_MOXART
+   tristate "MOXART SD/MMC Host Controller support"
+   depends on ARCH_MOXART && MMC
+   help
+ This selects support for the MOXART SD/MMC Host Controller.
+ MOXA provides one multi-functional card reader which can
+ be found on some embedded hardware such as UC-7112-LX.
+ If you have a controller with this interface, say Y here.
+
 config MMC_OMAP
tristate "TI OMAP Multimedia Card Interface support"
depends on ARCH_OMAP
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 0c8aa5e..dfa6ecb 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_MMC_JZ4740)  += jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)   += vub300.o
 obj-$(CONFIG_MMC_USHC) += ushc.o
 obj-$(CONFIG_MMC_WMT)  += wmt-sdmmc.o
+obj-$(CONFIG_MMC_MOXART)   += moxart-mmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
 
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
new file mode 100644
index 000..74924a0
--- /dev/null
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -0,0 +1,730 @@
+/*
+ * MOXA ART MMC host driver.
+ *
+ * Copyright (C) 2014 Jonas Jensen
+ *
+ * Jonas Jensen 
+ *
+ * Based on code from
+ * Moxa Technologies Co., Ltd. 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version

[PATCH v8] mmc: moxart: Add MOXA ART SD/MMC driver

2014-04-09 Thread Jonas Jensen
Add SD/MMC driver for MOXA ART SoCs.

The MOXA ART MMC controller is likely a faraday ftsdc010,
a controller with support in U-Boot:

http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/mmc/ftsdc010_mci.c

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
This has been cleaned up further, especially the return value fiasco in v7.

The MOXA ART MMC controller is likely a faraday ftsdc010 (supported by 
U-Boot [1]).
Registers are the same albeit named slightly different.

I think this can support other ftsdc010 SoCs with one reservation for
power control, which may need hardware specific changes.

Changes since v7:

1. merge code from U-Boot ftsdc010 driver [1]

   Specifically how it implements status wait, clock divider, fifo width, 
bus width.

2. return value cleanup, MMC_ERR_TIMEOUT is no longer used or set at the 
top of every request

   i.e. the default (no error) return value (0) is respected.

   Error is only set on actual error, MMC_ERR_NONE is no longer used.

3. FIFO size is now read from register (and respected during PIO transfer)
4. supported bus width(s) is now read from register
5. !(of_dma_request_slave_channel()) return value check is wrong,
   IS_ERR() must be used.
6. clean up and remove unused defines / header includes
7. add faraday,ftsdc010 compatible string (requested by Arnd)

[1] http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/mmc/ftsdc010_mci.c

Applies to next-20140409

 .../devicetree/bindings/mmc/moxa,moxart-mmc.txt|  30 +
 drivers/mmc/host/Kconfig   |   9 +
 drivers/mmc/host/Makefile  |   1 +
 drivers/mmc/host/moxart-mmc.c  | 730 +
 4 files changed, 770 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
 create mode 100644 drivers/mmc/host/moxart-mmc.c

diff --git a/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt 
b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
new file mode 100644
index 000..b638191
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
@@ -0,0 +1,30 @@
+MOXA ART MMC Host Controller Interface
+
+  Inherits from mmc binding[1].
+
+  [1] Documentation/devicetree/bindings/mmc/mmc.txt
+
+Required properties:
+
+- compatible : Must be moxa,moxart-mmc or faraday,ftsdc010
+- reg :Should contain registers location and length
+- interrupts : Should contain the interrupt number
+- clocks : Should contain phandle for the clock feeding the MMC controller
+
+Optional properties:
+
+- dmas :   Should contain two DMA channels, line request number must be 5 
for
+   both channels
+- dma-names :  Must be tx, rx
+
+Example:
+
+   mmc: mmc@98e0 {
+   compatible = moxa,moxart-mmc;
+   reg = 0x98e0 0x5C;
+   interrupts = 5 0;
+   clocks = clk_apb;
+   dmas =  dma 5,
+   dma 5;
+   dma-names = tx, rx;
+   };
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 8aaf8c1..eb93b81 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -283,6 +283,15 @@ config MMC_SDHCI_BCM2835
 
  If unsure, say N.
 
+config MMC_MOXART
+   tristate MOXART SD/MMC Host Controller support
+   depends on ARCH_MOXART  MMC
+   help
+ This selects support for the MOXART SD/MMC Host Controller.
+ MOXA provides one multi-functional card reader which can
+ be found on some embedded hardware such as UC-7112-LX.
+ If you have a controller with this interface, say Y here.
+
 config MMC_OMAP
tristate TI OMAP Multimedia Card Interface support
depends on ARCH_OMAP
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 0c8aa5e..dfa6ecb 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_MMC_JZ4740)  += jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)   += vub300.o
 obj-$(CONFIG_MMC_USHC) += ushc.o
 obj-$(CONFIG_MMC_WMT)  += wmt-sdmmc.o
+obj-$(CONFIG_MMC_MOXART)   += moxart-mmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
 
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
new file mode 100644
index 000..74924a0
--- /dev/null
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -0,0 +1,730 @@
+/*
+ * MOXA ART MMC host driver.
+ *
+ * Copyright (C) 2014 Jonas Jensen
+ *
+ * Jonas Jensen jonas.jen...@gmail.com
+ *
+ * Based on code from
+ * Moxa Technologies Co., Ltd. www.moxa.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/version.h
+#include linux/module.h
+#include linux/init.h

Re: [PATCH] ARM: reinsert ARCH_MULTI_V4 Kconfig option

2014-04-09 Thread Jonas Jensen
On 13 December 2013 12:39, Russell King - ARM Linux
li...@arm.linux.org.uk wrote:
 I see what's causing this: the kuser helpers are using bx lr to return
 which will be undefined on non-Thumb CPUs.  We generally cope fine with
 non-Thumb CPUs, conditionalising where necessary on HWCAP_THUMB or the
 T bit in the PSR being set.

 However, it looks like the kuser helpers got missed.  As a check, please
 look at arch/arm/kernel/entry-armv.S, find the line with:

 .macro  usr_ret, reg

 and ensure that the mov pc, \reg case always gets used.  Please report
 back.

Uwe and Arnd came up with a solution except it doesn't work when I test it.

The suggested patch is:

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 1879e8d..de15bfd 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -739,6 +739,18 @@ ENDPROC(__switch_to)

.macro  usr_ret, reg
 #ifdef CONFIG_ARM_THUMB
+   /*
+* Having CONFIG_ARM_THUMB isn't a guarantee that the cpu has support
+* for Thumb and so the bx instruction. Use a mov if the address to
+* jump to is 32 bit aligned. (Note that this code is compiled in ARM
+* mode, so this is the right test.)
+*/
+#if defined(CONFIG_CPU_32v4)
+   tst \reg, #3
+   moveq   pc, \reg
+   b   .
+#endif
+
bx  \reg
 #else
mov pc, \reg


With this applied, and the following two possibilities in next-20140403:

[1] ARCH_MULTI_V4 only (no CONFIG_ARM_THUMB)
 CONFIG_CPU_32v4=y

[2] ARCH_MULTI_V4 and ARCH_MULTI_V4T
 CONFIG_ARM_THUMB=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_32v4T=y


Booting a kernel with either option [1] or [2] yield the following results:

[1] works
[2] hangs after [2.73] Freeing unused kernel memory: 104K
(c02f5000 - c030f000)


Any help why the moveq doesn't work would be much appreciated.


The commit where this was tested:
https://bitbucket.org/Kasreyn/linux-next/commits/48320cbe0d5a1fb6ada52cea9efd87c7712367cb


Regards,
Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v11] clk: add MOXA ART SoCs clock driver

2014-01-28 Thread Jonas Jensen
MOXA ART SoCs allow to determine PLL output and APB frequencies
by reading registers holding multiplier and divisor information.

Add a clock driver for this SoC.

Signed-off-by: Jonas Jensen 
---

Notes:
Thanks for the replies,

Changes since v10:

1. add clock-specifier to DT binding description
2. remove local variable "rate"
3. add local variable "parent_name"
4. use clk_register_fixed_factor() instead of clk_register_fixed_rate()
5. remove flag CLK_IS_ROOT

Applies to next-20140128

 .../bindings/clock/moxa,moxart-clock.txt   | 48 +++
 drivers/clk/Makefile   |  1 +
 drivers/clk/clk-moxart.c   | 97 ++
 3 files changed, 146 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
 create mode 100644 drivers/clk/clk-moxart.c

diff --git a/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt 
b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
new file mode 100644
index 000..fedea84
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
@@ -0,0 +1,48 @@
+Device Tree Clock bindings for arch-moxart
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+MOXA ART SoCs allow to determine PLL output and APB frequencies
+by reading registers holding multiplier and divisor information.
+
+
+PLL:
+
+Required properties:
+- compatible : Must be "moxa,moxart-pll-clock"
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle + clock-specifier for the parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+APB:
+
+Required properties:
+- compatible : Must be "moxa,moxart-apb-clock"
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle + clock-specifier for the parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+For example:
+
+   clk_pll: clk_pll@9810 {
+   compatible = "moxa,moxart-pll-clock";
+   #clock-cells = <0>;
+   reg = <0x9810 0x34>;
+   };
+
+   clk_apb: clk_apb@9810 {
+   compatible = "moxa,moxart-apb-clock";
+   #clock-cells = <0>;
+   reg = <0x9810 0x34>;
+   clocks = <_pll>;
+   };
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 0faf730..7940d0c 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK)  += clk-composite.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)   += clk-efm32gg.o
+obj-$(CONFIG_ARCH_MOXART)  += clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)+= clk-highbank.o
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
new file mode 100644
index 000..30a3b69
--- /dev/null
+++ b/drivers/clk/clk-moxart.c
@@ -0,0 +1,97 @@
+/*
+ * MOXA ART SoCs clock driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+void __init moxart_of_pll_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *ref_clk;
+   unsigned int mul;
+   const char *name = node->name;
+   const char *parent_name;
+
+   of_property_read_string(node, "clock-output-names", );
+   parent_name = of_clk_get_parent_name(node, 0);
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err("%s: of_iomap failed\n", node->full_name);
+   return;
+   }
+
+   mul = readl(base + 0x30) >> 3 & 0x3f;
+   iounmap(base);
+
+   ref_clk = of_clk_get(node, 0);
+   if (IS_ERR(ref_clk)) {
+   pr_err("%s: of_clk_get failed\n", node->full_name);
+   return;
+   }
+
+   clk = clk_register_fixed_factor(NULL, name, parent_name, 0, mul, 1);
+   if (IS_ERR(clk)) {
+   pr_err("%s: failed to register clock\n", node->full_name);
+   return;
+   }
+
+   clk_register_clkdev(clk, NULL, name);
+   of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(moxart_pll_clock, "moxa,moxart-pll-clock",
+  moxart_of_pll_clk_init);
+
+void __init moxart_of_apb_clk_init(struct device_node *node)
+{
+   static vo

[PATCH v11] clk: add MOXA ART SoCs clock driver

2014-01-28 Thread Jonas Jensen
MOXA ART SoCs allow to determine PLL output and APB frequencies
by reading registers holding multiplier and divisor information.

Add a clock driver for this SoC.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Thanks for the replies,

Changes since v10:

1. add clock-specifier to DT binding description
2. remove local variable rate
3. add local variable parent_name
4. use clk_register_fixed_factor() instead of clk_register_fixed_rate()
5. remove flag CLK_IS_ROOT

Applies to next-20140128

 .../bindings/clock/moxa,moxart-clock.txt   | 48 +++
 drivers/clk/Makefile   |  1 +
 drivers/clk/clk-moxart.c   | 97 ++
 3 files changed, 146 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
 create mode 100644 drivers/clk/clk-moxart.c

diff --git a/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt 
b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
new file mode 100644
index 000..fedea84
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
@@ -0,0 +1,48 @@
+Device Tree Clock bindings for arch-moxart
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+MOXA ART SoCs allow to determine PLL output and APB frequencies
+by reading registers holding multiplier and divisor information.
+
+
+PLL:
+
+Required properties:
+- compatible : Must be moxa,moxart-pll-clock
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle + clock-specifier for the parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+APB:
+
+Required properties:
+- compatible : Must be moxa,moxart-apb-clock
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle + clock-specifier for the parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+For example:
+
+   clk_pll: clk_pll@9810 {
+   compatible = moxa,moxart-pll-clock;
+   #clock-cells = 0;
+   reg = 0x9810 0x34;
+   };
+
+   clk_apb: clk_apb@9810 {
+   compatible = moxa,moxart-apb-clock;
+   #clock-cells = 0;
+   reg = 0x9810 0x34;
+   clocks = clk_pll;
+   };
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 0faf730..7940d0c 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK)  += clk-composite.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)   += clk-efm32gg.o
+obj-$(CONFIG_ARCH_MOXART)  += clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)+= clk-highbank.o
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
new file mode 100644
index 000..30a3b69
--- /dev/null
+++ b/drivers/clk/clk-moxart.c
@@ -0,0 +1,97 @@
+/*
+ * MOXA ART SoCs clock driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen jonas.jen...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/clk-provider.h
+#include linux/io.h
+#include linux/of_address.h
+#include linux/clkdev.h
+
+void __init moxart_of_pll_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *ref_clk;
+   unsigned int mul;
+   const char *name = node-name;
+   const char *parent_name;
+
+   of_property_read_string(node, clock-output-names, name);
+   parent_name = of_clk_get_parent_name(node, 0);
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err(%s: of_iomap failed\n, node-full_name);
+   return;
+   }
+
+   mul = readl(base + 0x30)  3  0x3f;
+   iounmap(base);
+
+   ref_clk = of_clk_get(node, 0);
+   if (IS_ERR(ref_clk)) {
+   pr_err(%s: of_clk_get failed\n, node-full_name);
+   return;
+   }
+
+   clk = clk_register_fixed_factor(NULL, name, parent_name, 0, mul, 1);
+   if (IS_ERR(clk)) {
+   pr_err(%s: failed to register clock\n, node-full_name);
+   return;
+   }
+
+   clk_register_clkdev(clk, NULL, name);
+   of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(moxart_pll_clock, moxa,moxart-pll-clock,
+  moxart_of_pll_clk_init);
+
+void __init moxart_of_apb_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *pll_clk;
+   unsigned int div, val;
+   unsigned

[PATCH] ARM: moxart: DT fixups

2014-01-21 Thread Jonas Jensen
Change DT files to remain coherent with changes in
accompanying drivers.

1. replace "sdhci" with "mmc"
2. add bus-width property to mmc node
3. drop device_type property
4. replace "mac@" with "ethernet@"
5. replace CONFIG_MMC_SDHCI_MOXART with CONFIG_MMC_MOXART

Signed-off-by: Jonas Jensen 
---

Notes:
Applies on top of:

"[PATCH] ARM: moxart: move fixed rate clock child node to board level dts"

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-January/226141.html

Applies to next-20140121

 arch/arm/boot/dts/moxart-uc7112lx.dts | 5 ++---
 arch/arm/boot/dts/moxart.dtsi | 8 
 arch/arm/configs/moxart_defconfig | 2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
index 10d088d..ee6ef7c 100644
--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -80,15 +80,15 @@
clocks = <>;
 };
 
- {
+ {
status = "okay";
+   bus-width = <4>;
 };
 
  {
status = "okay";
 
ethphy0: ethernet-phy@1 {
-   device_type = "ethernet-phy";
compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
reg = <1>;
};
@@ -98,7 +98,6 @@
status = "okay";
 
ethphy1: ethernet-phy@1 {
-   device_type = "ethernet-phy";
compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
reg = <1>;
};
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index 1fd27ed..97c8084 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -90,8 +90,8 @@
clocks = <_apb>;
};
 
-   sdhci: sdhci@98e0 {
-   compatible = "moxa,moxart-sdhci";
+   mmc: mmc@98e0 {
+   compatible = "moxa,moxart-mmc";
reg = <0x98e0 0x5C>;
interrupts = <5 0>;
clocks = <_apb>;
@@ -117,7 +117,7 @@
status = "disabled";
};
 
-   mac0: mac@9090 {
+   mac0: ethernet@9090 {
compatible = "moxa,moxart-mac";
reg = <0x9090 0x90>;
interrupts = <25 0>;
@@ -126,7 +126,7 @@
status = "disabled";
};
 
-   mac1: mac@9200 {
+   mac1: ethernet@9200 {
compatible = "moxa,moxart-mac";
reg = <0x9200 0x90>;
interrupts = <27 0>;
diff --git a/arch/arm/configs/moxart_defconfig 
b/arch/arm/configs/moxart_defconfig
index a3cb76c..708c0cf 100644
--- a/arch/arm/configs/moxart_defconfig
+++ b/arch/arm/configs/moxart_defconfig
@@ -107,7 +107,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 CONFIG_MOXART_WDT=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_MMC=y
-CONFIG_MMC_SDHCI_MOXART=y
+CONFIG_MMC_MOXART=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 3/7] net: moxa: connect to PHY

2014-01-21 Thread Jonas Jensen
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP),
connect to this PHY using OF.

Signed-off-by: Jonas Jensen 
---

Notes:
Thanks for reviewing,

This time I'll avoid sending out the entire set, attaching it here
directly to my reply.

Because the DT example is directly imported from files in arch/arm/
those must be updated too. I'll submit those in a separate fixup patch.

Changes since v3:

1. drop device_type property from DT example
2. replace "mac@" with "ethernet@" in DT example

Applies to next-20140121

 .../devicetree/bindings/net/moxa,moxart-mac.txt| 49 +++-
 drivers/net/ethernet/moxa/moxart_ether.c   | 92 +-
 drivers/net/ethernet/moxa/moxart_ether.h   |  2 +
 3 files changed, 138 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt 
b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
index 583418b..36d5185 100644
--- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
+++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
@@ -1,21 +1,62 @@
 MOXA ART Ethernet Controller
 
+Integrated MDIO bus node:
+
+- compatible: "moxa,moxart-mdio"
+- Inherits from MDIO bus node binding[1]
+
+[1] Documentation/devicetree/bindings/net/phy.txt
+
+
+Ethernet node:
+
 Required properties:
 
 - compatible : Must be "moxa,moxart-mac"
 - reg : Should contain register location and length
 - interrupts : Should contain the mac interrupt number
 
+Optional Properties:
+
+- phy-handle : the phandle to a PHY node
+
+
 Example:
 
-   mac0: mac@9090 {
+   mdio0: mdio@90900090 {
+   compatible = "moxa,moxart-mdio";
+   reg = <0x90900090 0x8>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@1 {
+   compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
+   reg = <1>;
+   };
+   };
+
+   mdio1: mdio@9290 {
+   compatible = "moxa,moxart-mdio";
+   reg = <0x9290 0x8>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy1: ethernet-phy@1 {
+   compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
+   reg = <1>;
+   };
+   };
+
+   mac0: ethernet@9090 {
compatible = "moxa,moxart-mac";
-   reg =   <0x9090 0x100>;
+   reg = <0x9090 0x90>;
interrupts = <25 0>;
+   phy-handle = <>;
};
 
-   mac1: mac@9200 {
+   mac1: ethernet@9200 {
compatible = "moxa,moxart-mac";
-   reg =   <0x9200 0x100>;
+   reg = <0x9200 0x90>;
interrupts = <27 0>;
+   phy-handle = <>;
};
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 17c9f0e..c19bff2 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, 
void *addr)
return 0;
 }
 
+static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   if (!netif_running(ndev))
+   return -EINVAL;
+
+   return phy_mii_ioctl(priv->phy_dev, ir, cmd);
+}
+
 static void moxart_mac_free_memory(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev)
writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
 }
 
+static void moxart_mac_update_duplex(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   priv->reg_maccr &= ~(FULLDUP | ENRX_IN_HALFTX);
+   if (priv->duplex)
+   priv->reg_maccr |= FULLDUP;
+   else
+   priv->reg_maccr |= ENRX_IN_HALFTX;
+
+   writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
+}
+
 static void moxart_mac_setup_desc_ring(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev)
moxart_update_mac_address(ndev);
moxart_mac_setup_desc_ring(ndev);
moxart_mac_enable(ndev);
+
+   phy_start(priv->phy_dev);
+
netif_start_queue(

[PATCH v10] clk: add MOXA ART SoCs clock driver

2014-01-21 Thread Jonas Jensen
MOXA ART SoCs allow to determine PLL output and APB frequencies
by reading registers holding multiplier and divisor information.

Add a clock driver for this SoC.

Signed-off-by: Jonas Jensen 
---

Notes:
Thanks for the reply Sudeep, changes are in v10.

Changes since v9:

1. rebase drivers/clk/Makefile to next-20140121
2. remove unnecessary switch
3. use a more elaborate commit message

Applies to next-20140121

 .../bindings/clock/moxa,moxart-clock.txt   | 48 +++
 drivers/clk/Makefile   |  1 +
 drivers/clk/clk-moxart.c   | 99 ++
 3 files changed, 148 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
 create mode 100644 drivers/clk/clk-moxart.c

diff --git a/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt 
b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
new file mode 100644
index 000..242e3fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
@@ -0,0 +1,48 @@
+Device Tree Clock bindings for arch-moxart
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+MOXA ART SoCs allow to determine PLL output and APB frequencies
+by reading registers holding multiplier and divisor information.
+
+
+PLL:
+
+Required properties:
+- compatible : Must be "moxa,moxart-pll-clock"
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+APB:
+
+Required properties:
+- compatible : Must be "moxa,moxart-apb-clock"
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+For example:
+
+   clk_pll: clk_pll@9810 {
+   compatible = "moxa,moxart-pll-clock";
+   #clock-cells = <0>;
+   reg = <0x9810 0x34>;
+   };
+
+   clk_apb: clk_apb@9810 {
+   compatible = "moxa,moxart-apb-clock";
+   #clock-cells = <0>;
+   reg = <0x9810 0x34>;
+   clocks = <_pll>;
+   };
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 58b2d72..24361bf 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK)  += clk-composite.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)   += clk-efm32gg.o
+obj-$(CONFIG_ARCH_MOXART)  += clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)+= clk-highbank.o
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
new file mode 100644
index 000..7021748
--- /dev/null
+++ b/drivers/clk/clk-moxart.c
@@ -0,0 +1,99 @@
+/*
+ * MOXA ART SoCs clock driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+void __init moxart_of_pll_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *ref_clk;
+   unsigned long rate;
+   unsigned int mul;
+   const char *name = node->name;
+
+   of_property_read_string(node, "clock-output-names", );
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err("%s: of_iomap failed\n", node->full_name);
+   return;
+   }
+
+   mul = readl(base + 0x30) >> 3 & 0x3f;
+   iounmap(base);
+
+   ref_clk = of_clk_get(node, 0);
+   if (IS_ERR(ref_clk)) {
+   pr_err("%s: of_clk_get failed\n", node->full_name);
+   return;
+   }
+
+   rate = mul * clk_get_rate(ref_clk);
+
+   clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
+   if (IS_ERR(clk)) {
+   pr_err("%s: clk_register_fixed_rate failed\n", node->full_name);
+   return;
+   }
+
+   clk_register_clkdev(clk, NULL, name);
+   of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(moxart_pll_clock, "moxa,moxart-pll-clock",
+  moxart_of_pll_clk_init);
+
+void __init moxart_of_apb_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *pll_clk;
+   unsigned long rate;
+   unsigned int div, val;
+   unsigned int div_idx[] = { 2

[PATCH v7] mmc: moxart: Add MOXA ART SD/MMC driver

2014-01-21 Thread Jonas Jensen
Add SD/MMC driver for MOXA ART SoCs.

Signed-off-by: Jonas Jensen 
---

Notes:
v6 was supposed to fix a panic from dmaengine_tx_status() but it
still happened. This is the sort of panic that lasts between reboots
but not between kernel reflash.

dmaengine_tx_status() is used only to print DMA error, that's why
I decided to remove it, instead of risking permanent kernel panic.

Changes since v6:

1. use mmc_of_parse()
2. remove duplicate defines MSD_*
3. add reference to bindings/mmc/mmc.txt in DT binding
4. update DT binding example
   ("coreclk" renamed "clk_apb", DMA channel number is no longer needed)
5. rename "sdhci-moxart" "moxart-mmc"
6. remove dmaengine_tx_status() / don't print DMA error
7. format comments / use correct grammar

Applies to next-20140121

 .../devicetree/bindings/mmc/moxa,moxart-mmc.txt|  32 +
 drivers/mmc/host/Kconfig   |   9 +
 drivers/mmc/host/Makefile  |   1 +
 drivers/mmc/host/moxart-mmc.c  | 872 +
 4 files changed, 914 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
 create mode 100644 drivers/mmc/host/moxart-mmc.c

diff --git a/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt 
b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
new file mode 100644
index 000..c2045d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
@@ -0,0 +1,32 @@
+MOXA ART SD Host Controller Interface
+
+  Inherits from mmc binding[1].
+
+  [1] Documentation/devicetree/bindings/mmc/mmc.txt
+
+Required properties:
+
+- compatible : Must be "moxa,moxart-mmc"
+- reg :Should contain registers location and length
+- interrupts : Should contain the interrupt number
+- clocks : Should contain phandle for the clock feeding the SDHCI 
controller
+
+Optional properties:
+
+These are optional but required to enable DMA transfer mode:
+
+- dmas :   Should contain two DMA channels, line request number must be 5 
for
+   both channels
+- dma-names :  Must be "tx", "rx"
+
+Example:
+
+   mmc: mmc@98e0 {
+   compatible = "moxa,moxart-mmc";
+   reg = <0x98e0 0x5C>;
+   interrupts = <5 0>;
+   clocks = <_apb>;
+   dmas =  < 5>,
+   < 5>;
+   dma-names = "tx", "rx";
+   };
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1384f67..15806d6 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -283,6 +283,15 @@ config MMC_SDHCI_BCM2835
 
  If unsure, say N.
 
+config MMC_MOXART
+   tristate "MOXART SD/MMC Host Controller support"
+   depends on ARCH_MOXART && MMC
+   help
+ This selects support for the MOXART SD/MMC Host Controller.
+ MOXA provides one multi-functional card reader which can
+ be found on some embedded hardware such as UC-7112-LX.
+ If you have a controller with this interface, say Y here.
+
 config MMC_OMAP
tristate "TI OMAP Multimedia Card Interface support"
depends on ARCH_OMAP
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 3483b6b..6b90eda 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_MMC_JZ4740)  += jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)   += vub300.o
 obj-$(CONFIG_MMC_USHC) += ushc.o
 obj-$(CONFIG_MMC_WMT)  += wmt-sdmmc.o
+obj-$(CONFIG_MMC_MOXART)   += moxart-mmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
 
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
new file mode 100644
index 000..be12e12
--- /dev/null
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -0,0 +1,872 @@
+/*
+ * MOXA ART MMC host driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen 
+ *
+ * Based on code from
+ * Moxa Technologies Co., Ltd. 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define MMC_RSP_SHORT  1
+#define MMC_RSP_LONG   2
+#define MMC_RSP_MASK   3
+#define MMC_ERR_NONE   0
+#define MMC_ERR_TIMEOUT1
+#define MMC_MODE_MMC   0
+#define MMC_MODE_SD1
+#define MMC_ERR_BADCRC 2
+#define MMC_VDD_360

[PATCH v7] mmc: moxart: Add MOXA ART SD/MMC driver

2014-01-21 Thread Jonas Jensen
Add SD/MMC driver for MOXA ART SoCs.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
v6 was supposed to fix a panic from dmaengine_tx_status() but it
still happened. This is the sort of panic that lasts between reboots
but not between kernel reflash.

dmaengine_tx_status() is used only to print DMA error, that's why
I decided to remove it, instead of risking permanent kernel panic.

Changes since v6:

1. use mmc_of_parse()
2. remove duplicate defines MSD_*
3. add reference to bindings/mmc/mmc.txt in DT binding
4. update DT binding example
   (coreclk renamed clk_apb, DMA channel number is no longer needed)
5. rename sdhci-moxart moxart-mmc
6. remove dmaengine_tx_status() / don't print DMA error
7. format comments / use correct grammar

Applies to next-20140121

 .../devicetree/bindings/mmc/moxa,moxart-mmc.txt|  32 +
 drivers/mmc/host/Kconfig   |   9 +
 drivers/mmc/host/Makefile  |   1 +
 drivers/mmc/host/moxart-mmc.c  | 872 +
 4 files changed, 914 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
 create mode 100644 drivers/mmc/host/moxart-mmc.c

diff --git a/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt 
b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
new file mode 100644
index 000..c2045d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/moxa,moxart-mmc.txt
@@ -0,0 +1,32 @@
+MOXA ART SD Host Controller Interface
+
+  Inherits from mmc binding[1].
+
+  [1] Documentation/devicetree/bindings/mmc/mmc.txt
+
+Required properties:
+
+- compatible : Must be moxa,moxart-mmc
+- reg :Should contain registers location and length
+- interrupts : Should contain the interrupt number
+- clocks : Should contain phandle for the clock feeding the SDHCI 
controller
+
+Optional properties:
+
+These are optional but required to enable DMA transfer mode:
+
+- dmas :   Should contain two DMA channels, line request number must be 5 
for
+   both channels
+- dma-names :  Must be tx, rx
+
+Example:
+
+   mmc: mmc@98e0 {
+   compatible = moxa,moxart-mmc;
+   reg = 0x98e0 0x5C;
+   interrupts = 5 0;
+   clocks = clk_apb;
+   dmas =  dma 5,
+   dma 5;
+   dma-names = tx, rx;
+   };
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1384f67..15806d6 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -283,6 +283,15 @@ config MMC_SDHCI_BCM2835
 
  If unsure, say N.
 
+config MMC_MOXART
+   tristate MOXART SD/MMC Host Controller support
+   depends on ARCH_MOXART  MMC
+   help
+ This selects support for the MOXART SD/MMC Host Controller.
+ MOXA provides one multi-functional card reader which can
+ be found on some embedded hardware such as UC-7112-LX.
+ If you have a controller with this interface, say Y here.
+
 config MMC_OMAP
tristate TI OMAP Multimedia Card Interface support
depends on ARCH_OMAP
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 3483b6b..6b90eda 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_MMC_JZ4740)  += jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)   += vub300.o
 obj-$(CONFIG_MMC_USHC) += ushc.o
 obj-$(CONFIG_MMC_WMT)  += wmt-sdmmc.o
+obj-$(CONFIG_MMC_MOXART)   += moxart-mmc.o
 
 obj-$(CONFIG_MMC_REALTEK_PCI)  += rtsx_pci_sdmmc.o
 
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
new file mode 100644
index 000..be12e12
--- /dev/null
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -0,0 +1,872 @@
+/*
+ * MOXA ART MMC host driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen jonas.jen...@gmail.com
+ *
+ * Based on code from
+ * Moxa Technologies Co., Ltd. www.moxa.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/version.h
+#include linux/module.h
+#include linux/init.h
+#include linux/ioport.h
+#include linux/platform_device.h
+#include linux/delay.h
+#include linux/interrupt.h
+#include linux/blkdev.h
+#include linux/dma-mapping.h
+#include linux/dmaengine.h
+#include linux/mmc/host.h
+#include linux/mmc/sd.h
+#include linux/mmc/mmc.h
+#include linux/sched.h
+#include linux/io.h
+#include linux/gpio.h
+#include linux/sizes.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/clk.h
+#include linux/bitops.h
+#include linux/of_dma.h
+
+#include asm/dma.h
+#include asm/irq.h
+
+#define MMC_RSP_SHORT  1
+#define MMC_RSP_LONG   2
+#define MMC_RSP_MASK   3
+#define

[PATCH v10] clk: add MOXA ART SoCs clock driver

2014-01-21 Thread Jonas Jensen
MOXA ART SoCs allow to determine PLL output and APB frequencies
by reading registers holding multiplier and divisor information.

Add a clock driver for this SoC.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Thanks for the reply Sudeep, changes are in v10.

Changes since v9:

1. rebase drivers/clk/Makefile to next-20140121
2. remove unnecessary switch
3. use a more elaborate commit message

Applies to next-20140121

 .../bindings/clock/moxa,moxart-clock.txt   | 48 +++
 drivers/clk/Makefile   |  1 +
 drivers/clk/clk-moxart.c   | 99 ++
 3 files changed, 148 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
 create mode 100644 drivers/clk/clk-moxart.c

diff --git a/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt 
b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
new file mode 100644
index 000..242e3fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
@@ -0,0 +1,48 @@
+Device Tree Clock bindings for arch-moxart
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+MOXA ART SoCs allow to determine PLL output and APB frequencies
+by reading registers holding multiplier and divisor information.
+
+
+PLL:
+
+Required properties:
+- compatible : Must be moxa,moxart-pll-clock
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+APB:
+
+Required properties:
+- compatible : Must be moxa,moxart-apb-clock
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+For example:
+
+   clk_pll: clk_pll@9810 {
+   compatible = moxa,moxart-pll-clock;
+   #clock-cells = 0;
+   reg = 0x9810 0x34;
+   };
+
+   clk_apb: clk_apb@9810 {
+   compatible = moxa,moxart-apb-clock;
+   #clock-cells = 0;
+   reg = 0x9810 0x34;
+   clocks = clk_pll;
+   };
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 58b2d72..24361bf 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK)  += clk-composite.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)   += clk-efm32gg.o
+obj-$(CONFIG_ARCH_MOXART)  += clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)+= clk-highbank.o
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
new file mode 100644
index 000..7021748
--- /dev/null
+++ b/drivers/clk/clk-moxart.c
@@ -0,0 +1,99 @@
+/*
+ * MOXA ART SoCs clock driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen jonas.jen...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/clk-provider.h
+#include linux/io.h
+#include linux/of_address.h
+#include linux/clkdev.h
+
+void __init moxart_of_pll_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *ref_clk;
+   unsigned long rate;
+   unsigned int mul;
+   const char *name = node-name;
+
+   of_property_read_string(node, clock-output-names, name);
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err(%s: of_iomap failed\n, node-full_name);
+   return;
+   }
+
+   mul = readl(base + 0x30)  3  0x3f;
+   iounmap(base);
+
+   ref_clk = of_clk_get(node, 0);
+   if (IS_ERR(ref_clk)) {
+   pr_err(%s: of_clk_get failed\n, node-full_name);
+   return;
+   }
+
+   rate = mul * clk_get_rate(ref_clk);
+
+   clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
+   if (IS_ERR(clk)) {
+   pr_err(%s: clk_register_fixed_rate failed\n, node-full_name);
+   return;
+   }
+
+   clk_register_clkdev(clk, NULL, name);
+   of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(moxart_pll_clock, moxa,moxart-pll-clock,
+  moxart_of_pll_clk_init);
+
+void __init moxart_of_apb_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *pll_clk;
+   unsigned long rate;
+   unsigned int div, val;
+   unsigned int div_idx[] = { 2, 3, 4, 6, 8};
+   const char *name = node-name;
+
+   of_property_read_string

[PATCH v3 3/7] net: moxa: connect to PHY

2014-01-21 Thread Jonas Jensen
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP),
connect to this PHY using OF.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Thanks for reviewing,

This time I'll avoid sending out the entire set, attaching it here
directly to my reply.

Because the DT example is directly imported from files in arch/arm/
those must be updated too. I'll submit those in a separate fixup patch.

Changes since v3:

1. drop device_type property from DT example
2. replace mac@ with ethernet@ in DT example

Applies to next-20140121

 .../devicetree/bindings/net/moxa,moxart-mac.txt| 49 +++-
 drivers/net/ethernet/moxa/moxart_ether.c   | 92 +-
 drivers/net/ethernet/moxa/moxart_ether.h   |  2 +
 3 files changed, 138 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt 
b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
index 583418b..36d5185 100644
--- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
+++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
@@ -1,21 +1,62 @@
 MOXA ART Ethernet Controller
 
+Integrated MDIO bus node:
+
+- compatible: moxa,moxart-mdio
+- Inherits from MDIO bus node binding[1]
+
+[1] Documentation/devicetree/bindings/net/phy.txt
+
+
+Ethernet node:
+
 Required properties:
 
 - compatible : Must be moxa,moxart-mac
 - reg : Should contain register location and length
 - interrupts : Should contain the mac interrupt number
 
+Optional Properties:
+
+- phy-handle : the phandle to a PHY node
+
+
 Example:
 
-   mac0: mac@9090 {
+   mdio0: mdio@90900090 {
+   compatible = moxa,moxart-mdio;
+   reg = 0x90900090 0x8;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   ethphy0: ethernet-phy@1 {
+   compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
+   reg = 1;
+   };
+   };
+
+   mdio1: mdio@9290 {
+   compatible = moxa,moxart-mdio;
+   reg = 0x9290 0x8;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   ethphy1: ethernet-phy@1 {
+   compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
+   reg = 1;
+   };
+   };
+
+   mac0: ethernet@9090 {
compatible = moxa,moxart-mac;
-   reg =   0x9090 0x100;
+   reg = 0x9090 0x90;
interrupts = 25 0;
+   phy-handle = ethphy0;
};
 
-   mac1: mac@9200 {
+   mac1: ethernet@9200 {
compatible = moxa,moxart-mac;
-   reg =   0x9200 0x100;
+   reg = 0x9200 0x90;
interrupts = 27 0;
+   phy-handle = ethphy1;
};
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 17c9f0e..c19bff2 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,9 @@
 #include linux/of_irq.h
 #include linux/crc32.h
 #include linux/crc32c.h
+#include linux/phy.h
+#include linux/of_mdio.h
+#include linux/of_net.h
 
 #include moxart_ether.h
 
@@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, 
void *addr)
return 0;
 }
 
+static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   if (!netif_running(ndev))
+   return -EINVAL;
+
+   return phy_mii_ioctl(priv-phy_dev, ir, cmd);
+}
+
 static void moxart_mac_free_memory(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev)
writel(priv-reg_maccr, priv-base + REG_MAC_CTRL);
 }
 
+static void moxart_mac_update_duplex(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   priv-reg_maccr = ~(FULLDUP | ENRX_IN_HALFTX);
+   if (priv-duplex)
+   priv-reg_maccr |= FULLDUP;
+   else
+   priv-reg_maccr |= ENRX_IN_HALFTX;
+
+   writel(priv-reg_maccr, priv-base + REG_MAC_CTRL);
+}
+
 static void moxart_mac_setup_desc_ring(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev)
moxart_update_mac_address(ndev);
moxart_mac_setup_desc_ring(ndev);
moxart_mac_enable(ndev);
+
+   phy_start(priv-phy_dev);
+
netif_start_queue(ndev);
 
netdev_dbg(ndev, %s: IMR=0x%x, MACCR=0x%x\n,
@@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev)
 
napi_disable(priv-napi);
 
+   phy_stop(priv-phy_dev

[PATCH] ARM: moxart: DT fixups

2014-01-21 Thread Jonas Jensen
Change DT files to remain coherent with changes in
accompanying drivers.

1. replace sdhci with mmc
2. add bus-width property to mmc node
3. drop device_type property
4. replace mac@ with ethernet@
5. replace CONFIG_MMC_SDHCI_MOXART with CONFIG_MMC_MOXART

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies on top of:

[PATCH] ARM: moxart: move fixed rate clock child node to board level dts

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-January/226141.html

Applies to next-20140121

 arch/arm/boot/dts/moxart-uc7112lx.dts | 5 ++---
 arch/arm/boot/dts/moxart.dtsi | 8 
 arch/arm/configs/moxart_defconfig | 2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
index 10d088d..ee6ef7c 100644
--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -80,15 +80,15 @@
clocks = ref12;
 };
 
-sdhci {
+mmc {
status = okay;
+   bus-width = 4;
 };
 
 mdio0 {
status = okay;
 
ethphy0: ethernet-phy@1 {
-   device_type = ethernet-phy;
compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
reg = 1;
};
@@ -98,7 +98,6 @@
status = okay;
 
ethphy1: ethernet-phy@1 {
-   device_type = ethernet-phy;
compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
reg = 1;
};
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index 1fd27ed..97c8084 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -90,8 +90,8 @@
clocks = clk_apb;
};
 
-   sdhci: sdhci@98e0 {
-   compatible = moxa,moxart-sdhci;
+   mmc: mmc@98e0 {
+   compatible = moxa,moxart-mmc;
reg = 0x98e0 0x5C;
interrupts = 5 0;
clocks = clk_apb;
@@ -117,7 +117,7 @@
status = disabled;
};
 
-   mac0: mac@9090 {
+   mac0: ethernet@9090 {
compatible = moxa,moxart-mac;
reg = 0x9090 0x90;
interrupts = 25 0;
@@ -126,7 +126,7 @@
status = disabled;
};
 
-   mac1: mac@9200 {
+   mac1: ethernet@9200 {
compatible = moxa,moxart-mac;
reg = 0x9200 0x90;
interrupts = 27 0;
diff --git a/arch/arm/configs/moxart_defconfig 
b/arch/arm/configs/moxart_defconfig
index a3cb76c..708c0cf 100644
--- a/arch/arm/configs/moxart_defconfig
+++ b/arch/arm/configs/moxart_defconfig
@@ -107,7 +107,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 CONFIG_MOXART_WDT=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_MMC=y
-CONFIG_MMC_SDHCI_MOXART=y
+CONFIG_MMC_MOXART=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 2/7] net: moxa: fix build_skb() memory corruption

2014-01-20 Thread Jonas Jensen
DMA buffer memory must be synchronized and copied before passing skb to
napi_gro_receive(). The use of build_skb() can lead to memory corruption,
replace it with netdev_alloc_skb_ip_align() and memcpy().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen 
---

Notes:
This fixes the following error on wget download (or ncftp),
usually after only a few seconds:

"read error: Bad address"

On receiving this error, wget exits. The download is not resumed (busybox 
default).

Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index aa45607..17c9f0e 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,14 +226,21 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len > RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv->rx_buf[rx_head], priv->rx_buf_size);
+   dma_sync_single_for_cpu(>dev,
+   priv->rx_mapping[rx_head],
+   priv->rx_buf_size, DMA_FROM_DEVICE);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
if (unlikely(!skb)) {
-   net_dbg_ratelimited("build_skb failed\n");
+   net_dbg_ratelimited("netdev_alloc_skb_ip_align 
failed\n");
priv->stats.rx_dropped++;
priv->stats.rx_errors++;
}
-
+   memcpy(skb->data, priv->rx_buf[rx_head], len);
skb_put(skb, len);
+   dma_sync_single_for_device(>dev,
+  priv->rx_mapping[rx_head],
+  priv->rx_buf_size, DMA_FROM_DEVICE);
+
skb->protocol = eth_type_trans(skb, ndev);
napi_gro_receive(>napi, skb);
rx++;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 6/7] net: moxa: generate random address

2014-01-20 Thread Jonas Jensen
The address register is zero:ed on boot, fill it with a randomly generated
address on probe.

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 6df372f..0f25f4dc 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -740,6 +740,12 @@ static int moxart_mac_probe(struct platform_device *pdev)
goto init_fail;
}
 
+   if (!is_valid_ether_addr(ndev->dev_addr)) {
+   eth_hw_addr_random(ndev);
+   netdev_info(ndev, "generated random MAC address %pM\n",
+   ndev->dev_addr);
+   }
+
netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n",
   __func__, ndev->irq, ndev->dev_addr);
 
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 3/7] net: moxa: connect to PHY

2014-01-20 Thread Jonas Jensen
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP),
connect to this PHY using OF.

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140120

 .../devicetree/bindings/net/moxa,moxart-mac.txt| 47 ++-
 drivers/net/ethernet/moxa/moxart_ether.c   | 92 +-
 drivers/net/ethernet/moxa/moxart_ether.h   |  2 +
 3 files changed, 138 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt 
b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
index 583418b..94c1f3b 100644
--- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
+++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
@@ -1,21 +1,64 @@
 MOXA ART Ethernet Controller
 
+Integrated MDIO bus node:
+
+- compatible: "moxa,moxart-mdio"
+- Inherits from MDIO bus node binding[1]
+
+[1] Documentation/devicetree/bindings/net/phy.txt
+
+
+Ethernet node:
+
 Required properties:
 
 - compatible : Must be "moxa,moxart-mac"
 - reg : Should contain register location and length
 - interrupts : Should contain the mac interrupt number
 
+Optional Properties:
+
+- phy-handle : the phandle to a PHY node
+
+
 Example:
 
+   mdio0: mdio@90900090 {
+   compatible = "moxa,moxart-mdio";
+   reg = <0x90900090 0x8>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@1 {
+   device_type = "ethernet-phy";
+   compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
+   reg = <1>;
+   };
+   };
+
+   mdio1: mdio@9290 {
+   compatible = "moxa,moxart-mdio";
+   reg = <0x9290 0x8>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy1: ethernet-phy@1 {
+   device_type = "ethernet-phy";
+   compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
+   reg = <1>;
+   };
+   };
+
mac0: mac@9090 {
compatible = "moxa,moxart-mac";
-   reg =   <0x9090 0x100>;
+   reg = <0x9090 0x90>;
interrupts = <25 0>;
+   phy-handle = <>;
};
 
mac1: mac@9200 {
compatible = "moxa,moxart-mac";
-   reg =   <0x9200 0x100>;
+   reg = <0x9200 0x90>;
interrupts = <27 0>;
+   phy-handle = <>;
};
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 17c9f0e..c19bff2 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "moxart_ether.h"
 
@@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, 
void *addr)
return 0;
 }
 
+static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   if (!netif_running(ndev))
+   return -EINVAL;
+
+   return phy_mii_ioctl(priv->phy_dev, ir, cmd);
+}
+
 static void moxart_mac_free_memory(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev)
writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
 }
 
+static void moxart_mac_update_duplex(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   priv->reg_maccr &= ~(FULLDUP | ENRX_IN_HALFTX);
+   if (priv->duplex)
+   priv->reg_maccr |= FULLDUP;
+   else
+   priv->reg_maccr |= ENRX_IN_HALFTX;
+
+   writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
+}
+
 static void moxart_mac_setup_desc_ring(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev)
moxart_update_mac_address(ndev);
moxart_mac_setup_desc_ring(ndev);
moxart_mac_enable(ndev);
+
+   phy_start(priv->phy_dev);
+
netif_start_queue(ndev);
 
netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n",
@@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev)
 
napi_disable(>napi);
 
+   phy_stop(priv->phy_dev);
+
netif_stop_queue(ndev);
 
/* disable all interrupts */
@@ -435,12 +466,49 @@ static struct net_device_ops moxart_netdev_ops = {
.ndo_set

[PATCH v3 7/7] net: moxa: use eth_mac_addr()

2014-01-20 Thread Jonas Jensen
Replace boilerplate in moxart_set_mac_address() with eth_mac_addr().

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 0f25f4dc..8378be9 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -56,12 +56,7 @@ static void moxart_update_mac_address(struct net_device 
*ndev)
 
 static int moxart_set_mac_address(struct net_device *ndev, void *addr)
 {
-   struct sockaddr *address = addr;
-
-   if (!is_valid_ether_addr(address->sa_data))
-   return -EADDRNOTAVAIL;
-
-   memcpy(ndev->dev_addr, address->sa_data, ndev->addr_len);
+   eth_mac_addr(ndev, addr);
moxart_update_mac_address(ndev);
 
return 0;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 5/7] net: moxa: add IFF_LIVE_ADDR_CHANGE flag

2014-01-20 Thread Jonas Jensen
.ndo_set_mac_address hook callback already supports IFF_LIVE_ADDR_CHANGE
so add it to our flags.

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index ca892bb..6df372f 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -728,7 +728,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
ether_setup(ndev);
ndev->netdev_ops = _netdev_ops;
netif_napi_add(ndev, >napi, moxart_rx_poll, RX_DESC_NUM);
-   ndev->priv_flags |= IFF_UNICAST_FLT;
+   ndev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE;
ndev->irq = irq;
 
SET_NETDEV_DEV(ndev, >dev);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 1/7] net: moxa: clear TX descriptor length bits between sends

2014-01-20 Thread Jonas Jensen
Add TX_DESC1_BUF_SIZE_MASK to bits that are cleared, before the TX buffer
length is set. Failing to do so can cause the controller to drop dead
i.e. all TX interrupts stop, resulting in complete communication failure.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..aa45607 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -348,7 +348,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+   txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE |
+   TX_DESC1_BUF_SIZE_MASK);
txdes1 |= (len & TX_DESC1_BUF_SIZE_MASK);
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 4/7] net: moxa: add ethtool support

2014-01-20 Thread Jonas Jensen
Add and assign ethtool_ops callback functions.

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 121 +++
 1 file changed, 121 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index c19bff2..ca892bb 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -31,6 +31,10 @@
 
 #include "moxart_ether.h"
 
+#define DRV_NAME   "moxart-ethernet"
+#define DRV_VERSION"0.2"
+#define MOXART_NUM_STATS   ARRAY_SIZE(ethtool_stats_keys)
+
 static inline void moxart_emac_write(struct net_device *ndev,
 unsigned int reg, unsigned long value)
 {
@@ -63,6 +67,122 @@ static int moxart_set_mac_address(struct net_device *ndev, 
void *addr)
return 0;
 }
 
+static struct {
+   const char str[ETH_GSTRING_LEN];
+} ethtool_stats_keys[] = {
+   { "tx_ok_mcol_2to15" },
+   { "tx_ok_1col" },
+   { "rx_frame_pause" },
+   { "frame_align_err" },
+   { "err_col_late_16" },
+   { "err_col_16" },
+   { "rx_runt" },
+   { "late_col" },
+   { "crc_err" },
+   { "rx_ftl" },
+   { "rx_fifo_full" },
+   { "rx_col" },
+   { "rx_bcast" },
+   { "rx_mcast" },
+   { "rx_ok" },
+   { "tx_ok" },
+};
+
+static void moxart_get_drvinfo(struct net_device *ndev,
+  struct ethtool_drvinfo *info)
+{
+   strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+   strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+   strlcpy(info->bus_info, dev_name(>dev), sizeof(info->bus_info));
+}
+
+static int moxart_get_settings(struct net_device *ndev, struct ethtool_cmd 
*cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return phy_ethtool_gset(priv->phy_dev, cmd);
+}
+
+static int moxart_set_settings(struct net_device *ndev, struct ethtool_cmd 
*cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return phy_ethtool_sset(priv->phy_dev, cmd);
+}
+
+static int moxart_nway_reset(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return genphy_restart_aneg(priv->phy_dev);
+}
+
+static void moxart_get_ethtool_stats(struct net_device *ndev,
+struct ethtool_stats *estats,
+u64 *tmp_stats)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+   u32 s;
+   int i = 0;
+
+   s = readl(priv->base + REG_TX_COL_COUNTER);
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = s & 0x;
+   s = readl(priv->base + REG_RPF_AEP_COUNTER);
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = s & 0x;
+   s = readl(priv->base + REG_XM_PG_COUNTER);
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = s & 0x;
+   s = readl(priv->base + REG_RUNT_TLC_COUNTER);
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = s & 0x;
+   s = readl(priv->base + REG_CRC_FTL_COUNTER);
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = s & 0x;
+   s = readl(priv->base + REG_RLC_RCC_COUNTER);
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = s & 0x;
+   tmp_stats[i++] = readl(priv->base + REG_BROC_COUNTER);
+   tmp_stats[i++] = readl(priv->base + REG_MULCA_COUNTER);
+   tmp_stats[i++] = readl(priv->base + REG_XP_COUNTER);
+   tmp_stats[i++] = readl(priv->base + REG_RP_COUNTER);
+}
+
+static int moxart_get_sset_count(struct net_device *netdev,
+   int string_set)
+{
+   switch (string_set) {
+   case ETH_SS_STATS:
+   return MOXART_NUM_STATS;
+   default:
+   return -EINVAL;
+   }
+}
+
+static void moxart_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+{
+   switch (stringset) {
+   case ETH_SS_STATS:
+   memcpy(data, _stats_keys, sizeof(ethtool_stats_keys));
+   break;
+   default:
+   WARN_ON(1);
+   break;
+   }
+}
+
+static const struct ethtool_ops moxart_ethtool_ops = {
+   .set_settings   = moxart_set_settings,
+   .get_settings   = moxart_get_settings,
+   .get_drvinfo= moxart_get_drvinfo,
+   .nway_reset = moxart_nway_reset,
+   .get_link   = ethtool_op_get_link,
+   .get_ethtool_stats  = moxart_get_ethtool_stats,
+   .get_sset_count 

[PATCH v3 4/7] net: moxa: add ethtool support

2014-01-20 Thread Jonas Jensen
Add and assign ethtool_ops callback functions.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 121 +++
 1 file changed, 121 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index c19bff2..ca892bb 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -31,6 +31,10 @@
 
 #include moxart_ether.h
 
+#define DRV_NAME   moxart-ethernet
+#define DRV_VERSION0.2
+#define MOXART_NUM_STATS   ARRAY_SIZE(ethtool_stats_keys)
+
 static inline void moxart_emac_write(struct net_device *ndev,
 unsigned int reg, unsigned long value)
 {
@@ -63,6 +67,122 @@ static int moxart_set_mac_address(struct net_device *ndev, 
void *addr)
return 0;
 }
 
+static struct {
+   const char str[ETH_GSTRING_LEN];
+} ethtool_stats_keys[] = {
+   { tx_ok_mcol_2to15 },
+   { tx_ok_1col },
+   { rx_frame_pause },
+   { frame_align_err },
+   { err_col_late_16 },
+   { err_col_16 },
+   { rx_runt },
+   { late_col },
+   { crc_err },
+   { rx_ftl },
+   { rx_fifo_full },
+   { rx_col },
+   { rx_bcast },
+   { rx_mcast },
+   { rx_ok },
+   { tx_ok },
+};
+
+static void moxart_get_drvinfo(struct net_device *ndev,
+  struct ethtool_drvinfo *info)
+{
+   strlcpy(info-driver, DRV_NAME, sizeof(info-driver));
+   strlcpy(info-version, DRV_VERSION, sizeof(info-version));
+   strlcpy(info-bus_info, dev_name(ndev-dev), sizeof(info-bus_info));
+}
+
+static int moxart_get_settings(struct net_device *ndev, struct ethtool_cmd 
*cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return phy_ethtool_gset(priv-phy_dev, cmd);
+}
+
+static int moxart_set_settings(struct net_device *ndev, struct ethtool_cmd 
*cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return phy_ethtool_sset(priv-phy_dev, cmd);
+}
+
+static int moxart_nway_reset(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   return genphy_restart_aneg(priv-phy_dev);
+}
+
+static void moxart_get_ethtool_stats(struct net_device *ndev,
+struct ethtool_stats *estats,
+u64 *tmp_stats)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+   u32 s;
+   int i = 0;
+
+   s = readl(priv-base + REG_TX_COL_COUNTER);
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = s  0x;
+   s = readl(priv-base + REG_RPF_AEP_COUNTER);
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = s  0x;
+   s = readl(priv-base + REG_XM_PG_COUNTER);
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = s  0x;
+   s = readl(priv-base + REG_RUNT_TLC_COUNTER);
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = s  0x;
+   s = readl(priv-base + REG_CRC_FTL_COUNTER);
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = s  0x;
+   s = readl(priv-base + REG_RLC_RCC_COUNTER);
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = s  0x;
+   tmp_stats[i++] = readl(priv-base + REG_BROC_COUNTER);
+   tmp_stats[i++] = readl(priv-base + REG_MULCA_COUNTER);
+   tmp_stats[i++] = readl(priv-base + REG_XP_COUNTER);
+   tmp_stats[i++] = readl(priv-base + REG_RP_COUNTER);
+}
+
+static int moxart_get_sset_count(struct net_device *netdev,
+   int string_set)
+{
+   switch (string_set) {
+   case ETH_SS_STATS:
+   return MOXART_NUM_STATS;
+   default:
+   return -EINVAL;
+   }
+}
+
+static void moxart_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+{
+   switch (stringset) {
+   case ETH_SS_STATS:
+   memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
+   break;
+   default:
+   WARN_ON(1);
+   break;
+   }
+}
+
+static const struct ethtool_ops moxart_ethtool_ops = {
+   .set_settings   = moxart_set_settings,
+   .get_settings   = moxart_get_settings,
+   .get_drvinfo= moxart_get_drvinfo,
+   .nway_reset = moxart_nway_reset,
+   .get_link   = ethtool_op_get_link,
+   .get_ethtool_stats  = moxart_get_ethtool_stats,
+   .get_sset_count = moxart_get_sset_count,
+   .get_strings= moxart_get_strings,
+};
+
 static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -612,6 +732,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
ndev-irq = irq

[PATCH v3 1/7] net: moxa: clear TX descriptor length bits between sends

2014-01-20 Thread Jonas Jensen
Add TX_DESC1_BUF_SIZE_MASK to bits that are cleared, before the TX buffer
length is set. Failing to do so can cause the controller to drop dead
i.e. all TX interrupts stop, resulting in complete communication failure.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69031

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 5020fd4..aa45607 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -348,7 +348,8 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, 
struct net_device *ndev)
 
txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
-   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+   txdes1 = ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE |
+   TX_DESC1_BUF_SIZE_MASK);
txdes1 |= (len  TX_DESC1_BUF_SIZE_MASK);
writel(txdes1, desc + TX_REG_OFFSET_DESC1);
writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 5/7] net: moxa: add IFF_LIVE_ADDR_CHANGE flag

2014-01-20 Thread Jonas Jensen
.ndo_set_mac_address hook callback already supports IFF_LIVE_ADDR_CHANGE
so add it to our flags.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index ca892bb..6df372f 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -728,7 +728,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
ether_setup(ndev);
ndev-netdev_ops = moxart_netdev_ops;
netif_napi_add(ndev, priv-napi, moxart_rx_poll, RX_DESC_NUM);
-   ndev-priv_flags |= IFF_UNICAST_FLT;
+   ndev-priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE;
ndev-irq = irq;
 
SET_NETDEV_DEV(ndev, pdev-dev);
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 7/7] net: moxa: use eth_mac_addr()

2014-01-20 Thread Jonas Jensen
Replace boilerplate in moxart_set_mac_address() with eth_mac_addr().

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 0f25f4dc..8378be9 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -56,12 +56,7 @@ static void moxart_update_mac_address(struct net_device 
*ndev)
 
 static int moxart_set_mac_address(struct net_device *ndev, void *addr)
 {
-   struct sockaddr *address = addr;
-
-   if (!is_valid_ether_addr(address-sa_data))
-   return -EADDRNOTAVAIL;
-
-   memcpy(ndev-dev_addr, address-sa_data, ndev-addr_len);
+   eth_mac_addr(ndev, addr);
moxart_update_mac_address(ndev);
 
return 0;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 3/7] net: moxa: connect to PHY

2014-01-20 Thread Jonas Jensen
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP),
connect to this PHY using OF.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140120

 .../devicetree/bindings/net/moxa,moxart-mac.txt| 47 ++-
 drivers/net/ethernet/moxa/moxart_ether.c   | 92 +-
 drivers/net/ethernet/moxa/moxart_ether.h   |  2 +
 3 files changed, 138 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt 
b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
index 583418b..94c1f3b 100644
--- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
+++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
@@ -1,21 +1,64 @@
 MOXA ART Ethernet Controller
 
+Integrated MDIO bus node:
+
+- compatible: moxa,moxart-mdio
+- Inherits from MDIO bus node binding[1]
+
+[1] Documentation/devicetree/bindings/net/phy.txt
+
+
+Ethernet node:
+
 Required properties:
 
 - compatible : Must be moxa,moxart-mac
 - reg : Should contain register location and length
 - interrupts : Should contain the mac interrupt number
 
+Optional Properties:
+
+- phy-handle : the phandle to a PHY node
+
+
 Example:
 
+   mdio0: mdio@90900090 {
+   compatible = moxa,moxart-mdio;
+   reg = 0x90900090 0x8;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   ethphy0: ethernet-phy@1 {
+   device_type = ethernet-phy;
+   compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
+   reg = 1;
+   };
+   };
+
+   mdio1: mdio@9290 {
+   compatible = moxa,moxart-mdio;
+   reg = 0x9290 0x8;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   ethphy1: ethernet-phy@1 {
+   device_type = ethernet-phy;
+   compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
+   reg = 1;
+   };
+   };
+
mac0: mac@9090 {
compatible = moxa,moxart-mac;
-   reg =   0x9090 0x100;
+   reg = 0x9090 0x90;
interrupts = 25 0;
+   phy-handle = ethphy0;
};
 
mac1: mac@9200 {
compatible = moxa,moxart-mac;
-   reg =   0x9200 0x100;
+   reg = 0x9200 0x90;
interrupts = 27 0;
+   phy-handle = ethphy1;
};
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 17c9f0e..c19bff2 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -25,6 +25,9 @@
 #include linux/of_irq.h
 #include linux/crc32.h
 #include linux/crc32c.h
+#include linux/phy.h
+#include linux/of_mdio.h
+#include linux/of_net.h
 
 #include moxart_ether.h
 
@@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, 
void *addr)
return 0;
 }
 
+static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   if (!netif_running(ndev))
+   return -EINVAL;
+
+   return phy_mii_ioctl(priv-phy_dev, ir, cmd);
+}
+
 static void moxart_mac_free_memory(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev)
writel(priv-reg_maccr, priv-base + REG_MAC_CTRL);
 }
 
+static void moxart_mac_update_duplex(struct net_device *ndev)
+{
+   struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+   priv-reg_maccr = ~(FULLDUP | ENRX_IN_HALFTX);
+   if (priv-duplex)
+   priv-reg_maccr |= FULLDUP;
+   else
+   priv-reg_maccr |= ENRX_IN_HALFTX;
+
+   writel(priv-reg_maccr, priv-base + REG_MAC_CTRL);
+}
+
 static void moxart_mac_setup_desc_ring(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
@@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev)
moxart_update_mac_address(ndev);
moxart_mac_setup_desc_ring(ndev);
moxart_mac_enable(ndev);
+
+   phy_start(priv-phy_dev);
+
netif_start_queue(ndev);
 
netdev_dbg(ndev, %s: IMR=0x%x, MACCR=0x%x\n,
@@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev)
 
napi_disable(priv-napi);
 
+   phy_stop(priv-phy_dev);
+
netif_stop_queue(ndev);
 
/* disable all interrupts */
@@ -435,12 +466,49 @@ static struct net_device_ops moxart_netdev_ops = {
.ndo_set_mac_address= moxart_set_mac_address,
.ndo_validate_addr  = eth_validate_addr,
.ndo_change_mtu = eth_change_mtu,
+   .ndo_do_ioctl   = moxart_do_ioctl,
 };
 
+static void moxart_adjust_link

[PATCH v3 6/7] net: moxa: generate random address

2014-01-20 Thread Jonas Jensen
The address register is zero:ed on boot, fill it with a randomly generated
address on probe.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 6df372f..0f25f4dc 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -740,6 +740,12 @@ static int moxart_mac_probe(struct platform_device *pdev)
goto init_fail;
}
 
+   if (!is_valid_ether_addr(ndev-dev_addr)) {
+   eth_hw_addr_random(ndev);
+   netdev_info(ndev, generated random MAC address %pM\n,
+   ndev-dev_addr);
+   }
+
netdev_dbg(ndev, %s: IRQ=%d address=%pM\n,
   __func__, ndev-irq, ndev-dev_addr);
 
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 2/7] net: moxa: fix build_skb() memory corruption

2014-01-20 Thread Jonas Jensen
DMA buffer memory must be synchronized and copied before passing skb to
napi_gro_receive(). The use of build_skb() can lead to memory corruption,
replace it with netdev_alloc_skb_ip_align() and memcpy().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=69041

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
This fixes the following error on wget download (or ncftp),
usually after only a few seconds:

read error: Bad address

On receiving this error, wget exits. The download is not resumed (busybox 
default).

Applies to next-20140120

 drivers/net/ethernet/moxa/moxart_ether.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index aa45607..17c9f0e 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -226,14 +226,21 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
if (len  RX_BUF_SIZE)
len = RX_BUF_SIZE;
 
-   skb = build_skb(priv-rx_buf[rx_head], priv-rx_buf_size);
+   dma_sync_single_for_cpu(ndev-dev,
+   priv-rx_mapping[rx_head],
+   priv-rx_buf_size, DMA_FROM_DEVICE);
+   skb = netdev_alloc_skb_ip_align(ndev, len);
if (unlikely(!skb)) {
-   net_dbg_ratelimited(build_skb failed\n);
+   net_dbg_ratelimited(netdev_alloc_skb_ip_align 
failed\n);
priv-stats.rx_dropped++;
priv-stats.rx_errors++;
}
-
+   memcpy(skb-data, priv-rx_buf[rx_head], len);
skb_put(skb, len);
+   dma_sync_single_for_device(ndev-dev,
+  priv-rx_mapping[rx_head],
+  priv-rx_buf_size, DMA_FROM_DEVICE);
+
skb-protocol = eth_type_trans(skb, ndev);
napi_gro_receive(priv-napi, skb);
rx++;
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v9] clk: add MOXA ART SoCs clock driver

2014-01-17 Thread Jonas Jensen
This patch adds MOXA ART SoCs clock driver support.

Signed-off-by: Jonas Jensen 
---

Notes:
Changes since v8:

1. rebase drivers/clk/Makefile to next-20140117

DT bindings document:

2. use two separate sections describing PLL/APB
3. update example

Applies to next-20140117

 .../bindings/clock/moxa,moxart-clock.txt   |  48 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/clk-moxart.c   | 112 +
 3 files changed, 161 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
 create mode 100644 drivers/clk/clk-moxart.c

diff --git a/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt 
b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
new file mode 100644
index 000..242e3fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
@@ -0,0 +1,48 @@
+Device Tree Clock bindings for arch-moxart
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+MOXA ART SoCs allow to determine PLL output and APB frequencies
+by reading registers holding multiplier and divisor information.
+
+
+PLL:
+
+Required properties:
+- compatible : Must be "moxa,moxart-pll-clock"
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+APB:
+
+Required properties:
+- compatible : Must be "moxa,moxart-apb-clock"
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+For example:
+
+   clk_pll: clk_pll@9810 {
+   compatible = "moxa,moxart-pll-clock";
+   #clock-cells = <0>;
+   reg = <0x9810 0x34>;
+   };
+
+   clk_apb: clk_apb@9810 {
+   compatible = "moxa,moxart-apb-clock";
+   #clock-cells = <0>;
+   reg = <0x9810 0x34>;
+   clocks = <_pll>;
+   };
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 0c16e9c..ed5d58d 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK)  += clk-composite.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)   += clk-efm32gg.o
+obj-$(CONFIG_ARCH_MOXART)  += clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)+= clk-highbank.o
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
new file mode 100644
index 000..f0436a3
--- /dev/null
+++ b/drivers/clk/clk-moxart.c
@@ -0,0 +1,112 @@
+/*
+ * MOXA ART SoCs clock driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+void __init moxart_of_pll_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *ref_clk;
+   unsigned long rate;
+   unsigned int mul;
+   const char *name = node->name;
+
+   of_property_read_string(node, "clock-output-names", );
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err("%s: of_iomap failed\n", node->full_name);
+   return;
+   }
+
+   mul = readl(base + 0x30) >> 3 & 0x3f;
+   iounmap(base);
+
+   ref_clk = of_clk_get(node, 0);
+   if (IS_ERR(ref_clk)) {
+   pr_err("%s: of_clk_get failed\n", node->full_name);
+   return;
+   }
+
+   rate = mul * clk_get_rate(ref_clk);
+
+   clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
+   if (IS_ERR(clk)) {
+   pr_err("%s: clk_register_fixed_rate failed\n", node->full_name);
+   return;
+   }
+
+   clk_register_clkdev(clk, NULL, name);
+   of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(moxart_pll_clock, "moxa,moxart-pll-clock",
+  moxart_of_pll_clk_init);
+
+void __init moxart_of_apb_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *pll_clk;
+   unsigned long rate;
+   unsigned int div, val;
+   const char *name = node->name;
+
+   of_property_read_string(node, "clock-output-names", );
+
+   base = of_iomap(node, 0);
+   if (!base) {
+

[PATCH v6] mmc: sdhci-moxart: Add MOXA ART SDHCI driver

2014-01-17 Thread Jonas Jensen
Add SDHCI driver for MOXA ART SoCs.

Signed-off-by: Jonas Jensen 
---

Notes:
Changes in v6 fixes a kernel panic in moxart_dma_complete().

Panic only happens with CONFIG_SLAB or CONFIG_SLOB, the same code
works for CONFIG_SLUB, and happens because a cookie belonging
to the channel is passed to dmaengine_tx_status(), e.g.
"host->tx_desc->chan->cookie".

Panic log:
[4.13] mmc0: new SD card at address e624
[4.17] nf_conntrack version 0.5.0 (357 buckets, 1428 max)
[4.19] ip_tables: (C) 2000-2006 Netfilter Core Team
[4.19] TCP: cubic registered
[4.20] NET: Registered protocol family 10
[4.24] sit: IPv6 over IPv4 tunneling driver
[4.27] mmcblk0: mmc0:e624 SD02G 1.84 GiB
[4.32]  mmcblk0: p1
[4.37] NET: Registered protocol family 17
[4.44] console [netcon0] enabled
[4.44] netconsole: network logging started
[4.45] moxart-rtc rtc.0: setting system clock to 2014-01-16 
13:39:54 UTC (1389879594)
[4.55] kjournald starting.  Commit interval 5 seconds
[4.55] EXT3-fs (mmcblk0p1): warning: maximal mount count reached, 
running e2fsck is recommended
[4.57] EXT3-fs (mmcblk0p1): using internal journal
[4.58] EXT3-fs (mmcblk0p1): mounted filesystem with ordered data 
mode
[4.59] VFS: Mounted root (ext3 filesystem) on device 179:1.
[4.61] devtmpfs: mounted
[4.63] Freeing unused kernel memory: 156K (c0339000 - c036)
[4.64] Unable to handle kernel paging request at virtual address 

[4.64] pgd = c0004000
[4.64] [] *pgd=
[4.64] Internal error: Oops: 1 [#1] ARM
[4.64] CPU: 0 PID: 0 Comm: swapper Not tainted 
3.13.0-rc8-next-20140115+ #1577
[4.64] task: c03676a8 ti: c0362000 task.ti: c0362000
[4.64] PC is at moxart_dma_complete+0x14/0x68
[4.64] LR is at vchan_complete+0xcc/0xf4
[4.64] pc : []lr : []psr: a013
[4.64] sp : c0363e98  ip : c037ffcc  fp : c0380f00
[4.64] r10: c1a867e0  r9 : c0380f38  r8 : c0363eb0
[4.64] r7 : 00100100  r6 : 00200200  r5 : c01a6710  r4 : c1a867e0
[4.64] r3 : c1ac0030  r2 : c0363e9c  r1 : c03676a8  r0 : 
[4.64] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
kernel
[4.64] Control: 397f  Table: 4000  DAC: 0017
[4.64] Process swapper (pid: 0, stack limit = 0xc03621c0)
[4.64] Stack: (0xc0363e98 to 0xc0364000)
[4.64] 3e80:   
c1a867e0 c03676a8
[4.64] 3ea0:  c03676a8 c1871158 c0154a28 c0363eb0 c0363eb0 
6013 c1871184
[4.64] 3ec0: c03694d4   0006 0100 c0018fc4 
c036bc60 0007
[4.64] 3ee0: 0040 c0362000 c0380f20 c0018950 c185b894 c185b894 
c185b840 0006
[4.64] 3f00: 000a 0020 0001 8ca1  0011 
 c0934d40
[4.64] 3f20: 0001 c0363f68 66015261 c0352624  c0018d38 
0011 c0009a14
[4.64] 3f40: c18020e4 0100 0018 c0008538 c0009b94 2013 
 c0363f9c
[4.64] 3f60: c0998200 c000bfb8 0001 c03676a8  2013 
c0362000 c0364020
[4.64] 3f80: c0364110  c0998200 66015261 c0352624  
f6aa4ecf c0363fb0
[4.64] 3fa0: c003da20 c0009b94 2013  c03676a8 c0047548 
c03676a8 c0339988
[4.64] 3fc0:   c03394d4   c0352624 
 397d
[4.64] 3fe0: c03640a4 c0352620 c03689ec 4000 003517b4 8040 
 
[4.64] [] (moxart_dma_complete) from [] 
(vchan_complete+0xcc/0xf4)
[4.64] [] (vchan_complete) from [] 
(tasklet_action+0x84/0xd4)
[4.64] [] (tasklet_action) from [] 
(__do_softirq+0x170/0x2a4)
[4.64] [] (__do_softirq) from [] 
(irq_exit+0x80/0x100)
[4.64] [] (irq_exit) from [] 
(handle_IRQ+0x60/0x80)
[4.64] [] (handle_IRQ) from [] 
(handle_irq+0x88/0x9c)
[4.64] [] (handle_irq) from [] 
(__irq_svc+0x38/0x48)
[4.64] Exception stack(0xc0363f68 to 0xc0363fb0)
[4.64] 3f60:   0001 c03676a8  2013 
c0362000 c0364020
[4.64] 3f80: c0364110  c0998200 66015261 c0352624  
f6aa4ecf c0363fb0
[4.64] 3fa0: c003da20 c0009b94 2013 
[4.64] [] (__irq_svc) from [] 
(arch_cpu_idle+0x3c/0x48)
[4.64] [] (arch_cpu_idle) from [] 
(cpu_startup_entry+0x80/0xf0)
[4.64] [] (cpu_startup_entry) from [] 
(start_kernel+0x298/0x2e0)
[4.64] Code: e5903030 e1a04000 e593000c e28d2004 (e5903000)
[   

[PATCH v16] dmaengine: Add MOXA ART DMA engine driver

2014-01-17 Thread Jonas Jensen
The MOXA ART SoC has a DMA controller capable of offloading expensive
memory operations, such as large copies. This patch adds support for
the controller including four channels. Two of these are used to
handle MMC copy on the UC-7112-LX hardware. The remaining two can be
used in a future audio driver or client application.

Signed-off-by: Jonas Jensen 
---

Notes:
Changes since v15:
1. rebase drivers/dma/Kconfig to next-20140117

Applies to next-20140117

 .../devicetree/bindings/dma/moxa,moxart-dma.txt|  45 ++
 drivers/dma/Kconfig|   8 +
 drivers/dma/Makefile   |   1 +
 drivers/dma/moxart-dma.c   | 699 +
 4 files changed, 753 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt
 create mode 100644 drivers/dma/moxart-dma.c

diff --git a/Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt 
b/Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt
new file mode 100644
index 000..8a9f355
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt
@@ -0,0 +1,45 @@
+MOXA ART DMA Controller
+
+See dma.txt first
+
+Required properties:
+
+- compatible : Must be "moxa,moxart-dma"
+- reg :Should contain registers location and length
+- interrupts : Should contain an interrupt-specifier for the sole
+   interrupt generated by the device
+- #dma-cells : Should be 1, a single cell holding a line request number
+
+Example:
+
+   dma: dma@9050 {
+   compatible = "moxa,moxart-dma";
+   reg = <0x90500080 0x40>;
+   interrupts = <24 0>;
+   #dma-cells = <1>;
+   };
+
+
+Clients:
+
+DMA clients connected to the MOXA ART DMA controller must use the format
+described in the dma.txt file, using a two-cell specifier for each channel:
+a phandle plus one integer cells.
+The two cells in order are:
+
+1. A phandle pointing to the DMA controller.
+2. Peripheral identifier for the hardware handshaking interface.
+
+Example:
+Use specific request line passing from dma
+For example, MMC request line is 5
+
+   sdhci: sdhci@98e0 {
+   compatible = "moxa,moxart-sdhci";
+   reg = <0x98e0 0x5C>;
+   interrupts = <5 0>;
+   clocks = <_apb>;
+   dmas =  < 5>,
+   < 5>;
+   dma-names = "tx", "rx";
+   };
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 9ae6f54..9bed1a2 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -342,6 +342,14 @@ config K3_DMA
  Support the DMA engine for Hisilicon K3 platform
  devices.
 
+config MOXART_DMA
+   tristate "MOXART DMA support"
+   depends on ARCH_MOXART
+   select DMA_ENGINE
+   select DMA_VIRTUAL_CHANNELS
+   help
+ Enable support for the MOXA ART SoC DMA controller.
+
 config DMA_ENGINE
bool
 
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 0a6f08e..a029d0f4 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -43,3 +43,4 @@ obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o
 obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o
 obj-$(CONFIG_TI_CPPI41) += cppi41.o
 obj-$(CONFIG_K3_DMA) += k3dma.o
+obj-$(CONFIG_MOXART_DMA) += moxart-dma.o
diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
new file mode 100644
index 000..3258e48
--- /dev/null
+++ b/drivers/dma/moxart-dma.c
@@ -0,0 +1,699 @@
+/*
+ * MOXA ART SoCs DMA Engine support.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "dmaengine.h"
+#include "virt-dma.h"
+
+#define APB_DMA_MAX_CHANNEL4
+
+#define REG_OFF_ADDRESS_SOURCE 0
+#define REG_OFF_ADDRESS_DEST   4
+#define REG_OFF_CYCLES 8
+#define REG_OFF_CTRL   12
+#define REG_OFF_CHAN_SIZE  16
+
+#define APB_DMA_ENABLE BIT(0)
+#define APB_DMA_FIN_INT_STSBIT(1)
+#define APB_DMA_FIN_INT_EN BIT(2)
+#define APB_DMA_BURST_MODE BIT(3)
+#define APB_DMA_ERR_INT_STSBIT(4)
+#define APB_DMA_ERR_INT_EN BIT(5)
+
+/*
+ * Unset: APB
+ * Set:   AHB
+ */
+#define APB_DMA_SOURCE_SELECT  0x40
+#define APB_DMA_DEST_SELECT0x80
+
+

[PATCH v16] dmaengine: Add MOXA ART DMA engine driver

2014-01-17 Thread Jonas Jensen
The MOXA ART SoC has a DMA controller capable of offloading expensive
memory operations, such as large copies. This patch adds support for
the controller including four channels. Two of these are used to
handle MMC copy on the UC-7112-LX hardware. The remaining two can be
used in a future audio driver or client application.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes since v15:
1. rebase drivers/dma/Kconfig to next-20140117

Applies to next-20140117

 .../devicetree/bindings/dma/moxa,moxart-dma.txt|  45 ++
 drivers/dma/Kconfig|   8 +
 drivers/dma/Makefile   |   1 +
 drivers/dma/moxart-dma.c   | 699 +
 4 files changed, 753 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt
 create mode 100644 drivers/dma/moxart-dma.c

diff --git a/Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt 
b/Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt
new file mode 100644
index 000..8a9f355
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/moxa,moxart-dma.txt
@@ -0,0 +1,45 @@
+MOXA ART DMA Controller
+
+See dma.txt first
+
+Required properties:
+
+- compatible : Must be moxa,moxart-dma
+- reg :Should contain registers location and length
+- interrupts : Should contain an interrupt-specifier for the sole
+   interrupt generated by the device
+- #dma-cells : Should be 1, a single cell holding a line request number
+
+Example:
+
+   dma: dma@9050 {
+   compatible = moxa,moxart-dma;
+   reg = 0x90500080 0x40;
+   interrupts = 24 0;
+   #dma-cells = 1;
+   };
+
+
+Clients:
+
+DMA clients connected to the MOXA ART DMA controller must use the format
+described in the dma.txt file, using a two-cell specifier for each channel:
+a phandle plus one integer cells.
+The two cells in order are:
+
+1. A phandle pointing to the DMA controller.
+2. Peripheral identifier for the hardware handshaking interface.
+
+Example:
+Use specific request line passing from dma
+For example, MMC request line is 5
+
+   sdhci: sdhci@98e0 {
+   compatible = moxa,moxart-sdhci;
+   reg = 0x98e0 0x5C;
+   interrupts = 5 0;
+   clocks = clk_apb;
+   dmas =  dma 5,
+   dma 5;
+   dma-names = tx, rx;
+   };
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 9ae6f54..9bed1a2 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -342,6 +342,14 @@ config K3_DMA
  Support the DMA engine for Hisilicon K3 platform
  devices.
 
+config MOXART_DMA
+   tristate MOXART DMA support
+   depends on ARCH_MOXART
+   select DMA_ENGINE
+   select DMA_VIRTUAL_CHANNELS
+   help
+ Enable support for the MOXA ART SoC DMA controller.
+
 config DMA_ENGINE
bool
 
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 0a6f08e..a029d0f4 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -43,3 +43,4 @@ obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o
 obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o
 obj-$(CONFIG_TI_CPPI41) += cppi41.o
 obj-$(CONFIG_K3_DMA) += k3dma.o
+obj-$(CONFIG_MOXART_DMA) += moxart-dma.o
diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
new file mode 100644
index 000..3258e48
--- /dev/null
+++ b/drivers/dma/moxart-dma.c
@@ -0,0 +1,699 @@
+/*
+ * MOXA ART SoCs DMA Engine support.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen jonas.jen...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/dmaengine.h
+#include linux/dma-mapping.h
+#include linux/err.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/list.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/spinlock.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/of_dma.h
+#include linux/bitops.h
+
+#include asm/cacheflush.h
+
+#include dmaengine.h
+#include virt-dma.h
+
+#define APB_DMA_MAX_CHANNEL4
+
+#define REG_OFF_ADDRESS_SOURCE 0
+#define REG_OFF_ADDRESS_DEST   4
+#define REG_OFF_CYCLES 8
+#define REG_OFF_CTRL   12
+#define REG_OFF_CHAN_SIZE  16
+
+#define APB_DMA_ENABLE BIT(0)
+#define APB_DMA_FIN_INT_STSBIT(1)
+#define APB_DMA_FIN_INT_EN BIT(2)
+#define APB_DMA_BURST_MODE BIT(3)
+#define APB_DMA_ERR_INT_STSBIT(4)
+#define APB_DMA_ERR_INT_EN BIT(5)
+
+/*
+ * Unset: APB
+ * Set:   AHB
+ */
+#define

[PATCH v6] mmc: sdhci-moxart: Add MOXA ART SDHCI driver

2014-01-17 Thread Jonas Jensen
Add SDHCI driver for MOXA ART SoCs.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes in v6 fixes a kernel panic in moxart_dma_complete().

Panic only happens with CONFIG_SLAB or CONFIG_SLOB, the same code
works for CONFIG_SLUB, and happens because a cookie belonging
to the channel is passed to dmaengine_tx_status(), e.g.
host-tx_desc-chan-cookie.

Panic log:
[4.13] mmc0: new SD card at address e624
[4.17] nf_conntrack version 0.5.0 (357 buckets, 1428 max)
[4.19] ip_tables: (C) 2000-2006 Netfilter Core Team
[4.19] TCP: cubic registered
[4.20] NET: Registered protocol family 10
[4.24] sit: IPv6 over IPv4 tunneling driver
[4.27] mmcblk0: mmc0:e624 SD02G 1.84 GiB
[4.32]  mmcblk0: p1
[4.37] NET: Registered protocol family 17
[4.44] console [netcon0] enabled
[4.44] netconsole: network logging started
[4.45] moxart-rtc rtc.0: setting system clock to 2014-01-16 
13:39:54 UTC (1389879594)
[4.55] kjournald starting.  Commit interval 5 seconds
[4.55] EXT3-fs (mmcblk0p1): warning: maximal mount count reached, 
running e2fsck is recommended
[4.57] EXT3-fs (mmcblk0p1): using internal journal
[4.58] EXT3-fs (mmcblk0p1): mounted filesystem with ordered data 
mode
[4.59] VFS: Mounted root (ext3 filesystem) on device 179:1.
[4.61] devtmpfs: mounted
[4.63] Freeing unused kernel memory: 156K (c0339000 - c036)
[4.64] Unable to handle kernel paging request at virtual address 

[4.64] pgd = c0004000
[4.64] [] *pgd=
[4.64] Internal error: Oops: 1 [#1] ARM
[4.64] CPU: 0 PID: 0 Comm: swapper Not tainted 
3.13.0-rc8-next-20140115+ #1577
[4.64] task: c03676a8 ti: c0362000 task.ti: c0362000
[4.64] PC is at moxart_dma_complete+0x14/0x68
[4.64] LR is at vchan_complete+0xcc/0xf4
[4.64] pc : [c01a6724]lr : [c0154a28]psr: a013
[4.64] sp : c0363e98  ip : c037ffcc  fp : c0380f00
[4.64] r10: c1a867e0  r9 : c0380f38  r8 : c0363eb0
[4.64] r7 : 00100100  r6 : 00200200  r5 : c01a6710  r4 : c1a867e0
[4.64] r3 : c1ac0030  r2 : c0363e9c  r1 : c03676a8  r0 : 
[4.64] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment 
kernel
[4.64] Control: 397f  Table: 4000  DAC: 0017
[4.64] Process swapper (pid: 0, stack limit = 0xc03621c0)
[4.64] Stack: (0xc0363e98 to 0xc0364000)
[4.64] 3e80:   
c1a867e0 c03676a8
[4.64] 3ea0:  c03676a8 c1871158 c0154a28 c0363eb0 c0363eb0 
6013 c1871184
[4.64] 3ec0: c03694d4   0006 0100 c0018fc4 
c036bc60 0007
[4.64] 3ee0: 0040 c0362000 c0380f20 c0018950 c185b894 c185b894 
c185b840 0006
[4.64] 3f00: 000a 0020 0001 8ca1  0011 
 c0934d40
[4.64] 3f20: 0001 c0363f68 66015261 c0352624  c0018d38 
0011 c0009a14
[4.64] 3f40: c18020e4 0100 0018 c0008538 c0009b94 2013 
 c0363f9c
[4.64] 3f60: c0998200 c000bfb8 0001 c03676a8  2013 
c0362000 c0364020
[4.64] 3f80: c0364110  c0998200 66015261 c0352624  
f6aa4ecf c0363fb0
[4.64] 3fa0: c003da20 c0009b94 2013  c03676a8 c0047548 
c03676a8 c0339988
[4.64] 3fc0:   c03394d4   c0352624 
 397d
[4.64] 3fe0: c03640a4 c0352620 c03689ec 4000 003517b4 8040 
 
[4.64] [c01a6724] (moxart_dma_complete) from [c0154a28] 
(vchan_complete+0xcc/0xf4)
[4.64] [c0154a28] (vchan_complete) from [c0018fc4] 
(tasklet_action+0x84/0xd4)
[4.64] [c0018fc4] (tasklet_action) from [c0018950] 
(__do_softirq+0x170/0x2a4)
[4.64] [c0018950] (__do_softirq) from [c0018d38] 
(irq_exit+0x80/0x100)
[4.64] [c0018d38] (irq_exit) from [c0009a14] 
(handle_IRQ+0x60/0x80)
[4.64] [c0009a14] (handle_IRQ) from [c0008538] 
(handle_irq+0x88/0x9c)
[4.64] [c0008538] (handle_irq) from [c000bfb8] 
(__irq_svc+0x38/0x48)
[4.64] Exception stack(0xc0363f68 to 0xc0363fb0)
[4.64] 3f60:   0001 c03676a8  2013 
c0362000 c0364020
[4.64] 3f80: c0364110  c0998200 66015261 c0352624  
f6aa4ecf c0363fb0
[4.64] 3fa0: c003da20 c0009b94 2013 
[4.64] [c000bfb8] (__irq_svc) from [c0009b94] 
(arch_cpu_idle+0x3c/0x48)
[4.64] [c0009b94] (arch_cpu_idle) from [c0047548] 
(cpu_startup_entry+0x80/0xf0

[PATCH v9] clk: add MOXA ART SoCs clock driver

2014-01-17 Thread Jonas Jensen
This patch adds MOXA ART SoCs clock driver support.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Changes since v8:

1. rebase drivers/clk/Makefile to next-20140117

DT bindings document:

2. use two separate sections describing PLL/APB
3. update example

Applies to next-20140117

 .../bindings/clock/moxa,moxart-clock.txt   |  48 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/clk-moxart.c   | 112 +
 3 files changed, 161 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
 create mode 100644 drivers/clk/clk-moxart.c

diff --git a/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt 
b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
new file mode 100644
index 000..242e3fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/moxa,moxart-clock.txt
@@ -0,0 +1,48 @@
+Device Tree Clock bindings for arch-moxart
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+MOXA ART SoCs allow to determine PLL output and APB frequencies
+by reading registers holding multiplier and divisor information.
+
+
+PLL:
+
+Required properties:
+- compatible : Must be moxa,moxart-pll-clock
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+APB:
+
+Required properties:
+- compatible : Must be moxa,moxart-apb-clock
+- #clock-cells : Should be 0
+- reg : Should contain registers location and length
+- clocks : Should contain phandle to parent clock
+
+Optional properties:
+- clock-output-names : Should contain clock name
+
+
+For example:
+
+   clk_pll: clk_pll@9810 {
+   compatible = moxa,moxart-pll-clock;
+   #clock-cells = 0;
+   reg = 0x9810 0x34;
+   };
+
+   clk_apb: clk_apb@9810 {
+   compatible = moxa,moxart-apb-clock;
+   #clock-cells = 0;
+   reg = 0x9810 0x34;
+   clocks = clk_pll;
+   };
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 0c16e9c..ed5d58d 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_COMMON_CLK)  += clk-composite.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o
 obj-$(CONFIG_ARCH_EFM32)   += clk-efm32gg.o
+obj-$(CONFIG_ARCH_MOXART)  += clk-moxart.o
 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)+= clk-highbank.o
 obj-$(CONFIG_ARCH_HI3xxx)  += hisilicon/
diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
new file mode 100644
index 000..f0436a3
--- /dev/null
+++ b/drivers/clk/clk-moxart.c
@@ -0,0 +1,112 @@
+/*
+ * MOXA ART SoCs clock driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen jonas.jen...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/clk-provider.h
+#include linux/io.h
+#include linux/of_address.h
+#include linux/clkdev.h
+
+void __init moxart_of_pll_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *ref_clk;
+   unsigned long rate;
+   unsigned int mul;
+   const char *name = node-name;
+
+   of_property_read_string(node, clock-output-names, name);
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err(%s: of_iomap failed\n, node-full_name);
+   return;
+   }
+
+   mul = readl(base + 0x30)  3  0x3f;
+   iounmap(base);
+
+   ref_clk = of_clk_get(node, 0);
+   if (IS_ERR(ref_clk)) {
+   pr_err(%s: of_clk_get failed\n, node-full_name);
+   return;
+   }
+
+   rate = mul * clk_get_rate(ref_clk);
+
+   clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
+   if (IS_ERR(clk)) {
+   pr_err(%s: clk_register_fixed_rate failed\n, node-full_name);
+   return;
+   }
+
+   clk_register_clkdev(clk, NULL, name);
+   of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(moxart_pll_clock, moxa,moxart-pll-clock,
+  moxart_of_pll_clk_init);
+
+void __init moxart_of_apb_clk_init(struct device_node *node)
+{
+   static void __iomem *base;
+   struct clk *clk, *pll_clk;
+   unsigned long rate;
+   unsigned int div, val;
+   const char *name = node-name;
+
+   of_property_read_string(node, clock-output-names, name);
+
+   base = of_iomap(node, 0);
+   if (!base) {
+   pr_err(%s: of_iomap failed\n, node-full_name);
+   return

[PATCH] ARM: moxart: move fixed rate clock child node to board level dts

2014-01-16 Thread Jonas Jensen
When a skeleton "clocks { .. }" remain in .dtsi, the child node can
be moved to .dts, "ref12" is then found by of_clk_get().

Signed-off-by: Jonas Jensen 
---

Notes:
Applies to next-20140116

 arch/arm/boot/dts/moxart-uc7112lx.dts | 8 
 arch/arm/boot/dts/moxart.dtsi | 6 --
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
index 90749d5..10d088d 100644
--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -17,6 +17,14 @@
reg = <0x0 0x200>;
};
 
+   clocks {
+   ref12: ref12M {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1200>;
+   };
+   };
+
flash@8000,0 {
compatible = "numonyx,js28f128", "cfi-flash";
reg = <0x8000 0x100>;
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index da1d8ef..1fd27ed 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -26,12 +26,6 @@
clocks {
#address-cells = <1>;
#size-cells = <0>;
-
-   ref12: ref12M {
-   compatible = "fixed-clock";
-   #clock-cells = <0>;
-   clock-frequency = <1200>;
-   };
};
 
soc {
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: moxart: move fixed rate clock child node to board level dts

2014-01-16 Thread Jonas Jensen
When a skeleton clocks { .. } remain in .dtsi, the child node can
be moved to .dts, ref12 is then found by of_clk_get().

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---

Notes:
Applies to next-20140116

 arch/arm/boot/dts/moxart-uc7112lx.dts | 8 
 arch/arm/boot/dts/moxart.dtsi | 6 --
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
index 90749d5..10d088d 100644
--- a/arch/arm/boot/dts/moxart-uc7112lx.dts
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -17,6 +17,14 @@
reg = 0x0 0x200;
};
 
+   clocks {
+   ref12: ref12M {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 1200;
+   };
+   };
+
flash@8000,0 {
compatible = numonyx,js28f128, cfi-flash;
reg = 0x8000 0x100;
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index da1d8ef..1fd27ed 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -26,12 +26,6 @@
clocks {
#address-cells = 1;
#size-cells = 0;
-
-   ref12: ref12M {
-   compatible = fixed-clock;
-   #clock-cells = 0;
-   clock-frequency = 1200;
-   };
};
 
soc {
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: build_skb() and data corruption

2014-01-14 Thread Jonas Jensen
Thanks for the replies, you led me to a new solution,


I now think build_skb() is not the right choice, my motivation for
using it in the first place, that I thought it meant getting away with
not copying memory.

build_skb() is replaced by netdev_alloc_skb_ip_align() and memcpy()
(derived from drivers/net/ethernet/realtek/r8169.c).

Read errors are gone, even without syncing DMA. Is it a good idea to
do it anyway, i.e. leave calls to dma_sync_single_* in?

Also, without build_skb(), kmalloc memory can be used (frag_size > 0),
memory is used more efficiently, at least half of a page times 64
previously wasted.

New code here:
https://bitbucket.org/Kasreyn/linux-next/src/92f5aeb3b58f8d8dffd9178b6b5ff46217156caa/drivers/net/ethernet/moxa/moxart_ether.c#cl-424


Thanks,
Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: build_skb() and data corruption

2014-01-14 Thread Jonas Jensen
Thanks for the replies, you led me to a new solution,


I now think build_skb() is not the right choice, my motivation for
using it in the first place, that I thought it meant getting away with
not copying memory.

build_skb() is replaced by netdev_alloc_skb_ip_align() and memcpy()
(derived from drivers/net/ethernet/realtek/r8169.c).

Read errors are gone, even without syncing DMA. Is it a good idea to
do it anyway, i.e. leave calls to dma_sync_single_* in?

Also, without build_skb(), kmalloc memory can be used (frag_size  0),
memory is used more efficiently, at least half of a page times 64
previously wasted.

New code here:
https://bitbucket.org/Kasreyn/linux-next/src/92f5aeb3b58f8d8dffd9178b6b5ff46217156caa/drivers/net/ethernet/moxa/moxart_ether.c#cl-424


Thanks,
Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


build_skb() and data corruption

2014-01-13 Thread Jonas Jensen
Please help,

I think I see memory corruption with a driver recently added to linux-next.

The following error occur downloading a large file with wget (or
ncftp): "read error: Bad address"
wget exits and leaves the file unfinished.

The error goes away when build_skb() is patched out, in this case by
allocating pages directly in RX loop.

I currently have two branches with code placed under ifdef USE_BUILD_SKB:
https://bitbucket.org/Kasreyn/linux-next/src/faa7c408a655fdfd7c383f79259031da5a05d61e/drivers/net/ethernet/moxa/moxart_ether.c#cl-472

If build_skb() is the cause, is there something the driver can do about it?

A quick search on "build_skb memory corruption" reveals the following
commit, "igb: Revert support for build_skb in igb"
f9d40f6a9921cc7d9385f64362314054e22152bd:

"The reason for reverting this patch is that it can lead to data corruption.
The following flow was pointed out by Ben Hutchings:
1. skb is forwarded to another device
2. Packet headers are modified and it's put into a queue
3. Second packet is received into the other half of this page
4. Page cannot be reused, so is DMA-unmapped
5. The DMA mapping was non-coherent, so unmap copies or invalidates
cache
The headers added in step 2 get trashed in step 5."


This is extra interesting, errors only happen on a locally mounted
ext3 filesystem, never on tmpfs e.g.:

# mount
/dev/mmcblk0p1 on / type ext3
(rw,relatime,errors=continue,barrier=1,data=ordered)
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777)
tmpfs on /tmp type tmpfs (rw,relatime)

#cd /tmp
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.  25% |***| 11374k
0:01:36 ETAwget: short write
[  153.56] wget (383) used greatest stack depth: 4776 bytes left
# rm linux-2.6.11.11.tar.gz
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.  25% |***| 11315k
0:01:34 ETAwget: short write
# rm linux-2.6.11.11.tar.gz
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.  25% |***| 11473k
0:01:38 ETAwget: short write
[  237.30] wget (387) used greatest stack depth: 4752 bytes left

# cd /root/
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.   3% |*  |  1647k  0:03:02 ETA
wget: read error: Bad address


Regards,
Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


build_skb() and data corruption

2014-01-13 Thread Jonas Jensen
Please help,

I think I see memory corruption with a driver recently added to linux-next.

The following error occur downloading a large file with wget (or
ncftp): read error: Bad address
wget exits and leaves the file unfinished.

The error goes away when build_skb() is patched out, in this case by
allocating pages directly in RX loop.

I currently have two branches with code placed under ifdef USE_BUILD_SKB:
https://bitbucket.org/Kasreyn/linux-next/src/faa7c408a655fdfd7c383f79259031da5a05d61e/drivers/net/ethernet/moxa/moxart_ether.c#cl-472

If build_skb() is the cause, is there something the driver can do about it?

A quick search on build_skb memory corruption reveals the following
commit, igb: Revert support for build_skb in igb
f9d40f6a9921cc7d9385f64362314054e22152bd:

The reason for reverting this patch is that it can lead to data corruption.
The following flow was pointed out by Ben Hutchings:
1. skb is forwarded to another device
2. Packet headers are modified and it's put into a queue
3. Second packet is received into the other half of this page
4. Page cannot be reused, so is DMA-unmapped
5. The DMA mapping was non-coherent, so unmap copies or invalidates
cache
The headers added in step 2 get trashed in step 5.


This is extra interesting, errors only happen on a locally mounted
ext3 filesystem, never on tmpfs e.g.:

# mount
/dev/mmcblk0p1 on / type ext3
(rw,relatime,errors=continue,barrier=1,data=ordered)
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777)
tmpfs on /tmp type tmpfs (rw,relatime)

#cd /tmp
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.  25% |***| 11374k
0:01:36 ETAwget: short write
[  153.56] wget (383) used greatest stack depth: 4776 bytes left
# rm linux-2.6.11.11.tar.gz
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.  25% |***| 11315k
0:01:34 ETAwget: short write
# rm linux-2.6.11.11.tar.gz
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.  25% |***| 11473k
0:01:38 ETAwget: short write
[  237.30] wget (387) used greatest stack depth: 4752 bytes left

# cd /root/
# wget -c ftp://149.20.4.69/pub/linux/kernel/v2.6/linux-2.6.11.11.tar.gz
Connecting to 149.20.4.69 (149.20.4.69:21)
linux-2.6.11.11.tar.   3% |*  |  1647k  0:03:02 ETA
wget: read error: Bad address


Regards,
Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v6 2/2] ARM: mach-moxart: add MOXA ART SoC device tree files

2013-12-19 Thread Jonas Jensen
On 19 December 2013 00:41, Peter Crosthwaite
 wrote:
>> +   clocks {
>> +   #address-cells = <1>;
>> +   #size-cells = <0>;
>> +
>> +   ref12: ref12M {
>> +   compatible = "fixed-clock";
>
> Is the correct split to perhaps have the fixed-clock node in dtsi as
> you have here but ...
>
>> +   #clock-cells = <0>;
>> +   clock-frequency = <1200>;
>
> The board is responsible for the frequency?
>
> I guess in this schema,
>
> 1. the "fixed-clock" node corresponds to the existence of clock input
> pins on the SoC level - hence the node is DTSI.
> 2. setting the clock-frequency corresponds to populatation of those
> input pins with a soldered crystal - hence done in DTS

Yes, the soldered crystal belongs to board. Changes in v7 should reflect that.

I tried to doing what you said above, it didn't quite work, I got the
same error from of_clk_get() / of_clk_get_by_name(), but came up with
another solution please have a look at v7.

Thanks,
Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 2/2] ARM: mach-moxart: add MOXA ART SoC device tree files

2013-12-19 Thread Jonas Jensen
Add a generic (dtsi) include file for MOXA ART SoCs.

Also add a file for UC-7112-LX.

Signed-off-by: Jonas Jensen 
---
 Documentation/devicetree/bindings/arm/moxart.txt |  12 ++
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/moxart-uc7112lx.dts| 117 ++
 arch/arm/boot/dts/moxart.dtsi| 148 +++
 4 files changed, 278 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/moxart.txt
 create mode 100644 arch/arm/boot/dts/moxart-uc7112lx.dts
 create mode 100644 arch/arm/boot/dts/moxart.dtsi

diff --git a/Documentation/devicetree/bindings/arm/moxart.txt 
b/Documentation/devicetree/bindings/arm/moxart.txt
new file mode 100644
index 000..11087ed
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/moxart.txt
@@ -0,0 +1,12 @@
+MOXA ART device tree bindings
+
+Boards with the MOXA ART SoC shall have the following properties:
+
+Required root node property:
+
+compatible = "moxa,moxart";
+
+Boards:
+
+- UC-7112-LX: embedded computer
+  compatible = "moxa,moxart-uc-7112-lx", "moxa,moxart"
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 40e13e3..99a730f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -111,6 +111,7 @@ dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-cloudbox.dtb \
kirkwood-ts219-6281.dtb \
kirkwood-ts219-6282.dtb
 dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb
+dtb-$(CONFIG_ARCH_MOXART) += moxart-uc7112lx.dtb
 dtb-$(CONFIG_ARCH_MSM) += qcom-msm8660-surf.dtb \
qcom-msm8960-cdp.dtb
 dtb-$(CONFIG_ARCH_MVEBU) += armada-370-db.dtb \
diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
new file mode 100644
index 000..10d088d
--- /dev/null
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -0,0 +1,117 @@
+/* moxart-uc7112lx.dts - Device Tree file for MOXA UC-7112-LX
+ *
+ * Copyright (C) 2013 Jonas Jensen 
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+/dts-v1/;
+/include/ "moxart.dtsi"
+
+/ {
+   model = "MOXA UC-7112-LX";
+   compatible = "moxa,moxart-uc-7112-lx", "moxa,moxart";
+
+   memory {
+   device_type = "memory";
+   reg = <0x0 0x200>;
+   };
+
+   clocks {
+   ref12: ref12M {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1200>;
+   };
+   };
+
+   flash@8000,0 {
+   compatible = "numonyx,js28f128", "cfi-flash";
+   reg = <0x8000 0x100>;
+   bank-width = <2>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   label = "bootloader";
+   reg = <0x0 0x4>;
+   };
+   partition@4 {
+   label = "linux kernel";
+   reg = <0x4 0x1C>;
+   };
+   partition@20 {
+   label = "root filesystem";
+   reg = <0x20 0x80>;
+   };
+   partition@a0 {
+   label = "user filesystem";
+   reg = <0xa0 0x60>;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   user-led {
+   label = "ready-led";
+   gpios = < 27 0x1>;
+   default-state = "on";
+   linux,default-trigger = "default-on";
+   };
+   };
+
+   gpio_keys_polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <500>;
+   button@25 {
+   label = "GPIO Reset";
+   linux,code = <116>;
+   gpios = < 25 1>;
+   };
+   };
+
+   chosen {
+   bootargs = "console=ttyS0,115200n8 earlyprintk 
root=/dev/mmcblk0p1 rw rootwait";
+   };
+};
+
+_pll {
+   clocks = <>;
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+
+   ethphy0: ethernet-phy@1 {
+   device_type = "ethernet-phy";
+   compatible = "moxa,moxart-rtl8201cp", 
"ethernet-phy-ieee802.3-c22";
+   reg = <1>;
+   };
+};
+
+ {
+   status = "okay";
+
+   ethphy1: ethernet-phy@1 {
+   device_type = "ethernet-phy";
+   

[PATCH v7 1/2] ARM: mach-moxart: add MOXA ART SoC platform files

2013-12-19 Thread Jonas Jensen
The MOXA ART SoC is based on Faraday's FA526. This is a ARMv4 32-bit
192 MHz CPU with MMU and 16KB/8KB D/I-cache.

Add platform support for this SoC.

Also add UC-7112-LX as a machine.

Signed-off-by: Jonas Jensen 
---
 arch/arm/Kconfig  |   2 +
 arch/arm/Makefile |   1 +
 arch/arm/configs/moxart_defconfig | 149 ++
 arch/arm/mach-moxart/Kconfig  |  31 
 arch/arm/mach-moxart/Makefile |   3 +
 arch/arm/mach-moxart/moxart.c |  15 
 6 files changed, 201 insertions(+)
 create mode 100644 arch/arm/configs/moxart_defconfig
 create mode 100644 arch/arm/mach-moxart/Kconfig
 create mode 100644 arch/arm/mach-moxart/Makefile
 create mode 100644 arch/arm/mach-moxart/moxart.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a95e067..75f48fe 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -948,6 +948,8 @@ source "arch/arm/mach-kirkwood/Kconfig"
 
 source "arch/arm/mach-ks8695/Kconfig"
 
+source "arch/arm/mach-moxart/Kconfig"
+
 source "arch/arm/mach-msm/Kconfig"
 
 source "arch/arm/mach-mv78xx0/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index dfe2bc4..1a2f619 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -168,6 +168,7 @@ machine-$(CONFIG_ARCH_KIRKWOOD) += kirkwood
 machine-$(CONFIG_ARCH_KS8695)  += ks8695
 machine-$(CONFIG_ARCH_LPC32XX) += lpc32xx
 machine-$(CONFIG_ARCH_MMP) += mmp
+machine-$(CONFIG_ARCH_MOXART)  += moxart
 machine-$(CONFIG_ARCH_MSM) += msm
 machine-$(CONFIG_ARCH_MV78XX0) += mv78xx0
 machine-$(CONFIG_ARCH_MVEBU)   += mvebu
diff --git a/arch/arm/configs/moxart_defconfig 
b/arch/arm/configs/moxart_defconfig
new file mode 100644
index 000..a3cb76c
--- /dev/null
+++ b/arch/arm/configs/moxart_defconfig
@@ -0,0 +1,149 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_NO_HZ=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_SYSCTL_SYSCALL=y
+# CONFIG_ELF_CORE is not set
+# CONFIG_BASE_FULL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+CONFIG_EMBEDDED=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_ARCH_MULTI_V4T=y
+# CONFIG_ARCH_MULTI_V7 is not set
+CONFIG_KEYBOARD_GPIO_POLLED=y
+CONFIG_ARCH_MOXART=y
+CONFIG_MACH_UC7112LX=y
+CONFIG_PREEMPT=y
+CONFIG_AEABI=y
+# CONFIG_ATAGS is not set
+CONFIG_ARM_APPENDED_DTB=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_WIRELESS is not set
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_CFI=y
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_CFI_INTELEXT=y
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_PROC_DEVICETREE=y
+CONFIG_NETDEVICES=y
+CONFIG_NETCONSOLE=y
+CONFIG_NETCONSOLE_DYNAMIC=y
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+CONFIG_ARM_MOXART_ETHER=y
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_REALTEK_PHY=y
+CONFIG_MDIO_MOXART=y
+# CONFIG_WLAN is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+CONFIG_INPUT_EVDEV=y
+CONFIG_INPUT_EVBUG=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=1
+CONFIG_SERIAL_8250_RUNTIME_UARTS=1
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_OF_PLATFORM=y
+# CONFIG_HW_RANDOM is not set
+CONFIG_DEBUG_GPIO=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MOXART=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_GPIO=y
+# CONFIG_HWMON is not set
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_CORE=y
+CONFIG_WATCHDOG_NOWAYOUT=y
+CONFIG_MOXART_WDT=y
+# CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFI

[PATCH v7 0/2] ARM: mach-moxart: add MOXA ART SoC support

2013-12-19 Thread Jonas Jensen
The reason behind why fixed rate clock "ref12" couldn't be moved from
.dtsi to .dts:

There was nothing else in "clocks { .. }", the entire block was then
deleted from .dtsi.

If a skeleton "clocks { .. }" remain in .dtsi, the node can then be
moved to .dts, and of_clk_get() works again.

Changes since v6:

1. move fixed rate clock "ref12" from .dtsi to .dts
2. sort new entry alphabetically in arch/arm/Kconfig
3. rebase to next-20131219: arch/arm/Makefile arch/arm/Kconfig

Applies to next-20131219

Jonas Jensen (2):
  ARM: mach-moxart: add MOXA ART SoC platform files
  ARM: mach-moxart: add MOXA ART SoC device tree files

 Documentation/devicetree/bindings/arm/moxart.txt |  12 ++
 arch/arm/Kconfig |   2 +
 arch/arm/Makefile|   1 +
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/moxart-uc7112lx.dts| 117 ++
 arch/arm/boot/dts/moxart.dtsi| 148 ++
 arch/arm/configs/moxart_defconfig| 149 +++
 arch/arm/mach-moxart/Kconfig |  31 +
 arch/arm/mach-moxart/Makefile|   3 +
 arch/arm/mach-moxart/moxart.c|  15 +++
 10 files changed, 479 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/moxart.txt
 create mode 100644 arch/arm/boot/dts/moxart-uc7112lx.dts
 create mode 100644 arch/arm/boot/dts/moxart.dtsi
 create mode 100644 arch/arm/configs/moxart_defconfig
 create mode 100644 arch/arm/mach-moxart/Kconfig
 create mode 100644 arch/arm/mach-moxart/Makefile
 create mode 100644 arch/arm/mach-moxart/moxart.c

-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 1/2] ARM: mach-moxart: add MOXA ART SoC platform files

2013-12-19 Thread Jonas Jensen
The MOXA ART SoC is based on Faraday's FA526. This is a ARMv4 32-bit
192 MHz CPU with MMU and 16KB/8KB D/I-cache.

Add platform support for this SoC.

Also add UC-7112-LX as a machine.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---
 arch/arm/Kconfig  |   2 +
 arch/arm/Makefile |   1 +
 arch/arm/configs/moxart_defconfig | 149 ++
 arch/arm/mach-moxart/Kconfig  |  31 
 arch/arm/mach-moxart/Makefile |   3 +
 arch/arm/mach-moxart/moxart.c |  15 
 6 files changed, 201 insertions(+)
 create mode 100644 arch/arm/configs/moxart_defconfig
 create mode 100644 arch/arm/mach-moxart/Kconfig
 create mode 100644 arch/arm/mach-moxart/Makefile
 create mode 100644 arch/arm/mach-moxart/moxart.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a95e067..75f48fe 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -948,6 +948,8 @@ source arch/arm/mach-kirkwood/Kconfig
 
 source arch/arm/mach-ks8695/Kconfig
 
+source arch/arm/mach-moxart/Kconfig
+
 source arch/arm/mach-msm/Kconfig
 
 source arch/arm/mach-mv78xx0/Kconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index dfe2bc4..1a2f619 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -168,6 +168,7 @@ machine-$(CONFIG_ARCH_KIRKWOOD) += kirkwood
 machine-$(CONFIG_ARCH_KS8695)  += ks8695
 machine-$(CONFIG_ARCH_LPC32XX) += lpc32xx
 machine-$(CONFIG_ARCH_MMP) += mmp
+machine-$(CONFIG_ARCH_MOXART)  += moxart
 machine-$(CONFIG_ARCH_MSM) += msm
 machine-$(CONFIG_ARCH_MV78XX0) += mv78xx0
 machine-$(CONFIG_ARCH_MVEBU)   += mvebu
diff --git a/arch/arm/configs/moxart_defconfig 
b/arch/arm/configs/moxart_defconfig
new file mode 100644
index 000..a3cb76c
--- /dev/null
+++ b/arch/arm/configs/moxart_defconfig
@@ -0,0 +1,149 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_NO_HZ=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_SYSCTL_SYSCALL=y
+# CONFIG_ELF_CORE is not set
+# CONFIG_BASE_FULL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+CONFIG_EMBEDDED=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_ARCH_MULTI_V4T=y
+# CONFIG_ARCH_MULTI_V7 is not set
+CONFIG_KEYBOARD_GPIO_POLLED=y
+CONFIG_ARCH_MOXART=y
+CONFIG_MACH_UC7112LX=y
+CONFIG_PREEMPT=y
+CONFIG_AEABI=y
+# CONFIG_ATAGS is not set
+CONFIG_ARM_APPENDED_DTB=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_WIRELESS is not set
+CONFIG_UEVENT_HELPER_PATH=/sbin/hotplug
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_CFI=y
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_GEOMETRY=y
+CONFIG_MTD_CFI_INTELEXT=y
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_PROC_DEVICETREE=y
+CONFIG_NETDEVICES=y
+CONFIG_NETCONSOLE=y
+CONFIG_NETCONSOLE_DYNAMIC=y
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+CONFIG_ARM_MOXART_ETHER=y
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_REALTEK_PHY=y
+CONFIG_MDIO_MOXART=y
+# CONFIG_WLAN is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+CONFIG_INPUT_EVDEV=y
+CONFIG_INPUT_EVBUG=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=1
+CONFIG_SERIAL_8250_RUNTIME_UARTS=1
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_OF_PLATFORM=y
+# CONFIG_HW_RANDOM is not set
+CONFIG_DEBUG_GPIO=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MOXART=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_GPIO=y
+# CONFIG_HWMON is not set
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_CORE=y
+CONFIG_WATCHDOG_NOWAYOUT=y
+CONFIG_MOXART_WDT=y
+# CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI_MOXART=y
+CONFIG_NEW_LEDS=y

[PATCH v7 0/2] ARM: mach-moxart: add MOXA ART SoC support

2013-12-19 Thread Jonas Jensen
The reason behind why fixed rate clock ref12 couldn't be moved from
.dtsi to .dts:

There was nothing else in clocks { .. }, the entire block was then
deleted from .dtsi.

If a skeleton clocks { .. } remain in .dtsi, the node can then be
moved to .dts, and of_clk_get() works again.

Changes since v6:

1. move fixed rate clock ref12 from .dtsi to .dts
2. sort new entry alphabetically in arch/arm/Kconfig
3. rebase to next-20131219: arch/arm/Makefile arch/arm/Kconfig

Applies to next-20131219

Jonas Jensen (2):
  ARM: mach-moxart: add MOXA ART SoC platform files
  ARM: mach-moxart: add MOXA ART SoC device tree files

 Documentation/devicetree/bindings/arm/moxart.txt |  12 ++
 arch/arm/Kconfig |   2 +
 arch/arm/Makefile|   1 +
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/moxart-uc7112lx.dts| 117 ++
 arch/arm/boot/dts/moxart.dtsi| 148 ++
 arch/arm/configs/moxart_defconfig| 149 +++
 arch/arm/mach-moxart/Kconfig |  31 +
 arch/arm/mach-moxart/Makefile|   3 +
 arch/arm/mach-moxart/moxart.c|  15 +++
 10 files changed, 479 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/moxart.txt
 create mode 100644 arch/arm/boot/dts/moxart-uc7112lx.dts
 create mode 100644 arch/arm/boot/dts/moxart.dtsi
 create mode 100644 arch/arm/configs/moxart_defconfig
 create mode 100644 arch/arm/mach-moxart/Kconfig
 create mode 100644 arch/arm/mach-moxart/Makefile
 create mode 100644 arch/arm/mach-moxart/moxart.c

-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7 2/2] ARM: mach-moxart: add MOXA ART SoC device tree files

2013-12-19 Thread Jonas Jensen
Add a generic (dtsi) include file for MOXA ART SoCs.

Also add a file for UC-7112-LX.

Signed-off-by: Jonas Jensen jonas.jen...@gmail.com
---
 Documentation/devicetree/bindings/arm/moxart.txt |  12 ++
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/moxart-uc7112lx.dts| 117 ++
 arch/arm/boot/dts/moxart.dtsi| 148 +++
 4 files changed, 278 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/moxart.txt
 create mode 100644 arch/arm/boot/dts/moxart-uc7112lx.dts
 create mode 100644 arch/arm/boot/dts/moxart.dtsi

diff --git a/Documentation/devicetree/bindings/arm/moxart.txt 
b/Documentation/devicetree/bindings/arm/moxart.txt
new file mode 100644
index 000..11087ed
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/moxart.txt
@@ -0,0 +1,12 @@
+MOXA ART device tree bindings
+
+Boards with the MOXA ART SoC shall have the following properties:
+
+Required root node property:
+
+compatible = moxa,moxart;
+
+Boards:
+
+- UC-7112-LX: embedded computer
+  compatible = moxa,moxart-uc-7112-lx, moxa,moxart
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 40e13e3..99a730f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -111,6 +111,7 @@ dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-cloudbox.dtb \
kirkwood-ts219-6281.dtb \
kirkwood-ts219-6282.dtb
 dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb
+dtb-$(CONFIG_ARCH_MOXART) += moxart-uc7112lx.dtb
 dtb-$(CONFIG_ARCH_MSM) += qcom-msm8660-surf.dtb \
qcom-msm8960-cdp.dtb
 dtb-$(CONFIG_ARCH_MVEBU) += armada-370-db.dtb \
diff --git a/arch/arm/boot/dts/moxart-uc7112lx.dts 
b/arch/arm/boot/dts/moxart-uc7112lx.dts
new file mode 100644
index 000..10d088d
--- /dev/null
+++ b/arch/arm/boot/dts/moxart-uc7112lx.dts
@@ -0,0 +1,117 @@
+/* moxart-uc7112lx.dts - Device Tree file for MOXA UC-7112-LX
+ *
+ * Copyright (C) 2013 Jonas Jensen jonas.jen...@gmail.com
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+/dts-v1/;
+/include/ moxart.dtsi
+
+/ {
+   model = MOXA UC-7112-LX;
+   compatible = moxa,moxart-uc-7112-lx, moxa,moxart;
+
+   memory {
+   device_type = memory;
+   reg = 0x0 0x200;
+   };
+
+   clocks {
+   ref12: ref12M {
+   compatible = fixed-clock;
+   #clock-cells = 0;
+   clock-frequency = 1200;
+   };
+   };
+
+   flash@8000,0 {
+   compatible = numonyx,js28f128, cfi-flash;
+   reg = 0x8000 0x100;
+   bank-width = 2;
+   #address-cells = 1;
+   #size-cells = 1;
+   partition@0 {
+   label = bootloader;
+   reg = 0x0 0x4;
+   };
+   partition@4 {
+   label = linux kernel;
+   reg = 0x4 0x1C;
+   };
+   partition@20 {
+   label = root filesystem;
+   reg = 0x20 0x80;
+   };
+   partition@a0 {
+   label = user filesystem;
+   reg = 0xa0 0x60;
+   };
+   };
+
+   leds {
+   compatible = gpio-leds;
+   user-led {
+   label = ready-led;
+   gpios = gpio 27 0x1;
+   default-state = on;
+   linux,default-trigger = default-on;
+   };
+   };
+
+   gpio_keys_polled {
+   compatible = gpio-keys-polled;
+   #address-cells = 1;
+   #size-cells = 0;
+   poll-interval = 500;
+   button@25 {
+   label = GPIO Reset;
+   linux,code = 116;
+   gpios = gpio 25 1;
+   };
+   };
+
+   chosen {
+   bootargs = console=ttyS0,115200n8 earlyprintk 
root=/dev/mmcblk0p1 rw rootwait;
+   };
+};
+
+clk_pll {
+   clocks = ref12;
+};
+
+sdhci {
+   status = okay;
+};
+
+mdio0 {
+   status = okay;
+
+   ethphy0: ethernet-phy@1 {
+   device_type = ethernet-phy;
+   compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
+   reg = 1;
+   };
+};
+
+mdio1 {
+   status = okay;
+
+   ethphy1: ethernet-phy@1 {
+   device_type = ethernet-phy;
+   compatible = moxa,moxart-rtl8201cp, 
ethernet-phy-ieee802.3-c22;
+   reg = 1;
+   };
+};
+
+mac0 {
+   status = okay;
+};
+
+mac1 {
+   status = okay;
+};
+
+uart0 {
+   status = okay;
+};
diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
new file mode 100644
index 000..1fd27ed
--- /dev/null
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -0,0 +1,148

Re: [PATCH v6 2/2] ARM: mach-moxart: add MOXA ART SoC device tree files

2013-12-19 Thread Jonas Jensen
On 19 December 2013 00:41, Peter Crosthwaite
peter.crosthwa...@xilinx.com wrote:
 +   clocks {
 +   #address-cells = 1;
 +   #size-cells = 0;
 +
 +   ref12: ref12M {
 +   compatible = fixed-clock;

 Is the correct split to perhaps have the fixed-clock node in dtsi as
 you have here but ...

 +   #clock-cells = 0;
 +   clock-frequency = 1200;

 The board is responsible for the frequency?

 I guess in this schema,

 1. the fixed-clock node corresponds to the existence of clock input
 pins on the SoC level - hence the node is DTSI.
 2. setting the clock-frequency corresponds to populatation of those
 input pins with a soldered crystal - hence done in DTS

Yes, the soldered crystal belongs to board. Changes in v7 should reflect that.

I tried to doing what you said above, it didn't quite work, I got the
same error from of_clk_get() / of_clk_get_by_name(), but came up with
another solution please have a look at v7.

Thanks,
Jonas
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] watchdog: mach-moxart: add restart handler

2013-12-18 Thread Jonas Jensen
mach-moxart lacks a separate register for reset; as a workaround,
add a function that can be hooked to arm_pm_restart.

Signed-off-by: Jonas Jensen 
---

Notes:
During review of this driver, the restart handler for moxart was
removed, and moved to platform code under arch/arm/mach-moxart/.

Since then, new considerations arrived,
see replies from Arnd and Guenter:

"[PATCH v4 1/2] ARM: mach-moxart: add MOXA ART SoC platform files"

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-December/219175.html

I can move this to a new power/restart driver, but first, I want to
hear what Wim or others think.

Until there is a better solution, my motivation is that this uses
the watchdog. The way I see it, the problem is that there is no
separate register for reset, this was always a workaround for that.

Applies to next-20131218

 drivers/watchdog/moxart_wdt.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c
index 4166e4d..4aa3a8a 100644
--- a/drivers/watchdog/moxart_wdt.c
+++ b/drivers/watchdog/moxart_wdt.c
@@ -19,6 +19,8 @@
 #include 
 #include 
 
+#include 
+
 #define REG_COUNT  0x4
 #define REG_MODE   0x8
 #define REG_ENABLE 0xC
@@ -29,8 +31,17 @@ struct moxart_wdt_dev {
unsigned int clock_frequency;
 };
 
+static struct moxart_wdt_dev *moxart_restart_ctx;
+
 static int heartbeat;
 
+static void moxart_wdt_restart(enum reboot_mode reboot_mode, const char *cmd)
+{
+   writel(1, moxart_restart_ctx->base + REG_COUNT);
+   writel(0x5ab9, moxart_restart_ctx->base + REG_MODE);
+   writel(0x03, moxart_restart_ctx->base + REG_ENABLE);
+}
+
 static int moxart_wdt_stop(struct watchdog_device *wdt_dev)
 {
struct moxart_wdt_dev *moxart_wdt = watchdog_get_drvdata(wdt_dev);
@@ -125,6 +136,9 @@ static int moxart_wdt_probe(struct platform_device *pdev)
if (err)
return err;
 
+   moxart_restart_ctx = moxart_wdt;
+   arm_pm_restart = moxart_wdt_restart;
+
dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n",
moxart_wdt->dev.timeout, nowayout);
 
@@ -135,6 +149,7 @@ static int moxart_wdt_remove(struct platform_device *pdev)
 {
struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev);
 
+   arm_pm_restart = NULL;
moxart_wdt_stop(_wdt->dev);
watchdog_unregister_device(_wdt->dev);
 
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 2/2] ARM: mach-moxart: add MOXA ART SoC device tree files

2013-12-18 Thread Jonas Jensen
Thanks for the replies, changes should be in v6.

On 18 December 2013 00:29, Peter Crosthwaite
 wrote:
>> +   clocks {
>> +   #address-cells = <1>;
>> +   #size-cells = <0>;
>> +
>> +   ref12: ref12M {
>> +   compatible = "fixed-clock";
>> +   #clock-cells = <0>;
>> +   clock-frequency = <1200>;
>
> Crystal board level?

I couldn't move this due to fixed-clock load order.

See my comments in v6 cover letter:

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-December/220302.html


Thanks,
Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   >