All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] irqchip/gic-v3-its: Size the collection table for all possible CPUs
@ 2026-11-17 12:31 Jinjie Ruan
  2026-11-17 20:29 ` Marc Zyngier
  0 siblings, 1 reply; 3+ messages in thread
From: Jinjie Ruan @ 2026-11-17 12:31 UTC (permalink / raw)
  To: maz, tglx, radu, linux-arm-kernel, linux-kernel; +Cc: ruanjinjie

The collection table is currently sized at a single ITS page size,
and the driver's allocation policy is to allocate a single collection
per CPU. On systems with more CPUs that the ITS can fit in a single
page, no LPI can be routed to the CPUs that don't have an allocated
collection, and the system grinds to a halt.

Change the allocation policy to allow two-level tables, similarly to
the other tables.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v1 -> v2:
- Cleanup the similar calls of its_parse_indirect_baser() (Marc).
- Simplfy the commit message (Marc).
- Drop fix tag and comment (Marc).
- Give nr_ids a default for unrecognised BASER types.
---
 drivers/irqchip/irq-gic-v3-its.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index c952c069f937..41cd359e52a7 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -2682,7 +2682,7 @@ static int its_alloc_tables(struct its_node *its)
 		u64 val = its_read_baser(its, baser);
 		u64 type = GITS_BASER_TYPE(val);
 		bool indirect = false;
-		u32 order;
+		u32 order, nr_ids;
 
 		if (type == GITS_BASER_TYPE_NONE)
 			continue;
@@ -2696,8 +2696,7 @@ static int its_alloc_tables(struct its_node *its)
 
 		switch (type) {
 		case GITS_BASER_TYPE_DEVICE:
-			indirect = its_parse_indirect_baser(its, baser, &order,
-							    device_ids(its));
+			nr_ids = device_ids(its);
 			break;
 
 		case GITS_BASER_TYPE_VCPU:
@@ -2713,11 +2712,19 @@ static int its_alloc_tables(struct its_node *its)
 				}
 			}
 
-			indirect = its_parse_indirect_baser(its, baser, &order,
-							    ITS_MAX_VPEID_BITS);
+			nr_ids = ITS_MAX_VPEID_BITS;
+			break;
+
+		case GITS_BASER_TYPE_COLLECTION:
+			nr_ids = order_base_2(num_possible_cpus());
+			break;
+
+		default:
+			nr_ids = 0;
 			break;
 		}
 
+		indirect = its_parse_indirect_baser(its, baser, &order, nr_ids);
 		err = its_setup_baser(its, baser, cache, shr, order, indirect);
 		if (err < 0) {
 			its_free_tables(its);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] irqchip/gic-v3-its: Size the collection table for all possible CPUs
  2026-11-17 12:31 [PATCH v2] irqchip/gic-v3-its: Size the collection table for all possible CPUs Jinjie Ruan
@ 2026-11-17 20:29 ` Marc Zyngier
  2026-11-18  1:50   ` Jinjie Ruan
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Zyngier @ 2026-11-17 20:29 UTC (permalink / raw)
  To: Jinjie Ruan; +Cc: tglx, radu, linux-arm-kernel, linux-kernel

On Tue, 17 Nov 2026 12:31:16 +0000,
Jinjie Ruan <ruanjinjie@huawei.com> wrote:
> 
> The collection table is currently sized at a single ITS page size,
> and the driver's allocation policy is to allocate a single collection
> per CPU. On systems with more CPUs that the ITS can fit in a single
> page, no LPI can be routed to the CPUs that don't have an allocated
> collection, and the system grinds to a halt.
> 
> Change the allocation policy to allow two-level tables, similarly to
> the other tables.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v1 -> v2:
> - Cleanup the similar calls of its_parse_indirect_baser() (Marc).
> - Simplfy the commit message (Marc).
> - Drop fix tag and comment (Marc).
> - Give nr_ids a default for unrecognised BASER types.

At this stage, and given that this is my commit message and my code
(plus an additional bug of your own doing), you may as well put:

Suggested-by: Marc Zyngier <maz@kernel.org>

> ---
>  drivers/irqchip/irq-gic-v3-its.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index c952c069f937..41cd359e52a7 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -2682,7 +2682,7 @@ static int its_alloc_tables(struct its_node *its)
>  		u64 val = its_read_baser(its, baser);
>  		u64 type = GITS_BASER_TYPE(val);
>  		bool indirect = false;
> -		u32 order;
> +		u32 order, nr_ids;
>  
>  		if (type == GITS_BASER_TYPE_NONE)
>  			continue;
> @@ -2696,8 +2696,7 @@ static int its_alloc_tables(struct its_node *its)
>  
>  		switch (type) {
>  		case GITS_BASER_TYPE_DEVICE:
> -			indirect = its_parse_indirect_baser(its, baser, &order,
> -							    device_ids(its));
> +			nr_ids = device_ids(its);
>  			break;
>  
>  		case GITS_BASER_TYPE_VCPU:
> @@ -2713,11 +2712,19 @@ static int its_alloc_tables(struct its_node *its)
>  				}
>  			}
>  
> -			indirect = its_parse_indirect_baser(its, baser, &order,
> -							    ITS_MAX_VPEID_BITS);
> +			nr_ids = ITS_MAX_VPEID_BITS;
> +			break;
> +
> +		case GITS_BASER_TYPE_COLLECTION:
> +			nr_ids = order_base_2(num_possible_cpus());
> +			break;
> +
> +		default:
> +			nr_ids = 0;

Absolutely not. The above four BASER types are the only ones that are
allowed by the architecture. Anything else is a HW bug. So no, we're
not silently accepting this. We scream and *abort*.

	M.

-- 
Jazz isn't dead. It just smells funny.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] irqchip/gic-v3-its: Size the collection table for all possible CPUs
  2026-11-17 20:29 ` Marc Zyngier
