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

Commit dc880a12 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Support dynamic switch between USB and PCIe interface"

parents 26f7ba2c 10ced020
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -3,6 +3,5 @@ obj-$(CONFIG_DIAGFWD_BRIDGE_CODE) += diagfwd_bridge.o
obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diagfwd_hsic.o
obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diagfwd_smux.o
obj-$(CONFIG_MSM_MHI) += diagfwd_mhi.o
obj-$(CONFIG_DIAG_OVER_PCIE) += diag_pcie.o
obj-$(CONFIG_DIAG_USES_SMD) += diagfwd_smd.o
diagchar-objs := diagchar_core.o diagchar_hdlc.o diagfwd.o diagfwd_glink.o diagfwd_peripheral.o diagfwd_socket.o diag_mux.o diag_memorydevice.o diag_usb.o diagmem.o diagfwd_cntl.o diag_dci.o diag_masks.o diag_debugfs.o
diagchar-objs := diagchar_core.o diagchar_hdlc.o diagfwd.o diagfwd_glink.o diagfwd_peripheral.o diagfwd_socket.o diag_mux.o diag_memorydevice.o diag_usb.o diagmem.o diagfwd_cntl.o diag_dci.o diag_masks.o diag_debugfs.o diag_pcie.o
 No newline at end of file
+1 −9
Original line number Diff line number Diff line
/* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -44,9 +44,7 @@ static struct dentry *diag_dbgfs_dent;
static int diag_dbgfs_table_index;
static int diag_dbgfs_mempool_index;
static int diag_dbgfs_usbinfo_index;
#ifdef CONFIG_DIAG_OVER_PCIE
static int diag_dbgfs_pcieinfo_index;
#endif
static int diag_dbgfs_smdinfo_index;
static int diag_dbgfs_socketinfo_index;
static int diag_dbgfs_glinkinfo_index;
@@ -485,7 +483,6 @@ static ssize_t diag_dbgfs_read_usbinfo(struct file *file, char __user *ubuf,
	return ret;
}

#ifdef CONFIG_DIAG_OVER_PCIE
static ssize_t diag_dbgfs_read_pcieinfo(struct file *file, char __user *ubuf,
				       size_t count, loff_t *ppos)
{
@@ -545,7 +542,6 @@ static ssize_t diag_dbgfs_read_pcieinfo(struct file *file, char __user *ubuf,
	kfree(buf);
	return ret;
}
#endif

#ifdef CONFIG_DIAG_USES_SMD
static ssize_t diag_dbgfs_read_smdinfo(struct file *file, char __user *ubuf,
@@ -1146,11 +1142,9 @@ const struct file_operations diag_dbgfs_usbinfo_ops = {
	.read = diag_dbgfs_read_usbinfo,
};

#ifdef CONFIG_DIAG_OVER_PCIE
const struct file_operations diag_dbgfs_pcieinfo_ops = {
	.read = diag_dbgfs_read_pcieinfo,
};
#endif

const struct file_operations diag_dbgfs_dcistats_ops = {
	.read = diag_dbgfs_read_dcistats,
@@ -1211,12 +1205,10 @@ int diag_debugfs_init(void)
	if (!entry)
		goto err;

#ifdef CONFIG_DIAG_OVER_PCIE
	entry = debugfs_create_file("pcieinfo", 0444, diag_dbgfs_dent, 0,
				    &diag_dbgfs_pcieinfo_ops);
	if (!entry)
		goto err;
#endif

	entry = debugfs_create_file("dci_stats", 0444, diag_dbgfs_dent, 0,
				    &diag_dbgfs_dcistats_ops);
+24 −29
Original line number Diff line number Diff line
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -31,12 +31,6 @@
#include "diagfwd_peripheral.h"
#include "diag_ipc_logging.h"

#ifdef CONFIG_DIAG_OVER_PCIE
#define diag_mux_register_ops diag_pcie_register_ops
#else
#define diag_mux_register_ops diag_usb_register_ops
#endif

struct diag_mux_state_t *diag_mux;
static struct diag_logger_t usb_logger;
static struct diag_logger_t md_logger;
@@ -58,7 +52,6 @@ static struct diag_logger_ops md_log_ops = {
	.close_peripheral = diag_md_close_peripheral,
};

#ifdef CONFIG_DIAG_OVER_PCIE
static struct diag_logger_ops pcie_log_ops = {
	.open = diag_pcie_connect_all,
	.close = diag_pcie_disconnect_all,
@@ -66,7 +59,6 @@ static struct diag_logger_ops pcie_log_ops = {
	.write = diag_pcie_write,
	.close_peripheral = NULL
};
#endif

int diag_mux_init(void)
{
@@ -82,18 +74,16 @@ int diag_mux_init(void)
	md_logger.mode = DIAG_MEMORY_DEVICE_MODE;
	md_logger.log_ops = &md_log_ops;
	diag_md_init();
#ifdef CONFIG_DIAG_OVER_PCIE
	pcie_logger.mode = DIAG_PCIE_MODE;
	pcie_logger.log_ops = &pcie_log_ops;
	diag_mux->pcie_ptr = &pcie_logger;
#endif
	/*
	 * Set USB logging as the default logger. This is the mode
	 * Diag should be in when it initializes.
	 */
	diag_mux->usb_ptr = &usb_logger;
	diag_mux->md_ptr = &md_logger;
	switch (driver->transport_set) {
	switch (driver->pcie_transport_def) {
	case DIAG_ROUTE_TO_PCIE:
		diag_mux->logger = &pcie_logger;
		diag_mux->mode = DIAG_PCIE_MODE;
@@ -113,7 +103,6 @@ void diag_mux_exit(void)
	kfree(diag_mux);
}

#ifdef CONFIG_DIAG_OVER_PCIE
int diag_pcie_register_ops(int proc, int ctx, struct diag_mux_ops *ops)
{
	int err = 0;
@@ -127,22 +116,13 @@ int diag_pcie_register_ops(int proc, int ctx, struct diag_mux_ops *ops)
	pcie_logger.ops[proc] = ops;
	err = diag_pcie_register(proc, ctx, ops);
	if (err) {
		driver->transport_set = DIAG_ROUTE_TO_USB;
		diag_mux->logger = &usb_logger;
		diag_mux->mode = DIAG_USB_MODE;
		usb_logger.ops[proc] = ops;
		err = diag_usb_register(proc, ctx, ops);
		if (err) {
			pr_err("diag: MUX: unable to register usb operations for proc: %d, err: %d\n",
					   proc, err);
			return err;
		}
		pr_err("diag: MUX: unable to register pcie operations for proc: %d, err: %d\n",
			proc, err);
		return err;
	}
	return 0;
}
#else

int diag_usb_register_ops(int proc, int ctx, struct diag_mux_ops *ops)
{
	int err = 0;
@@ -161,7 +141,6 @@ int diag_usb_register_ops(int proc, int ctx, struct diag_mux_ops *ops)
	}
	return 0;
}
#endif

