Commit Graph

30 Commits

Author SHA1 Message Date
Steven Cahail 42c818494b hwspinlock/msm: Add PID tracking for remote spinlocks
The msm_remote_spinlock driver currently does not store the owner of the
lock (the raw value of the lock), and the state of the hardware lock is not
saved in memory dumps. This increases difficulty when debugging situations
where the lock could not be acquired.

Store the value of each lock in an array, and provide an API to read
elements from this array for testing purposes.

Change-Id: I7186c5201bbd6e51249fb073e899d2ac69e5bec7
Signed-off-by: Steven Cahail <scahail@codeaurora.org>
2015-01-27 11:38:57 -07:00
Eric Holmberg 6e3caa1e4f hwspinlock/msm: correct pid for release functionality
Valid remote spinlock processor ID's are 1..N, but the processor IDs
start at 0.  To fix this, the value written to the HW Mutex is PID + 1.
Because the release functionality was using the PID for comparison, the
remote spinlock was not being properly released during subsystem restart
processing which would ultimately result in a watchdog if the remote
subsystem failed with the remote spinlock locked.

Update the release functions to compare the lock value with PID + 1.

CRs-Fixed: 725337
Change-Id: I4d484b5d37cfd1f9f8c6a3290ed378812620b130
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
2014-09-16 17:42:57 -06:00
Jeff Hugo e2564644b1 hwspinlock/msm: Make inline assembly depend on CONFIG_ARM
Functions with inline assembly depend on CONFIG_ARM.

Stub out any functions with inline assembly if CONFIG_ARM is not defined.

Change-Id: I8b310a5f787f74bf1ef4653f138bfbd957e7d4a7
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
2014-02-05 09:33:59 -08:00
Matt Wagantall 84d5e35683 msm: remote_spinlock: Add support for remote_spin_lock_rlock_id()
remote_spin_lock_rlock_id() and remote_spin_unlock_rlock() are
added to acquire/release a raw remote lock (without a local
spinlock). This is useful when ownership of a lock must transfer
between different execution environments, such as when a lock is
used to guarantee atomicity of a set of actions spread across
different execution environments.

Specifically, these APIs are added to support a new lock which
must be acquired in Linux but released by TrustZone software.

Because no local spinlock is acquired, each thread must use a
different ID so that only one thread can proceed through the
lock at a time.

Support for these new APIs is presently implemented only for
SFPB locks.

Change-Id: Ifc5b1f552090051d2e975107e56e21e22df08924
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
2014-01-31 11:49:23 -08:00
Kumar Gala c8009f97ba msm: soc: Rename soc/msm to soc/qcom
We are using 'qcom' now for DT, file and directory names so rename
drivers/soc/msm to drivers/soc/qcom and fixup related header files
and path issues.

Change-Id: Ibd32a507afaec1920b0289df107231eb7d6ef5e1
Signed-off-by: Kumar Gala <galak@codeaurora.org>
2013-12-30 10:46:35 -06:00
Jeff Hugo fe28fe039b msm: smem: Support multiplatform
Upstream prefers existing drivers be converted to support multiplatform
kernels.  This requires drivers to be located in generic functionality
directories instead of specific mach directories.

Move the smem driver to the drivers/soc/msm location to support
multiplatform.

Change-Id: I9ba6eedce5237be6b96850e772232182a1a084ae
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
2013-12-18 10:08:39 -07:00
Arun Kumar Neelakantam fa27da83f1 hwspinlock/msm: Remove dead code
Remove the remote mutex framework as it is unused on
supported targets.

Change-Id: Ia1e2b0c82c9af514cf9366c447214ec08a845dc0
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
2013-12-09 11:12:12 +05:30
Jeff Hugo aca2f1a277 msm: remote_spinlock: Support multiplatform
Upstream prefers existing drivers be converted to support multiplatform
kernels.  This requires drivers to be located in generic functionality
directories instead of specific mach directories.

Move the remote-spinlock driver to the drivers/hwspinlock location to
support multiplatform.

