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 drm: Eliminate hrtimer_destroy a...



details:   https://anonhg.NetBSD.org/src/rev/5844cd249e37
branches:  trunk
changeset: 1028748:5844cd249e37
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:55:47 2021 +0000

description:
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:

 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c |   5 +-
 sys/external/bsd/drm2/dist/drm/drm_vblank.c              |   5 +-
 sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c       |   5 +-
 sys/external/bsd/drm2/include/linux/hrtimer.h            |  18 ++--
 sys/external/bsd/drm2/include/linux/timer.h              |  16 +---
 sys/external/bsd/drm2/linux/linux_hrtimer.c              |  70 ++++-----------
 6 files changed, 37 insertions(+), 82 deletions(-)

diffs (truncated from 368 to 300 lines):

diff -r d5b8f694d5b9 -r 5844cd249e37 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c  Sun Dec 19 11:55:38 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fence.c  Sun Dec 19 11:55:47 2021 +0000
@@ -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 @@
                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 -r d5b8f694d5b9 -r 5844cd249e37 sys/external/bsd/drm2/dist/drm/drm_vblank.c
--- a/sys/external/bsd/drm2/dist/drm/drm_vblank.c       Sun Dec 19 11:55:38 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_vblank.c       Sun Dec 19 11:55:47 2021 +0000
@@ -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 @@
                        drm_core_check_feature(dev, DRIVER_MODESET));
 
                del_timer_sync(&vblank->disable_timer);
-               teardown_timer(&vblank->disable_timer);
                seqlock_destroy(&vblank->seqlock);
        }
 
diff -r d5b8f694d5b9 -r 5844cd249e37 sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c
--- a/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c        Sun Dec 19 11:55:38 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c        Sun Dec 19 11:55:47 2021 +0000
@@ -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 @@
        uncore->fw_domains &= ~BIT(domain_id);
        WARN_ON(d->wake_count);
        WARN_ON(hrtimer_cancel(&d->timer));
-       hrtimer_destroy(&d->timer);
        kfree(d);
 }
 
diff -r d5b8f694d5b9 -r 5844cd249e37 sys/external/bsd/drm2/include/linux/hrtimer.h
--- a/sys/external/bsd/drm2/include/linux/hrtimer.h     Sun Dec 19 11:55:38 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/hrtimer.h     Sun Dec 19 11:55:47 2021 +0000
@@ -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 @@
 #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_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 -r d5b8f694d5b9 -r 5844cd249e37 sys/external/bsd/drm2/include/linux/timer.h
--- a/sys/external/bsd/drm2/include/linux/timer.h       Sun Dec 19 11:55:38 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/timer.h       Sun Dec 19 11:55:47 2021 +0000
@@ -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 @@
            (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 -r d5b8f694d5b9 -r 5844cd249e37 sys/external/bsd/drm2/linux/linux_hrtimer.c
--- a/sys/external/bsd/drm2/linux/linux_hrtimer.c       Sun Dec 19 11:55:38 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_hrtimer.c       Sun Dec 19 11:55:47 2021 +0000
@@ -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 @@
                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 @@
 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.  */



Home | Main Index | Thread Index | Old Index