Skip to contentSkip to conversation

firmware: arm_scmi: always initialize protocols

PATCH Applied Etienne Carriere 3 participants 27 messages Oct 8, 2020 – Oct 13, 2020 System control & power/management interface (SCPI/SCMI) Message Protocol drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 firmware: arm_scmi: always initialize protocols

Remove the IDR replacement that prevent initializing an SCMI protocol when it has already been initialized. This is needed when there are several SCMI agents that do implement a given SCMI protocol unless what only the related SCMI protocol communication is initialized only for first probed agent.

---
 drivers/firmware/arm_scmi/bus.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/firmware/arm_scmi/bus.c +0 -9
index 1377ec76a45d..8ea04b069129 100644
@@ -60,11 +60,6 @@ static int scmi_protocol_init(int protocol_id, struct scmi_handle *handle)
 	return fn(handle);
 }
 
-static int scmi_protocol_dummy_init(struct scmi_handle *handle)
-{
-	return 0;
-}
-
 static int scmi_dev_probe(struct device *dev)
 {
 	struct scmi_driver *scmi_drv = to_scmi_driver(dev->driver);
@@ -83,10 +78,6 @@ static int scmi_dev_probe(struct device *dev)
 	if (ret)
 		return ret;
 
-	/* Skip protocol initialisation for additional devices */
-	idr_replace(&scmi_protocols, &scmi_protocol_dummy_init,
-		    scmi_dev->protocol_id);
-
 	return scmi_drv->probe(scmi_dev);
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/5 firmware: arm_scmi: fix transfer missing re-initialization

Implement helper function scmi_do_xfer_again() to process consecutive transfers that are initialized only once with scmi_xfer_get_init() and hence get the pool completion and responses message length not reloaded regarding last completed transfer.

---
 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  | 10 ++++++++++
 drivers/firmware/arm_scmi/perf.c    |  2 +-
 drivers/firmware/arm_scmi/sensors.c |  2 +-
 6 files changed, 16 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/base.c +1 -1
index 9853bd3c4d45..508f214baa1b 100644
@@ -183,7 +183,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
 		/* Set the number of protocols to be skipped/already read */
 		*num_skip = cpu_to_le32(tot_num_ret);
 
-		ret = scmi_do_xfer(handle, t);
+		ret = scmi_do_xfer_again(handle, t);
 		if (ret)
 			break;
 
drivers/firmware/arm_scmi/clock.c +1 -1
index c1cfe3ee3d55..9bb54c1a8d55 100644
@@ -161,7 +161,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
 		/* Set the number of rates to be skipped/already read */
 		clk_desc->rate_index = cpu_to_le32(tot_rate_cnt);
 
-		ret = scmi_do_xfer(handle, t);
+		ret = scmi_do_xfer_again(handle, t);
 		if (ret)
 			goto err;
 
drivers/firmware/arm_scmi/common.h +2 -0
index 37fb583f1bf5..6d4eea7b0f3e 100644
@@ -143,6 +143,8 @@ struct scmi_xfer {
 
 void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
 int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
+int scmi_do_xfer_again(const struct scmi_handle *handle,
+		       struct scmi_xfer *xfer);
 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,
drivers/firmware/arm_scmi/driver.c +10 -0
index c5dea87edf8f..887cb8249db0 100644
@@ -402,6 +402,16 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
 	return ret;
 }
 
+int scmi_do_xfer_again(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;
+	xfer->hdr.poll_completion = false;
+
+	return scmi_do_xfer(handle, xfer);
+}
+
 #define SCMI_MAX_RESPONSE_TIMEOUT	(2 * MSEC_PER_SEC)
 
 /**
drivers/firmware/arm_scmi/perf.c +1 -1
index ed475b40bd08..66d3d8459936 100644
@@ -281,7 +281,7 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain,
 		/* Set the number of OPPs to be skipped/already read */
 		dom_info->level_index = cpu_to_le32(tot_opp_cnt);
 
-		ret = scmi_do_xfer(handle, t);
+		ret = scmi_do_xfer_again(handle, t);
 		if (ret)
 			break;
 
drivers/firmware/arm_scmi/sensors.c +1 -1
index 9703cf6356a0..97addcf828a3 100644
@@ -134,7 +134,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
 		/* Set the number of sensors to be skipped/already read */
 		put_unaligned_le32(desc_index, t->tx.buf);
 
-		ret = scmi_do_xfer(handle, t);
+		ret = scmi_do_xfer_again(handle, t);
 		if (ret)
 			break;
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/5] firmware: arm_scmi: fix transfer missing re-initialization

Quoted 59 lines · Etienne Carriere

Implement helper function scmi_do_xfer_again() to process consecutive transfers that are initialized only once with scmi_xfer_get_init() and hence get the pool completion and responses message length not reloaded regarding last completed transfer.

---
 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  | 10 ++++++++++
 drivers/firmware/arm_scmi/perf.c    |  2 +-
 drivers/firmware/arm_scmi/sensors.c |  2 +-
 6 files changed, 16 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/base.c +1 -1
