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