platform/x86: amd-pmc: Fix command completion code
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Tue, 29 Jun 2021 08:47:57 +0000 (14:17 +0530)
committerHans de Goede <hdegoede@redhat.com>
Wed, 14 Jul 2021 13:09:01 +0000 (15:09 +0200)
commit95e1b60f8dc8f225b14619e9aca9bdd7d99167db
treeff1e620c8aeda493cbdeb41c78f37eb5c93f7ad1
parent95d429206c97cf109591009fa386004191c62c47
platform/x86: amd-pmc: Fix command completion code

The protocol to submit a job request to SMU is to wait for
AMD_PMC_REGISTER_RESPONSE to return 1,meaning SMU is ready to take
requests. PMC driver has to make sure that the response code is always
AMD_PMC_RESULT_OK before making any command submissions.

When we submit a message to SMU, we have to wait until it processes
the request. Adding a read_poll_timeout() check as this was missing in
the existing code.

Also, add a mutex to protect amd_pmc_send_cmd() calls to SMU.

Fixes: 156ec4731cb2 ("platform/x86: amd-pmc: Add AMD platform support for S2Idle")
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Acked-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210629084803.248498-2-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/amd-pmc.c