M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@ -0,0 +1,32 @@
BOARD_PLATFORM_LIST := msm8660
BOARD_PLATFORM_LIST += msm8960
BOARD_PLATFORM_LIST += apq8064
BOARD_PLATFORM_LIST += msm8930
BOARD_PLATFORM_LIST += msm8974
BOARD_PLATFORM_LIST += mdm9625
BOARD_PLATFORM_LIST += msm8226
BOARD_PLATFORM_LIST += msm8610
ifeq ($(call is-board-platform-in-list, $(BOARD_PLATFORM_LIST)),true)
DLKM_DIR := device/qcom/common/dlkm
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_COPY_HEADERS_TO := kernel-tests/msm_bus
LOCAL_COPY_HEADERS := msm_bus_test.h
include $(BUILD_COPY_HEADERS)
LOCAL_MODULE := msm_bus_ioctl.ko
LOCAL_MODULE_TAGS := eng
include $(DLKM_DIR)/AndroidKernelModule.mk
include $(CLEAR_VARS)
LOCAL_MODULE := msm_bus_test
LOCAL_SRC_FILES := msm_bus_test.c
LOCAL_C_FLAGS := -lpthread
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/kernel-tests
include $(BUILD_EXECUTABLE)
endif

View File

@ -0,0 +1 @@
obj-m := msm_bus_ioctl.o

View File

@ -0,0 +1,24 @@
KERNEL_FLAGS ?= ARCH=arm
module = msm_bus_ioctl.ko
kmake = $(MAKE) $(KERNEL_FLAGS) -C $(KERNEL_DIR) M=$(CURDIR)
$(module):
$(kmake) modules
all-local: $(module)
install-exec-local: $(module)
$(kmake) INSTALL_MOD_PATH=$(DESTDIR)$(prefix)/modules modules_install
# "make distclean" will always run clean-local in this directory,
# regardless of the KERNELMODULES conditional. Therefore, ensure
# KERNEL_DIR exists before running clean. Further, don't fail even
# if there is a problem.
clean-local:
-test ! -d "$(KERNEL_DIR)" || $(kmake) clean
msm_busdir = $(prefix)/msm_bus
include_HEADERS = msm_bus_test.h

View File

