]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmGic: Fix maximum number of interrupts in GICv3
authorAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 9 Mar 2021 16:45:10 +0000 (16:45 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 27 May 2021 10:08:32 +0000 (10:08 +0000)
Bugzilla: 3415 (https://bugzilla.tianocore.org/show_bug.cgi?id=3415)

The GICv3 architecture supports up to 1020 ordinary interrupt
lines. The actual number of interrupts supported is described by the
ITLinesNumber field in the GICD_TYPER register. The total number of
implemented registers is normally calculated as
32*(ITLinesNumber+1). However, maximum value (0x1f) is a special case
since that would indicate that 1024 interrupts are implemented.

Add handling for this special case in ArmGicGetMaxNumInterrupts.

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
ArmPkg/Drivers/ArmGic/ArmGicLib.c

index 6b01c88206ad8adef3100dd44c0d57660db77783..bd4b5edb903f3846f4f0e431f93e001f01cd9e7d 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2018, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2021, Arm Limited. All rights reserved.\r
 *\r
 *  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 *\r
@@ -120,7 +120,14 @@ ArmGicGetMaxNumInterrupts (
   IN  INTN          GicDistributorBase\r
   )\r
 {\r
-  return 32 * ((MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F) + 1);\r
+  UINTN ItLines;\r
+\r
+  ItLines = MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F;\r
+\r
+  //\r
+  // Interrupt ID 1020-1023 are reserved.\r
+  //\r
+  return (ItLines == 0x1f) ? 1020 : 32 * (ItLines + 1);\r
 }\r
 \r
 VOID\r