From: Tom Lendacky <thomas.lendacky@amd.com>
To: Zehao Zhang <zhangzehao@vivo.com>,
bp@alien8.de, dionnaglaze@google.com, rafaelmendsr@gmail.com,
pgonda@google.com, crobinso@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] virt/coco/sev-guest: Convert to use time_after macro
Date: Fri, 7 Jul 2023 11:28:54 -0500 [thread overview]
Message-ID: <14a13f71-1deb-ad69-ddea-03d85a69c513@amd.com> (raw)
In-Reply-To: <20230707030635.67881-1-zhangzehao@vivo.com>
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;
> }
prev parent reply other threads:[~2023-07-07 16:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 3:06 Zehao Zhang
2023-07-07 16:28 ` Tom Lendacky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14a13f71-1deb-ad69-ddea-03d85a69c513@amd.com \
--to=thomas.lendacky@amd.com \
--cc=bp@alien8.de \
--cc=crobinso@redhat.com \
--cc=dionnaglaze@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pgonda@google.com \
--cc=rafaelmendsr@gmail.com \
--cc=zhangzehao@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®