From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752087AbdAYRCK (ORCPT ); Wed, 25 Jan 2017 12:02:10 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:57112 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751550AbdAYRBa (ORCPT ); Wed, 25 Jan 2017 12:01:30 -0500 From: Thierry Escande To: Lee Jones Cc: Benson Leung , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] cros_ec: Fix deadlock when EC is not responsive at probe Date: Wed, 25 Jan 2017 18:01:13 +0100 Message-Id: <1485363674-25503-3-git-send-email-thierry.escande@collabora.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485363674-25503-1-git-send-email-thierry.escande@collabora.com> References: <1485363674-25503-1-git-send-email-thierry.escande@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset = "utf-8" Content-Transfert-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gwendal Grignou When the EC is not responsive at probe, we try to get basic information (protocol to use) later on through cros_xfer_cmd() call. This patch makes sure there is no deadlock when re-probing the EC by replacing call to cros_xfer_cmd() with send_command() in the function cros_ec_get_host_command_version_mask(). Also, this patch adds the function header indicating it must be called protected. Signed-off-by: Gwendal Grignou Signed-off-by: Thierry Escande --- drivers/platform/chrome/cros_ec_proto.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index 403649a..256249b 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -235,6 +235,22 @@ static int cros_ec_host_command_proto_query_v2(struct cros_ec_device *ec_dev) return ret; } +/* + * cros_ec_get_host_command_version_mask + * + * Get the version mask of a given command. + * + * @ec_dev: EC device to call + * @msg: message structure to use + * @cmd: command to get the version of. + * @mask: result when function returns 0. + * + * @return 0 on success, error code otherwise + * + * LOCKING: + * the caller has ec_dev->lock mutex or the caller knows there is + * no other command in progress. + */ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, u16 cmd, u32 *mask) { @@ -256,7 +272,7 @@ static int cros_ec_get_host_command_version_mask(struct cros_ec_device *ec_dev, pver = (struct ec_params_get_cmd_versions *)msg->data; pver->cmd = cmd; - ret = cros_ec_cmd_xfer(ec_dev, msg); + ret = send_command(ec_dev, msg); if (ret > 0) { rver = (struct ec_response_get_cmd_versions *)msg->data; *mask = rver->version_mask; -- 2.7.4