Re: [PATCH] spi: rspi: fix the bug related to mount/remount jffs2

2017-02-12 Thread Hiep Cao Minh

Hi Geert,

Sorry to bother you!

qspi_transfer_in() does:

 while (n > 0) {
 len = qspi_set_receive_trigger(rspi, n);
 // len will be <= n

I agree. This is len = min value of n and 32.

 if (len == QSPI_BUFFER_SIZE) {
 // receive blocks of len bytes

Yes, This is len == 32 bytes

 ...
 } else {
 // receive n (not len) bytes

This is always n == len ( This case, len or n is always < 32)
Because this is the last n bytes should be received.


 ret = rspi_pio_transfer(rspi, NULL, rx, n);
 //
 if (ret < 0)
 return ret;
 // bogus write (which your patch removes: OK)
 *rx++ = ret;

I agree. This code needs to be removed.


 // here we should also return (see below why)
 // (in qspi_transfer_out() we should "break")
 }
 // Either we received a block of len bytes
 // or we received n bytes, and the below is wrong if len < n!
 n -= len;
 // If len was < n, n will be non-zero, and we will receive more
 // bytes in the next iteration

I am sorry, I don't understand your opinion here also.
The following is my opinion:

In case of receiving n bytes data > 32 bytes (Ex: n= 50bytes)
The first loop, n= 50,and  len = 32 bytes by getting min value of 50 and 
32 from qspi_set_receive_trigger()

(this case was n < len).
Then it receives 32 bytes in "if (len == QSPI_BUFFER_SIZE)" statement.
After received 32bytes of data, n -= len is implemented. It means n =(n 
- len) = (50-32)= 18 bytes.

The first loop finished.

The second loop, n=18 bytes, and len = 18 bytes by getting min value of 
32 and 18 from qspi_set_receive_trigger().
This time, 'else' statement would be implemented. *rx pointer was 
increased into rspi_pio_transfer()
After received the last 18 bytes of data into 'else' statement, n -=len 
was implemented again.

It means n = (n - len) = (18 -18) = 0 byte.
The second loop finished.

This time n = 0, Completed receiving data.

In case of receiving n bytes data < 32 bytes  (Ex: n= 20 bytes).
It's the same with the second loop above.

Thank you.
Hiep.




Re: [PATCH 1/2] tests: Add basic stress testing

2017-02-12 Thread Laurent Pinchart
On Monday 13 Feb 2017 01:25:29 Laurent Pinchart wrote:
> On Saturday 11 Feb 2017 14:43:05 Kieran Bingham wrote:
> > From: Kieran Bingham 
> > 
> > Duplicate the functionality of vsp-unit-test-0001, to provide a set of
> > work for the hardware to run, whilst we load the system using the
> > 'stress' utility.
> > 
> > Signed-off-by: Kieran Bingham 
> > ---
> > 
> >  tests/vsp-unit-test-0022.sh | 55 
> >  1 file changed, 55 insertions(+)
> >  create mode 100755 tests/vsp-unit-test-0022.sh
> > 
> > diff --git a/tests/vsp-unit-test-0022.sh b/tests/vsp-unit-test-0022.sh
> > new file mode 100755
> > index ..10230dffcc42
> > --- /dev/null
> > +++ b/tests/vsp-unit-test-0022.sh
> > @@ -0,0 +1,55 @@
> > +#!/bin/sh
> > +
> > +#
> > +# Test active pipeline, with high load on CPU/Memory/IO using 'stress'
> > +#
> > +# Test WPF packing in RGB mode. Use a RPF -> WPF pipeline with a fixed
> > ARGB32
> > +# format on the input and capture output frames in all RGB formats
> > supported
> > +# by the WPF.
> > +#
> > +
> > +source vsp-lib.sh
> > +
> > +features="rpf.0 wpf.0"
> > +formats="RGB332 ARGB555 XRGB555 RGB565 BGR24 RGB24 ABGR32 ARGB32 XBGR32
> > XRGB32"
> > +
> > +test_wpf_packing() {
> > +   test_start "WPF packing in $format during stress testing"
> > +
> > +   pipe_configure rpf-wpf 0 0
> > +   format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
> > +
> > +   vsp_runner rpf.0 &
> > +   vsp_runner wpf.0
> > +
> > +   local result=$(compare_frames)
> > +
> > +   test_complete $result
> > +}
> > +
> > +exists() { type -t "$1" > /dev/null 2>&1; }
> 
> Let's keep formatting consistent and not inline functions on a single line.
> Same comment for patch 2/2.
> 
> > +test_main() {
> > +   local format
> > +
> > +   if exists stress ; then
> > +   STRESS=`which stress`
> 
> I don't think this is needed, you can just execute stress below, it will be
> found from the $PATH. Same comment for patch 2/2.
> 
> No need to resend, I'll fix this while applying.
> 
> > +   else
> > +   echo "$0: Stress test requires utility 'stress'"
> > +   test_complete skip

Additionally, as you haven't called test_start() yet, you shouldn't called 
test_complete().

> > +   return
> > +   fi
> > +
> > +   # Start stressing the system, as a background task
> > +   $STRESS --cpu 8 --io 4 --vm 2 --vm-bytes 128M &
> > +
> > +   for format in $formats ; do
> > +   test_wpf_packing $format
> > +   done
> > +
> > +   # Recover the system. Stress launches multiple PIDs, so it's best to:
> > +   killall -9 stress
> > +}
> > +
> > +test_init $0 "$features"
> > +test_run

-- 
Regards,

Laurent Pinchart



Re: [PATCH 1/2] tests: Add basic stress testing

2017-02-12 Thread Laurent Pinchart
Hi Kieran,

Thank you for the patch.

On Saturday 11 Feb 2017 14:43:05 Kieran Bingham wrote:
> From: Kieran Bingham 
> 
> Duplicate the functionality of vsp-unit-test-0001, to provide a set of
> work for the hardware to run, whilst we load the system using the
> 'stress' utility.
> 
> Signed-off-by: Kieran Bingham 
> ---
>  tests/vsp-unit-test-0022.sh | 55 ++
>  1 file changed, 55 insertions(+)
>  create mode 100755 tests/vsp-unit-test-0022.sh
> 
> diff --git a/tests/vsp-unit-test-0022.sh b/tests/vsp-unit-test-0022.sh
> new file mode 100755
> index ..10230dffcc42
> --- /dev/null
> +++ b/tests/vsp-unit-test-0022.sh
> @@ -0,0 +1,55 @@
> +#!/bin/sh
> +
> +#
> +# Test active pipeline, with high load on CPU/Memory/IO using 'stress'
> +#
> +# Test WPF packing in RGB mode. Use a RPF -> WPF pipeline with a fixed
> ARGB32 +# format on the input and capture output frames in all RGB formats
> supported +# by the WPF.
> +#
> +
> +source vsp-lib.sh
> +
> +features="rpf.0 wpf.0"
> +formats="RGB332 ARGB555 XRGB555 RGB565 BGR24 RGB24 ABGR32 ARGB32 XBGR32
> XRGB32"
> +
> +test_wpf_packing() {
> + test_start "WPF packing in $format during stress testing"
> +
> + pipe_configure rpf-wpf 0 0
> + format_configure rpf-wpf 0 0 ARGB32 1024x768 $format
> +
> + vsp_runner rpf.0 &
> + vsp_runner wpf.0
> +
> + local result=$(compare_frames)
> +
> + test_complete $result
> +}
> +
> +exists() { type -t "$1" > /dev/null 2>&1; }

Let's keep formatting consistent and not inline functions on a single line. 
Same comment for patch 2/2.

> +test_main() {
> + local format
> +
> + if exists stress ; then
> + STRESS=`which stress`

I don't think this is needed, you can just execute stress below, it will be 
found from the $PATH. Same comment for patch 2/2.

No need to resend, I'll fix this while applying.

> + else
> + echo "$0: Stress test requires utility 'stress'"
> + test_complete skip
> + return
> + fi
> +
> + # Start stressing the system, as a background task
> + $STRESS --cpu 8 --io 4 --vm 2 --vm-bytes 128M &
> +
> + for format in $formats ; do
> + test_wpf_packing $format
> + done
> +
> + # Recover the system. Stress launches multiple PIDs, so it's best to:
> + killall -9 stress
> +}
> +
> +test_init $0 "$features"
> +test_run

-- 
Regards,

Laurent Pinchart



[PATCH] v4l: vsp1: Fix WPF U/V order in 3-planar formats on Gen3

2017-02-12 Thread Laurent Pinchart
The WPF U/V order bit has no effect for 3-planar formats on Gen3
hardware. Swap the U and V planes manually instead in that case.

Fixes: b915bd24a034 ("[media] v4l: vsp1: Add tri-planar memory formats support")
Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_wpf.c | 9 +
 1 file changed, 9 insertions(+)

This makes the vsp-unit-test-0002.sh test pass on both H2 and H3.

diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c 
b/drivers/media/platform/vsp1/vsp1_wpf.c
index 7c48f81cd5c1..052a83e2d489 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -216,6 +216,7 @@ static void wpf_configure(struct vsp1_entity *entity,
 
if (params == VSP1_ENTITY_PARAMS_PARTITION) {
const struct v4l2_pix_format_mplane *format = >format;
+   const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
struct vsp1_rwpf_memory mem = wpf->mem;
unsigned int flip = wpf->flip.active;
unsigned int width = source_format->width;
@@ -281,6 +282,14 @@ static void wpf_configure(struct vsp1_entity *entity,
}
}
 
+   /*
+* On Gen3 hardware the SPUVS bit has no effect on 3-planar
+* formats. Swap the U and V planes manually in that case.
+*/
+   if (vsp1->info->gen == 3 && format->num_planes == 3 &&
+   fmtinfo->swap_uv)
+   swap(mem.addr[1], mem.addr[2]);
+
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_Y, mem.addr[0]);
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C0, mem.addr[1]);
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C1, mem.addr[2]);
-- 
Regards,

