From: Yanteng Si <si.yanteng@linux.dev>
To: Bibo Mao <maobibo@loongson.cn>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Xianglai Li <lixianglai@loongson.cn>
Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: KVM: Access mailbox directly in mail_send()
Date: Thu, 31 Jul 2025 17:30:32 +0800 [thread overview]
Message-ID: <3fdcce8e-dff6-4871-82b3-571144a26c51@linux.dev> (raw)
In-Reply-To: <20250731075907.189847-1-maobibo@loongson.cn>
在 7/31/25 3:59 PM, Bibo Mao 写道:
> With function mail_send(), it is to write mailbox of other VCPUs.
> Existing simple APIs read_mailbox/write_mailbox can be used directly
> rather than send command on IOCSR address.
Hmm, that's indeed a feasible approach. However, I'm
curious: what is the purpose of designing IOCSR in
LoongArch? Is it merely to make things "complicated"?
Thanks,
Yanteng
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
> arch/loongarch/kvm/intc/ipi.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c
> index fe734dc062ed..832b2d4aa2ef 100644
> --- a/arch/loongarch/kvm/intc/ipi.c
> +++ b/arch/loongarch/kvm/intc/ipi.c
> @@ -134,7 +134,8 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)
>
> static int mail_send(struct kvm *kvm, uint64_t data)
> {
> - int cpu, mailbox, offset;
> + int i, cpu, mailbox, offset;
> + uint32_t val = 0, mask = 0;
> struct kvm_vcpu *vcpu;
>
> cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
> @@ -144,9 +145,18 @@ static int mail_send(struct kvm *kvm, uint64_t data)
> return -EINVAL;
> }
> mailbox = ((data & 0xffffffff) >> 2) & 0x7;
> - offset = IOCSR_IPI_BASE + IOCSR_IPI_BUF_20 + mailbox * 4;
> + offset = IOCSR_IPI_BUF_20 + mailbox * 4;
> + if ((data >> 27) & 0xf) {
> + val = read_mailbox(vcpu, offset, 4);
> + for (i = 0; i < 4; i++)
> + if (data & (BIT(27 + i)))
> + mask |= (0xff << (i * 8));
> + val &= mask;
> + }
>
> - return send_ipi_data(vcpu, offset, data);
> + val |= ((uint32_t)(data >> 32) & ~mask);
> + write_mailbox(vcpu, offset, val, 4);
> + return 0;
> }
>
> static int any_send(struct kvm *kvm, uint64_t data)
>
> base-commit: 038d61fd642278bab63ee8ef722c50d10ab01e8f
next prev parent reply other threads:[~2025-07-31 9:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 7:59 [PATCH] LoongArch: KVM: Access mailbox directly in mail_send() Bibo Mao
2025-07-31 9:30 ` Yanteng Si [this message]
2025-07-31 11:24 ` Bibo Mao
2025-08-01 5:32 ` Yanteng Si
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=3fdcce8e-dff6-4871-82b3-571144a26c51@linux.dev \
--to=si.yanteng@linux.dev \
--cc=chenhuacai@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixianglai@loongson.cn \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=zhaotianrui@loongson.cn \
/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;
as well as URLs for NNTP newsgroup(s).