]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
firmware: arm_scmi: Add missing Rx size re-initialisation
authorSudeep Holla <sudeep.holla@arm.com>
Mon, 12 Oct 2020 13:26:24 +0000 (14:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:43:12 +0000 (11:43 +0100)
[ 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 <etienne.carriere@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/arm_scmi/base.c
drivers/firmware/arm_scmi/clock.c
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c
drivers/firmware/arm_scmi/perf.c
drivers/firmware/arm_scmi/sensors.c

index f804e8af6521b9808a833830368776abddc81305..f986ee8919f0392dd1866036f45f75e938c8300f 100644 (file)
@@ -173,6 +173,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);
index 32526a793f3ace11cb5835cf336aea22aae53325..38400a8d0ca892ebf4260ed27face94dab1eab8d 100644 (file)
@@ -177,6 +177,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
index 5237c2ff79fea1dfce305a20542b3d3b9f17d5b6..9a680b9af9e586eb1d722826a862555f23dc1968 100644 (file)
@@ -103,6 +103,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);
index 3eb0382491cebbc973de870eda7fc43ec244eee2..11078199abed3c4ba76808099efa9ed36e056aa8 100644 (file)
@@ -481,6 +481,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)
 
 /**
index 601af4edad5e6de4597a1637d34d8f8f4fcafb4c..129a2887e964f327c5c5e9a0ab27b66f7159169d 100644 (file)
@@ -281,6 +281,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
index a400ea805fc236738047efc3dc351cfa79aed895..931208bc48f122623209edf16c1230e4853b74e4 100644 (file)
@@ -154,6 +154,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