Linux Kernel
3.7.1
|
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/err.h>
#include <linux/jiffies.h>
#include <linux/radix-tree.h>
#include <linux/hwspinlock.h>
#include <linux/pm_runtime.h>
#include <linux/mutex.h>
#include "hwspinlock_internal.h"
Go to the source code of this file.
Macros | |
#define | pr_fmt(fmt) "%s: " fmt, __func__ |
#define | HWSPINLOCK_UNUSED (0) /* tags an hwspinlock as unused */ |
#define HWSPINLOCK_UNUSED (0) /* tags an hwspinlock as unused */ |
Definition at line 34 of file hwspinlock_core.c.
#define pr_fmt | ( | fmt | ) | "%s: " fmt, __func__ |
Definition at line 18 of file hwspinlock_core.c.
int __hwspin_lock_timeout | ( | struct hwspinlock * | hwlock, |
unsigned int | to, | ||
int | mode, | ||
unsigned long * | flags | ||
) |
__hwspin_lock_timeout() - lock an hwspinlock with timeout limit : the hwspinlock to be locked : timeout value in msecs : mode which controls whether local interrupts are disabled or not : a pointer to where the caller's interrupt state will be saved at (if requested)
This function locks the given . If the is already taken, the function will busy loop waiting for it to be released, but give up after msecs have elapsed.
Upon a successful return from this function, preemption is disabled (and possibly local interrupts, too), so the caller must not sleep, and is advised to release the hwspinlock as soon as possible. This is required in order to minimize remote cores polling on the hardware interconnect.
The user decides whether local interrupts are disabled or not, and if yes, whether he wants their previous state to be saved. It is up to the user to choose the appropriate of operation, exactly the same way users should decide between spin_lock, spin_lock_irq and spin_lock_irqsave.
Returns 0 when the was successfully taken, and an appropriate error code otherwise (most notably -ETIMEDOUT if the is still busy after msecs). The function will never sleep.
Definition at line 177 of file hwspinlock_core.c.
int __hwspin_trylock | ( | struct hwspinlock * | hwlock, |
int | mode, | ||
unsigned long * | flags | ||
) |
__hwspin_trylock() - attempt to lock a specific hwspinlock : an hwspinlock which we want to trylock : controls whether local interrupts are disabled or not : a pointer where the caller's interrupt state will be saved at (if requested)
This function attempts to lock an hwspinlock, and will immediately fail if the hwspinlock is already taken.
Upon a successful return from this function, preemption (and possibly interrupts) is disabled, so the caller must not sleep, and is advised to release the hwspinlock as soon as possible. This is required in order to minimize remote cores polling on the hardware interconnect.
The user decides whether local interrupts are disabled or not, and if yes, whether he wants their previous state to be saved. It is up to the user to choose the appropriate of operation, exactly the same way users should decide between spin_trylock, spin_trylock_irq and spin_trylock_irqsave.
Returns 0 if we successfully locked the hwspinlock or -EBUSY if the hwspinlock was already taken. This function will never sleep.
Definition at line 88 of file hwspinlock_core.c.
void __hwspin_unlock | ( | struct hwspinlock * | hwlock, |
int | mode, | ||
unsigned long * | flags | ||
) |
__hwspin_unlock() - unlock a specific hwspinlock : a previously-acquired hwspinlock which we want to unlock : controls whether local interrupts needs to be restored or not : previous caller's interrupt state to restore (if requested)
This function will unlock a specific hwspinlock, enable preemption and (possibly) enable interrupts or restore their previous state. must be already locked before calling this function: it is a bug to call unlock on a that is already unlocked.
The user decides whether local interrupts should be enabled or not, and if yes, whether he wants their previous state to be restored. It is up to the user to choose the appropriate of operation, exactly the same way users decide between spin_unlock, spin_unlock_irq and spin_unlock_irqrestore.
The function will never sleep.
Definition at line 229 of file hwspinlock_core.c.
EXPORT_SYMBOL_GPL | ( | __hwspin_trylock | ) |
EXPORT_SYMBOL_GPL | ( | __hwspin_lock_timeout | ) |
EXPORT_SYMBOL_GPL | ( | __hwspin_unlock | ) |
EXPORT_SYMBOL_GPL | ( | hwspin_lock_register | ) |
EXPORT_SYMBOL_GPL | ( | hwspin_lock_unregister | ) |
EXPORT_SYMBOL_GPL | ( | hwspin_lock_get_id | ) |
EXPORT_SYMBOL_GPL | ( | hwspin_lock_request | ) |
EXPORT_SYMBOL_GPL | ( | hwspin_lock_request_specific | ) |
EXPORT_SYMBOL_GPL | ( | hwspin_lock_free | ) |
int hwspin_lock_free | ( | struct hwspinlock * | hwlock | ) |
hwspin_lock_free() - free a specific hwspinlock : the specific hwspinlock to free
This function mark as free again. Should only be called with an that was retrieved from an earlier call to omap_hwspin_lock_request{_specific}.
Should be called from a process context (might sleep)
Returns 0 on success, or an appropriate error code on failure
Definition at line 553 of file hwspinlock_core.c.
int hwspin_lock_get_id | ( | struct hwspinlock * | hwlock | ) |
hwspin_lock_get_id() - retrieve id number of a given hwspinlock : a valid hwspinlock instance
Returns the id number of a given , or -EINVAL if is invalid.
Definition at line 438 of file hwspinlock_core.c.
int hwspin_lock_register | ( | struct hwspinlock_device * | bank, |
struct device * | dev, | ||
const struct hwspinlock_ops * | ops, | ||
int | base_id, | ||
int | num_locks | ||
) |
hwspin_lock_register() - register a new hw spinlock device : the hwspinlock device, which usually provides numerous hw locks : the backing device : hwspinlock handlers for this device : id of the first hardware spinlock in this bank : number of hwspinlocks provided by this device
This function should be called from the underlying platform-specific implementation, to register a new hwspinlock device instance.
Should be called from a process context (might sleep)
Returns 0 on success, or an appropriate error code on failure
Definition at line 325 of file hwspinlock_core.c.
|
read |
hwspin_lock_request() - request an hwspinlock
This function should be called by users of the hwspinlock device, in order to dynamically assign them an unused hwspinlock. Usually the user of this lock will then have to communicate the lock's id to the remote core before it can be used for synchronization (to get the id of a given hwlock, use hwspin_lock_get_id()).
Should be called from a process context (might sleep)
Returns the address of the assigned hwspinlock, or NULL on error
Definition at line 462 of file hwspinlock_core.c.
|
read |
hwspin_lock_request_specific() - request for a specific hwspinlock : index of the specific hwspinlock that is requested
This function should be called by users of the hwspinlock module, in order to assign them a specific hwspinlock. Usually early board code will be calling this function in order to reserve specific hwspinlock ids for predefined purposes.
Should be called from a process context (might sleep)
Returns the address of the assigned hwspinlock, or NULL on error
Definition at line 505 of file hwspinlock_core.c.
int hwspin_lock_unregister | ( | struct hwspinlock_device * | bank | ) |
hwspin_lock_unregister() - unregister an hw spinlock device : the hwspinlock device, which usually provides numerous hw locks
This function should be called from the underlying platform-specific implementation, to unregister an existing (and unused) hwspinlock.
Should be called from a process context (might sleep)
Returns 0 on success, or an appropriate error code on failure
Definition at line 373 of file hwspinlock_core.c.
MODULE_AUTHOR | ( | "Ohad Ben-Cohen <[email protected]>" | ) |
MODULE_LICENSE | ( | "GPL v2" | ) |