Skip to content

Commit 70cc81e

Browse files
author
Marc Zyngier
committed
irqchip/gic-v3-its: Generalize device table allocation
As we want to use 2-level tables for VCPUs, let's hack the device table allocator in order to make it slightly more generic. It will get reused in subsequent patches. Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent cf2be8b commit 70cc81e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,26 +1392,19 @@ static struct its_baser *its_get_baser(struct its_node *its, u32 type)
13921392
return NULL;
13931393
}
13941394

1395-
static bool its_alloc_device_table(struct its_node *its, u32 dev_id)
1395+
static bool its_alloc_table_entry(struct its_baser *baser, u32 id)
13961396
{
1397-
struct its_baser *baser;
13981397
struct page *page;
13991398
u32 esz, idx;
14001399
__le64 *table;
14011400

1402-
baser = its_get_baser(its, GITS_BASER_TYPE_DEVICE);
1403-
1404-
/* Don't allow device id that exceeds ITS hardware limit */
1405-
if (!baser)
1406-
return (ilog2(dev_id) < its->device_ids);
1407-
14081401
/* Don't allow device id that exceeds single, flat table limit */
14091402
esz = GITS_BASER_ENTRY_SIZE(baser->val);
14101403
if (!(baser->val & GITS_BASER_INDIRECT))
1411-
return (dev_id < (PAGE_ORDER_TO_SIZE(baser->order) / esz));
1404+
return (id < (PAGE_ORDER_TO_SIZE(baser->order) / esz));
14121405

14131406
/* Compute 1st level table index & check if that exceeds table limit */
1414-
idx = dev_id >> ilog2(baser->psz / esz);
1407+
idx = id >> ilog2(baser->psz / esz);
14151408
if (idx >= (PAGE_ORDER_TO_SIZE(baser->order) / GITS_LVL1_ENTRY_SIZE))
14161409
return false;
14171410

@@ -1440,6 +1433,19 @@ static bool its_alloc_device_table(struct its_node *its, u32 dev_id)
14401433
return true;
14411434
}
14421435

1436+
static bool its_alloc_device_table(struct its_node *its, u32 dev_id)
1437+
{
1438+
struct its_baser *baser;
1439+
1440+
baser = its_get_baser(its, GITS_BASER_TYPE_DEVICE);
1441+
1442+
/* Don't allow device id that exceeds ITS hardware limit */
1443+
if (!baser)
1444+
return (ilog2(dev_id) < its->device_ids);
1445+
1446+
return its_alloc_table_entry(baser, dev_id);
1447+
}
1448+
14431449
static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
14441450
int nvecs)
14451451
{

0 commit comments

Comments
 (0)