public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: sean yang <seanyang230@gmail.com>
Cc: sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] firmware: arm_scmi: Add lock for mailbox do_xfer
Date: Mon, 23 Oct 2023 09:13:54 +0100	[thread overview]
Message-ID: <ZTYrQvfZlaX8Jnw1@pluto> (raw)
In-Reply-To: <CADGqjFJsG4=ZXAOPh930pZ5KT7n3xSDOUs68ZQsEo4t2uP-FPg@mail.gmail.com>

On Sun, Oct 22, 2023 at 08:15:17PM +0800, sean yang wrote:
> 
>    The function do_xfer may cause multithreading send message at almost
>    the same time.
> 
>    send_message will write the message in the shared memory, This causes
>    the second write
> 
>    to overwrite the first write, resulting in the loss of the first write.
> 
>    Add lock to avoid this situation. Release lock when the message has
>    responded.
> 
> 

Hi Xinglong ,

In the current SCMI stack, channels are protected from issues of
concurrency at the transport layer, not here in the core, because each
transport has different requirements in these regards.

As an example, VirtIO SCMI transport can indeed support multiple
outgoing messages in-flight if needed, so placing a global mutex here
around the send_message will kill this possibility. (and in this case
will serialize all because the muetx is not even per-channel but global)

Each SCMI transport has its own locking placed where it is deemed
needed, just look at smc or optee in send_message()/ mark_txdone().

Regarding mailboxes, which is probably the case you are referring to,
the shmem_tx_prepare accessors contain some spin_until_cond() to protect
the shared mem, but the core of the mutual exclusion around the channel
is done really by the mailbox framework, since we register the scmi mbox
client with 'knows_txdone = true' and then we use mbox_send_message() and
mbox_client_txdone() to enqueue messages to the mailbox framework: in a
nutshell, no message transmission will be attempted if the previous one
has not completed by calling mbox_client_txdone().

I've never seen any anomalies on this. Did you notice any issue with
mailboxes ? What is your setup ?

Thanks,
Cristian


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

       reply	other threads:[~2023-10-23  8:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CADGqjFJsG4=ZXAOPh930pZ5KT7n3xSDOUs68ZQsEo4t2uP-FPg@mail.gmail.com>
2023-10-23  8:13 ` Cristian Marussi [this message]
2023-10-23  8:58 ` [PATCH] firmware: arm_scmi: Add lock for mailbox do_xfer Sudeep Holla
     [not found] <PUZPR06MB5498D2331BB04DAE393F9447F0D4A@PUZPR06MB5498.apcprd06.prod.outlook.com>
2023-10-19  9:14 ` Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZTYrQvfZlaX8Jnw1@pluto \
    --to=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=seanyang230@gmail.com \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox