diff mbox series

[02/15] firmware: arm_scmi: Skip scmi mbox channel setup for addtional devices

Message ID 20191210145345.11616-3-sudeep.holla@arm.com
State Superseded
Headers show
Series firmware: arm_scmi: Add support for multiple device per protocol | expand

Commit Message

Sudeep Holla Dec. 10, 2019, 2:53 p.m. UTC
Now that the scmi bus supports adding multiple devices per protocol,
and since scmi_create_protocol_device calls scmi_mbox_chan_setup,
we must avoid allocating and initialising the mbox channel if it is
already initialised.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

---
 drivers/firmware/arm_scmi/driver.c | 5 +++++
 1 file changed, 5 insertions(+)

--
2.17.1

Comments

Cristian Marussi Dec. 10, 2019, 5:33 p.m. UTC | #1
On 10/12/2019 14:53, Sudeep Holla wrote:
> Now that the scmi bus supports adding multiple devices per protocol,

> and since scmi_create_protocol_device calls scmi_mbox_chan_setup,

> we must avoid allocating and initialising the mbox channel if it is

> already initialised.

> 

> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> ---

>  drivers/firmware/arm_scmi/driver.c | 5 +++++

>  1 file changed, 5 insertions(+)

> 

> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c

> index dee7ce3bd815..2952fcd8dd8a 100644

> --- a/drivers/firmware/arm_scmi/driver.c

> +++ b/drivers/firmware/arm_scmi/driver.c

> @@ -735,6 +735,11 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev,

>  	idx = tx ? 0 : 1;

>  	idr = tx ? &info->tx_idr : &info->rx_idr;

> 

> +	/* check if already allocated, used for multiple device per protocol */

> +	cinfo = idr_find(idr, prot_id);

> +	if (cinfo)

> +		return 0;

> +

>  	if (scmi_mailbox_check(np, idx)) {

>  		cinfo = idr_find(idr, SCMI_PROTOCOL_BASE);

>  		if (unlikely(!cinfo)) /* Possible only if platform has no Rx */

> --

> 2.17.1

> 


Fine for me.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>



Cristian
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index dee7ce3bd815..2952fcd8dd8a 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -735,6 +735,11 @@  static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev,
 	idx = tx ? 0 : 1;
 	idr = tx ? &info->tx_idr : &info->rx_idr;

+	/* check if already allocated, used for multiple device per protocol */
+	cinfo = idr_find(idr, prot_id);
+	if (cinfo)
+		return 0;
+
 	if (scmi_mailbox_check(np, idx)) {
 		cinfo = idr_find(idr, SCMI_PROTOCOL_BASE);
 		if (unlikely(!cinfo)) /* Possible only if platform has no Rx */