Hi all,
This RFC series mainly aims to introduce atomic support for transport that
can support it.
At first in [03/10], 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.needs_polling,
typically during .chan_setup(). The usual per-command polling selection
behaviour based on hdr.poll_completion is preserved as before.
then in [04/10], a transport that supports atomic operation on its tx path
can now declare itself as .atomic_capable and as a consequence the SCMI
core will refrain itself from sleeping on the correspondent rx-path.
In [07/10] 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 [08/10], can optionally support atomic operations when
operating on an atomically configured transport.
Finally there are 2 *tentative" patch for SMC transport: at first [09/10]
ports SMC to use the common core completions when completion interrupt is
available or otherwise revert to use common core polling mechanism above
introduced; then in [10/10] SMC is converted to be .atomic_capable by
substituting the mutexes with busy-waiting to keep the channel 'locked'.
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; both patches are completely intended as RFCs, though, not
only regarding their implementation but even their mere existence is RFC:
I mean maybe we just don't want to do such kind of unification/abstraction,
and I can just drop those SMC patches if unwanted; any feedback welcome.
Atomic support has been minimally tested against the upcoming virtio
transport draft(unposted) series, while polling has been tested both
with virtio and mailbox transports.
The series is based on sudeep/for-next [1] on top of commit:
commit 0aa69c9fc80d ("firmware: arm_scmi: Add compatibility checks for
shmem node")
Given the RFC status of the series in general 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
Cristian Marussi (10):
firmware: arm_scmi: Reset properly xfer SCMI status
firmware: arm_scmi: Add missing xfer reinit_completion
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: Make smc transport use common completions
firmware: arm-scmi: Make smc transport atomic
drivers/clk/clk-scmi.c | 44 +++++--
drivers/firmware/arm_scmi/common.h | 11 ++
drivers/firmware/arm_scmi/driver.c | 184 +++++++++++++++++++++++++----
drivers/firmware/arm_scmi/smc.c | 60 ++++++----
include/linux/scmi_protocol.h | 8 ++
include/trace/events/scmi.h | 28 +++++
6 files changed, 277 insertions(+), 58 deletions(-)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
When an SCMI command transfer fails due to some protocol issue an SCMI
error code is reported inside the SCMI message payload itself and it is
then retrieved and transcribed by the specific transport layer into the
xfer.hdr.status field by transport specific .fetch_response().
The core SCMI transport layer never explicitly reset xfer.hdr.status,
so when an xfer is reused, if a transport misbehaved in handling such
status field, we risk to see an invalid ghost error code.
Reset xfer.hdr.status to SCMI_SUCCESS right before each transfer is
started.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
1 file changed, 1 insertion(+)
Reusing timed out xfers in a loop can lead to issue if completion was not
properly reinitialized.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
1 file changed, 1 insertion(+)
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 evaluates the transport-specific .poll_done() function to
determine if a request was 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.needs_polling: 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>
---
drivers/firmware/arm_scmi/common.h | 10 ++++++++++
drivers/firmware/arm_scmi/driver.c | 17 +++++++++++++++++
2 files changed, 27 insertions(+)
@@ -319,6 +319,15 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,}xfer=&minfo->xfer_block[xfer_id];++/* Discard unexpected messages when polling is active. */+if(msg_type!=MSG_TYPE_DELAYED_RESP&&xfer->hdr.poll_completion){+WARN_ON_ONCE(1);+dev_dbg(dev,+"Completion IRQ received but using polling. Ignore.\n");+return;+}+/**Evenifaresponsewasindeedexpectedonthisslotatthispoint,*abuggyplatformcouldwronglyreplyfeedingusanunexpected
@@ -443,6 +452,9 @@ static int do_xfer(const struct scmi_protocol_handle *ph,if(unlikely(!cinfo))return-EINVAL;+if(info->desc->force_polling||cinfo->needs_polling)+xfer->hdr.poll_completion=true;+trace_scmi_xfer_begin(xfer->transfer_id,xfer->hdr.id,xfer->hdr.protocol_id,xfer->hdr.seq,xfer->hdr.poll_completion);
@@ -1102,6 +1114,11 @@ static int scmi_chan_setup(struct scmi_info *info, struct device *dev,if(ret)returnret;+if(tx&&(cinfo->needs_polling||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 | 1 +
drivers/firmware/arm_scmi/driver.c | 144 +++++++++++++++++++++++------
2 files changed, 119 insertions(+), 26 deletions(-)
@@ -421,6 +423,79 @@ 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_after(ktime_get(),stop)){+dev_err(dev,+"timed out in resp(caller: %pS) - polling\n",+(void*)_RET_IP_);+ret=-ETIMEDOUT;+}else{+info->desc->ops->fetch_response(cinfo,xfer);+}+}++returnret;+}+/***do_xfer()-Doonetransfer*
@@ -435,7 +510,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;
@@ -467,25 +541,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))-info->desc->ops->fetch_response(cinfo,xfer);-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);
@@ -531,8 +606,25 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph,xfer->async_done=&async_response;ret=do_xfer(ph,xfer);-if(!ret&&!wait_for_completion_timeout(xfer->async_done,timeout))-ret=-ETIMEDOUT;+if(!ret){+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_);+}xfer->async_done=NULL;returnret;
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
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(-)
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>
---
drivers/firmware/arm_scmi/smc.c | 40 ++++++++++++++++-----------------
1 file changed, 20 insertions(+), 20 deletions(-)
On Sun, Jun 06, 2021 at 11:12:23PM +0100, Cristian Marussi wrote:
When an SCMI command transfer fails due to some protocol issue an SCMI
error code is reported inside the SCMI message payload itself and it is
then retrieved and transcribed by the specific transport layer into the
xfer.hdr.status field by transport specific .fetch_response().
The core SCMI transport layer never explicitly reset xfer.hdr.status,
so when an xfer is reused, if a transport misbehaved in handling such
status field, we risk to see an invalid ghost error code.
Reset xfer.hdr.status to SCMI_SUCCESS right before each transfer is
started.
Any particular reason why it can't be part of xfer_get_init which has other
initialisations ? If none, please move it there.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Sun, Jun 06, 2021 at 11:12:24PM +0100, Cristian Marussi wrote:
quoted hunk
Reusing timed out xfers in a loop can lead to issue if completion was not
properly reinitialized.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
1 file changed, 1 insertion(+)
@@ -448,6 +448,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph,xfer->hdr.poll_completion);xfer->hdr.status=SCMI_SUCCESS;+reinit_completion(&xfer->done);
What could happen after xfer_get_init->scmi_xfer_get->reinit_completion
that it needs to be re-initialised again. I don't see any reason for this ?
If there are, please state them explicitly. If this is needed, I would drop
the one in scmi_xfer_get().
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Mon, Jun 07, 2021 at 06:38:09PM +0100, Sudeep Holla wrote:
On Sun, Jun 06, 2021 at 11:12:23PM +0100, Cristian Marussi wrote:
quoted
When an SCMI command transfer fails due to some protocol issue an SCMI
error code is reported inside the SCMI message payload itself and it is
then retrieved and transcribed by the specific transport layer into the
xfer.hdr.status field by transport specific .fetch_response().
The core SCMI transport layer never explicitly reset xfer.hdr.status,
so when an xfer is reused, if a transport misbehaved in handling such
status field, we risk to see an invalid ghost error code.
Reset xfer.hdr.status to SCMI_SUCCESS right before each transfer is
started.
Any particular reason why it can't be part of xfer_get_init which has other
initialisations ? If none, please move it there.
Well it was there initially then I moved it here.
The reason is mostly the same as the reason for the other patch in this
series that adds a reinit_completion() in this same point: the core does
not forbid to reuse an xfer multiple times, once obtained with xfer_get()
or xfer_get_init(), and indeed some protocols do such a thing: they
implements such do_xfer looping and bails out on error.
In the way that it is implemented now in protocols poses no problem
indeed because the do_xfer loop bails out on error and the xfer is put,
but as soon as some protocol is implemented that violates this common
practice and it just keeps on reuse an xfer after an error fo other
do_xfers() this breaks...so it seemed more defensive to just reinit the
completion and the status before each send.
Thanks,
Cristian
Hi,
On Mon, Jun 07, 2021 at 06:42:57PM +0100, Sudeep Holla wrote:
On Sun, Jun 06, 2021 at 11:12:24PM +0100, Cristian Marussi wrote:
quoted
Reusing timed out xfers in a loop can lead to issue if completion was not
properly reinitialized.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
1 file changed, 1 insertion(+)
@@ -448,6 +448,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph,xfer->hdr.poll_completion);xfer->hdr.status=SCMI_SUCCESS;+reinit_completion(&xfer->done);
What could happen after xfer_get_init->scmi_xfer_get->reinit_completion
that it needs to be re-initialised again. I don't see any reason for this ?
If there are, please state them explicitly. If this is needed, I would drop
the one in scmi_xfer_get().
The reason, like I explained in the other reply in hdr.status, is the
possibility of do_xfer loops and being more defensive.
I agree that if what I blabbed in the other email is acceptable, I could
drop the reinit_completion in xfer_get() and just use it before
send_message().
Thanks,
Cristian
On Mon, Jun 07, 2021 at 07:01:37PM +0100, Cristian Marussi wrote:
On Mon, Jun 07, 2021 at 06:38:09PM +0100, Sudeep Holla wrote:
quoted
On Sun, Jun 06, 2021 at 11:12:23PM +0100, Cristian Marussi wrote:
quoted
When an SCMI command transfer fails due to some protocol issue an SCMI
error code is reported inside the SCMI message payload itself and it is
then retrieved and transcribed by the specific transport layer into the
xfer.hdr.status field by transport specific .fetch_response().
The core SCMI transport layer never explicitly reset xfer.hdr.status,
so when an xfer is reused, if a transport misbehaved in handling such
status field, we risk to see an invalid ghost error code.
Reset xfer.hdr.status to SCMI_SUCCESS right before each transfer is
started.
Any particular reason why it can't be part of xfer_get_init which has other
initialisations ? If none, please move it there.
Well it was there initially then I moved it here.
The reason is mostly the same as the reason for the other patch in this
series that adds a reinit_completion() in this same point: the core does
not forbid to reuse an xfer multiple times, once obtained with xfer_get()
or xfer_get_init(), and indeed some protocols do such a thing: they
implements such do_xfer looping and bails out on error.
Makes sense. But it is okay to retain xfer->transfer_id for every transfer
in such a loop ?
In the way that it is implemented now in protocols poses no problem
indeed because the do_xfer loop bails out on error and the xfer is put,
but as soon as some protocol is implemented that violates this common
practice and it just keeps on reuse an xfer after an error fo other
do_xfers() this breaks...so it seemed more defensive to just reinit the
completion and the status before each send.
Fair enough. But they use it to send same message I guess, may be if it
gave error or something ? I would like to really know such a sequence
instead of assisting that 😉.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Mon, Jun 07, 2021 at 07:04:34PM +0100, Cristian Marussi wrote:
Hi,
On Mon, Jun 07, 2021 at 06:42:57PM +0100, Sudeep Holla wrote:
quoted
On Sun, Jun 06, 2021 at 11:12:24PM +0100, Cristian Marussi wrote:
quoted
Reusing timed out xfers in a loop can lead to issue if completion was not
properly reinitialized.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
1 file changed, 1 insertion(+)
@@ -448,6 +448,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph,xfer->hdr.poll_completion);xfer->hdr.status=SCMI_SUCCESS;+reinit_completion(&xfer->done);
What could happen after xfer_get_init->scmi_xfer_get->reinit_completion
that it needs to be re-initialised again. I don't see any reason for this ?
If there are, please state them explicitly. If this is needed, I would drop
the one in scmi_xfer_get().
The reason, like I explained in the other reply in hdr.status, is the
possibility of do_xfer loops and being more defensive.
Understood.
I agree that if what I blabbed in the other email is acceptable, I could
drop the reinit_completion in xfer_get() and just use it before
send_message().
I wonder if it is possible to reset only on error if possible and not
expensive of-course ?
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Sudeep,
On Mon, Jun 07, 2021 at 07:27:54PM +0100, Sudeep Holla wrote:
On Mon, Jun 07, 2021 at 07:01:37PM +0100, Cristian Marussi wrote:
quoted
On Mon, Jun 07, 2021 at 06:38:09PM +0100, Sudeep Holla wrote:
quoted
On Sun, Jun 06, 2021 at 11:12:23PM +0100, Cristian Marussi wrote:
quoted
When an SCMI command transfer fails due to some protocol issue an SCMI
error code is reported inside the SCMI message payload itself and it is
then retrieved and transcribed by the specific transport layer into the
xfer.hdr.status field by transport specific .fetch_response().
The core SCMI transport layer never explicitly reset xfer.hdr.status,
so when an xfer is reused, if a transport misbehaved in handling such
status field, we risk to see an invalid ghost error code.
Reset xfer.hdr.status to SCMI_SUCCESS right before each transfer is
started.
Any particular reason why it can't be part of xfer_get_init which has other
initialisations ? If none, please move it there.
Well it was there initially then I moved it here.
The reason is mostly the same as the reason for the other patch in this
series that adds a reinit_completion() in this same point: the core does
not forbid to reuse an xfer multiple times, once obtained with xfer_get()
or xfer_get_init(), and indeed some protocols do such a thing: they
implements such do_xfer looping and bails out on error.
Makes sense. But it is okay to retain xfer->transfer_id for every transfer
in such a loop ?
No you are right and indeed I saw that anomaly, but I have not addressed
it since, even if wrong, it is harmless and transfer_id is really used
only for debugging/profiling, while the missing reinit_completion is
potentially broken.
quoted
In the way that it is implemented now in protocols poses no problem
indeed because the do_xfer loop bails out on error and the xfer is put,
but as soon as some protocol is implemented that violates this common
practice and it just keeps on reuse an xfer after an error fo other
do_xfers() this breaks...so it seemed more defensive to just reinit the
completion and the status before each send.
Fair enough. But they use it to send same message I guess, may be if it
gave error or something ? I would like to really know such a sequence
instead of assisting that 😉.
So the current real 'looping do_xfer' behavior is safe and so this missing
reinit is only potentially broken in the future, and we cannot really
know now in advance about some future protocol needs, but it seems as of now
wrong that you'll want to keep going on and reuse an xfer for the same command
after an error in your loop.
On the other side we allow such behaviour, so I thought was good to
provide a safe net if it is misused.
But, beside this patches, that, as said, are more defensive that strictly
needed as of now, I think now it's worth mentioning that this same 'issue'
affects also, as an example, the new mechanism I introduced later in this
same series to always use monotonically increasing sequence number for
outgoing messages.
In that case I stick to the current behavior and I assign such monotonically
increasing sequence numbers to message during xfer_get, but the potential
issue is the same: if a do_xfer loop is used you end up reusing the same
seq_num for multiple do_xfers (so defeating really the mechanism itself
that aims not to reuse immediately the most recently used seq_num).
In that case I did this to keep it simple and to avoid placing more burden
on tx path by picking and assigning a seq_num upon each transfer...but, again,
also this behavior of picking a seq_num only at xfer_get is NOT really broken
as of now even for do_xfer loops since we bail out on error and you won't
really reuse that xfer.
It's just that in this seq_num selection case seems to add a lot of burden
and complexity if moved to the do_xfer phase, while status/reinit seemed
to me cheaper to move it in the do_xfer so I tried to play defensive.
At the end, in general I would say that all of these ops (status/reinit/
seq_nums/transfer_id) DO really belong logically to the do_xfer phase more than
to the xfer_get/xfer_get_init, but in reality we can cope with having them
@xfer_get/get_init and this keeps things simple and reduce burden, especially
in the monotonic seq_nums case: so I am not so sure anymore if it is fine to
move reinit/status to the do_xfer, as proposed here, while keeping seq_nums
(for good reasons) to the xfer_get phase, because we'd use 2 different strategies
to address similar issues.
I would say: just keep reinit and status in the xfer_get phase instead and
maybe warn somehow if a failed xfer is detected being reused. (but this
would anyway need a check in every tx transaction to see if status != SUCCESS
so is it worth ?)
Lot of overthinking for a one-liner :D ... sorry
Thanks,
Cristian
On Tue, Jun 08, 2021 at 11:10:48AM +0100, Cristian Marussi wrote:
Hi Sudeep,
On Mon, Jun 07, 2021 at 07:27:54PM +0100, Sudeep Holla wrote:
quoted
On Mon, Jun 07, 2021 at 07:01:37PM +0100, Cristian Marussi wrote:
quoted
On Mon, Jun 07, 2021 at 06:38:09PM +0100, Sudeep Holla wrote:
quoted
On Sun, Jun 06, 2021 at 11:12:23PM +0100, Cristian Marussi wrote:
quoted
When an SCMI command transfer fails due to some protocol issue an SCMI
error code is reported inside the SCMI message payload itself and it is
then retrieved and transcribed by the specific transport layer into the
xfer.hdr.status field by transport specific .fetch_response().
The core SCMI transport layer never explicitly reset xfer.hdr.status,
so when an xfer is reused, if a transport misbehaved in handling such
status field, we risk to see an invalid ghost error code.
Reset xfer.hdr.status to SCMI_SUCCESS right before each transfer is
started.
Any particular reason why it can't be part of xfer_get_init which has other
initialisations ? If none, please move it there.
Well it was there initially then I moved it here.
The reason is mostly the same as the reason for the other patch in this
series that adds a reinit_completion() in this same point: the core does
not forbid to reuse an xfer multiple times, once obtained with xfer_get()
or xfer_get_init(), and indeed some protocols do such a thing: they
implements such do_xfer looping and bails out on error.
Makes sense. But it is okay to retain xfer->transfer_id for every transfer
in such a loop ?
No you are right and indeed I saw that anomaly, but I have not addressed
it since, even if wrong, it is harmless and transfer_id is really used
only for debugging/profiling, while the missing reinit_completion is
potentially broken.
No agreed, just wanted to make it clear that if do_xfer is used in loops
the transfer_id remains same. I am fine with that.
quoted
quoted
In the way that it is implemented now in protocols poses no problem
indeed because the do_xfer loop bails out on error and the xfer is put,
but as soon as some protocol is implemented that violates this common
practice and it just keeps on reuse an xfer after an error fo other
do_xfers() this breaks...so it seemed more defensive to just reinit the
completion and the status before each send.
Fair enough. But they use it to send same message I guess, may be if it
gave error or something ? I would like to really know such a sequence
instead of assisting that 😉.
So the current real 'looping do_xfer' behavior is safe and so this missing
reinit is only potentially broken in the future, and we cannot really
know now in advance about some future protocol needs, but it seems as of now
wrong that you'll want to keep going on and reuse an xfer for the same command
after an error in your loop.
Fair enough.
On the other side we allow such behaviour, so I thought was good to
provide a safe net if it is misused.
Agreed.
But, beside this patches, that, as said, are more defensive that strictly
needed as of now, I think now it's worth mentioning that this same 'issue'
affects also, as an example, the new mechanism I introduced later in this
same series to always use monotonically increasing sequence number for
outgoing messages.
OK, I haven't seen that yet.
In that case I stick to the current behavior and I assign such monotonically
increasing sequence numbers to message during xfer_get, but the potential
issue is the same: if a do_xfer loop is used you end up reusing the same
seq_num for multiple do_xfers (so defeating really the mechanism itself
that aims not to reuse immediately the most recently used seq_num).
I assumed the do_xfer loop is to avoid those overheads with compromise of
reusing seq_num.
In that case I did this to keep it simple and to avoid placing more burden
on tx path by picking and assigning a seq_num upon each transfer...but, again,
also this behavior of picking a seq_num only at xfer_get is NOT really broken
as of now even for do_xfer loops since we bail out on error and you won't
really reuse that xfer.
OK.
It's just that in this seq_num selection case seems to add a lot of burden
and complexity if moved to the do_xfer phase, while status/reinit seemed
to me cheaper to move it in the do_xfer so I tried to play defensive.
I assumed the same as mentioned above.
At the end, in general I would say that all of these ops (status/reinit/
seq_nums/transfer_id) DO really belong logically to the do_xfer phase more than
to the xfer_get/xfer_get_init, but in reality we can cope with having them
@xfer_get/get_init and this keeps things simple and reduce burden, especially
in the monotonic seq_nums case: so I am not so sure anymore if it is fine to
move reinit/status to the do_xfer, as proposed here, while keeping seq_nums
(for good reasons) to the xfer_get phase, because we'd use 2 different strategies
to address similar issues.
I almost agreed with the change just to read here you think otherwise now 😄.
I would say: just keep reinit and status in the xfer_get phase instead and
maybe warn somehow if a failed xfer is detected being reused. (but this
would anyway need a check in every tx transaction to see if status != SUCCESS
so is it worth ?)
I have started thinking why do we need to reset the status. Since it is
always read from the shmem, do we really have to ?
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel