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

Commit 959e0698 authored by Hardik Arya's avatar Hardik Arya Committed by Manoj Prabhu B
Browse files

diag: Update remote address for each CNTL packet



Possibility of stale remote address for CNTL channel is
prevented by updating address for every CNTL packet received.
Since APPS only writes on CNTL channel, updation is only needed
for CNTL channel.
Reduce the scope of notifier mutex to reduce the chances of
race condition. Update spelling for few macros.

Change-Id: I0a53ebe0a66660b763d5df1f7084b0f7fa8ebcb0
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
Signed-off-by: default avatarHardik Arya <harya@codeaurora.org>
parent 4f83e9a1
Loading
Loading
Loading
Loading
+24 −11
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ static void __socket_close_channel(struct diag_socket_info *info)
	if (!atomic_read(&info->opened))
		return;

	if ((bootup_req[info->peripheral] == PEPIPHERAL_SSR_UP) &&
	if ((bootup_req[info->peripheral] == PERIPHERAL_SSR_UP) &&
		(info->port_type == PORT_TYPE_SERVER)) {
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: %s is up, stopping cleanup: bootup_req = %d\n",
@@ -964,7 +964,6 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
		return NOTIFY_DONE;
	}

	mutex_lock(&driver->diag_notifier_mutex);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
	"%s: ssr for processor %d ('%s')\n",
	__func__, notifier->processor, notifier->name);
@@ -974,7 +973,12 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
	case SUBSYS_BEFORE_SHUTDOWN:
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: %s: SUBSYS_BEFORE_SHUTDOWN\n", __func__);
		bootup_req[notifier->processor] = PEPIPHERAL_SSR_DOWN;
		mutex_lock(&driver->diag_notifier_mutex);
		bootup_req[notifier->processor] = PERIPHERAL_SSR_DOWN;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: bootup_req[%s] = %d\n",
		notifier->name, (int)bootup_req[notifier->processor]);
		mutex_unlock(&driver->diag_notifier_mutex);
		break;

	case SUBSYS_AFTER_SHUTDOWN:
@@ -990,11 +994,20 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
	case SUBSYS_AFTER_POWERUP:
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: %s: SUBSYS_AFTER_POWERUP\n", __func__);
		mutex_lock(&driver->diag_notifier_mutex);
		if (!bootup_req[notifier->processor]) {
			bootup_req[notifier->processor] = PEPIPHERAL_SSR_DOWN;
			bootup_req[notifier->processor] = PERIPHERAL_SSR_DOWN;
			DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
			"diag: bootup_req[%s] = %d\n",
			notifier->name, (int)bootup_req[notifier->processor]);
			mutex_unlock(&driver->diag_notifier_mutex);
			break;
		}
		bootup_req[notifier->processor] = PEPIPHERAL_SSR_UP;
		bootup_req[notifier->processor] = PERIPHERAL_SSR_UP;
		DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		"diag: bootup_req[%s] = %d\n",
		notifier->name, (int)bootup_req[notifier->processor]);
		mutex_unlock(&driver->diag_notifier_mutex);
		break;

	default:
@@ -1002,10 +1015,6 @@ static int restart_notifier_cb(struct notifier_block *this, unsigned long code,
		"diag: code: %lu\n", code);
		break;
	}
	mutex_unlock(&driver->diag_notifier_mutex);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
	"diag: bootup_req[%s] = %d\n",
	notifier->name, (int)bootup_req[notifier->processor]);

	return NOTIFY_DONE;
}
@@ -1165,7 +1174,11 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len,
		if (read_len <= 0)
			goto fail;

		if (!atomic_read(&info->opened) &&
		if (info->type == TYPE_CNTL) {
			memcpy(&info->remote_addr, &src_addr, sizeof(src_addr));
			if (!atomic_read(&info->opened))
				__socket_open_channel(info);
		} else if (!atomic_read(&info->opened) &&
			info->port_type == PORT_TYPE_SERVER) {
			/*
			 * This is the first packet from the client. Copy its
+4 −4
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017, 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
@@ -24,9 +24,9 @@
#define PORT_TYPE_SERVER		0
#define PORT_TYPE_CLIENT		1

#define PEPIPHERAL_AFTER_BOOT		0
#define PEPIPHERAL_SSR_DOWN		1
#define PEPIPHERAL_SSR_UP		2
#define PERIPHERAL_AFTER_BOOT		0
#define PERIPHERAL_SSR_DOWN		1
#define PERIPHERAL_SSR_UP		2

#define CNTL_CMD_NEW_SERVER		4
#define CNTL_CMD_REMOVE_SERVER		5