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

Commit 55aad62b authored by Manoj Prabhu B's avatar Manoj Prabhu B
Browse files

diag: Send PASSTHRU control packet after SSR



Add support to send the passthru control packet after ssr to update
prior hardware acceleration configuration of peripheral.

Change-Id: I58122499f4a6f9208e3a217c1602152230f18935
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
parent 75d4a367
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3201,7 +3201,8 @@ void diag_send_updates_peripheral(uint8_t peripheral)
				driver->real_time_mode[DIAG_LOCAL_PROC]);
		diag_send_peripheral_buffering_mode(
					&driver->buffering_mode[peripheral]);

		if (P_FMASK_DIAGID_V2(peripheral))
			diag_send_hw_accel_status(peripheral);
		/*
		 * Clear mask_update variable afer updating
		 * logging masks to peripheral.
+8 −1
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@
#define DIAG_GET_TIME_API	0x21B
#define DIAG_SET_TIME_API	0x21C
#define DIAG_GET_DIAG_ID	0x222
#define DIAG_HW_ACCEL_CMD	0x224
#define DIAG_FEATURE_QUERY	0x225
#define DIAG_SWITCH_COMMAND	0x081B
#define DIAG_BUFFERING_MODE	0x080C
@@ -262,6 +263,9 @@ do { \
#define DIAGIDV2_STATUS(f_index)	\
	driver->diagid_v2_status[f_index]

#define P_FMASK_DIAGID_V2(peripheral)	\
	driver->feature[peripheral].diagid_v2_feature_mask

/*
 * Number of stm processors includes all the peripherals and
 * apps.Added 1 below to indicate apps
@@ -891,6 +895,7 @@ struct diagchar_dev {
	uint8_t uses_time_api;
	uint32_t diagid_v2_feature[DIAGID_V2_FEATURE_COUNT];
	uint32_t diagid_v2_status[DIAGID_V2_FEATURE_COUNT];
	uint32_t diag_hw_accel[DIAGID_V2_FEATURE_COUNT];
};

extern struct diagchar_dev *driver;
@@ -930,10 +935,12 @@ uint8_t diag_search_diagid_by_pd(uint8_t pd_val,
void diag_record_stats(int type, int flag);

struct diag_md_session_t *diag_md_session_get_pid(int pid);
int diag_map_hw_accel_type_ver(uint8_t hw_accel_type, uint8_t hw_accel_ver);
struct diag_md_session_t *diag_md_session_get_peripheral(int dev_id,
							uint8_t peripheral);
int diag_md_session_match_pid_peripheral(int proc, int pid,
					uint8_t peripheral);
int diag_map_hw_accel_type_ver(uint8_t hw_accel_type, uint8_t hw_accel_ver);
void diag_map_index_to_hw_accel(uint8_t index, uint8_t *hw_accel_type,
			uint8_t *hw_accel_ver);

#endif
+22 −3
Original line number Diff line number Diff line
@@ -2423,8 +2423,27 @@ static int diag_ioctl_query_pd_logging(struct diag_logging_mode_param_t *param)
	return ret;
}

int diag_map_hw_accel_type_ver(
	uint8_t hw_accel_type, uint8_t hw_accel_ver)
void diag_map_index_to_hw_accel(uint8_t index,
	uint8_t *hw_accel_type, uint8_t *hw_accel_ver)
{
	*hw_accel_type = 0;
	*hw_accel_ver = 0;

	switch (index) {
	case DIAG_HW_ACCEL_TYPE_STM:
		*hw_accel_type = DIAG_HW_ACCEL_TYPE_STM;
		*hw_accel_ver = DIAG_HW_ACCEL_VER_MIN;
		break;
	case DIAG_HW_ACCEL_TYPE_ATB:
		*hw_accel_type = DIAG_HW_ACCEL_TYPE_ATB;
		*hw_accel_ver = DIAG_HW_ACCEL_VER_MIN;
		break;
	default:
		break;
	}
}

int diag_map_hw_accel_type_ver(uint8_t hw_accel_type, uint8_t hw_accel_ver)
{
	int index = -EINVAL;

@@ -2483,7 +2502,7 @@ static int diag_ioctl_query_pd_featuremask(
static int diag_ioctl_passthru_control_func(
	struct diag_hw_accel_cmd_req_t *req_params)
{
	return diag_send_passtru_ctrl_pkt(req_params);
	return diag_send_passthru_ctrl_pkt(req_params);
}

static void diag_query_session_pid(struct diag_query_pid_t *param)
+1 −0
Original line number Diff line number Diff line
@@ -1043,6 +1043,7 @@ static void diag_init_apps_feature(void)
	driver->apps_feature = 0;

	SET_APPS_FEATURE(driver, F_DIAG_EVENT_REPORT);
	SET_APPS_FEATURE(driver, F_DIAG_HW_ACCELERATION);
}

void diag_send_error_rsp(unsigned char *buf, int len,
+70 −4
Original line number Diff line number Diff line
@@ -802,8 +802,8 @@ void process_diagid_v2_feature_mask(uint32_t diag_id,
		uint32_t pd_feature_mask)
{
	int i = 0;
	uint32_t diagid_mask_bit = 0;
	uint32_t feature_id_mask = 0;
	uint32_t diagid_mask_bit = 0, feature_id_mask = 0;
	uint8_t hw_accel_type = 0, hw_accel_ver = 0;

	if (!pd_feature_mask)
		return;
@@ -814,6 +814,10 @@ void process_diagid_v2_feature_mask(uint32_t diag_id,
		if (feature_id_mask)
			driver->diagid_v2_feature[i] |= diagid_mask_bit;
		feature_id_mask = 0;

		diag_map_index_to_hw_accel(i, &hw_accel_type, &hw_accel_ver);
		if (hw_accel_type && hw_accel_ver)
			driver->diag_hw_accel[i] = 1;
	}
	mutex_unlock(&driver->diagid_v2_mutex);
}
@@ -838,7 +842,7 @@ static void process_diagid(uint8_t *buf, uint32_t len,
		return;

	diagid_v2_feature_mask =
		driver->feature[peripheral].diagid_v2_feature_mask;
		P_FMASK_DIAGID_V2(peripheral);

	if (len < sizeof(struct diag_ctrl_diagid_header)) {
		pr_err("diag: Invalid control pkt len(%d) from peripheral: %d to parse packet header\n",
@@ -1497,6 +1501,66 @@ int diag_send_peripheral_buffering_mode(struct diag_buffering_mode_t *params)
	return err;
}

void diag_send_hw_accel_status(uint8_t peripheral)
{
	struct diag_hw_accel_cmd_req_t req_params;
	struct diagfwd_info *fwd_info = NULL;
	struct diag_id_info *diagid_struct = NULL;
	uint32_t diagid_mask_bit = 0;
	uint8_t hw_accel_type = 0, hw_accel_ver = 0;
	int feature = 0, pd = 0;

	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"Send HW Acceleration Enabled status to peripheral: %d\n",
		peripheral);

	fwd_info = &peripheral_info[TYPE_CNTL][peripheral];
	if (!fwd_info) {
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"Error return for peripheral: %d\n", peripheral);
		return;
	}

	for (feature = 0; feature < DIAGID_V2_FEATURE_COUNT - 1; feature++) {
		for (pd = 0; pd <= MAX_PERIPHERAL_UPD; pd++) {
			if (!pd) {
				diagid_struct = &fwd_info->root_diag_id;
				diagid_mask_bit =
					1 << (diagid_struct->diagid_val - 1);
			}
			if (!diagid_mask_bit)
				continue;
			if (driver->diagid_v2_feature[feature] &
				driver->diagid_v2_status[feature] &
				diagid_mask_bit) {
				diag_map_index_to_hw_accel(feature,
					&hw_accel_type, &hw_accel_ver);
				req_params.header.cmd_code =
					DIAG_CMD_DIAG_SUBSYS;
				req_params.header.subsys_id =
					DIAG_SS_DIAG;
				req_params.header.subsys_cmd_code =
					DIAG_HW_ACCEL_CMD;
				req_params.version = 1;
				req_params.reserved = 0;
				req_params.operation = DIAG_HW_ACCEL_OP_ENABLE;
				req_params.op_req.hw_accel_type = hw_accel_type;
				req_params.op_req.hw_accel_ver = hw_accel_ver;
				req_params.op_req.diagid_mask = diagid_mask_bit;
				DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
					"Sending passthru packet for diag_id: %d\n",
					diagid_struct->diagid_val);
				if (P_FMASK_DIAGID_V2(peripheral))
					diag_send_passthru_ctrl_pkt(
						&req_params);
			}
			diagid_struct = &fwd_info->upd_diag_id[pd];
			diagid_mask_bit = 0;
			diagid_mask_bit = 1 << (diagid_struct->diagid_val - 1);
		}
	}
}

int diag_send_stm_state(uint8_t peripheral, uint8_t stm_control_data)
{
	struct diag_ctrl_msg_stm stm_msg;
@@ -1747,7 +1811,7 @@ int diag_send_buffering_wm_values(uint8_t peripheral,
	return err;
}

int diag_send_passtru_ctrl_pkt(struct diag_hw_accel_cmd_req_t *req_params)
int diag_send_passthru_ctrl_pkt(struct diag_hw_accel_cmd_req_t *req_params)
{
	struct diag_ctrl_passthru ctrl_pkt;
	int f_index = -1, err = 0;
@@ -1805,6 +1869,8 @@ int diag_send_passtru_ctrl_pkt(struct diag_hw_accel_cmd_req_t *req_params)
		sizeof(ctrl_pkt.diagid_mask) + sizeof(ctrl_pkt.hw_accel_type) +
		sizeof(ctrl_pkt.hw_accel_ver) + sizeof(ctrl_pkt.control_data);
	for (i = 0; i < NUM_PERIPHERALS; i++) {
		if (!P_FMASK_DIAGID_V2(i))
			continue;
		err = diagfwd_write(i, TYPE_CNTL, &ctrl_pkt, sizeof(ctrl_pkt));
		if (err && err != -ENODEV) {
			pr_err("diag: Unable to send PASSTHRU ctrl packet to peripheral %d, err: %d\n",
Loading