index 9853bd3c4d45..508f214baa1b 100644
@@ -183,7 +183,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
 		/* Set the number of protocols to be skipped/already read */
 		*num_skip = cpu_to_le32(tot_num_ret);
 
-		ret = scmi_do_xfer(handle, t);
+		ret = scmi_do_xfer_again(handle, t);
 		if (ret)
 			break;
 
drivers/firmware/arm_scmi/clock.c +1 -1
index c1cfe3ee3d55..9bb54c1a8d55 100644
@@ -161,7 +161,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
 		/* Set the number of rates to be skipped/already read */
 		clk_desc->rate_index = cpu_to_le32(tot_rate_cnt);
 
-		ret = scmi_do_xfer(handle, t);
+		ret = scmi_do_xfer_again(handle, t);
 		if (ret)
 			goto err;
 
drivers/firmware/arm_scmi/common.h +2 -0
index 37fb583f1bf5..6d4eea7b0f3e 100644
@@ -143,6 +143,8 @@ struct scmi_xfer {
 
 void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
 int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
+int scmi_do_xfer_again(const struct scmi_handle *handle,
+		       struct scmi_xfer *xfer);
 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,
drivers/firmware/arm_scmi/driver.c +0 -0
index c5dea87edf8f..887cb8249db0 100644

drivers/firmware/arm_scmi/driver.c int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) · line 409

Quoted 8 lines
drivers/firmware/arm_scmi/driver.c +5 -0
@@ -402,6 +402,16 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
 	return ret;
 }
 
+int scmi_do_xfer_again(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;

I am tempted to just have helper for above and use it where needed. Or may be I just don't like the name of the function, how about scmi_do_xfer_rxlen_reinit or anything else. Suggestions ?

drivers/firmware/arm_scmi/driver.c int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) · line 410

Quoted 1 line
drivers/firmware/arm_scmi/driver.c +1 -0
+	xfer->hdr.poll_completion = false;

Do we really need the above ?

Signature · 2 lines
Regards,
Sudeep
#3 lore raw

Re: [PATCH 2/5] firmware: arm_scmi: fix transfer missing re-initialization

Quoted 64 lines · Sudeep Holla
Quoted 62 lines · Etienne Carriere

Implement helper function scmi_do_xfer_again() to process consecutive transfers that are initialized only once with scmi_xfer_get_init() and hence get the pool completion and responses message length not reloaded regarding last completed transfer.

---
 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  | 10 ++++++++++
 drivers/firmware/arm_scmi/perf.c    |  2 +-
 drivers/firmware/arm_scmi/sensors.c |  2 +-
 6 files changed, 16 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/base.c +1 -1
index 9853bd3c4d45..508f214baa1b 100644
@@ -183,7 +183,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
              /* Set the number of protocols to be skipped/already read */
              *num_skip = cpu_to_le32(tot_num_ret);
 
-             ret = scmi_do_xfer(handle, t);
+             ret = scmi_do_xfer_again(handle, t);
              if (ret)
                      break;
 
drivers/firmware/arm_scmi/clock.c +1 -1
index c1cfe3ee3d55..9bb54c1a8d55 100644
@@ -161,7 +161,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
              /* Set the number of rates to be skipped/already read */
              clk_desc->rate_index = cpu_to_le32(tot_rate_cnt);
 
-             ret = scmi_do_xfer(handle, t);
+             ret = scmi_do_xfer_again(handle, t);
              if (ret)
                      goto err;
 
drivers/firmware/arm_scmi/common.h +2 -0
index 37fb583f1bf5..6d4eea7b0f3e 100644
@@ -143,6 +143,8 @@ struct scmi_xfer {
 
 void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
 int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
+int scmi_do_xfer_again(const struct scmi_handle *handle,
+                    struct scmi_xfer *xfer);
 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,
drivers/firmware/arm_scmi/driver.c +0 -0
index c5dea87edf8f..887cb8249db0 100644
@@ -402,6 +402,16 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
      return ret;
 }
 
Quoted 9 lines

drivers/firmware/arm_scmi/driver.c int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) · line 409

Quoted 5 lines
drivers/firmware/arm_scmi/driver.c +5 -0
+int scmi_do_xfer_again(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;

I am tempted to just have helper for above and use it where needed. Or may be I just don't like the name of the function, how about scmi_do_xfer_rxlen_reinit or anything else. Suggestions ?

I think a smoother way would be that scmi_do_xfer() initializes both
xfer->rx.len = info->desc->max_msg_size
and
xfer->hdr.poll_completion = false
instead of doing that from scmi_xfer_get_init().

Quoted 4 lines

drivers/firmware/arm_scmi/driver.c int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) · line 410

Quoted 2 lines
drivers/firmware/arm_scmi/driver.c +1 -0
+     xfer->hdr.poll_completion = false;

Do we really need the above ?

I think so. Once a transfer is completed, poll_completion is true. But the next transfer we expect should start assuming completion is not yet done, hence this reset to false.

Regards,
Etienne

Quoted 4 lines

--
Regards,
Sudeep

#4 lore raw

