[PATCH 09/27] staging: ks7010: delete seperate debug header

2016-05-10 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Move the one debug macro to the generic wlan header.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/staging/ks7010/ks7010_config.c |  1 -
 drivers/staging/ks7010/ks7010_sdio.c   |  1 -
 drivers/staging/ks7010/ks_debug.h  | 28 
 drivers/staging/ks7010/ks_hostif.c |  1 -
 drivers/staging/ks7010/ks_wlan.h   |  7 +++
 drivers/staging/ks7010/ks_wlan_net.c   |  1 -
 6 files changed, 7 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks_debug.h

diff --git a/drivers/staging/ks7010/ks7010_config.c 
b/drivers/staging/ks7010/ks7010_config.c
index abe99a52ae1ad8..7f273dafaf3583 100644
--- a/drivers/staging/ks7010/ks7010_config.c
+++ b/drivers/staging/ks7010/ks7010_config.c
@@ -4,7 +4,6 @@
 #include "ks_wlan.h"
 #include "ks_hostif.h"
 #include "ks_wlan_ioctl.h"
-#include "ks_debug.h"
 
 static int wep_on_off;
 #defineWEP_OFF 0
diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 1a1a43ff306aae..3fb432c9dd314d 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -19,7 +19,6 @@
 
 #include "ks_wlan.h"
 #include "ks_wlan_ioctl.h"
-#include "ks_debug.h"
 #include "ks_hostif.h"
 
 #include "ks7010_sdio.h"
diff --git a/drivers/staging/ks7010/ks_debug.h 
b/drivers/staging/ks7010/ks_debug.h
deleted file mode 100644
index adad5f927dfda9..00
--- a/drivers/staging/ks7010/ks_debug.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *   Driver for KeyStream 11b/g wireless LAN cards.
- *   
- *   ks_debug.h
- *   $Id: ks_debug.h 991 2009-09-14 01:38:58Z sekine $
- *
- *   Copyright (C) 2005-2008 KeyStream Corp.
- *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it undr the terms of the GNU General Public License version 2 as
- *   published by the Free Sotware Foundation.
- */
-
-#ifndef _KS_DEBUG_H
-#define _KS_DEBUG_H
-
-#include 
-
-
-#ifdef KS_WLAN_DEBUG
-#define DPRINTK(n, fmt, args...) \
- if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, 
__FUNCTION__, ## args)
-#else
-#define DPRINTK(n, fmt, args...)
-#endif
-
-#endif /* _KS_DEBUG_H */
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 146a1357909b39..367d487cef1ba8 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -13,7 +13,6 @@
  */
 
 #include "ks_wlan.h"
-#include "ks_debug.h"
 #include "ks_hostif.h"
 #include "eap_packet.h"
 #include "michael_mic.h"
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 6bd016414a4f1d..c460741c6606ee 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -38,6 +38,13 @@
 
 #include "ks7010_sdio.h"
 
+#ifdef KS_WLAN_DEBUG
+#define DPRINTK(n, fmt, args...) \
+ if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, 
__FUNCTION__, ## args)
+#else
+#define DPRINTK(n, fmt, args...)
+#endif
+
 struct ks_wlan_parameter {
uint8_t operation_mode;/* Operation Mode */
uint8_t channel;   /*  Channel */
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 776a544031495f..1da2768ea9f31b 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -40,7 +40,6 @@ static int wep_on_off;
 #include "ks_wlan.h"
 #include "ks_hostif.h"
 #include "ks_wlan_ioctl.h"
-#include "ks_debug.h"
 
 /* Include Wireless Extension definition and check version */
 #include 
-- 
2.8.1



[PATCH 11/27] staging: ks7010: make loading config file optional

2016-05-10 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

We have sane defaults, so we don't need to bail out if there is no
config file. Note that the config file should go away completely in
favour of configuration mechanisms already upstream.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/staging/ks7010/ks7010_config.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_config.c 
b/drivers/staging/ks7010/ks7010_config.c
index 7f273dafaf3583..06ff8852e17f33 100644
--- a/drivers/staging/ks7010/ks7010_config.c
+++ b/drivers/staging/ks7010/ks7010_config.c
@@ -203,7 +203,6 @@ int ks_wlan_read_config_file(ks_wlan_private *priv)
 
const struct firmware *fw_entry;
struct device *dev = NULL;
-   int retval;
char cfg_file[]=CFG_FILE;
char *cur_p, *end_p;
char wk_buff[256], *wk_p;
@@ -254,10 +253,9 @@ int ks_wlan_read_config_file(ks_wlan_private *priv)
priv->reg.rate_set.size = 12;
 
dev = >ks_wlan_hw.sdio_card->func->dev;
-   if((retval = request_firmware(_entry, cfg_file, dev)) !=0 ){
-   DPRINTK(1, "error request_firmware() file=%s ret=%d\n", 
cfg_file, retval);
-   return 1;
-   }
+   /* If no cfg file, stay with the defaults */
+   if (request_firmware_direct(_entry, cfg_file, dev))
+   return 0;
 
DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, 
fw_entry->size);
cur_p = fw_entry->data;
-- 
2.8.1



[PATCH 08/27] staging: ks7010: use kernel helper to print buffer

2016-05-10 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

No need for an open coded one.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/staging/ks7010/Makefile  |  2 +-
 drivers/staging/ks7010/ks7010_sdio.c |  9 +
 drivers/staging/ks7010/ks_debug.c| 30 --
 drivers/staging/ks7010/ks_debug.h|  2 --
 4 files changed, 6 insertions(+), 37 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks_debug.c

diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile
index 32b0efc7bd00e8..f6a2cc8fd0276d 100644
--- a/drivers/staging/ks7010/Makefile
+++ b/drivers/staging/ks7010/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_KS7010) += ks7010.o
 
 ccflags-y   += -DKS_WLAN_DEBUG=0
-ks7010-y:= michael_mic.o ks_hostif.o ks_wlan_net.o ks_debug.o \
+ks7010-y:= michael_mic.o ks_hostif.o ks_wlan_net.o \
ks7010_sdio.o ks7010_config.o
diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 5b78522fad1ec1..1a1a43ff306aae 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -441,10 +441,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
 
/* length check */
if(size > 2046 || size == 0){
-
-   DPRINTK(5,"-INVAILED DATA dump\n");
-   print_buffer(_buffer->data[0],32);
-
+#ifdef KS_WLAN_DEBUG
+   if (KS_WLAN_DEBUG > 5)
+   print_hex_dump_bytes("INVALID DATA dump: ", 
DUMP_PREFIX_OFFSET,
+rx_buffer->data, 32);
+#endif
/* rx_status update */
read_status = READ_STATUS_IDLE;
retval = ks7010_sdio_write(priv, READ_STATUS, _status, 
sizeof(read_status));
diff --git a/drivers/staging/ks7010/ks_debug.c 
b/drivers/staging/ks7010/ks_debug.c
deleted file mode 100644
index 009f5f6df8f4e6..00
--- a/drivers/staging/ks7010/ks_debug.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *   Driver for KeyStream 11b/g wireless LAN cards.
- *   
- *   ks_debug.c
- *   $Id: ks_debug.c 991 2009-09-14 01:38:58Z sekine $
- *
- *   Copyright (C) 2005-2008 KeyStream Corp.
- *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it undr the terms of the GNU General Public License version 2 as
- *   published by the Free Sotware Foundation.
- */
-#include "ks_wlan.h"
-#include "ks_debug.h"
-
-void print_buffer(unsigned char *p, int length)
-{
-#ifdef KS_WLAN_DEBUG
-int i;
-#define HEX_OFFSET "\
-   +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F"
-printk(HEX_OFFSET);
-for (i=0; i<length; i++) {
-if (i % 16 == 0) printk("\n%04X-%04X:", i, i+15);
-printk(" %02X", *(p+i));
-}
-printk("\n");
-#endif
-}
diff --git a/drivers/staging/ks7010/ks_debug.h 
b/drivers/staging/ks7010/ks_debug.h
index 2fd5d8484b7f04..adad5f927dfda9 100644
--- a/drivers/staging/ks7010/ks_debug.h
+++ b/drivers/staging/ks7010/ks_debug.h
@@ -25,6 +25,4 @@
 #define DPRINTK(n, fmt, args...)
 #endif
 
-extern void print_buffer(unsigned char *p, int size);
-
 #endif /* _KS_DEBUG_H */
-- 
2.8.1



[PATCH 12/27] staging: ks7010: fix printk format warnings

2016-05-10 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Use proper type for size_t.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/staging/ks7010/ks7010_config.c | 2 +-
 drivers/staging/ks7010/ks7010_sdio.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_config.c 
b/drivers/staging/ks7010/ks7010_config.c
index 06ff8852e17f33..4b00d25cd8f575 100644
--- a/drivers/staging/ks7010/ks7010_config.c
+++ b/drivers/staging/ks7010/ks7010_config.c
@@ -257,7 +257,7 @@ int ks_wlan_read_config_file(ks_wlan_private *priv)
if (request_firmware_direct(_entry, cfg_file, dev))
return 0;
 
-   DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, 
fw_entry->size);
+   DPRINTK(4, "success request_firmware() file=%s size=%zu\n", cfg_file, 
fw_entry->size);
cur_p = fw_entry->data;
end_p = cur_p + fw_entry->size;
*end_p = '\0';
diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 3fb432c9dd314d..50364909449aec 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -750,7 +750,7 @@ static int ks79xx_upload_firmware(ks_wlan_private *priv, 
struct ks_sdio_card *ca
DPRINTK(1,"error request_firmware() file=%s\n", 
priv->reg.rom_file);
return 1;
}
-   DPRINTK(4,"success request_firmware() file=%s size=%d\n", 
priv->reg.rom_file, fw_entry->size);
+   DPRINTK(4,"success request_firmware() file=%s size=%zu\n", 
priv->reg.rom_file, fw_entry->size);
length = fw_entry->size;
 
/* Load Program */
-- 
2.8.1



[PATCH 10/27] staging: ks7010: really iterate over multicast addresses

2016-05-10 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

The loop variable was defined but not really used. Fix this.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/staging/ks7010/ks_hostif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 367d487cef1ba8..b0a0a53d3a00bf 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2105,7 +2105,7 @@ void hostif_sme_multicast_set(ks_wlan_private *priv)
struct netdev_hw_addr *ha;
charset_address[NIC_MAX_MCAST_LIST*ETH_ALEN];
unsigned long filter_type;
-   int i;
+   int i = 0;
 
DPRINTK(3,"\n");
 
@@ -2128,6 +2128,7 @@ void hostif_sme_multicast_set(ks_wlan_private *priv)
mc_count = netdev_mc_count(dev);
netdev_for_each_mc_addr(ha, dev) {
memcpy(_address[i*ETH_ALEN], ha->addr, 
ETH_ALEN);
+   i++;
}
priv->sme_i.sme_flag &= ~SME_MULTICAST;
hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
-- 
2.8.1



Re: [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency

2016-04-15 Thread Wolfram Sang

> >   1. The SDHI/MMC clocks now run much slower than before. Perhaps this is
> >  intentional, and a consequence of finding the best way to drive the SD
> >  card at the target frequency?
> 
> I don't think is generally a problem.  Probably even saves a little
> power.

If you insert an SD card, frequencies should be back to normal. This
happens on Lager at least.

> 
> >   2. On r8a7740, the situation is worse: the HP ("High-speed Peripheral")
> >  clock is also scaled down from 99 MHz to 12.375 MHz.
> >  As the HP clock is the parent of lots of on-chip devices, this may 
> > affect
> >  performance for all of them.
> >
> > On r8a73a4, r8a7791, and sh73a0, the SDHI clocks are children of the 
> > pll1_div2
> > clocks, which are fixed.
> > On r8a7740, the SDHI and MMC clocks are children of the HP clock,
> > which is also scaled down, affecting all other siblings.
> [...]
> 
> That seems like a bug in the clock driver.  If it doesn't have
> independent dividers for each clock client then it shouldn't allow any
> client to change the frequency.

I tend to agree.

However, I just found out that we don't check the result of
clk_set_rate(). Probably something like this is missing?


diff --git a/drivers/mmc/host/sh_mobile_sdhi.c 
b/drivers/mmc/host/sh_mobile_sdhi.c
index 5923ce7e0fccb3..e51d7b01d39a3b 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -167,7 +167,7 @@ static unsigned int sh_mobile_sdhi_clk_update(struct 
tmio_mmc_host *host,
 {
struct sh_mobile_sdhi *priv = host_to_priv(host);
unsigned int freq, best_freq, diff_min, diff;
-   int i;
+   int i, ret;
 
diff_min = ~0;
best_freq = 0;
@@ -195,9 +195,9 @@ static unsigned int sh_mobile_sdhi_clk_update(struct 
tmio_mmc_host *host,
}
}
 
-   clk_set_rate(priv->clk, best_freq);
+   ret = clk_set_rate(priv->clk, best_freq);
 
-   return best_freq;
+   return ret == 0 ? best_freq : clk_get_rate(priv->clk);
 }
 
 static void sh_mobile_sdhi_clk_disable(struct tmio_mmc_host *host)



signature.asc
Description: PGP signature


Re: [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency

2016-04-15 Thread Wolfram Sang
> > That seems like a bug in the clock driver.  If it doesn't have
> > independent dividers for each clock client then it shouldn't allow any
> > client to change the frequency.

So, we need MSTP clocks which do not use CLK_SET_RATE_PARENT on r8a7740.
Probably the best way is to use the "renesas,r8a7740-mstp-clocks"
compatible entry to determine the difference? Geert?



signature.asc
Description: PGP signature


[RFC 2/2] ARM: shmobile: r8a7740: add "sd" clock and use it

2016-04-17 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Create the "sd" clock and connect the SDHI MSTP clocks to it. Those
shouldn't be connect to HP directly, because they shouldn't be allowed
to change the rate of the HP clock.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm/boot/dts/r8a7740.dtsi| 8 
 include/dt-bindings/clock/r8a7740-clock.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
index 39b2f88ad151e4..fefe99860edf69 100644
--- a/arch/arm/boot/dts/r8a7740.dtsi
+++ b/arch/arm/boot/dts/r8a7740.dtsi
@@ -474,7 +474,7 @@
 "usb24s",
 "i", "zg", "b", "m1", "hp",
 "hpp", "usbp", "s", "zb", "m3",
-"cp";
+"cp", "sd";
};
 
/* Variable factor clocks (DIV6) */
@@ -623,8 +623,8 @@
 <_clocks R8A7740_CLK_HP>,
 <_clk>,
 <_clocks R8A7740_CLK_HP>,
-<_clocks R8A7740_CLK_HP>,
-<_clocks R8A7740_CLK_HP>,
+<_clocks R8A7740_CLK_SD>,
+<_clocks R8A7740_CLK_SD>,
 <_clocks R8A7740_CLK_HP>,
 <_clocks R8A7740_CLK_HP>,
 <_clocks R8A7740_CLK_HP>;
@@ -642,7 +642,7 @@
compatible = "renesas,r8a7740-mstp-clocks", 
"renesas,cpg-mstp-clocks";
reg = <0xe6150140 4>, <0xe615004c 4>;
clocks = <_clocks R8A7740_CLK_HP>,
-<_clocks R8A7740_CLK_HP>,
+<_clocks R8A7740_CLK_SD>,
 <_clocks R8A7740_CLK_HP>,
 <_clocks R8A7740_CLK_HP>;
#clock-cells = <1>;
diff --git a/include/dt-bindings/clock/r8a7740-clock.h 
b/include/dt-bindings/clock/r8a7740-clock.h
index 476135da0f2388..ca34e5314c4378 100644
--- a/include/dt-bindings/clock/r8a7740-clock.h
+++ b/include/dt-bindings/clock/r8a7740-clock.h
@@ -28,6 +28,7 @@
 #define R8A7740_CLK_ZB 14
 #define R8A7740_CLK_M3 15
 #define R8A7740_CLK_CP 16
+#define R8A7740_CLK_SD 17
 
 /* MSTP1 */
 #define R8A7740_CLK_CEU21  28
-- 
2.7.0



[RFC 1/2] clk: renesas: r8a7740: add an "sd" clock

2016-04-17 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Create a virtual "sd" clock to feed the MSTP clocks for the SDHI cores.
MSTP clocks can change the rate of their parents which is undesired for
a generic clock as HP. So, add this static "sd" clock where the MSTP
clocks can safely connect to.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/clk/renesas/clk-r8a7740.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/renesas/clk-r8a7740.c 
b/drivers/clk/renesas/clk-r8a7740.c
index 2f7ce6696b6c0f..29834c3f22bdea 100644
--- a/drivers/clk/renesas/clk-r8a7740.c
+++ b/drivers/clk/renesas/clk-r8a7740.c
@@ -119,6 +119,8 @@ r8a7740_cpg_register_clock(struct device_node *np, struct 
r8a7740_cpg *cpg,
parent_name = "system";
if (!(value & BIT(6)))
div = 2;
+   } else if (!strcmp(name, "sd")) {
+   parent_name = "hp";
} else {
struct div4_clk *c;
for (c = div4_clks; c->name; c++) {
-- 
2.7.0



[RFC 0/2] r8a7740: fix SDHI clock handling

2016-04-17 Thread Wolfram Sang
Here is a less intrusive approach of handling the r8a7740 flaw when handling
SDHI clocks. Let me know what you think of it.

Not tested due to no hw!

Thanks,

   Wolfram


Wolfram Sang (2):
  clk: renesas: r8a7740: add an "sd" clock
  ARM: shmobile: r8a7740: add "sd" clock and use it

 arch/arm/boot/dts/r8a7740.dtsi| 8 
 drivers/clk/renesas/clk-r8a7740.c | 2 ++
 include/dt-bindings/clock/r8a7740-clock.h | 1 +
 3 files changed, 7 insertions(+), 4 deletions(-)

-- 
2.7.0



[PATCH] ARM: shmobile: r8a7790: fix max-frequency for SDHI

2016-04-17 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

The wrong values come from an old datasheet. Fix them.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm/boot/dts/r8a7790.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 1a3b6b08f1f3c9..e75baf369ccfb4 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -607,7 +607,7 @@
dmas = < 0xcd>, < 0xce>,
   < 0xcd>, < 0xce>;
dma-names = "tx", "rx", "tx", "rx";
-   max-frequency = <15600>;
+   max-frequency = <19500>;
power-domains = <_clocks>;
status = "disabled";
};
@@ -620,7 +620,7 @@
dmas = < 0xc9>, < 0xca>,
   < 0xc9>, < 0xca>;
dma-names = "tx", "rx", "tx", "rx";
-   max-frequency = <15600>;
+   max-frequency = <19500>;
power-domains = <_clocks>;
status = "disabled";
};
-- 
2.7.0



Re: [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency

2016-04-17 Thread Wolfram Sang
On Fri, Apr 15, 2016 at 10:41:57PM +0200, Wolfram Sang wrote:
> > > That seems like a bug in the clock driver.  If it doesn't have
> > > independent dividers for each clock client then it shouldn't allow any
> > > client to change the frequency.
> 
> So, we need MSTP clocks which do not use CLK_SET_RATE_PARENT on r8a7740.
> Probably the best way is to use the "renesas,r8a7740-mstp-clocks"
> compatible entry to determine the difference? Geert?

Well, I like the idea of a virtual sd clock even better. I sent a series
doing that a minute ago to the renesas-soc list.



signature.asc
Description: PGP signature


Re: [RFC 0/2] r8a7740: fix SDHI clock handling

2016-04-18 Thread Wolfram Sang

> Whether we want a clock to influence its parent is policy, not hardware
> description. So IMHO it doesn't belong in DT.

Yeah, I agree to that.

> IMHO it's more worthwhile to convert r8a7740 to use the CPG/MSSR driver.
> There it can be handled easily by adding a flag to the mssr_mod_clk structure.

I see. Yet, this sounds like a core group task, or? Is there time for
this? Maybe we can apply my "virtual sd" with a FIXME comment?



signature.asc
Description: PGP signature


[PATCH 1/5] mmc: tmio: give read32/write32 functions more descriptive names

2016-04-14 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Looking at the backlogs, I am not the only one who missed that the above
functions do not read u32 from one register, but create a virtual u32
from reading to adjacent u16 registers (which depending on 'bus_shift'
can be up to 8 byte apart). Because this driver supports old hardware
for which we don't have documentation, I first wrongly assumed there was
a variant which had a few u32 registers. Let's give the functions more
descriptive names to make it more obvious what is happening.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h |  5 ++---
 drivers/mmc/host/tmio_mmc_pio.c | 22 +++---
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 439fdad2bad91d..e75e5ca220bc0a 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -232,7 +232,7 @@ static inline void sd_ctrl_read16_rep(struct tmio_mmc_host 
*host, int addr,
readsw(host->ctl + (addr << host->bus_shift), buf, count);
 }
 
-static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr)
+static inline u32 sd_ctrl_read16_and_16_as_32(struct tmio_mmc_host *host, int 
addr)
 {
return readw(host->ctl + (addr << host->bus_shift)) |
   readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
@@ -254,11 +254,10 @@ static inline void sd_ctrl_write16_rep(struct 
tmio_mmc_host *host, int addr,
writesw(host->ctl + (addr << host->bus_shift), buf, count);
 }
 
-static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 
val)
+static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, 
int addr, u32 val)
 {
writew(val, host->ctl + (addr << host->bus_shift));
writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
 }
 
