1f50a7f3dSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 21feaa87cSMichael Ellerman /* 31feaa87cSMichael Ellerman * Copyright 2014, Michael Ellerman, IBM Corp. 41feaa87cSMichael Ellerman */ 51feaa87cSMichael Ellerman 61feaa87cSMichael Ellerman #include <stdio.h> 71feaa87cSMichael Ellerman #include <stdlib.h> 81feaa87cSMichael Ellerman 91feaa87cSMichael Ellerman #include "event.h" 101feaa87cSMichael Ellerman #include "utils.h" 111feaa87cSMichael Ellerman 121feaa87cSMichael Ellerman #define MALLOC_SIZE (0x10000 * 10) /* Ought to be enough .. */ 131feaa87cSMichael Ellerman 141feaa87cSMichael Ellerman /* 151feaa87cSMichael Ellerman * Tests that the L3 bank handling is correct. We fixed it in commit e9aaac1. 161feaa87cSMichael Ellerman */ l3_bank_test(void)171feaa87cSMichael Ellermanstatic int l3_bank_test(void) 181feaa87cSMichael Ellerman { 191feaa87cSMichael Ellerman struct event event; 201feaa87cSMichael Ellerman char *p; 211feaa87cSMichael Ellerman int i; 221feaa87cSMichael Ellerman 23*4871a10bSMichael Ellerman // The L3 bank logic is only used on Power8 or later 24*4871a10bSMichael Ellerman SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07)); 25*4871a10bSMichael Ellerman 261feaa87cSMichael Ellerman p = malloc(MALLOC_SIZE); 271feaa87cSMichael Ellerman FAIL_IF(!p); 281feaa87cSMichael Ellerman 291feaa87cSMichael Ellerman event_init(&event, 0x84918F); 301feaa87cSMichael Ellerman 311feaa87cSMichael Ellerman FAIL_IF(event_open(&event)); 321feaa87cSMichael Ellerman 331feaa87cSMichael Ellerman for (i = 0; i < MALLOC_SIZE; i += 0x10000) 341feaa87cSMichael Ellerman p[i] = i; 351feaa87cSMichael Ellerman 361feaa87cSMichael Ellerman event_read(&event); 371feaa87cSMichael Ellerman event_report(&event); 381feaa87cSMichael Ellerman 391feaa87cSMichael Ellerman FAIL_IF(event.result.running == 0); 401feaa87cSMichael Ellerman FAIL_IF(event.result.enabled == 0); 411feaa87cSMichael Ellerman 421feaa87cSMichael Ellerman event_close(&event); 431feaa87cSMichael Ellerman free(p); 441feaa87cSMichael Ellerman 451feaa87cSMichael Ellerman return 0; 461feaa87cSMichael Ellerman } 471feaa87cSMichael Ellerman main(void)481feaa87cSMichael Ellermanint main(void) 491feaa87cSMichael Ellerman { 501feaa87cSMichael Ellerman return test_harness(l3_bank_test, "l3_bank_test"); 511feaa87cSMichael Ellerman } 52