Re: [PATCH 2/5] firmware: arm_scmi: fix transfer missing re-initialization

Quoted 75 lines · Etienne Carriere
Quoted 64 lines · Sudeep Holla
Quoted 62 lines · Etienne Carriere

Implement helper function scmi_do_xfer_again() to process consecutive transfers that are initialized only once with scmi_xfer_get_init() and hence get the pool completion and responses message length not reloaded regarding last completed transfer.

---
 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  | 10 ++++++++++
 drivers/firmware/arm_scmi/perf.c    |  2 +-
 drivers/firmware/arm_scmi/sensors.c |  2 +-
 6 files changed, 16 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/base.c +1 -1
index 9853bd3c4d45..508f214baa1b 100644
@@ -183,7 +183,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
              /* Set the number of protocols to be skipped/already read */
              *num_skip = cpu_to_le32(tot_num_ret);
 
-             ret = scmi_do_xfer(handle, t);
+             ret = scmi_do_xfer_again(handle, t);
              if (ret)
                      break;
 
drivers/firmware/arm_scmi/clock.c +1 -1
index c1cfe3ee3d55..9bb54c1a8d55 100644
@@ -161,7 +161,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
              /* Set the number of rates to be skipped/already read */
              clk_desc->rate_index = cpu_to_le32(tot_rate_cnt);
 
-             ret = scmi_do_xfer(handle, t);
+             ret = scmi_do_xfer_again(handle, t);
              if (ret)
                      goto err;
 
drivers/firmware/arm_scmi/common.h +2 -0
index 37fb583f1bf5..6d4eea7b0f3e 100644
@@ -143,6 +143,8 @@ struct scmi_xfer {
 
 void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
 int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
+int scmi_do_xfer_again(const struct scmi_handle *handle,
+                    struct scmi_xfer *xfer);
 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,
drivers/firmware/arm_scmi/driver.c +0 -0
index c5dea87edf8f..887cb8249db0 100644
@@ -402,6 +402,16 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
      return ret;
 }
 
Quoted 9 lines

drivers/firmware/arm_scmi/driver.c int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) · line 409

Quoted 5 lines
drivers/firmware/arm_scmi/driver.c +5 -0
+int scmi_do_xfer_again(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;

I am tempted to just have helper for above and use it where needed. Or may be I just don't like the name of the function, how about scmi_do_xfer_rxlen_reinit or anything else. Suggestions ?

Quoted 3 lines

I think a smoother way would be that scmi_do_xfer() initializes both
xfer->rx.len = info->desc->max_msg_size

Possibly

Quoted 10 lines

and
xfer->hdr.poll_completion = false
instead of doing that from scmi_xfer_get_init().

Quoted 4 lines

drivers/firmware/arm_scmi/driver.c int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) · line 410

Quoted 2 lines
drivers/firmware/arm_scmi/driver.c +1 -0
+     xfer->hdr.poll_completion = false;

Do we really need the above ?

I think so. Once a transfer is completed, poll_completion is true.

Where and how ? By default it is always false and it can be set to true only by perf set/get calls. So I still see no need for this.

Signature · 2 lines
Regards,
Sudeep
#5 lore raw

PATCH 1/1 firmware: arm_scmi: Add missing Rx size re-initialisation

In reply to Etienne Carriere

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.

Fixes b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol")
---
 drivers/firmware/arm_scmi/base.c    | 2 ++
 drivers/firmware/arm_scmi/clock.c   | 2 ++
 drivers/firmware/arm_scmi/common.h  | 8 ++++++++
 drivers/firmware/arm_scmi/perf.c    | 2 ++
 drivers/firmware/arm_scmi/sensors.c | 2 ++
 5 files changed, 16 insertions(+)

Hi Etienne,

I reworked this in a different way and hence dropped your authorship and added reported by. If you prefer I can attribute you as author. I want to push 2,4,5/5 as fixes and hence the rush.

Regards,
Sudeep

drivers/firmware/arm_scmi/base.c +2 -0
index 9853bd3c4d45..017e5d8bd869 100644
@@ -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);
drivers/firmware/arm_scmi/clock.c +2 -0
index c1cfe3ee3d55..4645677d86f1 100644
@@ -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
drivers/firmware/arm_scmi/common.h +8 -0
index 37fb583f1bf5..a3f1bc44b1de 100644
@@ -245,6 +245,14 @@ extern const struct scmi_desc scmi_mailbox_desc;
 extern const struct scmi_desc scmi_smc_desc;
 #endif
 
+static inline 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;
+}
+
 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
 void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
 
drivers/firmware/arm_scmi/perf.c +2 -0
index ed475b40bd08..82fb3babff72 100644
@@ -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
drivers/firmware/arm_scmi/sensors.c +2 -0
index 9703cf6356a0..b4232d611033 100644
@@ -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
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH] firmware: arm_scmi: Add missing Rx size re-initialisation

Quoted 26 lines · Sudeep Holla

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.

