Add 'qcom/opensource/dsp-kernel/' from commit 'ca5dc8ec8dfe988ba23cf4d4497f932154a6021a'
git-subtree-dir: qcom/opensource/dsp-kernel git-subtree-mainline:1841c0f616
git-subtree-split:ca5dc8ec8d
Change-Id: repo: https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/dsp-kernel tag: LA.VENDOR.14.3.0.r1-17300-lanai.QSSI15.0
This commit is contained in:
commit
caab746e9f
53
qcom/opensource/dsp-kernel/Android.mk
Normal file
53
qcom/opensource/dsp-kernel/Android.mk
Normal file
@ -0,0 +1,53 @@
|
||||
FASTRPC_DLKM_ENABLED := true
|
||||
|
||||
ifeq ($(TARGET_KERNEL_DLKM_DISABLE), true)
|
||||
ifeq ($(TARGET_KERNEL_DLKM_FASTRPC_OVERRIDE), false)
|
||||
FASTRPC_DLKM_ENABLED := false
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(FASTRPC_DLKM_ENABLED), true)
|
||||
DLKM_DIR := device/qcom/common/dlkm
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
DSP_BLD_DIR := $(abspath .)/vendor/qcom/opensource/dsp-kernel
|
||||
|
||||
LOCAL_MODULE_DDK_BUILD := true
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
$(info DLKM_DIR = $(DLKM_DIR))
|
||||
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
|
||||
LOCAL_MODULE := dsp-module-symvers
|
||||
LOCAL_MODULE_STEM := Module.symvers
|
||||
LOCAL_MODULE_KBUILD_NAME := Module.symvers
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
include $(DLKM_DIR)/Build_external_kernelmodule.mk
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
$(info DLKM_DIR = $(DLKM_DIR))
|
||||
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
|
||||
LOCAL_MODULE := frpc-adsprpc.ko
|
||||
LOCAL_EXPORT_KO_INCLUDE_DIRS := $(LOCAL_PATH)/include/linux
|
||||
LOCAL_MODULE_KBUILD_NAME := frpc-adsprpc.ko
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
KBUILD_OPTIONS += DSP_ROOT=$(DSP_BLD_DIR)
|
||||
KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
|
||||
include $(DLKM_DIR)/Build_external_kernelmodule.mk
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
$(info DLKM_DIR = $(DLKM_DIR))
|
||||
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
|
||||
LOCAL_MODULE := cdsp-loader.ko
|
||||
LOCAL_MODULE_KBUILD_NAME := cdsp-loader.ko
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
KBUILD_OPTIONS += DSP_ROOT=$(DSP_BLD_DIR)
|
||||
KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
|
||||
include $(DLKM_DIR)/Build_external_kernelmodule.mk
|
||||
|
||||
# print out variables
|
||||
$(info KBUILD_OPTIONS = $(KBUILD_OPTIONS))
|
||||
$(info intermediates dsp symvers path = $(call intermediates-dir-for,DLKM,dsp-module-symvers))
|
||||
$(info DLKM_DIR = $(DLKM_DIR))
|
||||
|
||||
endif
|
39
qcom/opensource/dsp-kernel/BUILD.bazel
Normal file
39
qcom/opensource/dsp-kernel/BUILD.bazel
Normal file
@ -0,0 +1,39 @@
|
||||
# Bazel file for fastrpc
|
||||
# Three modules to be exported - frpc-adsprpc,
|
||||
# cdsp-loader and frpc-trusted
|
||||
|
||||
package(
|
||||
default_visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
|
||||
load(":define_modules.bzl", "define_modules")
|
||||
|
||||
define_modules("pineapple", "consolidate")
|
||||
|
||||
define_modules("pineapple", "gki")
|
||||
|
||||
define_modules("blair", "consolidate")
|
||||
|
||||
define_modules("blair", "gki")
|
||||
|
||||
define_modules("holi", "consolidate")
|
||||
|
||||
define_modules("holi", "gki")
|
||||
|
||||
define_modules("cliffs", "consolidate")
|
||||
|
||||
define_modules("cliffs", "gki")
|
||||
|
||||
define_modules("pitti", "consolidate")
|
||||
|
||||
define_modules("pitti", "gki")
|
||||
|
||||
define_modules("volcano", "consolidate")
|
||||
|
||||
define_modules("volcano", "gki")
|
||||
|
||||
define_modules("anorak", "consolidate")
|
||||
|
||||
define_modules("anorak", "gki")
|
39
qcom/opensource/dsp-kernel/Kbuild
Normal file
39
qcom/opensource/dsp-kernel/Kbuild
Normal file
@ -0,0 +1,39 @@
|
||||
# ported from Android.mk
|
||||
$(info within KBUILD file KBUILD_EXTRA_SYMBOLS = $(KBUILD_EXTRA_SYMBOLS))
|
||||
|
||||
ifeq ($(CONFIG_ARCH_WAIPIO), y)
|
||||
$(info within KBUILD file CONFIG_ARCH_WAIPIO = $(CONFIG_ARCH_WAIPIO))
|
||||
KBUILD_CPPFLAGS += -DCONFIG_DSP_WAIPIO=1
|
||||
ccflags-y += -DCONFIG_DSP_WAIPIO=1
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_KALAMA), y)
|
||||
$(info within KBUILD file CONFIG_ARCH_KALAMA = $(CONFIG_ARCH_KALAMA))
|
||||
KBUILD_CPPFLAGS += -DCONFIG_DSP_KALAMA=1
|
||||
ccflags-y += -DCONFIG_DSP_KALAMA=1
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_PINEAPPLE), y)
|
||||
$(info within KBUILD file CONFIG_ARCH_PINEAPPLE = $(CONFIG_ARCH_PINEAPPLE))
|
||||
KBUILD_CPPFLAGS += -DCONFIG_DSP_PINEAPPLE=1
|
||||
ccflags-y += -DCONFIG_DSP_PINEAPPLE=1
|
||||
endif
|
||||
|
||||
LINUXINCLUDE += -I$(DSP_ROOT)/include/linux
|
||||
LINUXINCLUDE += -I$(DSP_ROOT)/include/uapi
|
||||
|
||||
frpc-adsprpc-y := dsp/adsprpc.o \
|
||||
dsp/adsprpc_rpmsg.o \
|
||||
|
||||
frpc-adsprpc-$(CONFIG_COMPAT) += dsp/adsprpc_compat.o \
|
||||
|
||||
frpc_trusted-adsprpc-y := dsp/adsprpc.o \
|
||||
dsp/adsprpc_compat.o \
|
||||
dsp/adsprpc_socket.o \
|
||||
|
||||
cdsp-loader-y := dsp/cdsp-loader.o
|
||||
|
||||
obj-m := frpc-adsprpc.o cdsp-loader.o
|
||||
|
||||
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/frpc-adsprpc.ko
|
||||
#BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/cdsp-loader.ko
|
15
qcom/opensource/dsp-kernel/Kbuild.am
Normal file
15
qcom/opensource/dsp-kernel/Kbuild.am
Normal file
@ -0,0 +1,15 @@
|
||||
# ported from Android.mk
|
||||
$(info within KBUILD file KBUILD_EXTRA_SYMBOLS = $(KBUILD_EXTRA_SYMBOLS))
|
||||
|
||||
ifeq ($(CONFIG_ARCH_PINEAPPLE), y)
|
||||
$(info within KBUILD file CONFIG_ARCH_PINEAPPLE = $(CONFIG_ARCH_PINEAPPLE))
|
||||
KBUILD_CPPFLAGS += -DCONFIG_DSP_PINEAPPLE=1
|
||||
ccflags-y += -DCONFIG_DSP_PINEAPPLE=1
|
||||
ccflags-y += -DCONFIG_MSM_ADSPRPC_TRUSTED=1
|
||||
endif
|
||||
|
||||
frpc-trusted-adsprpc-y := dsp/adsprpc.o \
|
||||
dsp/adsprpc_compat.o \
|
||||
dsp/adsprpc_socket.o \
|
||||
|
||||
obj-m := frpc-trusted-adsprpc.o
|
14
qcom/opensource/dsp-kernel/Makefile
Normal file
14
qcom/opensource/dsp-kernel/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
KBUILD_OPTIONS += DSP_ROOT=$(KERNEL_SRC)/$(M) V=1
|
||||
|
||||
all:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) M=$(M) -C $(KERNEL_SRC) modules_install
|
||||
|
||||
%:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
|
||||
rm -rf .tmp_versions
|
19
qcom/opensource/dsp-kernel/Makefile.am
Normal file
19
qcom/opensource/dsp-kernel/Makefile.am
Normal file
@ -0,0 +1,19 @@
|
||||
DSP_KERNEL_ROOT=$(ROOTDIR)vendor/qcom/opensource/dsp-kernel
|
||||
KBUILD_OPTIONS := DSP_KERNEL_ROOT=$(DSP_KERNEL_ROOT) CONFIG_MSM_ADSPRPC_TRUSTED=m
|
||||
|
||||
ifeq ($(TARGET_SUPPORT),genericarmv8)
|
||||
KBUILD_OPTIONS += CONFIG_ARCH_PINEAPPLE=y
|
||||
endif
|
||||
|
||||
all:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
|
||||
|
||||
%:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
|
||||
rm -rf .tmp_versions
|
6
qcom/opensource/dsp-kernel/config/pineappledsp.conf
Normal file
6
qcom/opensource/dsp-kernel/config/pineappledsp.conf
Normal file
@ -0,0 +1,6 @@
|
||||
ifeq ($(CONFIG_QGKI),y)
|
||||
export CONFIG_MSM_ADSPRPC =y
|
||||
else
|
||||
export CONFIG_MSM_ADSPRPC =m
|
||||
endif
|
||||
#export CONFIG_MSM_DSP=y
|
6
qcom/opensource/dsp-kernel/config/pineappledspconf.h
Normal file
6
qcom/opensource/dsp-kernel/config/pineappledspconf.h
Normal file
@ -0,0 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#define CONFIG_MSM_ADSPRPC 1
|
62
qcom/opensource/dsp-kernel/define_modules.bzl
Normal file
62
qcom/opensource/dsp-kernel/define_modules.bzl
Normal file
@ -0,0 +1,62 @@
|
||||
# TODO
|
||||
# Add ddk module definition for frpc-trusted driver
|
||||
load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
|
||||
|
||||
load(
|
||||
"//build/kernel/kleaf:kernel.bzl",
|
||||
"ddk_headers",
|
||||
"ddk_module",
|
||||
"kernel_module",
|
||||
"kernel_modules_install",
|
||||
)
|
||||
|
||||
def define_modules(target, variant):
|
||||
kernel_build_variant = "{}_{}".format(target, variant)
|
||||
|
||||
# Path to dsp folder from msm-kernel/include/trace directory
|
||||
trace_include_path = "../../../{}/dsp".format(native.package_name())
|
||||
|
||||
ddk_module(
|
||||
name = "{}_frpc-adsprpc".format(kernel_build_variant),
|
||||
kernel_build = "//msm-kernel:{}".format(kernel_build_variant),
|
||||
deps = ["//msm-kernel:all_headers"],
|
||||
srcs = [
|
||||
"dsp/adsprpc.c",
|
||||
"dsp/adsprpc_compat.c",
|
||||
"dsp/adsprpc_compat.h",
|
||||
"dsp/adsprpc_rpmsg.c",
|
||||
"dsp/adsprpc_shared.h",
|
||||
"dsp/fastrpc_trace.h",
|
||||
],
|
||||
local_defines = ["DSP_TRACE_INCLUDE_PATH={}".format(trace_include_path)],
|
||||
out = "frpc-adsprpc.ko",
|
||||
hdrs = [
|
||||
"include/linux/fastrpc.h",
|
||||
"include/uapi/fastrpc_shared.h",
|
||||
],
|
||||
includes = [
|
||||
"include/linux",
|
||||
"include/uapi",
|
||||
],
|
||||
)
|
||||
|
||||
ddk_module(
|
||||
name = "{}_cdsp-loader".format(kernel_build_variant),
|
||||
kernel_build = "//msm-kernel:{}".format(kernel_build_variant),
|
||||
deps = ["//msm-kernel:all_headers"],
|
||||
srcs = ["dsp/cdsp-loader.c"],
|
||||
out = "cdsp-loader.ko",
|
||||
)
|
||||
|
||||
copy_to_dist_dir(
|
||||
name = "{}_dsp-kernel_dist".format(kernel_build_variant),
|
||||
data = [
|
||||
":{}_frpc-adsprpc".format(kernel_build_variant),
|
||||
":{}_cdsp-loader".format(kernel_build_variant),
|
||||
],
|
||||
dist_dir = "out/target/product/{}/dlkm/lib/modules/".format(target),
|
||||
flat = True,
|
||||
wipe_dist_dir = False,
|
||||
allow_duplicate_filenames = False,
|
||||
mode_overrides = {"**/*": "644"},
|
||||
)
|
9261
qcom/opensource/dsp-kernel/dsp/adsprpc.c
Normal file
9261
qcom/opensource/dsp-kernel/dsp/adsprpc.c
Normal file
File diff suppressed because it is too large
Load Diff
1112
qcom/opensource/dsp-kernel/dsp/adsprpc_compat.c
Normal file
1112
qcom/opensource/dsp-kernel/dsp/adsprpc_compat.c
Normal file
File diff suppressed because it is too large
Load Diff
17
qcom/opensource/dsp-kernel/dsp/adsprpc_compat.h
Normal file
17
qcom/opensource/dsp-kernel/dsp/adsprpc_compat.h
Normal file
@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2014, 2018-2019 The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef ADSPRPC_COMPAT_H
|
||||
#define ADSPRPC_COMPAT_H
|
||||
|
||||
#if IS_ENABLED(CONFIG_COMPAT)
|
||||
|
||||
long compat_fastrpc_device_ioctl(struct file *filp, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
#else
|
||||
|
||||
#define compat_fastrpc_device_ioctl NULL
|
||||
|
||||
#endif /* CONFIG_COMPAT */
|
||||
#endif /* ADSPRPC_COMPAT_H */
|
284
qcom/opensource/dsp-kernel/dsp/adsprpc_rpmsg.c
Normal file
284
qcom/opensource/dsp-kernel/dsp/adsprpc_rpmsg.c
Normal file
@ -0,0 +1,284 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/rpmsg.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/module.h>
|
||||
#include "fastrpc_trace.h"
|
||||
#include <trace/events/rproc_qcom.h>
|
||||
#include "adsprpc_shared.h"
|
||||
|
||||
struct frpc_transport_session_control {
|
||||
struct rpmsg_device *rpdev;
|
||||
struct mutex rpmsg_mutex;
|
||||
char *subsys;
|
||||
/* Flags for DSP up mutex */
|
||||
wait_queue_head_t wait_for_rpmsg_ch;
|
||||
atomic_t is_rpmsg_ch_up;
|
||||
};
|
||||
|
||||
static struct frpc_transport_session_control rpmsg_session_control[NUM_CHANNELS];
|
||||
|
||||
inline int verify_transport_device(int cid, int tvm_remote_domain)
|
||||
{
|
||||
int err = 0;
|
||||
struct frpc_transport_session_control *rpmsg_session = &rpmsg_session_control[cid];
|
||||
|
||||
mutex_lock(&rpmsg_session->rpmsg_mutex);
|
||||
VERIFY(err, NULL != rpmsg_session->rpdev);
|
||||
if (err) {
|
||||
err = -ENODEV;
|
||||
mutex_unlock(&rpmsg_session->rpmsg_mutex);
|
||||
goto bail;
|
||||
}
|
||||
mutex_unlock(&rpmsg_session->rpmsg_mutex);
|
||||
bail:
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int get_cid_from_rpdev(struct rpmsg_device *rpdev)
|
||||
{
|
||||
int err = 0, cid = -1;
|
||||
const char *label = 0;
|
||||
|
||||
VERIFY(err, !IS_ERR_OR_NULL(rpdev));
|
||||
if (err)
|
||||
return -ENODEV;
|
||||
|
||||
err = of_property_read_string(rpdev->dev.parent->of_node, "label",
|
||||
&label);
|
||||
|
||||
if (err)
|
||||
label = rpdev->dev.parent->of_node->name;
|
||||
|
||||
if (!strcmp(label, "cdsp"))
|
||||
cid = CDSP_DOMAIN_ID;
|
||||
else if (!strcmp(label, "adsp"))
|
||||
cid = ADSP_DOMAIN_ID;
|
||||
else if (!strcmp(label, "slpi"))
|
||||
cid = SDSP_DOMAIN_ID;
|
||||
else if (!strcmp(label, "mdsp"))
|
||||
cid = MDSP_DOMAIN_ID;
|
||||
else if (!strcmp(label, "cdsp1"))
|
||||
cid = CDSP1_DOMAIN_ID;
|
||||
|
||||
return cid;
|
||||
}
|
||||
|
||||
static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
|
||||
{
|
||||
int err = 0;
|
||||
int cid = -1;
|
||||
struct frpc_transport_session_control *transport_session_control = NULL;
|
||||
|
||||
VERIFY(err, !IS_ERR_OR_NULL(rpdev));
|
||||
if (err)
|
||||
return -ENODEV;
|
||||
|
||||
cid = get_cid_from_rpdev(rpdev);
|
||||
VERIFY(err, VALID_FASTRPC_CID(cid));
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
transport_session_control = &rpmsg_session_control[cid];
|
||||
mutex_lock(&transport_session_control->rpmsg_mutex);
|
||||
transport_session_control->rpdev = rpdev;
|
||||
mutex_unlock(&transport_session_control->rpmsg_mutex);
|
||||
|
||||
/*
|
||||
* Set atomic variable to 1 when rpmsg channel is up
|
||||
* and wake up all threads waiting for rpmsg channel
|
||||
*/
|
||||
atomic_set(&transport_session_control->is_rpmsg_ch_up, 1);
|
||||
wake_up_interruptible(&transport_session_control->wait_for_rpmsg_ch);
|
||||
|
||||
ADSPRPC_INFO("opened rpmsg channel for %s\n",
|
||||
rpmsg_session_control[cid].subsys);
|
||||
bail:
|
||||
if (err)
|
||||
ADSPRPC_ERR("rpmsg probe of %s cid %d failed\n",
|
||||
rpdev->dev.parent->of_node->name, cid);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
|
||||
{
|
||||
int err = 0;
|
||||
int cid = -1;
|
||||
struct frpc_transport_session_control *transport_session_control = NULL;
|
||||
|
||||
VERIFY(err, !IS_ERR_OR_NULL(rpdev));
|
||||
if (err) {
|
||||
err = -ENODEV;
|
||||
return;
|
||||
}
|
||||
|
||||
cid = get_cid_from_rpdev(rpdev);
|
||||
VERIFY(err, VALID_FASTRPC_CID(cid));
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
transport_session_control = &rpmsg_session_control[cid];
|
||||
mutex_lock(&transport_session_control->rpmsg_mutex);
|
||||
transport_session_control->rpdev = NULL;
|
||||
mutex_unlock(&transport_session_control->rpmsg_mutex);
|
||||
|
||||
/*
|
||||
* Set atomic variable to 0 when rpmsg channel is down and
|
||||
* make threads wait on is_rpmsg_ch_up
|
||||
*/
|
||||
atomic_set(&transport_session_control->is_rpmsg_ch_up, 0);
|
||||
|
||||
ADSPRPC_INFO("closed rpmsg channel of %s\n",
|
||||
rpmsg_session_control[cid].subsys);
|
||||
bail:
|
||||
if (err)
|
||||
ADSPRPC_ERR("rpmsg remove of %s cid %d failed\n",
|
||||
rpdev->dev.parent->of_node->name, cid);
|
||||
}
|
||||
|
||||
static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
|
||||
int len, void *priv, u32 addr)
|
||||
{
|
||||
int err = 0;
|
||||
int rpmsg_err = 0;
|
||||
int cid = -1;
|
||||
|
||||
trace_fastrpc_msg("rpmsg_callback: begin");
|
||||
cid = get_cid_from_rpdev(rpdev);
|
||||
VERIFY(err, VALID_FASTRPC_CID(cid));
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
rpmsg_err = fastrpc_handle_rpc_response(data, len, cid);
|
||||
bail:
|
||||
if (err) {
|
||||
err = -ENOKEY;
|
||||
ADSPRPC_ERR(
|
||||
"invalid response data %pK, len %d from remote subsystem err %d\n",
|
||||
data, len, err);
|
||||
} else
|
||||
err = rpmsg_err;
|
||||
|
||||
trace_fastrpc_msg("rpmsg_callback: end");
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called from fastrpc_channel open to wait
|
||||
* for rpmsg channel in the respective domain. The wait in this
|
||||
* function is done only for CDSP, Audio and Sensors Daemons.
|
||||
*/
|
||||
int fastrpc_wait_for_transport_interrupt(int cid,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct frpc_transport_session_control *transport_session_control = NULL;
|
||||
int err = 0;
|
||||
|
||||
/*
|
||||
* The flags which are applicable only for daemons are checked.
|
||||
* Dynamic PDs will fail and return immediately if the
|
||||
* remote subsystem is not up.
|
||||
*/
|
||||
if (flags == FASTRPC_INIT_ATTACH || flags == FASTRPC_INIT_ATTACH_SENSORS
|
||||
|| flags == FASTRPC_INIT_CREATE_STATIC) {
|
||||
transport_session_control = &rpmsg_session_control[cid];
|
||||
ADSPRPC_DEBUG("Thread waiting for cid %d rpmsg channel", cid);
|
||||
err = wait_event_interruptible(transport_session_control->wait_for_rpmsg_ch,
|
||||
atomic_read(&transport_session_control->is_rpmsg_ch_up));
|
||||
ADSPRPC_DEBUG("Thread received signal for cid %d rpmsg channel (interrupted %d)",
|
||||
cid, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int fastrpc_transport_send(int cid, void *rpc_msg, uint32_t rpc_msg_size, int tvm_remote_domain)
|
||||
{
|
||||
int err = 0;
|
||||
struct frpc_transport_session_control *rpmsg_session = &rpmsg_session_control[cid];
|
||||
|
||||
mutex_lock(&rpmsg_session->rpmsg_mutex);
|
||||
VERIFY(err, !IS_ERR_OR_NULL(rpmsg_session->rpdev));
|
||||
if (err) {
|
||||
err = -ENODEV;
|
||||
ADSPRPC_ERR("No rpmsg device for %s, err %d\n", current->comm, err);
|
||||
mutex_unlock(&rpmsg_session->rpmsg_mutex);
|
||||
goto bail;
|
||||
}
|
||||
err = rpmsg_send(rpmsg_session->rpdev->ept, rpc_msg, rpc_msg_size);
|
||||
mutex_unlock(&rpmsg_session->rpmsg_mutex);
|
||||
bail:
|
||||
return err;
|
||||
}
|
||||
|
||||
static const struct rpmsg_device_id fastrpc_rpmsg_match[] = {
|
||||
{ FASTRPC_GLINK_GUID },
|
||||
{ },
|
||||
};
|
||||
|
||||
static const struct of_device_id fastrpc_rpmsg_of_match[] = {
|
||||
{ .compatible = "qcom,msm-fastrpc-rpmsg" },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, fastrpc_rpmsg_of_match);
|
||||
|
||||
static struct rpmsg_driver fastrpc_rpmsg_client = {
|
||||
.id_table = fastrpc_rpmsg_match,
|
||||
.probe = fastrpc_rpmsg_probe,
|
||||
.remove = fastrpc_rpmsg_remove,
|
||||
.callback = fastrpc_rpmsg_callback,
|
||||
.drv = {
|
||||
.name = "qcom,msm_fastrpc_rpmsg",
|
||||
.of_match_table = fastrpc_rpmsg_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
void fastrpc_rproc_trace_events(const char *name, const char *event,
|
||||
const char *subevent)
|
||||
{
|
||||
trace_rproc_qcom_event(name, event, subevent);
|
||||
}
|
||||
|
||||
inline void fastrpc_transport_session_init(int cid, char *subsys)
|
||||
{
|
||||
rpmsg_session_control[cid].subsys = subsys;
|
||||
mutex_init(&rpmsg_session_control[cid].rpmsg_mutex);
|
||||
init_waitqueue_head(&rpmsg_session_control[cid].wait_for_rpmsg_ch);
|
||||
}
|
||||
|
||||
inline void fastrpc_transport_session_deinit(int cid)
|
||||
{
|
||||
mutex_destroy(&rpmsg_session_control[cid].rpmsg_mutex);
|
||||
}
|
||||
|
||||
int fastrpc_set_tvm_remote_domain(struct fastrpc_file *fl, struct fastrpc_ioctl_init *init)
|
||||
{
|
||||
fl->tvm_remote_domain = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fastrpc_transport_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
err = register_rpmsg_driver(&fastrpc_rpmsg_client);
|
||||
if (err) {
|
||||
pr_err("Error: adsprpc: %s: register_rpmsg_driver failed with err %d\n",
|
||||
__func__, err);
|
||||
goto bail;
|
||||
}
|
||||
bail:
|
||||
return err;
|
||||
}
|
||||
|
||||
void fastrpc_transport_deinit(void)
|
||||
{
|
||||
unregister_rpmsg_driver(&fastrpc_rpmsg_client);
|
||||
}
|
994
qcom/opensource/dsp-kernel/dsp/adsprpc_shared.h
Normal file
994
qcom/opensource/dsp-kernel/dsp/adsprpc_shared.h
Normal file
@ -0,0 +1,994 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef ADSPRPC_SHARED_H
|
||||
#define ADSPRPC_SHARED_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/cdev.h>
|
||||
|
||||
#ifdef CONFIG_MSM_ADSPRPC_TRUSTED
|
||||
#include "../include/uapi/fastrpc_shared.h"
|
||||
#else
|
||||
#include "fastrpc_shared.h"
|
||||
#endif
|
||||
|
||||
#define FASTRPC_GLINK_GUID "fastrpcglink-apps-dsp"
|
||||
#define FASTRPC_SMD_GUID "fastrpcsmd-apps-dsp"
|
||||
#define DEVICE_NAME "adsprpc-smd"
|
||||
#define DEVICE_NAME_SECURE "adsprpc-smd-secure"
|
||||
|
||||
/* Pre-defined parameter for print gfa structure*/
|
||||
|
||||
#define smq_invoke_ctx_params "pid: %d, tgid: %d, handle: %d, sc: 0x%x, fl: %p, fd: %p, magic: %d\n"
|
||||
|
||||
#define fastrpc_file_params "fl->tgid: %d, fl->cid: %d, fl->ssrcount: %p, fl->pd: %d, fl->profile: %p, fl->mode: %p, fl->tgid_open: %d, fl->num_cached_buf: %d, num_pers_hdrs: %d, fl->sessionid: %d, fl->servloc_name: %s, fl->file_close: %d, fl->dsp_proc_init: %d,fl->apps: %p, fl->qos_request: %d, fl->dev_minor: %d, fl->debug_buf: %s fl->debug_buf_alloced_attempted: %d, fl->wake_enable: %d, fl->ws_timeout: %d, fl->untrusted_process: %d\n"
|
||||
|
||||
#define fastrpc_mmap_params "fd: %d, flags: %p, buf: %p, phys: %p, size : %d, va : %p, map->raddr: %p, len : %d, refs : %d, secure: %d\n"
|
||||
|
||||
#define fastrpc_buf_params "buf->fl: %p, buf->phys: %p, buf->virt: %p, buf->size: %d, buf->dma_attr: %ld, buf->raddr: %p, buf->flags: %d, buf->type: %d, buf->in_use: %d\n"
|
||||
/* Set for buffers that have no virtual mapping in userspace */
|
||||
#define FASTRPC_ATTR_NOVA 0x1
|
||||
|
||||
/* Set for buffers that are NOT dma coherent */
|
||||
#define FASTRPC_ATTR_NON_COHERENT 0x2
|
||||
|
||||
/* Set for buffers that are dma coherent */
|
||||
#define FASTRPC_ATTR_COHERENT 0x4
|
||||
|
||||
/* Fastrpc attribute for keeping the map persistent */
|
||||
#define FASTRPC_ATTR_KEEP_MAP 0x8
|
||||
|
||||
/* Fastrpc attribute for no mapping of fd */
|
||||
#define FASTRPC_ATTR_NOMAP (16)
|
||||
|
||||
/*
|
||||
* Fastrpc attribute to skip flush by fastrpc
|
||||
*/
|
||||
#define FASTRPC_ATTR_FORCE_NOFLUSH (32)
|
||||
|
||||
/*
|
||||
* Fastrpc attribute to skip invalidate by fastrpc
|
||||
*/
|
||||
#define FASTRPC_ATTR_FORCE_NOINVALIDATE (64)
|
||||
|
||||
/* Driver should operate in parallel with the co-processor */
|
||||
#define FASTRPC_MODE_PARALLEL 0
|
||||
|
||||
/* Driver should operate in serial mode with the co-processor */
|
||||
#define FASTRPC_MODE_SERIAL 1
|
||||
|
||||
/* Driver should operate in profile mode with the co-processor */
|
||||
#define FASTRPC_MODE_PROFILE 2
|
||||
|
||||
/* Set FastRPC session ID to 1 */
|
||||
#define FASTRPC_MODE_SESSION 4
|
||||
|
||||
/* Retrives number of input buffers from the scalars parameter */
|
||||
#define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff)
|
||||
|
||||
/* Retrives number of output buffers from the scalars parameter */
|
||||
#define REMOTE_SCALARS_OUTBUFS(sc) (((sc) >> 8) & 0x0ff)
|
||||
|
||||
/* Retrives number of input handles from the scalars parameter */
|
||||
#define REMOTE_SCALARS_INHANDLES(sc) (((sc) >> 4) & 0x0f)
|
||||
|
||||
/* Retrives number of output handles from the scalars parameter */
|
||||
#define REMOTE_SCALARS_OUTHANDLES(sc) ((sc) & 0x0f)
|
||||
|
||||
/* Remote domains ID */
|
||||
#define ADSP_DOMAIN_ID (0)
|
||||
#define MDSP_DOMAIN_ID (1)
|
||||
#define SDSP_DOMAIN_ID (2)
|
||||
#define CDSP_DOMAIN_ID (3)
|
||||
#define CDSP1_DOMAIN_ID (4)
|
||||
|
||||
#define NUM_CHANNELS 5 /* adsp, mdsp, slpi, cdsp, cdsp1*/
|
||||
#define NUM_SESSIONS 14 /* max 11 compute, 3 cpz */
|
||||
|
||||
/* Default maximum sessions allowed per process */
|
||||
#define DEFAULT_MAX_SESS_PER_PROC 4
|
||||
|
||||
#define VALID_FASTRPC_CID(cid) \
|
||||
(cid >= ADSP_DOMAIN_ID && cid < NUM_CHANNELS)
|
||||
|
||||
#define REMOTE_SCALARS_LENGTH(sc) (REMOTE_SCALARS_INBUFS(sc) +\
|
||||
REMOTE_SCALARS_OUTBUFS(sc) +\
|
||||
REMOTE_SCALARS_INHANDLES(sc) +\
|
||||
REMOTE_SCALARS_OUTHANDLES(sc))
|
||||
|
||||
#define REMOTE_SCALARS_MAKEX(attr, method, in, out, oin, oout) \
|
||||
((((uint32_t) (attr) & 0x7) << 29) | \
|
||||
(((uint32_t) (method) & 0x1f) << 24) | \
|
||||
(((uint32_t) (in) & 0xff) << 16) | \
|
||||
(((uint32_t) (out) & 0xff) << 8) | \
|
||||
(((uint32_t) (oin) & 0x0f) << 4) | \
|
||||
((uint32_t) (oout) & 0x0f))
|
||||
|
||||
#define REMOTE_SCALARS_MAKE(method, in, out) \
|
||||
REMOTE_SCALARS_MAKEX(0, method, in, out, 0, 0)
|
||||
|
||||
#ifdef VERIFY_PRINT_ERROR
|
||||
#define VERIFY_EPRINTF(format, ...) pr_err(format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define VERIFY_EPRINTF(format, args) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifndef VERIFY_PRINT_INFO
|
||||
#define VERIFY_IPRINTF(args) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifndef VERIFY
|
||||
#define __STR__(x) #x ":"
|
||||
#define __TOSTR__(x) __STR__(x)
|
||||
#define __FILE_LINE__ __FILE__ ":" __TOSTR__(__LINE__)
|
||||
#define __ADSPRPC_LINE__ "adsprpc:" __TOSTR__(__LINE__)
|
||||
|
||||
#define VERIFY(err, val) \
|
||||
do {\
|
||||
VERIFY_IPRINTF(__FILE_LINE__"info: calling: " #val "\n");\
|
||||
if ((val) == 0) {\
|
||||
(err) = (err) == 0 ? -1 : (err);\
|
||||
VERIFY_EPRINTF(__ADSPRPC_LINE__" error: %d: "#val "\n", (err));\
|
||||
} else {\
|
||||
VERIFY_IPRINTF(__FILE_LINE__"info: passed: " #val "\n");\
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define ADSPRPC_ERR(fmt, args...)\
|
||||
pr_err("Error: adsprpc (%d): %s: %s: " fmt, __LINE__,\
|
||||
current->comm, __func__, ##args)
|
||||
#define ADSPRPC_INFO(fmt, args...)\
|
||||
pr_info("Info: adsprpc (%d): %s: %s: " fmt, __LINE__,\
|
||||
current->comm, __func__, ##args)
|
||||
#define ADSPRPC_WARN(fmt, args...)\
|
||||
pr_warn("Warning: adsprpc (%d): %s: %s: " fmt, __LINE__,\
|
||||
current->comm, __func__, ##args)
|
||||
#define ADSPRPC_DEBUG(fmt, args...)\
|
||||
pr_debug("Debug: adsprpc (%d): %s: %s: " fmt, __LINE__,\
|
||||
current->comm, __func__, ##args)
|
||||
|
||||
#define DEBUG_PRINT_SIZE_LIMIT (512*1024)
|
||||
|
||||
#define remote_arg64_t union remote_arg64
|
||||
|
||||
struct remote_buf64 {
|
||||
uint64_t pv;
|
||||
uint64_t len;
|
||||
};
|
||||
|
||||
struct remote_dma_handle64 {
|
||||
int fd;
|
||||
uint32_t offset;
|
||||
uint32_t len;
|
||||
};
|
||||
|
||||
union remote_arg64 {
|
||||
struct remote_buf64 buf;
|
||||
struct remote_dma_handle64 dma;
|
||||
uint32_t h;
|
||||
};
|
||||
|
||||
struct remote_buf {
|
||||
void *pv; /* buffer pointer */
|
||||
size_t len; /* length of buffer */
|
||||
};
|
||||
|
||||
/* structure to hold fd and size of buffer shared with DSP,
|
||||
* which contains inital debug parameters that needs to be passed
|
||||
* during process initialization.
|
||||
*/
|
||||
struct fastrpc_proc_sharedbuf_info {
|
||||
int buf_fd;
|
||||
int buf_size;
|
||||
};
|
||||
|
||||
struct remote_dma_handle {
|
||||
int fd;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
union remote_arg {
|
||||
struct remote_buf buf; /* buffer info */
|
||||
struct remote_dma_handle dma;
|
||||
uint32_t h; /* remote handle */
|
||||
};
|
||||
|
||||
struct fastrpc_async_job {
|
||||
uint32_t isasyncjob; /* flag to distinguish async job */
|
||||
uint64_t jobid; /* job id generated by user */
|
||||
uint32_t reserved; /* reserved */
|
||||
};
|
||||
|
||||
/* FastRPC ioctl structure to set session related info */
|
||||
struct fastrpc_proc_sess_info {
|
||||
uint32_t domain_id; /* Set the remote subsystem, Domain ID of the session */
|
||||
uint32_t session_id; /* Unused, Set the Session ID on remote subsystem */
|
||||
uint32_t pd_type; /* Set the process type on remote subsystem */
|
||||
uint32_t sharedcb; /* Unused, Session can share context bank with other sessions */
|
||||
};
|
||||
|
||||
/* INIT a new process or attach to guestos */
|
||||
enum fastrpc_init_flags {
|
||||
FASTRPC_INIT_NO_CREATE = -1,
|
||||
FASTRPC_INIT_ATTACH = 0,
|
||||
FASTRPC_INIT_CREATE = 1,
|
||||
FASTRPC_INIT_CREATE_STATIC = 2,
|
||||
FASTRPC_INIT_ATTACH_SENSORS = 3,
|
||||
};
|
||||
|
||||
enum fastrpc_invoke2_type {
|
||||
FASTRPC_INVOKE2_ASYNC = 1,
|
||||
FASTRPC_INVOKE2_ASYNC_RESPONSE = 2,
|
||||
FASTRPC_INVOKE2_KERNEL_OPTIMIZATIONS,
|
||||
FASTRPC_INVOKE2_STATUS_NOTIF,
|
||||
FASTRPC_INVOKE2_PROC_SHAREDBUF_INFO,
|
||||
/* Set session info of remote sub system */
|
||||
FASTRPC_INVOKE2_SESS_INFO,
|
||||
};
|
||||
|
||||
/**
|
||||
* Control flags for mapping memory on DSP user process
|
||||
*/
|
||||
enum fastrpc_map_flags {
|
||||
/**
|
||||
* Map memory pages with RW- permission and CACHE WRITEBACK.
|
||||
* The driver is responsible for cache maintenance when passed
|
||||
* the buffer to FastRPC calls. Same virtual address will be
|
||||
* assigned for subsequent FastRPC calls.
|
||||
*/
|
||||
FASTRPC_MAP_STATIC = 0,
|
||||
|
||||
/* Reserved */
|
||||
FASTRPC_MAP_RESERVED,
|
||||
|
||||
/**
|
||||
* Map memory pages with RW- permission and CACHE WRITEBACK.
|
||||
* Mapping tagged with a file descriptor. User is responsible for
|
||||
* CPU and DSP cache maintenance for the buffer. Get virtual address
|
||||
* of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs.
|
||||
*/
|
||||
FASTRPC_MAP_FD = 2,
|
||||
|
||||
/**
|
||||
* Mapping delayed until user call HAP_mmap() and HAP_munmap()
|
||||
* functions on DSP. It is useful to map a buffer with cache modes
|
||||
* other than default modes. User is responsible for CPU and DSP
|
||||
* cache maintenance for the buffer.
|
||||
*/
|
||||
FASTRPC_MAP_FD_DELAYED,
|
||||
|
||||
/**
|
||||
* This flag is used to skip CPU mapping,
|
||||
* otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.
|
||||
*/
|
||||
FASTRPC_MAP_FD_NOMAP = 16,
|
||||
|
||||
FASTRPC_MAP_MAX,
|
||||
};
|
||||
|
||||
/*
|
||||
* This enum is shared with DSP. So, existing values should NOT
|
||||
* be modified. Only new members can be added.
|
||||
*/
|
||||
enum dsp_map_flags {
|
||||
/* Add memory to static PD pool, protection thru XPU */
|
||||
ADSP_MMAP_HEAP_ADDR = 4,
|
||||
|
||||
/* MAP static DMA buffer on DSP User PD */
|
||||
ADSP_MMAP_DMA_BUFFER = 6,
|
||||
|
||||
/* Add memory to static PD pool, protection thru hypervisor */
|
||||
ADSP_MMAP_REMOTE_HEAP_ADDR = 8,
|
||||
|
||||
/* Add memory to userPD pool, for user heap */
|
||||
ADSP_MMAP_ADD_PAGES = 0x1000,
|
||||
|
||||
/* Add memory to userPD pool, for LLC heap */
|
||||
ADSP_MMAP_ADD_PAGES_LLC = 0x3000,
|
||||
|
||||
/* Map persistent header buffer on DSP */
|
||||
ADSP_MMAP_PERSIST_HDR = 0x4000,
|
||||
};
|
||||
|
||||
enum fastrpc_control_type {
|
||||
FASTRPC_CONTROL_LATENCY = 1,
|
||||
/* Share SMMU context bank */
|
||||
FASTRPC_CONTROL_SMMU = 2,
|
||||
FASTRPC_CONTROL_KALLOC = 3,
|
||||
FASTRPC_CONTROL_WAKELOCK = 4,
|
||||
FASTRPC_CONTROL_PM = 5,
|
||||
/* Clean process on DSP */
|
||||
FASTRPC_CONTROL_DSPPROCESS_CLEAN = 6,
|
||||
FASTRPC_CONTROL_RPC_POLL = 7,
|
||||
FASTRPC_CONTROL_ASYNC_WAKE = 8,
|
||||
FASTRPC_CONTROL_NOTIF_WAKE = 9,
|
||||
};
|
||||
|
||||
#define FASTRPC_MAX_DSP_ATTRIBUTES (256)
|
||||
#define FASTRPC_MAX_ATTRIBUTES (260)
|
||||
|
||||
enum fastrpc_dsp_capability {
|
||||
ASYNC_FASTRPC_CAP = 9,
|
||||
DMA_HANDLE_REVERSE_RPC_CAP = 129,
|
||||
};
|
||||
|
||||
struct smq_null_invoke {
|
||||
uint64_t ctx; /* invoke caller context */
|
||||
uint32_t handle; /* handle to invoke */
|
||||
uint32_t sc; /* scalars structure describing the data */
|
||||
};
|
||||
|
||||
struct smq_phy_page {
|
||||
uint64_t addr; /* physical address */
|
||||
uint64_t size; /* size of contiguous region */
|
||||
};
|
||||
|
||||
struct smq_invoke_buf {
|
||||
int num; /* number of contiguous regions */
|
||||
int pgidx; /* index to start of contiguous region */
|
||||
};
|
||||
|
||||
struct smq_invoke {
|
||||
struct smq_null_invoke header;
|
||||
struct smq_phy_page page; /* remote arg and list of pages address */
|
||||
};
|
||||
|
||||
struct smq_msg {
|
||||
uint32_t pid; /* process group id */
|
||||
uint32_t tid; /* thread id */
|
||||
struct smq_invoke invoke;
|
||||
};
|
||||
|
||||
struct smq_invoke_rsp {
|
||||
uint64_t ctx; /* invoke caller context */
|
||||
int retval; /* invoke return value */
|
||||
};
|
||||
|
||||
enum fastrpc_response_flags {
|
||||
NORMAL_RESPONSE = 0,
|
||||
EARLY_RESPONSE = 1,
|
||||
USER_EARLY_SIGNAL = 2,
|
||||
COMPLETE_SIGNAL = 3,
|
||||
STATUS_RESPONSE = 4,
|
||||
POLL_MODE = 5,
|
||||
};
|
||||
|
||||
enum fastrpc_process_create_state {
|
||||
PROCESS_CREATE_DEFAULT = 0, /* Process is not created */
|
||||
PROCESS_CREATE_IS_INPROGRESS = 1, /* Process creation is in progress */
|
||||
PROCESS_CREATE_SUCCESS = 2, /* Process creation is successful */
|
||||
};
|
||||
|
||||
struct smq_invoke_rspv2 {
|
||||
uint64_t ctx; /* invoke caller context */
|
||||
int retval; /* invoke return value */
|
||||
uint32_t flags; /* early response flags */
|
||||
uint32_t early_wake_time; /* user predicted early wakeup time in us */
|
||||
uint32_t version; /* Version number for validation */
|
||||
};
|
||||
|
||||
enum fastrpc_status_flags {
|
||||
FASTRPC_USERPD_UP = 0,
|
||||
FASTRPC_USERPD_EXIT = 1,
|
||||
FASTRPC_USERPD_FORCE_KILL = 2,
|
||||
FASTRPC_USERPD_EXCEPTION = 3,
|
||||
FASTRPC_DSP_SSR = 4,
|
||||
};
|
||||
|
||||
struct smq_notif_rspv3 {
|
||||
uint64_t ctx; /* response context */
|
||||
uint32_t type; /* Notification type */
|
||||
int pid; /* user process pid */
|
||||
uint32_t status; /* userpd status notification */
|
||||
};
|
||||
|
||||
enum fastrpc_process_exit_states {
|
||||
/* Process Default State */
|
||||
FASTRPC_PROCESS_DEFAULT_STATE = 0,
|
||||
/* Process exit initiated */
|
||||
FASTRPC_PROCESS_EXIT_START = 1,
|
||||
/* Process exit issued to DSP */
|
||||
FASTRPC_PROCESS_DSP_EXIT_INIT = 2,
|
||||
/* Process exit in DSP complete */
|
||||
FASTRPC_PROCESS_DSP_EXIT_COMPLETE = 3,
|
||||
/* Process exit in DSP error */
|
||||
FASTRPC_PROCESS_DSP_EXIT_ERROR = 4,
|
||||
};
|
||||
|
||||
/*
|
||||
* Process types on remote subsystem
|
||||
* Always add new PD types at the end, before MAX_PD_TYPE
|
||||
*/
|
||||
#define DEFAULT_UNUSED 0 /* pd type not configured for context banks */
|
||||
#define ROOT_PD 1 /* Root PD */
|
||||
#define AUDIO_STATICPD 2 /* ADSP Audio Static PD */
|
||||
#define SENSORS_STATICPD 3 /* ADSP Sensors Static PD */
|
||||
#define SECURE_STATICPD 4 /* CDSP Secure Static PD */
|
||||
#define OIS_STATICPD 5 /* ADSP OIS Static PD */
|
||||
#define CPZ_USERPD 6 /* CDSP CPZ USER PD */
|
||||
#define USERPD 7 /* DSP User Dynamic PD */
|
||||
#define GUEST_OS_SHARED 8 /* Legacy Guest OS Shared */
|
||||
#define MAX_PD_TYPE 9 /* Max PD type */
|
||||
|
||||
struct fastrpc_file;
|
||||
|
||||
int fastrpc_transport_send(int cid, void *rpc_msg, uint32_t rpc_msg_size, int tvm_remote_domain);
|
||||
inline int fastrpc_handle_rpc_response(void *data, int len, int cid);
|
||||
inline int verify_transport_device(int cid, int tvm_remote_domain);
|
||||
int fastrpc_transport_init(void);
|
||||
void fastrpc_transport_deinit(void);
|
||||
void fastrpc_transport_session_init(int cid, char *subsys);
|
||||
void fastrpc_transport_session_deinit(int cid);
|
||||
int fastrpc_wait_for_transport_interrupt(int cid, unsigned int flags);
|
||||
int fastrpc_set_tvm_remote_domain(struct fastrpc_file *fl, struct fastrpc_ioctl_init *init);
|
||||
void fastrpc_restart_drivers(int cid);
|
||||
|
||||
static inline struct smq_invoke_buf *smq_invoke_buf_start(remote_arg64_t *pra,
|
||||
uint32_t sc)
|
||||
{
|
||||
unsigned int len = REMOTE_SCALARS_LENGTH(sc);
|
||||
|
||||
return (struct smq_invoke_buf *)(&pra[len]);
|
||||
}
|
||||
|
||||
static inline struct smq_phy_page *smq_phy_page_start(uint32_t sc,
|
||||
struct smq_invoke_buf *buf)
|
||||
{
|
||||
unsigned int nTotal = REMOTE_SCALARS_LENGTH(sc);
|
||||
|
||||
return (struct smq_phy_page *)(&buf[nTotal]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fastrpc context ID bit-map:
|
||||
*
|
||||
* bits 0-3 : type of remote PD
|
||||
* bit 4 : type of job (sync/async)
|
||||
* bit 5 : reserved
|
||||
* bits 6-15 : index in context table
|
||||
* bits 16-63 : incrementing context ID
|
||||
*/
|
||||
#define FASTRPC_CTX_MAX (1024)
|
||||
|
||||
/* Length of glink transaction history to store */
|
||||
#define GLINK_MSG_HISTORY_LEN (128)
|
||||
|
||||
|
||||
/* Type of fastrpc DMA bufs sent to DSP */
|
||||
enum fastrpc_buf_type {
|
||||
METADATA_BUF,
|
||||
COPYDATA_BUF,
|
||||
INITMEM_BUF,
|
||||
USERHEAP_BUF,
|
||||
};
|
||||
|
||||
|
||||
/* Types of RPC calls to DSP */
|
||||
enum fastrpc_msg_type {
|
||||
/* 64 bit user application invoke message */
|
||||
USER_MSG = 0,
|
||||
/* kernel invoke message with zero pid */
|
||||
KERNEL_MSG_WITH_ZERO_PID,
|
||||
/* kernel invoke message with non zero pid to kill the PD in DSP */
|
||||
KERNEL_MSG_WITH_NONZERO_PID,
|
||||
/* 32 bit user application invoke message */
|
||||
COMPAT_MSG,
|
||||
};
|
||||
|
||||
/* Fastrpc remote pd type */
|
||||
enum fastrpc_remote_pd_type {
|
||||
FASTRPC_ROOT_PD = 0,
|
||||
FASTRPC_USER_PD,
|
||||
FASTRPC_SENSORS_PD,
|
||||
};
|
||||
|
||||
#define DSPSIGNAL_TIMEOUT_NONE 0xffffffff
|
||||
#define DSPSIGNAL_NUM_SIGNALS 1024
|
||||
|
||||
// Signal state and completions are stored in groups of DSPSIGNAL_GROUP_SIZE.
|
||||
// Must be a power of two.
|
||||
#define DSPSIGNAL_GROUP_SIZE 256
|
||||
|
||||
|
||||
struct secure_vm {
|
||||
int *vmid;
|
||||
int *vmperm;
|
||||
int vmcount;
|
||||
};
|
||||
|
||||
struct gid_list {
|
||||
unsigned int *gids;
|
||||
unsigned int gidcount;
|
||||
};
|
||||
|
||||
struct fastrpc_buf {
|
||||
struct hlist_node hn;
|
||||
struct hlist_node hn_rem;
|
||||
struct hlist_node hn_init;
|
||||
struct fastrpc_file *fl;
|
||||
void *virt;
|
||||
uint64_t phys;
|
||||
size_t size;
|
||||
unsigned long dma_attr;
|
||||
uintptr_t raddr;
|
||||
uint32_t flags;
|
||||
int type; /* One of "fastrpc_buf_type" */
|
||||
bool in_use; /* Used only for persistent header buffers */
|
||||
struct timespec64 buf_start_time;
|
||||
struct timespec64 buf_end_time;
|
||||
};
|
||||
|
||||
struct fastrpc_ctx_lst;
|
||||
|
||||
struct fastrpc_tx_msg {
|
||||
struct smq_msg msg; /* Msg sent to remote subsystem */
|
||||
int transport_send_err; /* transport error */
|
||||
int64_t ns; /* Timestamp (in ns) of msg */
|
||||
uint64_t xo_time_in_us; /* XO Timestamp (in us) of sent message */
|
||||
uint64_t xo_time_in_us_interrupted; /* XO Timestamp (in us) of interrupted ctx */
|
||||
uint64_t xo_time_in_us_restored; /* XO Timestamp (in us) of restored ctx */
|
||||
};
|
||||
|
||||
struct fastrpc_rx_msg {
|
||||
struct smq_invoke_rspv2 rsp; /* Response from remote subsystem */
|
||||
int64_t ns; /* Timestamp (in ns) of response */
|
||||
uint64_t xo_time_in_us; /* XO Timestamp (in us) of response */
|
||||
};
|
||||
|
||||
struct fastrpc_transport_log {
|
||||
unsigned int tx_index; /* Current index of 'tx_msgs' array */
|
||||
unsigned int rx_index; /* Current index of 'rx_msgs' array */
|
||||
|
||||
/* Rolling history of messages sent to remote subsystem */
|
||||
struct fastrpc_tx_msg tx_msgs[GLINK_MSG_HISTORY_LEN];
|
||||
|
||||
/* Rolling history of responses from remote subsystem */
|
||||
struct fastrpc_rx_msg rx_msgs[GLINK_MSG_HISTORY_LEN];
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
struct overlap {
|
||||
uintptr_t start;
|
||||
uintptr_t end;
|
||||
int raix;
|
||||
uintptr_t mstart;
|
||||
uintptr_t mend;
|
||||
uintptr_t offset;
|
||||
int do_cmo; /*used for cache maintenance of inrout buffers*/
|
||||
};
|
||||
|
||||
struct fastrpc_perf {
|
||||
uint64_t count;
|
||||
uint64_t flush;
|
||||
uint64_t map;
|
||||
uint64_t copy;
|
||||
uint64_t link;
|
||||
uint64_t getargs;
|
||||
uint64_t putargs;
|
||||
uint64_t invargs;
|
||||
uint64_t invoke;
|
||||
uint64_t tid;
|
||||
};
|
||||
|
||||
struct smq_notif_rsp {
|
||||
struct list_head notifn;
|
||||
int domain;
|
||||
int session;
|
||||
enum fastrpc_status_flags status;
|
||||
};
|
||||
|
||||
struct smq_invoke_ctx {
|
||||
struct hlist_node hn;
|
||||
/* Async node to add to async job ctx list */
|
||||
struct hlist_node asyncn;
|
||||
struct completion work;
|
||||
int retval;
|
||||
int pid;
|
||||
int tgid;
|
||||
remote_arg_t *lpra;
|
||||
remote_arg64_t *rpra;
|
||||
remote_arg64_t *lrpra; /* Local copy of rpra for put_args */
|
||||
int *fds;
|
||||
unsigned int *attrs;
|
||||
struct fastrpc_mmap **maps;
|
||||
struct fastrpc_buf *buf;
|
||||
struct fastrpc_buf *copybuf; /*used to copy non-ion buffers */
|
||||
size_t used;
|
||||
struct fastrpc_file *fl;
|
||||
uint32_t handle;
|
||||
uint32_t sc;
|
||||
struct overlap *overs;
|
||||
struct overlap **overps;
|
||||
struct smq_msg msg;
|
||||
uint32_t *crc;
|
||||
uint64_t *perf_kernel;
|
||||
uint64_t *perf_dsp;
|
||||
unsigned int magic;
|
||||
uint64_t ctxid;
|
||||
struct fastrpc_perf *perf;
|
||||
/* response flags from remote processor */
|
||||
enum fastrpc_response_flags rsp_flags;
|
||||
/* user hint of completion time in us */
|
||||
uint32_t early_wake_time;
|
||||
/* work done status flag */
|
||||
bool is_work_done;
|
||||
/* Store Async job in the context*/
|
||||
struct fastrpc_async_job asyncjob;
|
||||
/* Async early flag to check the state of context */
|
||||
bool is_early_wakeup;
|
||||
uint32_t sc_interrupted;
|
||||
struct fastrpc_file *fl_interrupted;
|
||||
uint32_t handle_interrupted;
|
||||
uint64_t xo_time_in_us_created; /* XO Timestamp (in us) of ctx creation */
|
||||
uint64_t xo_time_in_us_interrupted; /* XO Timestamp (in us) of interrupted ctx */
|
||||
uint64_t xo_time_in_us_restored; /* XO Timestamp (in us) of restored ctx */
|
||||
int tx_index; /* index of current ctx in channel gmsg_log array */
|
||||
bool is_job_sent_to_remote_ss; /* Flag to check if job is sent to remote sub system */
|
||||
};
|
||||
|
||||
struct fastrpc_ctx_lst {
|
||||
struct hlist_head pending;
|
||||
struct hlist_head interrupted;
|
||||
/* Number of active contexts queued to DSP */
|
||||
uint32_t num_active_ctxs;
|
||||
/* Queue which holds all async job contexts of process */
|
||||
struct hlist_head async_queue;
|
||||
/* Queue which holds all status notifications of process */
|
||||
struct list_head notif_queue;
|
||||
};
|
||||
|
||||
struct fastrpc_smmu {
|
||||
struct device *dev;
|
||||
const char *dev_name;
|
||||
int cb;
|
||||
int enabled;
|
||||
int faults;
|
||||
int secure;
|
||||
int coherent;
|
||||
int sharedcb;
|
||||
int pd_type; /* Process type on remote sub system */
|
||||
/* gen pool for QRTR */
|
||||
struct gen_pool *frpc_genpool;
|
||||
/* fastrpc gen pool buffer */
|
||||
struct fastrpc_buf *frpc_genpool_buf;
|
||||
/* fastrpc gen pool buffer fixed IOVA */
|
||||
unsigned long genpool_iova;
|
||||
/* fastrpc gen pool buffer size */
|
||||
size_t genpool_size;
|
||||
};
|
||||
|
||||
struct fastrpc_session_ctx {
|
||||
struct device *dev;
|
||||
struct fastrpc_smmu smmu;
|
||||
int used;
|
||||
};
|
||||
|
||||
struct fastrpc_static_pd {
|
||||
char *servloc_name;
|
||||
char *spdname;
|
||||
void *pdrhandle;
|
||||
uint64_t pdrcount;
|
||||
uint64_t prevpdrcount;
|
||||
atomic_t ispdup;
|
||||
int cid;
|
||||
wait_queue_head_t wait_for_pdup;
|
||||
};
|
||||
|
||||
struct fastrpc_dsp_capabilities {
|
||||
uint32_t is_cached; //! Flag if dsp attributes are cached
|
||||
uint32_t dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
|
||||
};
|
||||
|
||||
struct fastrpc_channel_ctx {
|
||||
char *name;
|
||||
char *subsys;
|
||||
struct device *dev;
|
||||
struct fastrpc_session_ctx session[NUM_SESSIONS];
|
||||
struct fastrpc_static_pd spd[NUM_SESSIONS];
|
||||
struct completion work;
|
||||
struct completion workport;
|
||||
struct notifier_block nb;
|
||||
struct mutex smd_mutex;
|
||||
uint64_t sesscount;
|
||||
uint64_t ssrcount;
|
||||
int in_hib;
|
||||
void *handle;
|
||||
uint64_t prevssrcount;
|
||||
int subsystemstate;
|
||||
int vmid;
|
||||
struct secure_vm rhvm;
|
||||
void *rh_dump_dev;
|
||||
/* Indicates, if channel is restricted to secure node only */
|
||||
int secure;
|
||||
/* Indicates whether the channel supports unsigned PD */
|
||||
bool unsigned_support;
|
||||
struct fastrpc_dsp_capabilities dsp_cap_kernel;
|
||||
/* cpu capabilities shared to DSP */
|
||||
uint64_t cpuinfo_todsp;
|
||||
bool cpuinfo_status;
|
||||
struct smq_invoke_ctx *ctxtable[FASTRPC_CTX_MAX];
|
||||
spinlock_t ctxlock;
|
||||
struct fastrpc_transport_log gmsg_log;
|
||||
struct hlist_head initmems;
|
||||
/* Store gfa structure debug details */
|
||||
struct fastrpc_buf *buf;
|
||||
};
|
||||
|
||||
struct fastrpc_apps {
|
||||
struct fastrpc_channel_ctx *channel;
|
||||
struct cdev cdev;
|
||||
struct class *class;
|
||||
struct smq_phy_page range;
|
||||
struct hlist_head maps;
|
||||
uint32_t staticpd_flags;
|
||||
dev_t dev_no;
|
||||
int compat;
|
||||
struct hlist_head drivers;
|
||||
spinlock_t hlock;
|
||||
struct device *dev;
|
||||
/* Indicates fastrpc device node info */
|
||||
struct device *dev_fastrpc;
|
||||
unsigned int latency;
|
||||
int transport_initialized;
|
||||
/* Flag to determine fastrpc bus registration */
|
||||
int fastrpc_bus_register;
|
||||
bool legacy_remote_heap;
|
||||
/* Unique job id for each message */
|
||||
uint64_t jobid[NUM_CHANNELS];
|
||||
struct gid_list gidlist;
|
||||
struct device *secure_dev;
|
||||
struct device *non_secure_dev;
|
||||
/* Secure subsystems like ADSP/SLPI will use secure client */
|
||||
struct wakeup_source *wake_source_secure;
|
||||
/* Non-secure subsystem like CDSP will use regular client */
|
||||
struct wakeup_source *wake_source;
|
||||
uint32_t duplicate_rsp_err_cnt;
|
||||
uint32_t max_size_limit;
|
||||
struct hlist_head frpc_devices;
|
||||
struct hlist_head frpc_drivers;
|
||||
struct mutex mut_uid;
|
||||
/* Indicates nsp status */
|
||||
int fastrpc_nsp_status;
|
||||
/* Indicates secure context bank to be shared */
|
||||
int share_securecb;
|
||||
/* Indicates process type is configured for SMMU context bank */
|
||||
bool cb_pd_type;
|
||||
/* Number of lowest capacity cores for given platform */
|
||||
unsigned int lowest_capacity_core_count;
|
||||
/* Flag to check if PM QoS vote needs to be done for only one core */
|
||||
bool single_core_latency_vote;
|
||||
/* Maximum sessions allowed to be created per process */
|
||||
uint32_t max_sess_per_proc;
|
||||
};
|
||||
|
||||
struct fastrpc_mmap {
|
||||
struct hlist_node hn;
|
||||
struct fastrpc_file *fl;
|
||||
struct fastrpc_apps *apps;
|
||||
int fd;
|
||||
uint32_t flags;
|
||||
struct dma_buf *buf;
|
||||
struct sg_table *table;
|
||||
struct dma_buf_attachment *attach;
|
||||
struct ion_handle *handle;
|
||||
uint64_t phys;
|
||||
size_t size;
|
||||
uintptr_t va;
|
||||
size_t len;
|
||||
int refs;
|
||||
uintptr_t raddr;
|
||||
int secure;
|
||||
bool is_persistent; /* the map is persistenet across sessions */
|
||||
int frpc_md_index; /* Minidump unique index */
|
||||
uintptr_t attr;
|
||||
bool in_use; /* Indicates if persistent map is in use*/
|
||||
struct timespec64 map_start_time;
|
||||
struct timespec64 map_end_time;
|
||||
/* Mapping for fastrpc shell */
|
||||
bool is_filemap;
|
||||
bool is_dumped; /* flag to indicate map is dumped during SSR */
|
||||
char *servloc_name; /* Indicate which daemon mapped this */
|
||||
/* Indicates map is being used by a pending RPC call */
|
||||
unsigned int ctx_refs;
|
||||
/* Map in use for dma handle */
|
||||
unsigned int dma_handle_refs;
|
||||
};
|
||||
|
||||
enum fastrpc_perfkeys {
|
||||
PERF_COUNT = 0,
|
||||
PERF_FLUSH = 1,
|
||||
PERF_MAP = 2,
|
||||
PERF_COPY = 3,
|
||||
PERF_LINK = 4,
|
||||
PERF_GETARGS = 5,
|
||||
PERF_PUTARGS = 6,
|
||||
PERF_INVARGS = 7,
|
||||
PERF_INVOKE = 8,
|
||||
PERF_TID = 9,
|
||||
PERF_KEY_MAX = 10,
|
||||
};
|
||||
|
||||
struct fastrpc_notif_queue {
|
||||
/* Number of pending status notifications in queue */
|
||||
atomic_t notif_queue_count;
|
||||
|
||||
/* Wait queue to synchronize notifier thread and response */
|
||||
wait_queue_head_t notif_wait_queue;
|
||||
|
||||
/* IRQ safe spin lock for protecting notif queue */
|
||||
spinlock_t nqlock;
|
||||
};
|
||||
|
||||
enum fastrpc_dspsignal_state {
|
||||
DSPSIGNAL_STATE_UNUSED = 0,
|
||||
DSPSIGNAL_STATE_PENDING,
|
||||
DSPSIGNAL_STATE_SIGNALED,
|
||||
DSPSIGNAL_STATE_CANCELED
|
||||
};
|
||||
|
||||
struct fastrpc_dspsignal {
|
||||
struct completion comp;
|
||||
int state;
|
||||
};
|
||||
|
||||
struct memory_snapshot {
|
||||
/* Total size of heap buffers allocated in userspace */
|
||||
size_t heap_bufs_size;
|
||||
/* Total size of non-heap buffers allocated in userspace */
|
||||
size_t nonheap_bufs_size;
|
||||
};
|
||||
|
||||
struct fastrpc_file {
|
||||
struct hlist_node hn;
|
||||
spinlock_t hlock;
|
||||
struct hlist_head maps;
|
||||
struct hlist_head cached_bufs;
|
||||
uint32_t num_cached_buf;
|
||||
struct hlist_head remote_bufs;
|
||||
struct fastrpc_ctx_lst clst;
|
||||
struct fastrpc_session_ctx *sctx;
|
||||
struct fastrpc_buf *init_mem;
|
||||
struct kref refcount;
|
||||
|
||||
/* No. of persistent headers */
|
||||
unsigned int num_pers_hdrs;
|
||||
/* Pre-allocated header buffer */
|
||||
struct fastrpc_buf *pers_hdr_buf;
|
||||
/* Pre-allocated buffer divided into N chunks */
|
||||
struct fastrpc_buf *hdr_bufs;
|
||||
/* Store snapshot of memory occupied by different buffers */
|
||||
struct memory_snapshot mem_snap;
|
||||
|
||||
struct fastrpc_session_ctx *secsctx;
|
||||
uint32_t mode;
|
||||
uint32_t profile;
|
||||
int sessionid;
|
||||
int tgid_open; /* Process ID during device open */
|
||||
int tgid; /* Process ID that uses device for RPC calls */
|
||||
/* Unique HLOS process ID created by fastrpc for each client */
|
||||
int tgid_frpc;
|
||||
int cid;
|
||||
int tvm_remote_domain;
|
||||
uint64_t ssrcount;
|
||||
int pd;
|
||||
char *servloc_name;
|
||||
int file_close;
|
||||
int dsp_proc_init;
|
||||
int sharedcb;
|
||||
int pd_type; /* Process type on remote subsystem */
|
||||
struct fastrpc_apps *apps;
|
||||
struct dentry *debugfs_file;
|
||||
struct dev_pm_qos_request *dev_pm_qos_req;
|
||||
int qos_request;
|
||||
struct mutex map_mutex;
|
||||
struct mutex internal_map_mutex;
|
||||
/* Identifies the device (MINOR_NUM_DEV / MINOR_NUM_SECURE_DEV) */
|
||||
int dev_minor;
|
||||
char *debug_buf;
|
||||
/* Flag to indicate attempt has been made to allocate memory for debug_buf*/
|
||||
int debug_buf_alloced_attempted;
|
||||
/* Flag to enable PM wake/relax voting for every remote invoke */
|
||||
int wake_enable;
|
||||
struct gid_list gidlist;
|
||||
/* Number of jobs pending in Async Queue */
|
||||
atomic_t async_queue_job_count;
|
||||
/* Async wait queue to synchronize glink response and async thread */
|
||||
wait_queue_head_t async_wait_queue;
|
||||
/* IRQ safe spin lock for protecting async queue */
|
||||
spinlock_t aqlock;
|
||||
/* Process status notification queue */
|
||||
struct fastrpc_notif_queue proc_state_notif;
|
||||
uint32_t ws_timeout;
|
||||
bool untrusted_process;
|
||||
struct fastrpc_device *device;
|
||||
/* Process kill will wait on bus driver invoke thread to complete its process */
|
||||
struct completion dma_invoke;
|
||||
/* Flag to indicate invoke pending */
|
||||
bool is_dma_invoke_pend;
|
||||
/* Flag to indicate type of process (static, dynamic) */
|
||||
uint32_t proc_flags;
|
||||
/* If set, threads will poll for DSP response instead of glink wait */
|
||||
bool poll_mode;
|
||||
/* Threads poll for specified timeout and fall back to glink wait */
|
||||
uint32_t poll_timeout;
|
||||
/* Flag to indicate dynamic process creation status*/
|
||||
enum fastrpc_process_create_state dsp_process_state;
|
||||
bool is_unsigned_pd;
|
||||
/* Completion objects and state for dspsignals */
|
||||
struct fastrpc_dspsignal *signal_groups[DSPSIGNAL_NUM_SIGNALS / DSPSIGNAL_GROUP_SIZE];
|
||||
spinlock_t dspsignals_lock;
|
||||
struct mutex signal_create_mutex;
|
||||
struct completion shutdown;
|
||||
/* Flag to indicate notif thread exit requested*/
|
||||
bool exit_notif;
|
||||
/* Flag to indicate async thread exit requested*/
|
||||
bool exit_async;
|
||||
/*
|
||||
* structure to hold fd and size of buffer shared with DSP,
|
||||
* which contains initial debug configurations and other initial
|
||||
* config paramters.
|
||||
*/
|
||||
struct fastrpc_proc_sharedbuf_info sharedbuf_info;
|
||||
/* Flag to indicate 4 session support available */
|
||||
bool multi_session_support;
|
||||
/* Flag to indicate session info is set */
|
||||
bool set_session_info;
|
||||
};
|
||||
|
||||
int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
|
||||
uint32_t kernel,
|
||||
struct fastrpc_ioctl_invoke_async *inv);
|
||||
|
||||
int fastrpc_internal_invoke2(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_invoke2 *inv2, bool is_compat);
|
||||
|
||||
int fastrpc_internal_munmap(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_munmap *ud);
|
||||
|
||||
int fastrpc_internal_mem_map(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_mem_map *ud);
|
||||
|
||||
int fastrpc_internal_mem_unmap(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_mem_unmap *ud);
|
||||
|
||||
int fastrpc_internal_mmap(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_mmap *ud);
|
||||
|
||||
int fastrpc_init_process(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_init_attrs *uproc);
|
||||
|
||||
int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info);
|
||||
|
||||
int fastrpc_internal_control(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_control *cp);
|
||||
|
||||
int fastrpc_setmode(unsigned long ioctl_param,
|
||||
struct fastrpc_file *fl);
|
||||
|
||||
int fastrpc_get_info_from_kernel(
|
||||
struct fastrpc_ioctl_capability *cap,
|
||||
struct fastrpc_file *fl);
|
||||
|
||||
int fastrpc_dspsignal_signal(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_dspsignal_signal *sig);
|
||||
|
||||
int fastrpc_dspsignal_wait(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_dspsignal_wait *wait);
|
||||
|
||||
int fastrpc_dspsignal_create(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_dspsignal_create *create);
|
||||
|
||||
int fastrpc_dspsignal_destroy(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_dspsignal_destroy *destroy);
|
||||
|
||||
int fastrpc_dspsignal_cancel_wait(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_dspsignal_cancel_wait *cancel);
|
||||
|
||||
void fastrpc_rproc_trace_events(const char *name, const char *event,
|
||||
const char *subevent);
|
||||
|
||||
#endif
|
663
qcom/opensource/dsp-kernel/dsp/adsprpc_socket.c
Normal file
663
qcom/opensource/dsp-kernel/dsp/adsprpc_socket.c
Normal file
@ -0,0 +1,663 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* For debug only. Uncomment these blocks to log on every VERIFY statement */
|
||||
|
||||
/*
|
||||
* #ifndef VERIFY_PRINT_ERROR
|
||||
* #define VERIFY_PRINT_ERROR
|
||||
* #endif
|
||||
*/
|
||||
|
||||
/*
|
||||
* #ifndef VERIFY_PRINT_INFO
|
||||
* #define VERIFY_PRINT_INFO
|
||||
* #endif
|
||||
* #define VERIFY_IPRINTF(format, ...) pr_info(format, ##__VA_ARGS__)
|
||||
*/
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/qrtr.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <net/sock.h>
|
||||
#include "fastrpc_trace.h"
|
||||
#include <linux/workqueue.h>
|
||||
#include "adsprpc_shared.h"
|
||||
|
||||
// Registered QRTR service ID
|
||||
#define FASTRPC_REMOTE_SERVER_SERVICE_ID 5012
|
||||
|
||||
/*
|
||||
* Fastrpc remote server instance ID bit-map:
|
||||
*
|
||||
* bits 0-1 : channel ID
|
||||
* bits 2-7 : reserved
|
||||
* bits 8-9 : remote domains (SECURE_PD, GUEST_OS)
|
||||
* bits 10-31 : reserved
|
||||
*/
|
||||
#define REMOTE_DOMAIN_INSTANCE_INDEX (8)
|
||||
#define GET_SERVER_INSTANCE(remote_domain, cid) \
|
||||
((remote_domain << REMOTE_DOMAIN_INSTANCE_INDEX) | cid)
|
||||
#define GET_CID_FROM_SERVER_INSTANCE(remote_server_instance) \
|
||||
(remote_server_instance & 0x3)
|
||||
|
||||
// Maximun received fastprc packet size
|
||||
#define FASTRPC_SOCKET_RECV_SIZE sizeof(union rsp)
|
||||
|
||||
union rsp {
|
||||
struct smq_invoke_rsp rsp;
|
||||
struct smq_invoke_rspv2 rsp2;
|
||||
struct smq_notif_rspv3 rsp3;
|
||||
};
|
||||
|
||||
enum fastrpc_remote_domains_id {
|
||||
SECURE_PD = 0,
|
||||
GUEST_OS = 1,
|
||||
MAX_REMOTE_ID = SECURE_PD + 1,
|
||||
};
|
||||
|
||||
struct fastrpc_socket {
|
||||
struct socket *sock; // Socket used to communicate with remote domain
|
||||
struct sockaddr_qrtr local_sock_addr; // Local socket address on kernel side
|
||||
struct sockaddr_qrtr remote_sock_addr; // Remote socket address on remote domain side
|
||||
struct mutex socket_mutex; // Mutex for socket synchronization
|
||||
void *recv_buf; // Received packet buffer
|
||||
};
|
||||
|
||||
struct frpc_transport_session_control {
|
||||
struct fastrpc_socket frpc_socket; // Fastrpc socket data structure
|
||||
uint32_t remote_server_instance; // Unique remote server instance ID
|
||||
bool remote_server_online; // Flag to indicate remote server status
|
||||
struct work_struct work; // work for handling incoming messages
|
||||
struct workqueue_struct *wq; // workqueue to post @work on
|
||||
};
|
||||
|
||||
struct remote_domain_configuration {
|
||||
int channel_id;
|
||||
int remote_domain;
|
||||
};
|
||||
|
||||
/**
|
||||
* glist_session_ctrl
|
||||
* Static list containing socket session information for all remote domains.
|
||||
*/
|
||||
static struct frpc_transport_session_control *glist_session_ctrl[NUM_CHANNELS][MAX_REMOTE_ID];
|
||||
|
||||
|
||||
static const struct remote_domain_configuration configurations[] = {
|
||||
{
|
||||
.channel_id = CDSP_DOMAIN_ID,
|
||||
.remote_domain = SECURE_PD,
|
||||
},
|
||||
};
|
||||
|
||||
int fastrpc_set_tvm_remote_domain(struct fastrpc_file *fl, struct fastrpc_ioctl_init *init)
|
||||
{
|
||||
int err = 0;
|
||||
char *proc_name = NULL;
|
||||
|
||||
fl->tvm_remote_domain = GUEST_OS;
|
||||
if (init->file) {
|
||||
if (!init->filelen)
|
||||
goto bail;
|
||||
|
||||
proc_name = kzalloc(init->filelen + 1, GFP_KERNEL);
|
||||
VERIFY(err, !IS_ERR_OR_NULL(proc_name));
|
||||
if (err) {
|
||||
err = -ENOMEM;
|
||||
goto bail;
|
||||
}
|
||||
err = copy_from_user((void *)proc_name,
|
||||
(void __user *)init->file, init->filelen);
|
||||
if (err) {
|
||||
err = -EFAULT;
|
||||
goto bail;
|
||||
}
|
||||
if (!strcmp(proc_name, "securepd"))
|
||||
fl->tvm_remote_domain = SECURE_PD;
|
||||
}
|
||||
bail:
|
||||
kfree(proc_name);
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* verify_transport_device()
|
||||
* @cid: Channel ID.
|
||||
* @tvm_remote_domain: Remote domain on TVM.
|
||||
*
|
||||
* Obtain remote session information given channel ID and tvm_remote_domain
|
||||
* and verify that socket has been created and remote server is up.
|
||||
*
|
||||
* Return: 0 on success or negative errno value on failure.
|
||||
*/
|
||||
inline int verify_transport_device(int cid, int tvm_remote_domain)
|
||||
{
|
||||
int remote_domain, err = 0;
|
||||
struct frpc_transport_session_control *session_control = NULL;
|
||||
|
||||
remote_domain = tvm_remote_domain;
|
||||
VERIFY(err, remote_domain >= 0 && remote_domain < MAX_REMOTE_ID);
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
session_control = glist_session_ctrl[cid][remote_domain];
|
||||
VERIFY(err, session_control);
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
mutex_lock(&session_control->frpc_socket.socket_mutex);
|
||||
VERIFY(err, session_control->frpc_socket.sock);
|
||||
VERIFY(err, session_control->remote_server_online);
|
||||
if (err) {
|
||||
err = -EPIPE;
|
||||
mutex_unlock(&session_control->frpc_socket.socket_mutex);
|
||||
goto bail;
|
||||
}
|
||||
mutex_unlock(&session_control->frpc_socket.socket_mutex);
|
||||
|
||||
bail:
|
||||
return err;
|
||||
}
|
||||
|
||||
static void fastrpc_recv_new_server(struct frpc_transport_session_control *session_control,
|
||||
unsigned int service, unsigned int instance,
|
||||
unsigned int node, unsigned int port)
|
||||
{
|
||||
uint32_t remote_server_instance = session_control->remote_server_instance;
|
||||
int32_t err = 0;
|
||||
|
||||
/* Ignore EOF marker */
|
||||
if (!node && !port) {
|
||||
err = -EINVAL;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (service != FASTRPC_REMOTE_SERVER_SERVICE_ID ||
|
||||
instance != remote_server_instance) {
|
||||
err = -ENOMSG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
mutex_lock(&session_control->frpc_socket.socket_mutex);
|
||||
session_control->frpc_socket.remote_sock_addr.sq_family = AF_QIPCRTR;
|
||||
session_control->frpc_socket.remote_sock_addr.sq_node = node;
|
||||
session_control->frpc_socket.remote_sock_addr.sq_port = port;
|
||||
session_control->remote_server_online = true;
|
||||
mutex_unlock(&session_control->frpc_socket.socket_mutex);
|
||||
ADSPRPC_INFO("Remote server is up: remote ID (0x%x), node %u, port %u",
|
||||
remote_server_instance, node, port);
|
||||
bail:
|
||||
if (err != -EINVAL && err) {
|
||||
ADSPRPC_WARN("Ignoring ctrl packet: service id %u, instance id %u, err %d",
|
||||
service, instance, err);
|
||||
}
|
||||
}
|
||||
|
||||
static void fastrpc_recv_del_server(struct frpc_transport_session_control *session_control,
|
||||
unsigned int node, unsigned int port)
|
||||
{
|
||||
uint32_t remote_server_instance = session_control->remote_server_instance;
|
||||
int32_t err = 0;
|
||||
int32_t cid = 0;
|
||||
|
||||
/* Ignore EOF marker */
|
||||
if (!node && !port) {
|
||||
err = -EINVAL;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (node != session_control->frpc_socket.remote_sock_addr.sq_node ||
|
||||
port != session_control->frpc_socket.remote_sock_addr.sq_port) {
|
||||
err = -ENOMSG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
mutex_lock(&session_control->frpc_socket.socket_mutex);
|
||||
session_control->frpc_socket.remote_sock_addr.sq_node = 0;
|
||||
session_control->frpc_socket.remote_sock_addr.sq_port = 0;
|
||||
session_control->remote_server_online = false;
|
||||
mutex_unlock(&session_control->frpc_socket.socket_mutex);
|
||||
cid = GET_CID_FROM_SERVER_INSTANCE(remote_server_instance);
|
||||
ADSPRPC_INFO("Remote server is down: remote ID (0x%x)", remote_server_instance);
|
||||
fastrpc_restart_drivers(cid);
|
||||
bail:
|
||||
if (err != -EINVAL && err)
|
||||
ADSPRPC_WARN("Ignoring ctrl packet: node %u, port %u, err %d", node, port, err);
|
||||
}
|
||||
|
||||
/**
|
||||
* fastrpc_recv_ctrl_pkt()
|
||||
* @session_control: Data structure that contains information related to socket and
|
||||
* remote server availability.
|
||||
* @buf: Control packet.
|
||||
* @len: Control packet length.
|
||||
*
|
||||
* Handle control packet status notifications from remote domain.
|
||||
*/
|
||||
static void fastrpc_recv_ctrl_pkt(struct frpc_transport_session_control *session_control,
|
||||
const void *buf, size_t len)
|
||||
{
|
||||
const struct qrtr_ctrl_pkt *pkt = buf;
|
||||
|
||||
if (len < sizeof(struct qrtr_ctrl_pkt)) {
|
||||
ADSPRPC_WARN("Ignoring short control packet (%d bytes)", len);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (le32_to_cpu(pkt->cmd)) {
|
||||
case QRTR_TYPE_NEW_SERVER:
|
||||
fastrpc_recv_new_server(session_control,
|
||||
le32_to_cpu(pkt->server.service),
|
||||
le32_to_cpu(pkt->server.instance),
|
||||
le32_to_cpu(pkt->server.node),
|
||||
le32_to_cpu(pkt->server.port));
|
||||
break;
|
||||
case QRTR_TYPE_DEL_SERVER:
|
||||
fastrpc_recv_del_server(session_control,
|
||||
le32_to_cpu(pkt->server.node),
|
||||
le32_to_cpu(pkt->server.port));
|
||||
break;
|
||||
default:
|
||||
ADSPRPC_WARN("Ignoring unknown ctrl packet with size %zu", len);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fastrpc_socket_callback_wq()
|
||||
* @work: workqueue structure for incoming socket packets
|
||||
*
|
||||
* Callback function to receive responses that were posted on workqueue.
|
||||
* We expect to receive control packets with remote domain status notifications or
|
||||
* RPC data packets from remote domain.
|
||||
*/
|
||||
static void fastrpc_socket_callback_wq(struct work_struct *work)
|
||||
{
|
||||
int32_t err = 0, cid = -1, bytes_rx = 0;
|
||||
uint32_t remote_server_instance = (uint32_t)-1;
|
||||
bool ignore_err = false;
|
||||
struct kvec msg = {0};
|
||||
struct sockaddr_qrtr remote_sock_addr = {0};
|
||||
struct msghdr remote_server = {0};
|
||||
struct frpc_transport_session_control *session_control = NULL;
|
||||
__u32 sq_node = 0, sq_port = 0;
|
||||
|
||||
session_control = container_of(work, struct frpc_transport_session_control, work);
|
||||
VERIFY(err, session_control);
|
||||
if (err) {
|
||||
err = -EFAULT;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
remote_server.msg_name = &remote_sock_addr;
|
||||
remote_server.msg_namelen = sizeof(remote_sock_addr);
|
||||
msg.iov_base = session_control->frpc_socket.recv_buf;
|
||||
msg.iov_len = FASTRPC_SOCKET_RECV_SIZE;
|
||||
remote_server_instance = session_control->remote_server_instance;
|
||||
for (;;) {
|
||||
trace_fastrpc_msg("socket_callback_ready: begin");
|
||||
err = kernel_recvmsg(session_control->frpc_socket.sock, &remote_server, &msg, 1,
|
||||
msg.iov_len, MSG_DONTWAIT);
|
||||
if (err == -EAGAIN) {
|
||||
ignore_err = true;
|
||||
goto bail;
|
||||
}
|
||||
if (err < 0)
|
||||
goto bail;
|
||||
|
||||
bytes_rx = err;
|
||||
err = 0;
|
||||
|
||||
sq_node = remote_sock_addr.sq_node;
|
||||
sq_port = remote_sock_addr.sq_port;
|
||||
if (sq_node == session_control->frpc_socket.local_sock_addr.sq_node &&
|
||||
sq_port == QRTR_PORT_CTRL) {
|
||||
fastrpc_recv_ctrl_pkt(session_control,
|
||||
session_control->frpc_socket.recv_buf,
|
||||
bytes_rx);
|
||||
} else {
|
||||
cid = GET_CID_FROM_SERVER_INSTANCE(remote_server_instance);
|
||||
VERIFY(err, VALID_FASTRPC_CID(cid));
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
fastrpc_handle_rpc_response(msg.iov_base, msg.iov_len, cid);
|
||||
}
|
||||
trace_fastrpc_msg("socket_callback_ready: end");
|
||||
}
|
||||
bail:
|
||||
if (!ignore_err && err < 0) {
|
||||
ADSPRPC_ERR(
|
||||
"invalid response data %pK (rx %d bytes), buffer len %d from remote ID (0x%x) err %d\n",
|
||||
msg.iov_base, bytes_rx, msg.iov_len, remote_server_instance, err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fastrpc_socket_callback()
|
||||
* @sk: Sock data structure with information related to the callback response.
|
||||
*
|
||||
* Callback function to receive responses from socket layer.
|
||||
* Responses are posted on workqueue to be process.
|
||||
*/
|
||||
static void fastrpc_socket_callback(struct sock *sk)
|
||||
{
|
||||
int32_t err = 0;
|
||||
struct frpc_transport_session_control *session_control = NULL;
|
||||
|
||||
trace_fastrpc_msg("socket_callback: begin");
|
||||
VERIFY(err, sk);
|
||||
if (err) {
|
||||
err = -EFAULT;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
session_control = rcu_dereference_sk_user_data(sk);
|
||||
if (session_control)
|
||||
queue_work(session_control->wq, &session_control->work);
|
||||
rcu_read_unlock();
|
||||
bail:
|
||||
if (err < 0)
|
||||
ADSPRPC_ERR("invalid sock received, err %d", err);
|
||||
trace_fastrpc_msg("socket_callback: end");
|
||||
}
|
||||
|
||||
/**
|
||||
* fastrpc_transport_send()
|
||||
* @cid: Channel ID.
|
||||
* @rpc_msg: RPC message to send to remote domain.
|
||||
* @rpc_msg_size: RPC message size.
|
||||
* @tvm_remote_domain: Remote domain on TVM.
|
||||
*
|
||||
* Send RPC message to remote domain. Depending on tvm_remote_domain flag message will be
|
||||
* sent to one of the remote domains on remote subsystem.
|
||||
* Depending on the channel ID and remote domain, a corresponding socket is retrieved
|
||||
* from glist_session_ctrl and is use to send RPC message.
|
||||
*
|
||||
* Return: 0 on success or negative errno value on failure.
|
||||
*/
|
||||
int fastrpc_transport_send(int cid, void *rpc_msg, uint32_t rpc_msg_size, int tvm_remote_domain)
|
||||
{
|
||||
int err = 0, remote_domain;
|
||||
struct fastrpc_socket *frpc_socket = NULL;
|
||||
struct frpc_transport_session_control *session_control = NULL;
|
||||
struct msghdr remote_server = {0};
|
||||
struct kvec msg = {0};
|
||||
|
||||
remote_domain = tvm_remote_domain;
|
||||
VERIFY(err, remote_domain >= 0 && remote_domain < MAX_REMOTE_ID);
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
session_control = glist_session_ctrl[cid][remote_domain];
|
||||
VERIFY(err, session_control);
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
frpc_socket = &session_control->frpc_socket;
|
||||
remote_server.msg_name = &frpc_socket->remote_sock_addr;
|
||||
remote_server.msg_namelen = sizeof(frpc_socket->remote_sock_addr);
|
||||
|
||||
msg.iov_base = rpc_msg;
|
||||
msg.iov_len = rpc_msg_size;
|
||||
|
||||
mutex_lock(&frpc_socket->socket_mutex);
|
||||
VERIFY(err, frpc_socket->sock);
|
||||
VERIFY(err, session_control->remote_server_online);
|
||||
if (err) {
|
||||
err = -EPIPE;
|
||||
mutex_unlock(&frpc_socket->socket_mutex);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
err = kernel_sendmsg(frpc_socket->sock, &remote_server, &msg, 1, msg.iov_len);
|
||||
if (err > 0)
|
||||
err = 0;
|
||||
|
||||
mutex_unlock(&frpc_socket->socket_mutex);
|
||||
bail:
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* create_socket()
|
||||
* @session_control: Data structure that contains information related to socket and
|
||||
* remote server availability.
|
||||
*
|
||||
* Initializes and creates a kernel socket.
|
||||
*
|
||||
* Return: pointer to a socket on success or negative errno value on failure.
|
||||
*/
|
||||
static struct socket *create_socket(struct frpc_transport_session_control *session_control)
|
||||
{
|
||||
int err = 0;
|
||||
struct socket *sock = NULL;
|
||||
struct fastrpc_socket *frpc_socket = NULL;
|
||||
|
||||
err = sock_create_kern(&init_net, AF_QIPCRTR, SOCK_DGRAM,
|
||||
PF_QIPCRTR, &sock);
|
||||
if (err < 0) {
|
||||
ADSPRPC_ERR("sock_create_kern failed with err %d\n", err);
|
||||
goto bail;
|
||||
}
|
||||
frpc_socket = &session_control->frpc_socket;
|
||||
err = kernel_getsockname(sock, (struct sockaddr *)&frpc_socket->local_sock_addr);
|
||||
if (err < 0) {
|
||||
sock_release(sock);
|
||||
ADSPRPC_ERR("kernel_getsockname failed with err %d\n", err);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
rcu_assign_sk_user_data(sock->sk, session_control);
|
||||
sock->sk->sk_data_ready = fastrpc_socket_callback;
|
||||
sock->sk->sk_error_report = fastrpc_socket_callback;
|
||||
bail:
|
||||
if (err < 0)
|
||||
return ERR_PTR(err);
|
||||
else
|
||||
return sock;
|
||||
}
|
||||
|
||||
/**
|
||||
* register_remote_server_notifications()
|
||||
* @frpc_socket: Socket to send message to register for remote service notifications.
|
||||
* @remote_server_instance: ID to uniquely identify remote server
|
||||
*
|
||||
* Register socket to receive status notifications from remote service
|
||||
* using remote service ID FASTRPC_REMOTE_SERVER_SERVICE_ID and instance ID.
|
||||
*
|
||||
* Return: 0 on success or negative errno value on failure.
|
||||
*/
|
||||
static int register_remote_server_notifications(struct fastrpc_socket *frpc_socket,
|
||||
uint32_t remote_server_instance)
|
||||
{
|
||||
struct qrtr_ctrl_pkt pkt = {0};
|
||||
struct sockaddr_qrtr sq = {0};
|
||||
struct msghdr remote_server = {0};
|
||||
struct kvec msg = { &pkt, sizeof(pkt) };
|
||||
int err = 0;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
pkt.cmd = cpu_to_le32(QRTR_TYPE_NEW_LOOKUP);
|
||||
pkt.server.service = cpu_to_le32(FASTRPC_REMOTE_SERVER_SERVICE_ID);
|
||||
pkt.server.instance = cpu_to_le32(remote_server_instance);
|
||||
|
||||
sq.sq_family = frpc_socket->local_sock_addr.sq_family;
|
||||
sq.sq_node = frpc_socket->local_sock_addr.sq_node;
|
||||
sq.sq_port = QRTR_PORT_CTRL;
|
||||
|
||||
remote_server.msg_name = &sq;
|
||||
remote_server.msg_namelen = sizeof(sq);
|
||||
|
||||
err = kernel_sendmsg(frpc_socket->sock, &remote_server, &msg, 1, sizeof(pkt));
|
||||
if (err < 0)
|
||||
goto bail;
|
||||
|
||||
bail:
|
||||
if (err < 0)
|
||||
ADSPRPC_ERR("failed to send lookup registration: %d\n", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
inline void fastrpc_transport_session_init(int cid, char *subsys)
|
||||
{
|
||||
}
|
||||
|
||||
inline void fastrpc_transport_session_deinit(int cid)
|
||||
{
|
||||
}
|
||||
|
||||
int fastrpc_wait_for_transport_interrupt(int cid, unsigned int flags)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fastrpc_rproc_trace_events(const char *name, const char *event,
|
||||
const char *subevent)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* fastrpc_transport_init() - Initialize sockets for fastrpc driver.
|
||||
*
|
||||
* Initialize and create all sockets that are enabled from all channels
|
||||
* and remote domains.
|
||||
* Traverse array configurations and initialize session on glist_session_ctrl if remote
|
||||
* domain is enabled.
|
||||
*
|
||||
* Return: 0 on success or negative errno value on failure.
|
||||
*/
|
||||
int fastrpc_transport_init(void)
|
||||
{
|
||||
int err = 0, cid = -1, ii = 0, remote_domain = -1;
|
||||
struct socket *sock = NULL;
|
||||
struct fastrpc_socket *frpc_socket = NULL;
|
||||
struct frpc_transport_session_control *session_control = NULL;
|
||||
struct workqueue_struct *wq = NULL;
|
||||
|
||||
for (ii = 0; ii < ARRAY_SIZE(configurations); ii++) {
|
||||
session_control = kzalloc(sizeof(*session_control), GFP_KERNEL);
|
||||
VERIFY(err, NULL != session_control);
|
||||
if (err) {
|
||||
err = -ENOMEM;
|
||||
goto bail;
|
||||
}
|
||||
cid = configurations[ii].channel_id;
|
||||
remote_domain = configurations[ii].remote_domain;
|
||||
VERIFY(err, remote_domain < MAX_REMOTE_ID);
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
VERIFY(err, VALID_FASTRPC_CID(cid));
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
session_control->remote_server_online = false;
|
||||
frpc_socket = &session_control->frpc_socket;
|
||||
mutex_init(&frpc_socket->socket_mutex);
|
||||
|
||||
sock = create_socket(session_control);
|
||||
if (IS_ERR_OR_NULL(sock)) {
|
||||
err = PTR_ERR(sock);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
frpc_socket->sock = sock;
|
||||
frpc_socket->recv_buf = kzalloc(FASTRPC_SOCKET_RECV_SIZE, GFP_KERNEL);
|
||||
if (!frpc_socket->recv_buf) {
|
||||
err = -ENOMEM;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
INIT_WORK(&session_control->work, fastrpc_socket_callback_wq);
|
||||
wq = alloc_workqueue("fastrpc_msg_handler", WQ_UNBOUND|WQ_HIGHPRI, 0);
|
||||
if (!wq) {
|
||||
err = -ENOMEM;
|
||||
goto bail;
|
||||
}
|
||||
session_control->wq = wq;
|
||||
|
||||
session_control->remote_server_instance = GET_SERVER_INSTANCE(remote_domain, cid);
|
||||
err = register_remote_server_notifications(frpc_socket,
|
||||
session_control->remote_server_instance);
|
||||
if (err < 0)
|
||||
goto bail;
|
||||
|
||||
glist_session_ctrl[cid][remote_domain] = session_control;
|
||||
ADSPRPC_INFO("Created and registered socket for remote server (service ID %u, instance ID 0x%x)\n",
|
||||
FASTRPC_REMOTE_SERVER_SERVICE_ID, session_control->remote_server_instance);
|
||||
|
||||
}
|
||||
|
||||
err = 0;
|
||||
bail:
|
||||
if (err)
|
||||
ADSPRPC_ERR("fastrpc_socket_init failed with err %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* fastrpc_transport_deinit() - Deinitialize sockets for fastrpc driver.
|
||||
*
|
||||
* Deinitialize and release all sockets that are enabled from all channels
|
||||
* and remote domains.
|
||||
* Traverse array configurations and deinitialize corresponding session from
|
||||
* glist_session_ctrl.
|
||||
*/
|
||||
void fastrpc_transport_deinit(void)
|
||||
{
|
||||
int ii = 0, cid = -1, remote_domain = -1, err = 0;
|
||||
struct fastrpc_socket *frpc_socket = NULL;
|
||||
struct frpc_transport_session_control *session_control = NULL;
|
||||
|
||||
for (ii = 0; ii < ARRAY_SIZE(configurations); ii++) {
|
||||
cid = configurations[ii].channel_id;
|
||||
remote_domain = configurations[ii].remote_domain;
|
||||
VERIFY(err, remote_domain < MAX_REMOTE_ID);
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
VERIFY(err, VALID_FASTRPC_CID(cid));
|
||||
if (err) {
|
||||
err = -ECHRNG;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
session_control = glist_session_ctrl[cid][remote_domain];
|
||||
if (!session_control)
|
||||
continue;
|
||||
|
||||
frpc_socket = &session_control->frpc_socket;
|
||||
|
||||
if (frpc_socket->sock)
|
||||
sock_release(frpc_socket->sock);
|
||||
|
||||
if (session_control->wq)
|
||||
destroy_workqueue(session_control->wq);
|
||||
|
||||
kfree(frpc_socket->recv_buf);
|
||||
frpc_socket->recv_buf = NULL;
|
||||
frpc_socket->sock = NULL;
|
||||
mutex_destroy(&frpc_socket->socket_mutex);
|
||||
kfree(session_control);
|
||||
glist_session_ctrl[cid][remote_domain] = NULL;
|
||||
}
|
||||
bail:
|
||||
if (err)
|
||||
ADSPRPC_ERR("fastrpc_socket_deinit failed with err %d\n", err);
|
||||
}
|
304
qcom/opensource/dsp-kernel/dsp/cdsp-loader.c
Normal file
304
qcom/opensource/dsp-kernel/dsp/cdsp-loader.c
Normal file
@ -0,0 +1,304 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2012-2014, 2017-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/remoteproc.h>
|
||||
|
||||
#define BOOT_CMD 1
|
||||
#define IMAGE_UNLOAD_CMD 0
|
||||
|
||||
#define CDSP_SUBSYS_DOWN 0
|
||||
#define CDSP_SUBSYS_LOADED 1
|
||||
|
||||
static ssize_t cdsp_boot_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf, size_t count);
|
||||
|
||||
struct cdsp_loader_private {
|
||||
void *pil_h;
|
||||
struct kobject *boot_cdsp_obj;
|
||||
struct attribute_group *attr_group;
|
||||
};
|
||||
|
||||
static struct kobj_attribute cdsp_boot_attribute =
|
||||
__ATTR(boot, 0220, NULL, cdsp_boot_store);
|
||||
|
||||
static struct attribute *attrs[] = {
|
||||
&cdsp_boot_attribute.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static u32 cdsp_state = CDSP_SUBSYS_DOWN;
|
||||
static struct platform_device *cdsp_private;
|
||||
static void cdsp_loader_unload(struct platform_device *pdev);
|
||||
|
||||
static int cdsp_loader_do(struct platform_device *pdev)
|
||||
{
|
||||
struct cdsp_loader_private *priv = NULL;
|
||||
phandle rproc_phandle;
|
||||
int rc = 0, sz = 0;
|
||||
const char *img_name;
|
||||
|
||||
if (!pdev) {
|
||||
pr_err("%s: Platform device null\n", __func__);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!pdev->dev.of_node) {
|
||||
dev_err(&pdev->dev,
|
||||
"%s: Device tree information missing\n", __func__);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
rc = of_property_read_string(pdev->dev.of_node,
|
||||
"qcom,proc-img-to-load",
|
||||
&img_name);
|
||||
if (rc)
|
||||
goto fail;
|
||||
|
||||
if (!strcmp(img_name, "cdsp")) {
|
||||
/* cdsp_state always returns "0".*/
|
||||
if (cdsp_state == CDSP_SUBSYS_DOWN) {
|
||||
priv = platform_get_drvdata(pdev);
|
||||
if (!priv) {
|
||||
dev_err(&pdev->dev,
|
||||
"%s: Private data get failed\n", __func__);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sz = of_property_read_u32(pdev->dev.of_node, "qcom,rproc-handle",
|
||||
&rproc_phandle);
|
||||
if (sz) {
|
||||
pr_err("%s: of_property_read failed, returned value %d\n",
|
||||
__func__, sz);
|
||||
dev_err(&pdev->dev, "error reading rproc phandle\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
priv->pil_h = rproc_get_by_phandle(rproc_phandle);
|
||||
if (!priv->pil_h) {
|
||||
dev_err(&pdev->dev, "rproc not found\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dev_dbg(&pdev->dev, "%s: calling rproc_boot on %s\n",
|
||||
__func__, img_name);
|
||||
rc = rproc_boot(priv->pil_h);
|
||||
if (rc) {
|
||||
dev_err(&pdev->dev, "%s: rproc_boot failed with error %d\n",
|
||||
__func__, rc);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Set the state of the CDSP.*/
|
||||
cdsp_state = CDSP_SUBSYS_LOADED;
|
||||
} else if (cdsp_state == CDSP_SUBSYS_LOADED) {
|
||||
dev_dbg(&pdev->dev,
|
||||
"%s: CDSP state = 0x%x\n", __func__, cdsp_state);
|
||||
}
|
||||
|
||||
dev_dbg(&pdev->dev, "%s: CDSP image is loaded\n", __func__);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fail:
|
||||
if (pdev)
|
||||
dev_err(&pdev->dev,
|
||||
"%s: CDSP image loading failed\n", __func__);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t cdsp_boot_store(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t boot = 0;
|
||||
|
||||
ret = kstrtou32(buf, 0, &boot);
|
||||
if (ret) {
|
||||
pr_debug("%s: invalid arguments for cdsp_loader.\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (boot == BOOT_CMD) {
|
||||
pr_debug("%s: going to call cdsp_loader_do\n", __func__);
|
||||
cdsp_loader_do(cdsp_private);
|
||||
} else if (boot == IMAGE_UNLOAD_CMD) {
|
||||
pr_debug("%s: going to call cdsp_unloader\n", __func__);
|
||||
cdsp_loader_unload(cdsp_private);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void cdsp_loader_unload(struct platform_device *pdev)
|
||||
{
|
||||
struct cdsp_loader_private *priv = NULL;
|
||||
|
||||
priv = platform_get_drvdata(pdev);
|
||||
|
||||
if (!priv)
|
||||
return;
|
||||
|
||||
if (priv->pil_h) {
|
||||
dev_dbg(&pdev->dev, "%s: calling subsystem_put\n", __func__);
|
||||
rproc_shutdown(priv->pil_h);
|
||||
priv->pil_h = NULL;
|
||||
cdsp_state = CDSP_SUBSYS_DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static int cdsp_loader_init_sysfs(struct platform_device *pdev)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
struct cdsp_loader_private *priv = NULL;
|
||||
|
||||
cdsp_private = NULL;
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv) {
|
||||
ret = -ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, priv);
|
||||
|
||||
priv->pil_h = NULL;
|
||||
priv->boot_cdsp_obj = NULL;
|
||||
priv->attr_group = devm_kzalloc(&pdev->dev,
|
||||
sizeof(*(priv->attr_group)),
|
||||
GFP_KERNEL);
|
||||
if (!priv->attr_group) {
|
||||
ret = -ENOMEM;
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
priv->attr_group->attrs = attrs;
|
||||
|
||||
priv->boot_cdsp_obj = kobject_create_and_add("boot_cdsp", kernel_kobj);
|
||||
if (!priv->boot_cdsp_obj) {
|
||||
dev_err(&pdev->dev, "%s: sysfs create and add failed\n",
|
||||
__func__);
|
||||
ret = -ENOMEM;
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
ret = sysfs_create_group(priv->boot_cdsp_obj, priv->attr_group);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "%s: sysfs create group failed %d\n",
|
||||
__func__, ret);
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
cdsp_private = pdev;
|
||||
|
||||
return 0;
|
||||
|
||||
error_return:
|
||||
|
||||
if (priv->boot_cdsp_obj) {
|
||||
kobject_del(priv->boot_cdsp_obj);
|
||||
priv->boot_cdsp_obj = NULL;
|
||||
}
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "%s failed with ret %d\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cdsp_loader_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct cdsp_loader_private *priv = NULL;
|
||||
|
||||
priv = platform_get_drvdata(pdev);
|
||||
|
||||
if (!priv)
|
||||
return 0;
|
||||
|
||||
if (priv->pil_h) {
|
||||
rproc_shutdown(priv->pil_h);
|
||||
priv->pil_h = NULL;
|
||||
cdsp_state = CDSP_SUBSYS_DOWN;
|
||||
}
|
||||
|
||||
if (priv->boot_cdsp_obj) {
|
||||
sysfs_remove_group(priv->boot_cdsp_obj, priv->attr_group);
|
||||
kobject_del(priv->boot_cdsp_obj);
|
||||
priv->boot_cdsp_obj = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdsp_loader_probe(struct platform_device *pdev)
|
||||
{
|
||||
phandle rproc_phandle;
|
||||
struct property *prop = NULL;
|
||||
int size = 0;
|
||||
struct rproc *cdsp = NULL;
|
||||
int ret = 0;
|
||||
|
||||
prop = of_find_property(pdev->dev.of_node, "qcom,rproc-handle", &size);
|
||||
if (!prop) {
|
||||
dev_err(&pdev->dev, "%s: error reading rproc phandle\n", __func__);
|
||||
return -ENOPARAM;
|
||||
}
|
||||
|
||||
rproc_phandle = be32_to_cpup(prop->value);
|
||||
cdsp = rproc_get_by_phandle(rproc_phandle);
|
||||
if (!cdsp) {
|
||||
dev_err(&pdev->dev, "%s: rproc not found\n", __func__);
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
ret = cdsp_loader_init_sysfs(pdev);
|
||||
|
||||
if (ret != 0) {
|
||||
dev_err(&pdev->dev, "%s: Error in initing sysfs\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id cdsp_loader_dt_match[] = {
|
||||
{ .compatible = "qcom,cdsp-loader" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, cdsp_loader_dt_match);
|
||||
|
||||
static struct platform_driver cdsp_loader_driver = {
|
||||
.driver = {
|
||||
.name = "cdsp-loader",
|
||||
.of_match_table = cdsp_loader_dt_match,
|
||||
},
|
||||
.probe = cdsp_loader_probe,
|
||||
.remove = cdsp_loader_remove,
|
||||
};
|
||||
|
||||
static int __init cdsp_loader_init(void)
|
||||
{
|
||||
return platform_driver_register(&cdsp_loader_driver);
|
||||
}
|
||||
module_init(cdsp_loader_init);
|
||||
|
||||
static void __exit cdsp_loader_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&cdsp_loader_driver);
|
||||
}
|
||||
module_exit(cdsp_loader_exit);
|
||||
|
||||
MODULE_DESCRIPTION("CDSP Loader module");
|
||||
MODULE_LICENSE("GPL v2");
|
433
qcom/opensource/dsp-kernel/dsp/fastrpc_trace.h
Normal file
433
qcom/opensource/dsp-kernel/dsp/fastrpc_trace.h
Normal file
@ -0,0 +1,433 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(TRACE_FASTRPC_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define TRACE_FASTRPC_H
|
||||
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM fastrpc
|
||||
|
||||
/*
|
||||
* Path must be relative to location of 'define_trace.h' header in kernel
|
||||
* Define path if not defined in bazel file
|
||||
*/
|
||||
#ifndef DSP_TRACE_INCLUDE_PATH
|
||||
#define DSP_TRACE_INCLUDE_PATH ../../../../vendor/qcom/opensource/dsp-kernel/dsp
|
||||
#endif
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
#define TRACE_INCLUDE_PATH DSP_TRACE_INCLUDE_PATH
|
||||
|
||||
/* Name of trace header file */
|
||||
#undef TRACE_INCLUDE_FILE
|
||||
#define TRACE_INCLUDE_FILE fastrpc_trace
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
|
||||
TRACE_EVENT(fastrpc_transport_send,
|
||||
|
||||
TP_PROTO(int cid, uint64_t smq_ctx,
|
||||
uint64_t ctx, uint32_t handle,
|
||||
uint32_t sc, uint64_t addr, uint64_t size),
|
||||
|
||||
TP_ARGS(cid, smq_ctx, ctx, handle, sc, addr, size),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, smq_ctx)
|
||||
__field(u64, ctx)
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
__field(u64, addr)
|
||||
__field(u64, size)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->smq_ctx = smq_ctx;
|
||||
__entry->ctx = ctx;
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
__entry->addr = addr;
|
||||
__entry->size = size;
|
||||
),
|
||||
|
||||
TP_printk("to cid %d: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x, addr 0x%llx, size %llu",
|
||||
__entry->cid, __entry->smq_ctx, __entry->ctx, __entry->handle,
|
||||
__entry->sc, __entry->addr, __entry->size)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_transport_response,
|
||||
|
||||
TP_PROTO(int cid, uint64_t ctx, int retval,
|
||||
uint32_t rsp_flags, uint32_t early_wake_time),
|
||||
|
||||
TP_ARGS(cid, ctx, retval, rsp_flags, early_wake_time),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, ctx)
|
||||
__field(int, retval)
|
||||
__field(u32, rsp_flags)
|
||||
__field(u32, early_wake_time)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->ctx = ctx;
|
||||
__entry->retval = retval;
|
||||
__entry->rsp_flags = rsp_flags;
|
||||
__entry->early_wake_time = early_wake_time;
|
||||
),
|
||||
|
||||
TP_printk("from cid %d: ctx 0x%llx, retval 0x%x, rsp_flags %u, early_wake_time %u",
|
||||
__entry->cid, __entry->ctx, __entry->retval,
|
||||
__entry->rsp_flags, __entry->early_wake_time)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_context_interrupt,
|
||||
|
||||
TP_PROTO(int cid, uint64_t smq_ctx, uint64_t ctx,
|
||||
uint32_t handle, uint32_t sc),
|
||||
|
||||
TP_ARGS(cid, smq_ctx, ctx, handle, sc),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, smq_ctx)
|
||||
__field(u64, ctx)
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->smq_ctx = smq_ctx;
|
||||
__entry->ctx = ctx;
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
),
|
||||
|
||||
TP_printk("to cid %d: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
|
||||
__entry->cid, __entry->smq_ctx,
|
||||
__entry->ctx, __entry->handle, __entry->sc)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_context_restore,
|
||||
|
||||
TP_PROTO(int cid, uint64_t smq_ctx, uint64_t ctx,
|
||||
uint32_t handle, uint32_t sc),
|
||||
|
||||
TP_ARGS(cid, smq_ctx, ctx, handle, sc),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, smq_ctx)
|
||||
__field(u64, ctx)
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->smq_ctx = smq_ctx;
|
||||
__entry->ctx = ctx;
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
),
|
||||
|
||||
TP_printk("for cid %d: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
|
||||
__entry->cid, __entry->smq_ctx,
|
||||
__entry->ctx, __entry->handle, __entry->sc)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_dma_map,
|
||||
|
||||
TP_PROTO(int cid, int fd, uint64_t phys, size_t size,
|
||||
size_t len, unsigned int attr, int mflags),
|
||||
|
||||
TP_ARGS(cid, fd, phys, size, len, attr, mflags),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(int, fd)
|
||||
__field(u64, phys)
|
||||
__field(size_t, size)
|
||||
__field(size_t, len)
|
||||
__field(unsigned int, attr)
|
||||
__field(int, mflags)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->fd = fd;
|
||||
__entry->phys = phys;
|
||||
__entry->size = size;
|
||||
__entry->len = len;
|
||||
__entry->attr = attr;
|
||||
__entry->mflags = mflags;
|
||||
),
|
||||
|
||||
TP_printk("cid %d, fd %d, phys 0x%llx, size %zu (len %zu), attr 0x%x, flags 0x%x",
|
||||
__entry->cid, __entry->fd, __entry->phys, __entry->size,
|
||||
__entry->len, __entry->attr, __entry->mflags)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_dma_unmap,
|
||||
|
||||
TP_PROTO(int cid, uint64_t phys, size_t size),
|
||||
|
||||
TP_ARGS(cid, phys, size),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, phys)
|
||||
__field(size_t, size)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->phys = phys;
|
||||
__entry->size = size;
|
||||
),
|
||||
|
||||
TP_printk("cid %d, phys 0x%llx, size %zu",
|
||||
__entry->cid, __entry->phys, __entry->size)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_dma_alloc,
|
||||
|
||||
TP_PROTO(int cid, uint64_t phys, size_t size,
|
||||
unsigned long attr, int mflags),
|
||||
|
||||
TP_ARGS(cid, phys, size, attr, mflags),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, phys)
|
||||
__field(size_t, size)
|
||||
__field(unsigned long, attr)
|
||||
__field(int, mflags)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->phys = phys;
|
||||
__entry->size = size;
|
||||
__entry->attr = attr;
|
||||
__entry->mflags = mflags;
|
||||
),
|
||||
|
||||
TP_printk("cid %d, phys 0x%llx, size %zu, attr 0x%lx, flags 0x%x",
|
||||
__entry->cid, __entry->phys, __entry->size,
|
||||
__entry->attr, __entry->mflags)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_dma_free,
|
||||
|
||||
TP_PROTO(int cid, uint64_t phys, size_t size),
|
||||
|
||||
TP_ARGS(cid, phys, size),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, phys)
|
||||
__field(size_t, size)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->phys = phys;
|
||||
__entry->size = size;
|
||||
),
|
||||
|
||||
TP_printk("cid %d, phys 0x%llx, size %zu",
|
||||
__entry->cid, __entry->phys, __entry->size)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_context_complete,
|
||||
|
||||
TP_PROTO(int cid, uint64_t smq_ctx, int retval,
|
||||
uint64_t ctx, uint32_t handle, uint32_t sc),
|
||||
|
||||
TP_ARGS(cid, smq_ctx, retval, ctx, handle, sc),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, cid)
|
||||
__field(u64, smq_ctx)
|
||||
__field(int, retval)
|
||||
__field(u64, ctx)
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->cid = cid;
|
||||
__entry->smq_ctx = smq_ctx;
|
||||
__entry->retval = retval;
|
||||
__entry->ctx = ctx;
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
),
|
||||
|
||||
TP_printk("from cid %d: smq_ctx 0x%llx, retval 0x%x, ctx 0x%llx, handle 0x%x, sc 0x%x",
|
||||
__entry->cid, __entry->smq_ctx, __entry->retval,
|
||||
__entry->ctx, __entry->handle, __entry->sc)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_context_alloc,
|
||||
|
||||
TP_PROTO(uint64_t smq_ctx, uint64_t ctx,
|
||||
uint32_t handle, uint32_t sc),
|
||||
|
||||
TP_ARGS(smq_ctx, ctx, handle, sc),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(u64, smq_ctx)
|
||||
__field(u64, ctx)
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->smq_ctx = smq_ctx;
|
||||
__entry->ctx = ctx;
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
),
|
||||
|
||||
TP_printk("for: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
|
||||
__entry->smq_ctx, __entry->ctx, __entry->handle, __entry->sc)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_context_free,
|
||||
|
||||
TP_PROTO(uint64_t smq_ctx, uint64_t ctx,
|
||||
uint32_t handle, uint32_t sc),
|
||||
|
||||
TP_ARGS(smq_ctx, ctx, handle, sc),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(u64, smq_ctx)
|
||||
__field(u64, ctx)
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->smq_ctx = smq_ctx;
|
||||
__entry->ctx = ctx;
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
),
|
||||
|
||||
TP_printk("for: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
|
||||
__entry->smq_ctx, __entry->ctx, __entry->handle, __entry->sc)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_perf_counters,
|
||||
|
||||
TP_PROTO(uint32_t handle, uint32_t sc,
|
||||
uint64_t count, uint64_t flush, uint64_t map,
|
||||
uint64_t copy, uint64_t link, uint64_t getargs,
|
||||
uint64_t putargs, uint64_t invargs, uint64_t invoke,
|
||||
uint64_t tid),
|
||||
|
||||
TP_ARGS(handle, sc, count, flush, map, copy, link, getargs,
|
||||
putargs, invargs, invoke, tid),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(u32, handle)
|
||||
__field(u32, sc)
|
||||
__field(u64, count)
|
||||
__field(u64, flush)
|
||||
__field(u64, map)
|
||||
__field(u64, copy)
|
||||
__field(u64, link)
|
||||
__field(u64, getargs)
|
||||
__field(u64, putargs)
|
||||
__field(u64, invargs)
|
||||
__field(u64, invoke)
|
||||
__field(u64, tid)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->handle = handle;
|
||||
__entry->sc = sc;
|
||||
__entry->count = count;
|
||||
__entry->flush = flush;
|
||||
__entry->map = map;
|
||||
__entry->copy = copy;
|
||||
__entry->link = link;
|
||||
__entry->getargs = getargs;
|
||||
__entry->putargs = putargs;
|
||||
__entry->invargs = invargs;
|
||||
__entry->invoke = invoke;
|
||||
__entry->tid = tid;
|
||||
),
|
||||
|
||||
TP_printk("for: handle 0x%x, sc 0x%x, count %lld, flush %lld ns, map %lld ns, copy %lld ns, link %lld ns, getargs %lld ns, putargs %lld ns, invargs %lld ns, invoke %lld ns, tid %lld",
|
||||
__entry->handle, __entry->sc, __entry->count,
|
||||
__entry->flush, __entry->map, __entry->copy, __entry->link,
|
||||
__entry->getargs, __entry->putargs, __entry->invargs,
|
||||
__entry->invoke, __entry->tid)
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_msg,
|
||||
TP_PROTO(const char *message),
|
||||
TP_ARGS(message),
|
||||
TP_STRUCT__entry(__string(buf, message)),
|
||||
TP_fast_assign(
|
||||
#if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
|
||||
memcpy(__get_str(buf), (message), (sizeof(message) - 1));
|
||||
__get_str(buf)[sizeof(message) - 1] = '\0';
|
||||
#else
|
||||
if (message)
|
||||
__assign_str_len(buf, message, (sizeof(message) - 1));
|
||||
else
|
||||
memcpy(__get_str(buf), "(null)", sizeof("(null)"));
|
||||
#endif
|
||||
),
|
||||
TP_printk(" %s", __get_str(buf))
|
||||
);
|
||||
|
||||
TRACE_EVENT(fastrpc_dspsignal,
|
||||
|
||||
TP_PROTO(const char *event, uint32_t signal_id,
|
||||
int state, uint32_t timeout),
|
||||
|
||||
TP_ARGS(event, signal_id, state, timeout),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__string(buf, event)
|
||||
__field(u32, signal_id)
|
||||
__field(int, state)
|
||||
__field(u32, timeout)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
#if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
|
||||
memcpy(__get_str(buf), (event), (sizeof(event) - 1));
|
||||
__get_str(buf)[sizeof(event) - 1] = '\0';
|
||||
#else
|
||||
if (event)
|
||||
__assign_str_len(buf, event, (sizeof(event) - 1));
|
||||
else
|
||||
memcpy(__get_str(buf), "(null)", sizeof("(null)"));
|
||||
#endif
|
||||
__entry->signal_id = signal_id;
|
||||
__entry->state = state;
|
||||
__entry->timeout = timeout;
|
||||
),
|
||||
|
||||
TP_printk("%s for sig id %u, state %d, timeout %u",
|
||||
__get_str(buf), __entry->signal_id, __entry->state, __entry->timeout)
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
9
qcom/opensource/dsp-kernel/dsp_kernel_board.mk
Normal file
9
qcom/opensource/dsp-kernel/dsp_kernel_board.mk
Normal file
@ -0,0 +1,9 @@
|
||||
ifneq ($(TARGET_KERNEL_DLKM_DISABLE), true)
|
||||
ifneq ($(ENABLE_HYP), true)
|
||||
ifeq ($(call is-board-platform-in-list,$(TARGET_BOARD_PLATFORM)),true)
|
||||
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/frpc-adsprpc.ko
|
||||
#BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/frpc-trusted-adsprpc.ko
|
||||
BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/cdsp-loader.ko
|
||||
endif
|
||||
endif
|
||||
endif
|
7
qcom/opensource/dsp-kernel/dsp_kernel_product.mk
Normal file
7
qcom/opensource/dsp-kernel/dsp_kernel_product.mk
Normal file
@ -0,0 +1,7 @@
|
||||
ifneq ($(TARGET_KERNEL_DLKM_DISABLE), true)
|
||||
ifneq ($(ENABLE_HYP), true)
|
||||
PRODUCT_PACKAGES += frpc-adsprpc.ko
|
||||
#PRODUCT_PACKAGES += frpc_trusted-adsprpc.ko
|
||||
PRODUCT_PACKAGES += cdsp-loader.ko
|
||||
endif
|
||||
endif
|
158
qcom/opensource/dsp-kernel/include/linux/fastrpc.h
Normal file
158
qcom/opensource/dsp-kernel/include/linux/fastrpc.h
Normal file
@ -0,0 +1,158 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_fastrpc_H
|
||||
#define __LINUX_fastrpc_H
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#define FASTRPC_DRV_NAME_SIZE 32
|
||||
|
||||
enum fastrpc_driver_status {
|
||||
FASTRPC_PROC_DOWN = 0,
|
||||
};
|
||||
enum fastrpc_driver_invoke_nums {
|
||||
FASTRPC_DEV_MAP_DMA = 1,
|
||||
FASTRPC_DEV_UNMAP_DMA,
|
||||
FASTRPC_DEV_GET_HLOS_PID,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct fastrpc_dev_map_dma - fastrpc dma buffer map structure
|
||||
* @buf : Shared DMA buf object
|
||||
* @attrs : Attributes to map buffer on IOMMU
|
||||
* @size : Size of DMA buffer
|
||||
* @v_dsp_addr : Virtual addr of DSP after mapping the buffer on DSP
|
||||
*/
|
||||
struct fastrpc_dev_map_dma {
|
||||
struct dma_buf *buf;
|
||||
uint32_t attrs;
|
||||
size_t size;
|
||||
uint64_t v_dsp_addr;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct fastrpc_dev_unmap_dma - fastrpc dma buffer unmap structure
|
||||
* @buf : Shared DMA buf object
|
||||
* @size : Size of DMA buffer
|
||||
*/
|
||||
struct fastrpc_dev_unmap_dma {
|
||||
struct dma_buf *buf;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct fastrpc_dev_get_hlos_pid - fastrpc dma buffer unmap structure
|
||||
* @hlos_pid : HLOS PID of attached device
|
||||
*/
|
||||
struct fastrpc_dev_get_hlos_pid {
|
||||
int hlos_pid;
|
||||
};
|
||||
|
||||
/**
|
||||
* fastrpc_device - device that belong to the fastrpc bus
|
||||
* @hn: Head node to add to fastrpc device list
|
||||
* @dev: the device struct
|
||||
* @handle: handle of the process
|
||||
* @fl: process file of fastrpc device
|
||||
* @dev_close: flag to determine if device is closed
|
||||
* @refs: reference count of drivers using the device
|
||||
*/
|
||||
struct fastrpc_device {
|
||||
struct hlist_node hn;
|
||||
struct device dev;
|
||||
int handle;
|
||||
struct fastrpc_file *fl;
|
||||
bool dev_close;
|
||||
unsigned int refs;
|
||||
};
|
||||
|
||||
#define to_fastrpc_device(d) container_of(d, struct fastrpc_device, dev)
|
||||
|
||||
/**
|
||||
* struct fastrpc_driver - fastrpc driver struct
|
||||
* @hn: Node to add to fastrpc driver list
|
||||
* @driver: underlying device driver
|
||||
* @device: device that is matching to driver
|
||||
* @handle: handle of the process
|
||||
* @create: 0 to attach, 1 to create process
|
||||
* @probe: invoked when a matching fastrpc device (i.e. device) is found
|
||||
* @callback: invoked when there is a status change in the process
|
||||
*/
|
||||
struct fastrpc_driver {
|
||||
struct hlist_node hn;
|
||||
struct device_driver driver;
|
||||
struct device *device;
|
||||
int handle;
|
||||
int create;
|
||||
int (*probe)(struct fastrpc_device *dev);
|
||||
int (*callback)(struct fastrpc_device *dev,
|
||||
enum fastrpc_driver_status status);
|
||||
};
|
||||
|
||||
#define to_fastrpc_driver(x) container_of((x), struct fastrpc_driver, driver)
|
||||
|
||||
//#if IS_ENABLED(CONFIG_MSM_ADSPRPC) || IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
|
||||
/**
|
||||
* function fastrpc_driver_register - Register fastrpc driver
|
||||
* @drv: Initialized fastrpc driver structure pointer
|
||||
*/
|
||||
int fastrpc_driver_register(struct fastrpc_driver *drv);
|
||||
|
||||
/**
|
||||
* function fastrpc_driver_unregister - Un-register fastrpc driver
|
||||
* @drv: fastrpc driver structure pointer
|
||||
*/
|
||||
void fastrpc_driver_unregister(struct fastrpc_driver *drv);
|
||||
|
||||
/**
|
||||
* function fastrpc_driver_invoke - fastrpc driver invocation function
|
||||
* Invoke fastrpc driver using fastrpc_device received in probe of registration
|
||||
* @dev : Device received in probe of registration.
|
||||
* @invoke_num : Invocation number of operation,
|
||||
* one of "fastrpc_driver_invoke_nums"
|
||||
* @invoke_param: Address of invocation structure corresponding to invoke_num
|
||||
* (struct fastrpc_dev_map_dma *) for FASTRPC_DEV_MAP_DMA
|
||||
* (struct fastrpc_dev_unmap_dma *) for FASTRPC_DEV_UNMAP_DMA.
|
||||
*/
|
||||
long fastrpc_driver_invoke(struct fastrpc_device *dev,
|
||||
enum fastrpc_driver_invoke_nums invoke_num, unsigned long invoke_param);
|
||||
|
||||
/*
|
||||
#else
|
||||
static inline int fastrpc_driver_register(struct fastrpc_driver *drv)
|
||||
{ return 0; }
|
||||
|
||||
static inline void fastrpc_driver_unregister(struct fastrpc_driver *drv)
|
||||
{ return; }
|
||||
|
||||
static inline long fastrpc_driver_invoke(struct fastrpc_device *dev,
|
||||
enum fastrpc_driver_invoke_nums invoke_num, unsigned long invoke_param)
|
||||
{ return 0; }
|
||||
#endif
|
||||
*/
|
||||
/**
|
||||
* module_fastrpc_driver() - Helper macro for registering a fastrpc driver
|
||||
* @__fastrpc_driver: fastrpc_driver struct
|
||||
*
|
||||
* Helper macro for fastrpc drivers which do not do anything special in module
|
||||
* init/exit. This eliminates a lot of boilerplate code. Each module may only
|
||||
* use this macro once, and calling it replaces module_init and module_exit.
|
||||
*/
|
||||
#define module_fastrpc_driver(__fastrpc_driver) \
|
||||
static int __init __fastrpc_driver##_init(void) \
|
||||
{ \
|
||||
return fastrpc_driver_register(&(__fastrpc_driver)); \
|
||||
} \
|
||||
module_init(__fastrpc_driver##_init); \
|
||||
static void __exit __fastrpc_driver##_exit(void) \
|
||||
{ \
|
||||
fastrpc_driver_unregister(&(__fastrpc_driver)); \
|
||||
} \
|
||||
module_exit(__fastrpc_driver##_exit)
|
||||
|
||||
#endif /* __LINUX_fastrpc_H */
|
284
qcom/opensource/dsp-kernel/include/uapi/fastrpc_shared.h
Normal file
284
qcom/opensource/dsp-kernel/include/uapi/fastrpc_shared.h
Normal file
@ -0,0 +1,284 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
|
||||
/*
|
||||
* Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef FASTRPC_IOCTL_H
|
||||
#define FASTRPC_IOCTL_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#define remote_arg_t union remote_arg
|
||||
/* Map and unmap IOCTL methods reserved memory size for future extensions */
|
||||
#define MAP_RESERVED_NUM (14)
|
||||
#define UNMAP_RESERVED_NUM (10)
|
||||
|
||||
#define FASTRPC_IOCTL_INVOKE _IOWR('R', 1, struct fastrpc_ioctl_invoke)
|
||||
#define FASTRPC_IOCTL_MMAP _IOWR('R', 2, struct fastrpc_ioctl_mmap)
|
||||
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 3, struct fastrpc_ioctl_munmap)
|
||||
#define FASTRPC_IOCTL_MMAP_64 _IOWR('R', 14, struct fastrpc_ioctl_mmap_64)
|
||||
#define FASTRPC_IOCTL_MUNMAP_64 _IOWR('R', 15, struct fastrpc_ioctl_munmap_64)
|
||||
#define FASTRPC_IOCTL_INVOKE_FD _IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
|
||||
#define FASTRPC_IOCTL_SETMODE _IOWR('R', 5, uint32_t)
|
||||
#define FASTRPC_IOCTL_INIT _IOWR('R', 6, struct fastrpc_ioctl_init)
|
||||
#define FASTRPC_IOCTL_INVOKE_ATTRS \
|
||||
_IOWR('R', 7, struct fastrpc_ioctl_invoke_attrs)
|
||||
#define FASTRPC_IOCTL_GETINFO _IOWR('R', 8, uint32_t)
|
||||
//#define FASTRPC_IOCTL_GETPERF _IOWR('R', 9, struct fastrpc_ioctl_perf)
|
||||
#define FASTRPC_IOCTL_INIT_ATTRS _IOWR('R', 10, struct fastrpc_ioctl_init_attrs)
|
||||
#define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
|
||||
#define FASTRPC_IOCTL_CONTROL _IOWR('R', 12, struct fastrpc_ioctl_control)
|
||||
#define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
|
||||
#define FASTRPC_IOCTL_GET_DSP_INFO \
|
||||
_IOWR('R', 17, struct fastrpc_ioctl_capability)
|
||||
#define FASTRPC_IOCTL_INVOKE2 _IOWR('R', 18, struct fastrpc_ioctl_invoke2)
|
||||
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 19, struct fastrpc_ioctl_mem_map)
|
||||
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 20, struct fastrpc_ioctl_mem_unmap)
|
||||
#define FASTRPC_IOCTL_INVOKE_PERF \
|
||||
_IOWR('R', 21, struct fastrpc_ioctl_invoke_perf)
|
||||
#define FASTRPC_IOCTL_NOTIF_RSP \
|
||||
_IOWR('R', 22, struct fastrpc_ioctl_notif_rsp)
|
||||
#define FASTRPC_IOCTL_DSPSIGNAL_CREATE _IOWR('R', 23, struct fastrpc_ioctl_dspsignal_create)
|
||||
#define FASTRPC_IOCTL_DSPSIGNAL_DESTROY _IOWR('R', 24, struct fastrpc_ioctl_dspsignal_destroy)
|
||||
#define FASTRPC_IOCTL_DSPSIGNAL_SIGNAL _IOWR('R', 25, struct fastrpc_ioctl_dspsignal_signal)
|
||||
#define FASTRPC_IOCTL_DSPSIGNAL_WAIT _IOWR('R', 26, struct fastrpc_ioctl_dspsignal_wait)
|
||||
#define FASTRPC_IOCTL_DSPSIGNAL_CANCEL_WAIT \
|
||||
_IOWR('R', 27, struct fastrpc_ioctl_dspsignal_cancel_wait)
|
||||
|
||||
struct fastrpc_mem_map {
|
||||
int fd; /* ion fd */
|
||||
int offset; /* buffer offset */
|
||||
uint32_t flags; /* flags defined in enum fastrpc_map_flags */
|
||||
int attrs; /* buffer attributes used for SMMU mapping */
|
||||
uintptr_t vaddrin; /* buffer virtual address */
|
||||
size_t length; /* buffer length */
|
||||
uint64_t vaddrout; /* [out] remote virtual address */
|
||||
};
|
||||
|
||||
struct fastrpc_mem_unmap {
|
||||
int fd; /* ion fd */
|
||||
uint64_t vaddr; /* remote process (dsp) virtual address */
|
||||
size_t length; /* buffer size */
|
||||
};
|
||||
|
||||
struct fastrpc_ctrl_latency {
|
||||
uint32_t enable; /* latency control enable */
|
||||
uint32_t latency; /* latency request in us */
|
||||
};
|
||||
|
||||
struct fastrpc_ctrl_kalloc {
|
||||
uint32_t kalloc_support; /* Remote memory allocation from kernel */
|
||||
};
|
||||
|
||||
struct fastrpc_ctrl_wakelock {
|
||||
uint32_t enable; /* wakelock control enable */
|
||||
};
|
||||
|
||||
struct fastrpc_ctrl_pm {
|
||||
uint32_t timeout; /* timeout(in ms) for PM to keep system awake */
|
||||
};
|
||||
|
||||
struct fastrpc_ctrl_smmu {
|
||||
uint32_t sharedcb; /* Set to SMMU share context bank */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke {
|
||||
uint32_t handle; /* remote handle */
|
||||
uint32_t sc; /* scalars describing the data */
|
||||
remote_arg_t *pra; /* remote arguments list */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke_fd {
|
||||
struct fastrpc_ioctl_invoke inv;
|
||||
int *fds; /* fd list */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke_attrs {
|
||||
struct fastrpc_ioctl_invoke inv;
|
||||
int *fds; /* fd list */
|
||||
unsigned int *attrs; /* attribute list */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke_crc {
|
||||
struct fastrpc_ioctl_invoke inv;
|
||||
int *fds; /* fd list */
|
||||
unsigned int *attrs; /* attribute list */
|
||||
unsigned int *crc;
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke_perf {
|
||||
struct fastrpc_ioctl_invoke inv;
|
||||
int *fds;
|
||||
unsigned int *attrs;
|
||||
unsigned int *crc;
|
||||
uint64_t *perf_kernel;
|
||||
uint64_t *perf_dsp;
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke_async {
|
||||
struct fastrpc_ioctl_invoke inv;
|
||||
int *fds; /* fd list */
|
||||
unsigned int *attrs; /* attribute list */
|
||||
unsigned int *crc;
|
||||
uint64_t *perf_kernel;
|
||||
uint64_t *perf_dsp;
|
||||
struct fastrpc_async_job *job; /* async job*/
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke_async_no_perf {
|
||||
struct fastrpc_ioctl_invoke inv;
|
||||
int *fds; /* fd list */
|
||||
unsigned int *attrs; /* attribute list */
|
||||
unsigned int *crc;
|
||||
struct fastrpc_async_job *job; /* async job*/
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_async_response {
|
||||
uint64_t jobid;/* job id generated by user */
|
||||
int result; /* result from DSP */
|
||||
uint64_t *perf_kernel;
|
||||
uint64_t *perf_dsp;
|
||||
uint32_t handle;
|
||||
uint32_t sc;
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_notif_rsp {
|
||||
int domain; /* Domain of User PD */
|
||||
int session; /* Session ID of User PD */
|
||||
uint32_t status; /* Status of the process */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_invoke2 {
|
||||
uint32_t req; /* type of invocation request */
|
||||
uintptr_t invparam; /* invocation request param */
|
||||
uint32_t size; /* size of invocation param */
|
||||
int err; /* reserved */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_init {
|
||||
uint32_t flags; /* one of FASTRPC_INIT_* macros */
|
||||
uintptr_t file; /* pointer to elf file */
|
||||
uint32_t filelen; /* elf file length */
|
||||
int32_t filefd; /* ION fd for the file */
|
||||
uintptr_t mem; /* mem for the PD */
|
||||
uint32_t memlen; /* mem length */
|
||||
int32_t memfd; /* ION fd for the mem */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_init_attrs {
|
||||
struct fastrpc_ioctl_init init;
|
||||
int attrs;
|
||||
unsigned int siglen;
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_munmap {
|
||||
uintptr_t vaddrout; /* address to unmap */
|
||||
size_t size; /* size */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_munmap_64 {
|
||||
uint64_t vaddrout; /* address to unmap */
|
||||
size_t size; /* size */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_mmap {
|
||||
int fd; /* ion fd */
|
||||
uint32_t flags; /* flags for dsp to map with */
|
||||
uintptr_t vaddrin; /* optional virtual address */
|
||||
size_t size; /* size */
|
||||
uintptr_t vaddrout; /* dsps virtual address */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_mmap_64 {
|
||||
int fd; /* ion fd */
|
||||
uint32_t flags; /* flags for dsp to map with */
|
||||
uint64_t vaddrin; /* optional virtual address */
|
||||
size_t size; /* size */
|
||||
uint64_t vaddrout; /* dsps virtual address */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_munmap_fd {
|
||||
int fd; /* fd */
|
||||
uint32_t flags; /* control flags */
|
||||
uintptr_t va; /* va */
|
||||
ssize_t len; /* length */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_dspsignal_create {
|
||||
uint32_t signal_id; /* Signal ID */
|
||||
uint32_t flags; /* Flags, currently unused */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_dspsignal_destroy {
|
||||
uint32_t signal_id; /* Signal ID */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_dspsignal_signal {
|
||||
uint32_t signal_id; /* Signal ID */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_dspsignal_wait {
|
||||
uint32_t signal_id; /* Signal ID */
|
||||
uint32_t timeout_usec; /* Timeout in microseconds. UINT32_MAX for an infinite wait */
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_dspsignal_cancel_wait {
|
||||
uint32_t signal_id; /* Signal ID */
|
||||
};
|
||||
|
||||
/* map memory to DSP device */
|
||||
struct fastrpc_ioctl_mem_map {
|
||||
int version; /* Initial version 0 */
|
||||
union {
|
||||
struct fastrpc_mem_map m;
|
||||
int reserved[MAP_RESERVED_NUM];
|
||||
};
|
||||
};
|
||||
|
||||
/* unmap memory to DSP device */
|
||||
struct fastrpc_ioctl_mem_unmap {
|
||||
int version; /* Initial version 0 */
|
||||
union {
|
||||
struct fastrpc_mem_unmap um;
|
||||
int reserved[UNMAP_RESERVED_NUM];
|
||||
};
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_control {
|
||||
uint32_t req;
|
||||
union {
|
||||
struct fastrpc_ctrl_latency lp;
|
||||
struct fastrpc_ctrl_kalloc kalloc;
|
||||
struct fastrpc_ctrl_wakelock wp;
|
||||
struct fastrpc_ctrl_pm pm;
|
||||
struct fastrpc_ctrl_smmu smmu;
|
||||
};
|
||||
};
|
||||
|
||||
struct fastrpc_ioctl_capability {
|
||||
uint32_t domain;
|
||||
uint32_t attribute_ID;
|
||||
uint32_t capability;
|
||||
};
|
||||
|
||||
union fastrpc_ioctl_param {
|
||||
struct fastrpc_ioctl_invoke_async inv;
|
||||
struct fastrpc_ioctl_mem_map mem_map;
|
||||
struct fastrpc_ioctl_mem_unmap mem_unmap;
|
||||
struct fastrpc_ioctl_mmap mmap;
|
||||
struct fastrpc_ioctl_mmap_64 mmap64;
|
||||
struct fastrpc_ioctl_munmap munmap;
|
||||
struct fastrpc_ioctl_munmap_64 munmap64;
|
||||
struct fastrpc_ioctl_munmap_fd munmap_fd;
|
||||
struct fastrpc_ioctl_init_attrs init;
|
||||
struct fastrpc_ioctl_control cp;
|
||||
struct fastrpc_ioctl_capability cap;
|
||||
struct fastrpc_ioctl_invoke2 inv2;
|
||||
struct fastrpc_ioctl_dspsignal_signal sig;
|
||||
struct fastrpc_ioctl_dspsignal_wait wait;
|
||||
struct fastrpc_ioctl_dspsignal_create cre;
|
||||
struct fastrpc_ioctl_dspsignal_destroy des;
|
||||
struct fastrpc_ioctl_dspsignal_cancel_wait canc;
|
||||
};
|
||||
|
||||
#endif
|
4
qcom/opensource/dsp-kernel/product.mk
Normal file
4
qcom/opensource/dsp-kernel/product.mk
Normal file
@ -0,0 +1,4 @@
|
||||
ifneq ($(ENABLE_HYP), true)
|
||||
PRODUCT_PACKAGES += frpc-adsprpc.ko
|
||||
#PRODUCT_PACKAGES += cdsp-loader.ko
|
||||
endif
|
Loading…
Reference in New Issue
Block a user