Change-Id: Ibbc6046ab177b62a5a79cba7f5752685470c4ebb
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
2013-12-03 12:00:47 -07:00
Linus Torvalds c807b17375 A single patch from Vincent extending OMAP's hwspinlock support to OMAP5.
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJRiONpAAoJELLolMlTRIoMChkP/RW1KNCJkM3iTFhgeSDkdFOn
 4QXUCDlVUg8OqiUgCsdgW/CdwID8cRMBZ9Lif/RiNQlgG9I0RqiHPcrGsYaimOX0
 16h6Fuoldolem2p7G5++zdwKsLRe4Yl06sXBsIHrUZMwj+TmpWzzZyIEKLg+qQAF
 T2ku2nHJWtoPQGNrTYq8VUWz1tKv26w6jAJDZshzsbTinaMl20gUOynz1dsPjeIP
 RH5ycmA9NVaNq89PIodbawG6o2ztMMa6QcokqmOF0p/TQC9ByHoFMoV/mPjPuvcm
 2jpgPr2wjI7Ya7yoUpGVIL76OUadAZKzAojyOA3VWXYKyrTE7i/1tlOwuSU8x2Ky
 mrlXfhJlFbVChO1jYV8QTnrdQlCnIFwlHsVF/XXw1NGpJoI3bYVgmpg9tmQ3vVo5
 gjFukfGG34mVGiVfHFJIgh0ZCcVbyAeqlEN+/C5Zh2F5Kv/XYXUthJgy1LLFpYp7
 rNLCX2AARp+aNAkZ2Gvumd0hUfI2BBxiPmMnEL8yitq759slYsbrSagTVD19LUKL
 RwuRZ3gJV4oNnkttmnshrg7FK7o0WJ46UZ1T6RrVtrBbVti21N6uMcY43pu5FHyG
 1PjYl0/IbUjL80K6yxpSWYlbhzlhCMkm7eRz//Sss3x5chqaRwwrmSN3h3rgv+4p
 UkOjjySS1tfVV7F8O95i
 =vZ99
 -----END PGP SIGNATURE-----

Merge tag 'hwspinlock-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/hwspinlock

Pullhwspinlock update from Ohad Ben-Cohen:
 "A single patch from Vincent extending OMAP's hwspinlock support to
  OMAP5"

* tag 'hwspinlock-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/hwspinlock:
  hwspinlock/omap: support OMAP5 as well
2013-05-07 14:01:27 -07:00
Li Fei c10b90d85a hwspinlock: fix __hwspin_lock_request error path
Even in failed case of pm_runtime_get_sync, the usage_count
is incremented. In order to keep the usage_count with correct
value and runtime power management to behave correctly, call
pm_runtime_put_noidle in such case.

In __hwspin_lock_request, module_put is also called before
return in pm_runtime_get_sync failed case.

Cc: stable@vger.kernel.org
Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
Signed-off-by: Li Fei <fei.li@intel.com>
[edit commit log]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2013-04-05 17:45:11 +03:00
Vincent Stehlé 8ae053d62e hwspinlock/omap: support OMAP5 as well
OMAP5 has spinlocks, too.

Signed-off-by: Vincent Stehlé <v-stehle@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2013-04-05 09:11:17 +03:00
Bill Pemberton e533a349c0 hwspinlock: remove use of __devexit
CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28 11:41:36 -08:00
Bill Pemberton 571291066d hwspinlock: remove use of __devinit
CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28 11:41:36 -08:00
Bill Pemberton 9eb26bddfc hwspinlock: remove use of __devexit_p
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28 11:41:36 -08:00
Wei Yongjun e352614cd3 hwspinlock/core: move the dereference below the NULL test
The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2012-09-10 13:19:25 +03:00
Shinya Kuribayashi 476a7eeb60 hwspinlock/core: use global ID to register hwspinlocks on multiple devices
Commit 300bab9770 (hwspinlock/core: register a bank of hwspinlocks in a
single API call, 2011-09-06) introduced 'hwspin_lock_register_single()'
to register numerous (a bank of) hwspinlock instances in a single API,
'hwspin_lock_register()'.