Fixes b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol")
---
 drivers/firmware/arm_scmi/base.c    | 2 ++
 drivers/firmware/arm_scmi/clock.c   | 2 ++
 drivers/firmware/arm_scmi/common.h  | 8 ++++++++
 drivers/firmware/arm_scmi/perf.c    | 2 ++
 drivers/firmware/arm_scmi/sensors.c | 2 ++
 5 files changed, 16 insertions(+)
Quoted 5 lines

Hi Etienne,

I reworked this in a different way and hence dropped your authorship and added reported by. If you prefer I can attribute you as author. I want to push 2,4,5/5 as fixes and hence the rush.

Hi Sudeep,

Tags are fine like that.
As for the content, it looks good to me.
When trying to apply this, I failed, but I guess I'm not testing over the same kernel tree/branch as you.
All in one, I am really fine with this change, I think it does the job

Regards,
Etienne

Quoted 78 lines

Regards,
Sudeep

drivers/firmware/arm_scmi/base.c +2 -0
index 9853bd3c4d45..017e5d8bd869 100644
@@ -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);
drivers/firmware/arm_scmi/clock.c +2 -0
index c1cfe3ee3d55..4645677d86f1 100644
@@ -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
drivers/firmware/arm_scmi/common.h +8 -0
index 37fb583f1bf5..a3f1bc44b1de 100644
@@ -245,6 +245,14 @@ extern const struct scmi_desc scmi_mailbox_desc;
 extern const struct scmi_desc scmi_smc_desc;
 #endif
 
+static inline 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;
+}
+
 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
 void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
 
drivers/firmware/arm_scmi/perf.c +2 -0
index ed475b40bd08..82fb3babff72 100644
@@ -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
drivers/firmware/arm_scmi/sensors.c +2 -1
index 9703cf6356a0..b4232d611033 100644
@@ -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
--

2.17.1

#7 lore raw

Re: [PATCH] firmware: arm_scmi: Add missing Rx size re-initialisation

Quoted 29 lines · Etienne Carriere
Quoted 28 lines · Sudeep Holla

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.

Fixes b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol")
---
 drivers/firmware/arm_scmi/base.c    | 2 ++
 drivers/firmware/arm_scmi/clock.c   | 2 ++
 drivers/firmware/arm_scmi/common.h  | 8 ++++++++
 drivers/firmware/arm_scmi/perf.c    | 2 ++
 drivers/firmware/arm_scmi/sensors.c | 2 ++
 5 files changed, 16 insertions(+)

Hi Etienne,

Quoted 8 lines
Quoted 3 lines

I reworked this in a different way and hence dropped your authorship and added reported by. If you prefer I can attribute you as author. I want to push 2,4,5/5 as fixes and hence the rush.

Hi Sudeep,

Tags are fine like that.
As for the content, it looks good to me.

Thanks.

Quoted 2 lines

When trying to apply this, I failed, but I guess I'm not testing over the same kernel tree/branch as you.

Ah OK. I wasn't sure if we had touch code around these recently. Anyway, I have all these on my for-next/scmi[1][2]

--
Regards,
Sudeep

[1] https://git.kernel.org/sudeep.holla/linux/h/for-next/scmi
[2] git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git for-next/scmi

Quoted 83 lines

All in one, I am really fine with this change, I think it does the job

Regards,
Etienne

Quoted 78 lines

Regards,
Sudeep

drivers/firmware/arm_scmi/base.c +2 -0
index 9853bd3c4d45..017e5d8bd869 100644
@@ -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);
drivers/firmware/arm_scmi/clock.c +2 -0
index c1cfe3ee3d55..4645677d86f1 100644
@@ -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
drivers/firmware/arm_scmi/common.h +8 -0
index 37fb583f1bf5..a3f1bc44b1de 100644
@@ -245,6 +245,14 @@ extern const struct scmi_desc scmi_mailbox_desc;
 extern const struct scmi_desc scmi_smc_desc;
 #endif
 
+static inline 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;
+}
+
 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
 void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
 
drivers/firmware/arm_scmi/perf.c +2 -0
index ed475b40bd08..82fb3babff72 100644
@@ -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
drivers/firmware/arm_scmi/sensors.c +2 -1
index 9703cf6356a0..b4232d611033 100644
@@ -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
--

2.17.1

Applied
#8 lore raw

Re: [PATCH] firmware: arm_scmi: Add missing Rx size re-initialisation

In reply to Sudeep Holla
Quoted 5 lines · Sudeep Holla

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.

Quoted 9 lines

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.

Applied to sudeep.holla/linux (for-next/scmi), thanks!

[PATCH] firmware: arm_scmi: Add missing Rx size re-initialisation

	https://git.kernel.org/sudeep.holla/c/9724722fde

--
Regards,
Sudeep

#9 lore raw

PATCH 3/5 firmware: arm_scmi: add config dependency for smc transport

In reply to Etienne Carriere

Fix dependencies for configuration switch ARM_SCMI_PROTOCOL that is not exclusively dependent on MAILBOX since the alternate smc transport that is depends on HAVE_ARM_SMCCC_DISCOVERY since [1].

