Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/platform/intel/quark: Drop IMR lock bit support

Isolated Memory Regions support a lock bit. The lock bit in an IMR prevents
modification of the IMR until the core goes through a warm or cold reset.
The lock bit feature is not useful in the context of the kernel API and is
not really necessary since modification of IMRs is possible only from
ring-zero anyway. This patch drops support for IMR locks bits, it
simplifies the kernel API and removes an unnecessary and needlessly complex
feature.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: andriy.shevchenko@linux.intel.com
Cc: boon.leong.ong@intel.com
Cc: paul.gortmaker@windriver.com
Link: http://lkml.kernel.org/r/1456190999-12685-3-git-send-email-pure.logic@nexus-software.ie
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Bryan O'Donoghue and committed by
Ingo Molnar
c637fa52 fb86780b

+14 -27
+1 -1
arch/x86/include/asm/imr.h
··· 53 53 #define IMR_MASK (IMR_ALIGN - 1) 54 54 55 55 int imr_add_range(phys_addr_t base, size_t size, 56 - unsigned int rmask, unsigned int wmask, bool lock); 56 + unsigned int rmask, unsigned int wmask); 57 57 58 58 int imr_remove_range(phys_addr_t base, size_t size); 59 59
+6 -18
arch/x86/platform/intel-quark/imr.c
··· 134 134 * @idev: pointer to imr_device structure. 135 135 * @imr_id: IMR entry to write. 136 136 * @imr: IMR structure representing address and access masks. 137 - * @lock: indicates if the IMR lock bit should be applied. 138 137 * @return: 0 on success or error code passed from mbi_iosf on failure. 139 138 */ 140 - static int imr_write(struct imr_device *idev, u32 imr_id, 141 - struct imr_regs *imr, bool lock) 139 + static int imr_write(struct imr_device *idev, u32 imr_id, struct imr_regs *imr) 142 140 { 143 141 unsigned long flags; 144 142 u32 reg = imr_id * IMR_NUM_REGS + idev->reg_base; ··· 159 161 ret = iosf_mbi_write(QRK_MBI_UNIT_MM, MBI_REG_WRITE, reg++, imr->wmask); 160 162 if (ret) 161 163 goto failed; 162 - 163 - /* Lock bit must be set separately to addr_lo address bits. */ 164 - if (lock) { 165 - imr->addr_lo |= IMR_LOCK; 166 - ret = iosf_mbi_write(QRK_MBI_UNIT_MM, MBI_REG_WRITE, 167 - reg - IMR_NUM_REGS, imr->addr_lo); 168 - if (ret) 169 - goto failed; 170 - } 171 164 172 165 local_irq_restore(flags); 173 166 return 0; ··· 311 322 * @size: physical size of region in bytes must be aligned to 1KiB. 312 323 * @read_mask: read access mask. 313 324 * @write_mask: write access mask. 314 - * @lock: indicates whether or not to permanently lock this region. 315 325 * @return: zero on success or negative value indicating error. 316 326 */ 317 327 int imr_add_range(phys_addr_t base, size_t size, 318 - unsigned int rmask, unsigned int wmask, bool lock) 328 + unsigned int rmask, unsigned int wmask) 319 329 { 320 330 phys_addr_t end; 321 331 unsigned int i; ··· 387 399 imr.rmask = rmask; 388 400 imr.wmask = wmask; 389 401 390 - ret = imr_write(idev, reg, &imr, lock); 402 + ret = imr_write(idev, reg, &imr); 391 403 if (ret < 0) { 392 404 /* 393 405 * In the highly unlikely event iosf_mbi_write failed ··· 398 410 imr.addr_hi = 0; 399 411 imr.rmask = IMR_READ_ACCESS_ALL; 400 412 imr.wmask = IMR_WRITE_ACCESS_ALL; 401 - imr_write(idev, reg, &imr, false); 413 + imr_write(idev, reg, &imr); 402 414 } 403 415 failed: 404 416 mutex_unlock(&idev->lock); ··· 494 506 imr.rmask = IMR_READ_ACCESS_ALL; 495 507 imr.wmask = IMR_WRITE_ACCESS_ALL; 496 508 497 - ret = imr_write(idev, reg, &imr, false); 509 + ret = imr_write(idev, reg, &imr); 498 510 499 511 failed: 500 512 mutex_unlock(&idev->lock); ··· 575 587 * We don't round up @size since it is already PAGE_SIZE aligned. 576 588 * See vmlinux.lds.S for details. 577 589 */ 578 - ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, false); 590 + ret = imr_add_range(base, size, IMR_CPU, IMR_CPU); 579 591 if (ret < 0) { 580 592 pr_err("unable to setup IMR for kernel: %zu KiB (%lx - %lx)\n", 581 593 size / 1024, start, end);
+7 -8
arch/x86/platform/intel-quark/imr_selftest.c
··· 60 60 int ret; 61 61 62 62 /* Test zero zero. */ 63 - ret = imr_add_range(0, 0, 0, 0, false); 63 + ret = imr_add_range(0, 0, 0, 0); 64 64 imr_self_test_result(ret < 0, "zero sized IMR\n"); 65 65 66 66 /* Test exact overlap. */ 67 - ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, false); 67 + ret = imr_add_range(base, size, IMR_CPU, IMR_CPU); 68 68 imr_self_test_result(ret < 0, fmt_over, __va(base), __va(base + size)); 69 69 70 70 /* Test overlap with base inside of existing. */ 71 71 base += size - IMR_ALIGN; 72 - ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, false); 72 + ret = imr_add_range(base, size, IMR_CPU, IMR_CPU); 73 73 imr_self_test_result(ret < 0, fmt_over, __va(base), __va(base + size)); 74 74 75 75 /* Test overlap with end inside of existing. */ 76 76 base -= size + IMR_ALIGN * 2; 77 - ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, false); 77 + ret = imr_add_range(base, size, IMR_CPU, IMR_CPU); 78 78 imr_self_test_result(ret < 0, fmt_over, __va(base), __va(base + size)); 79 79 80 80 /* Test that a 1 KiB IMR @ zero with read/write all will bomb out. */ 81 81 ret = imr_add_range(0, IMR_ALIGN, IMR_READ_ACCESS_ALL, 82 - IMR_WRITE_ACCESS_ALL, false); 82 + IMR_WRITE_ACCESS_ALL); 83 83 imr_self_test_result(ret < 0, "1KiB IMR @ 0x00000000 - access-all\n"); 84 84 85 85 /* Test that a 1 KiB IMR @ zero with CPU only will work. */ 86 - ret = imr_add_range(0, IMR_ALIGN, IMR_CPU, IMR_CPU, false); 86 + ret = imr_add_range(0, IMR_ALIGN, IMR_CPU, IMR_CPU); 87 87 imr_self_test_result(ret >= 0, "1KiB IMR @ 0x00000000 - cpu-access\n"); 88 88 if (ret >= 0) { 89 89 ret = imr_remove_range(0, IMR_ALIGN); ··· 92 92 93 93 /* Test 2 KiB works. */ 94 94 size = IMR_ALIGN * 2; 95 - ret = imr_add_range(0, size, IMR_READ_ACCESS_ALL, 96 - IMR_WRITE_ACCESS_ALL, false); 95 + ret = imr_add_range(0, size, IMR_READ_ACCESS_ALL, IMR_WRITE_ACCESS_ALL); 97 96 imr_self_test_result(ret >= 0, "2KiB IMR @ 0x00000000\n"); 98 97 if (ret >= 0) { 99 98 ret = imr_remove_range(0, size);