Laurent Pinchart



Re: [PATCH v2 3/4] vsp-lib: Support RPF frame cropping

2017-02-12 Thread Laurent Pinchart
Hi Kieran,

Thank you for the patch.

On Friday 10 Feb 2017 13:30:07 Kieran Bingham wrote:
> From: Kieran Bingham 
> 
> Pass the optional '--crop (X,Y)/WxH' parameter through reference_frame
> allowing the input to be cropped for comparison
> 
> Signed-off-by: Kieran Bingham 
> ---
>  scripts/vsp-lib.sh | 52 +--
>  1 file changed, 42 insertions(+), 10 deletions(-)
> 
> diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
> index 9e5e57b8c4ba..d13e7b6cde31 100755
> --- a/scripts/vsp-lib.sh
> +++ b/scripts/vsp-lib.sh
> @@ -147,6 +147,9 @@ reference_frame() {
>   clu)
>   options="$options --clu $value"
>   ;;
> + crop)
> + options="$options --crop $value"
> + ;;
>   hflip)
>   [ x$value = x1 ] && options="$options --hflip"
>   ;;
> @@ -662,22 +665,51 @@ format_rpf_wpf() {
>   local infmt=$(format_v4l2_to_mbus $3)
>   local size=$4
>   local outfmt=$(format_v4l2_to_mbus $5)
> - local crop=$6
> + local rpfcrop=
> + local wpfcrop=
> + local rpfoutsize=
>   local outsize=
> + local option=
> +
> + __vsp_rpf_format=$3
> + __vsp_wpf_format=$5
> +
> + shift 5
> +
> + for option in $* ; do
> + case $option in
> + --rpfcrop=*)
> + rpfcrop=${option/--rpfcrop=/}
> + ;;
> +
> + --wpfcrop=*)
> + wpfcrop=${option/--wpfcrop=/}
> + ;;
> + *)
> + echo "format_rpf_wpf: Unrecognised arguments"