-
 #endif
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 15e6f6d5a42337..dad2ebd3dc22b4 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -55,18 +55,18 @@
 void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
 {
host->sdcard_irq_mask &= ~(i & TMIO_MASK_IRQ);
-   sd_ctrl_write32(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
+   sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
 }
 
 void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
 {
host->sdcard_irq_mask |= (i & TMIO_MASK_IRQ);
-   sd_ctrl_write32(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
+   sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
 }
 
 static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i)
 {
-   sd_ctrl_write32(host, CTL_STATUS, ~i);
+   sd_ctrl_write32_as_16_and_16(host, CTL_STATUS, ~i);
 }
 
 static void tmio_mmc_init_sg(struct tmio_mmc_host *host, struct mmc_data *data)
@@ -381,7 +381,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host 
*host, struct mmc_command
tmio_mmc_enable_mmc_irqs(host, irq_mask);
 
/* Fire off the command */
-   sd_ctrl_write32(host, CTL_ARG_REG, cmd->arg);
+   sd_ctrl_write32_as_16_and_16(host, CTL_ARG_REG, cmd->arg);
sd_ctrl_write16(host, CTL_SD_CMD, c);
 
return 0;
@@ -536,7 +536,7 @@ static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
goto out;
 
if (host->chan_tx && (data->flags & MMC_DATA_WRITE) && 
!host->force_pio) {
-   u32 status = sd_ctrl_read32(host, CTL_STATUS);
+   u32 status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS);
bool done = false;
 
/*
@@ -591,7 +591,7 @@ static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
 */
 
for (i = 3, addr = CTL_RESPONSE ; i >= 0 ; i--, addr += 4)
-   cmd->resp[i] = sd_ctrl_read32(host, addr);
+   cmd->resp[i] = sd_ctrl_read16_and_16_as_32(host, addr);
 
if (cmd->flags &  MMC_RSP_136) {
cmd->resp[0] = (cmd->resp[0] << 8) | (cmd->resp[1] >> 24);
@@ -708,14 +708,14 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
struct tmio_mmc_host *host = devid;
unsigned int ireg, status;
 
-   status = sd_ctrl_read32(host, CTL_STATUS);
+   status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS);
ireg = status & TMIO_MASK_IRQ & ~host->sdcard_irq_mask;
 
pr_debug_status(status);
pr_debug_status(ireg);
 
/* Clear the status except the interrupt status */
-   sd_ctrl_write32(host, CTL_STATUS, TMIO_MASK_IRQ);
+   sd_ctrl_write32_as_16_and_16(host, CTL_STATUS, TMIO_MASK_IRQ);
 
if (__tmio_mmc_card_detect_irq(host, ireg, status))

[PATCH 2/5] mmc: tmio: use BIT() within defines

2016-04-14 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

BIT() makes it easier to match the bits to the datasheet. This is
especially important here, since some variants have different names in
their datasheets (like with Renesas R-Car).

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 44 +++-
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index e75e5ca220bc0a..74945c1a66ce81 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -49,27 +49,29 @@
 #define CTL_RESET_SDIO 0x1e0
 
 /* Definitions for values the CTRL_STATUS register can take. */
-#define TMIO_STAT_CMDRESPEND0x0001
-#define TMIO_STAT_DATAEND   0x0004
-#define TMIO_STAT_CARD_REMOVE   0x0008
-#define TMIO_STAT_CARD_INSERT   0x0010
-#define TMIO_STAT_SIGSTATE  0x0020
-#define TMIO_STAT_WRPROTECT 0x0080
-#define TMIO_STAT_CARD_REMOVE_A 0x0100
-#define TMIO_STAT_CARD_INSERT_A 0x0200
-#define TMIO_STAT_SIGSTATE_A0x0400
-#define TMIO_STAT_CMD_IDX_ERR   0x0001
-#define TMIO_STAT_CRCFAIL   0x0002
-#define TMIO_STAT_STOPBIT_ERR   0x0004
-#define TMIO_STAT_DATATIMEOUT   0x0008
-#define TMIO_STAT_RXOVERFLOW0x0010
-#define TMIO_STAT_TXUNDERRUN0x0020
-#define TMIO_STAT_CMDTIMEOUT0x0040
-#define TMIO_STAT_RXRDY 0x0100
-#define TMIO_STAT_TXRQ  0x0200
-#define TMIO_STAT_ILL_FUNC  0x2000
-#define TMIO_STAT_CMD_BUSY  0x4000
-#define TMIO_STAT_ILL_ACCESS0x8000
+#define TMIO_STAT_CMDRESPENDBIT(0)
+#define TMIO_STAT_DATAEND   BIT(2)
+#define TMIO_STAT_CARD_REMOVE   BIT(3)
+#define TMIO_STAT_CARD_INSERT   BIT(4)
+#define TMIO_STAT_SIGSTATE  BIT(5)
+#define TMIO_STAT_WRPROTECT BIT(7)
+#define TMIO_STAT_CARD_REMOVE_A BIT(8)
+#define TMIO_STAT_CARD_INSERT_A BIT(9)
+#define TMIO_STAT_SIGSTATE_ABIT(10)
+
+/* These belong technically to CTRL_STATUS2, but the driver merges them */
+#define TMIO_STAT_CMD_IDX_ERR   BIT(16)
+#define TMIO_STAT_CRCFAIL   BIT(17)
+#define TMIO_STAT_STOPBIT_ERR   BIT(18)
+#define TMIO_STAT_DATATIMEOUT   BIT(19)
+#define TMIO_STAT_RXOVERFLOWBIT(20)
+#define TMIO_STAT_TXUNDERRUNBIT(21)
+#define TMIO_STAT_CMDTIMEOUTBIT(22)
+#define TMIO_STAT_RXRDY BIT(24)
+#define TMIO_STAT_TXRQ  BIT(25)
+#define TMIO_STAT_ILL_FUNC  BIT(29)
+#define TMIO_STAT_CMD_BUSY  BIT(30)
+#define TMIO_STAT_ILL_ACCESSBIT(31)
 
 #define TMIO_STATUS2_DAT0  BIT(7)
 
-- 
2.7.0



[PATCH 5/5] mmc: tmio: document CTL_STATUS handling

2016-04-14 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Now that reading CTL_STATUS is consistent, we can remove CTL_STATUS2 and
document how this is handled internally.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 8dd5ea4be0a371..1aac2ad8edf265 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -30,8 +30,9 @@
 #define CTL_STOP_INTERNAL_ACTION 0x08
 #define CTL_XFER_BLK_COUNT 0xa
 #define CTL_RESPONSE 0x0c
+/* driver merges STATUS and following STATUS2 */
 #define CTL_STATUS 0x1c
-#define CTL_STATUS2 0x1e
+/* driver merges IRQ_MASK and following IRQ_MASK2 */
 #define CTL_IRQ_MASK 0x20
 #define CTL_SD_CARD_CLK_CTL 0x24
 #define CTL_SD_XFER_LEN 0x26
-- 
2.7.0



[PATCH 4/5] mmc: tmio/sdhi: distinguish between SCLKDIVEN and ILL_FUNC

2016-04-14 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

This bit has a different meaning in SDHI and original TMIO. Document
that and use the proper naming.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 3 ++-
 drivers/mmc/host/tmio_mmc.h   | 3 ++-
 drivers/mmc/host/tmio_mmc_pio.c   | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c 
b/drivers/mmc/host/sh_mobile_sdhi.c
index b85b87eb55009f..5923ce7e0fccb3 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -244,7 +244,8 @@ static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host 
*host)
 {
int timeout = 1000;
 
-   while (--timeout && !(sd_ctrl_read16(host, CTL_STATUS2) & (1 << 13)))
+   while (--timeout && !(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS)
+ & TMIO_STAT_SCLKDIVEN))
udelay(1);
 
