* [PATCH 1/1] rivers: scmi: Add completion timeout handling for raw mode transfers [not found] <20250929131422.525315-1-a.shimko.dev@gmail.com> @ 2025-09-29 13:14 ` Artem Shimko 2025-09-29 13:59 ` Artem Shimko 0 siblings, 1 reply; 3+ messages in thread From: Artem Shimko @ 2025-09-29 13:14 UTC (permalink / raw) To: Sudeep Holla, Cristian Marussi Cc: a.shimko.dev, arm-scmi, linux-arm-kernel, linux-kernel Fix race conditions in SCMI raw mode implementation by adding proper completion timeout handling. Multiple tests in the SCMI test suite were failing due to early clearing of SCMI_XFER_FLAG_IS_RAW flag in scmi_xfer_raw_put() function. The root cause: Tests were failing on poll() system calls with this condition: if (!raw || (idx == SCMI_RAW_REPLY_QUEUE && !SCMI_XFER_IS_RAW(xfer))) return; The SCMI_XFER_FLAG_IS_RAW flag was being cleared prematurely before the transfer completion was properly acknowledged, causing the poll to return on timeout and tests to fail. Сhanges implemented: 1. Add completion wait with timeout in scmi_xfer_raw_worker() 2. Signal completion in scmi_raw_message_report() This ensures: - Proper synchronization between transfer completion and flag clearing - Prevention of indefinite blocking with timeout safety mechanism - Stable test execution by maintaining correct flag states arm scmi tests: https://gitlab.arm.com/tests/scmi-tests/-/releases Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com> --- drivers/firmware/arm_scmi/raw_mode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c index 73db5492ab44..fb83beb42e7b 100644 --- a/drivers/firmware/arm_scmi/raw_mode.c +++ b/drivers/firmware/arm_scmi/raw_mode.c @@ -468,6 +468,12 @@ static void scmi_xfer_raw_worker(struct work_struct *work) ret = scmi_xfer_raw_wait_for_message_response(cinfo, xfer, timeout_ms); + if (!ret) + if (!wait_for_completion_timeout(&xfer->done, timeout_ms)) + dev_err(dev, + "timed out in RAW resp - HDR:%08X\n", + pack_scmi_header(&xfer->hdr)); + if (!ret && xfer->hdr.status) ret = scmi_to_linux_errno(xfer->hdr.status); @@ -1381,6 +1387,8 @@ void scmi_raw_message_report(void *r, struct scmi_xfer *xfer, if (!raw || (idx == SCMI_RAW_REPLY_QUEUE && !SCMI_XFER_IS_RAW(xfer))) return; + complete(&xfer->done); + dev = raw->handle->dev; q = scmi_raw_queue_select(raw, idx, SCMI_XFER_IS_CHAN_SET(xfer) ? chan_id : 0); -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] rivers: scmi: Add completion timeout handling for raw mode transfers 2025-09-29 13:14 ` [PATCH 1/1] rivers: scmi: Add completion timeout handling for raw mode transfers Artem Shimko @ 2025-09-29 13:59 ` Artem Shimko 0 siblings, 0 replies; 3+ messages in thread From: Artem Shimko @ 2025-09-29 13:59 UTC (permalink / raw) To: Artem Shimko Cc: Sudeep Holla, Cristian Marussi, arm-scmi, linux-arm-kernel, linux-kernel Hello maintainers and reviewers, Sorry, these patches were sent in error. Please disregard them. Thank you for your consideration. Best regards, Artem Shimko On Mon, Sep 29, 2025 at 4:14 PM Artem Shimko <artyom.shimko@gmail.com> wrote: > > Fix race conditions in SCMI raw mode implementation by adding proper > completion timeout handling. Multiple tests in the SCMI test suite > were failing due to early clearing of SCMI_XFER_FLAG_IS_RAW flag in > scmi_xfer_raw_put() function. > > The root cause: > Tests were failing on poll() system calls with this condition: > if (!raw || (idx == SCMI_RAW_REPLY_QUEUE && !SCMI_XFER_IS_RAW(xfer))) > return; > > The SCMI_XFER_FLAG_IS_RAW flag was being cleared prematurely before > the transfer completion was properly acknowledged, causing the poll > to return on timeout and tests to fail. > > Сhanges implemented: > 1. Add completion wait with timeout in scmi_xfer_raw_worker() > 2. Signal completion in scmi_raw_message_report() > > This ensures: > - Proper synchronization between transfer completion and flag clearing > - Prevention of indefinite blocking with timeout safety mechanism > - Stable test execution by maintaining correct flag states > > arm scmi tests: https://gitlab.arm.com/tests/scmi-tests/-/releases > > Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com> > --- > drivers/firmware/arm_scmi/raw_mode.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c > index 73db5492ab44..fb83beb42e7b 100644 > --- a/drivers/firmware/arm_scmi/raw_mode.c > +++ b/drivers/firmware/arm_scmi/raw_mode.c > @@ -468,6 +468,12 @@ static void scmi_xfer_raw_worker(struct work_struct *work) > > ret = scmi_xfer_raw_wait_for_message_response(cinfo, xfer, > timeout_ms); > + if (!ret) > + if (!wait_for_completion_timeout(&xfer->done, timeout_ms)) > + dev_err(dev, > + "timed out in RAW resp - HDR:%08X\n", > + pack_scmi_header(&xfer->hdr)); > + > if (!ret && xfer->hdr.status) > ret = scmi_to_linux_errno(xfer->hdr.status); > > @@ -1381,6 +1387,8 @@ void scmi_raw_message_report(void *r, struct scmi_xfer *xfer, > if (!raw || (idx == SCMI_RAW_REPLY_QUEUE && !SCMI_XFER_IS_RAW(xfer))) > return; > > + complete(&xfer->done); > + > dev = raw->handle->dev; > q = scmi_raw_queue_select(raw, idx, > SCMI_XFER_IS_CHAN_SET(xfer) ? chan_id : 0); > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20250929131011.524842-1-a.shimko.dev@gmail.com>]
* [PATCH 1/1] rivers: scmi: Add completion timeout handling for raw mode transfers [not found] <20250929131011.524842-1-a.shimko.dev@gmail.com> @ 2025-09-29 13:10 ` Artem Shimko 0 siblings, 0 replies; 3+ messages in thread From: Artem Shimko @ 2025-09-29 13:10 UTC (permalink / raw) To: Sudeep Holla, Cristian Marussi Cc: a.shimko.dev, arm-scmi, linux-arm-kernel, linux-kernel Fix race conditions in SCMI raw mode implementation by adding proper completion timeout handling. Multiple tests in the SCMI test suite were failing due to early clearing of SCMI_XFER_FLAG_IS_RAW flag in scmi_xfer_raw_put() function. The root cause: Tests were failing on poll() system calls with this condition: if (!raw || (idx == SCMI_RAW_REPLY_QUEUE && !SCMI_XFER_IS_RAW(xfer))) return; The SCMI_XFER_FLAG_IS_RAW flag was being cleared prematurely before the transfer completion was properly acknowledged, causing the poll to return on timeout and tests to fail. Сhanges implemented: 1. Add completion wait with timeout in scmi_xfer_raw_worker() 2. Signal completion in scmi_raw_message_report() This ensures: - Proper synchronization between transfer completion and flag clearing - Prevention of indefinite blocking with timeout safety mechanism - Stable test execution by maintaining correct flag states arm scmi tests: https://gitlab.arm.com/tests/scmi-tests/-/releases Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com> --- drivers/firmware/arm_scmi/raw_mode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c index 73db5492ab44..fb83beb42e7b 100644 --- a/drivers/firmware/arm_scmi/raw_mode.c +++ b/drivers/firmware/arm_scmi/raw_mode.c @@ -468,6 +468,12 @@ static void scmi_xfer_raw_worker(struct work_struct *work) ret = scmi_xfer_raw_wait_for_message_response(cinfo, xfer, timeout_ms); + if (!ret) + if (!wait_for_completion_timeout(&xfer->done, timeout_ms)) + dev_err(dev, + "timed out in RAW resp - HDR:%08X\n", + pack_scmi_header(&xfer->hdr)); + if (!ret && xfer->hdr.status) ret = scmi_to_linux_errno(xfer->hdr.status); @@ -1381,6 +1387,8 @@ void scmi_raw_message_report(void *r, struct scmi_xfer *xfer, if (!raw || (idx == SCMI_RAW_REPLY_QUEUE && !SCMI_XFER_IS_RAW(xfer))) return; + complete(&xfer->done); + dev = raw->handle->dev; q = scmi_raw_queue_select(raw, idx, SCMI_XFER_IS_CHAN_SET(xfer) ? chan_id : 0); -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-29 13:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250929131422.525315-1-a.shimko.dev@gmail.com>
2025-09-29 13:14 ` [PATCH 1/1] rivers: scmi: Add completion timeout handling for raw mode transfers Artem Shimko
2025-09-29 13:59 ` Artem Shimko
[not found] <20250929131011.524842-1-a.shimko.dev@gmail.com>
2025-09-29 13:10 ` Artem Shimko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox