Skip to content

Commit

Permalink
integrate socwatch driver
Browse files Browse the repository at this point in the history
Tracked-On: OAM-117842
Change-Id: I220cf48870deaf87f639cd9b6376ce43f70e5470
Signed-off-by: Qi Zhang <[email protected]>
  • Loading branch information
qizhangz authored and JeevakaPrabu committed Jun 17, 2024
1 parent cb848aa commit 1a708b7
Show file tree
Hide file tree
Showing 45 changed files with 13,663 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/platform/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1113,3 +1113,5 @@ config P2SB
The main purpose of this library is to unhide P2SB device in case
firmware kept it hidden on some platforms in order to access devices
behind it.

source "drivers/platform/x86/socwatch/Kconfig"
3 changes: 3 additions & 0 deletions drivers/platform/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ obj-$(CONFIG_SIEMENS_SIMATIC_IPC) += simatic-ipc.o

# Winmate
obj-$(CONFIG_WINMATE_FM07_KEYS) += winmate-fm07-keys.o

#socwatch drivers
obj-$(CONFIG_INTEL_SOCWATCH) += socwatch/
6 changes: 6 additions & 0 deletions drivers/platform/x86/socwatch/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
menuconfig INTEL_SOCWATCH
depends on X86 || X86_64
tristate "SocWatch Driver Support"
default m
help
Say Y here to enable SocWatch driver
24 changes: 24 additions & 0 deletions drivers/platform/x86/socwatch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Makefile for the socwatch driver.
#

DRIVER_BASE=socwatch
DRIVER_MAJOR=2
DRIVER_MINOR=15
# basic name of driver
DRIVER_NAME=${DRIVER_BASE}${DRIVER_MAJOR}_${DRIVER_MINOR}

DO_DRIVER_PROFILING=0

ccflags-y := -I$(srctree)/drivers/platform/x86/socwatch/inc
ccflags-y += -DDO_DRIVER_PROFILING=$(DO_DRIVER_PROFILING)

obj-$(CONFIG_INTEL_SOCWATCH) += $(DRIVER_NAME).o

$(DRIVER_NAME)-objs := sw_driver.o sw_hardware_io.o \
sw_output_buffer.o sw_tracepoint_handlers.o \
sw_collector.o sw_mem.o sw_internal.o \
sw_file_ops.o sw_ops_provider.o \
sw_trace_notifier_provider.o sw_reader.o \
sw_telem.o sw_pmt.o sw_counter_list.o sw_pci.o \

134 changes: 134 additions & 0 deletions drivers/platform/x86/socwatch/inc/sw_collector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/* SPDX-License-Identifier: GPL-2.0 AND BSD-3-Clause
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2014 - 2021 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License 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.
*
* Contact Information:
* SoC Watch Developer Team <[email protected]>
* Intel Corporation,
* 1300 S Mopac Expwy,
* Austin, TX 78746
*
* BSD LICENSE
*
* Copyright(c) 2014 - 2021 Intel Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __SW_COLLECTOR_H__

#include "sw_internal.h"

/*
* Forward declaration
*/
struct sw_hw_ops;

/* TODO: convert from 'list_head' to 'hlist_head' */
/**
* struct - sw_collector_data
* Information about the collector to be invoked at collection time.
*
* The collector_lists array holds linked lists of collectors to
* be exercised at specific points in time during the collection
* (e.g. begin, poll, end, etc.). At a trigger time, the driver walks
* that time's list of nodes, and exercises the collectors on that list.
*
* @list: List/link implementation
* @cpumask: Collect if cpu matches mask
* @info: Ptr to metric info
* @ops: Ptr to collector's operations
* @last_update_jiffies: Indicates when this node was last exercised.
* @per_msg_payload_size: Data size
* @msg: Ptr to collected data
*/
struct sw_collector_data {
SW_LIST_ENTRY(list, sw_collector_data);
struct cpumask cpumask;
struct sw_driver_interface_info *info;
const struct sw_hw_ops **ops;
size_t per_msg_payload_size;
u64 last_update_jiffies;
struct sw_driver_msg *msg;
};

#define GET_MSG_SLOT_FOR_CPU(msgs, cpu, size) ((struct sw_driver_msg *) & \
(((char *)(msgs))[(cpu) * (sizeof(struct sw_driver_msg) + (size))]))

struct sw_collector_data *sw_alloc_collector_node(void);
void sw_free_collector_node(struct sw_collector_data *node);
int sw_handle_collector_node(struct sw_collector_data *data);
int sw_handle_collector_node_on_cpu(struct sw_collector_data *data, int cpu);
int sw_write_collector_node(struct sw_collector_data *data);

void sw_init_collector_list(void *list_head);
void sw_destroy_collector_list(void *list_head);
int sw_handle_collector_list(void *list_head,
int (*func)(struct sw_collector_data *data));
int sw_handle_collector_list_on_cpu(void *list_head,
int (*func)(struct sw_collector_data *data, int cpu),
int cpu);

