#
b8774d31 |
| 30-Jul-2024 |
Patryk Duda <patrykd@google.com> |
platform/chrome: cros_ec_proto: Lock device when updating MKBP version
commit df615907f1bf907260af01ccb904d0e9304b5278 upstream.
The cros_ec_get_host_command_version_mask() function requires that t
platform/chrome: cros_ec_proto: Lock device when updating MKBP version
commit df615907f1bf907260af01ccb904d0e9304b5278 upstream.
The cros_ec_get_host_command_version_mask() function requires that the caller must have ec_dev->lock mutex before calling it. This requirement was not met and as a result it was possible that two commands were sent to the device at the same time.
The problem was observed while using UART backend which doesn't use any additional locks, unlike SPI backend which locks the controller until response is received.
Fixes: f74c7557ed0d ("platform/chrome: cros_ec_proto: Update version on GET_NEXT_EVENT failure") Cc: stable@vger.kernel.org Signed-off-by: Patryk Duda <patrykd@google.com> Link: https://lore.kernel.org/r/20240730104425.607083-1-patrykd@google.com Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
#
f74c7557 |
| 02-Aug-2022 |
Patryk Duda <pdk@semihalf.com> |
platform/chrome: cros_ec_proto: Update version on GET_NEXT_EVENT failure
Some EC based devices (e.g. Fingerpint MCU) can jump to RO part of the firmware (intentionally or due to device reboot). The
platform/chrome: cros_ec_proto: Update version on GET_NEXT_EVENT failure
Some EC based devices (e.g. Fingerpint MCU) can jump to RO part of the firmware (intentionally or due to device reboot). The RO part doesn't change during the device lifecycle, so it won't support newer version of EC_CMD_GET_NEXT_EVENT command.
Function cros_ec_query_all() is responsible for finding maximum supported MKBP event version. It's usually called when the device is running RW part of the firmware, so the command version can be potentially higher than version supported by the RO.
The problem was fixed by updating maximum supported version when the device returns EC_RES_INVALID_VERSION (mapped to -ENOPROTOOPT). That way the kernel will use highest common version supported by RO and RW.
Fixes: 3300fdd630d4 ("platform/chrome: cros_ec: handle MKBP more events flag") Cc: <stable@vger.kernel.org> # 5.10+ Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Patryk Duda <pdk@semihalf.com> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220802154128.21175-1-pdk@semihalf.com
show more ...
|
#
3e1c715e |
| 18-Jul-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: return -EPROTO if empty payload
cros_ec_wait_until_complete() sends EC_CMD_GET_COMMS_STATUS which expects to receive sizeof(struct ec_response_get_comms_status) from
platform/chrome: cros_ec_proto: return -EPROTO if empty payload
cros_ec_wait_until_complete() sends EC_CMD_GET_COMMS_STATUS which expects to receive sizeof(struct ec_response_get_comms_status) from cros_ec_xfer_command().
Return -EPROTO if cros_ec_xfer_command() returns 0.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-11-tzungbi@kernel.org
show more ...
|
#
7f95d2b6 |
| 18-Jul-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: return -EAGAIN when retries timed out
While EC_COMMS_STATUS_PROCESSING flag is still on after it tries EC_COMMAND_RETRIES times for sending EC_CMD_GET_COMMS_STATUS, c
platform/chrome: cros_ec_proto: return -EAGAIN when retries timed out
While EC_COMMS_STATUS_PROCESSING flag is still on after it tries EC_COMMAND_RETRIES times for sending EC_CMD_GET_COMMS_STATUS, cros_ec_wait_until_complete() doesn't return an error code.
Return -EAGAIN in the case instead.
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220718050914.2267370-9-tzungbi@kernel.org
show more ...
|
#
0aad9aff |
| 18-Jul-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: separate cros_ec_wait_until_complete()
EC returns EC_RES_IN_PROGRESS if the host command needs more time to complete. Whenever receives the return code, cros_ec_send
platform/chrome: cros_ec_proto: separate cros_ec_wait_until_complete()
EC returns EC_RES_IN_PROGRESS if the host command needs more time to complete. Whenever receives the return code, cros_ec_send_command() sends EC_CMD_GET_COMMS_STATUS to query the command status.
Separate cros_ec_wait_until_complete() from cros_ec_send_command(). It sends EC_CMD_GET_COMMS_STATUS and waits until the previous command was completed, or encountered error, or timed out.
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220718050914.2267370-7-tzungbi@kernel.org
show more ...
|
#
810be30d |
| 18-Jul-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: separate cros_ec_xfer_command()
cros_ec_send_command() has extra logic to handle EC_RES_IN_PROGRESS. Separate the command transfer part into cros_ec_xfer_command() so
platform/chrome: cros_ec_proto: separate cros_ec_xfer_command()
cros_ec_send_command() has extra logic to handle EC_RES_IN_PROGRESS. Separate the command transfer part into cros_ec_xfer_command() so that other functions can re-use it.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-6-tzungbi@kernel.org
show more ...
|
#
d311664b |
| 18-Jul-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: add "cros_ec_" prefix to send_command()
To be neat, add "cros_ec_" prefix to static function send_command().
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-
platform/chrome: cros_ec_proto: add "cros_ec_" prefix to send_command()
To be neat, add "cros_ec_" prefix to static function send_command().
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-3-tzungbi@kernel.org
show more ...
|
#
203b2aff |
| 14-Jun-2022 |
Colin Ian King <colin.i.king@gmail.com> |
platform/chrome: cros_ec_proto: Fix spelling mistake "unknwon" -> "unknown"
There is a spelling mistake in a dev_dbg message. Fix it.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-o
platform/chrome: cros_ec_proto: Fix spelling mistake "unknwon" -> "unknown"
There is a spelling mistake in a dev_dbg message. Fix it.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220614064909.47804-1-colin.i.king@gmail.com
show more ...
|
#
cfed691b |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: handle empty payload in getting wake mask
cros_ec_get_host_event_wake_mask() expects to receive sizeof(struct ec_response_host_event_mask) from send_command(). The p
platform/chrome: cros_ec_proto: handle empty payload in getting wake mask
cros_ec_get_host_event_wake_mask() expects to receive sizeof(struct ec_response_host_event_mask) from send_command(). The payload is valid only if the return value is positive.
Return -EPROTO if send_command() returns 0 in cros_ec_get_host_event_wake_mask().
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-22-tzungbi@kernel.org
show more ...
|
#
d65da5f9 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: return 0 on getting wake mask success
cros_ec_get_host_event_wake_mask() used to return value from send_command() which is number of bytes for input payload on succes
platform/chrome: cros_ec_proto: return 0 on getting wake mask success
cros_ec_get_host_event_wake_mask() used to return value from send_command() which is number of bytes for input payload on success (i.e. sizeof(struct ec_response_host_event_mask)).
However, the callers don't need to know how many bytes are available.
Don't return number of available bytes. Instead, return 0 on success; otherwise, negative integers on error.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-20-tzungbi@kernel.org
show more ...
|
#
aac29b04 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: handle empty payload in getting cmd mask
cros_ec_get_host_command_version_mask() expects to receive sizeof(struct ec_response_get_cmd_versions) from send_command().
platform/chrome: cros_ec_proto: handle empty payload in getting cmd mask
cros_ec_get_host_command_version_mask() expects to receive sizeof(struct ec_response_get_cmd_versions) from send_command(). The payload is valid only if the return value is positive.
Return -EPROTO if send_command() returns 0 in cros_ec_get_host_command_version_mask().
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-19-tzungbi@kernel.org
show more ...
|
#
ec513489 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: check `msg->result` in getting cmd mask
cros_ec_get_host_command_version_mask() should check if EC wasn't happy by checking `msg->result`.
Use cros_ec_map_error() an
platform/chrome: cros_ec_proto: check `msg->result` in getting cmd mask
cros_ec_get_host_command_version_mask() should check if EC wasn't happy by checking `msg->result`.
Use cros_ec_map_error() and return the error code if any.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-17-tzungbi@kernel.org
show more ...
|
#
f91183aa |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: return 0 on getting cmd mask success
cros_ec_get_host_command_version_mask() used to return value from send_command() which is number of available bytes for input pay
platform/chrome: cros_ec_proto: return 0 on getting cmd mask success
cros_ec_get_host_command_version_mask() used to return value from send_command() which is number of available bytes for input payload on success (i.e. sizeof(struct ec_response_get_cmd_versions)).
However, the callers don't need to know how many bytes are available.
Don't return number of available bytes. Instead, return 0 on success; otherwise, negative integers on error.
Also remove the unneeded `ver_mask` initialization as the callers should take it only if cros_ec_get_host_command_version_mask() returns 0.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-15-tzungbi@kernel.org
show more ...
|
#
b36f0643 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: don't show MKBP version if unsupported
It wrongly showed the following message when it doesn't support MKBP: "MKBP support version 4294967295".
Fix it.
Reviewed-by:
platform/chrome: cros_ec_proto: don't show MKBP version if unsupported
It wrongly showed the following message when it doesn't support MKBP: "MKBP support version 4294967295".
Fix it.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-14-tzungbi@kernel.org
show more ...
|
#
d394ab5c |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: handle empty payload in getting info legacy
cros_ec_get_proto_info_legacy() expects to receive sizeof(struct ec_response_hello) from send_command(). The payload is v
platform/chrome: cros_ec_proto: handle empty payload in getting info legacy
cros_ec_get_proto_info_legacy() expects to receive sizeof(struct ec_response_hello) from send_command(). The payload is valid only if the return value is positive.
Return -EPROTO if send_command() returns 0 in cros_ec_get_proto_info_legacy().
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-13-tzungbi@kernel.org
show more ...
|
#
a88f7966 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info_legacy()
Rename cros_ec_host_command_proto_query_v2() to cros_ec_get_proto_info_legacy() and make it responsible for setting `ec_dev`
platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info_legacy()
Rename cros_ec_host_command_proto_query_v2() to cros_ec_get_proto_info_legacy() and make it responsible for setting `ec_dev` fields for EC protocol v2.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-11-tzungbi@kernel.org
show more ...
|
#
878c36f6 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: handle empty payload in getting proto info
cros_ec_get_proto_info() expects to receive sizeof(struct ec_response_get_protocol_info) from send_command(). The payload
platform/chrome: cros_ec_proto: handle empty payload in getting proto info
cros_ec_get_proto_info() expects to receive sizeof(struct ec_response_get_protocol_info) from send_command(). The payload is valid only if the return value is positive.
Return -EPROTO if send_command() returns 0 in cros_ec_get_proto_info().
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-10-tzungbi@kernel.org
show more ...
|
#
b4d0836e |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info()
Rename cros_ec_host_command_proto_query() to cros_ec_get_proto_info() and make it responsible for setting `ec_dev` fields according
platform/chrome: cros_ec_proto: separate cros_ec_get_proto_info()
Rename cros_ec_host_command_proto_query() to cros_ec_get_proto_info() and make it responsible for setting `ec_dev` fields according to the response protocol info.
Also make cros_ec_get_host_event_wake_mask() allocate its own message buffer. It was lucky that size of `struct ec_response_host_event_mask` is less than `struct ec_response_get_protocol_info`. Thus, the buffer wasn't overflow.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-8-tzungbi@kernel.org
show more ...
|
#
93bea2fa |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: use cros_ec_map_error()
Use cros_ec_map_error() in cros_ec_get_host_event_wake_mask().
The behavior of cros_ec_get_host_event_wake_mask() slightly changed. It is ac
platform/chrome: cros_ec_proto: use cros_ec_map_error()
Use cros_ec_map_error() in cros_ec_get_host_event_wake_mask().
The behavior of cros_ec_get_host_event_wake_mask() slightly changed. It is acceptable because the caller only needs it returns negative integers for indicating errors. Especially, the EC_RES_INVALID_COMMAND still maps to -EOPNOTSUPP.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-7-tzungbi@kernel.org
show more ...
|
#
8e399161 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: remove redundant NULL check
send_command() already checks if `ec_dev->pkt_xfer` is NULL. Remove the redundant check.
Reviewed-by: Guenter Roeck <groeck@chromium.org
platform/chrome: cros_ec_proto: remove redundant NULL check
send_command() already checks if `ec_dev->pkt_xfer` is NULL. Remove the redundant check.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-6-tzungbi@kernel.org
show more ...
|
#
e796c0c4 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: assign buffer size from protocol info
`din_size` is calculated from `ec_dev->max_response`. `ec_dev->max_response` is further calculated from the protocol info.
To m
platform/chrome: cros_ec_proto: assign buffer size from protocol info
`din_size` is calculated from `ec_dev->max_response`. `ec_dev->max_response` is further calculated from the protocol info.
To make it clear, assign `din_size` and `dout_size` from protocol info directly.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-5-tzungbi@kernel.org
show more ...
|
#
3db0c9e5 |
| 09-Jun-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: use macros for passthru indexes
Move passthru indexes for EC and PD devices to common header. Also use them instead of literal constants.
Reviewed-by: Guenter Roeck <groeck@chromi
platform/chrome: use macros for passthru indexes
Move passthru indexes for EC and PD devices to common header. Also use them instead of literal constants.
Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220609084957.3684698-4-tzungbi@kernel.org
show more ...
|
#
f87e15fb |
| 06-Jun-2022 |
Prashant Malani <pmalani@chromium.org> |
platform/chrome: cros_ec_proto: Update size arg types
cros_ec_cmd() takes 2 size arguments. Update them to be of the more appropriate type size_t.
Suggested-by: Stephen Boyd <swboyd@chromium.org> S
platform/chrome: cros_ec_proto: Update size arg types
cros_ec_cmd() takes 2 size arguments. Update them to be of the more appropriate type size_t.
Suggested-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220606201825.763788-4-pmalani@chromium.org
show more ...
|
#
b1d288d9 |
| 06-Jun-2022 |
Prashant Malani <pmalani@chromium.org> |
platform/chrome: cros_ec_proto: Rename cros_ec_command function
cros_ec_command() is the name of a function as well as a struct, as such it can confuse indexing tools (like ctags). Avoid this by ren
platform/chrome: cros_ec_proto: Rename cros_ec_command function
cros_ec_command() is the name of a function as well as a struct, as such it can confuse indexing tools (like ctags). Avoid this by renaming it to cros_ec_cmd(). Update all the callsites to use the new name.
This patch is a find-and-replace, so should not introduce any functional changes.
Suggested-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Prashant Malani <pmalani@chromium.org> Acked-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220606201825.763788-3-pmalani@chromium.org
show more ...
|
#
97b11dd6 |
| 18-May-2022 |
Tzung-Bi Shih <tzungbi@kernel.org> |
platform/chrome: cros_ec_proto: update cros_ec_check_result() comment
At first glance, cros_ec_check_result() is quite like cros_ec_map_error(). They check for `ec_msg->result` and return correspond
platform/chrome: cros_ec_proto: update cros_ec_check_result() comment
At first glance, cros_ec_check_result() is quite like cros_ec_map_error(). They check for `ec_msg->result` and return corresponding errors. However, as calling from `pkt_xfer` and `cmd_xfer`, cros_ec_check_result() should not report furthermore errors. -EAGAIN is the only exception.
See [1][2][3] for some known userland programs' code. The return code from ioctl only denotes the EC communication status. Userland programs would further analyze the `result` in struct cros_ec_command* for follow-up actions (e.g. [4]).
To clarify, update the function comment.
[1]: https://crrev.com/54400e93a75ef440a83d6eaac2cec066daf99cf0/util/comm-dev.c#154 [2]: https://crrev.com/fe32670a89bf59e1aff84bba9dd3295657b85e9b/cros_ec_dev.c#296 [3]: https://crrev.com/4e19eb1d89de0422ff1bbd3f7260b131c761098c/drivers/google/cros_ec_dev.c#120 [4]: https://crrev.com/54400e93a75ef440a83d6eaac2cec066daf99cf0/util/comm-dev.c#164
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Link: https://lore.kernel.org/r/20220518091814.2028579-4-tzungbi@kernel.org
show more ...
|