Skip to content

Commit 3f8ddb0

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/hwspinlock
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/hwspinlock: hwspinlock: add MAINTAINERS entries hwspinlock/omap: omap_hwspinlock_remove should be __devexit hwspinlock/u8500: add hwspinlock driver hwspinlock/core: register a bank of hwspinlocks in a single API call hwspinlock/core: remove stubs for register/unregister hwspinlock/core: use a mutex to protect the radix tree hwspinlock/core/omap: fix id issues on multiple hwspinlock devices hwspinlock/omap: simplify allocation scheme hwspinlock/core: simplify 'owner' handling hwspinlock/core: simplify Kconfig Fix up trivial conflicts (addition of omap_hwspinlock_pdata, removal of omap_spinlock_latency) in arch/arm/mach-omap2/hwspinlock.c Also, do an "evil merge" to fix a compile error in omap_hsmmc.c which for some reason was reported in the same email thread as the "please pull hwspinlock changes".
2 parents 30307c6 + 8b37fcf commit 3f8ddb0

11 files changed

Lines changed: 516 additions & 226 deletions

File tree

‎Documentation/hwspinlock.txt‎

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,20 @@ independent, drivers.
3939
in case an unused hwspinlock isn't available. Users of this
4040
API will usually want to communicate the lock's id to the remote core
4141
before it can be used to achieve synchronization.
42-
Can be called from an atomic context (this function will not sleep) but
43-
not from within interrupt context.
42+
Should be called from a process context (might sleep).
4443

4544
struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
4645
- assign a specific hwspinlock id and return its address, or NULL
4746
if that hwspinlock is already in use. Usually board code will
4847
be calling this function in order to reserve specific hwspinlock
4948
ids for predefined purposes.
50-
Can be called from an atomic context (this function will not sleep) but
51-
not from within interrupt context.
49+
Should be called from a process context (might sleep).
5250

5351
int hwspin_lock_free(struct hwspinlock *hwlock);
5452
- free a previously-assigned hwspinlock; returns 0 on success, or an
5553
appropriate error code on failure (e.g. -EINVAL if the hwspinlock
5654
is already free).
57-
Can be called from an atomic context (this function will not sleep) but
58-
not from within interrupt context.
55+
Should be called from a process context (might sleep).
5956

6057
int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout);
6158
- lock a previously-assigned hwspinlock with a timeout limit (specified in
@@ -230,45 +227,62 @@ int hwspinlock_example2(void)
230227

231228
4. API for implementors
232229

233-
int hwspin_lock_register(struct hwspinlock *hwlock);
230+
int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
231+
const struct hwspinlock_ops *ops, int base_id, int num_locks);
234232
- to be called from the underlying platform-specific implementation, in
235-
order to register a new hwspinlock instance. Can be called from an atomic
236-
context (this function will not sleep) but not from within interrupt
237-
context. Returns 0 on success, or appropriate error code on failure.
233+
order to register a new hwspinlock device (which is usually a bank of
234+
numerous locks). Should be called from a process context (this function
235+
might sleep).
236+
Returns 0 on success, or appropriate error code on failure.
238237

239-
struct hwspinlock *hwspin_lock_unregister(unsigned int id);
238+
int hwspin_lock_unregister(struct hwspinlock_device *bank);
240239
- to be called from the underlying vendor-specific implementation, in order
241-
to unregister an existing (and unused) hwspinlock instance.
242-
Can be called from an atomic context (will not sleep) but not from
243-
within interrupt context.
240+
to unregister an hwspinlock device (which is usually a bank of numerous
241+
locks).
242+
Should be called from a process context (this function might sleep).
244243
Returns the address of hwspinlock on success, or NULL on error (e.g.
245244
if the hwspinlock is sill in use).
246245

247-
5. struct hwspinlock
246+
5. Important structs
248247

249-
This struct represents an hwspinlock instance. It is registered by the
250-
underlying hwspinlock implementation using the hwspin_lock_register() API.
248+
struct hwspinlock_device is a device which usually contains a bank
249+
of hardware locks. It is registered by the underlying hwspinlock
250+
implementation using the hwspin_lock_register() API.
251251

