OSDN Git Service

firmware: arm_scmi: Move reinit_completion from scmi_xfer_get to do_xfer
authorCristian Marussi <cristian.marussi@arm.com>
Sun, 6 Jun 2021 22:12:24 +0000 (23:12 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Tue, 8 Jun 2021 15:04:54 +0000 (16:04 +0100)
Re-using timed out xfers in a loop can lead to issue if completion was
not properly reinitialized. Move reinit_completion from scmi_xfer_get to
do_xfer to avoid the issue.

Link: https://lore.kernel.org/r/20210606221232.33768-3-cristian.marussi@arm.com
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
[sudeep.holla: moved reinit_completion instead of adding another one]
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/driver.c

index 74986bf..80010d3 100644 (file)
@@ -241,7 +241,6 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle,
 
        xfer = &minfo->xfer_block[xfer_id];
        xfer->hdr.seq = xfer_id;
-       reinit_completion(&xfer->done);
        xfer->transfer_id = atomic_inc_return(&transfer_last_id);
 
        return xfer;
@@ -438,6 +437,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
         * the scmi_xfer structure.
         */
        xfer->hdr.protocol_id = pi->proto->id;
+       reinit_completion(&xfer->done);
 
        cinfo = idr_find(&info->tx_idr, xfer->hdr.protocol_id);
        if (unlikely(!cinfo))