]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
irqchip/riscv-imsic: Add nr_guest_files in per-HART local config
authorGuo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
Mon, 25 May 2026 09:49:44 +0000 (15:19 +0530)
committerAnup Patel <anup@brainfault.org>
Tue, 26 May 2026 03:35:10 +0000 (09:05 +0530)
Add nr_guest_files in per-HART local config to represent the number of
guest files available on a particular HART whereas the nr_guest_files
in the global config represents the number of guest files available
across all HARTs.

This allows KVM RISC-V to use nr_guest_files from per-HART local
config for asymmetric big.Little systems.

Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
Acked-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260525094945.3721783-2-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
drivers/irqchip/irq-riscv-imsic-state.c
include/linux/irqchip/riscv-imsic.h

index e3ed874d89e73bec97f08559cab9e2a805f5409e..b8d1bbbf42f7301a89c972b46d10c949b0fea392 100644 (file)
@@ -920,13 +920,12 @@ int __init imsic_setup_state(struct fwnode_handle *fwnode, void *opaque)
                local->msi_va = mmios_va[index] + reloff;
 
                /*
-                * KVM uses global->nr_guest_files to determine the available guest
-                * interrupt files on each CPU. Take the minimum number of guest
-                * interrupt files across all CPUs to avoid KVM incorrectly allocating
-                * an unexisted or unmapped guest interrupt file on some CPUs.
+                * KVM uses both local->nr_guest_files and global->nr_guest_files
+                * to determine the available guest interrupt files on each CPU.
                 */
                nr_guest_files = (resource_size(&mmios[index]) - reloff) / IMSIC_MMIO_PAGE_SZ - 1;
-               global->nr_guest_files = min(global->nr_guest_files, nr_guest_files);
+               local->nr_guest_files = min((BIT(global->guest_index_bits) - 1), nr_guest_files);
+               global->nr_guest_files = min(global->nr_guest_files, local->nr_guest_files);
 
                nr_handlers++;
        }
index 4b348836de7adaa3790c31968b8536933a66bbfa..61af3a5bea09bdbdf61d75e79e9571def765c1b1 100644 (file)
@@ -40,6 +40,9 @@
 struct imsic_local_config {
        phys_addr_t                             msi_pa;
        void __iomem                            *msi_va;
+
+       /* Number of guest interrupt files per-HART */
+       u32                                     nr_guest_files;
 };
 
 struct imsic_global_config {
@@ -68,7 +71,7 @@ struct imsic_global_config {
        /* Number of guest interrupt identities */
        u32                                     nr_guest_ids;
 
-       /* Number of guest interrupt files per core */
+       /* Number of guest interrupt files across all HARTs */
        u32                                     nr_guest_files;
 
        /* Per-CPU IMSIC addresses */