Link [1] d76428237784 ("firmware: arm_scmi: Use HAVE_ARM_SMCCC_DISCOVERY instead of ARM_PSCI_FW")
---
 drivers/firmware/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/Kconfig +1 -1
index 3315e3c21586..5bdd411206ff 100644
@@ -9,7 +9,7 @@ menu "Firmware Drivers"
 config ARM_SCMI_PROTOCOL
 	tristate "ARM System Control and Management Interface (SCMI) Message Protocol"
 	depends on ARM || ARM64 || COMPILE_TEST
-	depends on MAILBOX
+	depends on MAILBOX || HAVE_ARM_SMCCC_DISCOVERY
 	help
 	  ARM System Control and Management Interface (SCMI) protocol is a
 	  set of operating system-independent software interfaces that are
Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH 3/5] firmware: arm_scmi: add config dependency for smc transport

Quoted 4 lines · Etienne Carriere

Fix dependencies for configuration switch ARM_SCMI_PROTOCOL that is not exclusively dependent on MAILBOX since the alternate smc transport that is depends on HAVE_ARM_SMCCC_DISCOVERY since [1].

Do you need any build issues ? I don't see why this is needed.

Signature · 2 lines
Regards,
Sudeep
#11 lore raw

Re: [PATCH 3/5] firmware: arm_scmi: add config dependency for smc transport

Quoted 9 lines · Sudeep Holla
Quoted 4 lines · Etienne Carriere

Fix dependencies for configuration switch ARM_SCMI_PROTOCOL that is not exclusively dependent on MAILBOX since the alternate smc transport that is depends on HAVE_ARM_SMCCC_DISCOVERY since [1].

Do you need any build issues ? I don't see why this is needed.

This change is for consistency of the kernel configuration. Without this change, a kernel configured without CONFIG_MAILBOX cannot embed SCMI support even is using only the SMC transport enabled thanks to HAVE_ARM_SMCCC_DISCOVERY.

Regards,
Etienne

Quoted 3 lines

--
Regards,
Sudeep

#12 lore raw

Re: [PATCH 3/5] firmware: arm_scmi: add config dependency for smc transport

Quoted 8 lines · Etienne Carriere
Quoted 7 lines · Sudeep Holla
Quoted 4 lines · Etienne Carriere

Fix dependencies for configuration switch ARM_SCMI_PROTOCOL that is not exclusively dependent on MAILBOX since the alternate smc transport that is depends on HAVE_ARM_SMCCC_DISCOVERY since [1].

Quoted 8 lines
Quoted 2 lines

Do you need any build issues ? I don't see why this is needed.

This change is for consistency of the kernel configuration. Without this change, a kernel configured without CONFIG_MAILBOX cannot embed SCMI support even is using only the SMC transport enabled thanks to HAVE_ARM_SMCCC_DISCOVERY.

Fair enough, however instead of adding to the list for each added transport we need to do better transport abstraction now that we have multiple. I don't see this as critical, let me know if you disagree.

Signature · 2 lines
Regards,
Sudeep
#13 lore raw

Re: [PATCH 3/5] firmware: arm_scmi: add config dependency for smc transport

Quoted 19 lines · Sudeep Holla
Quoted 8 lines · Etienne Carriere
Quoted 7 lines · Sudeep Holla
Quoted 4 lines · Etienne Carriere

Fix dependencies for configuration switch ARM_SCMI_PROTOCOL that is not exclusively dependent on MAILBOX since the alternate smc transport that is depends on HAVE_ARM_SMCCC_DISCOVERY since [1].

Quoted 8 lines
Quoted 2 lines

Do you need any build issues ? I don't see why this is needed.

This change is for consistency of the kernel configuration. Without this change, a kernel configured without CONFIG_MAILBOX cannot embed SCMI support even is using only the SMC transport enabled thanks to HAVE_ARM_SMCCC_DISCOVERY.

Quoted 3 lines

Fair enough, however instead of adding to the list for each added transport we need to do better transport abstraction now that we have multiple. I don't see this as critical, let me know if you disagree.

Not critical, I agree :)

etienne

Quoted 4 lines

--
Regards,
Sudeep

#14 lore raw

PATCH 4/5 firmware: arm_scmi: smc transport supports multi-message pool

In reply to Etienne Carriere

There is no reason for the smc transport to restrict itself to a 1 message pool. More can be allocated, messages are copied from/to the shared memory only on SMC exit/entry hence SCMI driver can play with several messages.

Use value of 20 to mimic mailbox transport implementation. Any high value could fit. This should be something configurable.

---
 drivers/firmware/arm_scmi/smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_scmi/smc.c +1 -1
