Documentation/locking/hwspinlock.rst

Source file repositories/reference/linux-study-clean/Documentation/locking/hwspinlock.rst

File Facts

System
Linux kernel
Corpus path
Documentation/locking/hwspinlock.rst
Extension
.rst
Size
14516 bytes
Lines
442
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct hwspinlock_device {
		struct device *dev;
		const struct hwspinlock_ops *ops;
		int base_id;
		int num_locks;
		struct hwspinlock lock[0];
	};

struct hwspinlock_device contains an array of hwspinlock structs, each
of which represents a single hardware lock::

	/**
	* struct hwspinlock - this struct represents a single hwspinlock instance
	* @bank: the hwspinlock_device structure which owns this lock
	* @lock: initialized and used by hwspinlock core
	* @priv: private data, owned by the underlying platform-specific hwspinlock drv
	*/
	struct hwspinlock {
		struct hwspinlock_device *bank;
		spinlock_t lock;
		void *priv;
	};

When registering a bank of locks, the hwspinlock driver only needs to
set the priv members of the locks. The rest of the members are set and
initialized by the hwspinlock core itself.

Implementation callbacks
========================

There are three possible callbacks defined in 'struct hwspinlock_ops'::

	struct hwspinlock_ops {
		int (*trylock)(struct hwspinlock *lock);
		void (*unlock)(struct hwspinlock *lock);
		void (*relax)(struct hwspinlock *lock);
	};

The first two callbacks are mandatory:

The ->trylock() callback should make a single attempt to take the lock, and
return 0 on failure and 1 on success. This callback may **not** sleep.

The ->unlock() callback releases the lock. It always succeed, and it, too,
may **not** sleep.

The ->relax() callback is optional. It is called by hwspinlock core while
spinning on a lock, and can be used by the underlying implementation to force
a delay between two successive invocations of ->trylock(). It may **not** sleep.

Annotation

Implementation Notes