2021-12-31 15:50:08

by Rajat Khandelwal

[permalink] [raw]
Subject: RE: [PATCH] platform/x86: intel_scu_ipc: Keep polling IPC status if it reads IPC_STATUS_ERR

Adding ++Heikki

Thanks
Rajat
-----Original Message-----
From: Khandelwal, Rajat <[email protected]>
Sent: Thursday, December 30, 2021 1:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; Khandelwal, Rajat <[email protected]>; Westerberg, Mika <[email protected]>
Subject: [PATCH] platform/x86: intel_scu_ipc: Keep polling IPC status if it reads IPC_STATUS_ERR

The current implementation returns -EIO if and when IPC_STATUS_ERR is returned and returns -ETIMEDOUT even if the status is busy.
This patch polls the IPC status even if IPC_STATUS_ERR is returned until timeout expires and returns -EBUSY if the status shows busy.
Observed in multiple scenarios, trying to fetch the status of IPC after it shows ERR sometimes eradicates the ERR status.

Signed-off-by: Rajat-Khandelwal <[email protected]>
---
drivers/platform/x86/intel_scu_ipc.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 7cc9089d1e14..1f90acaa7212 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -233,17 +233,23 @@ static inline u32 ipc_data_readl(struct intel_scu_ipc_dev *scu, u32 offset) static inline int busy_loop(struct intel_scu_ipc_dev *scu) {
unsigned long end = jiffies + IPC_TIMEOUT;
+ u32 status;

do {
- u32 status;
-
status = ipc_read_status(scu);
- if (!(status & IPC_STATUS_BUSY))
- return (status & IPC_STATUS_ERR) ? -EIO : 0;
+ if (!(status & IPC_STATUS_BUSY)) {
+ if (!(status & IPC_STATUS_ERR))
+ return 0;
+ }

usleep_range(50, 100);
} while (time_before(jiffies, end));

+ if (status & IPC_STATUS_BUSY)
+ return -EBUSY;
+ if (status & IPC_STATUS_ERR)
+ return -EIO;
+
return -ETIMEDOUT;
}

--
2.17.1



2022-01-01 13:04:00

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH] platform/x86: intel_scu_ipc: Keep polling IPC status if it reads IPC_STATUS_ERR

Hi Rajat,

On 12/31/21 16:49, Khandelwal, Rajat wrote:
> Adding ++Heikki
>
> Thanks
> Rajat

If you want me to apply this, please send this as a proper patch, not as an inline
forward to me, with the [email protected] list in the Cc.

Regards,

Hans


> -----Original Message-----
> From: Khandelwal, Rajat <[email protected]>
> Sent: Thursday, December 30, 2021 1:54 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; Khandelwal, Rajat <[email protected]>; Westerberg, Mika <[email protected]>
> Subject: [PATCH] platform/x86: intel_scu_ipc: Keep polling IPC status if it reads IPC_STATUS_ERR
>
> The current implementation returns -EIO if and when IPC_STATUS_ERR is returned and returns -ETIMEDOUT even if the status is busy.
> This patch polls the IPC status even if IPC_STATUS_ERR is returned until timeout expires and returns -EBUSY if the status shows busy.
> Observed in multiple scenarios, trying to fetch the status of IPC after it shows ERR sometimes eradicates the ERR status.
>
> Signed-off-by: Rajat-Khandelwal <[email protected]>
> ---
> drivers/platform/x86/intel_scu_ipc.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
> index 7cc9089d1e14..1f90acaa7212 100644
> --- a/drivers/platform/x86/intel_scu_ipc.c
> +++ b/drivers/platform/x86/intel_scu_ipc.c
> @@ -233,17 +233,23 @@ static inline u32 ipc_data_readl(struct intel_scu_ipc_dev *scu, u32 offset) static inline int busy_loop(struct intel_scu_ipc_dev *scu) {
> unsigned long end = jiffies + IPC_TIMEOUT;
> + u32 status;
>
> do {
> - u32 status;
> -
> status = ipc_read_status(scu);
> - if (!(status & IPC_STATUS_BUSY))
> - return (status & IPC_STATUS_ERR) ? -EIO : 0;
> + if (!(status & IPC_STATUS_BUSY)) {
> + if (!(status & IPC_STATUS_ERR))
> + return 0;
> + }
>
> usleep_range(50, 100);
> } while (time_before(jiffies, end));
>
> + if (status & IPC_STATUS_BUSY)
> + return -EBUSY;
> + if (status & IPC_STATUS_ERR)
> + return -EIO;
> +
> return -ETIMEDOUT;
> }
>
> --
> 2.17.1
>