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

Commit 0e15f0e3 authored by Karthikeyan Ramasubramanian's avatar Karthikeyan Ramasubramanian Committed by Rohit Vaswani
Browse files

soc: qcom: Add snapshot of SMEM driver



This snapshot is taken as of msm-3.18 commit e70ad0cd (Promotion of
kernel.lnx.3.18-151201)

Signed-off-by: default avatarKarthikeyan Ramasubramanian <kramasub@codeaurora.org>
parent 7569d9b4
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
#
# QCOM Soc drivers
#
config MSM_SMEM
	depends on ARCH_QCOM
	depends on REMOTE_SPINLOCK_MSM
	bool "MSM Shared Memory (SMEM)"
	help
	  Support for the shared memory interface between the various
	  processors in the System on a Chip (SoC) which allows basic
	  inter-processor communication.

config QCOM_GSBI
        tristate "QCOM General Serial Bus Interface"
        depends on ARCH_QCOM
+1 −0
Original line number Diff line number Diff line
obj-$(CONFIG_MSM_SMEM)	+=	msm_smem.o smem_debug.o
obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
obj-$(CONFIG_QCOM_PM)	+=	spm.o
obj-$(CONFIG_QCOM_SMD) +=	smd.o
+1508 −0

File added.

Preview size limit exceeded, changes collapsed.

+139 −0
Original line number Diff line number Diff line
/* arch/arm/mach-msm/smem_debug.c
 *
 * Copyright (C) 2007 Google, Inc.
 * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
 * Author: Brian Swetland <swetland@google.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/debugfs.h>
#include <linux/list.h>
#include <linux/ctype.h>
#include <linux/jiffies.h>

#include <soc/qcom/smem.h>

#include "smem_private.h"

#if defined(CONFIG_DEBUG_FS)

#define SZ_SMEM_ALLOCATION_TABLE 8192

static void debug_read_mem(struct seq_file *s)
{
	unsigned n;
	struct smem_heap_info *heap_info;
	struct smem_heap_entry *toc;

	heap_info = smem_find(SMEM_HEAP_INFO, sizeof(struct smem_heap_info),
						0,
						SMEM_ANY_HOST_FLAG);
	if (!heap_info) {
		seq_puts(s, "SMEM_HEAP_INFO is NULL\n");
		return;
	}
	toc = smem_find(SMEM_ALLOCATION_TABLE, SZ_SMEM_ALLOCATION_TABLE,
							0, SMEM_ANY_HOST_FLAG);
	if (!toc) {
		seq_puts(s, "SMEM_ALLOCATION_TABLE is NULL\n");
		return;
	}

	seq_printf(s, "heap: init=%d free=%d remain=%d\n",
		       heap_info->initialized,
		       heap_info->free_offset,
		       heap_info->heap_remaining);

	for (n = 0; n < SMEM_NUM_ITEMS; n++) {
		if (toc[n].allocated == 0)
			continue;
		seq_printf(s, "%04d: offset %08x size %08x\n",
			       n, toc[n].offset, toc[n].size);
	}
}

static void debug_read_smem_version(struct seq_file *s)
{
	uint32_t n, version;

	for (n = 0; n < 32; n++) {
		version = smem_get_version(n);
		seq_printf(s, "entry %d: smem = %d  proc_comm = %d\n", n,
			       version >> 16,
			       version & 0xffff);
	}
}

static void debug_read_build_id(struct seq_file *s)
{
	unsigned size;
	void *data;

	data = smem_get_entry(SMEM_HW_SW_BUILD_ID, &size, 0,
							SMEM_ANY_HOST_FLAG);
	if (!data)
		return;

	seq_write(s, data, size);
}

static int debugfs_show(struct seq_file *s, void *data)
{
	void (*show)(struct seq_file *) = s->private;

	show(s);

	return 0;
}

static int debug_open(struct inode *inode, struct file *file)
{
	return single_open(file, debugfs_show, inode->i_private);
}

static const struct file_operations debug_ops = {
	.open = debug_open,
	.release = single_release,
	.read = seq_read,
	.llseek = seq_lseek,
};

static void debug_create(const char *name, umode_t mode,
			 struct dentry *dent,
			 void (*show)(struct seq_file *))
{
	struct dentry *file;

	file = debugfs_create_file(name, mode, dent, show, &debug_ops);
	if (!file)
		pr_err("%s: unable to create file '%s'\n", __func__, name);
}

static int __init smem_debugfs_init(void)
{
	struct dentry *dent;

	dent = debugfs_create_dir("smem", 0);
	if (IS_ERR(dent))
		return PTR_ERR(dent);

	debug_create("mem", 0444, dent, debug_read_mem);
	debug_create("version", 0444, dent, debug_read_smem_version);

	/* NNV: this is google only stuff */
	debug_create("build", 0444, dent, debug_read_build_id);

	return 0;
}