252252
/**
253-
* struct hwspinlock - vendor-specific hwspinlock implementation
254-
*
255-
* @dev: underlying device, will be used with runtime PM api
256-
* @ops: vendor-specific hwspinlock handlers
257-
* @id: a global, unique, system-wide, index of the lock.
258-
* @lock: initialized and used by hwspinlock core
259-
* @owner: underlying implementation module, used to maintain module ref count
253+
* struct hwspinlock_device - a device which usually spans numerous hwspinlocks
254+
* @dev: underlying device, will be used to invoke runtime PM api
255+
* @ops: platform-specific hwspinlock handlers
256+
* @base_id: id index of the first lock in this device
257+
* @num_locks: number of locks in this device
258+
* @lock: dynamically allocated array of 'struct hwspinlock'
260259
*/
261-
struct hwspinlock {
260+
struct hwspinlock_device {
262261
struct device *dev;
263262
const struct hwspinlock_ops *ops;
264-
int id;
263+
int base_id;
264+
int num_locks;
265+
struct hwspinlock lock[0];
266+
};
267+
268+
struct hwspinlock_device contains an array of hwspinlock structs, each
269+
of which represents a single hardware lock:
270+
271+
/**
272+
* struct hwspinlock - this struct represents a single hwspinlock instance
273+
* @bank: the hwspinlock_device structure which owns this lock
274+
* @lock: initialized and used by hwspinlock core
275+
* @priv: private data, owned by the underlying platform-specific hwspinlock drv
276+
*/
277+
struct hwspinlock {
278+
struct hwspinlock_device *bank;
265279
spinlock_t lock;
266-
struct module *owner;
280+
void *priv;
267281
};
268282

269-
The underlying implementation is responsible to assign the dev, ops, id and
270-
owner members. The lock member, OTOH, is initialized and used by the hwspinlock
271-
core.
283+
When registering a bank of locks, the hwspinlock driver only needs to
284+
set the priv members of the locks. The rest of the members are set and
285+
initialized by the hwspinlock core itself.
272286

273287
6. Implementation callbacks
274288

‎MAINTAINERS‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,13 @@ F: Documentation/hw_random.txt
30183018
F: drivers/char/hw_random/
30193019
F: include/linux/hw_random.h
30203020

3021+
HARDWARE SPINLOCK CORE
3022+
M: Ohad Ben-Cohen <ohad@wizery.com>
3023+
S: Maintained
3024+
F: Documentation/hwspinlock.txt
3025+
F: drivers/hwspinlock/hwspinlock_*
3026+
F: include/linux/hwspinlock.h
3027+
30213028
HARMONY SOUND DRIVER
30223029
M: Kyle McMartin <kyle@mcmartin.ca>
30233030
L: linux-parisc@vger.kernel.org
@@ -4714,6 +4721,13 @@ S: Maintained
47144721
F: drivers/video/omap2/
47154722
F: Documentation/arm/OMAP/DSS
47164723

4724+
OMAP HARDWARE SPINLOCK SUPPORT
4725+
M: Ohad Ben-Cohen <ohad@wizery.com>
4726+
L: linux-omap@vger.kernel.org
4727+
S: Maintained
4728+
F: drivers/hwspinlock/omap_hwspinlock.c
4729+
F: arch/arm/mach-omap2/hwspinlock.c
4730+
47174731
OMAP MMC SUPPORT
47184732
M: Jarkko Lavinen <jarkko.lavinen@nokia.com>
47194733
L: linux-omap@vger.kernel.org

‎arch/arm/mach-omap2/hwspinlock.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919
#include <linux/kernel.h>
2020
#include <linux/init.h>
2121
#include <linux/err.h>
22+
#include <linux/hwspinlock.h>
2223

2324
#include <plat/omap_hwmod.h>
2425
#include <plat/omap_device.h>
2526

27+
static struct hwspinlock_pdata omap_hwspinlock_pdata __initdata = {
28+
.base_id = 0,
29+
};
30+
2631
int __init hwspinlocks_init(void)
2732
{
2833
int retval = 0;
@@ -40,7 +45,9 @@ int __init hwspinlocks_init(void)
4045
if (oh == NULL)
4146
return -EINVAL;
4247

43-
pdev = omap_device_build(dev_name, 0, oh, NULL, 0, NULL, 0, false);
48+
pdev = omap_device_build(dev_name, 0, oh, &omap_hwspinlock_pdata,
49+
sizeof(struct hwspinlock_pdata),
50+
NULL, 0, false);
4451
if (IS_ERR(pdev)) {
4552
pr_err("Can't build omap_device for %s:%s\n", dev_name,
4653
oh_name);

‎drivers/hwspinlock/Kconfig‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22
# Generic HWSPINLOCK framework
33
#
44

5+
# HWSPINLOCK always gets selected by whoever wants it.
56
config HWSPINLOCK
6-
tristate "Generic Hardware Spinlock framework"
7-
depends on ARCH_OMAP4
8-
help
9-
Say y here to support the generic hardware spinlock framework.
10-
You only need to enable this if you have hardware spinlock module
11-
on your system (usually only relevant if your system has remote slave
12-
coprocessors).
7+
tristate
138

14-
If unsure, say N.
9+
menu "Hardware Spinlock drivers"
1510

1611
config HWSPINLOCK_OMAP
1712
tristate "OMAP Hardware Spinlock device"
18-
depends on HWSPINLOCK && ARCH_OMAP4
13+
depends on ARCH_OMAP4
14+
select HWSPINLOCK
1915
help
2016
Say y here to support the OMAP Hardware Spinlock device (firstly
2117
introduced in OMAP4).
2218

2319
If unsure, say N.
20+
21+
config HSEM_U8500
22+
tristate "STE Hardware Semaphore functionality"
23+
depends on ARCH_U8500
24+
select HWSPINLOCK
25+
help
26+
Say y here to support the STE Hardware Semaphore functionality, which
27+
provides a synchronisation mechanism for the various processor on the
28+
SoC.
29+
30+
If unsure, say N.
31+
32+
endmenu

‎drivers/hwspinlock/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
obj-$(CONFIG_HWSPINLOCK) += hwspinlock_core.o
66
obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o
7+
obj-$(CONFIG_HSEM_U8500) += u8500_hsem.o

0 commit comments

Comments
 (0)