public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: [PATCH] Keep polling IPC status if it reads IPC_STATUS_BUSY or IPC_STATUS_ERR until timeout expires
       [not found] <20211229132948.4738-1-rajat.khandelwal@intel.com>
@ 2021-12-29 16:13 ` Khandelwal, Rajat
  2021-12-29 16:19   ` mika.westerberg
  0 siblings, 1 reply; 2+ messages in thread
From: Khandelwal, Rajat @ 2021-12-29 16:13 UTC (permalink / raw)
  To: mika.westerberg@linux.intel.com, Westerberg, Mika
  Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org

Hi @Westerberg, Mika
This was the original message!

-----Original Message-----
From: Khandelwal, Rajat <rajat.khandelwal@intel.com> 
Sent: Wednesday, December 29, 2021 7:00 PM
To: mika.westerberg@linux.intel.com
Cc: Khandelwal, Rajat <rajat.khandelwal@intel.com>; linux-kernel@vger.kernel.org; platform-driver-x86@vger.kernel.org
Subject: [PATCH] Keep polling IPC status if it reads IPC_STATUS_BUSY or IPC_STATUS_ERR until timeout expires

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 <rajat.khandelwal@intel.com>
---
 drivers/platform/x86/intel_scu_ipc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 7cc9089d1e14..91f716e84474 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -233,17 +233,19 @@ 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_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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Keep polling IPC status if it reads IPC_STATUS_BUSY or IPC_STATUS_ERR until timeout expires
  2021-12-29 16:13 ` [PATCH] Keep polling IPC status if it reads IPC_STATUS_BUSY or IPC_STATUS_ERR until timeout expires Khandelwal, Rajat
@ 2021-12-29 16:19   ` mika.westerberg
  0 siblings, 0 replies; 2+ messages in thread
From: mika.westerberg @ 2021-12-29 16:19 UTC (permalink / raw)
  To: Khandelwal, Rajat
  Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org

Hi,

Now I got it.

Please run checkpatch.pl and fix all the issues it reports, and change
the $subject line to match the style in that file and then re-send.
Thanks!

On Wed, Dec 29, 2021 at 06:13:56PM +0200, Khandelwal, Rajat wrote:
> Hi @Westerberg, Mika
> This was the original message!
> 
> -----Original Message-----
> From: Khandelwal, Rajat <rajat.khandelwal@intel.com>
> Sent: Wednesday, December 29, 2021 7:00 PM
> To: mika.westerberg@linux.intel.com
> Cc: Khandelwal, Rajat <rajat.khandelwal@intel.com>; linux-kernel@vger.kernel.org; platform-driver-x86@vger.kernel.org
> Subject: [PATCH] Keep polling IPC status if it reads IPC_STATUS_BUSY or IPC_STATUS_ERR until timeout expires
> 
> 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 <rajat.khandelwal@intel.com>
> ---
>  drivers/platform/x86/intel_scu_ipc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
> index 7cc9089d1e14..91f716e84474 100644
> --- a/drivers/platform/x86/intel_scu_ipc.c
> +++ b/drivers/platform/x86/intel_scu_ipc.c
> @@ -233,17 +233,19 @@ 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_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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-29 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20211229132948.4738-1-rajat.khandelwal@intel.com>
2021-12-29 16:13 ` [PATCH] Keep polling IPC status if it reads IPC_STATUS_BUSY or IPC_STATUS_ERR until timeout expires Khandelwal, Rajat
2021-12-29 16:19   ` mika.westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox