uio: msm_sharedmem: Add new device driver for sharedmemory access
Add new device driver to provide a standard interface for its clients (like RemoteFS and RFSA) to be able to memory map their respective allotted shared memory address in the client's address space. The shared memory (a transport buffer) address is unique for each individual client and is made available to the driver via device tree. This driver uses the existing UIO framework to facilitate the clients mmap requirements. Each individual client will be able to use a unique UIO device for this purpose. CRs-Fixed: 477427 Bug: 12784954 Change-Id: If07b88086b5f1b87845962818094644575629fcf Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org> Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org> Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
This commit is contained in:
parent
db04383138
commit
16b5329d9d
|
@ -0,0 +1,115 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
This is a new platform driver for newly introduced UIO devices
|
||||
to facilitate clients in Userspace.
|
||||
|
||||
Hardware description
|
||||
====================
|
||||
This driver does not implement any specific hardware driver.
|
||||
|
||||
Software description
|
||||
====================
|
||||
|
||||
Design
|
||||
======
|
||||
|
||||
The goal of this driver is to ensure there is no security lapse in the
|
||||
Userspace clients' functionality. This new driver uses the existing
|
||||
UIO framework to facilitate the clients to be able to memory map their
|
||||
respective allotted shared memory address in the client's address space.
|
||||
|
||||
|
|
||||
Userspace | Kernel space
|
||||
+--------------+ +---------------+ +---------------+
|
||||
| Client | | Shared | | shrdmem_uio |
|
||||
| <-------> Memory <-------> driver |
|
||||
+--------------+ +---------------+ +---------------+
|
||||
|
|
||||
|
|
||||
|
||||
The shared memory (a transport buffer) address is unique for each
|
||||
individual client and is made available to the driver via device tree.
|
||||
|
||||
For a given client the probe would be called once in the shrdmem_uio driver.
|
||||
This driver would parse the device tree and register a new UIO device with kernel
|
||||
available under /dev/uioX (where X would start from zero, being serially
|
||||
incremented for the next UIO device probed)
|
||||
|
||||
The client in Userspace would be able to access the respective UIO device
|
||||
under the sysfs entry(/sys/class/uio/uioX) upon verifying the name and version
|
||||
of the device under this sysfs node. Once verified it could access the physical
|
||||
address under /sys/class/uio/uioX/maps/map0/addr
|
||||
|
||||
The client would request for memory mapping which would be taken care of in the
|
||||
kernel space by the UIO framework. No explicit mmap() implementation required by
|
||||
the shrdmem_uio driver.
|
||||
|
||||
Power Management
|
||||
================
|
||||
Does not implement any power management.
|
||||
|
||||
SMP/multi-core
|
||||
==============
|
||||
|
||||
The platform driver would be loaded/probed once per client.
|
||||
DTS files will be looked up for shared memory addresses and sizes for all the clients.
|
||||
The UIO char device will be created under /dev/uioX.
|
||||
|
||||
This being one time activity for a given client it does not require SMP/multi-core safety.
|
||||
|
||||
Security
|
||||
========
|
||||
|
||||
The devices (/dev/uioX) would have permission checks for restricted access
|
||||
|
||||
Performance
|
||||
===========
|
||||
|
||||
None.
|
||||
|
||||
Interface
|
||||
=========
|
||||
|
||||
This driver does not export any APIs for kernel.
|
||||
Android user space can access the shared memory by mmaping it.
|
||||
|
||||
Driver parameters
|
||||
=================
|
||||
|
||||
None.
|
||||
|
||||
Config options
|
||||
==============
|
||||
|
||||
None.
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
The only dependency is the kernel device tree files for the
|
||||
Userspace client details.
|
||||
|
||||
User space utilities
|
||||
====================
|
||||
This driver communicates with the following user space clients/utilities:
|
||||
|
||||
Remote File System:
|
||||
- Based on Qualcomm Messaging Interface (QMI)
|
||||
- This service enables the modules on the MSM modem processor to
|
||||
read data from and write data to the embedded multimedia card (eMMC),
|
||||
which is solely controlled by the applications processor.
|
||||
|
||||
Remote File System Access (QMI_RFSA):
|
||||
- Based on Qualcomm Messaging Interface (QMI)
|
||||
- This service provides access from the Hexagon processor to a High-Level
|
||||
Operating Sytem (HLOS) file system
|
||||
Other
|
||||
=====
|
||||
|
||||
None.
|
||||
|
||||
Known issues
|
||||
============
|
||||
|
||||
None.
|
|
@ -0,0 +1,13 @@
|
|||
msm_sharedmem provides the shared memory addresses for various clients in user-space
|
||||
|
||||
Required properties:
|
||||
- compatible: Must be "qcom,sharedmem-uio"
|
||||
- reg : The address and size of the shared memory. The address/sizes may vary.
|
||||
- reg-names : indicates various client-names.
|
||||
|
||||
Example:
|
||||
msm_sharedmem {
|
||||
compatible = "qcom,sharedmem-uio";
|
||||
reg = <0x0dc80000 0x00180000>,
|
||||
reg-names = "rmtfs";
|
||||
};
|
|
@ -111,4 +111,11 @@ config UIO_PRUSS
|
|||
To compile this driver as a module, choose M here: the module
|
||||
will be called uio_pruss.
|
||||
|
||||
config UIO_MSM_SHAREDMEM
|
||||
bool "MSM shared memory driver"
|
||||
default n
|
||||
help
|
||||
Provides the clients with their respective alloted shared memory
|
||||
addresses which are used as transport buffer.
|
||||
|
||||
endif
|
||||
|
|
|
@ -7,3 +7,4 @@ obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
|
|||
obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o
|
||||
obj-$(CONFIG_UIO_NETX) += uio_netx.o
|
||||
obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o
|
||||
obj-$(CONFIG_UIO_MSM_SHAREDMEM) += msm_sharedmem.o
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "%s: " fmt, __func__
|
||||
|
||||
#include <linux/uio_driver.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#define DRIVER_NAME "msm_sharedmem"
|
||||
|
||||
static int msm_sharedmem_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct uio_info *info = NULL;
|
||||
struct resource *clnt_res = NULL;
|
||||
|
||||
/* Get the addresses from platform-data */
|
||||
if (!pdev->dev.of_node) {
|
||||
pr_err("Node not found\n");
|
||||
ret = -ENODEV;
|
||||
goto out;
|
||||
}
|
||||
clnt_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!clnt_res) {
|
||||
pr_err("resource not found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
info = devm_kzalloc(&pdev->dev, sizeof(struct uio_info), GFP_KERNEL);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
info->name = clnt_res->name;
|
||||
info->version = "1.0";
|
||||
info->mem[0].addr = clnt_res->start;
|
||||
info->mem[0].size = resource_size(clnt_res);
|
||||
info->mem[0].memtype = UIO_MEM_PHYS;
|
||||
|
||||
/* Setup device */
|
||||
ret = uio_register_device(&pdev->dev, info);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
dev_set_drvdata(&pdev->dev, info);
|
||||
pr_debug("Device created for client '%s'\n", clnt_res->name);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int msm_sharedmem_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct uio_info *info = dev_get_drvdata(&pdev->dev);
|
||||
|
||||
uio_unregister_device(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct of_device_id msm_sharedmem_of_match[] = {
|
||||
{.compatible = "qcom,sharedmem-uio",},
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, msm_sharedmem_of_match);
|
||||
|
||||
static struct platform_driver msm_sharedmem_driver = {
|
||||
.probe = msm_sharedmem_probe,
|
||||
.remove = msm_sharedmem_remove,
|
||||
.driver = {
|
||||
.name = DRIVER_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = msm_sharedmem_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(msm_sharedmem_driver);
|
||||
MODULE_LICENSE("GPL v2");
|
Loading…
Reference in New Issue