int sw_handle_driver_io_descriptor(char *dst_vals,
int cpu,
const struct sw_driver_io_descriptor *descriptor,
const struct sw_hw_ops *hw_ops);
int sw_init_driver_io_descriptor(struct sw_driver_io_descriptor *descriptor);
int sw_reset_driver_io_descriptor(struct sw_driver_io_descriptor *descriptor);

int sw_add_driver_info(void *list_head,
const struct sw_driver_interface_info *info);

void sw_handle_per_cpu_msg(void *info);
void sw_handle_per_cpu_msg_no_sched(void *info);
void sw_handle_per_cpu_msg_on_cpu(int cpu, void *info);

void sw_set_collector_ops(const struct sw_hw_ops *hw_ops);

/**
* Process all messages for the given time.
* @param[in] when The time period e.g. 'BEGIN' or 'END'
*
* @returns 0 on success, non-zero on error
*/
extern int sw_process_snapshot(enum sw_when_type when);
extern int sw_process_snapshot_on_cpu(enum sw_when_type when, int cpu);
#endif /* __SW_COLLECTOR_H__ */
36 changes: 36 additions & 0 deletions drivers/platform/x86/socwatch/inc/sw_common_buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* ********************************************************************************
# INTEL CONFIDENTIAL
# Copyright 2019 Intel Corporation.
# This software and the related documents are Intel copyrighted materials, and
# your use of them is governed by the express license under which they were
# provided to you (License). Unless the License provides otherwise, you may not
# use, modify, copy, publish, distribute, disclose or transmit this software or
# the related documents without Intel's prior written permission.
# This software and the related documents are provided as is, with no express or
# implied warranties, other than those that are expressly stated in the License.
# ********************************************************************************/

#ifndef _SW_OUTPUT_BUFFER_H_
#define _SW_OUTPUT_BUFFER_H_ 1

/*
* Data structures.
*/
enum sw_wakeup_action {
SW_WAKEUP_ACTION_DIRECT,
SW_WAKEUP_ACTION_TIMER,
SW_WAKEUP_ACTION_NONE,
};

/* *************************************************
* For circular buffer (continuous profiling)
* *************************************************
*/
long initialize_circular_buffer(size_t size);
void destroy_circular_buffer(void);
int enqueue_circular_data(struct sw_driver_msg *msg, enum sw_wakeup_action action);
size_t consume_circular_data(void *dest, size_t bytes_to_read);

#endif // _SW_OUTPUT_BUFFER_H_
67 changes: 67 additions & 0 deletions drivers/platform/x86/socwatch/inc/sw_counter_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* SPDX-License-Identifier: GPL-2.0 AND BSD-3-Clause
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2020 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License 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.
*
* Contact Information:
* SoC Watch Developer Team <[email protected]>
* Intel Corporation,
* 1300 S Mopac Expwy,
* Austin, TX 78746
*
* BSD LICENSE
*
* Copyright(c) 2020 Intel Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _SW_COUNTER_INFO_H_
#define _SW_COUNTER_INFO_H_ 1

static pw_u64_t msr_info_list[] = {
0x10, 0x17, 0xcd, 0xce, 0xe2, 0xe7, 0xe8, 0x198, 0x199, 0x19c, 0x1aa, 0x1a2, 0x1ad,
0x1b1, 0x1fc, 0x30a, 0x30b, 0x38d, 0x38f, 0x3f8, 0x3f9, 0x3fa, 0x3fc, 0x3fd, 0x3fe,
0x3ff, 0x601, 0x606, 0x60a, 0x60b, 0x60c, 0x60d, 0x610, 0x611, 0x615, 0x619, 0x630,
0x631, 0x632, 0x633, 0x634, 0x635, 0x638, 0x640, 0x64b, 0x64f, 0x659, 0x65a, 0x65b,
0x65c, 0x660, 0x661, 0x662, 0x664, 0x66c, 0x690, 0x6b0, 0x6b1, 0x770, 0x771, 0x772,
0x774, 0x17d0, 0x17d1, 0x17d2};

#endif //_SW_COUNTER_INFO_H_
74 changes: 74 additions & 0 deletions drivers/platform/x86/socwatch/inc/sw_counter_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* SPDX-License-Identifier: GPL-2.0 AND BSD-3-Clause
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2020 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License 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.
*
* Contact Information:
* SoC Watch Developer Team <[email protected]>
* Intel Corporation,
* 1300 S Mopac Expwy,
* Austin, TX 78746
*
* BSD LICENSE
*
* Copyright(c) 2020 Intel Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _SW_COUNTER_LIST_H_
#define _SW_COUNTER_LIST_H_ 1

/*
* Initialize the various search lists created from sets of white-listed
* counters
*/
int sw_counter_init_search_lists(void);
/*
* Destroy the created search lists
*/
void sw_counter_destroy_search_lists(void);

/*
* Check whether the MSR is present in the white-list
*/
bool sw_counter_is_valid_msr(pw_u64_t msr_id);

#endif /* _SW_COUNTER_LIST_H_ */
Loading

0 comments on commit 1a708b7

Please sign in to comment.