* [PATCH 0/2] irqchip/gic-v3-its: a raw_spinlock_t + early ->pend_page allocateion
@ 2018-07-18 15:42 Sebastian Andrzej Siewior
2018-07-18 15:42 ` [PATCH 1/2] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t Sebastian Andrzej Siewior
2018-07-18 15:42 ` [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback Sebastian Andrzej Siewior
0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-18 15:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Thomas Gleixner, Jason Cooper, Marc Zyngier
The errors popped up in -RT. One is the spinlock_t usage in IRQ-off
region which should be a raw_spinlock_t. I don't see this to be used
during run-time or for long period of time so I don't thing this is an
issue.
The second problem is the ->pend_page allocation on the target_cpu early
during CPU bring up. It would be simpler to allocate the memory once on
the boot CPU instead the hotplug callback since the memory is never
free()ed. I *think* this is avoided because the number of possible CPUs
might be higher than what will actually come up (on x86 the BIOS
sometimes reports more possible_cpus than what is *really* possible, not
sure if ARM64 is there yet). Therefore I moved the allocation to an
earlier callback.
Sebastian
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t
2018-07-18 15:42 [PATCH 0/2] irqchip/gic-v3-its: a raw_spinlock_t + early ->pend_page allocateion Sebastian Andrzej Siewior
@ 2018-07-18 15:42 ` Sebastian Andrzej Siewior
2018-08-06 8:17 ` Marc Zyngier
2018-07-18 15:42 ` [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback Sebastian Andrzej Siewior
1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-18 15:42 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Jason Cooper, Marc Zyngier, Sebastian Andrzej Siewior
The its_lock lock is held while a new device is added to the list and
during setup while the CPU is booted. Even on -RT the CPU-bootup is
performed with disabled interrupts.
Make its_lock a raw_spin_lock_t.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/irqchip/irq-gic-v3-its.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index d7842d312d3e..a616043d25ee 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -160,7 +160,7 @@ static struct {
} vpe_proxy;
static LIST_HEAD(its_nodes);
-static DEFINE_SPINLOCK(its_lock);
+static DEFINE_RAW_SPINLOCK(its_lock);
static struct rdists *gic_rdists;
static struct irq_domain *its_parent;
@@ -1997,12 +1997,12 @@ static void its_cpu_init_collections(void)
{
struct its_node *its;
- spin_lock(&its_lock);
+ raw_spin_lock(&its_lock);
list_for_each_entry(its, &its_nodes, entry)
its_cpu_init_collection(its);
- spin_unlock(&its_lock);
+ raw_spin_unlock(&its_lock);
}
static struct its_device *its_find_device(struct its_node *its, u32 dev_id)
@@ -3070,7 +3070,7 @@ static int its_save_disable(void)
struct its_node *its;
int err = 0;
- spin_lock(&its_lock);
+ raw_spin_lock(&its_lock);
list_for_each_entry(its, &its_nodes, entry) {
void __iomem *base;
@@ -3102,7 +3102,7 @@ static int its_save_disable(void)
writel_relaxed(its->ctlr_save, base + GITS_CTLR);
}
}
- spin_unlock(&its_lock);
+ raw_spin_unlock(&its_lock);
return err;
}
@@ -3112,7 +3112,7 @@ static void its_restore_enable(void)
struct its_node *its;
int ret;
- spin_lock(&its_lock);
+ raw_spin_lock(&its_lock);
list_for_each_entry(its, &its_nodes, entry) {
void __iomem *base;
int i;
@@ -3164,7 +3164,7 @@ static void its_restore_enable(void)
GITS_TYPER_HCC(gic_read_typer(base + GITS_TYPER)))
its_cpu_init_collection(its);
}
- spin_unlock(&its_lock);
+ raw_spin_unlock(&its_lock);
}
static struct syscore_ops its_syscore_ops = {
@@ -3398,9 +3398,9 @@ static int __init its_probe_one(struct resource *res,
if (err)
goto out_free_tables;
- spin_lock(&its_lock);
+ raw_spin_lock(&its_lock);
list_add(&its->entry, &its_nodes);
- spin_unlock(&its_lock);
+ raw_spin_unlock(&its_lock);
return 0;
--
2.18.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback
2018-07-18 15:42 [PATCH 0/2] irqchip/gic-v3-its: a raw_spinlock_t + early ->pend_page allocateion Sebastian Andrzej Siewior
2018-07-18 15:42 ` [PATCH 1/2] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t Sebastian Andrzej Siewior
@ 2018-07-18 15:42 ` Sebastian Andrzej Siewior
2018-08-06 8:15 ` Marc Zyngier
1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-18 15:42 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Jason Cooper, Marc Zyngier, Sebastian Andrzej Siewior
The AP-GIC-starting callback allocates memory for the ->pend_page while
the CPU is started during boot-up. This callback is invoked on the
target CPU with disabled interrupts.
This does not work on -RT because memory allocations are not possible
with disabled interrupts.
Move the memory allocation to an earlier hotplug step which is invoked
with enabled interrupts on the boot CPU.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/irqchip/irq-gic-v3-its.c | 60 ++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 19 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index a616043d25ee..acc3d44c356d 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -171,6 +171,7 @@ static DEFINE_RAW_SPINLOCK(vmovp_lock);
static DEFINE_IDA(its_vpeid_ida);
#define gic_data_rdist() (raw_cpu_ptr(gic_rdists->rdist))
+#define gic_data_rdist_cpu(cpu) (per_cpu_ptr(gic_rdists->rdist, cpu))
#define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base)
#define gic_data_rdist_vlpi_base() (gic_data_rdist_rd_base() + SZ_128K)
@@ -1853,15 +1854,17 @@ static int its_alloc_collections(struct its_node *its)
return 0;
}
-static struct page *its_allocate_pending_table(gfp_t gfp_flags)
+static struct page *its_allocate_pending_table(unsigned int cpu)
{
struct page *pend_page;
+ unsigned int order;
/*
* The pending pages have to be at least 64kB aligned,
* hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below.
*/
- pend_page = alloc_pages(gfp_flags | __GFP_ZERO,
- get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K)));
+ order = get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K));
+ pend_page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL | __GFP_ZERO,
+ order);
if (!pend_page)
return NULL;
@@ -1877,6 +1880,28 @@ static void its_free_pending_table(struct page *pt)
get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K)));
}
+static int its_alloc_pend_page(unsigned int cpu)
+{
+ struct page *pend_page;
+ phys_addr_t paddr;
+
+ pend_page = gic_data_rdist_cpu(cpu)->pend_page;
+ if (pend_page)
+ return 0;
+
+ pend_page = its_allocate_pending_table(cpu);
+ if (!pend_page) {
+ pr_err("Failed to allocate PENDBASE for CPU%d\n",
+ smp_processor_id());
+ return -ENOMEM;
+ }
+
+ paddr = page_to_phys(pend_page);
+ pr_info("CPU%d: using LPI pending table @%pa\n", cpu, &paddr);
+ gic_data_rdist_cpu(cpu)->pend_page = pend_page;
+ return 0;
+}
+
static void its_cpu_init_lpis(void)
{
void __iomem *rbase = gic_data_rdist_rd_base();
@@ -1885,21 +1910,8 @@ static void its_cpu_init_lpis(void)
/* If we didn't allocate the pending table yet, do it now */
pend_page = gic_data_rdist()->pend_page;
- if (!pend_page) {
- phys_addr_t paddr;
-
- pend_page = its_allocate_pending_table(GFP_NOWAIT);
- if (!pend_page) {
- pr_err("Failed to allocate PENDBASE for CPU%d\n",
- smp_processor_id());
- return;
- }
-
- paddr = page_to_phys(pend_page);
- pr_info("CPU%d: using LPI pending table @%pa\n",
- smp_processor_id(), &paddr);
- gic_data_rdist()->pend_page = pend_page;
- }
+ if (WARN_ON(!pend_page))
+ return;
/* set PROPBASE */
val = (page_to_phys(gic_rdists->prop_page) |
@@ -2732,7 +2744,7 @@ static int its_vpe_init(struct its_vpe *vpe)
return vpe_id;
/* Allocate VPT */
- vpt_page = its_allocate_pending_table(GFP_KERNEL);
+ vpt_page = its_allocate_pending_table(raw_smp_processor_id());
if (!vpt_page) {
its_vpe_id_free(vpe_id);
return -ENOMEM;
@@ -3706,6 +3718,16 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
if (err)
return err;
+ err = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "irqchip/arm/gicv3:prepare",
+ its_alloc_pend_page, NULL);
+ if (err < 0) {
+ pr_warn("ITS: Can't register CPU-hoplug callback.\n");
+ return err;
+ }
+ err = its_alloc_pend_page(smp_processor_id());
+ if (err < 0)
+ return err;
+
list_for_each_entry(its, &its_nodes, entry)
has_v4 |= its->is_v4;
--
2.18.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback
2018-07-18 15:42 ` [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback Sebastian Andrzej Siewior
@ 2018-08-06 8:15 ` Marc Zyngier
2018-08-29 16:49 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 7+ messages in thread
From: Marc Zyngier @ 2018-08-06 8:15 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, linux-kernel; +Cc: Thomas Gleixner, Jason Cooper
Hi Sebastian,
On 18/07/18 16:42, Sebastian Andrzej Siewior wrote:
> The AP-GIC-starting callback allocates memory for the ->pend_page while
> the CPU is started during boot-up. This callback is invoked on the
> target CPU with disabled interrupts.
> This does not work on -RT because memory allocations are not possible
> with disabled interrupts.
> Move the memory allocation to an earlier hotplug step which is invoked
> with enabled interrupts on the boot CPU.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> drivers/irqchip/irq-gic-v3-its.c | 60 ++++++++++++++++++++++----------
> 1 file changed, 41 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index a616043d25ee..acc3d44c356d 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -171,6 +171,7 @@ static DEFINE_RAW_SPINLOCK(vmovp_lock);
> static DEFINE_IDA(its_vpeid_ida);
>
> #define gic_data_rdist() (raw_cpu_ptr(gic_rdists->rdist))
> +#define gic_data_rdist_cpu(cpu) (per_cpu_ptr(gic_rdists->rdist, cpu))
> #define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base)
> #define gic_data_rdist_vlpi_base() (gic_data_rdist_rd_base() + SZ_128K)
>
> @@ -1853,15 +1854,17 @@ static int its_alloc_collections(struct its_node *its)
> return 0;
> }
>
> -static struct page *its_allocate_pending_table(gfp_t gfp_flags)
> +static struct page *its_allocate_pending_table(unsigned int cpu)
> {
> struct page *pend_page;
> + unsigned int order;
> /*
> * The pending pages have to be at least 64kB aligned,
> * hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below.
> */
> - pend_page = alloc_pages(gfp_flags | __GFP_ZERO,
> - get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K)));
> + order = get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K));
> + pend_page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL | __GFP_ZERO,
> + order);
> if (!pend_page)
> return NULL;
>
> @@ -1877,6 +1880,28 @@ static void its_free_pending_table(struct page *pt)
> get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K)));
> }
>
> +static int its_alloc_pend_page(unsigned int cpu)
> +{
> + struct page *pend_page;
> + phys_addr_t paddr;
> +
> + pend_page = gic_data_rdist_cpu(cpu)->pend_page;
> + if (pend_page)
> + return 0;
> +
> + pend_page = its_allocate_pending_table(cpu);
> + if (!pend_page) {
> + pr_err("Failed to allocate PENDBASE for CPU%d\n",
> + smp_processor_id());
> + return -ENOMEM;
> + }
> +
> + paddr = page_to_phys(pend_page);
> + pr_info("CPU%d: using LPI pending table @%pa\n", cpu, &paddr);
> + gic_data_rdist_cpu(cpu)->pend_page = pend_page;
> + return 0;
> +}
> +
> static void its_cpu_init_lpis(void)
> {
> void __iomem *rbase = gic_data_rdist_rd_base();
> @@ -1885,21 +1910,8 @@ static void its_cpu_init_lpis(void)
>
> /* If we didn't allocate the pending table yet, do it now */
> pend_page = gic_data_rdist()->pend_page;
> - if (!pend_page) {
> - phys_addr_t paddr;
> -
> - pend_page = its_allocate_pending_table(GFP_NOWAIT);
> - if (!pend_page) {
> - pr_err("Failed to allocate PENDBASE for CPU%d\n",
> - smp_processor_id());
> - return;
> - }
> -
> - paddr = page_to_phys(pend_page);
> - pr_info("CPU%d: using LPI pending table @%pa\n",
> - smp_processor_id(), &paddr);
> - gic_data_rdist()->pend_page = pend_page;
> - }
> + if (WARN_ON(!pend_page))
> + return;
>
> /* set PROPBASE */
> val = (page_to_phys(gic_rdists->prop_page) |
> @@ -2732,7 +2744,7 @@ static int its_vpe_init(struct its_vpe *vpe)
> return vpe_id;
>
> /* Allocate VPT */
> - vpt_page = its_allocate_pending_table(GFP_KERNEL);
> + vpt_page = its_allocate_pending_table(raw_smp_processor_id());
> if (!vpt_page) {
> its_vpe_id_free(vpe_id);
> return -ENOMEM;
> @@ -3706,6 +3718,16 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
> if (err)
> return err;
>
> + err = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "irqchip/arm/gicv3:prepare",
> + its_alloc_pend_page, NULL);
> + if (err < 0) {
> + pr_warn("ITS: Can't register CPU-hoplug callback.\n");
> + return err;
> + }
> + err = its_alloc_pend_page(smp_processor_id());
> + if (err < 0)
> + return err;
> +
> list_for_each_entry(its, &its_nodes, entry)
> has_v4 |= its->is_v4;
>
>
I must say I'm not overly keen on the extra hotplug notifier, and I'd
rather allocate all the memory upfront on the boot CPU.
I've implemented this as part of a series that is required for
kexec/kdump support[1] (and specifically this[2] patch). Could you
please have a look and let me know if that works for you? I otherwise
plan to post it for review once the 4.19 merge window has closed.
Thanks,
M.
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=irq/gicv3-kdump
[2]
https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/gicv3-kdump&id=effe377d415900af10e206173d60dc6cc3f0662c
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t
2018-07-18 15:42 ` [PATCH 1/2] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t Sebastian Andrzej Siewior
@ 2018-08-06 8:17 ` Marc Zyngier
0 siblings, 0 replies; 7+ messages in thread
From: Marc Zyngier @ 2018-08-06 8:17 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, linux-kernel; +Cc: Thomas Gleixner, Jason Cooper
On 18/07/18 16:42, Sebastian Andrzej Siewior wrote:
> The its_lock lock is held while a new device is added to the list and
> during setup while the CPU is booted. Even on -RT the CPU-bootup is
> performed with disabled interrupts.
>
> Make its_lock a raw_spin_lock_t.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Applied to irq/irqchip-next.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback
2018-08-06 8:15 ` Marc Zyngier
@ 2018-08-29 16:49 ` Sebastian Andrzej Siewior
2018-08-31 19:32 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-08-29 16:49 UTC (permalink / raw)
To: Marc Zyngier; +Cc: linux-kernel, Thomas Gleixner, Jason Cooper
On 2018-08-06 09:15:32 [+0100], Marc Zyngier wrote:
> Hi Sebastian,
Hi Marc,
> I must say I'm not overly keen on the extra hotplug notifier, and I'd
> rather allocate all the memory upfront on the boot CPU.
>
> I've implemented this as part of a series that is required for
> kexec/kdump support[1] (and specifically this[2] patch). Could you
> please have a look and let me know if that works for you? I otherwise
> plan to post it for review once the 4.19 merge window has closed.
This looks good, thank you. I can't test this because I don't have a
GICv3 box atm. The last one I had died somehow.
I pull that patch into my next RT release and ask for some feedback.
One question: You have
its_allocate_pending_table(GFP_NOWAIT);
for the allocation. Shouldn't GFP_KERNEL do the job, too?
> Thanks,
>
> M.
Sebastian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback
2018-08-29 16:49 ` Sebastian Andrzej Siewior
@ 2018-08-31 19:32 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-08-31 19:32 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-kernel, Thomas Gleixner, Jason Cooper, Grygorii Strashko
On 2018-08-29 18:49:06 [+0200], To Marc Zyngier wrote:
> On 2018-08-06 09:15:32 [+0100], Marc Zyngier wrote:
> > Hi Sebastian,
Hi Marc,
> > I've implemented this as part of a series that is required for
> > kexec/kdump support[1] (and specifically this[2] patch). Could you
> > please have a look and let me know if that works for you? I otherwise
> > plan to post it for review once the 4.19 merge window has closed.
> I pull that patch into my next RT release and ask for some feedback.
Grygorii Strashko confirmed that it works on RT as expected :)
Sebastian
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-08-31 19:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18 15:42 [PATCH 0/2] irqchip/gic-v3-its: a raw_spinlock_t + early ->pend_page allocateion Sebastian Andrzej Siewior
2018-07-18 15:42 ` [PATCH 1/2] irqchip/gic-v3-its: Make its_lock a raw_spin_lock_t Sebastian Andrzej Siewior
2018-08-06 8:17 ` Marc Zyngier
2018-07-18 15:42 ` [PATCH 2/2] irqchip/gic-v3-its: Move ITS' ->pend_page allocation into an early CPU up callback Sebastian Andrzej Siewior
2018-08-06 8:15 ` Marc Zyngier
2018-08-29 16:49 ` Sebastian Andrzej Siewior
2018-08-31 19:32 ` Sebastian Andrzej Siewior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).