int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops)
{
@@ -172,9 +151,17 @@ int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops)

	if (proc < 0 || proc >= NUM_MUX_PROC)
		return 0;
	err = diag_mux_register_ops(proc, ctx, ops);
	if (err)
	err = diag_pcie_register_ops(proc, ctx, ops);
	if (err) {
		pr_err("diag: MUX: unable to register PCIe operations, continuing with USB registrations for proc: %d, err: %d\n",
		proc, err);
	}
	err = diag_usb_register_ops(proc, ctx, ops);
	if (err) {
		pr_err("diag: MUX: unable to register USB operations for proc: %d, err: %d\n",
		proc, err);
		return err;
	}
	md_logger.ops[proc] = ops;
	err = diag_md_register(proc, ctx, ops);
	if (err) {
@@ -182,7 +169,6 @@ int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops)
		       proc, err);
		return err;
	}

	return 0;
}

@@ -308,6 +294,10 @@ int diag_mux_switch_logging(int *req_mode, int *peripheral_mask)
			diag_mux->pcie_ptr->log_ops->close();
			diag_mux->logger = diag_mux->md_ptr;
			diag_mux->md_ptr->log_ops->open();
		} else if (*req_mode == DIAG_USB_MODE) {
			diag_mux->pcie_ptr->log_ops->close();
			diag_mux->logger = diag_mux->usb_ptr;
			diag_mux->usb_ptr->log_ops->open();
		} else if (*req_mode == DIAG_MULTI_MODE) {
			diag_mux->md_ptr->log_ops->open();
			diag_mux->logger = NULL;
@@ -318,6 +308,10 @@ int diag_mux_switch_logging(int *req_mode, int *peripheral_mask)
			diag_mux->usb_ptr->log_ops->close();
			diag_mux->logger = diag_mux->md_ptr;
			diag_mux->md_ptr->log_ops->open();
		} else if (*req_mode == DIAG_PCIE_MODE) {
			diag_mux->usb_ptr->log_ops->close();
			diag_mux->logger = diag_mux->pcie_ptr;
			diag_mux->pcie_ptr->log_ops->open();
		} else if (*req_mode == DIAG_MULTI_MODE) {
			diag_mux->md_ptr->log_ops->open();
			diag_mux->logger = NULL;
@@ -333,7 +327,8 @@ int diag_mux_switch_logging(int *req_mode, int *peripheral_mask)
			diag_mux->logger = diag_mux->pcie_ptr;
			diag_mux->pcie_ptr->log_ops->open();
		} else if (*req_mode == DIAG_MULTI_MODE) {
			if (driver->transport_set == DIAG_ROUTE_TO_PCIE)
			if (driver->pcie_transport_def == DIAG_ROUTE_TO_PCIE ||
				driver->transport_set == DIAG_ROUTE_TO_PCIE)
				diag_mux->pcie_ptr->log_ops->open();
			else
				diag_mux->usb_ptr->log_ops->open();
+1 −2
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, 2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2016, 2018-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -77,5 +77,4 @@ int diag_mux_close_all(void);
int diag_mux_switch_logging(int *new_mode, int *peripheral_mask);
int diag_pcie_register_ops(int proc, int ctx, struct diag_mux_ops *ops);
int diag_usb_register_ops(int proc, int ctx, struct diag_mux_ops *ops);
int diag_mux_register_ops(int proc, int ctx, struct diag_mux_ops *ops);
#endif
+3 −2
Original line number Diff line number Diff line
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -85,6 +85,7 @@ void diag_pcie_read_work_fn(struct work_struct *work)
	ureq.mode = IPA_DMA_SYNC;
	ureq.buf = pcie_info->in_chan_attr.read_buffer;
	ureq.len = pcie_info->in_chan_attr.read_buffer_size;
	ureq.transfer_len = 0;
	bytes_avail = mhi_dev_read_channel(&ureq);
	if (bytes_avail < 0)
		return;
@@ -319,7 +320,7 @@ int diag_pcie_write(int id, unsigned char *buf, int len, int ctxt)
	pcie_info = &diag_pcie[id];

	if (len > pcie_info->out_chan_attr.max_pkt_size) {
		DIAG_LOG(DIAG_DEBUG_MUX, "len: %d, max_size: %d\n",
		DIAG_LOG(DIAG_DEBUG_MUX, "len: %d, max_size: %zu\n",
			 len, pcie_info->out_chan_attr.max_pkt_size);
		return diag_pcie_write_ext(pcie_info, buf, len, ctxt);
	}
Loading