if (!timeout) {
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 55f251fdb78623..8dd5ea4be0a371 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -70,7 +70,8 @@
 #define TMIO_STAT_DAT0 BIT(23) /* only known on R-Car so far */
 #define TMIO_STAT_RXRDY BIT(24)
 #define TMIO_STAT_TXRQ  BIT(25)
-#define TMIO_STAT_ILL_FUNC  BIT(29)
+#define TMIO_STAT_ILL_FUNC  BIT(29) /* only when !TMIO_MMC_HAS_IDLE_WAIT */
+#define TMIO_STAT_SCLKDIVEN BIT(29) /* only when TMIO_MMC_HAS_IDLE_WAIT */
 #define TMIO_STAT_CMD_BUSY  BIT(30)
 #define TMIO_STAT_ILL_ACCESSBIT(31)
 
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index f4d8b5a741a875..e9b0271a81742a 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -548,7 +548,7 @@ static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
 * waiting for one more interrupt fixes the problem.
 */
if (host->pdata->flags & TMIO_MMC_HAS_IDLE_WAIT) {
-   if (status & TMIO_STAT_ILL_FUNC)
+   if (status & TMIO_STAT_SCLKDIVEN)
done = true;
} else {
if (!(status & TMIO_STAT_CMD_BUSY))
-- 
2.7.0



[PATCH 3/5] mmc: tmio: use CTL_STATUS consistently

2016-04-14 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

To prevent confusion, use the virtual u32 CTL_STATUS in card_busy() the
same way as in other parts of this driver.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 3 +--
 drivers/mmc/host/tmio_mmc_pio.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 74945c1a66ce81..55f251fdb78623 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -67,14 +67,13 @@
 #define TMIO_STAT_RXOVERFLOWBIT(20)
 #define TMIO_STAT_TXUNDERRUNBIT(21)
 #define TMIO_STAT_CMDTIMEOUTBIT(22)
+#define TMIO_STAT_DAT0 BIT(23) /* only known on R-Car so far */
 #define TMIO_STAT_RXRDY BIT(24)
 #define TMIO_STAT_TXRQ  BIT(25)
 #define TMIO_STAT_ILL_FUNC  BIT(29)
 #define TMIO_STAT_CMD_BUSY  BIT(30)
 #define TMIO_STAT_ILL_ACCESSBIT(31)
 
-#define TMIO_STATUS2_DAT0  BIT(7)
-
 #defineCLK_CTL_DIV_MASK0xff
 #defineCLK_CTL_SCLKEN  BIT(8)
 
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index dad2ebd3dc22b4..f4d8b5a741a875 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -983,7 +983,7 @@ static int tmio_mmc_card_busy(struct mmc_host *mmc)
 {
struct tmio_mmc_host *host = mmc_priv(mmc);
 
-   return !(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS2) & 
TMIO_STATUS2_DAT0);
+   return !(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & 
TMIO_STAT_DAT0);
 }
 
 static struct mmc_host_ops tmio_mmc_ops = {
-- 
2.7.0



[PATCH 0/5] mmc: tmio: make CTL_STATUS handling consistent

2016-04-14 Thread Wolfram Sang
It took me a little to discover that CTL_STATUS has a different handling than
the other registers. CTL_STATUS and CTL_STATUS2, both u16, are merged into a
virtual u32. However, CTL_STATUS2 was also directly accessed.

Clean this up, make this consistent, and document this. Making the driver less
complex and easier to work with.

Tested on Renesas R-Car Gen2 and Gen3. It is on top of my not-yet applied
series "[PATCH 0/6] mmc: tmio/sdhi: clean up cruft". A complete branch is here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/sdhi-uhs

   Wolfram

Wolfram Sang (5):
  mmc: tmio: give read32/write32 functions more descriptive names
  mmc: tmio: use BIT() within defines
  mmc: tmio: use CTL_STATUS consistently
  mmc: tmio/sdhi: distinguish between SCLKDIVEN and ILL_FUNC
  mmc: tmio: document CTL_STATUS handling

 drivers/mmc/host/sh_mobile_sdhi.c |  3 ++-
 drivers/mmc/host/tmio_mmc.h   | 56 ---
 drivers/mmc/host/tmio_mmc_pio.c   | 24 -
 3 files changed, 43 insertions(+), 40 deletions(-)

-- 
2.7.0



Re: [RFC 0/2] r8a7740: fix SDHI clock handling

2016-04-18 Thread Wolfram Sang

> Hence I think it should be handled in the driver.

I knew it ;)

If we change the MSTP driver, we should do it in a generic way. MSTP
clocks which should/should not change the parent's clock rate can be
anywhere. My best bet so far would be encoding this in DT, because all
the heuristics I could think of seem too fragile to me. That's because I
assume in a clock tree, anything is possible.

Changing DTs having MSTP clocks is quite intrusive, though...



signature.asc
Description: PGP signature


Re: [RFC 0/2] r8a7740: fix SDHI clock handling

2016-04-18 Thread Wolfram Sang

> Can you please give more detail about this r8a7740 issue? Just
> "r8a7740 flaw" does not make me understand.

Ah, sorry. This RFC series was merely meant as a "right direction?"
series for Geert, thus the short CC list. The full series will have
better documentation.

The flaw is: On r8a7740, the MSTP clocks for SDHI have HP directly as
their parent. With my updates, SDHI driver changes clock rates. HP clock
shouldn't be changed since other IP cores are connected to it. So, this
solution puts a fixed-factor (1:1) "sd" clock between HP and SDHI MSTP.



signature.asc
Description: PGP signature


[PATCH] mmc: sdio: fall back to SDIO 1.0 for broken 1.1 cards

2016-05-09 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

I have two SDIO WLAN cards which specify being SDIO Rev. 1.1 cards but
their FUNCE tuple reports the smaller size of a Rev 1.0 card. So,
enforce 1.0 on these cards to avoid reading the not present registers.
They are not really used anyhow. My cards initialize properly after this
patch.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/core/sdio_cis.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c
index 6f6fc527a26338..dcb3dee59fa5f2 100644
--- a/drivers/mmc/core/sdio_cis.c
+++ b/drivers/mmc/core/sdio_cis.c
@@ -177,8 +177,13 @@ static int cistpl_funce_func(struct mmc_card *card, struct 
sdio_func *func,
vsn = func->card->cccr.sdio_vsn;
min_size = (vsn == SDIO_SDIO_REV_1_00) ? 28 : 42;
 
-   if (size < min_size)
+   if (size == 28 && vsn == SDIO_SDIO_REV_1_10) {
+   pr_warn("%s: card has broken SDIO 1.1 CIS, forcing SDIO 1.0\n",
+   mmc_hostname(card->host));
+   vsn = SDIO_SDIO_REV_1_00;
+   } else if (size < min_size) {
return -EINVAL;
+   }
 
/* TPLFE_MAX_BLK_SIZE */
func->max_blksize = buf[12] | (buf[13] << 8);
-- 
2.7.0



[PATCH] MAINTAINERS: update entry for TMIO MMC driver

2016-05-09 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

I have some more additions planned for this driver, so I'd like to get
notified of other changes and coordinate them. Drop Ian as maintainer
because he hasn't been involved in development for a while. Thanks for
all the initial work, of course! Also, reflect the recent changes to
the include file layout.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
Cc: Ian Molton <i...@mnementh.co.uk>
---

Ian: If you'd like to stay involved, please speak up and I'll change my patch
accordingly.

 MAINTAINERS | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 42e65d128d015e..d22540c44b534b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11245,14 +11245,13 @@ S:Maintained
 F: drivers/media/i2c/tc358743*
 F: include/media/i2c/tc358743.h
 
-TMIO MMC DRIVER
-M: Ian Molton <i...@mnementh.co.uk>
+TMIO/SDHI MMC DRIVER
+M: Wolfram Sang <wsa+rene...@sang-engineering.com>
 L: linux-...@vger.kernel.org
-S: Maintained
+S: Supported
 F: drivers/mmc/host/tmio_mmc*
 F: drivers/mmc/host/sh_mobile_sdhi.c
-F: include/linux/mmc/tmio.h
-F: include/linux/mmc/sh_mobile_sdhi.h
+F: include/linux/mfd/tmio.h
 
 TMP401 HARDWARE MONITOR DRIVER
 M: Guenter Roeck <li...@roeck-us.net>
-- 
2.7.0



[PATCH] mmc: sh_mobile_sdhi: enable SDIO IRQs for RCar Gen3

2016-05-09 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Tested on a Salvator-X board with a Spectec SDW-823 WLAN card.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c 
b/drivers/mmc/host/sh_mobile_sdhi.c
index 5309c73be1f04f..f750f9494410b0 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -71,7 +71,7 @@ static const struct sh_mobile_sdhi_of_data 
of_rcar_gen2_compatible = {
 static const struct sh_mobile_sdhi_of_data of_rcar_gen3_compatible = {
.tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE |
  TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2,
-   .capabilities   = MMC_CAP_SD_HIGHSPEED,
+   .capabilities   = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
.bus_shift  = 2,
 };
 
-- 
2.7.0



[PATCH 5/7] watchdog: add pretimeout support to the core

2016-05-25 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Since the watchdog framework centrializes the IOCTL interfaces of device
drivers now, SETPRETIMEOUT and GETPRETIMEOUT need to be added in the
common code.

Signed-off-by: Robin Gong <b38...@freescale.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
Changes since Robin's last version:

* rebased
* 0 is valid and means disable pretimeout
  add code and docs for that
* add docs that drivers must update pretimeout when a new timeout is set
* reworded some documentation
* core handles wdd->pretimeout if set_pretimeout() is not populated
* add pretimeout to sysfs

 Documentation/watchdog/watchdog-kernel-api.txt | 20 ++
 drivers/watchdog/watchdog_dev.c| 53 +-
 include/linux/watchdog.h   | 11 ++
 3 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/Documentation/watchdog/watchdog-kernel-api.txt 
b/Documentation/watchdog/watchdog-kernel-api.txt
index a9a65f8c0de9f0..4d4e0db6750c5f 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -50,6 +50,7 @@ struct watchdog_device {
const struct watchdog_ops *ops;
unsigned int bootstatus;
unsigned int timeout;
+   unsigned int pretimeout;
unsigned int min_timeout;
unsigned int max_timeout;
unsigned int min_hw_heartbeat_ms;
@@ -77,6 +78,7 @@ It contains following fields:
 * timeout: the watchdog timer's timeout value (in seconds).
   This is the time after which the system will reboot if user space does
   not send a heartbeat request if WDOG_ACTIVE is set.
+* pretimeout: the watchdog timer's pretimeout value (in seconds).
 * min_timeout: the watchdog timer's minimum timeout value (in seconds).
   If set, the minimum configurable value for 'timeout'.
 * max_timeout: the watchdog timer's maximum timeout value (in seconds),
@@ -120,6 +122,7 @@ struct watchdog_ops {
int (*ping)(struct watchdog_device *);
unsigned int (*status)(struct watchdog_device *);
int (*set_timeout)(struct watchdog_device *, unsigned int);
+   int (*set_pretimeout)(struct watchdog_device *, unsigned int);
unsigned int (*get_timeleft)(struct watchdog_device *);
int (*restart)(struct watchdog_device *);
void (*ref)(struct watchdog_device *) __deprecated;
@@ -183,6 +186,23 @@ they are supported. These optional routines/operations are:
   set_timeout is not provided but WDIOF_SETTIMEOUT is set, the watchdog
   infrastructure updates the timeout value of the watchdog_device internally
   to the requested value.
+  If the pretimeout feature is used (WDIOF_PRETIMEOUT), then set_timeout must
+  also take care of checking if pretimeout is still valid and set up the timer
+  accordingly. This can't be done in the core without races, so it is the
+  duty of the driver.
+* set_pretimeout: this routine checks and changes the pretimeout value of
+  the watchdog. It is optional because not all watchdogs support pretimeout
+  notification. The timeout value is not an absolute time, but the number of
+  seconds before the actual timeout would happen. It returns 0 on success,
+  -EINVAL for "parameter out of range" and -EIO for "could not write value to
+  the watchdog". A value of 0 disables pretimeout notification.
+  (Note: the WDIOF_PRETIMEOUT needs to be set in the options field of the
+  watchdog's info structure).
+  If the watchdog driver does not have to perform any action but setting the
+  watchdog_device.pretimeout, this callback can be omitted. That means if
+  set_pretimeout is not provided but WDIOF_PRETIMEOUT is set, the watchdog
+  infrastructure updates the pretimeout value of the watchdog_device internally
+  to the requested value.
 * get_timeleft: this routines returns the time that's left before a reset.
 * restart: this routine restarts the machine. It returns 0 on success or a
   negative errno code for failure.
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 5d028f94a90743..ad9f4032f02d18 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -308,10 +308,14 @@ static int watchdog_set_timeout(struct watchdog_device 
*wdd,
if (watchdog_timeout_invalid(wdd, timeout))
return -EINVAL;
 
-   if (wdd->ops->set_timeout)
+   if (wdd->ops->set_timeout) {
err = wdd->ops->set_timeout(wdd, timeout);
-   else
+   } else {
wdd->timeout = timeout;
+   /* Disable pretimeout if it doesn't fit the new timeout */
+   if (wdd->pretimeout > wdd->timeout)
+   wdd->pretimeout = 0;
+   }
 
watchdog_update_worker(wdd);
 
@@ -319,6 +323,31 @@ static int watchdog_set_timeout(struct watchdog_device 
*wdd,
 }
 
 /*
+ * watchdog_set_preti

[PATCH 2/7] watchdog: pretimeout: add panic pretimeout governor

2016-05-25 Thread Wolfram Sang
From: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>

Panic watchdog pretimeout governor, on watchdog pretimeout event the
kernel shall panic.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
Changes since Vladimir's last version:

* rebased
* shortened the panic message a little (removed redundancy)

 drivers/watchdog/Kconfig   | 29 +
 drivers/watchdog/Makefile  |  2 ++
 drivers/watchdog/pretimeout_panic.c| 47 ++
 drivers/watchdog/watchdog_pretimeout.h |  6 -
 4 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 drivers/watchdog/pretimeout_panic.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 909d1021de5cbc..36b7d1f83b3c51 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1782,4 +1782,33 @@ config WATCHDOG_PRETIMEOUT_GOV
help
  The option allows to select watchdog pretimeout governors.
 
+if WATCHDOG_PRETIMEOUT_GOV
+
+choice
+   prompt "Default Watchdog Pretimeout Governor"
+   default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC
+   help
+ This option selects a default watchdog pretimeout governor.
+ The governor takes its action, if a watchdog is capable
+ to report a pretimeout event.
+
+config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC
+   bool "panic"
+   select WATCHDOG_PRETIMEOUT_GOV_PANIC
+   help
+ Use panic watchdog pretimeout governor by default, if
+ a watchdog pretimeout event happens, consider that
+ a watchdog feeder is dead and reboot is unavoidable.
+
+endchoice
+
+config WATCHDOG_PRETIMEOUT_GOV_PANIC
+   tristate "Panic watchdog pretimeout governor"
+   help
+ Select this option to enable panic watchdog pretimeout
+ governor, on a watchdog pretimeout event the kernel shall
+ panic before an expected system reboot.
+
+endif # WATCHDOG_PRETIMEOUT_GOV
+
 endif # WATCHDOG
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 820860cf3e8d62..56dfadc0cee2a9 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -8,6 +8,8 @@ obj-$(CONFIG_WATCHDOG_CORE) += watchdog.o
 watchdog-y += watchdog_core.o watchdog_dev.o
 watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o
 
+obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC) += pretimeout_panic.o
+
 # Only one watchdog can succeed. We probe the ISA/PCI/USB based
 # watchdog-cards first, then the architecture specific watchdog
 # drivers and then the architecture independent "softdog" driver.
diff --git a/drivers/watchdog/pretimeout_panic.c 
b/drivers/watchdog/pretimeout_panic.c
new file mode 100644
index 00..f8c2410d993f02
--- /dev/null
+++ b/drivers/watchdog/pretimeout_panic.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 Mentor Graphics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include 
+#include 
+
+#include "watchdog_pretimeout.h"
+
+/**
+ * pretimeout_panic - Panic on watchdog pretimeout event
+ * @wdd - watchdog_device
+ *
+ * Panic, watchdog has not been fed till pretimeout event.
+ */
+static void pretimeout_panic(struct watchdog_device *wdd)
+{
+   panic("watchdog pretimeout event");
+}
+
+static struct watchdog_governor watchdog_gov_panic = {
+   .name   = "panic",
+   .pretimeout = pretimeout_panic,
+   .owner  = THIS_MODULE,
+};
+
+static int __init watchdog_gov_panic_register(void)
+{
+   return watchdog_register_governor(_gov_panic);
+}
+module_init(watchdog_gov_panic_register);
+
+static void __exit watchdog_gov_panic_unregister(void)
+{
+   watchdog_unregister_governor(_gov_panic);
+}
+module_exit(watchdog_gov_panic_unregister);
+
+MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapols...@mentor.com>");
+MODULE_DESCRIPTION("Panic watchdog pretimeout governor");
+MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/watchdog_pretimeout.h 
b/drivers/watchdog/watchdog_pretimeout.h
index 38965cdd23bebe..8b03fd480cb533 100644
--- a/drivers/watchdog/watchdog_pretimeout.h
+++ b/drivers/watchdog/watchdog_pretimeout.h
@@ -19,7 +19,11 @@ void watchdog_unregister_governor(struct watchdog_governor 
*gov);
 /* Interfaces to watchdog_core.c */
 #ifdef CONFIG_WATCHDOG_PRETIMEOUT_GOV
 
-#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"none"
+#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
+#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"panic"
+#else
+#error "Default watchdog pretimeout governor is not set."
+#endif
 
 int watchdog_register_pretimeout(struct watchdog_device *wdd, struct device 
*dev);
 void watchdog_unregister_pretimeout(struct watchdog_device *wdd);
-- 
2.8.1



[PATCH 3/7] watchdog: pretimeout: add noop pretimeout governor

2016-05-25 Thread Wolfram Sang
From: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>

Noop watchdog pretimeout governor, only an informational message is
added to the kernel log buffer.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
Changes since Vladimir's last version:

* rebased
* use pr_* now since device pointer became private

 drivers/watchdog/Kconfig   | 15 +++
 drivers/watchdog/Makefile  |  1 +
 drivers/watchdog/pretimeout_noop.c | 47 ++
 drivers/watchdog/watchdog_pretimeout.h |  2 ++
 4 files changed, 65 insertions(+)
 create mode 100644 drivers/watchdog/pretimeout_noop.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 36b7d1f83b3c51..a3ef2bcd94f10c 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1800,6 +1800,14 @@ config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC
  a watchdog pretimeout event happens, consider that
  a watchdog feeder is dead and reboot is unavoidable.
 
+config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP
+   bool "noop"
+   select WATCHDOG_PRETIMEOUT_GOV_NOOP
+   help
+ Use noop watchdog pretimeout governor by default. If noop
+ governor is selected by a user, write a short message to
+ the kernel log buffer and don't do any system changes.
+
 endchoice
 
 config WATCHDOG_PRETIMEOUT_GOV_PANIC
@@ -1809,6 +1817,13 @@ config WATCHDOG_PRETIMEOUT_GOV_PANIC
  governor, on a watchdog pretimeout event the kernel shall
  panic before an expected system reboot.
 
+config WATCHDOG_PRETIMEOUT_GOV_NOOP
+   tristate "Noop watchdog pretimeout governor"
+   help
+ Select this option to enable noop watchdog pretimeout
+ governor, only an informational message is added to the
+ kernel log buffer, if watchdog pretimeout is happened.
+
 endif # WATCHDOG_PRETIMEOUT_GOV
 
 endif # WATCHDOG
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 56dfadc0cee2a9..3ad68029916e00 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -9,6 +9,7 @@ watchdog-y += watchdog_core.o watchdog_dev.o
 watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o
 
 obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC) += pretimeout_panic.o
+obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP) += pretimeout_noop.o
 
 # Only one watchdog can succeed. We probe the ISA/PCI/USB based
 # watchdog-cards first, then the architecture specific watchdog
diff --git a/drivers/watchdog/pretimeout_noop.c 
b/drivers/watchdog/pretimeout_noop.c
new file mode 100644
index 00..91f36aa533b398
--- /dev/null
+++ b/drivers/watchdog/pretimeout_noop.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 Mentor Graphics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include 
+#include 
+
+#include "watchdog_pretimeout.h"
+
+/**
+ * pretimeout_noop - No operation on watchdog pretimeout event
+ * @wdd - watchdog_device
+ *
+ * This function prints a message about pretimeout to kernel log.
+ */
+static void pretimeout_noop(struct watchdog_device *wdd)
+{
+   pr_info("watchdog%d: pretimeout event\n", wdd->id);
+}
+
+static struct watchdog_governor watchdog_gov_noop = {
+   .name   = "noop",
+   .pretimeout = pretimeout_noop,
+   .owner  = THIS_MODULE,
+};
+
+static int __init watchdog_gov_noop_register(void)
+{
+   return watchdog_register_governor(_gov_noop);
+}
+module_init(watchdog_gov_noop_register);
+
+static void __exit watchdog_gov_noop_unregister(void)
+{
+   watchdog_unregister_governor(_gov_noop);
+}
+module_exit(watchdog_gov_noop_unregister);
+
+MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapols...@mentor.com>");
+MODULE_DESCRIPTION("Noop watchdog pretimeout governor");
+MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/watchdog_pretimeout.h 
b/drivers/watchdog/watchdog_pretimeout.h
index 8b03fd480cb533..2e60450a2be64e 100644
--- a/drivers/watchdog/watchdog_pretimeout.h
+++ b/drivers/watchdog/watchdog_pretimeout.h
@@ -21,6 +21,8 @@ void watchdog_unregister_governor(struct watchdog_governor 
*gov);
 
 #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
 #define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"panic"
+#elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
+#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"noop"
 #else
 #error "Default watchdog pretimeout governor is not set."
 #endif
-- 
2.8.1



[PATCH 7/7] watchdog: softdog: implement pretimeout support

2016-05-25 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Give devices which do not have hardware support for pretimeout at least a
software version of it.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/watchdog/softdog.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index b067edf246dff2..adfb3899296f0f 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -72,10 +72,25 @@ static void softdog_fire(unsigned long data)
 static struct timer_list softdog_ticktock =
TIMER_INITIALIZER(softdog_fire, 0, 0);
 
+static struct watchdog_device softdog_dev;
+
+static void softdog_pretimeout(unsigned long data)
+{
+   watchdog_notify_pretimeout(_dev);
+}
+
+static struct timer_list softdog_preticktock =
+   TIMER_INITIALIZER(softdog_pretimeout, 0, 0);
+
 static int softdog_ping(struct watchdog_device *w)
 {
if (!mod_timer(_ticktock, jiffies + (w->timeout * HZ)))
__module_get(THIS_MODULE);
+
+   if (w->pretimeout)
+   mod_timer(_preticktock, jiffies +
+ (w->timeout - w->pretimeout) * HZ);
+
return 0;
 }
 
@@ -84,12 +99,15 @@ static int softdog_stop(struct watchdog_device *w)
if (del_timer(_ticktock))
module_put(THIS_MODULE);
 
+   del_timer(_preticktock);
+
return 0;
 }
 
 static struct watchdog_info softdog_info = {
.identity = "Software Watchdog",
-   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE |
+  WDIOF_PRETIMEOUT,
 };
 
 static struct watchdog_ops softdog_ops = {
-- 
2.8.1



[RFC 0/2] watchdog: pretimeout: userspace governor

2016-05-25 Thread Wolfram Sang
So, here is the RFC series implementing the userspace governor. This is merely
meant as a proof-of-concept, so my patch series will have the same capabilities
as Vladimir's series. It does work (for me (tm)) and shows how the bottom half
handling can be better put to the watchdog device code, making the pretimeout
code a lot simpler.

However, I am not sure if a uevent on the watchdog device is a good userspace
notification. Setting the governor is done vis sysfs, okay. But setting the
pretimeout is done via the character device, so I wonder if the response
shouldn't go there as well? But do we want to introduce select/poll support
only for pretimeouts?

Other ideas?

Thanks,

   Wolfram

Vladimir Zapolskiy (1):
  watchdog: pretimeout: add userspace notifier pretimeout governor

Wolfram Sang (1):
  watchdog: dev: add helper for creating uevent on dev

 drivers/watchdog/Kconfig| 16 +++
 drivers/watchdog/Makefile   |  1 +
 drivers/watchdog/pretimeout_userspace.c | 47 +
 drivers/watchdog/watchdog_dev.c | 20 ++
 drivers/watchdog/watchdog_pretimeout.h  |  2 ++
 include/linux/watchdog.h|  3 +++
 6 files changed, 89 insertions(+)
 create mode 100644 drivers/watchdog/pretimeout_userspace.c

-- 
2.8.1



[PATCH 1/7] watchdog: add watchdog pretimeout framework

2016-05-25 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

The change adds a simple watchdog pretimeout framework infrastructure,
its purpose is to allow users to select a desired handling of watchdog
pretimeout events, which may be generated by a watchdog driver.

By design every watchdog pretimeout governor may be compiled as a
kernel module, a user selects a default watchdog pretimeout
governor during compilation stage and can select another governor in
runtime.

Watchdogs with WDIOF_PRETIMEOUT capability now have two device
attributes in sysfs: read/write pretimeout_governor attribute and read
only pretimeout_available_governors attribute.

Watchdogs with no WDIOF_PRETIMEOUT capability has no changes in
sysfs.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---

Changes since Vladimir's last version:

* rebased
  adapt to the internal data reorganization, especially the now private
  struct device *dev
* dropped can_sleep support!
  The additional lock, list, and workqueue made the code quite complex. The
  only user was the userspace governor which can be reworked to let the
  watchdog device code do the bottom half. In addition, I am not fully
  convinced sending a uevent is the proper thing to do, but this needs to
  be discussed in another thread. Removing this support makes the code much
  easier to follow (locking!), saves 30% of LoC + a list + a workqueue.
* moved pretimeout registration from watchdog_core to watchdog_dev
  Let's handle it exactly where the device is created, so we have access to
  the now private device pointer for adding the sysfs files.
* don't export watchdog_(un)register_pretimeout since they are linked to the
  core anyhow
* whitespace cleanups

 drivers/watchdog/Kconfig   |   8 +
 drivers/watchdog/Makefile  |   6 +-
 drivers/watchdog/watchdog_dev.c|   8 +
 drivers/watchdog/watchdog_pretimeout.c | 269 +
 drivers/watchdog/watchdog_pretimeout.h |  35 +
 include/linux/watchdog.h   |  10 ++
 6 files changed, 334 insertions(+), 2 deletions(-)
 create mode 100644 drivers/watchdog/watchdog_pretimeout.c
 create mode 100644 drivers/watchdog/watchdog_pretimeout.h

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 3902c9ca7f099d..909d1021de5cbc 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1774,4 +1774,12 @@ config USBPCWATCHDOG
 
  Most people will say N.
 
+comment "Watchdog Pretimeout Governors"
+
+config WATCHDOG_PRETIMEOUT_GOV
+   bool "Enable watchdog pretimeout governors"
+   default n
+   help
+ The option allows to select watchdog pretimeout governors.
+
 endif # WATCHDOG
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 2cbc9709852d0e..820860cf3e8d62 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -3,8 +3,10 @@
 #
 
 # The WatchDog Timer Driver Core.
-watchdog-objs  += watchdog_core.o watchdog_dev.o
-obj-$(CONFIG_WATCHDOG_CORE)+= watchdog.o
+obj-$(CONFIG_WATCHDOG_CORE) += watchdog.o
+
+watchdog-y += watchdog_core.o watchdog_dev.o
+watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o
 
 # Only one watchdog can succeed. We probe the ISA/PCI/USB based
 # watchdog-cards first, then the architecture specific watchdog
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 3595cffa24ea49..5d028f94a90743 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -49,6 +49,7 @@
 #include  /* For copy_to_user/put_user/... */
 
 #include "watchdog_core.h"
+#include "watchdog_pretimeout.h"
 
 /*
  * struct watchdog_core_data - watchdog core internal data
@@ -911,6 +912,12 @@ int watchdog_dev_register(struct watchdog_device *wdd)
return PTR_ERR(dev);
}
 
+   ret = watchdog_register_pretimeout(wdd, dev);
+   if (ret) {
+   device_destroy(_class, devno);
+   watchdog_cdev_unregister(wdd);
+   }
+
return ret;
 }
 
@@ -924,6 +931,7 @@ int watchdog_dev_register(struct watchdog_device *wdd)
 
 void watchdog_dev_unregister(struct watchdog_device *wdd)
 {
+   watchdog_unregister_pretimeout(wdd);
device_destroy(_class, wdd->wd_data->cdev.dev);
watchdog_cdev_unregister(wdd);
 }
diff --git a/drivers/watchdog/watchdog_pretimeout.c 
b/drivers/watchdog/watchdog_pretimeout.c
new file mode 100644
index 00..87a10ebeaacc7e
--- /dev/null
+++ b/drivers/watchdog/watchdog_pretimeout.c
@@ -0,0 +1,269 @@
+/*
+ * Watchdog pretimout governor framework
+ *
+ * Copyright (C) 2015 Mentor Graphics
+ * Copyright (C) 2016 Renesas Electronics Corporation
+ * Copyright (C) 2016 Sang Engineering, Wolfram Sang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * i

[RFC 1/2] watchdog: dev: add helper for creating uevent on dev

2016-05-25 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Mechanisms like pretimeout governors may want to notify userspace via
uevents. Add a helper because all the needed data is private to the
watchdog device. To allow calling it in atomic contexts, put actual
signalling to a workqueue.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/watchdog/watchdog_dev.c | 20 
 include/linux/watchdog.h|  3 +++
 2 files changed, 23 insertions(+)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 9e2e668e1c6b2d..2a7d04034641dc 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -63,6 +63,7 @@ struct watchdog_core_data {
struct kref kref;
struct cdev cdev;
struct watchdog_device *wdd;
+   struct device *dev;
struct mutex lock;
unsigned long last_keepalive;
unsigned long last_hw_keepalive;
@@ -70,6 +71,7 @@ struct watchdog_core_data {
unsigned long status;   /* Internal status bits */
 #define _WDOG_DEV_OPEN 0   /* Opened ? */
 #define _WDOG_ALLOW_RELEASE1   /* Did we receive the magic char ? */
+   struct work_struct uevent_work;
 };
 
 /* the dev_t structure to store the dynamically allocated watchdog devices */
@@ -821,6 +823,21 @@ static struct miscdevice watchdog_miscdev = {
.fops   = _fops,
 };
 
+void watchdog_dev_uevent(struct watchdog_device *wdd)
+{
+   queue_work(watchdog_wq, >wd_data->uevent_work);
+}
+
+static void watchdog_dev_uevent_work(struct work_struct *work)
+{
+   struct watchdog_core_data *wd_data = container_of(work, struct 
watchdog_core_data,
+ uevent_work);
+
+   mutex_lock(_data->lock);
+   kobject_uevent(_data->dev->kobj, KOBJ_CHANGE);
+   mutex_unlock(_data->lock);
+}
+
 /*
  * watchdog_cdev_register: register watchdog character device
  * @wdd: watchdog device
@@ -849,6 +866,7 @@ static int watchdog_cdev_register(struct watchdog_device 
*wdd, dev_t devno)
return -ENODEV;
 
INIT_DELAYED_WORK(_data->work, watchdog_ping_work);
+   INIT_WORK(_data->uevent_work, watchdog_dev_uevent_work);
 
if (wdd->id == 0) {
old_wd_data = wd_data;
@@ -968,6 +986,8 @@ int watchdog_dev_register(struct watchdog_device *wdd)
watchdog_cdev_unregister(wdd);
}
 
+   wdd->wd_data->dev = dev;
+
return ret;
 }
 
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 496e52e5b91fc7..f0f77f06d9813b 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -194,6 +194,9 @@ extern int watchdog_init_timeout(struct watchdog_device 
*wdd,
 extern int watchdog_register_device(struct watchdog_device *);
 extern void watchdog_unregister_device(struct watchdog_device *);
 
+/* drivers/watchdog/watchdog_dev.c */
+void watchdog_dev_uevent(struct watchdog_device *wdd);
+
 /* drivers/watchdog/watchdog_pretimeout.c */
 #ifdef CONFIG_WATCHDOG_PRETIMEOUT_GOV
 void watchdog_notify_pretimeout(struct watchdog_device *wdd);
-- 
2.8.1



[RFC 2/2] watchdog: pretimeout: add userspace notifier pretimeout governor

2016-05-25 Thread Wolfram Sang
From: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>

Userspace notifier watchdog pretimeout governor, on watchdog
pretimeout event sends a notification to userspace for further
handling.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapols...@mentor.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/watchdog/Kconfig| 16 +++
 drivers/watchdog/Makefile   |  1 +
 drivers/watchdog/pretimeout_userspace.c | 47 +
 drivers/watchdog/watchdog_pretimeout.h  |  2 ++
 4 files changed, 66 insertions(+)
 create mode 100644 drivers/watchdog/pretimeout_userspace.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 3682ae9d8a50ca..e69c17f518ef43 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1800,6 +1800,15 @@ config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP
  governor is selected by a user, write a short message to
  the kernel log buffer and don't do any system changes.
 
+config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_USERSPACE
+   bool "userspace"
+   select WATCHDOG_PRETIMEOUT_GOV_USERSPACE
+   help
+ Use userspace watchdog pretimeout governor by default,
+ the governor sends a device state change uevent
+ notification, if a pretimeout event a reported by a
+ watchdog.
+
 endchoice
 
 config WATCHDOG_PRETIMEOUT_GOV_PANIC
@@ -1816,6 +1825,13 @@ config WATCHDOG_PRETIMEOUT_GOV_NOOP
  governor, only an informational message is added to the
  kernel log buffer, if watchdog pretimeout is happened.
 
+config WATCHDOG_PRETIMEOUT_GOV_USERSPACE
+   tristate "Userspace notifier watchdog pretimeout governor"
+   help
+ Userspace notifier watchdog pretimeout governor, on watchdog
+ pretimeout event send a notification to userspace for
+ further handling.
+
 endif # WATCHDOG_PRETIMEOUT_GOV
 
 endif # WATCHDOG
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 9330e4cabd8f9c..23423b8b73620c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -10,6 +10,7 @@ watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += 
watchdog_pretimeout.o
 
 obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC) += pretimeout_panic.o
 obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP) += pretimeout_noop.o
+obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_USERSPACE) += pretimeout_userspace.o
 
 # Only one watchdog can succeed. We probe the ISA/PCI/USB based
 # watchdog-cards first, then the architecture specific watchdog
diff --git a/drivers/watchdog/pretimeout_userspace.c 
b/drivers/watchdog/pretimeout_userspace.c
new file mode 100644
index 00..cf7b03765f3254
--- /dev/null
+++ b/drivers/watchdog/pretimeout_userspace.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 Mentor Graphics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include 
+#include 
+
+#include "watchdog_pretimeout.h"
+
+/**
+ * pretimeout_userspace - Notify userspace on watchdog pretimeout event
+ * @wdd - watchdog_device
+ *
+ * Send watchdog device uevent to userspace to handle pretimeout event
+ */
+static void pretimeout_userspace(struct watchdog_device *wdd)
+{
+   watchdog_dev_uevent(wdd);
+}
+
+static struct watchdog_governor watchdog_gov_userspace = {
+   .name   = "userspace",
+   .pretimeout = pretimeout_userspace,
+   .owner  = THIS_MODULE,
+};
+
+static int __init watchdog_gov_userspace_register(void)
+{
+   return watchdog_register_governor(_gov_userspace);
+}
+module_init(watchdog_gov_userspace_register);
+
+static void __exit watchdog_gov_userspace_unregister(void)
+{
+   watchdog_unregister_governor(_gov_userspace);
+}
+module_exit(watchdog_gov_userspace_unregister);
+
+MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapols...@mentor.com>");
+MODULE_DESCRIPTION("Userspace notifier watchdog pretimeout governor");
+MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/watchdog_pretimeout.h 
b/drivers/watchdog/watchdog_pretimeout.h
index 2e60450a2be64e..8365cd78f2507b 100644
--- a/drivers/watchdog/watchdog_pretimeout.h
+++ b/drivers/watchdog/watchdog_pretimeout.h
@@ -23,6 +23,8 @@ void watchdog_unregister_governor(struct watchdog_governor 
*gov);
 #define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"panic"
 #elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP)
 #define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"noop"
+#elif IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_USERSPACE)
+#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV"userspace"
 #else
 #error "Default watchdog pretimeout governor is not set."
 #endif
-- 
2.8.1



Re: [PATCH v4 0/4] UHS-I SDR-104 support for sh_mobile_sdhi

2016-08-10 Thread Wolfram Sang
Hi Simon,

> In this patchset I have attempted to address all review received
> for the v3 patch-set. I also believe that I have resolved a problem
> where tuning would timeout under some circumstances: this seems to
> have been due to several bugs introduced between v1 and v3.

So, you didn't see timeouts anymore?

> * Currently I am seeing speeds of up to 48MB/s with these patches and
>   30MB/s without using a SanDisk Extreme Pro 8Gb microSDHC UHS-1 card.
> 
> * I am also seeing 45MB/s with these patches and 34MB/s without using
>   a SanDisk Ultra 64Gb microSDXC UHS-1 card.

I got similar numbers for my SanDisk and Samsung cards. While the SDR104
speed is not that what I hoped for, it is still an improvement over
SDR50. We are currently investigating if DMA causes a bottleneck
somewhere perhaps. Except for a minor comment, I'd think these patches
are good to go in and we could improve incrementally from here:

Tested-by: Wolfram Sang <wsa+rene...@sang-engineering.com>

Maybe Ulf can have another high-level view on those. I guess he is more
experienced with the tuning stuff?

Thanks,

   Wolfram



Re: [PATCH] i2c: mux: demux-pinctrl: properly roll back when adding adapter fails

2016-08-14 Thread Wolfram Sang
On Fri, Aug 12, 2016 at 06:40:23PM +0200, Wolfram Sang wrote:
> We also need to revert the dynamic OF change, so we get a consistent
> state again. Otherwise, we might have two devices enabled e.g. after
> pinctrl setup fails.
> 
> Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>

Applied to for-current, thanks!



signature.asc
Description: PGP signature


Re: [PATCH v4 2/4] mmc: tmio: Add tuning support

2016-08-10 Thread Wolfram Sang
> +static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
> +{
> + struct tmio_mmc_host *host = mmc_priv(mmc);
> + unsigned int num;
> + int i, ret = 0;
> + bool *tap;
> +
> + if (!host->init_tuning || !host->select_tuning)

Check host->prepare_tuning, too?

> + /* Tuning is not supported */
> + goto out;
> +
> + num = host->init_tuning(host);
> + if (!num)
> + /* Tuning is not supported */
> + goto out;
> +
> + tap = kmalloc(num * 2 * sizeof(*tap), GFP_KERNEL);
> + if (!tap) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + /* Issue CMD19 twice for each tap */
> + for (i = 0; i < 2 * num; i++) {
> + if (host->prepare_tuning)
> + host->prepare_tuning(host, i % num);
> +
> + ret = mmc_send_tuning(mmc, opcode, NULL);
> + if (ret && ret != -EILSEQ)
> + goto err_free;
> + tap[i] = (ret != 0);
> +
> + mdelay(1);
> + }
> +
> + ret = host->select_tuning(host, tap, num * 2);
> +
> +err_free:
> + kfree(tap);
> +out:
> + if (ret < 0) {
> + dev_warn(>pdev->dev, "Tuning procedure failed\n");
> + tmio_mmc_hw_reset(mmc);
> + } else {
> + host->mmc->retune_period = 0;
> + }
> +
> + return ret;
> +

Unnecessary blank line



[PATCH] i2c: mux: demux-pinctrl: properly roll back when adding adapter fails

2016-08-12 Thread Wolfram Sang
We also need to revert the dynamic OF change, so we get a consistent
state again. Otherwise, we might have two devices enabled e.g. after
pinctrl setup fails.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c 
b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index 8de073aed00148..215ac87f606d2d 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -68,7 +68,7 @@ static int i2c_demux_activate_master(struct 
i2c_demux_pinctrl_priv *priv, u32 ne
adap = of_find_i2c_adapter_by_node(priv->chan[new_chan].parent_np);
if (!adap) {
ret = -ENODEV;
-   goto err;
+   goto err_with_revert;
}
 
p = devm_pinctrl_get_select(adap->dev.parent, priv->bus_name);
@@ -103,6 +103,8 @@ static int i2c_demux_activate_master(struct 
i2c_demux_pinctrl_priv *priv, u32 ne
 
  err_with_put:
i2c_put_adapter(adap);
+ err_with_revert:
+   of_changeset_revert(>chan[new_chan].chgset);
  err:
dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, 
ret);
return ret;
-- 
2.8.1



Re: [RFC] ARM: shmobile: allow non-SMP builds again

2016-08-12 Thread Wolfram Sang

> Wasn't this fixed by
> 
> Commit: 869ec056fa8450184423c8076e0a342db127795c

Ooops, yes. Sorry, overlooked this new 'if' after rebasing from rc1 to
rd/master :(



signature.asc
Description: PGP signature


[PATCH 1/2] ARM: shmobile: r8a7790: only use smp_init when SMP is selected

2016-08-12 Thread Wolfram Sang
We use the helper function which populates the smp_init pointer only in
case of SMP.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm/mach-shmobile/setup-r8a7790.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c 
b/arch/arm/mach-shmobile/setup-r8a7790.c
index 3506327e0bed24..78d3e859bd64ad 100644
--- a/arch/arm/mach-shmobile/setup-r8a7790.c
+++ b/arch/arm/mach-shmobile/setup-r8a7790.c
@@ -28,7 +28,7 @@ static const char * const r8a7790_boards_compat_dt[] 
__initconst = {
 };
 
 DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
-   .smp_init   = shmobile_smp_init_fallback_ops,
+   .smp_init   = smp_init_ops(shmobile_smp_init_fallback_ops),
.smp= smp_ops(r8a7790_smp_ops),
.init_early = shmobile_init_delay,
.init_time  = rcar_gen2_timer_init,
-- 
2.8.1



[PATCH 2/2] ARM: shmobile: r8a7791: only use smp_init when SMP is selected

2016-08-12 Thread Wolfram Sang
We use the helper function which populates the smp_init pointer only in
case of SMP.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm/mach-shmobile/setup-r8a7791.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c 
b/arch/arm/mach-shmobile/setup-r8a7791.c
index 110e8b588e563f..26e2d181a1904d 100644
--- a/arch/arm/mach-shmobile/setup-r8a7791.c
+++ b/arch/arm/mach-shmobile/setup-r8a7791.c
@@ -29,7 +29,7 @@ static const char *const r8a7791_boards_compat_dt[] 
__initconst = {
 };
 
 DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
-   .smp_init   = shmobile_smp_init_fallback_ops,
+   .smp_init   = smp_init_ops(shmobile_smp_init_fallback_ops),
.smp= smp_ops(r8a7791_smp_ops),
.init_early = shmobile_init_delay,
.init_time  = rcar_gen2_timer_init,
-- 
2.8.1



[RFC] ARM: shmobile: allow non-SMP builds again

2016-08-12 Thread Wolfram Sang
platform_can_secondary_boot() is only available for SMP, so guard the smp_init
function with some ifdeffery to allow building without SMP.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---

This is the easiest solution, but I wonder if it is the proper one? It might
make sense to modify the Makefile so platsmp.o is in smp-y and not cpu-y? I may
be missing here something, though.

I needed !SMP for debugging purposes, obviously.

 arch/arm/mach-shmobile/platsmp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-shmobile/platsmp.c b/arch/arm/mach-shmobile/platsmp.c
index 02e21bceb0856b..d286e3ff6f6a5a 100644
--- a/arch/arm/mach-shmobile/platsmp.c
+++ b/arch/arm/mach-shmobile/platsmp.c
@@ -37,6 +37,7 @@ bool shmobile_smp_cpu_can_disable(unsigned int cpu)
 }
 #endif
 
+#ifdef CONFIG_SMP
 bool __init shmobile_smp_init_fallback_ops(void)
 {
/* fallback on PSCI/smp_ops if no other DT based method is detected */
@@ -45,3 +46,4 @@ bool __init shmobile_smp_init_fallback_ops(void)
 
return platform_can_secondary_boot() ? true : false;
 }
+#endif
-- 
2.8.1



Re: [PATCH v2] ARM: dts: r8a7794: Correct SDHI register size

2016-07-21 Thread Wolfram Sang
On Thu, Jul 21, 2016 at 08:44:08AM +0900, Simon Horman wrote:
> r8a7794 SDHI ch0 has SD_DMACR which is located in 0x324.
> This patch updates register size
> 
> Based on work for the r8a7790 by Kuninori Morimoto.
> 
> Cc: Kuninori Morimoto <kuninori.morimoto...@renesas.com>
> Signed-off-by: Simon Horman <horms+rene...@verge.net.au>

Reviewed-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



signature.asc
Description: PGP signature


Re: [PATCH] clk: renesas: r8a7795: Fix SD clocks

2016-07-21 Thread Wolfram Sang
On Wed, Jul 20, 2016 at 02:06:24PM +0200, Wolfram Sang wrote:
> 
> > Wolfram, Dirk: any comments?
> 
> Looks proper.
> 
> Reviewed-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
> 
> I couldn't really test it, though, since I still have problems with the
> Gen3 DMA series.

... which are gone now since this series landed in renesas-drivers.
Dunno why but DMA works now, so I can see Shimoda-san's patch makes a
difference if we apply a missing fix which I will send in a second. Long
story short:

Tested-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



[PATCH] arm64: dts: r8a7795: set maximum frequency for SDHI clocks

2016-07-21 Thread Wolfram Sang
From: Wolfram Sang <wsa+rene...@sang-engineering.com>

Define the upper limit otherwise the driver cannot utilize max speeds.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 80af0ba68750f3..9e70dbf32a 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1249,6 +1249,7 @@
reg = <0 0xee10 0 0x2000>;
interrupts = ;
clocks = < CPG_MOD 314>;
+   max-frequency = <2>;
power-domains = < R8A7795_PD_ALWAYS_ON>;
status = "disabled";
};
@@ -1258,6 +1259,7 @@
reg = <0 0xee12 0 0x2000>;
interrupts = ;
clocks = < CPG_MOD 313>;
+   max-frequency = <2>;
power-domains = < R8A7795_PD_ALWAYS_ON>;
status = "disabled";
};
@@ -1267,6 +1269,7 @@
reg = <0 0xee14 0 0x2000>;
interrupts = ;
clocks = < CPG_MOD 312>;
+   max-frequency = <2>;
power-domains = < R8A7795_PD_ALWAYS_ON>;
cap-mmc-highspeed;
status = "disabled";
@@ -1277,6 +1280,7 @@
reg = <0 0xee16 0 0x2000>;
interrupts = ;
clocks = < CPG_MOD 311>;
+   max-frequency = <2>;
power-domains = < R8A7795_PD_ALWAYS_ON>;
cap-mmc-highspeed;
status = "disabled";
-- 
2.8.1



Re: [PATCH] ARM: shmobile: r8a7794: tidyup SDHI register size on DTSI

2016-07-20 Thread Wolfram Sang

> - reg = <0 0xee10 0 0x200>;
> + reg = <0 0xee10 0 0x384>;

All other r8a779x.dtsi have 0x328 there.



signature.asc
Description: PGP signature


Re: [PATCH] clk: renesas: r8a7795: Fix SD clocks

2016-07-20 Thread Wolfram Sang

> Wolfram, Dirk: any comments?

Looks proper.

Reviewed-by: Wolfram Sang <wsa+rene...@sang-engineering.com>

I couldn't really test it, though, since I still have problems with the
Gen3 DMA series.



signature.asc
Description: PGP signature


Re: [PATCH/RFC 0/4] mmc: renesas_sdhi: add R-Car Gen-3 DMA support

2016-06-27 Thread Wolfram Sang

> git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git 
> topic/sdhi-gen3-dma

Strange, with this branch and the attached config, the driver fails to
register to the driver core?? Reverting this series, the driver gets
registered (and probed) again.

#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 4.7.0-rc2 Kernel Configuration
#
CONFIG_ARM64=y
CONFIG_64BIT=y
CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
CONFIG_MMU=y
CONFIG_ARM64_PAGE_SHIFT=12
CONFIG_ARM64_CONT_SHIFT=4
CONFIG_ARCH_MMAP_RND_BITS_MIN=18
CONFIG_ARCH_MMAP_RND_BITS_MAX=24
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
CONFIG_NO_IOPORT_MAP=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_ILLEGAL_POINTER_VALUE=0xdead
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_SUPPORT=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CSUM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ZONE_DMA=y
CONFIG_HAVE_GENERIC_RCU_GUP=y
CONFIG_ARCH_DMA_ADDR_T_64BIT=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_SMP=y
CONFIG_SWIOTLB=y
CONFIG_IOMMU_HELPER=y
CONFIG_KERNEL_MODE_NEON=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=3
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_FHANDLE=y
CONFIG_USELIB=y
CONFIG_AUDIT=y
CONFIG_HAVE_ARCH_AUDITSYSCALL=y
CONFIG_AUDITSYSCALL=y
CONFIG_AUDIT_WATCH=y
CONFIG_AUDIT_TREE=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
CONFIG_GENERIC_IRQ_MIGRATION=y
CONFIG_HARDIRQS_SW_RESEND=y
CONFIG_GENERIC_IRQ_CHIP=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_HIERARCHY=y
CONFIG_HANDLE_DOMAIN_IRQ=y
# CONFIG_IRQ_DOMAIN_DEBUG is not set
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_ARCH_HAS_TICK_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ_FULL is not set
# CONFIG_NO_HZ is not set
CONFIG_HIGH_RES_TIMERS=y

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
# CONFIG_IRQ_TIME_ACCOUNTING is not set
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y

#
# RCU Subsystem
#
CONFIG_PREEMPT_RCU=y
# CONFIG_RCU_EXPERT is not set
CONFIG_SRCU=y
# CONFIG_TASKS_RCU is not set
CONFIG_RCU_STALL_COMMON=y
# CONFIG_TREE_RCU_TRACE is not set
# CONFIG_RCU_EXPEDITE_BOOT is not set
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=14
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_GENERIC_SCHED_CLOCK=y
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
CONFIG_CGROUPS=y
CONFIG_PAGE_COUNTER=y
CONFIG_MEMCG=y
CONFIG_MEMCG_SWAP=y
CONFIG_MEMCG_SWAP_ENABLED=y
# CONFIG_BLK_CGROUP is not set
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
# CONFIG_CFS_BANDWIDTH is not set
# CONFIG_RT_GROUP_SCHED is not set
# CONFIG_CGROUP_PIDS is not set
# CONFIG_CGROUP_FREEZER is not set
CONFIG_CGROUP_HUGETLB=y
# CONFIG_CPUSETS is not set
# CONFIG_CGROUP_DEVICE is not set
# CONFIG_CGROUP_CPUACCT is not set
# CONFIG_CGROUP_PERF is not set
# CONFIG_CGROUP_DEBUG is not set
# CONFIG_CHECKPOINT_RESTORE is not set
CONFIG_NAMESPACES=y
# CONFIG_UTS_NS is not set
# CONFIG_IPC_NS is not set
# CONFIG_USER_NS is not set
CONFIG_PID_NS=y
# CONFIG_NET_NS is not set
CONFIG_SCHED_AUTOGROUP=y
# CONFIG_SYSFS_DEPRECATED is not set
# CONFIG_RELAY is not set
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="rootfs-wlan-20160507.cpio.xz"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
# CONFIG_RD_GZIP is not set
# CONFIG_RD_BZIP2 is not set
# CONFIG_RD_LZMA is not set
CONFIG_RD_XZ=y
# CONFIG_RD_LZO is not set
# CONFIG_RD_LZ4 is not set
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_SYSCTL=y
CONFIG_ANON_INODES=y
CONFIG_HAVE_UID16=y
CONFIG_SYSCTL_EXCEPTION_TRACE=y
CONFIG_BPF=y
# CONFIG_EXPERT is not set
CONFIG_UID16=y
CONFIG_MULTIUSER=y
# CONFIG_SGETMASK_SYSCALL is not set
CONFIG_SYSFS_SYSCALL=y
# CONFIG_SYSCTL_SYSCALL is not set
CONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y
# CONFIG_KALLSYMS_ABSOLUTE_PERCPU is not set
CONFIG_KALLSYMS_BASE_RELATIVE=y
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_SIGNALFD=y
CONFIG_TIMERFD=y
CONFIG_EVENTFD=y
# CONFIG_BPF_SYSCALL is not set
CONFIG_SHMEM=y
CONFIG_AIO=y
CONFIG_ADVISE_SYSCALLS=y
# CONFIG_USERFAULTFD is not set

Re: [PATCH 3/3] arm64: dts: r8a7795: salvator: enable UHS for SDHI 0 & 3

2016-06-29 Thread Wolfram Sang

> Could you kindly share the recent status of the MMC support for RCar3? Esp.
> the eMMC support on the Salvator-X? From time to time I get this question
> from several people ;)