late_initcall(smem_debugfs_init);
#endif
+104 −0
Original line number Diff line number Diff line
/* Copyright (c) 2013, 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
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_
#define _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_

#include <linux/remote_spinlock.h>
#include <soc/qcom/ramdump.h>


#define SMD_HEAP_SIZE 512

struct smem_heap_info {
	unsigned initialized;
	unsigned free_offset;
	unsigned heap_remaining;
	unsigned reserved;
};

struct smem_heap_entry {
	unsigned allocated;
	unsigned offset;
	unsigned size;
	unsigned reserved; /* bits 1:0 reserved, bits 31:2 aux smem base addr */
};
#define BASE_ADDR_MASK 0xfffffffc

struct smem_proc_comm {
	unsigned command;
	unsigned status;
	unsigned data1;
	unsigned data2;
};

struct smem_shared {
	struct smem_proc_comm proc_comm[4];
	unsigned version[32];
	struct smem_heap_info heap_info;
	struct smem_heap_entry heap_toc[SMD_HEAP_SIZE];
};

struct smem_area {
	phys_addr_t phys_addr;
	resource_size_t size;
	void __iomem *virt_addr;
};

/* used for unit testing spinlocks */
remote_spinlock_t *smem_get_remote_spinlock(void);

bool smem_initialized_check(void);

/**
 * smem_module_init_notifier_register() - Register a smem module
 *                                       init notifier block
 * @nb: Notifier block to be registered
 *
 * In order to mark the dependency on SMEM Driver module initialization
 * register a notifier using this API. Once the smem module_init is
 * done, notification will be passed to the registered module.
 */
int smem_module_init_notifier_register(struct notifier_block *nb);

/**
 * smem_module_init_notifier_register() - Unregister a smem module
 *                                       init notifier block
 * @nb: Notifier block to be unregistered
 */
int smem_module_init_notifier_unregister(struct notifier_block *nb);

/**
 * smem_get_free_space() - Get the available allocation free space for a
 *				partition
 *
 * @to_proc: remote SMEM host.  Determines the applicable partition
 * @returns: size in bytes available to allocate
 *
 * Helper function for SMD so that SMD only scans the channel allocation
 * table for a partition when it is reasonably certain that a channel has
 * actually been created, because scanning can be expensive.  Creating a channel
 * will consume some of the free space in a partition, so SMD can compare the
 * last free space size against the current free space size to determine if
 * a channel may have been created.  SMD can't do this directly, because the
 * necessary partition internals are restricted to just SMEM.
 */
unsigned smem_get_free_space(unsigned to_proc);

/**
 * smem_get_version() - Get the smem user version number
 *
 * @idx: SMEM user idx in SMEM_VERSION_INFO table.
 * @returns: smem version number if success otherwise zero.
 */
unsigned smem_get_version(unsigned idx);
#endif /* _ARCH_ARM_MACH_MSM_SMEM_PRIVATE_H_ */
Loading