@ -0,0 +1,202 @@
/* Copyright (c) 2012, 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/slab.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/uaccess.h>
#include <mach/msm_bus.h>
#include <mach/msm_bus_board.h>
#include "msm_bus_test.h"
static int msm_bus_create_client(unsigned long arg)
{
struct msm_bus_paths *usecase;
struct msm_bus_vectors *vectors;
struct msm_bus_scale_pdata *pdata;
int i, j;
struct msm_bus_test_cldata cldata;
uint32_t clid;
pdata = kmalloc(sizeof(struct msm_bus_scale_pdata), GFP_KERNEL);
pr_debug("AXI: %s(): create cl\n", __func__);
if (__copy_from_user(&cldata, (void __user *)arg,
sizeof(struct msm_bus_test_cldata))) {
pr_err("AXI: %s(): Error getting user memory\n", __func__);
return -EFAULT;
}
pdata->name = cldata.pdata.name;
pdata->active_only = cldata.pdata.active_only;
pdata->num_usecases = cldata.pdata.num_usecases;
usecase = kmalloc(((pdata->num_usecases) *
sizeof(struct msm_bus_paths)), GFP_KERNEL);
if (IS_ERR(usecase)) {
pr_err("AXI: %s(): Error creating usecase in test\n", __func__);
return -ENOMEM;
}
pdata->usecase = usecase;
for (i = 0; i < pdata->num_usecases; i++) {
pdata->usecase[i].num_paths = cldata.pdata.usecase[i].num_paths;
vectors = kmalloc((pdata->usecase[i].num_paths *
sizeof(struct msm_bus_vectors)), GFP_KERNEL);
if (IS_ERR(vectors)) {
for (j = 0; j < i; j++)
kfree(pdata->usecase[j].vectors);
kfree(pdata->usecase);
kfree(pdata);
pr_err("AXI: %s(): Error creating usecase in test\n",
__func__);
return -ENOMEM;
}
for (j = 0; j < pdata->usecase[i].num_paths; j++) {
vectors[j].src = cldata.pdata.usecase[i].vectors[j].src;
vectors[j].dst = cldata.pdata.usecase[i].vectors[j].dst;
vectors[j].ab = cldata.pdata.usecase[i].vectors[j].ab;
vectors[j].ib = cldata.pdata.usecase[i].vectors[j].ib;
}
pdata->usecase[i].vectors = vectors;
}
clid = msm_bus_scale_register_client(pdata);
pr_debug("AXI: %s(): Got client id: %u\n", __func__, clid);
cldata.clid = clid;
cldata.pdatah = (uint32_t)(pdata);
if (__copy_to_user((void __user *)arg, &cldata,
sizeof(struct msm_bus_test_cldata))) {
pr_err("AXI: %s(): Error copying data to client\n", __func__);
msm_bus_scale_unregister_client(clid);
for (i = 0; i < pdata->num_usecases; i++)
kfree(pdata->usecase[i].vectors);
kfree(pdata->usecase);
kfree(pdata);
return -EFAULT;
}
return 0;
}
static int msm_bus_ioctl_unreg_cl(unsigned cmd, unsigned long arg)
{
int retval = 0, i;
uint32_t clid;
struct msm_bus_test_cldata cldata;
struct msm_bus_scale_pdata *pdata;
if (__copy_from_user(&cldata, (void __user *)arg,
sizeof(struct msm_bus_test_cldata)))
retval = -EFAULT;
clid = cldata.clid;
pr_debug("AXI: %s(): IOCTL: Unregister cl%u\n", __func__, clid);
msm_bus_scale_unregister_client(clid);
pdata = (struct msm_bus_scale_pdata *)cldata.pdatah;
for (i = 0; i < pdata->num_usecases; i++)
kfree(pdata->usecase[i].vectors);
kfree(pdata->usecase);
kfree(pdata);
return retval;
}
static int msm_bus_ioctl_update_req(unsigned cmd, unsigned long arg)
{
int retval = 0;
struct msm_bus_test_update_req_data rdata;
if (__copy_from_user(&rdata, (void __user *)arg,
sizeof(rdata))) {
retval = -EFAULT;
goto err;
}
pr_debug("AXI: %s(): IOCTL: Update req for cl: %u, index: %d\n",
__func__, rdata.clid, rdata.index);
retval = msm_bus_scale_client_update_request(rdata.clid,
rdata.index);
err:
return retval;
}
static long msm_bus_test_ioctl(struct file *file, unsigned cmd,
unsigned long arg)
{
long retval = 0;
pr_debug("AXI: %s(): entering test ioctl\n", __func__);
if (_IOC_TYPE(cmd) != MSM_BUS_TEST_IOC_MAGIC) {
pr_err("AXI: %s(): Wrong IOC_MAGIC.Exiting\n", __func__);
return -ENOTTY;
}
switch (cmd) {
case MSM_BUS_TEST_REG_CL:
retval = msm_bus_create_client(arg);
break;
case MSM_BUS_TEST_UNREG_CL:
retval = msm_bus_ioctl_unreg_cl(cmd, arg);
break;
case MSM_BUS_TEST_UPDATE_REQ:
retval = msm_bus_ioctl_update_req(cmd, arg);
break;
default:
pr_err("AXI: %s(): IOCTL: Invalid case\n", __func__);
retval = -EFAULT;
break;
}
return retval;
}
static const struct file_operations msm_bus_test_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = msm_bus_test_ioctl,
};
static struct miscdevice msm_bus_test_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "msmbustest",
.fops = &msm_bus_test_fops,
};
static int msm_bus_test_init(void)
{
int ret;
pr_debug("AXI: %s(): Initializing ioctl module\n", __func__);
ret = misc_register(&msm_bus_test_dev);
if (ret < 0)
return ret;
return 0;
}
static void msm_bus_test_exit(void)
{
pr_debug("AXI: %s(): Exiting ioctl module\n", __func__);
misc_deregister(&msm_bus_test_dev);
}
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Test for MSM Bus Scaling driver");
MODULE_VERSION("1.00");
module_init(msm_bus_test_init);
module_exit(msm_bus_test_exit);

View File

@ -0,0 +1,405 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* 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 The Linux Foundation 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 "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* 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.
*/
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include "msm_bus_test.h"
#define MBPS(n) ((n) * 1000000)
#define NUM_ITERATIONS 1000
#define NUM_STRESS_ITERATIONS 20000
#define MAX_NUM_THREADS 20
static unsigned int iter;
static unsigned int nthreads;
void configureclient(struct msm_bus_test_scale_pdata *pdata, int target)
{
int i, j;
for (i = 0; i < NUM_USECASES; i++) {
for (j = 0; j < NUM_VECTORS; j++) {
pdata->usecase[i].vectors[j].dst =
MSM_BUS_TEST_SLAVE_FIRST;
pdata->usecase[i].vectors[j].ab = 0;
pdata->usecase[i].vectors[j].ib = MBPS(j);
}
pdata->usecase[i].num_paths = NUM_VECTORS;
}
if (target == 8960 || target == 8660 || target == 9615 ||
target == 8064 || target == 8930 || target == 'A' ||
target == 'a') {
for (i = 0; i < NUM_USECASES; i++) {
pdata->usecase[i].vectors[0].src =
MSM_BUS_TEST_MASTER_AMPSS_M0;
pdata->usecase[i].vectors[1].src =
MSM_BUS_TEST_MASTER_SPS;
pdata->usecase[i].vectors[2].src =
MSM_BUS_TEST_MASTER_LPASS;
pdata->usecase[i].vectors[3].src =
MSM_BUS_TEST_MASTER_ADM0_PORT0;
pdata->usecase[i].vectors[4].src =
MSM_BUS_TEST_MASTER_ADM0_PORT1;
}
} else if (target == 8974 || target == 9625 || target == 8226
|| target == 8610 || target == 'B' ||
target == 'b' || target == 8084) {
for (i = 0; i < NUM_USECASES; i++) {
pdata->usecase[i].vectors[0].src =
MSM_BUS_TEST_MASTER_AMPSS_M0;
pdata->usecase[i].vectors[1].src =
MSM_BUS_TEST_MASTER_LPASS_PROC;
pdata->usecase[i].vectors[2].src =
MSM_BUS_TEST_MASTER_CRYPTO_CORE0;
pdata->usecase[i].vectors[3].src =
MSM_BUS_TEST_MASTER_SDCC_1;
pdata->usecase[i].vectors[4].src =
MSM_BUS_TEST_MASTER_QDSS_BAM;
}
} else {
printf("Warning! Couldn't configure client. Target ID %d"
" is not valid. Tests may fail\n"
"Please provide a valid target-id. See usage\n",
target);
}
printf("%s\n", "TestClient");
pdata->active_only = 0;
pdata->num_usecases = NUM_USECASES;
pdata->name = "TestClient";
}
static void print_usage()
{
printf("Usage:\n");
puts(" Supported targets: 8660, 8960, 8930, 9615, 8064, 8974, 9625, "
"8226, 8610, 8084\n"
"Supported families: A & B\n"
"Usage with shell script:\n"
"\tWith target IDs:\n"
"--target <target-id ex. 8974> --nominal\n"
" Nominal is set by default\n"
" Example: ./msm_bus_test.sh --nominal --target 8974\n"
"--target <target-id> --adversarial\n"
" Example: ./msm_bus_test.sh --target 8226 --adversarial\n"
"--target <target-id> --stress [Number of threads]\n"
" Example: ./msm_bus_test.sh --target 9615 --stress 2\n"
"--target <target-id> --repeatability [Number of iterations]\n"
" Example: ./msm_bus_test.sh --target 8610 --repeatability 100\n"
"\nWith with families:\n"
"./msm_bus_test.sh --family A --nominal\n\n"
"Usage directly through test app\n"
"insmod /system/lib/modules/msm_bus_ioctl.ko\n"
"./msm_bus_test --target <Target-ID> --test-type <test-type args>\n"
"Example: ./msm_bus_test --target 8974 --stress 5\n"
"Example: ./msm_bus_test --family B --repeatability 100\n");
exit(1);
}
static int parse_args(int argc, char **argv, int *target)
{
struct option lopts[] = {
{ "nominal", no_argument, NULL, 'n'},
{ "adversarial", no_argument, NULL, 'a'},
{ "stress", required_argument, NULL, 's'},
{ "repeatability", required_argument, NULL, 'r'},
{ "target", required_argument, NULL, 't'},
{ "family", required_argument, NULL, 'f'},
{ NULL, 0, NULL, 0},
};
int command, target_id = 0, ret = 0;
const char *optstr = "n:a:s:r:t:f";
while ((command = getopt_long(argc, argv, optstr, lopts, NULL)) != -1) {
switch (command) {
case 'n':
printf("\nRunning nominal tests...\n");
ret = 'n';
break;
case 'r':
if (optarg) {
printf("Iterations: %d\n\n", atoi(optarg));
iter = atoi(optarg);
} else {
printf("Using default iterations\n");
iter = NUM_ITERATIONS;
}
printf("Running stress tests...\n");
ret = 'r';
break;
case 'a':
printf("Running adversarial tests...\n");
ret = 'a';
break;
case 's':
if (optarg) {
printf("number of threads: %d\n\n",
atoi(optarg));
nthreads = atoi(optarg);
} else {
printf("Using max number of threads\n");
nthreads = MAX_NUM_THREADS;
iter = NUM_ITERATIONS;
}
printf("\nRunning repeatability test for %d "
"iterations\n", iter);
ret = 's';
break;
case 't':
if (optarg) {
printf("\nGot target ID: %d\n", atoi(optarg));
target_id = atoi(optarg);
*target = target_id;
break;
}
case 'f':
if (optarg) {
printf("\nGot Family %c\n", optarg[0]);
target_id = optarg[0];
*target = target_id;
break;
}
default:
printf("\nDefault option: Running nominal tests...\n");
ret = 'n';
break;
}
}
if (target_id == 0) {
printf("\nTarget id not found. Usage:\n");
print_usage();
ret = 0;
}
return ret;
}
static int nominal(int fd, int target)
{
uint32_t clid;
int i, retval = 0;
struct msm_bus_test_update_req_data rdata;
struct msm_bus_test_cldata cldata;
configureclient(&cldata.pdata, target);
retval = ioctl(fd, MSM_BUS_TEST_REG_CL, &cldata);
clid = cldata.clid;
printf("Getting client id...\n");
if (clid != 0) {
printf("Got client id: %u\n", clid);
rdata.clid = clid;
} else {
printf("Client could not be registered\n");
goto err;
}
rdata.index = (rand() % NUM_USECASES);
printf("Updating request for cl %u, index: %d\n", clid, rdata.index);
retval = ioctl(fd, MSM_BUS_TEST_UPDATE_REQ, &rdata);
rdata.index = 0;
retval = ioctl(fd, MSM_BUS_TEST_UPDATE_REQ, &rdata);
printf("Unregistering client: %u\n", cldata.clid);
retval = ioctl(fd, MSM_BUS_TEST_UNREG_CL, &cldata);
printf("Client unregistered: %u\n", clid);
err:
return retval;
}
static int adversarial(int fd, int target)
{
struct msm_bus_test_update_req_data rdata;
struct msm_bus_test_cldata cldata;
configureclient(&cldata.pdata, target);
printf("Test 1: Using invalid master id\n");
cldata.pdata.usecase[0].vectors[0].src = MSM_BUS_TEST_SLAVE_FIRST;
ioctl(fd, MSM_BUS_TEST_REG_CL, &cldata);
printf("Getting client id...\n");
if (cldata.clid != 0) {
printf("Got client id: %u\n", cldata.clid);
rdata.clid = cldata.clid;
} else
printf("Client could not be registered: %d\n", cldata.clid);
printf("Test 2: Using invalid slave id\n");
cldata.pdata.usecase[0].vectors[0].src = MSM_BUS_TEST_MASTER_FIRST;
cldata.pdata.usecase[0].vectors[0].dst = MSM_BUS_TEST_MASTER_MDP_PORT0;
ioctl(fd, MSM_BUS_TEST_REG_CL, &cldata);
printf("Getting client id...\n");
if (cldata.clid != 0) {
printf("Got client id: %u\n", cldata.clid);
rdata.clid = cldata.clid;
} else
printf("Success. Client could not be registered: %d\n",
cldata.clid);
printf("Test 3: Using negative index\n");
cldata.pdata.usecase[0].vectors[0].src = MSM_BUS_TEST_MASTER_FIRST;
cldata.pdata.usecase[0].vectors[0].dst = MSM_BUS_TEST_SLAVE_FIRST;
ioctl(fd, MSM_BUS_TEST_REG_CL, &cldata);
printf("Getting client id...\n");
if (cldata.clid != 0) {
printf("Got client id: %u\n", cldata.clid);
rdata.clid = cldata.clid;
}
rdata.clid = cldata.clid;
rdata.index = -5;
if (ioctl(fd, MSM_BUS_TEST_UPDATE_REQ, &rdata))
printf("Success: Request couldn't be updated:\n");
printf("Test 4: Using out of bounds index\n");
rdata.clid = cldata.clid;
rdata.index = 35;
if (ioctl(fd, MSM_BUS_TEST_UPDATE_REQ, &rdata))
printf("Success: Request couldn't be updated:\n");
err:
return 0;
}
static int repeatability(int fd, int ni, int target)
{
int i, retval;
for (i = 0; i < ni; i++) {
printf("Iteration %d\n", i);
retval = nominal(fd, target);
if (retval) {
printf("\nRepeatability test failed at "
"iteration: %d\n", i);
return retval;
}
}
return 0;
}
void *rep_threadfn(void *thargs)
{
int ret = 0;
ret = repeatability(((int *)thargs)[0], ((int *)thargs)[1],
((int *)thargs)[2]);
if (ret)
printf("\nError :%d\n", ret);
return (void *)ret;
}
static int stress(int fd, int target)
{
int ret = 0;
unsigned int i, j;
pthread_t thread[MAX_NUM_THREADS];
int iret[MAX_NUM_THREADS];
int thargs[3];
printf("\nRunning stress test 1\n"
"Register client, update request with different clock values,"
"unregister client...\n");
ret = repeatability(fd, NUM_ITERATIONS, target);
if (ret)
printf("Stress test 1 failed..\n");
printf("\nRunning stress test 2\n"
"Concurrency test: Spawn 20 threads which register client, "
"upadte request, and unregister client..\n");
thargs[0] = fd;
thargs[1] = NUM_ITERATIONS;
thargs[2] = target;
for (i = 0; i < nthreads; i++) {
iret[i] = pthread_create(&thread[i], NULL, rep_threadfn,
(void *) thargs);
if (iret[i]) {
printf("\nFailed to create %d thread for stress "
"test..\n", i);
for (j = 0; j < i; j++)
pthread_join(thread[j], NULL);
printf("\nStress test failed in thread creation\n");
ret = -1;
return ret;
}
printf("\nRunning test thread %d\n", i);
}
for (i = 0; i < nthreads; i++)
pthread_join(thread[i], NULL);
return 0;
}
int main(int argc, char **argv)
{
int fd, test, target = 0;
test = parse_args(argc, argv, &target);
if (test < 0)
return 1;
printf("In main for msm_bus_test\n");
fd = open("/dev/msmbustest", O_RDWR | O_SYNC);
if (fd < 0) {
perror("Unable to open /dev/msmbustest");
exit(1);
}
printf("\nGot test :%c\n", test);
switch (test) {
case 'n':
nominal(fd, target);
break;
case 's':
stress(fd, target);
break;
case 'a':
adversarial(fd, target);
break;
case 'r':
printf("\nStarting repeatability tests:\n");
repeatability(fd, iter, target);
break;
default:
nominal(fd, target);
break;
}
close(fd);
exit(0);
}

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* 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 The Linux Foundation 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 "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* 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 __MSM_BUS_TEST__
#define __MSM_BUS_TEST__
#include <linux/ioctl.h>
#define MSM_BUS_IOC_MAGIC 0x80
#define TEST_SLAVE_ID_KEY 512
#define NUM_USECASES 10
#define NUM_VECTORS 5
/**
* The test enums do not contain the gateway master/slave IDs. Hence, they
* differ from the enums used in boards file.
* This is done so that random master/slave pairs can be created for
* testing.
*/
enum msm_bus_test_fabric_master_type {
MSM_BUS_TEST_MASTER_FIRST = 1,
MSM_BUS_TEST_MASTER_AMPSS_M0 = 1,
MSM_BUS_TEST_MASTER_SPS = 6,
MSM_BUS_TEST_MASTER_ADM0_PORT0,
MSM_BUS_TEST_MASTER_ADM0_PORT1,
MSM_BUS_TEST_MASTER_LPASS_PROC = 11,
MSM_BUS_TEST_MASTER_LPASS = 15,
MSM_BUS_TEST_MASTER_MDP_PORT0 = 22,
MSM_BUS_TEST_MASTER_HD_CODEC_PORT0 = 34,
MSM_BUS_TEST_MASTER_QDSS_BAM = 53,
MSM_BUS_TEST_MASTER_CRYPTO_CORE0 = 55,
MSM_BUS_TEST_MASTER_SDCC_1 = 78,
};
enum msm_bus_test_fabric_slave_type {
MSM_BUS_TEST_SLAVE_FIRST = TEST_SLAVE_ID_KEY,
MSM_BUS_TEST_SLAVE_EBI_CH0 = TEST_SLAVE_ID_KEY,
};
struct msm_bus_test_vectors {
int src; /* Master */
int dst; /* Slave */
unsigned int ab; /* Arbitrated bandwidth */
unsigned int ib; /* Instantaneous bandwidth */
};
struct msm_bus_test_paths {
int num_paths;
struct msm_bus_test_vectors vectors[NUM_VECTORS];
};
struct msm_bus_test_scale_pdata {
struct msm_bus_test_paths usecase[NUM_USECASES];
int num_usecases;
const char *name;
unsigned int active_only;
};
struct msm_bus_test_cldata {
struct msm_bus_test_scale_pdata pdata;
uint32_t clid;
uint32_t pdatah;
};
struct msm_bus_test_update_req_data {
uint32_t clid;
uint32_t index;
};
#define MSM_BUS_TEST_IOC_MAGIC 0x80
#define MSM_BUS_TEST_REG_CL _IOWR(MSM_BUS_TEST_IOC_MAGIC, 2, \
struct msm_bus_test_cldata)
#define MSM_BUS_TEST_UNREG_CL _IOWR(MSM_BUS_TEST_IOC_MAGIC, 3, \
struct msm_bus_test_cldata)
#define MSM_BUS_TEST_UPDATE_REQ _IOWR(MSM_BUS_TEST_IOC_MAGIC, 4, \
struct msm_bus_test_update_req_data)
#define MSM_BUS_TEST_GET_CLID _IOWR(MSM_BUS_TEST_IOC_MAGIC, 5, uint32_t)
#define MSM_BUS_TEST_GET_RET _IOWR(MSM_BUS_TEST_IOC_MAGIC, 6, int)
#endif /*__MSM_BUS_TEST__*/