Nothing changed since last time. Meaning that it could work in 4-bit
mode (haven't tested it, though, and am on the road right now), it
probably won't with 8-bit.



signature.asc
Description: PGP signature


Re: [PATCH v2 3/9] mmc: tmio: Add UHS-I mode support

2016-08-16 Thread Wolfram Sang

> The first SDHI channel (ee10.sd) doesn't seem to be affected
> by the problem.

Hmm, I sadly don't have any docs about 73a4 and/or its SDHI variants.
I'll ask around.



signature.asc
Description: PGP signature


Re: [PATCH 00/11] media: rcar-vin: fix OPS and format/pad index issues

2017-02-07 Thread Wolfram Sang

> Patch 10-11 fix a OPS when unbinding/binding the video source subdevice.

I can happily confirm that this series finally makes the I2C demuxer
work on the I2C bus with the HDMI clients because rebinding works now!
Note that I didn't test inputting any actual video but only the
rebinding capabilites. But since rebinding was a major motivation for
this series to be factored out of a bigger one:

Tested-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



signature.asc
Description: PGP signature


[RFC 2/4] mmc: host: tmio: fix minor typos in a comment

2017-02-07 Thread Wolfram Sang
Making sure we match the actual register name.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index b20b451ad90daa..8a4e99ffe64eb1 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -54,7 +54,7 @@
 #define TMIO_STOP_STP  BIT(0)
 #define TMIO_STOP_SEC  BIT(8)
 
-/* Definitions for values the CTRL_STATUS register can take. */
+/* Definitions for values the CTL_STATUS register can take */
 #define TMIO_STAT_CMDRESPENDBIT(0)
 #define TMIO_STAT_DATAEND   BIT(2)
 #define TMIO_STAT_CARD_REMOVE   BIT(3)
-- 
2.11.0



[RFC 3/4] mmc: host: tmio: don't BUG on unsupported stop commands

2017-02-07 Thread Wolfram Sang
Halting the kernel on an unsupported stop command seems overkill, report
the error and say what we already did (due to autocmd12) instead.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index ad2840e1bfae51..b47dd9195fe3fe 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -553,10 +553,11 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
}
 
