Skip to content

Commit a0a18e9

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: Reject clear channel request on A2P
The clear channel transport operation is supposed to be called exclusively on the P2A channel from the agent, since it relinquishes the ownership of the channel to the platform, after this latter has initiated some sort of P2A communication. Make sure that, if it is ever called on a A2P, is logged and ignored. Signed-off-by: Cristian Marussi <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Message-Id: <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 2954160 commit a0a18e9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/firmware/arm_scmi/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
163163
* used to initialize this channel
164164
* @dev: Reference to device in the SCMI hierarchy corresponding to this
165165
* channel
166+
* @is_p2a: A flag to identify a channel as P2A (RX)
166167
* @rx_timeout_ms: The configured RX timeout in milliseconds.
167168
* @handle: Pointer to SCMI entity handle
168169
* @no_completion_irq: Flag to indicate that this channel has no completion
@@ -174,6 +175,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
174175
struct scmi_chan_info {
175176
int id;
176177
struct device *dev;
178+
bool is_p2a;
177179
unsigned int rx_timeout_ms;
178180
struct scmi_handle *handle;
179181
bool no_completion_irq;

drivers/firmware/arm_scmi/driver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,11 @@ static inline void scmi_xfer_command_release(struct scmi_info *info,
10481048
static inline void scmi_clear_channel(struct scmi_info *info,
10491049
struct scmi_chan_info *cinfo)
10501050
{
1051+
if (!cinfo->is_p2a) {
1052+
dev_warn(cinfo->dev, "Invalid clear on A2P channel !\n");
1053+
return;
1054+
}
1055+
10511056
if (info->desc->ops->clear_channel)
10521057
info->desc->ops->clear_channel(cinfo);
10531058
}
@@ -2638,6 +2643,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,
26382643
if (!cinfo)
26392644
return -ENOMEM;
26402645

2646+
cinfo->is_p2a = !tx;
26412647
cinfo->rx_timeout_ms = info->desc->max_rx_timeout_ms;
26422648

26432649
/* Create a unique name for this transport device */

0 commit comments

Comments
 (0)