Lines Matching defs:dtl
15 #include <asm/dtl.h>
21 struct dtl {
28 static DEFINE_PER_CPU(struct dtl, cpu_dtl);
81 static int dtl_start(struct dtl *dtl)
83 struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu);
85 dtlr->buf = dtl->buf;
86 dtlr->buf_end = dtl->buf + dtl->buf_entries;
91 dtlr->write_ptr = dtl->buf;
94 lppaca_of(dtl->cpu).dtl_enable_mask |= dtl_event_mask;
101 static void dtl_stop(struct dtl *dtl)
103 struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu);
111 lppaca_of(dtl->cpu).dtl_enable_mask = DTL_LOG_PREEMPT;
117 static u64 dtl_current_index(struct dtl *dtl)
119 return per_cpu(dtl_rings, dtl->cpu).write_index;
124 static int dtl_start(struct dtl *dtl)
129 /* Register our dtl buffer with the hypervisor. The HV expects the
131 ((u32 *)dtl->buf)[1] = cpu_to_be32(DISPATCH_LOG_BYTES);
133 hwcpu = get_hard_smp_processor_id(dtl->cpu);
134 addr = __pa(dtl->buf);
138 "failed with %d\n", __func__, dtl->cpu, hwcpu, ret);
143 lppaca_of(dtl->cpu).dtl_idx = 0;
150 lppaca_of(dtl->cpu).dtl_enable_mask = dtl_event_mask;
155 static void dtl_stop(struct dtl *dtl)
157 int hwcpu = get_hard_smp_processor_id(dtl->cpu);
159 lppaca_of(dtl->cpu).dtl_enable_mask = 0x0;
164 static u64 dtl_current_index(struct dtl *dtl)
166 return be64_to_cpu(lppaca_of(dtl->cpu).dtl_idx);
170 static int dtl_enable(struct dtl *dtl)
180 if (dtl->buf)
183 /* ensure there are no other conflicting dtl users */
188 buf = kmem_cache_alloc_node(dtl_cache, GFP_KERNEL, cpu_to_node(dtl->cpu));
191 __func__, dtl->cpu);
196 spin_lock(&dtl->lock);
198 if (!dtl->buf) {
200 dtl->buf_entries = n_entries;
201 dtl->buf = buf;
202 dtl->last_idx = 0;
203 rc = dtl_start(dtl);
205 dtl->buf = NULL;
207 spin_unlock(&dtl->lock);
217 static void dtl_disable(struct dtl *dtl)
219 spin_lock(&dtl->lock);
220 dtl_stop(dtl);
221 kmem_cache_free(dtl_cache, dtl->buf);
222 dtl->buf = NULL;
223 dtl->buf_entries = 0;
224 spin_unlock(&dtl->lock);
232 struct dtl *dtl = inode->i_private;
235 rc = dtl_enable(dtl);
239 filp->private_data = dtl;
245 struct dtl *dtl = inode->i_private;
246 dtl_disable(dtl);
254 struct dtl *dtl;
260 dtl = filp->private_data;
268 spin_lock(&dtl->lock);
270 cur_idx = dtl_current_index(dtl);
271 last_idx = dtl->last_idx;
273 if (last_idx + dtl->buf_entries <= cur_idx)
274 last_idx = cur_idx - dtl->buf_entries + 1;
280 dtl->last_idx = last_idx + n_req;
282 spin_unlock(&dtl->lock);
287 i = last_idx % dtl->buf_entries;
290 if (i + n_req > dtl->buf_entries) {
291 read_size = dtl->buf_entries - i;
293 rc = copy_to_user(buf, &dtl->buf[i],
305 rc = copy_to_user(buf, &dtl->buf[i], n_req * sizeof(struct dtl_entry));
323 static void dtl_setup_file(struct dtl *dtl)
327 sprintf(name, "cpu-%d", dtl->cpu);
329 debugfs_create_file(name, 0400, dtl_dir, dtl, &dtl_fops);
341 dtl_dir = debugfs_create_dir("dtl", powerpc_debugfs_root);
348 struct dtl *dtl = &per_cpu(cpu_dtl, i);
349 spin_lock_init(&dtl->lock);
350 dtl->cpu = i;
352 dtl_setup_file(dtl);