if (stop) {
-   if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
-   else
-   BUG();
+   if (stop->opcode != MMC_STOP_TRANSMISSION || stop->arg)
+   dev_err(>pdev->dev, "unsupported stop: 
CMD%u,0x%x. We did CMD12,0\n",
+   stop->opcode, stop->arg);
+
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
}
 
schedule_work(>done);
-- 
2.11.0



[RFC 1/4] mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values

2017-02-07 Thread Wolfram Sang
Don't use hardcoded values.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 4 
 drivers/mmc/host/tmio_mmc_pio.c | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 2b349d48fb9a8a..b20b451ad90daa 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -50,6 +50,10 @@
 #define CTL_CLK_AND_WAIT_CTL 0x138
 #define CTL_RESET_SDIO 0x1e0
 
+/* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */
+#define TMIO_STOP_STP  BIT(0)
+#define TMIO_STOP_SEC  BIT(8)
+
 /* Definitions for values the CTRL_STATUS register can take. */
 #define TMIO_STAT_CMDRESPENDBIT(0)
 #define TMIO_STAT_DATAEND   BIT(2)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 6b789a739d4dfe..ad2840e1bfae51 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -340,7 +340,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host 
*host, struct mmc_command
 
/* CMD12 is handled by hardware */
if (cmd->opcode == MMC_STOP_TRANSMISSION && !cmd->arg) {
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x001);
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, TMIO_STOP_STP);
return 0;
}
 
@@ -367,7 +367,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host 
*host, struct mmc_command
if (data) {
c |= DATA_PRESENT;
if (data->blocks > 1) {
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x100);
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 
TMIO_STOP_SEC);
c |= TRANSFER_MULTI;
 
