firmware: arm_scmi: Augment SMC/HVC to allow optional interrupt
Subsystems (2)
v2 cover firmware: arm_scmi: Augment SMC/HVC to allow optional interrupt
v2 -- Correct commit message, s/msg/message/, and remove extra WS on
"dt-bindings" commit (Sudeep)
-- Change interrupt name to "message-serviced", move irq assignent to end
of function. (Sudeep)
v1 -- original.
Jim Quinlan (2):
dt-bindings: arm: Add optional interrupt to smc/hvc SCMI transport
firmware: arm_scmi: Augment SMC/HVC to allow optional interrupt
.../devicetree/bindings/arm/arm,scmi.txt | 8 ++++ drivers/firmware/arm_scmi/smc.c | 38 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH v2 1/2 dt-bindings: arm: Add optional interrupt to smc/hvc SCMI transport
In normal use of smc/hvc transport in SCMI the message completion is indicated by the return of the SMC call. This commit provides for an optional interrupt named "message-serviced" which is used instead to indicate the completion of a message.
--- Documentation/devicetree/bindings/arm/arm,scmi.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/arm/arm,scmi.txt +8 -0
@@ -31,6 +31,14 @@ Optional properties: - mbox-names: shall be "tx" or "rx" depending on mboxes entries. +- interrupts : when using smc or hvc transports, this optional + property indicates that msg completion by the platform is indicated + by an interrupt rather than by the return of the smc call. This + should not be used except when the platform requires such behavior. + +- interrupt-names : if "interrupts" is present, interrupt-names must also + be present and have the value "message-serviced". + See Documentation/devicetree/bindings/mailbox/mailbox.txt for more details about the generic mailbox controller and client driver bindings.
Signature · 1 line
2.17.1
Re: [PATCH v2 1/2] dt-bindings: arm: Add optional interrupt to smc/hvc SCMI transport
Quoted 19 lines · Jim Quinlan
In normal use of smc/hvc transport in SCMI the message completion is indicated by the return of the SMC call. This commit provides for an optional interrupt named "message-serviced" which is used instead to indicate the completion of a message.
Signed-off-by Jim Quinlan <[email protected]>--- Documentation/devicetree/bindings/arm/arm,scmi.txt | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/arm/arm,scmi.txt +0
-0@@ -31,6 +31,14 @@ Optional properties: - mbox-names: shall be "tx" or "rx" depending on mboxes entries.
Documentation/devicetree/bindings/arm/arm,scmi.txt Optional properties: · line 43
Quoted 10 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt +8
-0+- interrupts : when using smc or hvc transports, this optional + property indicates that msg completion by the platform is indicated + by an interrupt rather than by the return of the smc call. This + should not be used except when the platform requires such behavior. + +- interrupt-names : if "interrupts" is present, interrupt-names must also + be present and have the value "message-serviced". + See Documentation/devicetree/bindings/mailbox/mailbox.txt for more details about the generic mailbox controller and client driver bindings.
Hi Rob,
Are you okay with this commit?
Regards,
Jim Quinlan
Broadcom STB
Quoted 4 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt +0
-1--2.17.1
Rob Herring
maintainerRe: [PATCH v2 1/2] dt-bindings: arm: Add optional interrupt to smc/hvc SCMI transport
In reply to Jim QuinlanQuoted 15 lines · Jim Quinlan
In normal use of smc/hvc transport in SCMI the message completion is indicated by the return of the SMC call. This commit provides for an optional interrupt named "message-serviced" which is used instead to indicate the completion of a message.
Signed-off-by Jim Quinlan <[email protected]>--- Documentation/devicetree/bindings/arm/arm,scmi.txt | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/arm/arm,scmi.txt +0
-0
Documentation/devicetree/bindings/arm/arm,scmi.txt Optional properties: · line 40
Quoted 10 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt +7
-0@@ -31,6 +31,14 @@ Optional properties: - mbox-names: shall be "tx" or "rx" depending on mboxes entries. +- interrupts : when using smc or hvc transports, this optional + property indicates that msg completion by the platform is indicated + by an interrupt rather than by the return of the smc call. This + should not be used except when the platform requires such behavior. + +- interrupt-names : if "interrupts" is present, interrupt-names must also + be present and have the value "message-serviced".
Don't really need names when only one, but wouldn't 'a2p' be more concise and based on SCMI spec (just guessing...).
Quoted 7 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt +1
-0+ See Documentation/devicetree/bindings/mailbox/mailbox.txt for more details about the generic mailbox controller and client driver bindings.Signature · 1 line
2.17.1
Re: [PATCH v2 1/2] dt-bindings: arm: Add optional interrupt to smc/hvc SCMI transport
Quoted 20 lines · Rob Herring
Quoted 18 lines · Jim Quinlan
In normal use of smc/hvc transport in SCMI the message completion is indicated by the return of the SMC call. This commit provides for an optional interrupt named "message-serviced" which is used instead to indicate the completion of a message.
Signed-off-by Jim Quinlan <[email protected]>--- Documentation/devicetree/bindings/arm/arm,scmi.txt | 8 ++++++++ 1 file changed, 8 insertions(+)Documentation/devicetree/bindings/arm/arm,scmi.txt +0
-0@@ -31,6 +31,14 @@ Optional properties: - mbox-names: shall be "tx" or "rx" depending on mboxes entries.
Quoted 10 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt Optional properties: · line 40
Quoted 7 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt +7
-0+- interrupts : when using smc or hvc transports, this optional + property indicates that msg completion by the platform is indicated + by an interrupt rather than by the return of the smc call. This + should not be used except when the platform requires such behavior. + +- interrupt-names : if "interrupts" is present, interrupt-names must also + be present and have the value "message-serviced".Don't really need names when only one, but wouldn't 'a2p' be more concise and based on SCMI spec (just guessing...).
I gave it a name because (a) its presence is atypical/not common and
(b) future changes may add more interrupts and I don't want this interrupt at index 0.
As far as "message-serviced", this was Sudeep's suggestion, IIRC, although I had a similarly long name. Sudeep, are you okay with "a2p".
Thanks,
Jim
Quoted 10 lines
Quoted 8 lines
Documentation/devicetree/bindings/arm/arm,scmi.txt +1
-1+ See Documentation/devicetree/bindings/mailbox/mailbox.txt for more details about the generic mailbox controller and client driver bindings. --2.17.1
Signature · 11 lines
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
PATCH v2 2/2 firmware: arm_scmi: Augment SMC/HVC to allow optional interrupt
In reply to Jim QuinlanThe SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
--- drivers/firmware/arm_scmi/smc.c | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/smc.c +37 -1
@@ -9,9 +9,11 @@#include <linux/arm-smccc.h> #include <linux/device.h> #include <linux/err.h> +#include <linux/interrupt.h> #include <linux/mutex.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/of_irq.h> #include <linux/slab.h> #include "common.h"
@@ -23,6 +25,8 @@* @shmem: Transmit/Receive shared memory area * @shmem_lock: Lock to protect access to Tx/Rx shared memory area * @func_id: smc/hvc call function id +* @irq: Optional; employed when platforms indicates msg completion by intr. +* @tx_complete: Optional, employed only when irq is valid. */ struct scmi_smc {
@@ -30,8 +34,19 @@ struct scmi_smc {struct scmi_shared_mem __iomem *shmem;struct mutex shmem_lock;u32 func_id; +int irq; +struct completion tx_complete; }; +static irqreturn_t smc_msg_done_isr (int irq,void *data) +{ +struct scmi_smc *scmi_info = data; + +complete (&scmi_info->tx_complete); + +return IRQ_HANDLED ; +} +static bool smc_chan_available (struct device *dev,int idx) {struct device_node *np =of_parse_phandle (dev->of_node,"shmem" ,0 );
@@ -51,7 +66,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,struct resource res;struct device_node *np;u32 func_id; -int ret; +int ret, irq =0 ;if (!tx)return -ENODEV ;
@@ -79,10 +94,29 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,if (ret <0 )return ret; +/* +* If there is an interrupt named "message-serviced", then the +* service and completion of a message is signaled by an interrupt +* rather than by the return of the SMC call. +*/ + ret =of_irq_get_byname (cdev->of_node,"message-serviced" ); +if (ret >0 ) { + irq = ret; + ret =devm_request_irq (dev, irq, smc_msg_done_isr, +IRQF_NO_SUSPEND , +dev_name (dev), + scmi_info); +if (ret) { +dev_err (dev,"failed to setup SCMI smc irq\n" ); +return ret; + } +init_completion (&scmi_info->tx_complete); + } scmi_info->func_id = func_id; scmi_info->cinfo = cinfo;mutex_init (&scmi_info->shmem_lock); cinfo->transport_info = scmi_info; + scmi_info->irq = irq;return 0 ; }
@@ -111,6 +145,8 @@ static int smc_send_message(struct scmi_chan_info *cinfo,shmem_tx_prepare (scmi_info->shmem, xfer);arm_smccc_1_1_invoke (scmi_info->func_id,0 ,0 ,0 ,0 ,0 ,0 ,0 , &res); +if (scmi_info->irq) +wait_for_completion (&scmi_info->tx_complete);scmi_rx_callback (scmi_info->cinfo,shmem_read_header (scmi_info->shmem));mutex_unlock (&scmi_info->shmem_lock);
Signature · 1 line
2.17.1
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Signature · 2 lines
Regards, Sudeep
Hi, these are fast calls. Regards, Jim
Quoted 11 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) {
/* look for irq and request it */
}But we do use fast calls.
Regards,
Jim
Quoted 4 lines
--
Regards,
Sudeep
Quoted 12 lines · Jim Quinlan
Hi, these are fast calls. Regards, Jim
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Quoted 9 lines
Quoted 3 lines
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) { /* look for irq and request it */ }
Yes.
Quoted 1 line
But we do use fast calls.
What was the rationale for retaining fast SMC calls but use IRQ for Tx completion ?
Is it because you offload it to some other microprocessor and don't continue execution on secure side in whcih case you can afford fast call ?
--
Regards,
Sudeep
Quoted 26 lines · Sudeep Holla
Quoted 12 lines · Jim Quinlan
Hi, these are fast calls. Regards, Jim
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Quoted 9 lines
Quoted 3 lines
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) { /* look for irq and request it */ }Yes.
Quoted 7 lines
Quoted 1 line
But we do use fast calls.
What was the rationale for retaining fast SMC calls but use IRQ for Tx completion ?
Is it because you offload it to some other microprocessor and don't continue execution on secure side in whcih case you can afford fast call ?
Hi Sudeep,
I have an answer for this but allow me time to contact the platform FW engineer to make sure I have the full picture -- this may take a day or two. Regardless, our implementation has already "shipped" to customers for some time so we may not be able to change it. Regards, Jim
Quoted 5 lines
--
Regards,
Sudeep
Quoted 28 lines · Jim Quinlan
Quoted 26 lines · Sudeep Holla
Quoted 12 lines · Jim Quinlan
Hi, these are fast calls. Regards, Jim
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Quoted 9 lines
Quoted 3 lines
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) { /* look for irq and request it */ }Yes.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
But we do use fast calls.
What was the rationale for retaining fast SMC calls but use IRQ for Tx completion ?
Is it because you offload it to some other microprocessor and don't continue execution on secure side in whcih case you can afford fast call ?
Hi Sudeep,
Here is my understanding: Some SMC calls may take a few longer to complete than others. The longer ones tie up the CPU core that is handling the SMC call, and so nothing can be scheduled on that specific core. Unfortunately, we have a real-time OS that runs sporadically on one specific core and if that happens to be the same core that is handling the SMC, the RTOS will miss its deadline. So we need to have the SMC return immediately and use an SGI for task completion.
Regards,
Jim Quinlan
Broadcom STB
Quoted 12 lines
Hi Sudeep,
I have an answer for this but allow me time to contact the platform FW engineer to make sure I have the full picture -- this may take a day or two. Regardless, our implementation has already "shipped" to customers for some time so we may not be able to change it. Regards, JimQuoted 5 lines
--
Regards,
Sudeep
Quoted 29 lines · Jim Quinlan
Quoted 28 lines · Jim Quinlan
Quoted 26 lines · Sudeep Holla
Quoted 12 lines · Jim Quinlan
Hi, these are fast calls. Regards, Jim
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Quoted 9 lines
Quoted 3 lines
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) { /* look for irq and request it */ }Yes.
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
But we do use fast calls.
What was the rationale for retaining fast SMC calls but use IRQ for Tx completion ?
Is it because you offload it to some other microprocessor and don't continue execution on secure side in whcih case you can afford fast call ?
Hi Sudeep,
Thanks for the details. Unfortunately more questions:
Quoted 4 lines
Here is my understanding: Some SMC calls may take a few longer to complete than others. The longer ones tie up the CPU core that is handling the SMC call, and so nothing can be scheduled on that specific core.
So far good.
Quoted 6 lines
Unfortunately, we have a real-time OS that runs sporadically on one specific core and if that happens to be the same core that is handling the SMC, the RTOS will miss its deadline. So we need to have the SMC return immediately and use an SGI for task completion.
So it sounds more like it can't be fast call then.
Does that me, it will always return early and send SGI when the request is complete ?
1. If yes, what happens if there are multiple requests in parallel and second one completes before the first. Can we handle that with this patch set. Of will the second request fails until the first one is complete ? It extends to number of cpus in the system worst case.
2. If no, will this not cause issues if we unconditional wait for interrupt every single time ?
--
Regards,
Sudeep
Quoted 50 lines · Sudeep Holla
Quoted 29 lines · Jim Quinlan
Quoted 28 lines · Jim Quinlan
Quoted 26 lines · Sudeep Holla
Quoted 12 lines · Jim Quinlan
Hi, these are fast calls. Regards, Jim
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Quoted 9 lines
Quoted 3 lines
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) { /* look for irq and request it */ }Yes.
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
But we do use fast calls.
What was the rationale for retaining fast SMC calls but use IRQ for Tx completion ?
Is it because you offload it to some other microprocessor and don't continue execution on secure side in whcih case you can afford fast call ?
Hi Sudeep,
Thanks for the details. Unfortunately more questions:
Quoted 4 lines
Here is my understanding: Some SMC calls may take a few longer to complete than others. The longer ones tie up the CPU core that is handling the SMC call, and so nothing can be scheduled on that specific core.
So far good.
Quoted 8 lines
Quoted 6 lines
Unfortunately, we have a real-time OS that runs sporadically on one specific core and if that happens to be the same core that is handling the SMC, the RTOS will miss its deadline. So we need to have the SMC return immediately and use an SGI for task completion.
So it sounds more like it can't be fast call then.
Hi Sudeep,
To be honest, I'm not sure what the big difference between fast and slow SMC calls are other than the latter is "yielding" and interruptible. We cannot tolerate them being interruptible.
Quoted 3 lines
Does that me, it will always return early and send SGI when the request is complete ?
Most calls send the SGI and return immediately. The ones that take longer return from the SMC and send the SGI when the operation is completed.
Quoted 5 lines
1. If yes, what happens if there are multiple requests in parallel and second one completes before the first. Can we handle that with this patch set. Of will the second request fails until the first one is complete ? It extends to number of cpus in the system worst case.
With SCMI we only have one message pending at a time; perhaps I do not understand your question. Having the SMC return is mostly a no-op as far as the SCMI driver is concerned.
Our SCMI messages cannot fail. When we do have timeouts it indicates that something is wrong and needs to be fixed.
Regards,
Jim Quinlan
Broadcom STB
Quoted 7 lines
2. If no, will this not cause issues if we unconditional wait for interrupt every single time ?
--
Regards,
Sudeep
Quoted 58 lines · Jim Quinlan
Quoted 57 lines · Sudeep Holla
Quoted 29 lines · Jim Quinlan
Quoted 28 lines · Jim Quinlan
Quoted 26 lines · Sudeep Holla
Quoted 12 lines · Jim Quinlan
Hi, these are fast calls. Regards, Jim
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Jim Quinlan
The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed.
Quoted 9 lines
Quoted 3 lines
Sorry for missing to check with you earlier. Are these not fast smc calls ? Can we check the SMC Function IDs for the same and expect IRQ to be present if they are not fast calls ?
Hi, if I understand you correctly you want to do something like this:
if (! ARM_SMCCC_IS_FAST_CALL(func_id)) { /* look for irq and request it */ }Yes.
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
But we do use fast calls.
What was the rationale for retaining fast SMC calls but use IRQ for Tx completion ?
Is it because you offload it to some other microprocessor and don't continue execution on secure side in whcih case you can afford fast call ?
Hi Sudeep,
Thanks for the details. Unfortunately more questions:
Quoted 4 lines
Here is my understanding: Some SMC calls may take a few longer to complete than others. The longer ones tie up the CPU core that is handling the SMC call, and so nothing can be scheduled on that specific core.
So far good.
Quoted 6 lines
Unfortunately, we have a real-time OS that runs sporadically on one specific core and if that happens to be the same core that is handling the SMC, the RTOS will miss its deadline. So we need to have the SMC return immediately and use an SGI for task completion.
Quoted 7 lines
Quoted 1 line
So it sounds more like it can't be fast call then.
Hi Sudeep,
To be honest, I'm not sure what the big difference between fast and slow SMC calls are other than the latter is "yielding" and interruptible. We cannot tolerate them being interruptible.
OK
Quoted 6 lines
Quoted 3 lines
Does that me, it will always return early and send SGI when the request is complete ?
Most calls send the SGI and return immediately. The ones that take longer return from the SMC and send the SGI when the operation is completed.
That's relief.
Quoted 10 lines
Quoted 5 lines
1. If yes, what happens if there are multiple requests in parallel and second one completes before the first. Can we handle that with this patch set. Of will the second request fails until the first one is complete ? It extends to number of cpus in the system worst case.
With SCMI we only have one message pending at a time; perhaps I do not understand your question. Having the SMC return is mostly a no-op as far as the SCMI driver is concerned.
Yes we have lock, I forgot. There are requirements to make the smc atomic by some vendors, was thinking about that and forgot about the lock and how what I explained can never happen. Thanks for the patience.
If you ping and get Rob's ack on DT, I can take this patch along with DT bindings for now as is. We can always enhance if required.
Quoted 3 lines
Our SCMI messages cannot fail. When we do have timeouts it indicates that something is wrong and needs to be fixed.
Good to know.
--
Regards,
Sudeep