Lines Matching defs:dtl

16 #include <asm/dtl.h>
22 struct dtl {
29 static DEFINE_PER_CPU(struct dtl, cpu_dtl);
91 static int dtl_start(struct dtl *dtl)
93 struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu);
95 dtlr->buf = dtl->buf;
96 dtlr->buf_end = dtl->buf + dtl->buf_entries;
101 dtlr->write_ptr = dtl->buf;
104 lppaca_of(dtl->cpu).dtl_enable_mask |= dtl_event_mask;
111 static void dtl_stop(struct dtl *dtl)
113 struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu);
121 lppaca_of(dtl->cpu).dtl_enable_mask = DTL_LOG_PREEMPT;
127 static u64 dtl_current_index(struct dtl *dtl)
129 return per_cpu(dtl_rings, dtl->cpu).write_index;
134 static int dtl_start(struct dtl *dtl)
139 /* Register our dtl buffer with the hypervisor. The HV expects the
141 ((u32 *)dtl->buf)[1] = cpu_to_be32(DISPATCH_LOG_BYTES);
143 hwcpu = get_hard_smp_processor_id(dtl->cpu);
144 addr = __pa(dtl->buf);
148 "failed with %d\n", __func__, dtl->cpu, hwcpu, ret);
153 lppaca_of(dtl->cpu).dtl_idx = 0;
160 lppaca_of(dtl->cpu).dtl_enable_mask = dtl_event_mask;
165 static void dtl_stop(struct dtl *dtl)
167 int hwcpu = get_hard_smp_processor_id(dtl->cpu);
169 lppaca_of(dtl->cpu).dtl_enable_mask = 0x0;
174 static u64 dtl_current_index(struct dtl *dtl)
176 return be64_to_cpu(lppaca_of(dtl->cpu).dtl_idx);
180 static int dtl_enable(struct dtl *dtl)
190 if (dtl->buf)
193 /* ensure there are no other conflicting dtl users */
198 buf = kmem_cache_alloc_node(dtl_cache, GFP_KERNEL, cpu_to_node(dtl->cpu));
201 __func__, dtl->cpu);
206 spin_lock(&dtl->lock);
208 if (!dtl->buf) {
210 dtl->buf_entries = n_entries;
211 dtl->buf = buf;
212 dtl->last_idx = 0;
213 rc = dtl_start(dtl);
215 dtl->buf = NULL;
217 spin_unlock(&dtl->lock);
227 static void dtl_disable(struct dtl *dtl)
229 spin_lock(&dtl->lock);
230 dtl_stop(dtl);
231 kmem_cache_free(dtl_cache, dtl->buf);
232 dtl->buf = NULL;
233 dtl->buf_entries = 0;
234 spin_unlock(&dtl->lock);
242 struct dtl *dtl = inode->i_private;
245 rc = dtl_enable(dtl);
249 filp->private_data = dtl;
255 struct dtl *dtl = inode->i_private;
256 dtl_disable(dtl);
264 struct dtl *dtl;
270 dtl = filp->private_data;
278 spin_lock(&dtl->lock);
280 cur_idx = dtl_current_index(dtl);
281 last_idx = dtl->last_idx;
283 if (last_idx + dtl->buf_entries <= cur_idx)
284 last_idx = cur_idx - dtl->buf_entries + 1;
290 dtl->last_idx = last_idx + n_req;
292 spin_unlock(&dtl->lock);
297 i = last_idx % dtl->buf_entries;
300 if (i + n_req > dtl->buf_entries) {
301 read_size = dtl->buf_entries - i;
303 rc = copy_to_user(buf, &dtl->buf[i],
315 rc = copy_to_user(buf, &dtl->buf[i], n_req * sizeof(struct dtl_entry));
333 static void dtl_setup_file(struct dtl *dtl)
337 sprintf(name, "cpu-%d", dtl->cpu);
339 debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops);
351 dtl_dir = debugfs_create_dir("dtl", arch_debugfs_dir);
358 struct dtl *dtl = &per_cpu(cpu_dtl, i);
359 spin_lock_init(&dtl->lock);
360 dtl->cpu = i;
362 dtl_setup_file(dtl);
378 struct dtl_entry *dtl = local_paca->dtl_curr;
385 if (!dtl)
391 dtb = be64_to_cpu(dtl->timebase);
392 tb_delta = be32_to_cpu(dtl->enqueue_to_dispatch_time) +
393 be32_to_cpu(dtl->ready_to_enqueue_time);
398 dtl = local_paca->dispatch_log + (i % N_DISPATCH_LOG);
405 dtl_consumer(dtl, i);
409 ++dtl;
410 if (dtl == dtl_end)
411 dtl = local_paca->dispatch_log;
414 local_paca->dtl_curr = dtl;