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