Pull hwspinlock updates from Bjorn Andersson: "This contains support for hardware spinlock TI K3 AM65x and J721E family of SoCs, support for using hwspinlocks from atomic context and better error reporting when dealing with hardware disabled in DeviceTree" * tag 'hwlock-v5.3' of git://github.com/andersson/remoteproc: hwspinlock: add the 'in_atomic' API hwspinlock: document the hwspinlock 'raw' API hwspinlock: stm32: implement the relax() ops hwspinlock: ignore disabled device hwspinlock/omap: Add a trace during probe hwspinlock/omap: Add support for TI K3 SoCs dt-bindings: hwlock: Update OMAP binding for TI K3 SoCs
Showing the changes to include/linux (1 of 7 files). Show all
Unified · Split
| @@ -14,9 +14,10 @@ · 13 unmodified lines | |||
| 14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
| 15 | 15 | ||
| 16 | /* hwspinlock mode argument */ | 16 | /* hwspinlock mode argument */ |
| 17 | #define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */ | 17 | #define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */ |
| 18 | #define HWLOCK_IRQ 0x02 /* Disable interrupts, don't save state */ | 18 | #define HWLOCK_IRQ 0x02 /* Disable interrupts, don't save state */ |
| 19 | #define HWLOCK_RAW 0x03 | 19 | #define HWLOCK_RAW 0x03 |
| 20 | #define HWLOCK_IN_ATOMIC 0x04 /* Called while in atomic context */ | ||
| 20 | 21 | ||
| 21 | struct device; | 22 | struct device; |
| 22 | struct device_node; | 23 | struct device_node; |
| @@ -222,6 +223,23 @@ static inline int hwspin_trylock_raw(struct hwspinlock *hwlock) · 199 unmodified lines | |||
| 222 | return __hwspin_trylock(hwlock, HWLOCK_RAW, NULL); | 223 | return __hwspin_trylock(hwlock, HWLOCK_RAW, NULL); |
| 223 | } | 224 | } |
| 224 | 225 | ||
| 226 | /** | ||
| 227 | * hwspin_trylock_in_atomic() - attempt to lock a specific hwspinlock | ||
| 228 | * @hwlock: an hwspinlock which we want to trylock | ||
| 229 | * | ||
| 230 | * This function attempts to lock an hwspinlock, and will immediately fail | ||
| 231 | * if the hwspinlock is already taken. | ||
| 232 | * | ||
| 233 | * This function shall be called only from an atomic context. | ||
| 234 | * | ||
| 235 | * Returns 0 if we successfully locked the hwspinlock, -EBUSY if | ||
| 236 | * the hwspinlock was already taken, and -EINVAL if @hwlock is invalid. | ||
| 237 | */ | ||
| 238 | static inline int hwspin_trylock_in_atomic(struct hwspinlock *hwlock) | ||
| 239 | { | ||
| 240 | return __hwspin_trylock(hwlock, HWLOCK_IN_ATOMIC, NULL); | ||
| 241 | } | ||
| 242 | |||
| 225 | /** | 243 | /** |
| 226 | * hwspin_trylock() - attempt to lock a specific hwspinlock | 244 | * hwspin_trylock() - attempt to lock a specific hwspinlock |
| 227 | * @hwlock: an hwspinlock which we want to trylock | 245 | * @hwlock: an hwspinlock which we want to trylock |
| @@ -312,6 +330,28 @@ int hwspin_lock_timeout_raw(struct hwspinlock *hwlock, unsigned int to) · 84 unmodified lines | |||
| 312 | return __hwspin_lock_timeout(hwlock, to, HWLOCK_RAW, NULL); | 330 | return __hwspin_lock_timeout(hwlock, to, HWLOCK_RAW, NULL); |
| 313 | } | 331 | } |
| 314 | 332 | ||
| 333 | /** | ||
| 334 | * hwspin_lock_timeout_in_atomic() - lock an hwspinlock with timeout limit | ||
| 335 | * @hwlock: the hwspinlock to be locked | ||
| 336 | * @to: timeout value in msecs | ||
| 337 | * | ||
| 338 | * This function locks the underlying @hwlock. If the @hwlock | ||
| 339 | * is already taken, the function will busy loop waiting for it to | ||
| 340 | * be released, but give up when @timeout msecs have elapsed. | ||
| 341 | * | ||
| 342 | * This function shall be called only from an atomic context and the timeout | ||
| 343 | * value shall not exceed a few msecs. | ||
| 344 | * | ||
| 345 | * Returns 0 when the @hwlock was successfully taken, and an appropriate | ||
| 346 | * error code otherwise (most notably an -ETIMEDOUT if the @hwlock is still | ||
| 347 | * busy after @timeout msecs). The function will never sleep. | ||
| 348 | */ | ||
| 349 | static inline | ||
| 350 | int hwspin_lock_timeout_in_atomic(struct hwspinlock *hwlock, unsigned int to) | ||
| 351 | { | ||
| 352 | return __hwspin_lock_timeout(hwlock, to, HWLOCK_IN_ATOMIC, NULL); | ||
| 353 | } | ||
| 354 | |||
| 315 | /** | 355 | /** |
| 316 | * hwspin_lock_timeout() - lock an hwspinlock with timeout limit | 356 | * hwspin_lock_timeout() - lock an hwspinlock with timeout limit |
| 317 | * @hwlock: the hwspinlock to be locked | 357 | * @hwlock: the hwspinlock to be locked |
| @@ -386,6 +426,21 @@ static inline void hwspin_unlock_raw(struct hwspinlock *hwlock) · 68 unmodified lines | |||
| 386 | __hwspin_unlock(hwlock, HWLOCK_RAW, NULL); | 426 | __hwspin_unlock(hwlock, HWLOCK_RAW, NULL); |
| 387 | } | 427 | } |
| 388 | 428 | ||
| 429 | /** | ||
| 430 | * hwspin_unlock_in_atomic() - unlock hwspinlock | ||
| 431 | * @hwlock: a previously-acquired hwspinlock which we want to unlock | ||
| 432 | * | ||
| 433 | * This function will unlock a specific hwspinlock. | ||
| 434 | * | ||
| 435 | * @hwlock must be already locked (e.g. by hwspin_trylock()) before calling | ||
| 436 | * this function: it is a bug to call unlock on a @hwlock that is already | ||
| 437 | * unlocked. | ||
| 438 | */ | ||
| 439 | static inline void hwspin_unlock_in_atomic(struct hwspinlock *hwlock) | ||
| 440 | { | ||
| 441 | __hwspin_unlock(hwlock, HWLOCK_IN_ATOMIC, NULL); | ||
| 442 | } | ||
| 443 | |||
| 389 | /** | 444 | /** |
| 390 | * hwspin_unlock() - unlock hwspinlock | 445 | * hwspin_unlock() - unlock hwspinlock |
| 391 | * @hwlock: a previously-acquired hwspinlock which we want to unlock | 446 | * @hwlock: a previously-acquired hwspinlock which we want to unlock |