Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e66e78d4 authored by Sarangdhar Joshi's avatar Sarangdhar Joshi Committed by Trilok Soni
Browse files

arm64: Add support for app specific settings



Add support to provide an interface that can be used from
userspace to decide whether app specific settings need to
be applied / cleared when particular processes are running.

CRs-Fixed: 981519
Change-Id: Id81f8b70de64f291a8586150f4d2c7c8f8b4420f
Signed-off-by: default avatarSarangdhar Joshi <spjoshi@codeaurora.org>
parent 53d1dd96
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -495,9 +495,20 @@ config ARM64_ICACHE_DISABLE


	  If you are not sure what to do, select 'N' here.
	  If you are not sure what to do, select 'N' here.


config MSM_APP_API
	bool "API support to enable / disable app settings for MSM8996"
	depends on ARCH_MSM8996 && (ENABLE_FP_SIMD_SETTINGS || MSM_APP_SETTINGS)
	help
	  Add API support to enable / disable the app settings to be used
	  at runtime. These APIs are used to enable / disable app setting
	  when specific aarch32 or aarch64 processes are running.

	  If you are not sure what to do, select 'N' here.

config ENABLE_FP_SIMD_SETTINGS
config ENABLE_FP_SIMD_SETTINGS
	bool "Enable FP(Floating Point) Settings for Qualcomm MSM8996"
	bool "Enable FP(Floating Point) Settings for Qualcomm MSM8996"
	depends on ARCH_MSM8996
	depends on ARCH_MSM8996
	select MSM_APP_API
	help
	help
	  Enable FP(Floating Point) and SIMD settings for the MSM8996 during
	  Enable FP(Floating Point) and SIMD settings for the MSM8996 during
	  the execution of the aarch32 processes and disable these settings
	  the execution of the aarch32 processes and disable these settings
@@ -505,6 +516,16 @@ config ENABLE_FP_SIMD_SETTINGS


	  If you are not sure what to do, select 'N' here.
	  If you are not sure what to do, select 'N' here.


config MSM_APP_SETTINGS
	bool "Support to enable / disable app settings for MSM8996"
	depends on ARCH_MSM8996
	select MSM_APP_API
	help
	  Expose an interface used by the userspace at runtime to
	  enable / disable the app specific settings.

	  If you are not sure what to do, select 'N' here.

choice
choice
	prompt "Virtual address space size"
	prompt "Virtual address space size"
	default ARM64_VA_BITS_39 if ARM64_4K_PAGES
	default ARM64_VA_BITS_39 if ARM64_4K_PAGES
+42 −0
Original line number Original line Diff line number Diff line
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __ASM_APP_API_H
#define __ASM_APP_API_H

#include <linux/types.h>

#define APP_SETTING_BIT		30
#define MAX_ENTRIES		10

/*
 * APIs to set / clear the app setting bits
 * in the register.
 */
#ifdef CONFIG_MSM_APP_API
extern void set_app_setting_bit(uint32_t bit);
extern void clear_app_setting_bit(uint32_t bit);
#else
static inline void set_app_setting_bit(uint32_t bit) {}
static inline void clear_app_setting_bit(uint32_t bit) {}
#endif

#ifdef CONFIG_MSM_APP_SETTINGS
extern void get_lib_names(char *names[], unsigned int *cnt);
#else
static inline void get_lib_names(char *names[], unsigned int *cnt)
{
	*cnt = 0;
}
#endif

#endif
+0 −4
Original line number Original line Diff line number Diff line
@@ -84,13 +84,9 @@ extern void fpsimd_load_partial_state(struct fpsimd_partial_state *state);
#ifdef CONFIG_ENABLE_FP_SIMD_SETTINGS
#ifdef CONFIG_ENABLE_FP_SIMD_SETTINGS
extern void fpsimd_disable_trap(void);
extern void fpsimd_disable_trap(void);
extern void fpsimd_enable_trap(void);
extern void fpsimd_enable_trap(void);
extern void fpsimd_settings_disable(void);
extern void fpsimd_settings_enable(void);
#else
#else
static inline void fpsimd_disable_trap(void) {}
static inline void fpsimd_disable_trap(void) {}
static inline void fpsimd_enable_trap(void) {}
static inline void fpsimd_enable_trap(void) {}
static inline void fpsimd_settings_disable(void) {}
static inline void fpsimd_settings_enable(void) {}
#endif
#endif


#endif
#endif
+2 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,8 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o
arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
arm64-obj-$(CONFIG_PCI)			+= pci.o
arm64-obj-$(CONFIG_PCI)			+= pci.o
arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
arm64-obj-$(CONFIG_MSM_APP_API)		+= app_api.o
arm64-obj-$(CONFIG_MSM_APP_SETTINGS)	+= app_setting.o


obj-y					+= $(arm64-obj-y) vdso/
obj-y					+= $(arm64-obj-y) vdso/
obj-m					+= $(arm64-obj-m)
obj-m					+= $(arm64-obj-m)
+75 −0
Original line number Original line Diff line number Diff line
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/bitops.h>
#include <linux/spinlock.h>
#include <linux/cpu.h>
#include <linux/export.h>

#include <asm/app_api.h>

static spinlock_t spinlock;
static DEFINE_PER_CPU(int, app_config_applied);
static unsigned long app_config_set[NR_CPUS];
static unsigned long app_config_clear[NR_CPUS];

void set_app_setting_bit(uint32_t bit)
{
	unsigned long flags;
	uint64_t reg;
	int cpu;

	spin_lock_irqsave(&spinlock, flags);
	asm volatile("mrs %0, S3_1_C15_C15_0" : "=r" (reg));
	reg = reg | BIT(bit);
	isb();
	asm volatile("msr S3_1_C15_C15_0, %0" : : "r" (reg));
	isb();
	if (bit == APP_SETTING_BIT) {
		cpu = raw_smp_processor_id();
		app_config_set[cpu]++;

		this_cpu_write(app_config_applied, 1);
	}
	spin_unlock_irqrestore(&spinlock, flags);

}
EXPORT_SYMBOL(set_app_setting_bit);

void clear_app_setting_bit(uint32_t bit)
{
	unsigned long flags;
	uint64_t reg;
	int cpu;

	spin_lock_irqsave(&spinlock, flags);
	asm volatile("mrs %0, S3_1_C15_C15_0" : "=r" (reg));
	reg = reg & ~BIT(bit);
	isb();
	asm volatile("msr S3_1_C15_C15_0, %0" : : "r" (reg));
	isb();
	if (bit == APP_SETTING_BIT) {
		cpu = raw_smp_processor_id();
		app_config_clear[cpu]++;

		this_cpu_write(app_config_applied, 0);
	}
	spin_unlock_irqrestore(&spinlock, flags);
}
EXPORT_SYMBOL(clear_app_setting_bit);

static int __init init_app_api(void)
{
	spin_lock_init(&spinlock);
	return 0;
}
early_initcall(init_app_api);
Loading