@ 2026-11-18  1:50   ` Jinjie Ruan
  0 siblings, 0 replies; 3+ messages in thread
From: Jinjie Ruan @ 2026-11-18  1:50 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: tglx, radu, linux-arm-kernel, linux-kernel

Hi Marc,

在 2026/11/18 4:29, Marc Zyngier 写道:
> On Tue, 17 Nov 2026 12:31:16 +0000,
> Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>>
>> The collection table is currently sized at a single ITS page size,
>> and the driver's allocation policy is to allocate a single collection
>> per CPU. On systems with more CPUs that the ITS can fit in a single
>> page, no LPI can be routed to the CPUs that don't have an allocated
>> collection, and the system grinds to a halt.
>>
>> Change the allocation policy to allow two-level tables, similarly to
>> the other tables.
>>
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> ---
>> v1 -> v2:
>> - Cleanup the similar calls of its_parse_indirect_baser() (Marc).
>> - Simplfy the commit message (Marc).
>> - Drop fix tag and comment (Marc).
>> - Give nr_ids a default for unrecognised BASER types.
> 
> At this stage, and given that this is my commit message and my code
> (plus an additional bug of your own doing), you may as well put:
> 
> Suggested-by: Marc Zyngier <maz@kernel.org>

Very happy to do so.

> 
>> ---
>>  drivers/irqchip/irq-gic-v3-its.c | 17 ++++++++++++-----
>>  1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
>> index c952c069f937..41cd359e52a7 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -2682,7 +2682,7 @@ static int its_alloc_tables(struct its_node *its)
>>  		u64 val = its_read_baser(its, baser);
>>  		u64 type = GITS_BASER_TYPE(val);
>>  		bool indirect = false;
>> -		u32 order;
>> +		u32 order, nr_ids;
>>  
>>  		if (type == GITS_BASER_TYPE_NONE)
>>  			continue;
>> @@ -2696,8 +2696,7 @@ static int its_alloc_tables(struct its_node *its)
>>  
>>  		switch (type) {
>>  		case GITS_BASER_TYPE_DEVICE:
>> -			indirect = its_parse_indirect_baser(its, baser, &order,
>> -							    device_ids(its));
>> +			nr_ids = device_ids(its);
>>  			break;
>>  
>>  		case GITS_BASER_TYPE_VCPU:
>> @@ -2713,11 +2712,19 @@ static int its_alloc_tables(struct its_node *its)
>>  				}
>>  			}
>>  
>> -			indirect = its_parse_indirect_baser(its, baser, &order,
>> -							    ITS_MAX_VPEID_BITS);
>> +			nr_ids = ITS_MAX_VPEID_BITS;
>> +			break;
>> +
>> +		case GITS_BASER_TYPE_COLLECTION:
>> +			nr_ids = order_base_2(num_possible_cpus());
>> +			break;
>> +
>> +		default:
>> +			nr_ids = 0;
> 
> Absolutely not. The above four BASER types are the only ones that are
> allowed by the architecture. Anything else is a HW bug. So no, we're

Yes, according to the GIC architecture specification, a value of 0
indicates Unimplemented, and other values are reserved.

> not silently accepting this. We scream and *abort*.

Thank you for the suggestion, will add an appropriate pr_err info and
then return the error directly.

Best regards,
Jinjie

> 
> 	M.
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-18  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 12:31 [PATCH v2] irqchip/gic-v3-its: Size the collection table for all possible CPUs Jinjie Ruan
2026-11-17 20:29 ` Marc Zyngier
2026-11-18  1:50   ` Jinjie Ruan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.