/*
@@ -554,7 +554,7 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 
if (stop) {
if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x000);
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
else
BUG();
}
-- 
2.11.0



[RFC 0/4] mmc: host: tmio: properly report status from autocmd12

2017-02-07 Thread Wolfram Sang
SDHI automatically sends CMD12 when the desired amount of data was transferred
after multi block commands. However, the response from that CMD12 was never
reported back to the mmc core, so that errors like ECC might go unnoticed. This
series aims to fix that and clean up minor issues on the way when dealing with
the autocmd12 feature. It is marked as RFC because, so far, I could only test
that the success case was reported back to the MMC core. An error case (like
ECC) could not be created yet. But people inside Renesas will try some SD
tester soon, and I also will keep writing GB to an 64MB cards until wear level
problems kick in (though, I have to admit, I am trying this for days now and my
trust in lifetimes of SD cards has significantly increased since). I wanted to
present the patches early in case other parties are interested in testing, too.

The patches are based on mmc-next. A branch can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/topic/sdhi-autocmd12-resp

Thanks and all the best,

   Wolfram


Wolfram Sang (4):
  mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values
  mmc: host: tmio: fix minor typos in a comment
  mmc: host: tmio: don't BUG on unsupported stop commands
  mmc: host: tmio: fill in response from auto cmd12

 drivers/mmc/host/tmio_mmc.h |  6 +-
 drivers/mmc/host/tmio_mmc_pio.c | 16 ++--
 2 files changed, 15 insertions(+), 7 deletions(-)

-- 
2.11.0



[RFC 4/4] mmc: host: tmio: fill in response from auto cmd12

2017-02-07 Thread Wolfram Sang
After we received the dataend interrupt, R1 response register carries
the value from the automatically generated stop command. Report that
info back to the MMC block layer, so we will be notified in case of e.g.
ECC errors which happened during the last transfer.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index b47dd9195fe3fe..a08db28b0100d6 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -557,6 +557,9 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
dev_err(>pdev->dev, "unsupported stop: 
CMD%u,0x%x. We did CMD12,0\n",
stop->opcode, stop->arg);
 
+   /* fill in response from auto CMD12 */
+   stop->resp[0] = sd_ctrl_read16_and_16_as_32(host, CTL_RESPONSE);
+
sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
}
 
-- 
2.11.0



[PATCH v2] watchdog: softdog: make pretimeout support a compile option

2017-02-07 Thread Wolfram Sang
It occurred to me that the panic pretimeout governor will stall the
softdog, because it is purely software which simply breaks when the
kernel panics. Testing governors with the softdog on the other hand is
really useful, so make this feature a compile time option which nees to
be enabled explicitly. This also removes the overhead if pretimeout
support is not used because it will now be compiled away (saving ~10% on
ARM32).

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---

Change since V1:

* use IS_DEFINED as if-conditions, removing the need for #ifdef

I have to admit that this result is better readable and what the compiler
compiles away is sufficient.

 drivers/watchdog/Kconfig   |  8 
 drivers/watchdog/softdog.c | 21 +
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index acb00b53a5207b..70726ce3d166e8 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -71,6 +71,14 @@ config SOFT_WATCHDOG
  To compile this driver as a module, choose M here: the
  module will be called softdog.
 
+config SOFT_WATCHDOG_PRETIMEOUT
+   bool "Software watchdog pretimeout governor support"
+   depends on SOFT_WATCHDOG && WATCHDOG_PRETIMEOUT_GOV
+   help
+ Enable this if you want to use pretimeout governors with the software
+ watchdog. Be aware that governors might affect the watchdog because it
+ is purely software, e.g. the panic governor will stall it!
+
 config DA9052_WATCHDOG
tristate "Dialog DA9052 Watchdog"
depends on PMIC_DA9052
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index c7bdc986dca1c2..7983029852ab0d 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -87,11 +87,13 @@ static int softdog_ping(struct watchdog_device *w)
if (!mod_timer(_ticktock, jiffies + (w->timeout * HZ)))
__module_get(THIS_MODULE);
 
-   if (w->pretimeout)
-   mod_timer(_preticktock, jiffies +
- (w->timeout - w->pretimeout) * HZ);
-   else
-   del_timer(_preticktock);
+   if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
+   if (w->pretimeout)
+   mod_timer(_preticktock, jiffies +
+ (w->timeout - w->pretimeout) * HZ);
+   else
+   del_timer(_preticktock);
+   }
 
return 0;
 }
@@ -101,15 +103,15 @@ static int softdog_stop(struct watchdog_device *w)
if (del_timer(_ticktock))
module_put(THIS_MODULE);
 
-   del_timer(_preticktock);
+   if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT))
+   del_timer(_preticktock);
 
return 0;
 }
 
 static struct watchdog_info softdog_info = {
.identity = "Software Watchdog",
-   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE |
-  WDIOF_PRETIMEOUT,
+   .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
 };
 
 static const struct watchdog_ops softdog_ops = {
@@ -134,6 +136,9 @@ static int __init softdog_init(void)
watchdog_set_nowayout(_dev, nowayout);
watchdog_stop_on_reboot(_dev);
 
+   if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT))
+   softdog_info.options |= WDIOF_PRETIMEOUT;
+
ret = watchdog_register_device(_dev);
if (ret)
return ret;
-- 
2.11.0



Re: [PATCH v5 2/3] mmc: sh_mobile_sdhi: explain clock bindings

2017-01-21 Thread Wolfram Sang
On Fri, Jan 20, 2017 at 10:06:03PM -0500, Chris Brandt wrote:
> In the case of a single clock source, you don't need names. However,
> if the controller has 2 clock sources, you need to name them correctly
> so the driver can find the 2nd one. The 2nd clock is for the internal
> card detect logic.
> 
> Signed-off-by: Chris Brandt <chris.bra...@renesas.com>

Reviewed-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



signature.asc
Description: PGP signature


Re: [PATCH v5 1/3] mmc: sh_mobile_sdhi: add support for 2 clocks

2017-01-21 Thread Wolfram Sang
On Fri, Jan 20, 2017 at 10:06:02PM -0500, Chris Brandt wrote:
> Some controllers have 2 clock sources instead of 1. The 2nd clock
> is for the internal card detect logic and must be enabled/disabled
> along with the main core clock for proper operation.
> 
> Signed-off-by: Chris Brandt <chris.bra...@renesas.com>

Reviewed-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang

> The issue happened with renesas-devel, i.e. without those patches.
> It was mentioned during last core meeting, so have a look at that log.

No need to. As I said, the behaviour is expected without the patches.
Thanks for the update!



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang

> > Do you already fetch from Ulf's kernel.org tree? He switched away from
> > the Linaro tree for MMC for a while. I only realized when he complained

"since a while" not "for a while", of course.

> Thanks, I had not realised that. I've pulled the kernel.org tree.

So, there is hope for the patches to be in v4.11? :)



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang

