Hi all,
This series mainly aims to introduce atomic support for transports
that can support it.
At first in [2/12], as a closely related addition, it is introduced a
common way for a transport to signal to the SCMI core that it does not
offer completion interrupts, so that the usual polling behaviour based
on .poll_done() will be required: this can be done enabling statically
a global polling behaviour for the whole transport with flag
scmi_desc.force_polling OR dynamically enabling at runtime such polling
behaviour on a per-channel basis with scmi_chan_info.no_completion_irq,
typically during .chan_setup(). The usual per-command polling selection
behaviour based on hdr.poll_completion is preserved as before.
Then in [3/12], a transport that supports atomic operations on its TX path
can now declare itself as .atomic_capable and as a consequence the SCMI
core will refrain itself too from sleeping on the correspondent RX-path
even when using completion IRQs.
In [6/12] a simple method is introduced so that an SCMI driver can easily
query the core to check if the currently used transport is configured to
behave in an atomic manner: in this way, interested SCMI driver users, like
Clock framework [7/12], can optionally support atomic operations when
operating on an atomically configured transport.
In [8/12] virtio transport is declared atomic.
Finally there are 4 *tentative" RFC patch related to SMC transport.
At first [9/12] ports SMC to use the common core completions when
completion interrupt is available or otherwise revert to use common core
polling mechanism above introduced: this avoids the improper call of
scmi_rx_callback directly in smc_send_message.
Then in [10/12] SMC is converted to be .atomic_capable by substituting
the mutexes with busy-waiting to keep the channel 'locked'.
With [11/12] I introduce a flag to allow a transport to signal to the core
that upon return of a .send_message() the requested command execution can
be assumed by the core to have been fully completed by the platform, so
that the response payload (if any) can be immediately fetched without the
need to poll the channel.
Finally in [12/12] I enable the above flag for SMC transport.
As a side note on the sync_cmds_atomic_replies flag added in [11/12], note
that such flag assumes that a specific transport can set it and so
univocally assure to the SCMI core that the described behavior holds true
anytime for the said transport; in reality, in a transport like SMC such
behavior could also be dependent on the effective placement of the SCMI
platform server: while a pure EL-3 SCMI server could reasonably assure
that upon smc call termination the command is fully completed, the same
could not be true for an SCMI server living in S-EL1.
For such reasons a possible evolution could be to add also some DT property
to enable the SMC transport to conditionally enable the flag at run-time
depending on the effective runtime platform configuration in terms of
SCMI server placement.
This whole matter is up for discussion, though, maybe it's not even a real
possibility an S-EL1 SCMI server using an SMC transport, so the DT patch
has not been included in this series.
Moreover, SMC changes have NOT been tested so far (I cannot), AND they are
just a proposal at this stage to try to better abstract and unify behaviour
with the SCMI core, so they are marked as RFCs.
Atomic support has been minimally tested against the upcoming virtio
transport V7 series, while polling has been tested with mailbox transports.
The series is based on linux-next/master on top of tag next-20210824 so as
to include the recently queued series on SCMI virtio and its core changes
currently queued also on sudeep/for-next/scmi [1].
Given I'm still gathering feedback on this, I still not have CCed any
maintainer out of SCMI subsystem.
Any feedback welcome.
Thanks,
Cristian
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/log/?h=for-next/scmi
---
V3 --> V4
- rebased on linux-next/master next-20210824
- renamed .needs_polling to .no_completion_irq
- added .sync_cmds_atomic_replies
- make SMC use .sync_cmd_atomic_replies
V2 --> v3
- rebased on SCMI VirtIO V6 which in turn is based on v5.14-rc1
Cristian Marussi (12):
firmware: arm_scmi: Perform earlier cinfo lookup call in do_xfer
firmware: arm_scmi: Add configurable polling mode for transports
firmware: arm_scmi: Add support for atomic transports
include: trace: Add new scmi_xfer_response_wait event
firmware: arm_scmi: Use new trace event scmi_xfer_response_wait
firmware: arm_scmi: Add is_transport_atomic() handle method
clk: scmi: Support atomic enable/disable API
firmware: arm_scmi: Declare virtio transport .atomic_capable
[RFC] firmware: arm_scmi: Make smc transport use common completions
[RFC] firmware: arm_scmi: Make smc transport atomic
[RFC] firmware: arm_scmi: Add sync_cmds_atomic_replies transport flag
[RFC] firmware: arm_scmi: Make smc support atomic commands replies
drivers/clk/clk-scmi.c | 44 ++++--
drivers/firmware/arm_scmi/common.h | 22 +++
drivers/firmware/arm_scmi/driver.c | 224 +++++++++++++++++++++++------
drivers/firmware/arm_scmi/smc.c | 61 +++++---
drivers/firmware/arm_scmi/virtio.c | 1 +
include/linux/scmi_protocol.h | 8 ++
include/trace/events/scmi.h | 28 ++++
7 files changed, 311 insertions(+), 77 deletions(-)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Lookup cinfo data early in do_xfer so as to avoid any further init work
on xfer structure in case of error.
No functional change.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
SCMI communications along TX channels can optionally be provided of a
completion interrupt; when such interrupt is not available, command
transactions should rely on polling, where the SCMI core takes care to
repeatedly evaluate the transport-specific .poll_done() function to
determine if and when a request was fully completed or timed out.
Such mechanism is already present and working on a single transfer base:
SCMI protocols can indeed enable hdr.poll_completion on specific commands
ahead of each transfer and cause that transaction to be handled with
polling.
Introduce a couple of flags to be able to enforce such polling behaviour
globally at will:
- scmi_desc.force_polling: to statically switch the whole transport to
polling mode.
- scmi_chan_info.no_completion_irq: to switch a single channel dynamically
to polling mode if at runtime is determined that no completion interrupt
was available for such channel.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v3 --> v4:
- renamed .needs_polling flag to .no_completion_irq
- refactored error path when polling needed but not supported
---
drivers/firmware/arm_scmi/common.h | 11 +++++++++++
drivers/firmware/arm_scmi/driver.c | 29 +++++++++++++++++++++++------
2 files changed, 34 insertions(+), 6 deletions(-)
@@ -656,6 +656,15 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,return;}+/* Discard unexpected messages when polling is active. */+if(xfer->hdr.type!=MSG_TYPE_DELAYED_RESP&&+xfer->hdr.poll_completion){+WARN_ON_ONCE(1);+dev_dbg(cinfo->dev,+"Completion IRQ received but using polling. Ignore.\n");+return;+}+/* rx.len could be shrunk in the sync do_xfer, so reset to maxsz */if(xfer->hdr.type==MSG_TYPE_DELAYED_RESP)xfer->rx.len=info->desc->max_msg_size;
@@ -760,16 +769,19 @@ static int do_xfer(const struct scmi_protocol_handle *ph,structdevice*dev=info->dev;structscmi_chan_info*cinfo;-if(xfer->hdr.poll_completion&&!info->desc->ops->poll_done){-dev_warn_once(dev,-"Polling mode is not supported by transport.\n");-return-EINVAL;-}-cinfo=idr_find(&info->tx_idr,pi->proto->id);if(unlikely(!cinfo))return-EINVAL;+if(info->desc->force_polling||cinfo->no_completion_irq){+if(!info->desc->ops->poll_done){+dev_warn_once(dev,+"Polling mode is not supported by transport.\n");+return-EINVAL;+}+xfer->hdr.poll_completion=true;+}+/**Initialiseprotocolidnowfromprotocolhandletoavoiditbeing*overriddenbymistake(ormalice)bytheprotocolcodemanglingwith
@@ -1499,6 +1511,11 @@ static int scmi_chan_setup(struct scmi_info *info, struct device *dev,if(ret)returnret;+if(tx&&(cinfo->no_completion_irq||info->desc->force_polling))+dev_info(dev,+"Enabled polling mode for TX channel - prot_id:%d\n",+prot_id);+idr_alloc:ret=idr_alloc(idr,cinfo,prot_id,prot_id+1,GFP_KERNEL);if(ret!=prot_id){
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
An SCMI transport can declare itself as .atomic_capable in order to signal
to the SCMI core that all its transmit path can be executed in atomic
context: the core as a consequence will take care not to sleep to in the
corresponding rx path while waiting for a response or a delayed response.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 167 ++++++++++++++++++++++-------
2 files changed, 132 insertions(+), 38 deletions(-)
@@ -749,6 +751,90 @@ static bool scmi_xfer_done_no_timeout(struct scmi_chan_info *cinfo,ktime_after(ktime_get(),stop);}+staticboolxfer_complete_or_timeout(structcompletion*done,ktime_tstop)+{+returntry_wait_for_completion(done)||ktime_after(ktime_get(),stop);+}++staticintspin_for_completion_timeout(structcompletion*done,inttimeout_ms)+{+ktime_tstop=ktime_add_ms(ktime_get(),timeout_ms);++spin_until_cond(xfer_complete_or_timeout(done,stop));+if(ktime_after(ktime_get(),stop))+return-ETIMEDOUT;++return0;+}++/**+*scmi_wait_for_message_response-Anhelpertogroupallthepossiblewaysof+*waitingforasynchronousmessageresponse.+*+*@cinfo:SCMIchannelinfo+*@xfer:Referencetothetransferbeingwaitedfor.+*+*Chooseswaitingstrategy(sleep-waitingvsbusy-waiting)dependingonflags+*configurationlikexfer->hdr.poll_completionandscmi_desc.atomic.capable.+*+*Return:0onSuccess,errorotherwise.+*/+staticintscmi_wait_for_message_response(structscmi_chan_info*cinfo,+structscmi_xfer*xfer)+{+structscmi_info*info=handle_to_scmi_info(cinfo->handle);+structdevice*dev=info->dev;+intret=0,timeout_ms=info->desc->max_rx_timeout_ms;++if(!xfer->hdr.poll_completion){+if(!info->desc->atomic_capable){+if(!wait_for_completion_timeout(&xfer->done,+msecs_to_jiffies(timeout_ms))){+dev_err(dev,"timed out in resp(caller: %pS)\n",+(void*)_RET_IP_);+ret=-ETIMEDOUT;+}+}else{+/* Poll on xfer->done waiting for completion by interrupt */+ret=spin_for_completion_timeout(&xfer->done,+timeout_ms);+if(ret)+dev_err(dev,+"timed out in resp(caller: %pS) - atomic\n",+(void*)_RET_IP_);+}+}else{+/*+*Pollonxferusingtransportprovided.poll_done();+*assumesnocompletioninterruptwasavailable.+*/+ktime_tstop=ktime_add_ms(ktime_get(),timeout_ms);++spin_until_cond(scmi_xfer_done_no_timeout(cinfo,xfer,stop));+if(ktime_before(ktime_get(),stop)){+unsignedlongflags;++/*+*Donotfetch_responseifanout-of-order+*delayedresponseisbeingprocessed.+*/+spin_lock_irqsave(&xfer->lock,flags);+if(xfer->state==SCMI_XFER_SENT_OK){+info->desc->ops->fetch_response(cinfo,xfer);+xfer->state=SCMI_XFER_RESP_OK;+}+spin_unlock_irqrestore(&xfer->lock,flags);+}else{+dev_err(dev,+"timed out in resp(caller: %pS) - polling\n",+(void*)_RET_IP_);+ret=-ETIMEDOUT;+}+}++returnret;+}+/***do_xfer()-Doonetransfer*
@@ -763,7 +849,6 @@ static int do_xfer(const struct scmi_protocol_handle *ph,structscmi_xfer*xfer){intret;-inttimeout;conststructscmi_protocol_instance*pi=ph_to_pi(ph);structscmi_info*info=handle_to_scmi_info(pi->handle);structdevice*dev=info->dev;
@@ -810,36 +895,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph,returnret;}-if(xfer->hdr.poll_completion){-ktime_tstop=ktime_add_ns(ktime_get(),SCMI_MAX_POLL_TO_NS);--spin_until_cond(scmi_xfer_done_no_timeout(cinfo,xfer,stop));-if(ktime_before(ktime_get(),stop)){-unsignedlongflags;--/*-*Donotfetch_responseifanout-of-orderdelayed-*responseisbeingprocessed.-*/-spin_lock_irqsave(&xfer->lock,flags);-if(xfer->state==SCMI_XFER_SENT_OK){-info->desc->ops->fetch_response(cinfo,xfer);-xfer->state=SCMI_XFER_RESP_OK;-}-spin_unlock_irqrestore(&xfer->lock,flags);-}else{-ret=-ETIMEDOUT;-}-}else{-/* And we wait for the response. */-timeout=msecs_to_jiffies(info->desc->max_rx_timeout_ms);-if(!wait_for_completion_timeout(&xfer->done,timeout)){-dev_err(dev,"timed out in resp(caller: %pS)\n",-(void*)_RET_IP_);-ret=-ETIMEDOUT;-}-}-+ret=scmi_wait_for_message_response(cinfo,xfer);if(!ret&&xfer->hdr.status)ret=scmi_to_linux_errno(xfer->hdr.status);
Having a new step to trace SCMI stack while it waits for synchronous
responses is useful to analyze system performance when changing waiting
mode between polling and interrupt completion.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
include/trace/events/scmi.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
Use new trace event to mark start of waiting for response section.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 5 +++++
1 file changed, 5 insertions(+)
Add a method to check if the underlying transport configured for an SCMI
instance is configured to support atomic transaction of SCMI commands.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++++
include/linux/scmi_protocol.h | 8 ++++++++
2 files changed, 24 insertions(+)
Support enable/disable clk_ops instead of prepare/unprepare when the
underlying SCMI transport is configured to support atomic transactions for
synchronous commands.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/clk/clk-scmi.c | 44 +++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)
SCMI virtio transport support does not contain any sleeping pattern, so
declare it as .atomic_capable.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/virtio.c | 1 +
1 file changed, 1 insertion(+)
When a completion irq is available use it and delegate command completion
handling to the core SCMI completion mechanism.
If no completion irq is available revert to polling, using the core common
polling machinery.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v3 --> v4
- renamed usage of .needs_polling to .no_completion_irq
---
drivers/firmware/arm_scmi/smc.c | 40 ++++++++++++++++-----------------
1 file changed, 20 insertions(+), 20 deletions(-)
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/common.h | 8 ++++++++
drivers/firmware/arm_scmi/driver.c | 29 +++++++++++++++++------------
2 files changed, 25 insertions(+), 12 deletions(-)
@@ -809,14 +809,24 @@ static int scmi_wait_for_message_response(struct scmi_chan_info *cinfo,(void*)_RET_IP_);}}else{-/*-*Pollonxferusingtransportprovided.poll_done();-*assumesnocompletioninterruptwasavailable.-*/-ktime_tstop=ktime_add_ms(ktime_get(),timeout_ms);+if(!info->desc->sync_cmds_atomic_replies){+/*+*Pollonxferusingtransportprovided.poll_done();+*assumesnocompletioninterruptwasavailable.+*/+ktime_tstop=ktime_add_ms(ktime_get(),timeout_ms);++spin_until_cond(scmi_xfer_done_no_timeout(cinfo,+xfer,stop));+if(ktime_after(ktime_get(),stop)){+dev_err(dev,+"timed out in resp(caller: %pS) - polling\n",+(void*)_RET_IP_);+ret=-ETIMEDOUT;+}+}-spin_until_cond(scmi_xfer_done_no_timeout(cinfo,xfer,stop));-if(ktime_before(ktime_get(),stop)){+if(!ret){unsignedlongflags;/*
@@ -829,11 +839,6 @@ static int scmi_wait_for_message_response(struct scmi_chan_info *cinfo,xfer->state=SCMI_XFER_RESP_OK;}spin_unlock_irqrestore(&xfer->lock,flags);-}else{-dev_err(dev,-"timed out in resp(caller: %pS) - polling\n",-(void*)_RET_IP_);-ret=-ETIMEDOUT;}}
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Enable sync_cmds_atomic_replies in the SMC transport descriptor.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
NOTE THAT this flag is probably better to be also optionally settable
using an optional DT property to address the fact that the same
transport could expose or not this feature depending on where the SCMI
server sits.
(e.g. an SCMI server in S-EL1 accessed via smc dispatcher sitting in EL3)
---
drivers/firmware/arm_scmi/smc.c | 1 +
1 file changed, 1 insertion(+)
From: Jim Quinlan <hidden> Date: 2021-08-25 16:19:43
Hi Christian,
On Tue, Aug 24, 2021 at 10:00 AM Cristian Marussi
[off-list ref] wrote:
quoted hunk
An SCMI transport can declare itself as .atomic_capable in order to signal
to the SCMI core that all its transmit path can be executed in atomic
context: the core as a consequence will take care not to sleep to in the
corresponding rx path while waiting for a response or a delayed response.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 167 ++++++++++++++++++++++-------
2 files changed, 132 insertions(+), 38 deletions(-)
@@ -749,6 +751,90 @@ static bool scmi_xfer_done_no_timeout(struct scmi_chan_info *cinfo,ktime_after(ktime_get(),stop);}+staticboolxfer_complete_or_timeout(structcompletion*done,ktime_tstop)+{+returntry_wait_for_completion(done)||ktime_after(ktime_get(),stop);+}++staticintspin_for_completion_timeout(structcompletion*done,inttimeout_ms)+{+ktime_tstop=ktime_add_ms(ktime_get(),timeout_ms);++spin_until_cond(xfer_complete_or_timeout(done,stop));+if(ktime_after(ktime_get(),stop))+return-ETIMEDOUT;++return0;+}++/**+*scmi_wait_for_message_response-Anhelpertogroupallthepossiblewaysof+*waitingforasynchronousmessageresponse.+*+*@cinfo:SCMIchannelinfo+*@xfer:Referencetothetransferbeingwaitedfor.+*+*Chooseswaitingstrategy(sleep-waitingvsbusy-waiting)dependingonflags+*configurationlikexfer->hdr.poll_completionandscmi_desc.atomic.capable.+*+*Return:0onSuccess,errorotherwise.+*/+staticintscmi_wait_for_message_response(structscmi_chan_info*cinfo,+structscmi_xfer*xfer)+{+structscmi_info*info=handle_to_scmi_info(cinfo->handle);+structdevice*dev=info->dev;+intret=0,timeout_ms=info->desc->max_rx_timeout_ms;++if(!xfer->hdr.poll_completion){+if(!info->desc->atomic_capable){+if(!wait_for_completion_timeout(&xfer->done,+msecs_to_jiffies(timeout_ms))){+dev_err(dev,"timed out in resp(caller: %pS)\n",+(void*)_RET_IP_);+ret=-ETIMEDOUT;+}+}else{+/* Poll on xfer->done waiting for completion by interrupt */+ret=spin_for_completion_timeout(&xfer->done,+timeout_ms);
We use the SMC transport with a completion interrupt but would prefer
for the above to use wait_for_completion(...) instead of using
spin_for_completion(). A few of our SCMI commands can take a while to
complete execution so we do not want to be spinning or polling while
waiting.
We could probably go back to a mailbox-based transport and use delayed
messages here for these "long" SCMI messages, but we do not have full
control over the platform FW (plus there are backwards compatibility
issues). FWIW, the platform FW was setup before SCMI on Linux
implemented delayed/async messages.
Regards,
Jim Quinlan
Broadcom STB
quoted hunk
+ if (ret)
+ dev_err(dev,
+ "timed out in resp(caller: %pS) - atomic\n",
+ (void *)_RET_IP_);
+ }
+ } else {
+ /*
+ * Poll on xfer using transport provided .poll_done();
+ * assumes no completion interrupt was available.
+ */
+ ktime_t stop = ktime_add_ms(ktime_get(), timeout_ms);
+
+ spin_until_cond(scmi_xfer_done_no_timeout(cinfo, xfer, stop));
+ if (ktime_before(ktime_get(), stop)) {
+ unsigned long flags;
+
+ /*
+ * Do not fetch_response if an out-of-order
+ * delayed response is being processed.
+ */
+ spin_lock_irqsave(&xfer->lock, flags);
+ if (xfer->state == SCMI_XFER_SENT_OK) {
+ info->desc->ops->fetch_response(cinfo, xfer);
+ xfer->state = SCMI_XFER_RESP_OK;
+ }
+ spin_unlock_irqrestore(&xfer->lock, flags);
+ } else {
+ dev_err(dev,
+ "timed out in resp(caller: %pS) - polling\n",
+ (void *)_RET_IP_);
+ ret = -ETIMEDOUT;
+ }
+ }
+
+ return ret;
+}
+
/**
* do_xfer() - Do one transfer
*
@@ -810,36 +895,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph, return ret; }- if (xfer->hdr.poll_completion) {- ktime_t stop = ktime_add_ns(ktime_get(), SCMI_MAX_POLL_TO_NS);-- spin_until_cond(scmi_xfer_done_no_timeout(cinfo, xfer, stop));- if (ktime_before(ktime_get(), stop)) {- unsigned long flags;-- /*- * Do not fetch_response if an out-of-order delayed- * response is being processed.- */- spin_lock_irqsave(&xfer->lock, flags);- if (xfer->state == SCMI_XFER_SENT_OK) {- info->desc->ops->fetch_response(cinfo, xfer);- xfer->state = SCMI_XFER_RESP_OK;- }- spin_unlock_irqrestore(&xfer->lock, flags);- } else {- ret = -ETIMEDOUT;- }- } else {- /* And we wait for the response. */- timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms);- if (!wait_for_completion_timeout(&xfer->done, timeout)) {- dev_err(dev, "timed out in resp(caller: %pS)\n",- (void *)_RET_IP_);- ret = -ETIMEDOUT;- }- }-+ ret = scmi_wait_for_message_response(cinfo, xfer); if (!ret && xfer->hdr.status) ret = scmi_to_linux_errno(xfer->hdr.status);
@@ -861,7 +917,7 @@ static void reset_rx_to_maxsz(const struct scmi_protocol_handle *ph, xfer->rx.len = info->desc->max_msg_size; }-#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC)+#define SCMI_DRESP_TIMEOUT (2 * MSEC_PER_SEC) /** * do_xfer_with_response() - Do one transfer and wait until the delayed
@@ -870,22 +926,57 @@ static void reset_rx_to_maxsz(const struct scmi_protocol_handle *ph, * @ph: Pointer to SCMI protocol handle * @xfer: Transfer to initiate and wait for response *+ * Avois sleeping in favour of busy-waiting if the underlying transport was+ * declared as .atomic_capable.+ *+ * Note that using asynchronous commands when running on top of atomic+ * transports should be avoided since it could cause long busy-waiting here,+ * but, once a transport is declared atomic, upper layers using the SCMI stack+ * can freely make assumptions about the 'non-sleeping' nature of the stack+ * (e.g. Clock framework) and it cannot be excluded that asynchronous commands+ * could be exposed by the platform and so used.+ *+ * The only other option would have been to refrain from using any asynchronous+ * command even if made available, when an atomic transport is detected, and+ * instead forcibly use the synchronous version (thing that can be easily+ * attained at the protocol layer), but this would also have led to longer+ * stalls of the channel for synchronous commands and possibly timeouts.+ * (in other words there is usually a good reason if a platform provides an+ * asynchronous version of a command and we should prefer to use it)+ * * Return: -ETIMEDOUT in case of no delayed response, if transmit error, * return corresponding error, else if all goes well, return 0. */ static int do_xfer_with_response(const struct scmi_protocol_handle *ph, struct scmi_xfer *xfer) {- int ret, timeout = msecs_to_jiffies(SCMI_MAX_RESPONSE_TIMEOUT);+ int ret, timeout = msecs_to_jiffies(SCMI_DRESP_TIMEOUT);+ const struct scmi_protocol_instance *pi = ph_to_pi(ph);+ struct scmi_info *info = handle_to_scmi_info(pi->handle); DECLARE_COMPLETION_ONSTACK(async_response); xfer->async_done = &async_response; ret = do_xfer(ph, xfer); if (!ret) {- if (!wait_for_completion_timeout(xfer->async_done, timeout))- ret = -ETIMEDOUT;- else if (xfer->hdr.status)+ if (!info->desc->atomic_capable) {+ if (!wait_for_completion_timeout(xfer->async_done,+ timeout)) {+ dev_err(ph->dev,+ "timed out in delayed resp(caller: %pS)\n",+ (void *)_RET_IP_);+ ret = -ETIMEDOUT;+ }+ } else {+ ret = spin_for_completion_timeout(xfer->async_done,+ SCMI_DRESP_TIMEOUT);+ if (ret)+ dev_err(ph->dev,+ "timed out in delayed resp(caller: %pS) - atomic\n",+ (void *)_RET_IP_);+ }++ if (!ret && xfer->hdr.status) ret = scmi_to_linux_errno(xfer->hdr.status); }--
Lookup cinfo data early in do_xfer so as to avoid any further init work
on xfer structure in case of error.
No functional change.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
SCMI communications along TX channels can optionally be provided of a
completion interrupt; when such interrupt is not available, command
transactions should rely on polling, where the SCMI core takes care to
repeatedly evaluate the transport-specific .poll_done() function to
determine if and when a request was fully completed or timed out.
Such mechanism is already present and working on a single transfer base:
SCMI protocols can indeed enable hdr.poll_completion on specific commands
ahead of each transfer and cause that transaction to be handled with
polling.
Introduce a couple of flags to be able to enforce such polling behaviour
globally at will:
- scmi_desc.force_polling: to statically switch the whole transport to
polling mode.
- scmi_chan_info.no_completion_irq: to switch a single channel dynamically
to polling mode if at runtime is determined that no completion interrupt
was available for such channel.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Having a new step to trace SCMI stack while it waits for synchronous
responses is useful to analyze system performance when changing waiting
mode between polling and interrupt completion.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Add a method to check if the underlying transport configured for an SCMI
instance is configured to support atomic transaction of SCMI commands.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Support enable/disable clk_ops instead of prepare/unprepare when the
underlying SCMI transport is configured to support atomic transactions for
synchronous commands.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
When a completion irq is available use it and delegate command completion
handling to the core SCMI completion mechanism.
If no completion irq is available revert to polling, using the core common
polling machinery.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
--
Florian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Jim Quinlan <hidden> Date: 2021-08-25 17:18:02
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
Regards,
Jim
On Wed, Aug 25, 2021 at 12:18:31PM -0400, Jim Quinlan wrote:
Hi Christian,
Hi Jim,
thanks for the review first of all.
On Tue, Aug 24, 2021 at 10:00 AM Cristian Marussi
[off-list ref] wrote:
quoted
An SCMI transport can declare itself as .atomic_capable in order to signal
to the SCMI core that all its transmit path can be executed in atomic
context: the core as a consequence will take care not to sleep to in the
corresponding rx path while waiting for a response or a delayed response.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 167 ++++++++++++++++++++++-------
2 files changed, 132 insertions(+), 38 deletions(-)
@@ -749,6 +751,90 @@ static bool scmi_xfer_done_no_timeout(struct scmi_chan_info *cinfo,ktime_after(ktime_get(),stop);}+staticboolxfer_complete_or_timeout(structcompletion*done,ktime_tstop)+{+returntry_wait_for_completion(done)||ktime_after(ktime_get(),stop);+}++staticintspin_for_completion_timeout(structcompletion*done,inttimeout_ms)+{+ktime_tstop=ktime_add_ms(ktime_get(),timeout_ms);++spin_until_cond(xfer_complete_or_timeout(done,stop));+if(ktime_after(ktime_get(),stop))+return-ETIMEDOUT;++return0;+}++/**+*scmi_wait_for_message_response-Anhelpertogroupallthepossiblewaysof+*waitingforasynchronousmessageresponse.+*+*@cinfo:SCMIchannelinfo+*@xfer:Referencetothetransferbeingwaitedfor.+*+*Chooseswaitingstrategy(sleep-waitingvsbusy-waiting)dependingonflags+*configurationlikexfer->hdr.poll_completionandscmi_desc.atomic.capable.+*+*Return:0onSuccess,errorotherwise.+*/+staticintscmi_wait_for_message_response(structscmi_chan_info*cinfo,+structscmi_xfer*xfer)+{+structscmi_info*info=handle_to_scmi_info(cinfo->handle);+structdevice*dev=info->dev;+intret=0,timeout_ms=info->desc->max_rx_timeout_ms;++if(!xfer->hdr.poll_completion){+if(!info->desc->atomic_capable){+if(!wait_for_completion_timeout(&xfer->done,+msecs_to_jiffies(timeout_ms))){+dev_err(dev,"timed out in resp(caller: %pS)\n",+(void*)_RET_IP_);+ret=-ETIMEDOUT;+}+}else{+/* Poll on xfer->done waiting for completion by interrupt */+ret=spin_for_completion_timeout(&xfer->done,+timeout_ms);
We use the SMC transport with a completion interrupt but would prefer
for the above to use wait_for_completion(...) instead of using
spin_for_completion(). A few of our SCMI commands can take a while to
complete execution so we do not want to be spinning or polling while
waiting.
Busy-waiting when using a completion IRQ is used indeed only if the
transport has been declared .atomic_capable: the idea was that if
the specific transport does not sleep, the core can avoid sleeping too
and so enable users like the clock framework to switch to 'atomic' mode
and being called from atomic context.
So if you drop indeed the SMC patch later in the series that mmake it
atomic
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
you'll end up using the wait_for here when completion IRQ is used.
(instead to avoid any polling while in polling mode (O_o) the idea was
to use the new .sync_cmds_atomic_replies)
BUT the problem is that some other partner could possibly want to use
instead this same transport in atomic mode, so maybe it could be worth
introducing some sort of configurability so that atomic operations are
enabled only if (say) .atomic_capable && .atomic_enable.
Maybe this could be done on a per-channel base, so you could dedicate a
channel to a protocol and ask only for it to be atomic_enable (if the
whole transport is atomic_capable); mixing atomic/non_atomic behaviour
inside the same protocol/channel across different messages seems a bit
of a hell (...and I think a previous attempt led to a lot of issues in
the past)
Anyway, not sure really where to put this possible configuration bit
though...this not being really a FW config/description seems likely to
be a NACK for a placement in the DT :D
We could probably go back to a mailbox-based transport and use delayed
messages here for these "long" SCMI messages, but we do not have full
control over the platform FW (plus there are backwards compatibility
issues). FWIW, the platform FW was setup before SCMI on Linux
implemented delayed/async messages.
Having a completion IRQ couldn't you use it to send delayed responses or
notification even in this smc transport ? (well it'd need FW to be
updated in fact and maybe I'm missing something here)
Thanks a lot for the feedback, may I assume this initial series it sort
of worked (beside noted limitations) in your SMC test setup :D ?
Thanks,
Cristian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Wed, Aug 25, 2021 at 06:31:13PM +0200, Florian Fainelli wrote:
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
Use new trace event to mark start of waiting for response section.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Hi Florian,
Thanks for the review and the feedback across this series.
Might be worth squashing into patch 4?
Yes indeed I never know for sure when to squash when stuff crosses
subsystems/maintaners boundaries.
Thanks,
Cristian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Wed, Aug 25, 2021 at 01:17:47PM -0400, Jim Quinlan wrote:
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
quoted
Hi Florian and Jim,
quoted
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
The new flag .sync_cmds_atomic_replies applies only when polling mode
has been selected for a specific cmd transaction, which means when no
completion IRQ was found available OR if xfer.poll_completion was
excplicitly set for a specific command.
At the moment in this series (unknown bugs apart :D), if you have a
channel configured with a completion IRQ and the .sync_cmds_atomic_replies
set for the transport, this latter flag would be generally ignored and a
wait_for_completion() will be normally used upon reception of the
completionIRQ, UNLESS you specify that one specific command has to be
polled using the per message xfer.poll_completion flag: so you should be
already able to selectively use a polling which immediately returns after
the smc by setting xfer.poll_completion for that specific short lived
message (since sync_cmds_atomic_replies is set and applies to pollmode).
On the other side any other LONG lived message will be naturally handled
via completionIRQ + wait_for_completion. (at least that was the aim..)
!!! NOTE that you'll have also to drop
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
from this series for the wait_completion to happen as you wish.
As said I'm not sure that this whole mixing of polling and IRQs on the
same channel on a regular won't cause any issues: any feedback on this
from your setup is much appreciated.
(maybe it's fine for SMC transport, but it led to a bit of hell in the
past with mboxes AFAIK...)
Thanks a lot again for your feedback, I'll have to chat with Sudeep
about the various issues/configs possibility that we discussed and I'll
keep you in the loop.
Thanks,
Cristian
P.S.: I'll be off for a few weeks, so even though I'll keep an eye on
the mail, I cannot guarantee any responsiveness :D
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Jim Quinlan <hidden> Date: 2021-08-26 18:29:39
On Wed, Aug 25, 2021 at 2:49 PM Cristian Marussi
[off-list ref] wrote:
On Wed, Aug 25, 2021 at 01:17:47PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
quoted
Hi Florian and Jim,
quoted
quoted
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
The new flag .sync_cmds_atomic_replies applies only when polling mode
has been selected for a specific cmd transaction, which means when no
completion IRQ was found available OR if xfer.poll_completion was
excplicitly set for a specific command.
At the moment in this series (unknown bugs apart :D), if you have a
channel configured with a completion IRQ and the .sync_cmds_atomic_replies
set for the transport, this latter flag would be generally ignored and a
wait_for_completion() will be normally used upon reception of the
completionIRQ, UNLESS you specify that one specific command has to be
polled using the per message xfer.poll_completion flag: so you should be
already able to selectively use a polling which immediately returns after
the smc by setting xfer.poll_completion for that specific short lived
message (since sync_cmds_atomic_replies is set and applies to pollmode).
On the other side any other LONG lived message will be naturally handled
via completionIRQ + wait_for_completion. (at least that was the aim..)
!!! NOTE that you'll have also to drop
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
from this series for the wait_completion to happen as you wish.
Hi Cristian,
I've tested all commits on our SMC-based system. I also tested all commits
minus "10/12 [RFC] firmware: arm_scmi: Make smc transport atomic".
This was a basic stress test, not a comprehensive one. So
Tested-by: Jim Quinlan <redacted>
Of course I have a strong preference for omitting "10/12 [RFC]" :-).
FWIW, if you are not planning on dropping this commit, perhaps there
could be a transport
node in the DT, and that could contain the a bool property
"smc-atomic-capable"?
Regards,
Jim Quinlan
Broadcom STB
As said I'm not sure that this whole mixing of polling and IRQs on the
same channel on a regular won't cause any issues: any feedback on this
from your setup is much appreciated.
(maybe it's fine for SMC transport, but it led to a bit of hell in the
past with mboxes AFAIK...)
Thanks a lot again for your feedback, I'll have to chat with Sudeep
about the various issues/configs possibility that we discussed and I'll
keep you in the loop.
Thanks,
Cristian
P.S.: I'll be off for a few weeks, so even though I'll keep an eye on
the mail, I cannot guarantee any responsiveness :D
On Thu, Aug 26, 2021 at 02:29:21PM -0400, Jim Quinlan wrote:
On Wed, Aug 25, 2021 at 2:49 PM Cristian Marussi
[off-list ref] wrote:
quoted
On Wed, Aug 25, 2021 at 01:17:47PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
quoted
Hi Florian and Jim,
quoted
quoted
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
The new flag .sync_cmds_atomic_replies applies only when polling mode
has been selected for a specific cmd transaction, which means when no
completion IRQ was found available OR if xfer.poll_completion was
excplicitly set for a specific command.
At the moment in this series (unknown bugs apart :D), if you have a
channel configured with a completion IRQ and the .sync_cmds_atomic_replies
set for the transport, this latter flag would be generally ignored and a
wait_for_completion() will be normally used upon reception of the
completionIRQ, UNLESS you specify that one specific command has to be
polled using the per message xfer.poll_completion flag: so you should be
already able to selectively use a polling which immediately returns after
the smc by setting xfer.poll_completion for that specific short lived
message (since sync_cmds_atomic_replies is set and applies to pollmode).
On the other side any other LONG lived message will be naturally handled
via completionIRQ + wait_for_completion. (at least that was the aim..)
!!! NOTE that you'll have also to drop
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
from this series for the wait_completion to happen as you wish.
Hi Cristian,
Hi Jim,
I've tested all commits on our SMC-based system. I also tested all commits
minus "10/12 [RFC] firmware: arm_scmi: Make smc transport atomic".
This was a basic stress test, not a comprehensive one. So
Tested-by: Jim Quinlan <redacted>
Thanks a lot for this testing.
Of course I have a strong preference for omitting "10/12 [RFC]" :-).
FWIW, if you are not planning on dropping this commit, perhaps there
could be a transport
node in the DT, and that could contain the a bool property
"smc-atomic-capable"?
Indeed, as I was saying more than one customer/partner is asking for this
configurability so this atomic mode should be definitely configurable.
(as it could be teh case similarly with the sync_cmds_atomic_replies
depedning on SCMI server placement..)
I'll talk with Sudeep in general about the series and this configurations;
in fact I can exclude that I'll commit this series with 10/12 as it is right
now.
Thanks for the feedback !
Cristian
Regards,
Jim Quinlan
Broadcom STB
quoted
As said I'm not sure that this whole mixing of polling and IRQs on the
same channel on a regular won't cause any issues: any feedback on this
from your setup is much appreciated.
(maybe it's fine for SMC transport, but it led to a bit of hell in the
past with mboxes AFAIK...)
Thanks a lot again for your feedback, I'll have to chat with Sudeep
about the various issues/configs possibility that we discussed and I'll
keep you in the loop.
Thanks,
Cristian
P.S.: I'll be off for a few weeks, so even though I'll keep an eye on
the mail, I cannot guarantee any responsiveness :D
On Thu, Aug 26, 2021 at 02:29:21PM -0400, Jim Quinlan wrote:
On Wed, Aug 25, 2021 at 2:49 PM Cristian Marussi
[off-list ref] wrote:
quoted
On Wed, Aug 25, 2021 at 01:17:47PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
quoted
Hi Florian and Jim,
quoted
quoted
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
The new flag .sync_cmds_atomic_replies applies only when polling mode
has been selected for a specific cmd transaction, which means when no
completion IRQ was found available OR if xfer.poll_completion was
excplicitly set for a specific command.
At the moment in this series (unknown bugs apart :D), if you have a
channel configured with a completion IRQ and the .sync_cmds_atomic_replies
set for the transport, this latter flag would be generally ignored and a
wait_for_completion() will be normally used upon reception of the
completionIRQ, UNLESS you specify that one specific command has to be
polled using the per message xfer.poll_completion flag: so you should be
already able to selectively use a polling which immediately returns after
the smc by setting xfer.poll_completion for that specific short lived
message (since sync_cmds_atomic_replies is set and applies to pollmode).
On the other side any other LONG lived message will be naturally handled
via completionIRQ + wait_for_completion. (at least that was the aim..)
!!! NOTE that you'll have also to drop
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
from this series for the wait_completion to happen as you wish.
Hi Cristian,
Hi Jim,
I've tested all commits on our SMC-based system. I also tested all commits
minus "10/12 [RFC] firmware: arm_scmi: Make smc transport atomic".
This was a basic stress test, not a comprehensive one. So
Tested-by: Jim Quinlan <redacted>
Of course I have a strong preference for omitting "10/12 [RFC]" :-).
FWIW, if you are not planning on dropping this commit, perhaps there
could be a transport
node in the DT, and that could contain the a bool property
"smc-atomic-capable"?
I just posted V5 on this SCMI atomic transport series, where the atomic
mode behaviour of a transport can be selected by a Kconfig which is defined
as default N: so this new series should behave out-of-the-box like with the
previous one when you had dropped as a whole the SMC atomic patch.
Any feedback welcome.
Thanks,
Cristian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Jim Quinlan <hidden> Date: 2021-10-04 17:50:29
On Thu, Sep 23, 2021 at 11:03 AM Cristian Marussi
[off-list ref] wrote:
On Thu, Aug 26, 2021 at 02:29:21PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 2:49 PM Cristian Marussi
[off-list ref] wrote:
quoted
On Wed, Aug 25, 2021 at 01:17:47PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
quoted
Hi Florian and Jim,
quoted
quoted
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
The new flag .sync_cmds_atomic_replies applies only when polling mode
has been selected for a specific cmd transaction, which means when no
completion IRQ was found available OR if xfer.poll_completion was
excplicitly set for a specific command.
At the moment in this series (unknown bugs apart :D), if you have a
channel configured with a completion IRQ and the .sync_cmds_atomic_replies
set for the transport, this latter flag would be generally ignored and a
wait_for_completion() will be normally used upon reception of the
completionIRQ, UNLESS you specify that one specific command has to be
polled using the per message xfer.poll_completion flag: so you should be
already able to selectively use a polling which immediately returns after
the smc by setting xfer.poll_completion for that specific short lived
message (since sync_cmds_atomic_replies is set and applies to pollmode).
On the other side any other LONG lived message will be naturally handled
via completionIRQ + wait_for_completion. (at least that was the aim..)
!!! NOTE that you'll have also to drop
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
from this series for the wait_completion to happen as you wish.
Hi Cristian,
Hi Jim,
quoted
I've tested all commits on our SMC-based system. I also tested all commits
minus "10/12 [RFC] firmware: arm_scmi: Make smc transport atomic".
This was a basic stress test, not a comprehensive one. So
Tested-by: Jim Quinlan <redacted>
Of course I have a strong preference for omitting "10/12 [RFC]" :-).
FWIW, if you are not planning on dropping this commit, perhaps there
could be a transport
node in the DT, and that could contain the a bool property
"smc-atomic-capable"?
I just posted V5 on this SCMI atomic transport series, where the atomic
mode behaviour of a transport can be selected by a Kconfig which is defined
as default N: so this new series should behave out-of-the-box like with the
previous one when you had dropped as a whole the SMC atomic patch.
Any feedback welcome.
Hi Christian,
This is very much appreciated, thanks! No feedback except
Tested-by: Jim Quinlan <redacted>
Thanks again,
Jim
On Mon, Oct 04, 2021 at 01:50:04PM -0400, Jim Quinlan wrote:
On Thu, Sep 23, 2021 at 11:03 AM Cristian Marussi
[off-list ref] wrote:
quoted
On Thu, Aug 26, 2021 at 02:29:21PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 2:49 PM Cristian Marussi
[off-list ref] wrote:
quoted
On Wed, Aug 25, 2021 at 01:17:47PM -0400, Jim Quinlan wrote:
quoted
On Wed, Aug 25, 2021 at 12:38 PM Florian Fainelli [off-list ref] wrote:
quoted
Hi Florian and Jim,
quoted
quoted
On 8/24/2021 3:59 PM, Cristian Marussi wrote:
quoted
A flag is added to let the transport signal the core that its handling of
synchronous command messages implies that, after .send_message has returned
successfully, the requested command can be assumed to be fully and
completely executed on SCMI platform side so that any possible response
value is already immediately available to be retrieved by a .fetch_reponse:
in other words the polling phase can be skipped in such a case and the
response values accessed straight away.
Note that all of the above applies only when polling mode of operation was
selected by the core: if instead a completion IRQ was found to be available
the normal response processing path based on completions will still be
followed.
This might actually have to be settable on a per-message basis ideally
since we may be transporting short lived SCMI messages for which the
completion can be done at SMC time, and long lived SCMI messages (e.g.:
involving a voltage change) for which we would prefer a completion
interrupt. Jim, what do you think?
Even if the SCMI main driver could be configured this way in an
elegant manner, I'm not sure that there is a clean way of specifying
this attribute on a per-message basis. Certainly we could do this
with our own protocols, but many of our "long lived" messages are the
Perf protocol's set_level command. At any rate, let me give it some
thought.
The new flag .sync_cmds_atomic_replies applies only when polling mode
has been selected for a specific cmd transaction, which means when no
completion IRQ was found available OR if xfer.poll_completion was
excplicitly set for a specific command.
At the moment in this series (unknown bugs apart :D), if you have a
channel configured with a completion IRQ and the .sync_cmds_atomic_replies
set for the transport, this latter flag would be generally ignored and a
wait_for_completion() will be normally used upon reception of the
completionIRQ, UNLESS you specify that one specific command has to be
polled using the per message xfer.poll_completion flag: so you should be
already able to selectively use a polling which immediately returns after
the smc by setting xfer.poll_completion for that specific short lived
message (since sync_cmds_atomic_replies is set and applies to pollmode).
On the other side any other LONG lived message will be naturally handled
via completionIRQ + wait_for_completion. (at least that was the aim..)
!!! NOTE that you'll have also to drop
[PATCH v4 10/12] [RFC] firmware: arm_scmi: Make smc transport atomic
from this series for the wait_completion to happen as you wish.
Hi Cristian,
Hi Jim,
quoted
I've tested all commits on our SMC-based system. I also tested all commits
minus "10/12 [RFC] firmware: arm_scmi: Make smc transport atomic".
This was a basic stress test, not a comprehensive one. So
Tested-by: Jim Quinlan <redacted>
Of course I have a strong preference for omitting "10/12 [RFC]" :-).
FWIW, if you are not planning on dropping this commit, perhaps there
could be a transport
node in the DT, and that could contain the a bool property
"smc-atomic-capable"?
I just posted V5 on this SCMI atomic transport series, where the atomic
mode behaviour of a transport can be selected by a Kconfig which is defined
as default N: so this new series should behave out-of-the-box like with the
previous one when you had dropped as a whole the SMC atomic patch.
Any feedback welcome.
Hi Christian,
Hi Jim,
This is very much appreciated, thanks! No feedback except
Tested-by: Jim Quinlan <redacted>
Glad to hear that.
I'll see if I can gather more feedback from other partners that were
interested on using the atomic path (which was supposed to be the main
feature of this series at the end :D...)
Thanks for your testing.
Cristian