Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux linux: Use pointer indirection f...
details: https://anonhg.NetBSD.org/src/rev/4effd22626d0
branches: trunk
changeset: 1028717:4effd22626d0
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 11:50:54 2021 +0000
description:
linux: Use pointer indirection for irq_work_cpu.
Can't store locks in percpu since it moves around.
diffstat:
sys/external/bsd/drm2/linux/linux_irq_work.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diffs (80 lines):
diff -r 8a05cab8471a -r 4effd22626d0 sys/external/bsd/drm2/linux/linux_irq_work.c
--- a/sys/external/bsd/drm2/linux/linux_irq_work.c Sun Dec 19 11:50:47 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_irq_work.c Sun Dec 19 11:50:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_irq_work.c,v 1.1 2021/12/19 11:49:57 riastradh Exp $ */
+/* $NetBSD: linux_irq_work.c,v 1.2 2021/12/19 11:50:54 riastradh Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_irq_work.c,v 1.1 2021/12/19 11:49:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_irq_work.c,v 1.2 2021/12/19 11:50:54 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
#include <sys/intr.h>
+#include <sys/kmem.h>
#include <sys/mutex.h>
#include <sys/percpu.h>
#include <sys/queue.h>
@@ -57,11 +58,12 @@
static void
irq_work_intr(void *cookie)
{
- struct irq_work_cpu *iwc;
+ struct irq_work_cpu *const *iwcp, *iwc;
SIMPLEQ_HEAD(, irq_work) todo = SIMPLEQ_HEAD_INITIALIZER(todo);
struct irq_work *iw, *next;
- iwc = percpu_getref(irq_work_percpu);
+ iwcp = percpu_getref(irq_work_percpu);
+ iwc = *iwcp;
mutex_spin_enter(&iwc->iwc_lock);
SIMPLEQ_CONCAT(&todo, &iwc->iwc_todo);
mutex_spin_exit(&iwc->iwc_lock);
@@ -76,8 +78,9 @@
static void
irq_work_cpu_init(void *ptr, void *cookie, struct cpu_info *ci)
{
- struct irq_work_cpu *iwc = ptr;
+ struct irq_work_cpu **iwcp = ptr, *iwc;
+ iwc = *iwcp = kmem_zalloc(sizeof(*iwc), KM_SLEEP);
mutex_init(&iwc->iwc_lock, MUTEX_DEFAULT, IPL_HIGH);
SIMPLEQ_INIT(&iwc->iwc_todo);
}
@@ -85,10 +88,11 @@
static void
irq_work_cpu_fini(void *ptr, void *cookie, struct cpu_info *ci)
{
- struct irq_work_cpu *iwc __diagused = ptr;
+ struct irq_work_cpu **iwcp = ptr, *iwc = *iwcp;
KASSERT(SIMPLEQ_EMPTY(&iwc->iwc_todo));
mutex_destroy(&iwc->iwc_lock);
+ kmem_free(iwc, sizeof(*iwc));
}
void
@@ -120,13 +124,14 @@
bool
irq_work_queue(struct irq_work *iw)
{
- struct irq_work_cpu *iwc;
+ struct irq_work_cpu *const *iwcp, *iwc;
if (atomic_swap_uint(&iw->iw_flags, IRQ_WORK_PENDING)
& IRQ_WORK_PENDING)
return false;
- iwc = percpu_getref(irq_work_percpu);
+ iwcp = percpu_getref(irq_work_percpu);
+ iwc = *iwcp;
mutex_spin_enter(&iwc->iwc_lock);
SIMPLEQ_INSERT_TAIL(&iwc->iwc_todo, iw, iw_entry);
mutex_spin_exit(&iwc->iwc_lock);
Home |
Main Index |
Thread Index |
Old Index