> > Do you have the HS200 enablement patches in that branch? They are
> > currently in -next.
> 
> I tried mmc/next (but didn't notice anything special there).
> Which patches should I be looking for?

The series starting with 59c21074b582aa ("mmc: sh_mobile_sdhi: simplify
accessing DT data") up to 8c81459fa8adec ("mmc: sh_mobile_sdhi: enable
HS200").

Do you already fetch from Ulf's kernel.org tree? He switched away from
the Linaro tree for MMC for a while. I only realized when he complained
that he can't apply my patches.



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang

> I have tested with "the new mmc/next" and things seem better.

Good. The issue you saw is expected when you have not the enablement
patches in place.

> I am still of a mind to drop the M3-W patch of this series because unless
> we can control the order that things are merged into Linus's tree
> there will be a temporary regression there. Moreover I'm not very excited
> about renesas-next having regressed.

I have not heard of a regression. Geert, did you report that? Did I miss
that? As you can see, I did test the patches with M3 as well:

http://elinux.org/Tests:eMMC-HS

and Jinso test team (Duc-san) confirmed it works for them with H3 and
M3-W. In private communication, though.

Regards,

   Wolfram



signature.asc
Description: PGP signature


Re: [PATCH v3 1/8] pinctrl: sh-pfc: Add r7s72100 PFC driver

2017-01-26 Thread Wolfram Sang

Just some very minor nits... Probably not worth the resend.

On Mon, Jan 16, 2017 at 01:12:45PM +0100, Jacopo Mondi wrote:
> From: Magnus Damm <d...@opensource.se>
> 
> Squash commits in Geert's renesas-driver/genmai-gpio-and-pfc branch that
> add support for r7s72100 PFC.
> This squash combines commits for Magnus' original driver, several
> "groups" definitions and minor fixes on top to forward-port it to a more
> recent kernel (v4.10)
> 
> Signed-off-by: Magnus Damm <d...@opensource.se>
> Signed-off-by: Wolfram Sang <w...@sang-engineering.com>

I'd prefer the "wsa+renesas@..." address here, too.

> Signed-off-by: Simon Horman <horms+rene...@verge.net.au>
> Signed-off-by: Geert Uytterhoeven <geert+rene...@glider.be>
> Signed-off-by: Jacopo Mondi <jacopo+rene...@jmondi.org>

...

> diff --git a/drivers/pinctrl/sh-pfc/pfc-r7s72100.c 
> b/drivers/pinctrl/sh-pfc/pfc-r7s72100.c
> new file mode 100644
> index 000..72e1dff
> --- /dev/null
> +++ b/drivers/pinctrl/sh-pfc/pfc-r7s72100.c
> @@ -0,0 +1,529 @@
> +/*
> + * R7S72100 processor support
> + *
> + * Copyright (C) 2013  Renesas Electronics Corporation

2013-2017?



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang

> Using renesas-next without mmc-next I see the problem above on the M3-W.
> Using renesas-next with mmc-next I do not see the problem above.
> Using v4.10-rc2 I also do not see the problem above.

OK. So there is no problem with the code, at least.

> So I believe we should delay the integration change, which is currently in
> renesas-next, until the driver change in mmc-next hits Linus's tree.

Whatever you do, H3 and M3-W should be treated equally IMO.



signature.asc
Description: PGP signature


Re: [PATCH i2c/for-next] i2c: sh_mobile: document support for r8a7796 (R-Car M3-W)

2017-01-28 Thread Wolfram Sang
On Thu, Jan 26, 2017 at 09:47:31AM +0100, Simon Horman wrote:
> Explicitly list per-SoC binding for r8a7796. No driver change
> is required as the initialisation sequence is currently the same
> as for the R-Car Gen3 fallback binding.
> 
> Signed-off-by: Simon Horman 

Applied to for-next, thanks!



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang
On Thu, Jan 26, 2017 at 11:01:17AM +0100, Simon Horman wrote:
> On Fri, Jan 13, 2017 at 09:39:28AM +0100, Wolfram Sang wrote:
> > > Sorry for missing these.
> > > I have queued them up for v4.11.
> > 
> > Thank you!
> 
> On my r8a7796/salvator-x I see the following with this series applied:
> 
> sh_mobile_sdhi ee14.sd: timeout waiting for hardware interrupt (CMD13)

Do you have the HS200 enablement patches in that branch? They are
currently in -next.



signature.asc
Description: PGP signature


Re: [PATCH i2c/for-next] i2c: sh_mobile: document support for r8a7796 (R-Car M3-W)

2017-01-26 Thread Wolfram Sang
On Thu, Jan 26, 2017 at 09:47:31AM +0100, Simon Horman wrote:
> Explicitly list per-SoC binding for r8a7796. No driver change
> is required as the initialisation sequence is currently the same
> as for the R-Car Gen3 fallback binding.
> 
> Signed-off-by: Simon Horman <horms+rene...@verge.net.au>

Acked-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



signature.asc
Description: PGP signature


Re: [PATCH v6 0/3] mmc: sh_mobile_sdhi: fix missing r7s72100 clocks

2017-01-26 Thread Wolfram Sang

> Thanks, applied patch1 and patch2 for next. Patch3 is for Simon, I
> guess!? (And I can add Rob's ack afterwards).

Can you add my tags as well. They got dropped somehow:

Reviewed-by: Wolfram Sang <wsa+rene...@sang-engineering.com>



signature.asc
Description: PGP signature


[PATCH v7 0/2] arm64: dts: r8a779x: add thermal to DTS

2017-01-20 Thread Wolfram Sang
Since the driver is now merged into next, we can add the DTS snipplets as well.
Changes from V6:

* rebased to latest renesas/arm64-dt-for-v4.11
* changed critical temp from 90° to 120° which is the state in the latest BSP


Wolfram Sang (2):
  arm64: dts: r8a7795: Add R-Car Gen3 thermal support
  arm64: dts: r8a7796: Add R-Car Gen3 thermal support

 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 58 
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 58 
 2 files changed, 116 insertions(+)

-- 
2.11.0



[PATCH v7 2/2] arm64: dts: r8a7796: Add R-Car Gen3 thermal support

2017-01-20 Thread Wolfram Sang
Signed-off-by: Hien Dang <hien.dang...@renesas.com>
Signed-off-by: Thao Nguyen <thao.nguyen...@rvc.renesas.com>
Signed-off-by: Khiem Nguyen <khiem.nguyen...@renesas.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+rene...@ragnatech.se>
Acked-by: Eduardo Valentin <edubez...@gmail.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 58 
 1 file changed, 58 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index eb446d96662137..67aa0e4fde77b4 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -680,5 +680,63 @@
power-domains = < R8A7796_PD_ALWAYS_ON>;
status = "disabled";
};
+
+   tsc: thermal@e6198000 {
+   compatible = "renesas,r8a7796-thermal";
+   reg = <0 0xe6198000 0 0x68>,
+ <0 0xe61a 0 0x5c>,
+ <0 0xe61a8000 0 0x5c>;
+   interrupts = ,
+,
+;
+   clocks = < CPG_MOD 522>;
+   power-domains = < R8A7796_PD_ALWAYS_ON>;
+   #thermal-sensor-cells = <1>;
+   status = "okay";
+   };
+
+   thermal-zones {
+   sensor_thermal1: sensor-thermal1 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+   thermal-sensors = < 0>;
+
+   trips {
+   sensor1_crit: sensor1-crit {
+   temperature = <12>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+
+   sensor_thermal2: sensor-thermal2 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+   thermal-sensors = < 1>;
+
+   trips {
+   sensor2_crit: sensor2-crit {
+   temperature = <12>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+
+   sensor_thermal3: sensor-thermal3 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+   thermal-sensors = < 2>;
+
+   trips {
+   sensor3_crit: sensor3-crit {
+   temperature = <12>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
};
 };
-- 
2.11.0



[PATCH v7 1/2] arm64: dts: r8a7795: Add R-Car Gen3 thermal support

2017-01-20 Thread Wolfram Sang
Signed-off-by: Hien Dang <hien.dang...@renesas.com>
Signed-off-by: Thao Nguyen <thao.nguyen...@rvc.renesas.com>
Signed-off-by: Khiem Nguyen <khiem.nguyen...@renesas.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+rene...@ragnatech.se>
Acked-by: Eduardo Valentin <edubez...@gmail.com>
Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 58 
 1 file changed, 58 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 026a16ac41b422..d36783e751af87 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -1647,5 +1647,63 @@
};
};
};
+
+   tsc: thermal@e6198000 {
+   compatible = "renesas,r8a7795-thermal";
+   reg = <0 0xe6198000 0 0x68>,
+ <0 0xe61a 0 0x5c>,
+ <0 0xe61a8000 0 0x5c>;
+   interrupts = ,
+,
+;
+   clocks = < CPG_MOD 522>;
+   power-domains = < R8A7795_PD_ALWAYS_ON>;
+   #thermal-sensor-cells = <1>;
+   status = "okay";
+   };
+
+   thermal-zones {
+   sensor_thermal1: sensor-thermal1 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+   thermal-sensors = < 0>;
+
+   trips {
+   sensor1_crit: sensor1-crit {
+   temperature = <12>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+
+   sensor_thermal2: sensor-thermal2 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+   thermal-sensors = < 1>;
+
+   trips {
+   sensor2_crit: sensor2-crit {
+   temperature = <12>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+
+   sensor_thermal3: sensor-thermal3 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+   thermal-sensors = < 2>;
+
+   trips {
+   sensor3_crit: sensor3-crit {
+   temperature = <12>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
};
 };
-- 
2.11.0



Re: [PATCH v4 2/3] mmc: sh_mobile_sdhi: explain clock bindings

2017-01-20 Thread Wolfram Sang

> It sounds like your suggestion is to just put the HW description in
> the DT bindings, but move the dirty details into the driver.
> 
> Keep in DT:
> 
> +- clocks: Most controllers only have 1 clock source per channel. However, on
> +   some variations of this controller, the internal card detection
> +   logic that exists in this controller is sectioned off to be run by a
> +   separate second clock source to allow the main core clock to be turned
> +   off to save power.
> +   If 2 clocks are specified by the hardware, you must name them as
> +   "core" and "cd".
> +   If the controller only has 1 clock, naming is not required.
> 
> 
> 
> Move somewhere in the driver (maybe where the 2nd clock is detected):
> 
> +   Unfortunately, the existing driver architecture
> +   does not support such a separation of clocks.

"such" is not explained. Maybe "does not support a seperation of clocks.
It doesn't work with Runtime PM because ..."?

> +   Additionally, it is prohibited to supply a clock to the core but not
> +   to the card detect circuit. That leaves you with if separate clocks
> +   are presented, you must treat them both as 1.
> 
> 
> Is this what you were thinking?

Exactly.



signature.asc
Description: PGP signature


Re: [PATCH v3 1/3] mmc: sh_mobile_sdhi: add support for 2 clocks

2017-01-20 Thread Wolfram Sang

> > Is this clock solely about card detection? So in cases when you have a
> > GPIO card detect, the clock isn't needed?
> > 
> > Just trying to understand things a bit better...
> 
> According to the hardware manual, enabling the "core" clock but not the
> "cd" clock is not a valid setting. So in our case, it's always all or
> nothing.

It was my suggestion to either handle both clocks as "virtually" one
clock so it simulates how other SDHI instances behave, or to implement
proper and intended handling of the cd clock to save some power. Chris
chose the first option and I have full understanding for that decision.



signature.asc
Description: PGP signature


Re: [PATCH RESEND 0/2] arm64: gen3: enable eMMC HS200 in DT

2017-01-26 Thread Wolfram Sang

> The problem I see is the following logged to the console
> (which makes the console semi-unusable).
> 
> sh_mobile_sdhi ee14.sd: timeout waiting for hardware interrupt (CMD13)

Just to make sure: with the HS200 enablement patches present?



signature.asc
Description: PGP signature


[PATCH] ASoC: rsnd: drop useles self-assignments

2017-02-20 Thread Wolfram Sang
Coverity reported (CID 1397992) this self-assignment. I think the code
stays readable even with the assignments removed.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 sound/soc/sh/rcar/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 47b370cb2d3b3a..24adb3cc17aa63 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -674,12 +674,10 @@ static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
/* set clock inversion */
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_IF:
-   rdai->bit_clk_inv =  rdai->bit_clk_inv;
rdai->frm_clk_inv = !rdai->frm_clk_inv;
break;
case SND_SOC_DAIFMT_IB_NF:
rdai->bit_clk_inv = !rdai->bit_clk_inv;
-   rdai->frm_clk_inv =  rdai->frm_clk_inv;
break;
case SND_SOC_DAIFMT_IB_IF:
rdai->bit_clk_inv = !rdai->bit_clk_inv;
-- 
2.11.0



[PATCH] ASoC: rsnd: check return value of init function

2017-02-20 Thread Wolfram Sang
Currently, this function cannot fail for the ADG case. Still, let's
apply defensive programming techniques to make sure we fail gracefully
whenever rsnd_mod_init() gets extended with another failure case.
Reported by Coverity (CID 1397893).

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 sound/soc/sh/rcar/adg.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index 85a33ac0a5c443..54146f66538c18 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -564,6 +564,7 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
struct rsnd_adg *adg;
struct device *dev = rsnd_priv_to_dev(priv);
struct device_node *np = dev->of_node;
+   int ret;
 
adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL);
if (!adg) {
@@ -571,8 +572,10 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
return -ENOMEM;
}
 
-   rsnd_mod_init(priv, >mod, _ops,
+   ret = rsnd_mod_init(priv, >mod, _ops,
  NULL, NULL, 0, 0);
+   if (ret)
+   return ret;
 
rsnd_adg_get_clkin(priv, adg);
rsnd_adg_get_clkout(priv, adg);
-- 
2.11.0



[PATCH v2] mmc: host: tmio: ensure end of DMA and SD access are in sync

2017-02-17 Thread Wolfram Sang
The current code assumes that DMA is finished before SD access end is
flagged. Thus, it schedules the 'dma_complete' tasklet in the SD card
interrupt routine when DATAEND is set. The assumption is not safe,
though. Even by mounting an SD card, it can be seen that sometimes DMA
complete is first, sometimes DATAEND. It seems they are usually close
enough timewise to not cause problems. However, a customer reported that
with CMD53 sometimes things really break apart. As a result, the BSP has
a patch which introduces flags for both events and makes sure both flags
are set before scheduling the tasklet. The customer accepted the patch,
yet it doesn't seem a proper upstream solution to me.

This patch refactors the code to replace the tasklet with already
existing and more lightweight mechanisms. First of all, we set the
callback in a DMA descriptor to automatically get notified when DMA is
done. In the callback, we then use a completion to make sure the SD
access has already ended. Then, we proceed as before.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---

Changes since V1/RFC:

* removed #ifdef DEBUG
* rebased to latest mmc/next
* did some more performance testing. Couldn't spot any difference

 drivers/mmc/host/tmio_mmc.h |  2 +-
 drivers/mmc/host/tmio_mmc_dma.c | 58 -
 drivers/mmc/host/tmio_mmc_pio.c |  4 +--
 3 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 2b349d48fb9a8a..891d400d2a7cf2 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -137,7 +137,7 @@ struct tmio_mmc_host {
boolforce_pio;
struct dma_chan *chan_rx;
struct dma_chan *chan_tx;
-   struct tasklet_struct   dma_complete;
+   struct completion   dma_dataend;
struct tasklet_struct   dma_issue;
struct scatterlist  bounce_sg;
u8  *bounce_buf;
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index fa8a936a3d9ba1..c7684fa91f1f9c 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -43,6 +43,31 @@ void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
tmio_mmc_enable_dma(host, true);
 }
 
+static void tmio_mmc_dma_callback(void *arg)
+{
+   struct tmio_mmc_host *host = arg;
+
+   wait_for_completion(>dma_dataend);
+
+   spin_lock_irq(>lock);
+
+   if (!host->data)
+   goto out;
+
+   if (host->data->flags & MMC_DATA_READ)
+   dma_unmap_sg(host->chan_rx->device->dev,
+host->sg_ptr, host->sg_len,
+DMA_FROM_DEVICE);
+   else
+   dma_unmap_sg(host->chan_tx->device->dev,
+host->sg_ptr, host->sg_len,
+DMA_TO_DEVICE);
+
+   tmio_mmc_do_data_irq(host);
+out:
+   spin_unlock_irq(>lock);
+}
+
 static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
 {
struct scatterlist *sg = host->sg_ptr, *sg_tmp;
@@ -88,6 +113,10 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host 
*host)
DMA_DEV_TO_MEM, DMA_CTRL_ACK);
 
if (desc) {
+   reinit_completion(>dma_dataend);
+   desc->callback = tmio_mmc_dma_callback;
+   desc->callback_param = host;
+
cookie = dmaengine_submit(desc);
if (cookie < 0) {
desc = NULL;
@@ -162,6 +191,10 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host 
*host)
DMA_MEM_TO_DEV, DMA_CTRL_ACK);
 
if (desc) {
+   reinit_completion(>dma_dataend);
+   desc->callback = tmio_mmc_dma_callback;
+   desc->callback_param = host;
+
cookie = dmaengine_submit(desc);
if (cookie < 0) {
desc = NULL;
@@ -221,29 +254,6 @@ static void tmio_mmc_issue_tasklet_fn(unsigned long priv)
dma_async_issue_pending(chan);
 }
 
-static void tmio_mmc_tasklet_fn(unsigned long arg)
-{
-   struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
-
-   spin_lock_irq(>lock);
-
-   if (!host->data)
-   goto out;
-
-   if (host->data->flags & MMC_DATA_READ)
-   dma_unmap_sg(host->chan_rx->device->dev,
-host->sg_ptr, host->sg_len,
-DMA_FROM_DEVICE);
-   else
-   dma_unmap_sg(host->chan_tx->device->dev,
-host->sg_ptr, host->sg_len,
-DMA_TO_DEVICE);
-
-   tmio_mmc_do_data_irq(host);
-out:
-   spin_unlock_irq(>lock);
-}
-
 void tmio_mmc_request_dma(struct tmio_mmc_host *ho

[PULL REQUEST] renesas/topic/sdhi-dma-sync-v2 for renesas drivers

2017-02-17 Thread Wolfram Sang
Hi Geert,

since Ulf thinks this patch is a good idea, please pull this updated
branch (debug removed) into renesas/drivers. The branch is based on
mmc/next as of today.

Kind regards,

   Wolfram


The following changes since commit 8c7cdbf9272c300dc093da3c62fa3b4bc6dc960e:

  mmc: core: add mmc prefix for blk_fixups (2017-02-15 11:34:27 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/topic/sdhi-dma-sync-v2

for you to fetch changes up to f4af9bf51003a285e58a272e27e551658bab1b28:

  mmc: host: tmio: ensure end of DMA and SD access are in sync (2017-02-17 
18:43:28 +0100)


Wolfram Sang (1):
  mmc: host: tmio: ensure end of DMA and SD access are in sync

 drivers/mmc/host/tmio_mmc.h |  2 +-
 drivers/mmc/host/tmio_mmc_dma.c | 58 -
 drivers/mmc/host/tmio_mmc_pio.c |  4 +--
 3 files changed, 37 insertions(+), 27 deletions(-)


signature.asc
Description: PGP signature


[RFC] mmc: core: check also R1 response for stop commands

2017-02-17 Thread Wolfram Sang
Introduce a helper function to not only check the error value but also
error bits of a R1 response. Use the helper for the stop command.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---

So, here is a first draft of what we talked about recenlty. Let me know what
you think...

 drivers/mmc/core/block.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 985477cdcb3ea4..b96477b689e457 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1292,9 +1292,18 @@ static inline void mmc_apply_rel_rw(struct 
mmc_blk_request *brq,
 R1_ADDRESS_ERROR | /* Misaligned address */\
 R1_BLOCK_LEN_ERROR |   /* Transferred block length incorrect */\
 R1_WP_VIOLATION |  /* Tried to write to protected block */ \
+R1_CARD_ECC_FAILED |   /* Card ECC failed */   \
 R1_CC_ERROR |  /* Card controller error */ \
 R1_ERROR)  /* General/unknown error */
 
+static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
+{
+   if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
+   cmd->error = -EIO;
+
+   return cmd->error;
+}
+
 static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
 struct mmc_async_req *areq)
 {
@@ -1316,7 +1325,7 @@ static enum mmc_blk_status mmc_blk_err_check(struct 
mmc_card *card,
 * stop.error indicates a problem with the stop command.  Data
 * may have been transferred, or may still be transferring.
 */
-   if (brq->sbc.error || brq->cmd.error || brq->stop.error ||
+   if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(>stop) 
||
brq->data.error) {
switch (mmc_blk_cmd_recovery(card, req, brq, _err, 
_err)) {
case ERR_RETRY:
-- 
2.11.0



[PATCH 1/4] mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values

2017-02-12 Thread Wolfram Sang
Don't use hardcoded values.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 4 
 drivers/mmc/host/tmio_mmc_pio.c | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 2b349d48fb9a8a..b20b451ad90daa 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -50,6 +50,10 @@
 #define CTL_CLK_AND_WAIT_CTL 0x138
 #define CTL_RESET_SDIO 0x1e0
 
+/* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */
+#define TMIO_STOP_STP  BIT(0)
+#define TMIO_STOP_SEC  BIT(8)
+
 /* Definitions for values the CTRL_STATUS register can take. */
 #define TMIO_STAT_CMDRESPENDBIT(0)
 #define TMIO_STAT_DATAEND   BIT(2)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 6b789a739d4dfe..ad2840e1bfae51 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -340,7 +340,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host 
*host, struct mmc_command
 
/* CMD12 is handled by hardware */
if (cmd->opcode == MMC_STOP_TRANSMISSION && !cmd->arg) {
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x001);
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, TMIO_STOP_STP);
return 0;
}
 
@@ -367,7 +367,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host 
*host, struct mmc_command
if (data) {
c |= DATA_PRESENT;
if (data->blocks > 1) {
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x100);
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 
TMIO_STOP_SEC);
c |= TRANSFER_MULTI;
 
/*
@@ -554,7 +554,7 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 
if (stop) {
if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x000);
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
else
BUG();
}
-- 
2.11.0



[PATCH 2/4] mmc: host: tmio: fix minor typos in a comment

2017-02-12 Thread Wolfram Sang
Making sure we match the actual register name.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index b20b451ad90daa..8a4e99ffe64eb1 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -54,7 +54,7 @@
 #define TMIO_STOP_STP  BIT(0)
 #define TMIO_STOP_SEC  BIT(8)
 
-/* Definitions for values the CTRL_STATUS register can take. */
+/* Definitions for values the CTL_STATUS register can take */
 #define TMIO_STAT_CMDRESPENDBIT(0)
 #define TMIO_STAT_DATAEND   BIT(2)
 #define TMIO_STAT_CARD_REMOVE   BIT(3)
-- 
2.11.0



[PATCH 3/4] mmc: host: tmio: don't BUG on unsupported stop commands

2017-02-12 Thread Wolfram Sang
Halting the kernel on an unsupported stop command seems overkill, report
the error and say what we already did (due to autocmd12) instead.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index ad2840e1bfae51..b47dd9195fe3fe 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -553,10 +553,11 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
}
 
if (stop) {
-   if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
-   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
-   else
-   BUG();
+   if (stop->opcode != MMC_STOP_TRANSMISSION || stop->arg)
+   dev_err(>pdev->dev, "unsupported stop: 
CMD%u,0x%x. We did CMD12,0\n",
+   stop->opcode, stop->arg);
+
+   sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
}
 
schedule_work(>done);
-- 
2.11.0



[PATCH 4/4] mmc: host: tmio: fill in response from auto cmd12

2017-02-12 Thread Wolfram Sang
After we received the dataend interrupt, R1 response register carries
the value from the automatically generated stop command. Report that
info back to the MMC block layer, so we will be notified in case of e.g.
ECC errors which happened during the last transfer.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index b47dd9195fe3fe..a08db28b0100d6 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -557,6 +557,9 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
dev_err(>pdev->dev, "unsupported stop: 
CMD%u,0x%x. We did CMD12,0\n",
stop->opcode, stop->arg);
 
+   /* fill in response from auto CMD12 */
+   stop->resp[0] = sd_ctrl_read16_and_16_as_32(host, CTL_RESPONSE);
+
sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
}
 
-- 
2.11.0



[PATCH 0/4] mmc: host: tmio: properly report status from autocmd12

2017-02-12 Thread Wolfram Sang
SDHI automatically sends CMD12 when the desired amount of data was transferred
after multi block commands. However, the response from that CMD12 was never
reported back to the mmc core, so that errors like ECC might go unnoticed. This
series aims to fix that and clean up minor issues on the way when dealing with
the autocmd12 feature. So far, I could only test that the success case was
reported back to the MMC core [1]. An error case (like ECC) could not be
created yet, but I will keep on trying. However, the initial flaw of the CMD12
response not reported back is fixed with this series as the success case
demonstrates. If an ECC error is not properly handled, it is a seperate issue
anyway. So, I think this series could go in now. No pressure for 4.11, though.
But would be nice, of course ;)

The patches are based on mmc-next. A branch can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/topic/sdhi-autocmd12-resp

Thanks and all the best,

   Wolfram

[1] http://elinux.org/Tests:SDHI-autocmd12-responses


Wolfram Sang (4):
  mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values
  mmc: host: tmio: fix minor typos in a comment
  mmc: host: tmio: don't BUG on unsupported stop commands
  mmc: host: tmio: fill in response from auto cmd12

 drivers/mmc/host/tmio_mmc.h |  6 +-
 drivers/mmc/host/tmio_mmc_pio.c | 16 ++--
 2 files changed, 15 insertions(+), 7 deletions(-)

-- 
2.11.0



[PULL REQUEST] renesas/topic/sdhi-autocmd12-resp for renesas drivers

2017-02-12 Thread Wolfram Sang
Hi Geert,

here is a topic branch for renesas-drivers to report back autocmd12
responses for SDHI. It is based on mmc/next. Please pull.

Kind regards,

   Wolfram


The following changes since commit 0c3630150c9af658e7375c509c670fadf052cca8:

  mmc: core: start to break apart mmc_start_areq() (2017-02-03 10:50:23 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/topic/sdhi-autocmd12-resp

for you to fetch changes up to 22b13c28ac6b92f3acf7a5a91575b9da004c853a:

  mmc: host: tmio: fill in response from auto cmd12 (2017-02-07 11:47:26 +0100)


Wolfram Sang (4):
  mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values
  mmc: host: tmio: fix minor typos in a comment
  mmc: host: tmio: don't BUG on unsupported stop commands
  mmc: host: tmio: fill in response from auto cmd12

 drivers/mmc/host/tmio_mmc.h |  6 +-
 drivers/mmc/host/tmio_mmc_pio.c | 16 ++--
 2 files changed, 15 insertions(+), 7 deletions(-)


signature.asc
Description: PGP signature


Re: [PATCH v2 4/4] mmc: host: tmio: fill in response from auto cmd12

2017-02-14 Thread Wolfram Sang
Shimoda-san, Ulf,

On Tue, Feb 14, 2017 at 10:06:47AM +, Yoshihiro Shimoda wrote:
> Hi,
> 
> > From: Wolfram Sang [mailto:wsa+rene...@sang-engineering.com]
> > Sent: Tuesday, February 14, 2017 3:04 AM
> > 
> > After we received the dataend interrupt, R1 response register carries
> > the value from the automatically generated stop command. Report that
> > info back to the MMC block layer, so we will be notified in case of e.g.
> > ECC errors which happened during the last transfer.
> > 
> > Reviewed-by: Simon Horman <horms+rene...@verge.net.au>
> > Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
> 
> I tested this patch with a SD tester (SGDK320).
> As the commit log, this patch could pass the R1 response. So,
> 
> Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda...@renesas.com>

Thank you very much for testing!

> However, I think the MMC block layer should check the brq->stop.resp[0]
> because brq->stop.error should be zero in this case and mmc_blk_cmd_recovery()
> is not called in mmc_blk_err_check().

I see. Ulf, do you think it makes sense to extend the condition when to
call mmc_blk_cmd_recovery() with checking if stop.resp[0] has one of the
R1_* bits set which are marked with 'ex' (and probably 'erx', too)? I
agree with Shimoda-san, that the core is a good place to do it, since it
is about parsing the R1 and not the status bits of the host hardware.

Regards,

   Wolfram



signature.asc
Description: PGP signature


Re: [PATCH 2/4] mmc: host: tmio: fix minor typos in a comment

2017-02-13 Thread Wolfram Sang

> > -/* Definitions for values the CTRL_STATUS register can take. */
> > +/* Definitions for values the CTL_STATUS register can take */
> >  #define TMIO_STAT_CMDRESPENDBIT(0)
> >  #define TMIO_STAT_DATAEND   BIT(2)
> >  #define TMIO_STAT_CARD_REMOVE   BIT(3)
> 
> Is a similar update for CTRL_STATUS2 appropriate a few lines further down?

Yes, and SDIO_STATUS as well. Will fix and resend. Thanks!



signature.asc
Description: PGP signature


Re: [PATCH v2 4/4] mmc: host: tmio: fill in response from auto cmd12

2017-02-16 Thread Wolfram Sang
Hi Ulf,

On Thu, Feb 16, 2017 at 08:57:36AM +0100, Ulf Hansson wrote:
> On 15 February 2017 at 16:02, Wolfram Sang <w...@the-dreams.de> wrote:
> >
> >> > I see. Ulf, do you think it makes sense to extend the condition when to
> >> > call mmc_blk_cmd_recovery() with checking if stop.resp[0] has one of the
> >> > R1_* bits set which are marked with 'ex' (and probably 'erx', too)? I
> >> > agree with Shimoda-san, that the core is a good place to do it, since it
> >> > is about parsing the R1 and not the status bits of the host hardware.
> >>
> >> The method we use to indicate a stop command error to the mmc core, is
> >> to set ->stop.error in the host driver before completing the request.
> >> Perhaps set it to -EIO or -EILSEQ.
> >>
> >> In that way mmc_blk_err_check() sees the error and invokes the
> >> mmc_blk_cmd_recovery() to deal with it (response parsing etc).
> >>
> >> Does that work for you?
> >
> > It would work, yes. Since R1 response format is hardware independent, I
> > wondered if checking for ECC errors wouldn't be better suited in the
> > core. We roughly need something like this:
> >
> > if (stop.resp[0] & R1_CARD_ECC_FAILED)
> > stop.error = -EIO;
> >
> > We can copy this into every driver, of course. Yet, I wondered if we
> > couldn't have a helper function mapping the R1 error bits to an
> > apropriate error value and call that just before the check in
> > mmc_blk_err_check().
> >
> > Do you get what I mean?
> 
> I get it - and yes you have a point.

Cool.

> By looking at the code in mmc_blk_err_check() and
> mmc_blk_cmd_recovery(), it deserves a clean-up. That said, I don't

What do you mean with clean-up here? I would have just added the helper
function checking R1 error bits and setting stop.error accordingly.

> want to treat R1_CARD_ECC_FAILED as a special case.
> 
> So if you decide to add this check in the core (which I am open to),
> we should also add checks the other potential R1 errors, to be
> consistent.

I agree. That's what I meant with "checking if stop.resp[0] has one of
the R1_* bits set which are marked with 'ex' (and probably 'erx',
too)?". I think these are the candidates we care about.

Thanks,

   Wolfram


signature.asc
Description: PGP signature


Re: [RFC] mmc: host: tmio: ensure end of DMA and SD access are in sync

2017-02-16 Thread Wolfram Sang
On Thu, Feb 16, 2017 at 09:28:24AM +0100, Ulf Hansson wrote:
> On 15 February 2017 at 19:05, Wolfram Sang
> <wsa+rene...@sang-engineering.com> wrote:
> > The current code assumes that DMA is finished before SD access end is
> > flagged. Thus, it schedules the 'dma_complete' tasklet in the SD card
> > interrupt routine when DATAEND is set. The assumption is not safe,
> > though. Even by mounting an SD card, it can be seen that sometimes DMA
> > complete is first, sometimes DATAEND. It seems they are usually close
> > enough timewise to not cause problems. However, a customer reported that
> > with CMD53 sometimes things really break apart. As a result, the BSP has
> > a patch which introduces flags for both events and makes sure both flags
> > are set before scheduling the tasklet. The customer accepted the patch,
> > yet it doesn't seem a proper upstream solution to me.
> >
> > This patch refactors the code to replace the tasklet with already
> > existing and more lightweight mechanisms. First of all, we set the
> > callback in a DMA descriptor to automatically get notified when DMA is
> > done. In the callback, we then use a completion to make sure the SD
> > access has already ended. Then, we proceed as before.
> 
> I have similar experience and a HW behaviour. Your reasoning seems
> correct to me.

Great. Thanks for the review!

> > So, calling for early review here. And opinions how to proceed. I am not 
> > sure
> > we want this in renesas-drivers until the SDIO functionality has been 
> > verified?
> > Because it is the reason this patch exists in the first place :)
> 
> If there are no regressions, we could consider this as a nice
> clean-up, instead of waiting for the dependencies to be resolved.

Fine with me. I feel much more comfortable with your experience backing
up ours.

> 
> Did you run some performance test?

The throughput numbers of 'dd' are exactly the same. But maybe I could
run one or two more tests with specifically testing that.

> > index 2b349d48fb9a8a..891d400d2a7cf2 100644
> > --- a/drivers/mmc/host/tmio_mmc.h
> > +++ b/drivers/mmc/host/tmio_mmc.h
> > @@ -137,7 +137,7 @@ struct tmio_mmc_host {
> > boolforce_pio;
> > struct dma_chan *chan_rx;
> > struct dma_chan *chan_tx;
> > -   struct tasklet_struct   dma_complete;
> > +   struct completion   dma_dataend;
> > struct tasklet_struct   dma_issue;
> 
> The next step would be to convert the driver to a use threaded IRQ
> handler in favour of the dma_issue tasklet. That should also work,
> right!? :-)

I'll check. I also identified this tasklet as the next target but I
haven't actually looked into it yet.

Thanks for looking into it right away,

   Wolfram



signature.asc
Description: PGP signature


[RFC] mmc: host: tmio: ensure end of DMA and SD access are in sync

2017-02-15 Thread Wolfram Sang
The current code assumes that DMA is finished before SD access end is
flagged. Thus, it schedules the 'dma_complete' tasklet in the SD card
interrupt routine when DATAEND is set. The assumption is not safe,
though. Even by mounting an SD card, it can be seen that sometimes DMA
complete is first, sometimes DATAEND. It seems they are usually close
enough timewise to not cause problems. However, a customer reported that
with CMD53 sometimes things really break apart. As a result, the BSP has
a patch which introduces flags for both events and makes sure both flags
are set before scheduling the tasklet. The customer accepted the patch,
yet it doesn't seem a proper upstream solution to me.

This patch refactors the code to replace the tasklet with already
existing and more lightweight mechanisms. First of all, we set the
callback in a DMA descriptor to automatically get notified when DMA is
done. In the callback, we then use a completion to make sure the SD
access has already ended. Then, we proceed as before.

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
---

I tried various synchronization approaches and liked this one best.

There are a couple of reasons this patch is RFC:

The #ifdef's need to go but are handy for now.

More testing is needed. While it worked fine for me writing terrabytes to
different cards (still trying to break the wear-levelling), broader testing
with different workloads and use-cases is largely welcome. I specifically
couldn't test with CMD53 (SDIO) which originally caused the problem for the
customer because that seems not working with my Gen2 board. I tried to fix SDIO
on Gen2 as a side-task but didn't find anything obvious on a glimpse. SDIO
works with my Gen3 boards but for that we don't have DMA upstream yet.
Upstreaming Gen3 DMA will need some bigger DMA refactoring, so it might be
worth waiting until the refactoring is done. In a nutshell, there are
dependency issues currently.

So, calling for early review here. And opinions how to proceed. I am not sure
we want this in renesas-drivers until the SDIO functionality has been verified?
Because it is the reason this patch exists in the first place :)

The branch is here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/topic/sdhi-dma-sync

The test description is here:

http://elinux.org/Tests:SDHI-DMA-Sync

Cheers and thanks,

   Wolfram


 drivers/mmc/host/tmio_mmc.h |  2 +-
 drivers/mmc/host/tmio_mmc_dma.c | 71 +++--
 drivers/mmc/host/tmio_mmc_pio.c |  4 +--
 3 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 2b349d48fb9a8a..891d400d2a7cf2 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -137,7 +137,7 @@ struct tmio_mmc_host {
boolforce_pio;
struct dma_chan *chan_rx;
struct dma_chan *chan_tx;
-   struct tasklet_struct   dma_complete;
+   struct completion   dma_dataend;
struct tasklet_struct   dma_issue;
struct scatterlist  bounce_sg;
u8  *bounce_buf;
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index fa8a936a3d9ba1..d2b6aed644f361 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -43,6 +44,43 @@ void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
tmio_mmc_enable_dma(host, true);
 }
 
+static void tmio_mmc_dma_callback(void *arg)
+{
+   struct tmio_mmc_host *host = arg;
+
+#ifdef DEBUG
+   u32 status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS);
+
+   dev_dbg(>pdev->dev, "DMA complete (0x%08x)\n", status);
+#endif
+
+   wait_for_completion(>dma_dataend);
+
+#ifdef DEBUG
+   status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS);
+
+   dev_dbg(>pdev->dev, "DATAEND complete (0x%08x)\n", status);
+#endif
+
+   spin_lock_irq(>lock);
+
+   if (!host->data)
+   goto out;
+
+   if (host->data->flags & MMC_DATA_READ)
+   dma_unmap_sg(host->chan_rx->device->dev,
+host->sg_ptr, host->sg_len,
+DMA_FROM_DEVICE);
+   else
+   dma_unmap_sg(host->chan_tx->device->dev,
+host->sg_ptr, host->sg_len,
+DMA_TO_DEVICE);
+
+   tmio_mmc_do_data_irq(host);
+out:
+   spin_unlock_irq(>lock);
+}
+
 static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
 {
struct scatterlist *sg = host->sg_ptr, *sg_tmp;
@@ -88,6 +126,10 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host 
*host)
DMA_DEV_TO_MEM, DMA_CTRL_ACK);
 