At which time, 'hwspin_lock_register()' accidentally passes 'local IDs'
to 'hwspin_lock_register_single()', despite that ..._single() requires
'global IDs' to register hwspinlocks.

We have to convert into global IDs by supplying the missing 'base_id'.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
[ohad: fix error path of hwspin_lock_register, too]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2012-07-07 22:35:30 +03:00
Linus Torvalds 19e0bafc36 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
  drivers/media: video/a5k6aa is a module and so needs module.h
  mfd: fix build failures in recently added ab5500 code
  hwspinlock/u8500: include linux/module.h
  MTD: MAPS: bcm963xx-flash.c: explicitly include module.h
2011-11-08 18:34:16 -08:00
Axel Lin fdcb23634c hwspinlock/u8500: fix build error due to undefined label
Fix below build error:

  CC      drivers/hwspinlock/u8500_hsem.o
drivers/hwspinlock/u8500_hsem.c: In function 'u8500_hsem_probe':
drivers/hwspinlock/u8500_hsem.c:113: error: label 'free_state' used but not defined

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-11-08 09:28:41 +02:00
Axel Lin 8f7346bdea hwspinlock/u8500: include linux/module.h
Include module.h to fix below build error:

  CC      drivers/hwspinlock/u8500_hsem.o
drivers/hwspinlock/u8500_hsem.c:177: error: 'THIS_MODULE' undeclared here (not in a function)
 [...]
drivers/hwspinlock/u8500_hsem.c:196: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR'
drivers/hwspinlock/u8500_hsem.c:196: warning: function declaration isn't a prototype
make[2]: *** [drivers/hwspinlock/u8500_hsem.o] Error 1
make[1]: *** [drivers/hwspinlock] Error 2
make: *** [drivers] Error 2

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-11-07 21:45:14 -05:00
Ohad Ben-Cohen 9efb4a1bb9 hwspinlock/omap: omap_hwspinlock_remove should be __devexit
Mark omap_hwspinlock_remove with __devexit (and use __devexit_p
appropriately) so the function can be discarded when the conditions are met.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:57:45 +03:00
Mathieu J. Poirier f84a8ecfca hwspinlock/u8500: add hwspinlock driver
Add hwspinlock driver for U8500's Hsem hardware.

At this point only HSem's protocol 1 is used (i.e. no interrupts).

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
[ohad@wizery.com: adopt recent hwspin_lock_{un}register API changes]
[ohad@wizery.com: set the owner member of the driver]
[ohad@wizery.com: mark ->remove() function as __devexit]
[ohad@wizery.com: write commit log]
[ohad@wizery.com: small cleanups]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:57:45 +03:00
Ohad Ben-Cohen 300bab9770 hwspinlock/core: register a bank of hwspinlocks in a single API call
Hardware Spinlock devices usually contain numerous locks (known
devices today support between 32 to 256 locks).

Originally hwspinlock core required drivers to register (and later,
when needed, unregister) each lock separately.

That worked, but required hwspinlocks drivers to do a bit extra work
when they were probed/removed.

This patch changes hwspin_lock_{un}register() to allow a bank of
hwspinlocks to be {un}registered in a single invocation.

A new 'struct hwspinlock_device', which contains an array of 'struct
hwspinlock's is now being passed to the core upon registration (so
instead of wrapping each struct hwspinlock, a priv member has been added
to allow drivers to piggyback their private data with each hwspinlock).

While at it, several per-lock members were moved to be per-device:
1. struct device *dev
2. struct hwspinlock_ops *ops

In addition, now that the array of locks is handled by the core,
there's no reason to maintain a per-lock 'int id' member: the id of the
lock anyway equals to its index in the bank's array plus the bank's
base_id.
Remove this per-lock id member too, and instead use a simple pointers
arithmetic to derive it.

As a result of this change, hwspinlocks drivers are now simpler and smaller
(about %20 code reduction) and the memory footprint of the hwspinlock
framework is reduced.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:45:34 +03:00
Juan Gutierrez 93b465c2e1 hwspinlock/core: use a mutex to protect the radix tree
Since we're using non-atomic radix tree allocations, we
should be protecting the tree using a mutex and not a
spinlock.

