shmobile: ipmmu: Add basic PMB support
PATCH v3 1/1 shmobile: ipmmu: Add basic PMB support
The PMB can be used to allow multimedia hardware to remap physical memory from the 0x80000000-0xbfffffff address range to the 0x00000000-0x7fffffff range. It also has the ability to perform tiled-linear address translation, which can be used to access a memory buffer as a series of n x m tiles, useful for image encoding/decoding. Currently only the only access is via character device for use with user space multimedia drivers.
All register access and hardware dependent functionality is provided by the IPMMU driver, which is shared with the IOMMU/TLB module.
---
Hello all,
Here is the much delayed v3 for this patch. Just some minor updates to the initialization code which I think should address Morimoto-san's comment.
Changes from v2:
----------------
* Assign PMB private data inside ipmmu_pmb_init() and change return val type to int
* Use devm_free to free private data on ipmmu_pmb_init() failure.
It is necessary to free the memory explicitly in this case since the TLB side of the driver may continue operate, keeping the underyling dev active, even when the PMB initialization fails.
Changes from v1:
---------------
* Rebased onto latest (v6) shmobile IOMMU patch series
* Correct locking to ensure thread safety in set_pmb() and set_pmb_tile()
* Disable PMB once last client has disconnected
* Move user space API header definition to /include/uapi/ directory
* Allocate driver private data with devm_kzmalloc()
* Use unsigned data types for PMB indices, memory sizes, etc.
* Simplify PMB handle allocation by using a lookup table
* Fix address range error in patch comment
drivers/iommu/Kconfig | 15 ++ drivers/iommu/Makefile | 1 + drivers/iommu/shmobile-ipmmu.c | 121 +++++++++++- drivers/iommu/shmobile-ipmmu.h | 28 +++- drivers/iommu/shmobile-pmb.c | 385 +++++++++++++++++++++++++++++++++++++ include/uapi/linux/shmobile-pmb.h | 53 +++++ 6 files changed, 595 insertions(+), 8 deletions(-) create mode 100644 drivers/iommu/shmobile-pmb.c drivers/iommu/Kconfig | 15 ++ drivers/iommu/Makefile | 1 + drivers/iommu/shmobile-ipmmu.c | 121 +++++++++++- drivers/iommu/shmobile-ipmmu.h | 28 +++- drivers/iommu/shmobile-pmb.c | 389 +++++++++++++++++++++++++++++++++++++ include/uapi/linux/shmobile-pmb.h | 53 +++++ 6 files changed, 599 insertions(+), 8 deletions(-) create mode 100644 drivers/iommu/shmobile-pmb.c create mode 100644 include/uapi/linux/shmobile-pmb.h
drivers/iommu/Kconfig +15 -0
@@ -261,4 +261,19 @@ config SHMOBILE_IOMMU_L1SIZE default 256 if SHMOBILE_IOMMU_ADDRSIZE_64MB default 128 if SHMOBILE_IOMMU_ADDRSIZE_32MB +config SHMOBILE_PMB + bool "IPMMU PMB driver" + default n + depends on (ARM && ARCH_SHMOBILE) + select SHMOBILE_IPMMU + help + This enables the PMB interface of the IPMMU hardware module. + The PMB can be used to remap 16, 64, 128 or 512 MiB pages from + the 0x80000000-0xffffffff address range to anywhere in the + 0x00000000-0x7fffffff range. + PMB support can be used either with or without SHMOBILE IOMMU + support. + + If unsure, say N. + endif # IOMMU_SUPPORT
drivers/iommu/Makefile +1 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_TEGRA_IOMMU_SMMU) += tegra-smmu.o obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o obj-$(CONFIG_SHMOBILE_IOMMU) += shmobile-iommu.o obj-$(CONFIG_SHMOBILE_IPMMU) += shmobile-ipmmu.o +obj-$(CONFIG_SHMOBILE_PMB) += shmobile-pmb.o
drivers/iommu/shmobile-ipmmu.c +114 -7
140 lines not on this page · raw message
drivers/iommu/shmobile-ipmmu.h +27 -1
@@ -7,6 +7,8 @@* the Free Software Foundation; version 2 of the License. */ +#include <uapi/linux/shmobile-pmb.h> +#ifndef __SHMOBILE_IPMMU_H__#define __SHMOBILE_IPMMU_H__
@@ -17,10 +19,12 @@ struct shmobile_ipmmu {struct mutex flush_lock;const char *const *dev_names;unsigned int num_dev_names; +void *pmb_priv; }; -#ifdef CONFIG_SHMOBILE_IPMMU_TLB void ipmmu_tlb_flush (struct shmobile_ipmmu *ipmmu); + +#ifdef CONFIG_SHMOBILE_IPMMU_TLB void ipmmu_tlb_set (struct shmobile_ipmmu *ipmmu,unsigned long phys,int size,int asid);int ipmmu_iommu_init (struct shmobile_ipmmu *ipmmu);
@@ -31,4 +35,26 @@ static inline int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu) }#endif +#ifdef CONFIG_SHMOBILE_PMB +/* Access functions used by PMB device */ +/*void handle_free(struct device *dev, unsigned long handle, int size_mb); +unsigned long handle_alloc(struct device *dev, int size_mb);*/ +void ipmmu_pmb_set_addr (struct shmobile_ipmmu *ipmmu, +unsigned int index,unsigned long addr, +bool enabled); +int ipmmu_pmb_set_data (struct shmobile_ipmmu *ipmmu,unsigned int index, +const struct ipmmu_pmb_info *info, +const struct pmb_tile_info *tile); +void ipmmu_pmb_enable (struct shmobile_ipmmu *ipmmu,bool enable); +/* PMB initialization */ +int ipmmu_pmb_init (struct shmobile_ipmmu *ipmmu); +void ipmmu_pmb_deinit (void *pmb_priv); +#else +static inline int ipmmu_pmb_init (struct device *dev) +{ +return -EINVAL ; +} +static inline void ipmmu_pmb_deinit (void *pmb_priv) { } +#endif +#endif /* __SHMOBILE_IPMMU_H__ */
drivers/iommu/shmobile-pmb.c new file +389 -0
389 lines not on this page · raw message
include/uapi/linux/shmobile-pmb.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
1.7.5.4