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

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

Merge "diag: Remove memory device entries while mhi disconnect" into msm-4.19.c1

parents b5b58970 ff5e5bab
Loading
Loading
Loading
Loading
+41 −4
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/slab.h>
@@ -155,6 +155,9 @@ void diag_md_close_device(int id)
		 * When we close the Memory device mode, make sure we flush the
		 * internal buffers in the table so that there are no stale
		 * entries.
		 *
		 * Give Write_done notifications to buffers with packets
		 * indicated valid length.
		 */
		spin_lock_irqsave(&ch->lock, flags);
		for (j = 0; j < ch->num_tbl_entries; j++) {
@@ -173,6 +176,35 @@ void diag_md_close_device(int id)

	diag_ws_reset(DIAG_WS_MUX);
}

void diag_md_clear_tbl_entries(int id)
{
	int  j;
	unsigned long flags;
	struct diag_md_info *ch = NULL;
	struct diag_buf_tbl_t *entry = NULL;

	ch = &diag_md[id];
	if (!ch || !ch->md_info_inited)
		return;

	/*
	 * When we close the Memory device mode, make sure we flush the
	 * internal buffers in the table so that there are no stale
	 * entries.
	 */
	spin_lock_irqsave(&ch->lock, flags);
	for (j = 0; j < ch->num_tbl_entries; j++) {
		entry = &ch->tbl[j];
		entry->buf = NULL;
		entry->len = 0;
		entry->ctx = 0;
	}
	spin_unlock_irqrestore(&ch->lock, flags);

	diag_ws_reset(DIAG_WS_MUX);
}

int diag_md_write(int id, unsigned char *buf, int len, int ctx)
{
	int i, peripheral, pid = 0;
@@ -304,13 +336,18 @@ int diag_md_copy_to_user(char __user *buf, int *pret, size_t buf_size,
		if (!ch->md_info_inited)
			continue;
		for (j = 0; j < ch->num_tbl_entries && !err; j++) {
			spin_lock_irqsave(&ch->lock, flags);
			entry = &ch->tbl[j];
			if (entry->len <= 0 || entry->buf == NULL)
			if (entry->len <= 0 || entry->buf == NULL) {
				spin_unlock_irqrestore(&ch->lock, flags);
				continue;

			}
			peripheral = diag_md_get_peripheral(entry->ctx);
			if (peripheral < 0)
			if (peripheral < 0) {
				spin_unlock_irqrestore(&ch->lock, flags);
				goto drop_data;
			}
			spin_unlock_irqrestore(&ch->lock, flags);
			session_info =
			diag_md_session_get_peripheral(i, peripheral);
			if (!session_info)
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2014-2015, 2017-2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2015, 2017-2018, 2020 The Linux Foundation. All rights reserved.
 */

#ifndef DIAG_MEMORYDEVICE_H
@@ -33,6 +33,7 @@ void diag_md_open_all(void);
void diag_md_close_all(void);
void diag_md_open_device(int id);
void diag_md_close_device(int id);
void diag_md_clear_tbl_entries(int id);
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);
+17 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/slab.h>
@@ -33,6 +33,7 @@ static struct diag_logger_ops usb_log_ops = {
	.queue_read = diag_usb_queue_read,
	.open_device = diag_usb_connect_device,
	.close_device = diag_usb_disconnect_device,
	.clear_tbl_entries = NULL,
	.write = diag_usb_write,
	.close_peripheral = NULL
};
@@ -42,6 +43,7 @@ static struct diag_logger_ops md_log_ops = {
	.close = diag_md_close_all,
	.open_device = diag_md_open_device,
	.close_device = diag_md_close_device,
	.clear_tbl_entries = diag_md_clear_tbl_entries,
	.queue_read = NULL,
	.write = diag_md_write,
	.close_peripheral = diag_md_close_peripheral,
@@ -215,6 +217,20 @@ int diag_mux_close_peripheral(int proc, uint8_t peripheral)
	return 0;
}

void diag_mux_close_device(int proc)
{
	struct diag_logger_t *logger = NULL;

	if (!diag_mux)
		return;

	logger = diag_mux->logger[proc];

	if (logger && logger->log_ops && logger->log_ops->clear_tbl_entries)
		logger->log_ops->clear_tbl_entries(proc);

}

int diag_mux_switch_logging(int proc, int *req_mode, int *peripheral_mask)
{
	unsigned int new_mask = 0;
+3 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
 */
#ifndef DIAG_MUX_H
#define DIAG_MUX_H
@@ -43,6 +43,7 @@ struct diag_logger_ops {
	void (*close)(void);
	void (*open_device)(int id);
	void (*close_device)(int id);
	void (*clear_tbl_entries)(int id);
	int (*queue_read)(int id);
	int (*write)(int id, unsigned char *buf, int len, int ctx);
	int (*close_peripheral)(int id, uint8_t peripheral);
@@ -62,6 +63,7 @@ int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops);
int diag_mux_queue_read(int proc);
int diag_mux_write(int proc, unsigned char *buf, int len, int ctx);
int diag_mux_close_peripheral(int proc, uint8_t peripheral);
void diag_mux_close_device(int proc);
int diag_mux_open_all(struct diag_logger_t *logger);
int diag_mux_close_all(void);
int diag_mux_switch_logging(int proc, int *new_mode, int *peripheral_mask);
+7 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/slab.h>
@@ -205,6 +205,12 @@ int diag_remote_dev_open(int id)

void diag_remote_dev_close(int id)
{

	if (id < 0 || id >= NUM_REMOTE_DEV)
		return;

	diag_mux_close_device(BRIDGE_TO_MUX(id));

	if (bridge_info[id].type == DIAG_DATA_TYPE)
		diag_notify_md_client(BRIDGE_TO_MUX(id), 0, DIAG_STATUS_CLOSED);