From patchwork Tue Nov 3 20:31:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 320506 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp4949206ilc; Tue, 3 Nov 2020 14:09:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1zLSvJduK9pgbF2AhFJ+AhXRkvQ0RKxdr+YVrJ8wOGkdfUBooK2xEZnGRrtkOtjW0ozNX X-Received: by 2002:a17:906:7805:: with SMTP id u5mr13012510ejm.379.1604441366180; Tue, 03 Nov 2020 14:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604441366; cv=none; d=google.com; s=arc-20160816; b=flcO/Q7ad7sN5Krz/zcC33+BmLqqBFCMJpEuQQrEDxOMNSIlqsFIJa+i5ixvipOW1r eW2ghbckrDOXxqpFHvW9YtVdtJ1fZhz7cj6NuHwnpZ7PSGJ9DJXof/kMoasAq/aUvwR2 EtP52oQp1FqKJWv3L2yZaPcqmyP3YDJF6oaiLwD3mwqExRJjt+7pgvF6wDyzE6RHyU9q hfrrRGp4bIBV6elgMHYhGrZTwRUpM2nzb4JjPj3kwddHpST9BNUBy2vG+tbZe+T8b00J bC8jKOEC1l+bREMyyPSik7uOaJInkjqi4676kYZdUcLfmkVac8qORVRumZuJAOOyIjC3 oYow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ik7x7mdndQ4JTUILU3WeRmXX+/FCwo4Oyu11hLh6lwU=; b=rXmEgmva58pPcjWgwYdgjERxBoIU1F6fbW4y+hqNx0qJUtJ1f5dHgJLm/U6WWrHQ3k GAub9Z9IOBTPeyS3V0KEnt1WbC54wtOqsf3pjpQyj8X8sinDF9wELIL/u+zNZIQEREUK cAP32t7koFcIGsaMVGLdaauoRWfA/RThLFM3TauTAuOJlC+TyRxJAHiVi88YijZpyxcb YAGGTeTwN4dli3tp+IqBF7IU8l/F7OgB19Cld4h4UtardAKMNclFZs88ayQ5CdWUT0AK LpGgV4WhEFraxuqOCB84Y6Svy0xGEnOaxYh7OoBwx1exvyP/A5kBTKdbsMsaNEo64QdG EYmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gJoFATXU; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si4653640edr.388.2020.11.03.14.09.25; Tue, 03 Nov 2020 14:09:26 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gJoFATXU; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729674AbgKCUjn (ORCPT + 15 others); Tue, 3 Nov 2020 15:39:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:48596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729926AbgKCUi1 (ORCPT ); Tue, 3 Nov 2020 15:38:27 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C42022226; Tue, 3 Nov 2020 20:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604435906; bh=VII72c+Xy9wwyEpRk7ysq7tztNFetVc9cUkEEF/I4l4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJoFATXURwvki2rjpfeVLda/LngUFGsQ+GUw+miS/6d3SRyLGXrLJdsaE0yRHhDYq cl5UI3JdODzbtGQuVkXc9s2yw5YsAYVXL4urqEvGBpLhX3jlcd9TVi4PRdKnHBw+9K NL87T9QZ9du+3H0B2KN8eanKKq+djhGAN4nE6cms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Etienne Carriere , Sudeep Holla , Sasha Levin Subject: [PATCH 5.9 017/391] firmware: arm_scmi: Add missing Rx size re-initialisation Date: Tue, 3 Nov 2020 21:31:08 +0100 Message-Id: <20201103203349.112565902@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sudeep Holla [ Upstream commit 9724722fde8f9bbd2b87340f00b9300c9284001e ] Few commands provide the list of description partially and require to be called consecutively until all the descriptors are fetched completely. In such cases, we don't release the buffers and reuse them for consecutive transmits. However, currently we don't reset the Rx size which will be set as per the response for the last transmit. This may result in incorrect response size being interpretted as the firmware may repond with size greater than the one set but we read only upto the size set by previous response. Let us reset the receive buffer size to max possible in such cases as we don't know the exact size of the response. Link: https://lore.kernel.org/r/20201012141746.32575-1-sudeep.holla@arm.com Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol") Reported-by: Etienne Carriere Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/base.c | 2 ++ drivers/firmware/arm_scmi/clock.c | 2 ++ drivers/firmware/arm_scmi/common.h | 2 ++ drivers/firmware/arm_scmi/driver.c | 8 ++++++++ drivers/firmware/arm_scmi/perf.c | 2 ++ drivers/firmware/arm_scmi/sensors.c | 2 ++ 6 files changed, 18 insertions(+) -- 2.27.0 diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c index 9853bd3c4d456..017e5d8bd869a 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -197,6 +197,8 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, protocols_imp[tot_num_ret + loop] = *(list + loop); tot_num_ret += loop_num_ret; + + scmi_reset_rx_to_maxsz(handle, t); } while (loop_num_ret); scmi_xfer_put(handle, t); diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 75e39882746e1..fa3ad3a150c36 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -192,6 +192,8 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id, } tot_rate_cnt += num_returned; + + scmi_reset_rx_to_maxsz(handle, t); /* * check for both returned and remaining to avoid infinite * loop due to buggy firmware diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index c113e578cc6ce..6db59a7ac8531 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -147,6 +147,8 @@ int scmi_do_xfer_with_response(const struct scmi_handle *h, struct scmi_xfer *xfer); int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id, size_t tx_size, size_t rx_size, struct scmi_xfer **p); +void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle, + struct scmi_xfer *xfer); int scmi_handle_put(const struct scmi_handle *handle); struct scmi_handle *scmi_handle_get(struct device *dev); void scmi_set_handle(struct scmi_device *scmi_dev); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 03ec74242c141..28a3e4902ea4e 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -402,6 +402,14 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) return ret; } +void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle, + struct scmi_xfer *xfer) +{ + struct scmi_info *info = handle_to_scmi_info(handle); + + xfer->rx.len = info->desc->max_msg_size; +} + #define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC) /** diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 3e1e87012c95b..3e8b548a12b62 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -304,6 +304,8 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain, } tot_opp_cnt += num_returned; + + scmi_reset_rx_to_maxsz(handle, t); /* * check for both returned and remaining to avoid infinite * loop due to buggy firmware diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 1af0ad362e823..4beee439b84ba 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -166,6 +166,8 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, } desc_index += num_returned; + + scmi_reset_rx_to_maxsz(handle, t); /* * check for both returned and remaining to avoid infinite * loop due to buggy firmware