Non-atomic allocations and process context locking is good enough,
as the tree is manipulated only when locks are registered/
unregistered/requested/freed.

The locks themselves are still protected by spinlocks of course,
and mutexes are not involved in the locking/unlocking paths.

Cc: <stable@kernel.org>
Signed-off-by: Juan Gutierrez <jgutierrez@ti.com>
[ohad@wizery.com: rewrite the commit log, #include mutex.h, add minor
commentary]
[ohad@wizery.com: update register/unregister parts in hwspinlock.txt]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:45:32 +03:00
Ohad Ben-Cohen c3c1250e93 hwspinlock/core/omap: fix id issues on multiple hwspinlock devices
hwspinlock devices provide system-wide hardware locks that are used
by remote processors that have no other way to achieve synchronization.

To achieve that, each physical lock must have a system-wide id number
that is agreed upon, otherwise remote processors can't possibly assume
they're using the same hardware lock.

Usually boards have a single hwspinlock device, which provides several
hwspinlocks, and in this case, they can be trivially numbered 0 to
(num-of-locks - 1).

In case boards have several hwspinlocks devices, a different base id
should be used for each hwspinlock device (they can't all use 0 as
a starting id!).

While this is certainly not common, it's just plain wrong to just
silently use 0 as a base id whenever the hwspinlock driver is probed.

This patch provides a hwspinlock_pdata structure, that boards can use
to set a different base id for each of the hwspinlock devices they may
have, and demonstrates how to use it with the omap hwspinlock driver.

While we're at it, make sure the hwspinlock core prints an explicit
error message in case an hwspinlock is registered with an id number
that already exists; this will help users catch such base id issues.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Tony Lindgren <tony@atomide.com>
2011-09-21 19:45:32 +03:00
Ohad Ben-Cohen c97f6dd0fe hwspinlock/omap: simplify allocation scheme
Instead of allocating every hwspinlock separately, allocate
them all in one shot.

This both simplifies the driver and helps achieving better
slab utilization.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:45:32 +03:00
Ohad Ben-Cohen e467b64214 hwspinlock/core: simplify 'owner' handling
Use struct device_driver's owner member instead of asking drivers to
explicitly pass the owner again.

This simplifies drivers and also save some memory, since there's no
point now in maintaining a separate owner pointer per hwspinlock.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:45:32 +03:00
Ohad Ben-Cohen 315d8f5ccd hwspinlock/core: simplify Kconfig
Simplify hwspinlock's Kconfig by making the global CONFIG_HWSPINLOCK
entry invisible; users will just select it when needed.

This also prepares the ground for adding hwspinlock support for other
platforms (the 'depends on ARCH_OMAP4' was rather hideous, and while
we're at it, a dedicated menu is added).

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
2011-09-21 19:45:32 +03:00
Ohad Ben-Cohen 4fa8eebb04 hwspinlock: depend on OMAP4
Currently only OMAP4 supports hwspinlocks, so don't bother asking
anyone else.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2011-03-18 17:15:11 -07:00
Simon Que 70ba4cc26b drivers: hwspinlock: add OMAP implementation
Add hwspinlock support for the OMAP4 Hardware Spinlock device.

The Hardware Spinlock device on OMAP4 provides hardware assistance
for synchronization between the multiple processors in the system
(dual Cortex-A9, dual Cortex-M3 and a C64x+ DSP).

[ohad@wizery.com: adapt to hwspinlock framework, tidy up]
Signed-off-by: Simon Que <sque@ti.com>
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
Signed-off-by: Krishnamoorthy, Balaji T <balajitk@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2011-02-17 09:52:03 -08:00
Ohad Ben-Cohen bd9a4c7df2 drivers: hwspinlock: add framework
Add a platform-independent hwspinlock framework.

Hardware spinlock devices are needed, e.g., in order to access data
that is shared between remote processors, that otherwise have no
alternative mechanism to accomplish synchronization and mutual exclusion
operations.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Hari Kanigeri <h-kanigeri2@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2011-02-17 09:52:03 -08:00