* [PATCH] virt/coco/sev-guest: Convert to use time_after macro
@ 2023-07-07 3:06 Zehao Zhang
2023-07-07 16:28 ` Tom Lendacky
0 siblings, 1 reply; 2+ messages in thread
From: Zehao Zhang @ 2023-07-07 3:06 UTC (permalink / raw)
To: thomas.lendacky, bp, bp, dionnaglaze, rafaelmendsr, pgonda, crobinso
Cc: linux-kernel, Zehao Zhang
Use time_after macro instead of opening it for readability.
time_after(a,b) returns true if the time a is after time b.
The macro deals with the time wrapper correctly. If the timer wrap
changes in future, there will be no need to alter the driver code.
Signed-off-by: Zehao Zhang <zhangzehao@vivo.com>
---
drivers/virt/coco/sev-guest/sev-guest.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index 97dbe715e96a..f17302117c18 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -21,6 +21,7 @@
#include <linux/psp-sev.h>
#include <uapi/linux/sev-guest.h>
#include <uapi/linux/psp-sev.h>
+#include <linux/jiffies.h>
#include <asm/svm.h>
#include <asm/sev.h>
@@ -383,7 +384,7 @@ static int __handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code,
* message sequence number on a different message.
*/
case -EAGAIN:
- if (jiffies - req_start > SNP_REQ_MAX_RETRY_DURATION) {
+ if (time_after(jiffies, req_start + SNP_REQ_MAX_RETRY_DURATION)) {
rc = -ETIMEDOUT;
break;
}
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] virt/coco/sev-guest: Convert to use time_after macro
2023-07-07 3:06 [PATCH] virt/coco/sev-guest: Convert to use time_after macro Zehao Zhang
@ 2023-07-07 16:28 ` Tom Lendacky
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lendacky @ 2023-07-07 16:28 UTC (permalink / raw)
To: Zehao Zhang, bp, dionnaglaze, rafaelmendsr, pgonda, crobinso; +Cc: linux-kernel
On 7/6/23 22:06, Zehao Zhang wrote:
> Use time_after macro instead of opening it for readability.
>
> time_after(a,b) returns true if the time a is after time b.
>
> The macro deals with the time wrapper correctly. If the timer wrap
> changes in future, there will be no need to alter the driver code.
>
> Signed-off-by: Zehao Zhang <zhangzehao@vivo.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> drivers/virt/coco/sev-guest/sev-guest.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
> index 97dbe715e96a..f17302117c18 100644
> --- a/drivers/virt/coco/sev-guest/sev-guest.c
> +++ b/drivers/virt/coco/sev-guest/sev-guest.c
> @@ -21,6 +21,7 @@
> #include <linux/psp-sev.h>
> #include <uapi/linux/sev-guest.h>
> #include <uapi/linux/psp-sev.h>
> +#include <linux/jiffies.h>
>
> #include <asm/svm.h>
> #include <asm/sev.h>
> @@ -383,7 +384,7 @@ static int __handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code,
> * message sequence number on a different message.
> */
> case -EAGAIN:
> - if (jiffies - req_start > SNP_REQ_MAX_RETRY_DURATION) {
> + if (time_after(jiffies, req_start + SNP_REQ_MAX_RETRY_DURATION)) {
> rc = -ETIMEDOUT;
> break;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-07 16:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-07 3:06 [PATCH] virt/coco/sev-guest: Convert to use time_after macro Zehao Zhang
2023-07-07 16:28 ` Tom Lendacky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®