Let's also print the argument value to ease debugging.

> + return 1
> + ;;
> + esac
> + done
> 
> - if [ x$crop != 'x' ] ; then
> - crop="crop:$crop"
> - outsize=$(echo $crop | sed 's/.*\///')
> + if [ x$rpfcrop != 'x' ] ; then
> + rpfcrop="crop:$rpfcrop"
> + rpfoutsize=$(echo $rpfcrop | sed 's/.*\///')
>   else
> - outsize=$size
> + rpfoutsize=$size
>   fi
> 
> - $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size]"
> - $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$size $crop]"
> - $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
> + if [ x$wpfcrop != 'x' ] ; then
> + wpfcrop="crop:$wpfcrop"
> + outsize=$(echo $wpfcrop | sed 's/.*\///')
> + else
> + outsize=$rpfoutsize
> + fi
> 
> - __vsp_rpf_format=$3
> - __vsp_wpf_format=$5
> + $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size $rpfcrop]"
> + $mediactl -d $mdev -V "'$dev rpf.$rpf':1 [fmt:$infmt/$rpfoutsize]"
> + $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$rpfoutsize
> $wpfcrop]" +  $mediactl -d $mdev -V "'$dev wpf.$wpf':1
> [fmt:$outfmt/$outsize]" }
> 
>  format_wpf() {

-- 
Regards,

Laurent Pinchart



Re: [PATCH v2 2/4] gen-image: Implement option to parse an input crop

2017-02-12 Thread Laurent Pinchart
Hi Kieran,

Thank you for the patch.

On Friday 10 Feb 2017 13:30:06 Kieran Bingham wrote:
> From: Kieran Bingham 
> 
> Allow the user to specify an input crop in the form (X,Y)/WxH
> 
> Signed-off-by: Kieran Bingham 
> ---
>  src/gen-image.c | 132 +-
>  1 file changed, 132 insertions(+)
> 
> diff --git a/src/gen-image.c b/src/gen-image.c
> index 31d42e0211db..088e8b26f648 100644
> --- a/src/gen-image.c
> +++ b/src/gen-image.c
> @@ -95,6 +95,13 @@ struct format_info {
>   struct format_yuv_info yuv;
>  };
> 
> +struct image_rect {
> + int left;
> + int top;
> + unsigned int width;
> + unsigned int height;
> +};
> +
>  struct image {
>   const struct format_info *format;
>   unsigned int width;
> @@ -127,6 +134,8 @@ struct options {
>   bool rotate;
>   unsigned int compose;
>   struct params params;
> + bool crop;
> + struct image_rect inputcrop;
>  };
> 
>  /* 
> @@ -1076,6 +1085,25 @@ static void image_flip(const struct image *input,
> struct image *output, }
> 
>  /* 
> + * Image Cropping
> + */
> +
> +static void image_crop(const struct image *input, const struct image
> *output,
> +const struct image_rect *crop)
> +{
> + unsigned int offset = (crop->top * input->width + crop->left) * 3;
> + const uint8_t *idata = input->data + offset;
> + uint8_t *odata = output->data;
> + unsigned int y;
> +
> + for (y = 0; y < output->height; ++y) {
> + memcpy(odata, idata, output->width * 3);
> + odata += output->width * 3;
> + idata += input->width * 3;
> + }
> +}
> +
> +/* 
>   * Look Up Table
>   */
> 
> @@ -1363,6 +1391,21 @@ static int process(const struct options *options)
>   input = rgb;
>   }
> 
> + if (options->crop) {
> + struct image *cropped;
> +
> + cropped = image_new(input->format, options->inputcrop.width,
> + options->inputcrop.height);
> + if (!cropped) {
> + ret = -ENOMEM;
> + goto done;
> + }
> +
> + image_crop(input, cropped, >inputcrop);
> + image_delete(input);
> + input = cropped;
> + }
> +
>   /* Scale */
>   if (options->output_width && options->output_height) {
>   output_width = options->output_width;
> @@ -1596,6 +1639,7 @@ static void usage(const char *argv0)
>   printf("or percentages ([0%% - 100%%]). 
Defaults to 1.0\n");
>   printf("-c, --compose n Compose n copies of the image offset
> by (50,50) over a black background\n");
>   printf("-C, --no-chroma-average Disable chroma averaging for odd
> pixels on output\n");
> + printf("--crop (X,Y)/WxHCrop the input image\n");

The alignment is incorrect.

>   printf("-e, --encoding enc  Set the YCbCr encoding method. Valid
> values are\n");
>   printf("BT.601, REC.709, BT.2020 and
> SMPTE240M\n");
>   printf("-f, --format format Set the output image format\n");
> @@ -1628,11 +1672,13 @@ static void list_formats(void)
> 
>  #define OPT_HFLIP256
>  #define OPT_VFLIP257
> +#define OPT_CROP 260
> 
>  static struct option opts[] = {
>   {"alpha", 1, 0, 'a'},
>   {"clu", 1, 0, 'L'},
>   {"compose", 1, 0, 'c'},
> + {"crop", 1, 0, OPT_CROP},
>   {"encoding", 1, 0, 'e'},
>   {"format", 1, 0, 'f'},
>   {"help", 0, 0, 'h'},
> @@ -1649,6 +1695,84 @@ static struct option opts[] = {
>   {0, 0, 0, 0}
>  };
> 
> +static int parse_crop(struct image_rect *crop, char *optarg, char **endp)

The optarg argument should be made const. I would also rename it to value as 
it might not come from an option.

> +{
> + /* (X,Y)/WxH */
> + char *endptr = optarg;
> +
> + if (*endptr != '(') {
> + printf("Invalid crop argument\n");

How about "Invalid crop format, expected '('\n" to clearly indicate what's 
wrong ?

> + *endp = endptr;
> + return 1;
> + }
> +
> + crop->left = strtol(endptr + 1, , 10);
> + if (*endptr != ',') {
> + printf("Invalid crop position\n");
> + *endp = endptr;
> + return 1;
> + }
> +
> + if (crop->left < 0) {
> + printf("Invalid negative crop\n");
> + *endp = endptr - 1;
> + return 1;
> + }
> +
> + crop->top = strtol(endptr + 1, , 10);
> + if (*endptr != ')') {
> + printf("Invalid crop position\n");
> + *endp = endptr;
> + return 1;
> + }
> +
> + if (crop->top 

[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


[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 
---
 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 
---
 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 
---
 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



[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 
---
 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