]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/platform/amd: replace down_timeout() with down_interruptible()
authorJake Hillion <jake@hillion.co.uk>
Thu, 5 Jun 2025 18:09:27 +0000 (19:09 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 9 Jun 2025 07:50:42 +0000 (10:50 +0300)
Currently hsmp_send_message() uses down_timeout() with a 100ms timeout
to take the semaphore. However __hsmp_send_message(), the content of the
critical section, has a sleep in it. On systems with significantly
delayed scheduling behaviour this may take over 100ms.

Convert this method to down_interruptible(). Leave the error handling
the same as the documentation currently is not specific about what error
is returned.

Previous behaviour: a caller who competes with another caller stuck in
the critical section due to scheduler delays would receive -ETIME.

New behaviour: a caller who competes with another caller stuck in the
critical section due to scheduler delays will complete successfully.

Reviewed-by: Suma Hegde <suma.hegde@amd.com>
Tested-by: Suma Hegde <suma.hegde@amd.com>
Signed-off-by: Jake Hillion <jake@hillion.co.uk>
Link: https://lore.kernel.org/r/20250605-amd-hsmp-v2-2-a811bc3dd74a@hillion.co.uk
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/amd/hsmp/hsmp.c

index fa8bd5839dd289488bbd8ede4708c95d1ccc8e55..885e2f8136fd443d1ef9c89520c1862884b11748 100644 (file)
@@ -214,13 +214,7 @@ int hsmp_send_message(struct hsmp_message *msg)
                return -ENODEV;
        sock = &hsmp_pdev.sock[msg->sock_ind];
 
-       /*
-        * The time taken by smu operation to complete is between
-        * 10us to 1ms. Sometime it may take more time.
-        * In SMP system timeout of 100 millisecs should
-        * be enough for the previous thread to finish the operation
-        */
-       ret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT));
+       ret = down_interruptible(&sock->hsmp_sem);
        if (ret < 0)
                return ret;