From: Jay Chang <jay.chang@sifive.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
Jay Chang <jay.chang@sifive.com>,
Frank Chang <frank.chang@sifive.com>
Subject: [PATCH 2/2] hw/riscv: Refactor riscv_iommu_ctx_put() for Bare mode handling
Date: Thu, 11 Dec 2025 10:56:11 +0800 [thread overview]
Message-ID: <20251211025611.99038-3-jay.chang@sifive.com> (raw)
In-Reply-To: <20251211025611.99038-1-jay.chang@sifive.com>
Align SPEC: Bare mode contexts are not cached, so they require
direct memory deallocation via g_free instead of hash table cleanup.
Signed-off-by: Jay Chang <jay.chang@sifive.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>
---
hw/riscv/riscv-iommu.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c
index 79eee2e85e..fca5763858 100644
--- a/hw/riscv/riscv-iommu.c
+++ b/hw/riscv/riscv-iommu.c
@@ -1344,7 +1344,16 @@ static RISCVIOMMUContext *riscv_iommu_ctx(RISCVIOMMUState *s,
static void riscv_iommu_ctx_put(RISCVIOMMUState *s, void *ref)
{
- if (ref) {
+ unsigned mode = get_field(s->ddtp, RISCV_IOMMU_DDTP_MODE);
+
+ if (!ref) {
+ return;
+ }
+
+ /* ref is pointing to ctx in Bare mode. Bare mode ctx is not cached */
+ if (mode == RISCV_IOMMU_DDTP_MODE_BARE) {
+ g_free(ref);
+ } else {
g_hash_table_unref((GHashTable *)ref);
}
}
--
2.48.1
prev parent reply other threads:[~2025-12-11 2:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 2:56 [PATCH 0/2] Don't insert DDT cache in Bare mode Jay Chang
2025-12-11 2:56 ` [PATCH 1/2] hw/riscv: " Jay Chang
2025-12-11 2:56 ` Jay Chang [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=20251211025611.99038-3-jay.chang@sifive.com \
--to=jay.chang@sifive.com \
--cc=alistair.francis@wdc.com \
--cc=dbarboza@ventanamicro.com \
--cc=frank.chang@sifive.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).