| 1 |
/* Program Priority Register Facility API. API implementation. |
| 2 |
* |
| 3 |
* Copyright IBM Corp. 2015 |
| 4 |
* |
| 5 |
* The MIT License (MIT) |
| 6 |
* |
| 7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 |
* of this software and associated documentation files (the "Software"), to deal |
| 9 |
* in the Software without restriction, including without limitation the rights |
| 10 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 |
* copies of the Software, and to permit persons to whom the Software is |
| 12 |
* furnished to do so, subject to the following conditions: |
| 13 |
* |
| 14 |
* The above copyright notice and this permission notice shall be included in |
| 15 |
* all copies or substantial portions of the Software. |
| 16 |
* |
| 17 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 |
* THE SOFTWARE. |
| 24 |
* |
| 25 |
* Contributors: |
| 26 |
* IBM Corporation, Adhemerval Zanella - Initial implementation. |
| 27 |
* IBM Corporation, Rajalakshmi S - Initial implementation. |
| 28 |
*/ |
| 29 |
#ifndef _PAF_PPR_H |
| 30 |
#define _PAF_PPR_H |
| 31 |
|
| 32 |
|
| 33 |
/* ISA 2.05 and beyond support the Program Priority Register (PPR) to adjust |
| 34 |
thread priorities based on lock acquisition, wait and release. The ISA |
| 35 |
defines the use of form 'or Rx,Rx,Rx' as the way to modify the PRI field. |
| 36 |
The unprivileged priorities are: |
| 37 |
Rx = 1 (low) |
| 38 |
Rx = 2 (medium) |
| 39 |
Rx = 6 (medium-low/normal) |
| 40 |
The 'or' instruction form is a nop in previous hardware, so it is safe to |
| 41 |
use unguarded. The default value is 'medium'. |
| 42 |
From ISA 2.07: |
| 43 |
Rx = 5 (medium high) |
| 44 |
Rx = 31 (very low) |
| 45 |
*/ |
| 46 |
#ifdef _ARCH_PWR8 |
| 47 |
static inline void |
| 48 |
paf_ppr_very_low (void) |
| 49 |
{ |
| 50 |
__asm__ volatile ("or 31,31,31"); |
| 51 |
} |
| 52 |
#endif |
| 53 |
|
| 54 |
static inline void |
| 55 |
paf_ppr_low (void) |
| 56 |
{ |
| 57 |
__asm__ volatile ("or 1,1,1"); |
| 58 |
} |
| 59 |
|
| 60 |
static inline void |
| 61 |
paf_ppr_med_low (void) |
| 62 |
{ |
| 63 |
__asm__ volatile ("or 6,6,6"); |
| 64 |
} |
| 65 |
|
| 66 |
static inline void |
| 67 |
paf_ppr_med (void) |
| 68 |
{ |
| 69 |
__asm__ volatile ("or 2,2,2"); |
| 70 |
} |
| 71 |
|
| 72 |
#ifdef _ARCH_PWR8 |
| 73 |
static inline void |
| 74 |
paf_ppr_med_high (void) |
| 75 |
{ |
| 76 |
__asm__ volatile ("or 5,5,5"); |
| 77 |
} |
| 78 |
#endif |
| 79 |
|
| 80 |
/* The following functions provide hints about the usage of shared processor |
| 81 |
resources, as defined in ISA 2.06 and newer. */ |
| 82 |
|
| 83 |
/* Provides a hint that performance will probably be improved if shared |
| 84 |
resources dedicated to the executing processor are released for use by other |
| 85 |
processors. */ |
| 86 |
static inline void |
| 87 |
paf_yield (void) |
| 88 |
{ |
| 89 |
__asm__ volatile ("or 27,27,27"); |
| 90 |
} |
| 91 |
|
| 92 |
/* Provides a hint that performance will probably be improved if shared |
| 93 |
resources dedicated to the executing processor are released until |
| 94 |
all outstanding storage accesses to caching-inhibited storage have been |
| 95 |
completed. */ |
| 96 |
static inline void |
| 97 |
paf_mdoio (void) |
| 98 |
{ |
| 99 |
__asm__ volatile ("or 29,29,29"); |
| 100 |
} |
| 101 |
|
| 102 |
/* Provides a hint that performance will probably be improved if shared |
| 103 |
resources dedicated to the executing processor are released until all |
| 104 |
outstanding storage accesses to cacheable storage for which the data is not |
| 105 |
in the cache have been completed. */ |
| 106 |
static inline void |
| 107 |
paf_mdoom (void) |
| 108 |
{ |
| 109 |
__asm__ volatile ("or 30,30,30"); |
| 110 |
} |
| 111 |
|
| 112 |
#endif |