|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 03/28] ARM: GICv3: allocate LPI pending and property table
Hi Andre, On 30/01/17 18:31, Andre Przywara wrote: I think the description is misleading, if a user wants 8K worth of LPIs by default, he would have to use 14 and not 13. Furthermore, you provide both a runtime option (via command line) and build time option (via Kconfig). You don't express what is the differences between both and how there are supposed to co-exist. Anyway, IHMO the command line option should be sufficient to allow override if necessary. So I would drop the Kconfig version. + Xen itself does not know how many LPIs domains will ever need + beforehand. + This can be overriden on the command line with the max_lpi_bits s/overriden/overridden/ + parameter. + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 5f4ff23..4ccf2eb 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -19,6 +19,7 @@ obj-y += gic.o obj-y += gic-v2.o obj-$(CONFIG_HAS_GICV3) += gic-v3.o obj-$(CONFIG_HAS_ITS) += gic-v3-its.o +obj-$(CONFIG_HAS_ITS) += gic-v3-lpi.o obj-y += guestcopy.o obj-y += hvm.o obj-y += io.o diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c new file mode 100644 index 0000000..e2fc901 --- /dev/null +++ b/xen/arch/arm/gic-v3-lpi.c @@ -0,0 +1,129 @@ +/* + * xen/arch/arm/gic-v3-lpi.c + * + * ARM GICv3 Locality-specific Peripheral Interrupts (LPI) support + * + * Copyright (C) 2016,2017 - ARM Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <xen/config.h> xen/config.h is not necessary. On the previous version, Stefano suggested to rename this to phys_lpi_bits + adding a comment as you store the number of bits. However, looking at the usage the number of bits is only required during the initialization. Runtime code (such as gic_get_host_lpi) will use the number of LPIs (see gic_get_host_lpi) and therefore require extra instructions to compute the value. So I would prefer if you store the number of LPIs here to optimize the common case. Also, I find the naming "id_bits" confusing because you store the number of bits to encode the max LPI ID and not the number of bits to encode the number of LPI. You can use _zalloc to do the allocation and then memset to 0. + __flush_dcache_area(pendtable, BIT_ULL(lpi_data.host_lpi_bits) / 8); Please use clean_and_invalidate_dcache_va_range. The {} are not necessary. Also, on the previous version it was mentioned this should be an error and then replace by a BUG_ON(). Please do the change. + + reg |= GICR_PENDBASER_PTZ; + + ASSERT(!(virt_to_maddr(pendtable) & ~GENMASK(51, 16))); I don't understand the purpose of this ASSERT. The bits 15:0 should always be zero otherwise this would be a bug in the memory allocator. For bits 64:52, the architecture so far only support up to 52 bits. By keeping this ASSERT, you will make our life more difficult to extend the number of physical address supported if ARM decides to bump it. So please drop this ASSERT. You are using the shift defines from PENDBASER and not PROPBASER. The property table address has to be 4KB aligned right? If so, I would much prefer if you use _xmalloc(BIT_ULL(lpi_data.host_lpi_bits), SZ_4K) to avoid relying on PAGE_SIZE == 4KB. Also, you will allocate more memory than necessary because the property table only covers the LPIs. + + if ( !table ) + return 0; + + memset(table, GIC_PRI_IRQ | LPI_PROP_RES1, MAX_PHYS_LPIS); You could combine both suggested _xmalloc and memset to 0 in a single call to _zalloc. + __flush_dcache_area(table, MAX_PHYS_LPIS); Please use clean_and_invalidate_dcache_va_range. + lpi_data.lpi_property = table; + } + + reg |= ((lpi_data.host_lpi_bits - 1) << 0); Please avoid hardcoded shift. Please document this new option in docs/misc/xen-command-line.markdown. + +int gicv3_lpi_init_host_lpis(unsigned int hw_lpi_bits) Stefano suggested to rename this function to gicv3_lpi_init_phys_lpis and I agree with him here. s/lld/llu/. A macro has been suggested on the previous version here to avoid the hardcoded 0x1f. I think it would make sense to move this function in gicv3-lpi.c. So only one function rather than 2 would be exported. See my comment on patch #2 regarding host_its_list. + return -ENODEV; + + /* Make sure LPIs are disabled before setting up the tables. */ + reg = readl_relaxed(rdist_base + GICR_CTLR); + if ( reg & GICR_CTLR_ENABLE_LPIS ) + return -EBUSY; Why don't you just disable LPIs here? AFAIK, it should just be writel_relaxed(reg & ~GICR_CTLR_ENABLE_LPIS, GICR_CTLR); + + table_reg = gicv3_lpi_allocate_pendtable(); + if ( !table_reg ) From the spec, GICR_PENDBASER full of 0 is valid. + return -ENOMEM; + writeq_relaxed(table_reg, rdist_base + GICR_PENDBASER); On the first version of this series, I mentioned that based on the spec (8.11.18 in ARM IHI 0069C) cacheability and shareability may not stick. Whilst this may not (?) be a concern for the pending table, Xen will write in the property table to enable/disable LPIs. So we would need to know whether the cache needs to be cleaned after each access or not. + + table_reg = gicv3_lpi_get_proptable(); + if ( !table_reg ) + return -ENOMEM; + writeq_relaxed(table_reg, rdist_base + GICR_PROPBASER); See all my remarks above. CPU%u It would make much sense to have this definition moved in irq.h close to NR_IRQS. Also, I am a bit surprised that NR_IRQS & co has not been modified. Is there any reason for that? Regards, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |