]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
x86/hpet: Add function to select a /dev/hpet channel
authorThomas Gleixner <tglx@linutronix.de>
Sun, 23 Jun 2019 13:24:01 +0000 (15:24 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 27 Jun 2019 22:57:23 +0000 (00:57 +0200)
If CONFIG_HPET=y is enabled the x86 specific HPET code should reserve at
least one channel for the /dev/hpet character device, so that not all
channels are absorbed for per CPU clockevent devices.

Create a function to assign HPET_MODE_DEVICE so the rework of the
clockevents allocation code can utilize the mode information instead of
reducing the number of evaluated channels by #ifdef hackery.

The function is not yet used, but provided as a separate patch for ease of
review. It will be used when the rework of the clockevent selection takes
place.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Link: https://lkml.kernel.org/r/20190623132436.002758910@linutronix.de
arch/x86/kernel/hpet.c

index 3a8ec363d5694fc864ac01e46c28a313b3d72359..640ff75cc52392730c4545ecdce7dd0c7652e54a 100644 (file)
@@ -228,8 +228,25 @@ static void __init hpet_reserve_platform_timers(void)
        hpet_alloc(&hd);
 
 }
+
+static void __init hpet_select_device_channel(void)
+{
+       int i;
+
+       for (i = 0; i < hpet_base.nr_channels; i++) {
+               struct hpet_channel *hc = hpet_base.channels + i;
+
+               /* Associate the first unused channel to /dev/hpet */
+               if (hc->mode == HPET_MODE_UNUSED) {
+                       hc->mode = HPET_MODE_DEVICE;
+                       return;
+               }
+       }
+}
+
 #else
 static inline void hpet_reserve_platform_timers(void) { }
+static inline void hpet_select_device_channel(void) {}
 #endif
 
 /* Common HPET functions */