summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2021-12-19 11:55:47 +0000
committerriastradh <riastradh@NetBSD.org>2021-12-19 11:55:47 +0000
commit3ce23fa4b21c5f6984dff5e6ae040c1fcb3d76fe (patch)
tree3b8d9741127a5547904ae64b645cff0a3c5819f8 /sys
parentfc6511217bdfdc36d7a0df332ec293a1f094be1d (diff)
drm: Eliminate hrtimer_destroy and teardown_timer.
These are non-Linux shims added to the Linux API to pair with hrtimer_setup and setup_timer, but they really only serve to call callout_destroy, which is not strictly necessary in the NetBSD API. So although we lose a little bit of diagnostic help this way, we also reduce diffs a bit and save some trouble that bit us last week.
Diffstat (limited to 'sys')
-rw-r--r--sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c5
-rw-r--r--sys/external/bsd/drm2/dist/drm/drm_vblank.c5
-rw-r--r--sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c5
-rw-r--r--sys/external/bsd/drm2/include/linux/hrtimer.h18
-rw-r--r--sys/external/bsd/drm2/include/linux/timer.h16
-rw-r--r--sys/external/bsd/drm2/linux/linux_hrtimer.c70
6 files changed, 37 insertions, 82 deletions
diff --git a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c
index e8099c9c107..97291e9686b 100644
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c
@@ -1,4 +1,4 @@
-/* $NetBSD: amdgpu_fence.c,v 1.8 2021/12/19 09:59:30 riastradh Exp $ */
+/* $NetBSD: amdgpu_fence.c,v 1.9 2021/12/19 11:55:47 riastradh Exp $ */
/*
* Copyright 2009 Jerome Glisse.
@@ -31,7 +31,7 @@
* Dave Airlie
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_fence.c,v 1.8 2021/12/19 09:59:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_fence.c,v 1.9 2021/12/19 11:55:47 riastradh Exp $");
#include <linux/seq_file.h>
#include <linux/atomic.h>
@@ -549,7 +549,6 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
ring->fence_drv.fences = NULL;
ring->fence_drv.initialized = false;
spin_lock_destroy(&ring->fence_drv.lock);
- timer_teardown(&ring->fence_drv.fallback_timer);
}
}
diff --git a/sys/external/bsd/drm2/dist/drm/drm_vblank.c b/sys/external/bsd/drm2/dist/drm/drm_vblank.c
index 04a8b2c2f99..7273c5048ed 100644
--- a/sys/external/bsd/drm2/dist/drm/drm_vblank.c
+++ b/sys/external/bsd/drm2/dist/drm/drm_vblank.c
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_vblank.c,v 1.10 2021/12/19 11:52:25 riastradh Exp $ */
+/* $NetBSD: drm_vblank.c,v 1.11 2021/12/19 11:55:47 riastradh Exp $ */
/*
* drm_irq.c IRQ and vblank support
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_vblank.c,v 1.10 2021/12/19 11:52:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_vblank.c,v 1.11 2021/12/19 11:55:47 riastradh Exp $");
#include <linux/export.h>
#include <linux/moduleparam.h>
@@ -463,7 +463,6 @@ void drm_vblank_cleanup(struct drm_device *dev)
drm_core_check_feature(dev, DRIVER_MODESET));
del_timer_sync(&vblank->disable_timer);
- teardown_timer(&vblank->disable_timer);
seqlock_destroy(&vblank->seqlock);
}
diff --git a/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c b/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c
index 8668c7c8641..5a92e1578b5 100644
--- a/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c
+++ b/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c
@@ -1,4 +1,4 @@
-/* $NetBSD: intel_uncore.c,v 1.18 2021/12/19 11:53:18 riastradh Exp $ */
+/* $NetBSD: intel_uncore.c,v 1.19 2021/12/19 11:55:47 riastradh Exp $ */
/*
* Copyright © 2013 Intel Corporation
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_uncore.c,v 1.18 2021/12/19 11:53:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_uncore.c,v 1.19 2021/12/19 11:55:47 riastradh Exp $");
#include <linux/pm_runtime.h>
#include <asm/iosf_mbi.h>
@@ -1519,7 +1519,6 @@ static void fw_domain_fini(struct intel_uncore *uncore,
uncore->fw_domains &= ~BIT(domain_id);
WARN_ON(d->wake_count);
WARN_ON(hrtimer_cancel(&d->timer));
- hrtimer_destroy(&d->timer);
kfree(d);
}
diff --git a/sys/external/bsd/drm2/include/linux/hrtimer.h b/sys/external/bsd/drm2/include/linux/hrtimer.h
index 49e3bda3757..6cf6e64e81c 100644
--- a/sys/external/bsd/drm2/include/linux/hrtimer.h
+++ b/sys/external/bsd/drm2/include/linux/hrtimer.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hrtimer.h,v 1.6 2021/12/19 11:53:09 riastradh Exp $ */
+/* $NetBSD: hrtimer.h,v 1.7 2021/12/19 11:55:47 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -39,18 +39,20 @@
#include <linux/ktime.h>
#include <linux/timer.h>
-struct hrtimer {
- enum hrtimer_restart (*function)(struct hrtimer *);
-
- struct hrtimer_private *hrt_private;
-};
-
enum hrtimer_mode {
HRTIMER_MODE_ABS,
HRTIMER_MODE_REL,
HRTIMER_MODE_REL_PINNED,
};
+struct hrtimer {
+ enum hrtimer_restart (*function)(struct hrtimer *);
+
+ struct callout hrt_ch;
+ enum hrtimer_mode hrt_mode;
+ ktime_t hrt_expires;
+};
+
enum hrtimer_restart {
HRTIMER_NORESTART,
HRTIMER_RESTART,
@@ -59,7 +61,6 @@ enum hrtimer_restart {
#define hrtimer_active linux_hrtimer_active
#define hrtimer_add_expires_ns linux_hrtimer_add_expires_ns
#define hrtimer_cancel linux_hrtimer_cancel
-#define hrtimer_destroy linux_hrtimer_destroy
#define hrtimer_forward linux_hrtimer_forward
#define hrtimer_forward_now linux_hrtimer_forward_now
#define hrtimer_init linux_hrtimer_init
@@ -74,7 +75,6 @@ void hrtimer_start(struct hrtimer *, ktime_t, enum hrtimer_mode);
void hrtimer_start_range_ns(struct hrtimer *, ktime_t, uint64_t,
enum hrtimer_mode);
int hrtimer_cancel(struct hrtimer *);
-void hrtimer_destroy(struct hrtimer *);
bool hrtimer_active(struct hrtimer *);
uint64_t hrtimer_forward(struct hrtimer *, ktime_t, ktime_t);
uint64_t hrtimer_forward_now(struct hrtimer *, ktime_t);
diff --git a/sys/external/bsd/drm2/include/linux/timer.h b/sys/external/bsd/drm2/include/linux/timer.h
index f2597cd3753..355aa119bfa 100644
--- a/sys/external/bsd/drm2/include/linux/timer.h
+++ b/sys/external/bsd/drm2/include/linux/timer.h
@@ -1,4 +1,4 @@
-/* $NetBSD: timer.h,v 1.13 2021/12/19 11:49:12 riastradh Exp $ */
+/* $NetBSD: timer.h,v 1.14 2021/12/19 11:55:47 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -29,13 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * Notes on porting:
- *
- * - Linux does not have teardown_timer. You must add it yourself in
- * the appropriate place.
- */
-
#ifndef _LINUX_TIMER_H_
#define _LINUX_TIMER_H_
@@ -64,13 +57,6 @@ timer_setup(struct timer_list *timer, void (*fn)(struct timer_list *),
(void *)timer);
}
-static inline void
-teardown_timer(struct timer_list *timer)
-{
-
- callout_destroy(&timer->tl_callout);
-}
-
static inline int
mod_timer(struct timer_list *timer, unsigned long then)
{
diff --git a/sys/external/bsd/drm2/linux/linux_hrtimer.c b/sys/external/bsd/drm2/linux/linux_hrtimer.c
index 73a62b3a2bd..a4b2453d00d 100644
--- a/sys/external/bsd/drm2/linux/linux_hrtimer.c
+++ b/sys/external/bsd/drm2/linux/linux_hrtimer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_hrtimer.c,v 1.2 2021/12/19 11:53:09 riastradh Exp $ */
+/* $NetBSD: linux_hrtimer.c,v 1.3 2021/12/19 11:55:47 riastradh Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,61 +27,49 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_hrtimer.c,v 1.2 2021/12/19 11:53:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_hrtimer.c,v 1.3 2021/12/19 11:55:47 riastradh Exp $");
#include <sys/types.h>
#include <sys/callout.h>
-#include <sys/kmem.h>
#include <linux/hrtimer.h>
#include <linux/ktime.h>
-struct hrtimer_private {
- struct callout ch;
- enum hrtimer_mode mode;
- ktime_t expires;
-};
-
static void hrtimer_fire(void *);
void
hrtimer_init(struct hrtimer *hrt, clockid_t clkid, enum hrtimer_mode mode)
{
- struct hrtimer_private *H;
KASSERTMSG(clkid == CLOCK_MONOTONIC, "clkid %d", clkid);
- H = hrt->hrt_private = kmem_zalloc(sizeof(*H), KM_SLEEP);
-
- callout_init(&H->ch, CALLOUT_MPSAFE);
- callout_setfunc(&H->ch, hrtimer_fire, H);
- H->mode = mode;
+ callout_init(&hrt->hrt_ch, CALLOUT_MPSAFE);
+ callout_setfunc(&hrt->hrt_ch, hrtimer_fire, hrt);
+ hrt->hrt_mode = mode;
}
static void
_hrtimer_schedule(struct hrtimer *hrt)
{
- struct hrtimer_private *H = hrt->hrt_private;
int delta;
- switch (H->mode) {
+ switch (hrt->hrt_mode) {
case HRTIMER_MODE_ABS:
panic("absolute hrtimer NYI");
break;
case HRTIMER_MODE_REL:
- delta = ktime_to_ms(H->expires);
+ delta = ktime_to_ms(hrt->hrt_expires);
break;
default:
- panic("invalid hrtimer mode %d", H->mode);
+ panic("invalid hrtimer mode %d", hrt->hrt_mode);
}
- callout_schedule(&H->ch, delta);
+ callout_schedule(&hrt->hrt_ch, delta);
}
static void
hrtimer_fire(void *cookie)
{
struct hrtimer *hrt = cookie;
- struct hrtimer_private *H = hrt->hrt_private;
switch ((*hrt->function)(hrt)) {
case HRTIMER_RESTART:
@@ -91,23 +79,21 @@ hrtimer_fire(void *cookie)
break;
}
- callout_ack(&H->ch);
+ callout_ack(&hrt->hrt_ch);
}
void
hrtimer_set_expires(struct hrtimer *hrt, ktime_t expires)
{
- struct hrtimer_private *H = hrt->hrt_private;
- H->expires = expires;
+ hrt->hrt_expires = expires;
}
void
hrtimer_add_expires_ns(struct hrtimer *hrt, uint64_t ns)
{
- struct hrtimer_private *H = hrt->hrt_private;
- H->expires = ktime_add_ns(H->expires, ns);
+ hrt->hrt_expires = ktime_add_ns(hrt->hrt_expires, ns);
}
void
@@ -121,25 +107,23 @@ void
hrtimer_start_range_ns(struct hrtimer *hrt, ktime_t expires, uint64_t range_ns,
enum hrtimer_mode mode)
{
- struct hrtimer_private *H = hrt->hrt_private;
- H->expires = expires;
+ hrt->hrt_expires = expires;
(void)range_ns;
- H->mode = mode;
+ hrt->hrt_mode = mode;
_hrtimer_schedule(hrt);
}
int
hrtimer_cancel(struct hrtimer *hrt)
{
- struct hrtimer_private *H = hrt->hrt_private;
bool active;
/*
* Halt the callout and ascertain whether the hrtimer was
* active when we invoked hrtimer_cancel.
*/
- if (callout_halt(&H->ch, NULL)) {
+ if (callout_halt(&hrt->hrt_ch, NULL)) {
/* Callout expired, meaning it was active. */
active = true;
} else {
@@ -149,26 +133,14 @@ hrtimer_cancel(struct hrtimer *hrt)
* corresponds with whether the hrtimer was active or
* not.
*/
- active = callout_pending(&H->ch);
+ active = callout_pending(&hrt->hrt_ch);
}
return active;
}
-void
-hrtimer_destroy(struct hrtimer *hrt)
-{
- struct hrtimer_private *H = hrt->hrt_private;
-
- callout_destroy(&H->ch);
- kmem_free(H, sizeof(*H));
-
- explicit_memset(hrt, 0, sizeof(*hrt)); /* paranoia */
-}
-
bool
hrtimer_active(struct hrtimer *hrt)
{
- struct hrtimer_private *H = hrt->hrt_private;
/*
* If the callout has been scheduled, but has not yet fired,
@@ -177,16 +149,15 @@ hrtimer_active(struct hrtimer *hrt)
* If the callout has fired, but has not yet reached
* callout_ack, then it is invoking.
*/
- return callout_pending(&H->ch) || callout_invoking(&H->ch);
+ return callout_pending(&hrt->hrt_ch) || callout_invoking(&hrt->hrt_ch);
}
uint64_t
hrtimer_forward(struct hrtimer *hrt, ktime_t now, ktime_t period)
{
- struct hrtimer_private *H = hrt->hrt_private;
uint64_t now_ms, period_ms, expires_ms, nperiods;
- KASSERT(!callout_pending(&H->ch));
+ KASSERT(!callout_pending(&hrt->hrt_ch));
/*
* Can't get better than 10ms precision (or ~1ms if you set
@@ -195,7 +166,7 @@ hrtimer_forward(struct hrtimer *hrt, ktime_t now, ktime_t period)
*/
now_ms = ktime_to_ms(now);
period_ms = ktime_to_ms(period);
- expires_ms = ktime_to_ms(H->expires);
+ expires_ms = ktime_to_ms(hrt->hrt_expires);
/* If it hasn't yet expired, no overruns. */
if (now_ms < expires_ms)
@@ -204,7 +175,8 @@ hrtimer_forward(struct hrtimer *hrt, ktime_t now, ktime_t period)
/* Advance it by as many periods as it should have fired. */
/* XXX fenceposts */
nperiods = howmany(now_ms - expires_ms, period_ms);
- H->expires = ktime_add_ns(H->expires, 1000000*nperiods*period_ms);
+ hrt->hrt_expires = ktime_add_ns(hrt->hrt_expires,
+ 1000000*nperiods*period_ms);
return nperiods;
}