irqchip/gic-v3-its: Make LPI allocation optional on device creation

The normal course of action when allocating the ITS' view of a
device is to allocate the corresponding LPIs. But we're about
to introduce devices that borrow their interrupts from
some other entities.

So let's make the allocation optional.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+14 -7
+14 -7
drivers/irqchip/irq-gic-v3-its.c
··· 1978 1978 } 1979 1979 1980 1980 static struct its_device *its_create_device(struct its_node *its, u32 dev_id, 1981 - int nvecs) 1981 + int nvecs, bool alloc_lpis) 1982 1982 { 1983 1983 struct its_device *dev; 1984 - unsigned long *lpi_map; 1984 + unsigned long *lpi_map = NULL; 1985 1985 unsigned long flags; 1986 1986 u16 *col_map = NULL; 1987 1987 void *itt; ··· 2003 2003 sz = nr_ites * its->ite_size; 2004 2004 sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; 2005 2005 itt = kzalloc(sz, GFP_KERNEL); 2006 - lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); 2007 - if (lpi_map) 2008 - col_map = kzalloc(sizeof(*col_map) * nr_lpis, GFP_KERNEL); 2006 + if (alloc_lpis) { 2007 + lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); 2008 + if (lpi_map) 2009 + col_map = kzalloc(sizeof(*col_map) * nr_lpis, 2010 + GFP_KERNEL); 2011 + } else { 2012 + col_map = kzalloc(sizeof(*col_map) * nr_ites, GFP_KERNEL); 2013 + nr_lpis = 0; 2014 + lpi_base = 0; 2015 + } 2009 2016 2010 - if (!dev || !itt || !lpi_map || !col_map) { 2017 + if (!dev || !itt || !col_map || (!lpi_map && alloc_lpis)) { 2011 2018 kfree(dev); 2012 2019 kfree(itt); 2013 2020 kfree(lpi_map); ··· 2101 2094 goto out; 2102 2095 } 2103 2096 2104 - its_dev = its_create_device(its, dev_id, nvec); 2097 + its_dev = its_create_device(its, dev_id, nvec, true); 2105 2098 if (!its_dev) 2106 2099 return -ENOMEM; 2107 2100