cregit-Linux how code gets into the kernel

Release 4.14 drivers/gpu/drm/drm_flip_work.c

Directory: drivers/gpu/drm
/*
 * Copyright (C) 2013 Red Hat
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <drm/drmP.h>
#include <drm/drm_flip_work.h>

/**
 * drm_flip_work_allocate_task - allocate a flip-work task
 * @data: data associated to the task
 * @flags: allocator flags
 *
 * Allocate a drm_flip_task object and attach private data to it.
 */

struct drm_flip_task *drm_flip_work_allocate_task(void *data, gfp_t flags) { struct drm_flip_task *task; task = kzalloc(sizeof(*task), flags); if (task) task->data = data; return task; }

Contributors

PersonTokensPropCommitsCommitProp
Boris Brezillon45100.00%1100.00%
Total45100.00%1100.00%

EXPORT_SYMBOL(drm_flip_work_allocate_task); /** * drm_flip_work_queue_task - queue a specific task * @work: the flip-work * @task: the task to handle * * Queues task, that will later be run (passed back to drm_flip_func_t * func) on a work queue after drm_flip_work_commit() is called. */
void drm_flip_work_queue_task(struct drm_flip_work *work, struct drm_flip_task *task) { unsigned long flags; spin_lock_irqsave(&work->lock, flags); list_add_tail(&task->node, &work->queued); spin_unlock_irqrestore(&work->lock, flags); }

Contributors

PersonTokensPropCommitsCommitProp
Boris Brezillon52100.00%1100.00%
Total52100.00%1100.00%

EXPORT_SYMBOL(drm_flip_work_queue_task); /** * drm_flip_work_queue - queue work * @work: the flip-work * @val: the value to queue * * Queues work, that will later be run (passed back to drm_flip_func_t * func) on a work queue after drm_flip_work_commit() is called. */
void drm_flip_work_queue(struct drm_flip_work *work, void *val) { struct drm_flip_task *task; task = drm_flip_work_allocate_task(val, drm_can_sleep() ? GFP_KERNEL : GFP_ATOMIC); if (task) { drm_flip_work_queue_task(work, task); } else { DRM_ERROR("%s could not allocate task!\n", work->name); work->func(work, val); } }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark4465.67%150.00%
Boris Brezillon2334.33%150.00%
Total67100.00%2100.00%

EXPORT_SYMBOL(drm_flip_work_queue); /** * drm_flip_work_commit - commit queued work * @work: the flip-work * @wq: the work-queue to run the queued work on * * Trigger work previously queued by drm_flip_work_queue() to run * on a workqueue. The typical usage would be to queue work (via * drm_flip_work_queue()) at any point (from vblank irq and/or * prior), and then from vblank irq commit the queued work. */
void drm_flip_work_commit(struct drm_flip_work *work, struct workqueue_struct *wq) { unsigned long flags; spin_lock_irqsave(&work->lock, flags); list_splice_tail(&work->queued, &work->commited); INIT_LIST_HEAD(&work->queued); spin_unlock_irqrestore(&work->lock, flags); queue_work(wq, &work->worker); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark4361.43%150.00%
Boris Brezillon2738.57%150.00%
Total70100.00%2100.00%

EXPORT_SYMBOL(drm_flip_work_commit);
static void flip_worker(struct work_struct *w) { struct drm_flip_work *work = container_of(w, struct drm_flip_work, worker); struct list_head tasks; unsigned long flags; while (1) { struct drm_flip_task *task, *tmp; INIT_LIST_HEAD(&tasks); spin_lock_irqsave(&work->lock, flags); list_splice_tail(&work->commited, &tasks); INIT_LIST_HEAD(&work->commited); spin_unlock_irqrestore(&work->lock, flags); if (list_empty(&tasks)) break; list_for_each_entry_safe(task, tmp, &tasks, node) { work->func(work, task->data); kfree(task); } } }

Contributors

PersonTokensPropCommitsCommitProp
Boris Brezillon7658.46%150.00%
Rob Clark5441.54%150.00%
Total130100.00%2100.00%

/** * drm_flip_work_init - initialize flip-work * @work: the flip-work to initialize * @name: debug name * @func: the callback work function * * Initializes/allocates resources for the flip-work */
void drm_flip_work_init(struct drm_flip_work *work, const char *name, drm_flip_func_t func) { work->name = name; INIT_LIST_HEAD(&work->queued); INIT_LIST_HEAD(&work->commited); spin_lock_init(&work->lock); work->func = func; INIT_WORK(&work->worker, flip_worker); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark5281.25%133.33%
Boris Brezillon1218.75%266.67%
Total64100.00%3100.00%

EXPORT_SYMBOL(drm_flip_work_init); /** * drm_flip_work_cleanup - cleans up flip-work * @work: the flip-work to cleanup * * Destroy resources allocated for the flip-work */
void drm_flip_work_cleanup(struct drm_flip_work *work) { WARN_ON(!list_empty(&work->queued) || !list_empty(&work->commited)); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark2477.42%150.00%
Boris Brezillon722.58%150.00%
Total31100.00%2100.00%

EXPORT_SYMBOL(drm_flip_work_cleanup);

Overall Contributors

PersonTokensPropCommitsCommitProp
Boris Brezillon25550.80%250.00%
Rob Clark24548.80%125.00%
Maarten Lankhorst20.40%125.00%
Total502100.00%4100.00%
Directory: drivers/gpu/drm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.