drm/dp_mst: Add helper to get port number at specific LCT from RAD
[drm/drm-misc.git] / arch / loongarch / vdso / vgetcpu.c
blob0db51258b2a7ca7e44d2eb68ea514face48393f7
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Fast user context implementation of getcpu()
4 */
6 #include <asm/vdso.h>
7 #include <linux/getcpu.h>
9 static __always_inline int read_cpu_id(void)
11 int cpu_id;
13 __asm__ __volatile__(
14 " rdtime.d $zero, %0\n"
15 : "=r" (cpu_id)
17 : "memory");
19 return cpu_id;
22 static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
24 return _loongarch_data.pdata;
27 extern
28 int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
29 int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
31 int cpu_id;
32 const struct vdso_pcpu_data *data;
34 cpu_id = read_cpu_id();
36 if (cpu)
37 *cpu = cpu_id;
39 if (node) {
40 data = get_pcpu_data();
41 *node = data[cpu_id].node;
44 return 0;