mpam_internal.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. // Copyright (C) 2025 Arm Ltd.
  3. #ifndef MPAM_INTERNAL_H
  4. #define MPAM_INTERNAL_H
  5. #include <linux/arm_mpam.h>
  6. #include <linux/atomic.h>
  7. #include <linux/bitmap.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/io.h>
  10. #include <linux/jump_label.h>
  11. #include <linux/llist.h>
  12. #include <linux/mutex.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/srcu.h>
  15. #include <linux/types.h>
  16. #define MPAM_MSC_MAX_NUM_RIS 16
  17. struct platform_device;
  18. DECLARE_STATIC_KEY_FALSE(mpam_enabled);
  19. #ifdef CONFIG_MPAM_KUNIT_TEST
  20. #define PACKED_FOR_KUNIT __packed
  21. #else
  22. #define PACKED_FOR_KUNIT
  23. #endif
  24. static inline bool mpam_is_enabled(void)
  25. {
  26. return static_branch_likely(&mpam_enabled);
  27. }
  28. /*
  29. * Structures protected by SRCU may not be freed for a surprising amount of
  30. * time (especially if perf is running). To ensure the MPAM error interrupt can
  31. * tear down all the structures, build a list of objects that can be garbage
  32. * collected once synchronize_srcu() has returned.
  33. * If pdev is non-NULL, use devm_kfree().
  34. */
  35. struct mpam_garbage {
  36. /* member of mpam_garbage */
  37. struct llist_node llist;
  38. void *to_free;
  39. struct platform_device *pdev;
  40. };
  41. struct mpam_msc {
  42. /* member of mpam_all_msc */
  43. struct list_head all_msc_list;
  44. int id;
  45. struct platform_device *pdev;
  46. /* Not modified after mpam_is_enabled() becomes true */
  47. enum mpam_msc_iface iface;
  48. u32 nrdy_usec;
  49. cpumask_t accessibility;
  50. bool has_extd_esr;
  51. int reenable_error_ppi;
  52. struct mpam_msc * __percpu *error_dev_id;
  53. atomic_t online_refs;
  54. /*
  55. * probe_lock is only taken during discovery. After discovery these
  56. * properties become read-only and the lists are protected by SRCU.
  57. */
  58. struct mutex probe_lock;
  59. bool probed;
  60. u16 partid_max;
  61. u8 pmg_max;
  62. unsigned long ris_idxs;
  63. u32 ris_max;
  64. /*
  65. * error_irq_lock is taken when registering/unregistering the error
  66. * interrupt and maniupulating the below flags.
  67. */
  68. struct mutex error_irq_lock;
  69. bool error_irq_req;
  70. bool error_irq_hw_enabled;
  71. /* mpam_msc_ris of this component */
  72. struct list_head ris;
  73. /*
  74. * part_sel_lock protects access to the MSC hardware registers that are
  75. * affected by MPAMCFG_PART_SEL. (including the ID registers that vary
  76. * by RIS).
  77. * If needed, take msc->probe_lock first.
  78. */
  79. struct mutex part_sel_lock;
  80. /*
  81. * cfg_lock protects the msc configuration and guards against mbwu_state
  82. * save and restore racing.
  83. */
  84. struct mutex cfg_lock;
  85. /*
  86. * mon_sel_lock protects access to the MSC hardware registers that are
  87. * affected by MPAMCFG_MON_SEL, and the mbwu_state.
  88. * Access to mon_sel is needed from both process and interrupt contexts,
  89. * but is complicated by firmware-backed platforms that can't make any
  90. * access unless they can sleep.
  91. * Always use the mpam_mon_sel_lock() helpers.
  92. * Accesses to mon_sel need to be able to fail if they occur in the wrong
  93. * context.
  94. * If needed, take msc->probe_lock first.
  95. */
  96. raw_spinlock_t _mon_sel_lock;
  97. unsigned long _mon_sel_flags;
  98. void __iomem *mapped_hwpage;
  99. size_t mapped_hwpage_sz;
  100. struct mpam_garbage garbage;
  101. };
  102. /* Returning false here means accesses to mon_sel must fail and report an error. */
  103. static inline bool __must_check mpam_mon_sel_lock(struct mpam_msc *msc)
  104. {
  105. /* Locking will require updating to support a firmware backed interface */
  106. if (WARN_ON_ONCE(msc->iface != MPAM_IFACE_MMIO))
  107. return false;
  108. raw_spin_lock_irqsave(&msc->_mon_sel_lock, msc->_mon_sel_flags);
  109. return true;
  110. }
  111. static inline void mpam_mon_sel_unlock(struct mpam_msc *msc)
  112. {
  113. raw_spin_unlock_irqrestore(&msc->_mon_sel_lock, msc->_mon_sel_flags);
  114. }
  115. static inline void mpam_mon_sel_lock_held(struct mpam_msc *msc)
  116. {
  117. lockdep_assert_held_once(&msc->_mon_sel_lock);
  118. }
  119. static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
  120. {
  121. raw_spin_lock_init(&msc->_mon_sel_lock);
  122. }
  123. /* Bits for mpam features bitmaps */
  124. enum mpam_device_features {
  125. mpam_feat_cpor_part,
  126. mpam_feat_cmax_softlim,
  127. mpam_feat_cmax_cmax,
  128. mpam_feat_cmax_cmin,
  129. mpam_feat_cmax_cassoc,
  130. mpam_feat_mbw_part,
  131. mpam_feat_mbw_min,
  132. mpam_feat_mbw_max,
  133. mpam_feat_mbw_prop,
  134. mpam_feat_intpri_part,
  135. mpam_feat_intpri_part_0_low,
  136. mpam_feat_dspri_part,
  137. mpam_feat_dspri_part_0_low,
  138. mpam_feat_msmon,
  139. mpam_feat_msmon_csu,
  140. mpam_feat_msmon_csu_capture,
  141. mpam_feat_msmon_csu_xcl,
  142. mpam_feat_msmon_csu_hw_nrdy,
  143. mpam_feat_msmon_mbwu,
  144. mpam_feat_msmon_mbwu_31counter,
  145. mpam_feat_msmon_mbwu_44counter,
  146. mpam_feat_msmon_mbwu_63counter,
  147. mpam_feat_msmon_mbwu_capture,
  148. mpam_feat_msmon_mbwu_rwbw,
  149. mpam_feat_msmon_mbwu_hw_nrdy,
  150. mpam_feat_partid_nrw,
  151. MPAM_FEATURE_LAST
  152. };
  153. struct mpam_props {
  154. DECLARE_BITMAP(features, MPAM_FEATURE_LAST);
  155. u16 cpbm_wd;
  156. u16 mbw_pbm_bits;
  157. u16 bwa_wd;
  158. u16 cmax_wd;
  159. u16 cassoc_wd;
  160. u16 intpri_wd;
  161. u16 dspri_wd;
  162. u16 num_csu_mon;
  163. u16 num_mbwu_mon;
  164. /*
  165. * Kunit tests use memset() to set up feature combinations that should be
  166. * removed, and will false-positive if the compiler introduces padding that
  167. * isn't cleared during sanitisation.
  168. */
  169. } PACKED_FOR_KUNIT;
  170. #define mpam_has_feature(_feat, x) test_bit(_feat, (x)->features)
  171. /*
  172. * The non-atomic get/set operations are used because if struct mpam_props is
  173. * packed, the alignment requirements for atomics aren't met.
  174. */
  175. #define mpam_set_feature(_feat, x) __set_bit(_feat, (x)->features)
  176. #define mpam_clear_feature(_feat, x) __clear_bit(_feat, (x)->features)
  177. /* The values for MSMON_CFG_MBWU_FLT.RWBW */
  178. enum mon_filter_options {
  179. COUNT_BOTH = 0,
  180. COUNT_WRITE = 1,
  181. COUNT_READ = 2,
  182. };
  183. struct mon_cfg {
  184. u16 mon;
  185. u8 pmg;
  186. bool match_pmg;
  187. bool csu_exclude_clean;
  188. u32 partid;
  189. enum mon_filter_options opts;
  190. };
  191. /* Changes to msmon_mbwu_state are protected by the msc's mon_sel_lock. */
  192. struct msmon_mbwu_state {
  193. bool enabled;
  194. bool reset_on_next_read;
  195. struct mon_cfg cfg;
  196. /*
  197. * The value to add to the new reading to account for power management,
  198. * and overflow.
  199. */
  200. u64 correction;
  201. struct mpam_garbage garbage;
  202. };
  203. struct mpam_class {
  204. /* mpam_components in this class */
  205. struct list_head components;
  206. cpumask_t affinity;
  207. struct mpam_props props;
  208. u32 nrdy_usec;
  209. u8 level;
  210. enum mpam_class_types type;
  211. /* member of mpam_classes */
  212. struct list_head classes_list;
  213. struct ida ida_csu_mon;
  214. struct ida ida_mbwu_mon;
  215. struct mpam_garbage garbage;
  216. };
  217. struct mpam_config {
  218. /* Which configuration values are valid. */
  219. DECLARE_BITMAP(features, MPAM_FEATURE_LAST);
  220. u32 cpbm;
  221. u32 mbw_pbm;
  222. u16 mbw_max;
  223. bool reset_cpbm;
  224. bool reset_mbw_pbm;
  225. bool reset_mbw_max;
  226. struct mpam_garbage garbage;
  227. };
  228. struct mpam_component {
  229. u32 comp_id;
  230. /* mpam_vmsc in this component */
  231. struct list_head vmsc;
  232. cpumask_t affinity;
  233. /*
  234. * Array of configuration values, indexed by partid.
  235. * Read from cpuhp callbacks, hold the cpuhp lock when writing.
  236. */
  237. struct mpam_config *cfg;
  238. /* member of mpam_class:components */
  239. struct list_head class_list;
  240. /* parent: */
  241. struct mpam_class *class;
  242. struct mpam_garbage garbage;
  243. };
  244. struct mpam_vmsc {
  245. /* member of mpam_component:vmsc_list */
  246. struct list_head comp_list;
  247. /* mpam_msc_ris in this vmsc */
  248. struct list_head ris;
  249. struct mpam_props props;
  250. /* All RIS in this vMSC are members of this MSC */
  251. struct mpam_msc *msc;
  252. /* parent: */
  253. struct mpam_component *comp;
  254. struct mpam_garbage garbage;
  255. };
  256. struct mpam_msc_ris {
  257. u8 ris_idx;
  258. u64 idr;
  259. struct mpam_props props;
  260. bool in_reset_state;
  261. cpumask_t affinity;
  262. /* member of mpam_vmsc:ris */
  263. struct list_head vmsc_list;
  264. /* member of mpam_msc:ris */
  265. struct list_head msc_list;
  266. /* parent: */
  267. struct mpam_vmsc *vmsc;
  268. /* msmon mbwu configuration is preserved over reset */
  269. struct msmon_mbwu_state *mbwu_state;
  270. struct mpam_garbage garbage;
  271. };
  272. static inline int mpam_alloc_csu_mon(struct mpam_class *class)
  273. {
  274. struct mpam_props *cprops = &class->props;
  275. if (!mpam_has_feature(mpam_feat_msmon_csu, cprops))
  276. return -EOPNOTSUPP;
  277. return ida_alloc_max(&class->ida_csu_mon, cprops->num_csu_mon - 1,
  278. GFP_KERNEL);
  279. }
  280. static inline void mpam_free_csu_mon(struct mpam_class *class, int csu_mon)
  281. {
  282. ida_free(&class->ida_csu_mon, csu_mon);
  283. }
  284. static inline int mpam_alloc_mbwu_mon(struct mpam_class *class)
  285. {
  286. struct mpam_props *cprops = &class->props;
  287. if (!mpam_has_feature(mpam_feat_msmon_mbwu, cprops))
  288. return -EOPNOTSUPP;
  289. return ida_alloc_max(&class->ida_mbwu_mon, cprops->num_mbwu_mon - 1,
  290. GFP_KERNEL);
  291. }
  292. static inline void mpam_free_mbwu_mon(struct mpam_class *class, int mbwu_mon)
  293. {
  294. ida_free(&class->ida_mbwu_mon, mbwu_mon);
  295. }
  296. /* List of all classes - protected by srcu*/
  297. extern struct srcu_struct mpam_srcu;
  298. extern struct list_head mpam_classes;
  299. /* System wide partid/pmg values */
  300. extern u16 mpam_partid_max;
  301. extern u8 mpam_pmg_max;
  302. /* Scheduled work callback to enable mpam once all MSC have been probed */
  303. void mpam_enable(struct work_struct *work);
  304. void mpam_disable(struct work_struct *work);
  305. int mpam_apply_config(struct mpam_component *comp, u16 partid,
  306. struct mpam_config *cfg);
  307. int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx,
  308. enum mpam_device_features, u64 *val);
  309. void mpam_msmon_reset_mbwu(struct mpam_component *comp, struct mon_cfg *ctx);
  310. int mpam_get_cpumask_from_cache_id(unsigned long cache_id, u32 cache_level,
  311. cpumask_t *affinity);
  312. /*
  313. * MPAM MSCs have the following register layout. See:
  314. * Arm Memory System Resource Partitioning and Monitoring (MPAM) System
  315. * Component Specification.
  316. * https://developer.arm.com/documentation/ihi0099/aa/
  317. */
  318. #define MPAM_ARCHITECTURE_V1 0x10
  319. /* Memory mapped control pages */
  320. /* ID Register offsets in the memory mapped page */
  321. #define MPAMF_IDR 0x0000 /* features id register */
  322. #define MPAMF_IIDR 0x0018 /* implementer id register */
  323. #define MPAMF_AIDR 0x0020 /* architectural id register */
  324. #define MPAMF_IMPL_IDR 0x0028 /* imp-def partitioning */
  325. #define MPAMF_CPOR_IDR 0x0030 /* cache-portion partitioning */
  326. #define MPAMF_CCAP_IDR 0x0038 /* cache-capacity partitioning */
  327. #define MPAMF_MBW_IDR 0x0040 /* mem-bw partitioning */
  328. #define MPAMF_PRI_IDR 0x0048 /* priority partitioning */
  329. #define MPAMF_MSMON_IDR 0x0080 /* performance monitoring features */
  330. #define MPAMF_CSUMON_IDR 0x0088 /* cache-usage monitor */
  331. #define MPAMF_MBWUMON_IDR 0x0090 /* mem-bw usage monitor */
  332. #define MPAMF_PARTID_NRW_IDR 0x0050 /* partid-narrowing */
  333. /* Configuration and Status Register offsets in the memory mapped page */
  334. #define MPAMCFG_PART_SEL 0x0100 /* partid to configure */
  335. #define MPAMCFG_CPBM 0x1000 /* cache-portion config */
  336. #define MPAMCFG_CMAX 0x0108 /* cache-capacity config */
  337. #define MPAMCFG_CMIN 0x0110 /* cache-capacity config */
  338. #define MPAMCFG_CASSOC 0x0118 /* cache-associativity config */
  339. #define MPAMCFG_MBW_MIN 0x0200 /* min mem-bw config */
  340. #define MPAMCFG_MBW_MAX 0x0208 /* max mem-bw config */
  341. #define MPAMCFG_MBW_WINWD 0x0220 /* mem-bw accounting window config */
  342. #define MPAMCFG_MBW_PBM 0x2000 /* mem-bw portion bitmap config */
  343. #define MPAMCFG_PRI 0x0400 /* priority partitioning config */
  344. #define MPAMCFG_MBW_PROP 0x0500 /* mem-bw stride config */
  345. #define MPAMCFG_INTPARTID 0x0600 /* partid-narrowing config */
  346. #define MSMON_CFG_MON_SEL 0x0800 /* monitor selector */
  347. #define MSMON_CFG_CSU_FLT 0x0810 /* cache-usage monitor filter */
  348. #define MSMON_CFG_CSU_CTL 0x0818 /* cache-usage monitor config */
  349. #define MSMON_CFG_MBWU_FLT 0x0820 /* mem-bw monitor filter */
  350. #define MSMON_CFG_MBWU_CTL 0x0828 /* mem-bw monitor config */
  351. #define MSMON_CSU 0x0840 /* current cache-usage */
  352. #define MSMON_CSU_CAPTURE 0x0848 /* last cache-usage value captured */
  353. #define MSMON_MBWU 0x0860 /* current mem-bw usage value */
  354. #define MSMON_MBWU_CAPTURE 0x0868 /* last mem-bw value captured */
  355. #define MSMON_MBWU_L 0x0880 /* current long mem-bw usage value */
  356. #define MSMON_MBWU_L_CAPTURE 0x0890 /* last long mem-bw value captured */
  357. #define MSMON_CAPT_EVNT 0x0808 /* signal a capture event */
  358. #define MPAMF_ESR 0x00F8 /* error status register */
  359. #define MPAMF_ECR 0x00F0 /* error control register */
  360. /* MPAMF_IDR - MPAM features ID register */
  361. #define MPAMF_IDR_PARTID_MAX GENMASK(15, 0)
  362. #define MPAMF_IDR_PMG_MAX GENMASK(23, 16)
  363. #define MPAMF_IDR_HAS_CCAP_PART BIT(24)
  364. #define MPAMF_IDR_HAS_CPOR_PART BIT(25)
  365. #define MPAMF_IDR_HAS_MBW_PART BIT(26)
  366. #define MPAMF_IDR_HAS_PRI_PART BIT(27)
  367. #define MPAMF_IDR_EXT BIT(28)
  368. #define MPAMF_IDR_HAS_IMPL_IDR BIT(29)
  369. #define MPAMF_IDR_HAS_MSMON BIT(30)
  370. #define MPAMF_IDR_HAS_PARTID_NRW BIT(31)
  371. #define MPAMF_IDR_HAS_RIS BIT(32)
  372. #define MPAMF_IDR_HAS_EXTD_ESR BIT(38)
  373. #define MPAMF_IDR_HAS_ESR BIT(39)
  374. #define MPAMF_IDR_RIS_MAX GENMASK(59, 56)
  375. /* MPAMF_MSMON_IDR - MPAM performance monitoring ID register */
  376. #define MPAMF_MSMON_IDR_MSMON_CSU BIT(16)
  377. #define MPAMF_MSMON_IDR_MSMON_MBWU BIT(17)
  378. #define MPAMF_MSMON_IDR_HAS_LOCAL_CAPT_EVNT BIT(31)
  379. /* MPAMF_CPOR_IDR - MPAM features cache portion partitioning ID register */
  380. #define MPAMF_CPOR_IDR_CPBM_WD GENMASK(15, 0)
  381. /* MPAMF_CCAP_IDR - MPAM features cache capacity partitioning ID register */
  382. #define MPAMF_CCAP_IDR_CMAX_WD GENMASK(5, 0)
  383. #define MPAMF_CCAP_IDR_CASSOC_WD GENMASK(12, 8)
  384. #define MPAMF_CCAP_IDR_HAS_CASSOC BIT(28)
  385. #define MPAMF_CCAP_IDR_HAS_CMIN BIT(29)
  386. #define MPAMF_CCAP_IDR_NO_CMAX BIT(30)
  387. #define MPAMF_CCAP_IDR_HAS_CMAX_SOFTLIM BIT(31)
  388. /* MPAMF_MBW_IDR - MPAM features memory bandwidth partitioning ID register */
  389. #define MPAMF_MBW_IDR_BWA_WD GENMASK(5, 0)
  390. #define MPAMF_MBW_IDR_HAS_MIN BIT(10)
  391. #define MPAMF_MBW_IDR_HAS_MAX BIT(11)
  392. #define MPAMF_MBW_IDR_HAS_PBM BIT(12)
  393. #define MPAMF_MBW_IDR_HAS_PROP BIT(13)
  394. #define MPAMF_MBW_IDR_WINDWR BIT(14)
  395. #define MPAMF_MBW_IDR_BWPBM_WD GENMASK(28, 16)
  396. /* MPAMF_PRI_IDR - MPAM features priority partitioning ID register */
  397. #define MPAMF_PRI_IDR_HAS_INTPRI BIT(0)
  398. #define MPAMF_PRI_IDR_INTPRI_0_IS_LOW BIT(1)
  399. #define MPAMF_PRI_IDR_INTPRI_WD GENMASK(9, 4)
  400. #define MPAMF_PRI_IDR_HAS_DSPRI BIT(16)
  401. #define MPAMF_PRI_IDR_DSPRI_0_IS_LOW BIT(17)
  402. #define MPAMF_PRI_IDR_DSPRI_WD GENMASK(25, 20)
  403. /* MPAMF_CSUMON_IDR - MPAM cache storage usage monitor ID register */
  404. #define MPAMF_CSUMON_IDR_NUM_MON GENMASK(15, 0)
  405. #define MPAMF_CSUMON_IDR_HAS_OFLOW_CAPT BIT(24)
  406. #define MPAMF_CSUMON_IDR_HAS_CEVNT_OFLW BIT(25)
  407. #define MPAMF_CSUMON_IDR_HAS_OFSR BIT(26)
  408. #define MPAMF_CSUMON_IDR_HAS_OFLOW_LNKG BIT(27)
  409. #define MPAMF_CSUMON_IDR_HAS_XCL BIT(29)
  410. #define MPAMF_CSUMON_IDR_CSU_RO BIT(30)
  411. #define MPAMF_CSUMON_IDR_HAS_CAPTURE BIT(31)
  412. /* MPAMF_MBWUMON_IDR - MPAM memory bandwidth usage monitor ID register */
  413. #define MPAMF_MBWUMON_IDR_NUM_MON GENMASK(15, 0)
  414. #define MPAMF_MBWUMON_IDR_HAS_RWBW BIT(28)
  415. #define MPAMF_MBWUMON_IDR_LWD BIT(29)
  416. #define MPAMF_MBWUMON_IDR_HAS_LONG BIT(30)
  417. #define MPAMF_MBWUMON_IDR_HAS_CAPTURE BIT(31)
  418. /* MPAMF_PARTID_NRW_IDR - MPAM PARTID narrowing ID register */
  419. #define MPAMF_PARTID_NRW_IDR_INTPARTID_MAX GENMASK(15, 0)
  420. /* MPAMF_IIDR - MPAM implementation ID register */
  421. #define MPAMF_IIDR_IMPLEMENTER GENMASK(11, 0)
  422. #define MPAMF_IIDR_REVISION GENMASK(15, 12)
  423. #define MPAMF_IIDR_VARIANT GENMASK(19, 16)
  424. #define MPAMF_IIDR_PRODUCTID GENMASK(31, 20)
  425. /* MPAMF_AIDR - MPAM architecture ID register */
  426. #define MPAMF_AIDR_ARCH_MINOR_REV GENMASK(3, 0)
  427. #define MPAMF_AIDR_ARCH_MAJOR_REV GENMASK(7, 4)
  428. /* MPAMCFG_PART_SEL - MPAM partition configuration selection register */
  429. #define MPAMCFG_PART_SEL_PARTID_SEL GENMASK(15, 0)
  430. #define MPAMCFG_PART_SEL_INTERNAL BIT(16)
  431. #define MPAMCFG_PART_SEL_RIS GENMASK(27, 24)
  432. /* MPAMCFG_CASSOC - MPAM cache maximum associativity partition configuration register */
  433. #define MPAMCFG_CASSOC_CASSOC GENMASK(15, 0)
  434. /* MPAMCFG_CMAX - MPAM cache capacity configuration register */
  435. #define MPAMCFG_CMAX_SOFTLIM BIT(31)
  436. #define MPAMCFG_CMAX_CMAX GENMASK(15, 0)
  437. /* MPAMCFG_CMIN - MPAM cache capacity configuration register */
  438. #define MPAMCFG_CMIN_CMIN GENMASK(15, 0)
  439. /*
  440. * MPAMCFG_MBW_MIN - MPAM memory minimum bandwidth partitioning configuration
  441. * register
  442. */
  443. #define MPAMCFG_MBW_MIN_MIN GENMASK(15, 0)
  444. /*
  445. * MPAMCFG_MBW_MAX - MPAM memory maximum bandwidth partitioning configuration
  446. * register
  447. */
  448. #define MPAMCFG_MBW_MAX_MAX GENMASK(15, 0)
  449. #define MPAMCFG_MBW_MAX_HARDLIM BIT(31)
  450. /*
  451. * MPAMCFG_MBW_WINWD - MPAM memory bandwidth partitioning window width
  452. * register
  453. */
  454. #define MPAMCFG_MBW_WINWD_US_FRAC GENMASK(7, 0)
  455. #define MPAMCFG_MBW_WINWD_US_INT GENMASK(23, 8)
  456. /* MPAMCFG_PRI - MPAM priority partitioning configuration register */
  457. #define MPAMCFG_PRI_INTPRI GENMASK(15, 0)
  458. #define MPAMCFG_PRI_DSPRI GENMASK(31, 16)
  459. /*
  460. * MPAMCFG_MBW_PROP - Memory bandwidth proportional stride partitioning
  461. * configuration register
  462. */
  463. #define MPAMCFG_MBW_PROP_STRIDEM1 GENMASK(15, 0)
  464. #define MPAMCFG_MBW_PROP_EN BIT(31)
  465. /*
  466. * MPAMCFG_INTPARTID - MPAM internal partition narrowing configuration register
  467. */
  468. #define MPAMCFG_INTPARTID_INTPARTID GENMASK(15, 0)
  469. #define MPAMCFG_INTPARTID_INTERNAL BIT(16)
  470. /* MSMON_CFG_MON_SEL - Memory system performance monitor selection register */
  471. #define MSMON_CFG_MON_SEL_MON_SEL GENMASK(15, 0)
  472. #define MSMON_CFG_MON_SEL_RIS GENMASK(27, 24)
  473. /* MPAMF_ESR - MPAM Error Status Register */
  474. #define MPAMF_ESR_PARTID_MON GENMASK(15, 0)
  475. #define MPAMF_ESR_PMG GENMASK(23, 16)
  476. #define MPAMF_ESR_ERRCODE GENMASK(27, 24)
  477. #define MPAMF_ESR_OVRWR BIT(31)
  478. #define MPAMF_ESR_RIS GENMASK(35, 32)
  479. /* MPAMF_ECR - MPAM Error Control Register */
  480. #define MPAMF_ECR_INTEN BIT(0)
  481. /* Error conditions in accessing memory mapped registers */
  482. #define MPAM_ERRCODE_NONE 0
  483. #define MPAM_ERRCODE_PARTID_SEL_RANGE 1
  484. #define MPAM_ERRCODE_REQ_PARTID_RANGE 2
  485. #define MPAM_ERRCODE_MSMONCFG_ID_RANGE 3
  486. #define MPAM_ERRCODE_REQ_PMG_RANGE 4
  487. #define MPAM_ERRCODE_MONITOR_RANGE 5
  488. #define MPAM_ERRCODE_INTPARTID_RANGE 6
  489. #define MPAM_ERRCODE_UNEXPECTED_INTERNAL 7
  490. #define MPAM_ERRCODE_UNDEFINED_RIS_PART_SEL 8
  491. #define MPAM_ERRCODE_RIS_NO_CONTROL 9
  492. #define MPAM_ERRCODE_UNDEFINED_RIS_MON_SEL 10
  493. #define MPAM_ERRCODE_RIS_NO_MONITOR 11
  494. /*
  495. * MSMON_CFG_CSU_CTL - Memory system performance monitor configure cache storage
  496. * usage monitor control register
  497. * MSMON_CFG_MBWU_CTL - Memory system performance monitor configure memory
  498. * bandwidth usage monitor control register
  499. */
  500. #define MSMON_CFG_x_CTL_TYPE GENMASK(7, 0)
  501. #define MSMON_CFG_MBWU_CTL_OFLOW_STATUS_L BIT(15)
  502. #define MSMON_CFG_x_CTL_MATCH_PARTID BIT(16)
  503. #define MSMON_CFG_x_CTL_MATCH_PMG BIT(17)
  504. #define MSMON_CFG_MBWU_CTL_SCLEN BIT(19)
  505. #define MSMON_CFG_x_CTL_SUBTYPE GENMASK(22, 20)
  506. #define MSMON_CFG_x_CTL_OFLOW_FRZ BIT(24)
  507. #define MSMON_CFG_x_CTL_OFLOW_INTR BIT(25)
  508. #define MSMON_CFG_x_CTL_OFLOW_STATUS BIT(26)
  509. #define MSMON_CFG_x_CTL_CAPT_RESET BIT(27)
  510. #define MSMON_CFG_x_CTL_CAPT_EVNT GENMASK(30, 28)
  511. #define MSMON_CFG_x_CTL_EN BIT(31)
  512. #define MSMON_CFG_MBWU_CTL_TYPE_MBWU 0x42
  513. #define MSMON_CFG_CSU_CTL_TYPE_CSU 0x43
  514. /*
  515. * MSMON_CFG_CSU_FLT - Memory system performance monitor configure cache storage
  516. * usage monitor filter register
  517. * MSMON_CFG_MBWU_FLT - Memory system performance monitor configure memory
  518. * bandwidth usage monitor filter register
  519. */
  520. #define MSMON_CFG_x_FLT_PARTID GENMASK(15, 0)
  521. #define MSMON_CFG_x_FLT_PMG GENMASK(23, 16)
  522. #define MSMON_CFG_MBWU_FLT_RWBW GENMASK(31, 30)
  523. #define MSMON_CFG_CSU_FLT_XCL BIT(31)
  524. /*
  525. * MSMON_CSU - Memory system performance monitor cache storage usage monitor
  526. * register
  527. * MSMON_CSU_CAPTURE - Memory system performance monitor cache storage usage
  528. * capture register
  529. * MSMON_MBWU - Memory system performance monitor memory bandwidth usage
  530. * monitor register
  531. * MSMON_MBWU_CAPTURE - Memory system performance monitor memory bandwidth usage
  532. * capture register
  533. */
  534. #define MSMON___VALUE GENMASK(30, 0)
  535. #define MSMON___NRDY BIT(31)
  536. #define MSMON___L_NRDY BIT(63)
  537. #define MSMON___L_VALUE GENMASK(43, 0)
  538. #define MSMON___LWD_VALUE GENMASK(62, 0)
  539. /*
  540. * MSMON_CAPT_EVNT - Memory system performance monitoring capture event
  541. * generation register
  542. */
  543. #define MSMON_CAPT_EVNT_NOW BIT(0)
  544. #endif /* MPAM_INTERNAL_H */