if (desc) {
+   reinit_completion(>dma_dataend);
+   desc->callback = tmio_mmc_dma_call

[PULL REQUEST] renesas/topic/sdhi-dma-sync for renesas drivers

2017-02-15 Thread Wolfram Sang
Hi Geert,

in case, we decide to include this patch despite not being tested for
the original SDIO case, here is a formal pull request.

Kind regards,

   Wolfram


The following changes since commit 391a542fe891d6dac49fa7fc2422651e54af1d42:

  mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support (2017-02-13 13:21:08 
+0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/topic/sdhi-dma-sync

for you to fetch changes up to 2ea4d49db87684a27026922b73119d9b69c46074:

  mmc: host: tmio: ensure end of DMA and SD access are in sync (2017-02-15 
23:17:55 +0100)


Wolfram Sang (1):
  mmc: host: tmio: ensure end of DMA and SD access are in sync

 drivers/mmc/host/tmio_mmc.h |  2 +-
 drivers/mmc/host/tmio_mmc_dma.c | 70 +++--
 drivers/mmc/host/tmio_mmc_pio.c |  4 +--
 3 files changed, 49 insertions(+), 27 deletions(-)


signature.asc
Description: PGP signature


Re: [PATCH] ARM: shmobile: r7s72100: add restart handler

2017-02-10 Thread Wolfram Sang

> > #1 and #3 look like they are the same thing (except #3 is enabled on power
> > on reset). The renesas_wdt.c uses the register names from #1.
> > Is the idea that you only use #3 to make sure your systems boots and get 
> > into
> > Linux, then from there you use #1 and stop #3 (hence no driver is needed)?
> 
> Isn't the SRWDT restricted to secure mode?

Yes.



signature.asc
Description: PGP signature


Re: [PATCHv6 0/4] thermal: add driver for R-Car Gen3

2017-01-19 Thread Wolfram Sang

> larger. Therefore I would like to ask Morimoto-san and/or Khiem to
> provide or proxy testing of this less accurate formula and feedback if
> it's OK, let me know if there is anything I can do to help out.

We now got the results of Renesas internal testing via internal
channels. So, for this series:

Tested-by: Hien Dang 

So, from our point of view, this series is ready to go upstream. 4.11
would be most welcome.

Thanks,

   Wolfram



signature.asc
Description: PGP signature


Re: [PATCH] ARM: dts: r7s72100: fix sdhi clock define

2017-01-17 Thread Wolfram Sang

> So, should sh_mobile_sdhi_remove() be changed to call 
> sh_mobile_sdhi_clk_disable()?

Give me a minute, I already did a patch for this :)



signature.asc
Description: PGP signature


Re: [PATCH v2 2/3] mmc: sh_mobile_sdhi: explain clock bindings

2017-01-17 Thread Wolfram Sang
On Tue, Jan 17, 2017 at 02:59:39PM -0500, Chris Brandt wrote:
> In the case of a single clock source, you don't need names. However,
> if the controller has 2 clock sources, you need to name them correctly
> so the driver can find the 2nd one.
> 
> Signed-off-by: Chris Brandt 
> ---
>  Documentation/devicetree/bindings/mmc/tmio_mmc.txt | 21 +
>  1 file changed, 21 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mmc/tmio_mmc.txt 
> b/Documentation/devicetree/bindings/mmc/tmio_mmc.txt
> index a1650ed..258b98c 100644
> --- a/Documentation/devicetree/bindings/mmc/tmio_mmc.txt
> +++ b/Documentation/devicetree/bindings/mmc/tmio_mmc.txt
> @@ -25,8 +25,29 @@ Required properties:
>   "renesas,sdhi-r8a7795" - SDHI IP on R8A7795 SoC
>   "renesas,sdhi-r8a7796" - SDHI IP on R8A7796 SoC
>  
> +- clocks: Most controllers only have 1 clock source per cahnnel. However, 
> some

channel.

> +   have 2. If 2 clocks are specified, you must name them as "core" and

Maybe "However, some have a second clock dedicated to card detection."?



Re: [PATCH v4 1/2] iio: adc: Add Maxim MAX11100 driver

2017-01-17 Thread Wolfram Sang

> + * Copyright (C) 2016 Renesas Electronics Corporation
> + * Copyright (C) 2016 Jacopo Mondi

In case you need to resend: 2016-17?



Re: [PATCH] ARM: dts: r7s72100: fix sdhi clock define

2017-01-16 Thread Wolfram Sang

> > and then in the code do:
> >
> > struct *cd_clk;
> > cd_clk = devm_clk_get(>dev, "cd");
> > if (cd_clk) {
> > clk_prepare_enable(cd_clk);
> > }
> >
> >   (this simple 1-line fix patch is getting a lot more complicated)
> 
> Disclaimer: I don't know how/if the SDHI core manages clocks, and may
> interfere. Adding Wolfram.

Thanks for the heads up.

We have special callbacks for en-/disabling clocks:
sh_mobile_sdhi_clk_enable() and sh_mobile_sdhi_clk_disable().

I think those functions should get the above if-blocks (without curly
braces) to ensure we always have consistent 00 or 11 settings.



signature.asc
Description: PGP signature


Re: [PATCH] ARM: dts: r7s72100: fix sdhi clock define

2017-01-17 Thread Wolfram Sang

> The reason is that would then keep me from having to modify the existing
> functions sh_mobile_sdhi_clk_enable/disable.

Why do you prefer this? I may be missing something but a small if-block
per function are not expensive IMO.

> Is anyone going to have an issue if I turn the card-detect clock on but never
> turn it off That was the patch that I was going to test out and submit.

It smells a bit hacky to me. And while hacky things are sometimes
needed, IMO this doesn't hold true here. With just 3 more lines (an
if-block in disable and a variable for the new clock) we can have it
proper.



signature.asc
Description: PGP signature


Re: [PATCH] ARM: dts: r7s72100: fix sdhi clock define

2017-01-17 Thread Wolfram Sang

> If we handle them as one, won't we miss card detect events due to the
> card detect clock being disabled while SDHI is idle?

You mean this?

1208 /*
1209  * While using internal tmio hardware logic for card detection, we 
need
1210  * to ensure it stays powered for it to work.
1211  */
1212 if (_host->native_hotplug)
1213 pm_runtime_get_noresume(>dev);




signature.asc
Description: PGP signature


[PATCH 0/3] mmc: host: tmio: sdio irq improvements

2017-01-19 Thread Wolfram Sang
Here is a small series with two minor improvements (patches 1+2) and one bigger
change (patch 3) for SDIO handling with TMIO/SDHI. Since RFC, I addressed all
comments (Thanks Simon!) and since it is needed for the WLAN cards, I think it
should go in now.


Wolfram Sang (3):
  mmc: host: tmio: refactor calls to sdio irq
  mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS
  mmc: tmio: discard obsolete SDIO irqs before enabling irqs

 drivers/mmc/host/sh_mobile_sdhi.c |  6 ++
 drivers/mmc/host/tmio_mmc.h   |  2 ++
 drivers/mmc/host/tmio_mmc_pio.c   | 20 ++--
 include/linux/mfd/tmio.h  |  6 ++
 4 files changed, 20 insertions(+), 14 deletions(-)

-- 
2.11.0



[PATCH v2 1/3] mmc: host: tmio: refactor calls to sdio irq

2017-01-19 Thread Wolfram Sang
tmio_mmc_sdio_irq() is not used as a seperate irq handler anymore, so we
can make it similar to the other irq helper functions, namely:

* only give the host as argument function which is what it really needs
* prefix function name with __

Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com>
Acked-by: Simon Horman <horms+rene...@verge.net.au>
---
 drivers/mmc/host/tmio_mmc_pio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index a140848049ed81..6ab43892c132a9 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -756,9 +756,8 @@ static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host 
*host,
return false;
 }
 
-static void tmio_mmc_sdio_irq(int irq, void *devid)
+static void __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
 {
-   struct tmio_mmc_host *host = devid;
struct mmc_host *mmc = host->mmc;
struct tmio_mmc_data *pdata = host->pdata;
unsigned int ireg, status;
@@ -799,7 +798,7 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
if (__tmio_mmc_sdcard_irq(host, ireg, status))
return IRQ_HANDLED;
 
-   tmio_mmc_sdio_irq(irq, devid);
+   __tmio_mmc_sdio_irq(host);
 
return IRQ_HANDLED;
 }
-- 
2.11.0



<    1   2   3   4   5   6   7   8   9   10   >