Skip to contentSkip to conversation

driver: firmware: stratix10-svc: schedule thread out when there is no data reveived

PATCH In review Meng Li 2 participants 3 messages Nov 9, 2021 – Nov 15, 2021 Intel STRATIX10 firmware drivers

lore
Share & tools
lore

Meng Li

author
#0 lore raw

PATCH 1/1 driver: firmware: stratix10-svc: schedule thread out when there is no data reveived

From: Meng Li <[email protected]>

In thread svc_normal_to_secure_thread(), function kfifo_out_spinlocked() always return, so this thread can't release cpu even if there is no data received, and cause cpu is under heave load status. System performance is poor.

This issue is introduced by commit 7ca5ce896524("firmware: add Intel Stratix10 service layer driver")

Therefore, schedule this thread out when there is no data reveived, and wake it up after sending data to it.

Fixes 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver")
---
 drivers/firmware/stratix10-svc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/stratix10-svc.c +4 -1
index 2a7687911c09..ddb86d441726 100644
@@ -365,8 +365,10 @@ static int svc_normal_to_secure_thread(void *data)
 						pdata, sizeof(*pdata),
 						&ctrl->svc_fifo_lock);
 
-		if (!ret_fifo)
+		if (!ret_fifo) {
+			schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT);
 			continue;
+		}
 
 		pr_debug("get from FIFO pa=0x%016x, command=%u, size=%u\n",
 			 (unsigned int)pdata->paddr, pdata->command,
@@ -861,6 +863,7 @@ int stratix10_svc_send(struct stratix10_svc_chan *chan, void *msg)
 	ret = kfifo_in_spinlocked(&chan->ctrl->svc_fifo, p_data,
 				  sizeof(*p_data),
 				  &chan->ctrl->svc_fifo_lock);
+	wake_up_process(chan->ctrl->task);
 
 	kfree(p_data);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 5 lines · Meng Li

From: Meng Li <[email protected]>

In thread svc_normal_to_secure_thread(), function kfifo_out_spinlocked() always return, so this thread can't release cpu even if there is no data received, and cause cpu is under heave load status. System performance

do you mean "heavy"?

Quoted 6 lines

is poor.

This issue is introduced by commit 7ca5ce896524("firmware: add Intel Stratix10 service layer driver")

Therefore, schedule this thread out when there is no data reveived, and

s/reveived/received

Quoted 27 lines

wake it up after sending data to it.

Fixes 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver")
---
  drivers/firmware/stratix10-svc.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/stratix10-svc.c +3 -1
index 2a7687911c09..ddb86d441726 100644
@@ -365,8 +365,10 @@ static int svc_normal_to_secure_thread(void *data)
  						pdata, sizeof(*pdata),
  						&ctrl->svc_fifo_lock);
 
-		if (!ret_fifo)
+		if (!ret_fifo) {
+			schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT);
  			continue;
+		}
 
  		pr_debug("get from FIFO pa=0x%016x, command=%u, size=%u\n",
  			 (unsigned int)pdata->paddr, pdata->command,

drivers/firmware/stratix10-svc.c int stratix10_svc_send(struct stratix10_svc_chan *chan, void *msg) · line 869

Quoted 7 lines
drivers/firmware/stratix10-svc.c +1 -0
@@ -861,6 +863,7 @@ int stratix10_svc_send(struct stratix10_svc_chan *chan, void *msg)
  	ret = kfifo_in_spinlocked(&chan->ctrl->svc_fifo, p_data,
  				  sizeof(*p_data),
  				  &chan->ctrl->svc_fifo_lock);
+	wake_up_process(chan->ctrl->task);
 
  	kfree(p_data);
 

I've made above spelling fixes and have applied it.

Thanks,
Dinh

author
#2 lore raw
Quoted 13 lines

-----Original Message-----
From: Dinh Nguyen <[email protected]>
Sent: Saturday, November 13, 2021 3:35 AM
To: Li, Meng <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH] driver: firmware: stratix10-svc: schedule thread out when there is no data reveived

[Please note: This e-mail is from an EXTERNAL e-mail address]

On 11/9/21 1:46 AM, Meng Li wrote:

Quoted 8 lines
Quoted 6 lines

From: Meng Li <[email protected]>

In thread svc_normal_to_secure_thread(), function kfifo_out_spinlocked() always return, so this thread can't release cpu even if there is no data received, and cause cpu is under heave load status. System performance

do you mean "heavy"?

Yes!

Thanks for fixing these typos.
I will pay more attention next time.

Regards,
Limeng

Quoted 55 lines
Quoted 8 lines

is poor.

This issue is introduced by commit 7ca5ce896524("firmware: add Intel Stratix10 service layer driver")

Therefore, schedule this thread out when there is no data reveived, and

s/reveived/received

drivers/firmware/stratix10-svc.c static int svc_normal_to_secure_thread(void

Quoted 16 lines

wake it up after sending data to it.

Fixes 7ca5ce896524 ("firmware: add Intel Stratix10 service layer

driver")

---
  drivers/firmware/stratix10-svc.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/stratix10-svc.c +0 -0
index 2a7687911c09..ddb86d441726 100644
@@ -365,8 +365,10 @@ static int svc_normal_to_secure_thread(void

*data)

drivers/firmware/stratix10-svc.c static int svc_normal_to_secure_thread(void *data)

Quoted 13 lines
drivers/firmware/stratix10-svc.c +4 -2
                                              pdata, sizeof(*pdata),
                                              &ctrl->svc_fifo_lock);
 
-             if (!ret_fifo)
+             if (!ret_fifo) {
+
+ schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT);
                      continue;
+             }
 
              pr_debug("get from FIFO pa=0x%016x, command=%u, size=%u\n",
                       (unsigned int)pdata->paddr, pdata->command, @@
-861,6 +863,7 @@ int stratix10_svc_send(struct stratix10_svc_chan *chan,

void *msg)

Quoted 8 lines
      ret = kfifo_in_spinlocked(&chan->ctrl->svc_fifo, p_data,
                                sizeof(*p_data),
                                &chan->ctrl->svc_fifo_lock);

+ wake_up_process(chan->ctrl->task);

      kfree(p_data);

I've made above spelling fixes and have applied it.

Thanks,
Dinh