ectool: fix console command

There are a few issues with console output:

1. The EC was returning more bytes than the message's insize. The
   reason stems from a refacotring that the set the global
   ec_max_insize  variables to 'EC_PROTO2_MAX_PARAM_SIZE - 8'.
   It really should be EC_PROTO2_MAX_PARAM_SIZE to cover the
   maximum packet size returned from the EC.

2. A change was made to handle EAGAIN returning from the EC kernel
   driver's ioctl() interface. That change prevented 0 bytes received
   from being returned properly.

The first issue occurs because the EC console is always larger than
what the original ec_max_insize was set to. This caused no console
messages to be displayed. The second issue causes the console command
to potentially loop forever because the drain of the EC console is
never indicated because 0 could never be returned.

BUG=chrome-os-partner:21165
BRANCH=falco,peppy
TEST=Built and can now read 'ectool console' output as well
     as not including gargabe.

Change-Id: I3114594f0020a5198532aa78ce126f4da6caf09a
Reviewed-on: https://gerrit.chromium.org/gerrit/63445
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Aaron Durbin
2013-07-25 21:17:13 -05:00
committed by ChromeBot
parent ac78e589af
commit 1b4c5cf71e

View File

@@ -49,7 +49,7 @@ static int ec_command_dev(int command, int version,
fprintf(stderr, "EC result %d\n", s_cmd.result);
}
return r ? r : s_cmd.insize;
return r;
}
static int ec_readmem_dev(int offset, int bytes, void *dest)
@@ -108,9 +108,13 @@ int comm_init_dev(void)
/*
* TODO: need a way to get this from the driver and EC. For now,
* pick a magic lowest common denominator value.
* pick a magic lowest common denominator value. The ec_max_outsize
* is set to handle v3 EC protocol. The ec_max_insize needs to be
* set to the largest value that can be returned from the EC,
* EC_PROTO2_MAX_PARAM_SIZE.
*/
ec_max_insize = ec_max_outsize = EC_PROTO2_MAX_PARAM_SIZE - 8;
ec_max_outsize = EC_PROTO2_MAX_PARAM_SIZE - 8;
ec_max_insize = EC_PROTO2_MAX_PARAM_SIZE;
return 0;
}