index 1a03c3ec0230..82a82a5dc86a 100644
@@ -149,6 +149,6 @@ static const struct scmi_transport_ops scmi_smc_ops = {
 const struct scmi_desc scmi_smc_desc = {
 	.ops = &scmi_smc_ops,
 	.max_rx_timeout_ms = 30,
-	.max_msg = 1,
+	.max_msg = 20,
 	.max_msg_size = 128,
 };
Signature · 1 line
2.17.1
#15 lore raw

Re: [PATCH 4/5] firmware: arm_scmi: smc transport supports multi-message pool

Quoted 6 lines · Etienne Carriere

There is no reason for the smc transport to restrict itself to a 1 message pool. More can be allocated, messages are copied from/to the shared memory only on SMC exit/entry hence SCMI driver can play with several messages.

Use value of 20 to mimic mailbox transport implementation.

What is the need to mimic ?

Quoted 1 line

Any high value could fit. This should be something configurable.

Why not 10 or 100 ? I see any value other than 1 is useless as we lock the channel in send_message and we don't maintain a queue like mailbox.

Signature · 2 lines
Regards,
Sudeep
#16 lore raw

Re: [PATCH 4/5] firmware: arm_scmi: smc transport supports multi-message pool

Quoted 10 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

There is no reason for the smc transport to restrict itself to a 1 message pool. More can be allocated, messages are copied from/to the shared memory only on SMC exit/entry hence SCMI driver can play with several messages.

Use value of 20 to mimic mailbox transport implementation.

What is the need to mimic ?

I had to pick a value. I can't say whether 2, 5 or 20 is better. I looks how the mailbox transport did and used the same value as it seemed reasonable regarding its memory cost.

Quoted 5 lines
Quoted 2 lines

Any high value could fit. This should be something configurable.

Why not 10 or 100 ? I see any value other than 1 is useless as we lock the channel in send_message and we don't maintain a queue like mailbox.

I'll check again.
Playing with SCMI voltage domain [1], it happens that I needed several preallocated
message buffers unless what regulators fail to be probed.

[1] https://lkml.org/lkml/2020/10/5/1341

Regards,
etienne

Quoted 4 lines

--
Regards,
Sudeep

#17 lore raw

Re: [PATCH 4/5] firmware: arm_scmi: smc transport supports multi-message pool

Quoted 17 lines · Etienne Carriere
Quoted 10 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

There is no reason for the smc transport to restrict itself to a 1 message pool. More can be allocated, messages are copied from/to the shared memory only on SMC exit/entry hence SCMI driver can play with several messages.

Use value of 20 to mimic mailbox transport implementation.

What is the need to mimic ?

I had to pick a value. I can't say whether 2, 5 or 20 is better. I looks how the mailbox transport did and used the same value as it seemed reasonable regarding its memory cost.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Any high value could fit. This should be something configurable.

Why not 10 or 100 ? I see any value other than 1 is useless as we lock the channel in send_message and we don't maintain a queue like mailbox.

I'll check again.
Playing with SCMI voltage domain [1], it happens that I needed several preallocated message buffers unless what regulators fail to be probed.

I may be missing something but I can't see how, we simply block in send_message while mailbox has a queue of 20 which is why it has 20 there.

The issue you are seeing could be different. Let me know if I am missing something.

Signature · 2 lines
Regards,
Sudeep
#18 lore raw

Re: [PATCH 4/5] firmware: arm_scmi: smc transport supports multi-message pool

Quoted 28 lines · Sudeep Holla
Quoted 17 lines · Etienne Carriere
Quoted 10 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

There is no reason for the smc transport to restrict itself to a 1 message pool. More can be allocated, messages are copied from/to the shared memory only on SMC exit/entry hence SCMI driver can play with several messages.

Use value of 20 to mimic mailbox transport implementation.

What is the need to mimic ?

I had to pick a value. I can't say whether 2, 5 or 20 is better. I looks how the mailbox transport did and used the same value as it seemed reasonable regarding its memory cost.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Any high value could fit. This should be something configurable.

Why not 10 or 100 ? I see any value other than 1 is useless as we lock the channel in send_message and we don't maintain a queue like mailbox.

I'll check again.
Playing with SCMI voltage domain [1], it happens that I needed several preallocated message buffers unless what regulators fail to be probed.

Quoted 6 lines

I may be missing something but I can't see how, we simply block in send_message while mailbox has a queue of 20 which is why it has 20 there.

The issue you are seeing could be different. Let me know if I am missing something.

OK, I gave this some thought and realise that in-order to allow multiple requests simultaneously, we do need this value > 1. I will take this and make some tweaks to the commit log to indicate the same.

Signature · 2 lines
Regards,
Sudeep
#19 lore raw

Re: [PATCH 4/5] firmware: arm_scmi: smc transport supports multi-message pool

Quoted 33 lines · Sudeep Holla
Quoted 31 lines · Sudeep Holla
Quoted 17 lines · Etienne Carriere
Quoted 10 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

There is no reason for the smc transport to restrict itself to a 1 message pool. More can be allocated, messages are copied from/to the shared memory only on SMC exit/entry hence SCMI driver can play with several messages.

Use value of 20 to mimic mailbox transport implementation.

What is the need to mimic ?

I had to pick a value. I can't say whether 2, 5 or 20 is better. I looks how the mailbox transport did and used the same value as it seemed reasonable regarding its memory cost.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Any high value could fit. This should be something configurable.

Why not 10 or 100 ? I see any value other than 1 is useless as we lock the channel in send_message and we don't maintain a queue like mailbox.

I'll check again.
Playing with SCMI voltage domain [1], it happens that I needed several preallocated message buffers unless what regulators fail to be probed.

I may be missing something but I can't see how, we simply block in send_message while mailbox has a queue of 20 which is why it has 20 there.

Quoted 8 lines
Quoted 3 lines

The issue you are seeing could be different. Let me know if I am missing something.

OK, I gave this some thought and realise that in-order to allow multiple requests simultaneously, we do need this value > 1. I will take this and make some tweaks to the commit log to indicate the same.

Thanks for the feedback.
I planned to look back which value would really make sense. Whatever, feel free to tweak or change this proposal.

Regards,
etienne

Quoted 3 lines

--
Regards,
Sudeep

#20 lore raw

PATCH 5/5 firmware: arm_scmi: fix ARCH_COLD_RESET

In reply to Etienne Carriere

Fix ARCH_COLD_RESET according to SCMI specification.

---
 drivers/firmware/arm_scmi/reset.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/arm_scmi/reset.c +1 -3
index f063cfe17e02..a981a22cfe89 100644
@@ -36,9 +36,7 @@ struct scmi_msg_reset_domain_reset {
 #define EXPLICIT_RESET_ASSERT	BIT(1)
 #define ASYNCHRONOUS_RESET	BIT(2)
 	__le32 reset_state;
-#define ARCH_RESET_TYPE		BIT(31)
-#define COLD_RESET_STATE	BIT(0)
-#define ARCH_COLD_RESET		(ARCH_RESET_TYPE | COLD_RESET_STATE)
+#define ARCH_COLD_RESET		0
 };
 
 struct scmi_msg_reset_notify {
Signature · 1 line
2.17.1
#21 lore raw

Re: [PATCH 5/5] firmware: arm_scmi: fix ARCH_COLD_RESET

Quoted 2 lines · Etienne Carriere

Fix ARCH_COLD_RESET according to SCMI specification.

Thanks, nice catch.
I will send this as fix after v5.10-rc1 with fixes tag

Fixes 95a15d80aa0d ("firmware: arm_scmi: Add RESET protocol in SCMI v2.0")
Signature · 2 lines
Regards,
Sudeep
#22 lore raw
In reply to Etienne Carriere
Quoted 6 lines · Etienne Carriere

Remove the IDR replacement that prevent initializing an SCMI protocol when it has already been initialized. This is needed when there are several SCMI agents that do implement a given SCMI protocol unless what only the related SCMI protocol communication is initialized only for first probed agent.

Can you please elaborate on your usecase please. What do you mean by several SCMI agents here. OSPM is the only agent we are interested here. What other agents is this driver supposed to handle here. We allocate memory in init and calling init multiple times messes up the allocated and initialised structures.

So NACK for this patch as it needs more work if we need this at all.

Signature · 2 lines
Regards,
Sudeep
#23 lore raw
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

Remove the IDR replacement that prevent initializing an SCMI protocol when it has already been initialized. This is needed when there are several SCMI agents that do implement a given SCMI protocol unless what only the related SCMI protocol communication is initialized only for first probed agent.

Quoted 8 lines

Can you please elaborate on your usecase please. What do you mean by several SCMI agents here. OSPM is the only agent we are interested here. What other agents is this driver supposed to handle here. We allocate memory in init and calling init multiple times messes up the allocated and initialised structures.

So NACK for this patch as it needs more work if we need this at all.

Hello Sudeep,

Considering a device with several SCMI servers spread over several co-processor and possibly also in the Arm TZ secure world, each of these servers uses a specific
SCMI channel. Without this change, each SCMI protocol gets initialized only for the
first agent device that is probed.

My setup is also a bit specific. My device has several secure configuration features that can individually be enabled or not. For example, configuring domain X as secure makes some clocks reachable by Linux only through SCMI, and configuring domain Y as secure makes other clocks reachable by Linux only through SCMI. For flexibility, I expose domain X resources (here clocks) to an Linux agent whereas domain Y resources (here clocks also) are exposed to another agent, each agent with its specific transport/channel. Enabling each agent node in the Linux FDT allows to define which SCMI clocks get exposed and hence registered in the kernel.
Without the change proposed here, I cannot get the clocks exposed to both agents when enabled as the SCMI clock protocol is initialized only for the 1st probbed agent device.

Regards,
Etienne

Quoted 3 lines

--
Regards,
Sudeep

#24 lore raw

Hi Etienne,

Quoted 28 lines · Etienne Carriere
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

Remove the IDR replacement that prevent initializing an SCMI protocol when it has already been initialized. This is needed when there are several SCMI agents that do implement a given SCMI protocol unless what only the related SCMI protocol communication is initialized only for first probed agent.

Quoted 8 lines

Can you please elaborate on your usecase please. What do you mean by several SCMI agents here. OSPM is the only agent we are interested here. What other agents is this driver supposed to handle here. We allocate memory in init and calling init multiple times messes up the allocated and initialised structures.

So NACK for this patch as it needs more work if we need this at all.

Hello Sudeep,

Considering a device with several SCMI servers spread over several co-processor and possibly also in the Arm TZ secure world, each of these servers uses a specific
SCMI channel. Without this change, each SCMI protocol gets initialized only for the
first agent device that is probed.

Quoted 13 lines

My setup is also a bit specific. My device has several secure configuration features that can individually be enabled or not. For example, configuring domain X as secure makes some clocks reachable by Linux only through SCMI, and configuring domain Y as secure makes other clocks reachable by Linux only through SCMI. For flexibility, I expose domain X resources (here clocks) to an Linux agent whereas domain Y resources (here clocks also) are exposed to another agent, each agent with its specific transport/channel. Enabling each agent node in the Linux FDT allows to define which SCMI clocks get exposed and hence registered in the kernel.
Without the change proposed here, I cannot get the clocks exposed to both agents when enabled as the SCMI clock protocol is initialized only for the 1st probbed agent device.

Just a heads up that I have a series to be posted soon(ish) that is meant to address vendor protocols support and more in general protocols modularization by simplifying and reorganizing 'a bit' the whole initialization process and the handle interface itself: in that context I've got rid as a whole of the above protocol initialization code inside device probing and moved it at the time of first usage of the protocol, i.e. when the first SCMI driver, inside its probe, attempts to get hold of a protocol issuing something like:

	perf_ops = handle->get_ops(handle, SCMI_PROTOCOL_PERF);

This will effectively trigger a run of the usual protocol initialization code if the protocol was still NOT initialized (no previous get_ops) for that SCMI instance (server): so if your SCMI driver/device gets instantiated multiple times against multiple different servers, the needed protocol(s) will be initialized multiple times one for each instance (handle) upon first usage, while any other further instance of another SCMI driver requesting the same, already initialized, protocol will find it ready to go.

Cleanup/deinitialization is delegated to a corresponding handle->put_ops(), while the general notifications will still be available using the current .notify_ops() interface, but those requests will be now tracked internally against the relevant protocol in order to avoid premature deinitialization or removal of still in-use protocols.

Thanks

Cristian

Quoted 6 lines

Regards,
Etienne

Quoted 3 lines

--
Regards,
Sudeep

#25 lore raw
In reply to Etienne Carriere
Quoted 19 lines · Etienne Carriere
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Etienne Carriere

Remove the IDR replacement that prevent initializing an SCMI protocol when it has already been initialized. This is needed when there are several SCMI agents that do implement a given SCMI protocol unless what only the related SCMI protocol communication is initialized only for first probed agent.

Quoted 8 lines

Can you please elaborate on your usecase please. What do you mean by several SCMI agents here. OSPM is the only agent we are interested here. What other agents is this driver supposed to handle here. We allocate memory in init and calling init multiple times messes up the allocated and initialised structures.

So NACK for this patch as it needs more work if we need this at all.

Quoted 7 lines

Hello Sudeep,

Considering a device with several SCMI servers spread over several co-processor and possibly also in the Arm TZ secure world, each of these servers uses a specific SCMI channel. Without this change, each SCMI protocol gets initialized only for the first agent device that is probed.

Fair enough, but it also adds complexity. Do you have a master SCMI server implementation in that case. As some protocols like system might need to be broadcast to all servers and master server needs to take appropriate action.

Quoted 4 lines

My setup is also a bit specific. My device has several secure configuration features that can individually be enabled or not. For example, configuring domain X as secure makes some clocks reachable by Linux only through SCMI, and configuring domain Y as secure makes other clocks reachable by Linux

Quoted 9 lines

only through SCMI. For flexibility, I expose domain X resources (here clocks) to an Linux agent whereas domain Y resources (here clocks also) are exposed to another agent, each agent with its specific transport/channel. Enabling each agent node in the Linux FDT allows to define which SCMI clocks get exposed and hence registered in the kernel.
Without the change proposed here, I cannot get the clocks exposed to both agents when enabled as the SCMI clock protocol is initialized only for the 1st probbed agent device.

OK, as Cristian has already mentioned we need to clean up a bit on these initcalls and Cristian has some WIP patches, I would like to wait and look at them instead of breaking other usecases with patch(multiple devices per protocol within one scmi server)

Signature · 2 lines
Regards,
Sudeep
Applied
#26 lore raw
In reply to Etienne Carriere
Quoted 5 lines · Etienne Carriere

Remove the IDR replacement that prevent initializing an SCMI protocol when it has already been initialized. This is needed when there are several SCMI agents that do implement a given SCMI protocol unless what only the related SCMI protocol communication is initialized only for first probed agent.

I am picking up 4-5.

Applied to sudeep.holla/linux (for-next/scmi), thanks!

[4/5] firmware: arm_scmi: Expand SMC/HVC message pool to more than one
https://git.kernel.org/sudeep.holla/c/7adb2c8aaa
[5/5] firmware: arm_scmi: Fix ARCH_COLD_RESET

      https://git.kernel.org/sudeep.holla/c/45b9e04d5b

--

Regards,
Sudeep