View File

@ -0,0 +1,79 @@
# Copyright (c) 2013, The Linux Foundation. All rights reserved.
#
# 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 The Linux Foundation 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 "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# 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.
testpath=/data/kernel-tests
#
if [ -d /system/lib/modules/ ]; then
modpath=/system/lib/modules
else
modpath=/data
fi
msm_bus_ioctl=${modpath}/msm_bus_ioctl.ko
msm_bus_test=${testpath}/msm_bus_test
chmod 777 $msm_bus_test
CMD_LINE="$@"
NUM_ARGS=$#
# insert the msm_bus_ioctl.ko
insmod $msm_bus_ioctl
if [ $? -ne 0 ]; then
echo "ERROR: failed to load module $msm_bus_ioctl"
sleep 2
exit 1
else
echo "Inserted msm_bus_ioctl module\n"
fi
# Execute the tests
# Run nominal test case by default if there are no args
if [ $NUM_ARGS -ne 0 ]; then
$msm_bus_test $CMD_LINE
else
echo "Running nominal tests (default)"
$msm_bus_test -n
fi
num_failures=$?
# Check for pass or fail status
if [ $num_failures -ne 0 ]; then
echo "MSM_BUS tests failed ($num_failures)"
rc=1
else
echo "MSM_BUS tests passed"
rc=0
fi
echo "Unloading $MSM_BUS_IOCTL.ko"
rmmod $msm_bus_ioctl
exit $rc