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

Commit 9688988f authored by Ravi Aravamudhan's avatar Ravi Aravamudhan Committed by Gerrit - the friendly Code Review server
Browse files

diag: Split stream for diag memory device mode



This patch splits the streams for diag memory device mode and allows
multiple instances of diag on-device logging application.

Change-Id: I29ddf1eaa7756eca5edd9f3d3746a2bd394433f5
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent 50e0173f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,
		"RSP Buffer is Busy: %d\n"
		"HDLC Disabled: %d\n"
		"Time Sync Enabled: %d\n"
		"MD session mode: %d\n"
		"MD session mask: %d\n"
		"Uses Time API: %d\n",
		chk_config_get_id(),
		chk_polling_response(),
@@ -81,6 +83,8 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,
		driver->rsp_buf_busy,
		driver->hdlc_disabled,
		driver->time_sync_enabled,
		driver->md_session_mode,
		driver->md_session_mask,
		driver->uses_time_api);

	for (i = 0; i < NUM_PERIPHERALS; i++) {
+437 −144

File changed.

Preview size limit exceeded, changes collapsed.

+15 −3
Original line number Diff line number Diff line
@@ -156,11 +156,23 @@ extern struct diag_mask_info event_mask;

int diag_masks_init(void);
void diag_masks_exit(void);
int diag_process_apps_masks(unsigned char *buf, int len);
int diag_log_mask_copy(struct diag_mask_info *dest,
		       struct diag_mask_info *src);
int diag_msg_mask_copy(struct diag_mask_info *dest,
		       struct diag_mask_info *src);
int diag_event_mask_copy(struct diag_mask_info *dest,
			 struct diag_mask_info *src);
void diag_log_mask_free(struct diag_mask_info *mask_info);
void diag_msg_mask_free(struct diag_mask_info *mask_info);
void diag_event_mask_free(struct diag_mask_info *mask_info);
int diag_process_apps_masks(unsigned char *buf, int len,
			    struct diag_md_session_t *info);
void diag_send_updates_peripheral(uint8_t peripheral);

extern int diag_create_msg_mask_table_entry(struct diag_msg_mask_t *msg_mask,
					    struct diag_ssid_range_t *range);
extern int diag_copy_to_user_msg_mask(char __user *buf, size_t count);
extern int diag_copy_to_user_log_mask(char __user *buf, size_t count);
extern int diag_copy_to_user_msg_mask(char __user *buf, size_t count,
				      struct diag_md_session_t *info);
extern int diag_copy_to_user_log_mask(char __user *buf, size_t count,
				      struct diag_md_session_t *info);
#endif
+62 −5
Original line number Diff line number Diff line
@@ -22,10 +22,13 @@
#include <linux/delay.h>
#include <linux/kmemleak.h>
#include <linux/uaccess.h>
#include "diagchar.h"
#include "diag_memorydevice.h"
#include "diagfwd_bridge.h"
#include "diag_mux.h"
#include "diagmem.h"
#include "diagfwd.h"
#include "diagfwd_peripheral.h"

struct diag_md_info diag_md[NUM_DIAG_MD_DEV] = {
	{
@@ -131,6 +134,8 @@ int diag_md_write(int id, unsigned char *buf, int len, int ctx)
	uint8_t found = 0;
	unsigned long flags;
	struct diag_md_info *ch = NULL;
	uint8_t peripheral;
	struct diag_md_session_t *session_info = NULL;

	if (id < 0 || id >= NUM_DIAG_MD_DEV || id >= DIAG_NUM_PROC)
		return -EINVAL;
@@ -138,6 +143,14 @@ int diag_md_write(int id, unsigned char *buf, int len, int ctx)
	if (!buf || len < 0)
		return -EINVAL;

	peripheral = GET_BUF_PERIPHERAL(ctx);
	if (peripheral > NUM_PERIPHERALS)
		return -EINVAL;

	session_info = diag_md_session_get_peripheral(peripheral);
	if (!session_info)
		return -EIO;

	ch = &diag_md[id];

	spin_lock_irqsave(&ch->lock, flags);
@@ -174,10 +187,11 @@ int diag_md_write(int id, unsigned char *buf, int len, int ctx)

	found = 0;
	for (i = 0; i < driver->num_clients && !found; i++) {
		if ((driver->client_map[i].pid != driver->md_proc[id].pid) ||
		    (driver->client_map[i].pid == 0)) {
		if ((driver->client_map[i].pid !=
		     session_info->pid) ||
		    (driver->client_map[i].pid == 0))
			continue;
		}

		found = 1;
		driver->data_ready[i] |= USER_SPACE_DATA_TYPE;
		pr_debug("diag: wake up logging process\n");
@@ -190,9 +204,9 @@ int diag_md_write(int id, unsigned char *buf, int len, int ctx)
	return 0;
}

int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size)
int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size,
			struct diag_md_session_t *info)
{

	int i, j;
	int err = 0;
	int ret = *pret;
@@ -202,6 +216,8 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size)
	struct diag_md_info *ch = NULL;
	struct diag_buf_tbl_t *entry = NULL;
	uint8_t drain_again = 0;
	uint8_t peripheral = 0;
	struct diag_md_session_t *session_info = NULL;

	for (i = 0; i < NUM_DIAG_MD_DEV && !err; i++) {
		ch = &diag_md[i];
@@ -209,6 +225,18 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size)
			entry = &ch->tbl[j];
			if (entry->len <= 0)
				continue;
			peripheral = GET_BUF_PERIPHERAL(entry->ctx);
			/* Account for Apps data as well */
			if (peripheral > NUM_PERIPHERALS)
				goto drop_data;
			session_info =
			diag_md_session_get_peripheral(peripheral);
			if (session_info && info &&
				(session_info->pid != info->pid))
				continue;
			if ((info && (info->peripheral_mask &
			    MD_PERIPHERAL_MASK(peripheral)) == 0))
				goto drop_data;
			/*
			 * If the data is from remote processor, copy the remote
			 * token first
@@ -278,6 +306,35 @@ drop_data:
	return err;
}

int diag_md_close_peripheral(int id, uint8_t peripheral)
{
	int i;
	uint8_t found = 0;
	unsigned long flags;
	struct diag_md_info *ch = NULL;
	struct diag_buf_tbl_t *entry = NULL;

	if (id < 0 || id >= NUM_DIAG_MD_DEV || id >= DIAG_NUM_PROC)
		return -EINVAL;

	ch = &diag_md[id];

	spin_lock_irqsave(&ch->lock, flags);
	for (i = 0; i < ch->num_tbl_entries && !found; i++) {
		entry = &ch->tbl[i];
		if (GET_BUF_PERIPHERAL(entry->ctx) != peripheral)
			continue;
		found = 1;
		if (ch->ops && ch->ops->write_done) {
			ch->ops->write_done(entry->buf, entry->len,
					    entry->ctx,
					    DIAG_MEMORY_DEVICE_MODE);
		}
	}
	spin_unlock_irqrestore(&ch->lock, flags);
	return 0;
}

int diag_md_init()
{
	int i, j;
+3 −1
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ void diag_md_exit(void);
void diag_md_open_all(void);
void diag_md_close_all(void);
int diag_md_register(int id, int ctx, struct diag_mux_ops *ops);
int diag_md_close_peripheral(int id, uint8_t peripheral);
int diag_md_write(int id, unsigned char *buf, int len, int ctx);
int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size);
int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size,
			 struct diag_md_session_t *info);
#endif
Loading