All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Qualcomm remote filesystem shared memory driver
@ 2017-10-05  3:32 ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross
  Cc: Anton Vorontsov, Colin Cross, David Brown, Frank Rowand,
	Kees Cook, Rob Herring, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, linux-soc

Some remote processors (in particular the modem) found in Qualcomm platforms
stores configuration parameters and other data in a file system. As the remotes
does not have direct storage access it needs to relay block accesses through a
service running on the application CPU.

The memory is described in DeviceTree by a new reserved-memory compatible and
the implementation provides the user space service a read/write interface to
this chunk of memory.

Bjorn Andersson (5):
  of/platform: Generalize /reserved-memory handling
  of: reserved_mem: Accessor for acquiring reserved_mem
  dt-binding: soc: qcom: Add binding for rmtfs memory
  soc: qcom: Remote filesystem memory driver
  arm64: dts: msm8916: Mark rmtfs node as qcom,rmtfs-mem compatible

 .../bindings/reserved-memory/qcom,rmtfs-mem.txt    |  51 ++++
 arch/arm64/boot/dts/qcom/msm8916.dtsi              |   3 +
 drivers/of/of_reserved_mem.c                       |  26 ++
 drivers/of/platform.c                              |  19 +-
 drivers/soc/qcom/Kconfig                           |  11 +
 drivers/soc/qcom/Makefile                          |   1 +
 drivers/soc/qcom/rmtfs_mem.c                       | 272 +++++++++++++++++++++
 include/linux/of_reserved_mem.h                    |   5 +
 8 files changed, 380 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt
 create mode 100644 drivers/soc/qcom/rmtfs_mem.c

-- 
2.12.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 0/5] Qualcomm remote filesystem shared memory driver
@ 2017-10-05  3:32 ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

Some remote processors (in particular the modem) found in Qualcomm platforms
stores configuration parameters and other data in a file system. As the remotes
does not have direct storage access it needs to relay block accesses through a
service running on the application CPU.

The memory is described in DeviceTree by a new reserved-memory compatible and
the implementation provides the user space service a read/write interface to
this chunk of memory.

Bjorn Andersson (5):
  of/platform: Generalize /reserved-memory handling
  of: reserved_mem: Accessor for acquiring reserved_mem
  dt-binding: soc: qcom: Add binding for rmtfs memory
  soc: qcom: Remote filesystem memory driver
  arm64: dts: msm8916: Mark rmtfs node as qcom,rmtfs-mem compatible

 .../bindings/reserved-memory/qcom,rmtfs-mem.txt    |  51 ++++
 arch/arm64/boot/dts/qcom/msm8916.dtsi              |   3 +
 drivers/of/of_reserved_mem.c                       |  26 ++
 drivers/of/platform.c                              |  19 +-
 drivers/soc/qcom/Kconfig                           |  11 +
 drivers/soc/qcom/Makefile                          |   1 +
 drivers/soc/qcom/rmtfs_mem.c                       | 272 +++++++++++++++++++++
 include/linux/of_reserved_mem.h                    |   5 +
 8 files changed, 380 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt
 create mode 100644 drivers/soc/qcom/rmtfs_mem.c

-- 
2.12.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling
  2017-10-05  3:32 ` Bjorn Andersson
  (?)
@ 2017-10-05  3:32   ` Bjorn Andersson
  -1 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross, Anton Vorontsov, Colin Cross, Frank Rowand,
	Kees Cook, Rob Herring, Tony Luck
  Cc: devicetree, linux-arm-msm, linux-kernel, David Brown, linux-soc,
	linux-arm-kernel

By iterating over all /reserved-memory child nodes and match each one to
a list of compatibles that we want to treat specially, we can easily
extend the list of compatibles to handle - without having to resort to
of_platform_populate() that would create unnecessary platform_devices.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Simplify logic per Rob's suggestion.

Changes since v1:
- New patch

 drivers/of/platform.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b19524623498..ee89f096f0f3 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -497,6 +497,11 @@ int of_platform_default_populate(struct device_node *root,
 EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
+static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "ramoops" },
+	{}
+};
+
 static int __init of_platform_default_populate_init(void)
 {
 	struct device_node *node;
@@ -505,15 +510,12 @@ static int __init of_platform_default_populate_init(void)
 		return -ENODEV;
 
 	/*
-	 * Handle ramoops explicitly, since it is inside /reserved-memory,
-	 * which lacks a "compatible" property.
+	 * Handle certain compatibles explicitly, since we don't want to create
+	 * platform_devices for every node in /reserved-memory with a
+	 * "compatible",
 	 */
-	node = of_find_node_by_path("/reserved-memory");
-	if (node) {
-		node = of_find_compatible_node(node, NULL, "ramoops");
-		if (node)
-			of_platform_device_create(node, NULL, NULL);
-	}
+	for_each_matching_node(node, reserved_mem_matches)
+		of_platform_device_create(node, NULL, NULL);
 
 	/* Populate everything else. */
 	of_platform_default_populate(NULL, NULL, NULL);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling
@ 2017-10-05  3:32   ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross, Anton Vorontsov, Colin Cross, Frank Rowand,
	Kees Cook, Rob Herring, Tony Luck
  Cc: David Brown, devicetree, linux-arm-kernel, linux-arm-msm,
	linux-kernel, linux-soc

By iterating over all /reserved-memory child nodes and match each one to
a list of compatibles that we want to treat specially, we can easily
extend the list of compatibles to handle - without having to resort to
of_platform_populate() that would create unnecessary platform_devices.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Simplify logic per Rob's suggestion.

Changes since v1:
- New patch

 drivers/of/platform.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b19524623498..ee89f096f0f3 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -497,6 +497,11 @@ int of_platform_default_populate(struct device_node *root,
 EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
+static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "ramoops" },
+	{}
+};
+
 static int __init of_platform_default_populate_init(void)
 {
 	struct device_node *node;
@@ -505,15 +510,12 @@ static int __init of_platform_default_populate_init(void)
 		return -ENODEV;
 
 	/*
-	 * Handle ramoops explicitly, since it is inside /reserved-memory,
-	 * which lacks a "compatible" property.
+	 * Handle certain compatibles explicitly, since we don't want to create
+	 * platform_devices for every node in /reserved-memory with a
+	 * "compatible",
 	 */
-	node = of_find_node_by_path("/reserved-memory");
-	if (node) {
-		node = of_find_compatible_node(node, NULL, "ramoops");
-		if (node)
-			of_platform_device_create(node, NULL, NULL);
-	}
+	for_each_matching_node(node, reserved_mem_matches)
+		of_platform_device_create(node, NULL, NULL);
 
 	/* Populate everything else. */
 	of_platform_default_populate(NULL, NULL, NULL);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling
@ 2017-10-05  3:32   ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

By iterating over all /reserved-memory child nodes and match each one to
a list of compatibles that we want to treat specially, we can easily
extend the list of compatibles to handle - without having to resort to
of_platform_populate() that would create unnecessary platform_devices.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Simplify logic per Rob's suggestion.

Changes since v1:
- New patch

 drivers/of/platform.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b19524623498..ee89f096f0f3 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -497,6 +497,11 @@ int of_platform_default_populate(struct device_node *root,
 EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
+static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "ramoops" },
+	{}
+};
+
 static int __init of_platform_default_populate_init(void)
 {
 	struct device_node *node;
@@ -505,15 +510,12 @@ static int __init of_platform_default_populate_init(void)
 		return -ENODEV;
 
 	/*
-	 * Handle ramoops explicitly, since it is inside /reserved-memory,
-	 * which lacks a "compatible" property.
+	 * Handle certain compatibles explicitly, since we don't want to create
+	 * platform_devices for every node in /reserved-memory with a
+	 * "compatible",
 	 */
-	node = of_find_node_by_path("/reserved-memory");
-	if (node) {
-		node = of_find_compatible_node(node, NULL, "ramoops");
-		if (node)
-			of_platform_device_create(node, NULL, NULL);
-	}
+	for_each_matching_node(node, reserved_mem_matches)
+		of_platform_device_create(node, NULL, NULL);
 
 	/* Populate everything else. */
 	of_platform_default_populate(NULL, NULL, NULL);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/5] of: reserved_mem: Accessor for acquiring reserved_mem
  2017-10-05  3:32 ` Bjorn Andersson
@ 2017-10-05  3:32   ` Bjorn Andersson
  -1 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross, Frank Rowand, Rob Herring
  Cc: Anton Vorontsov, Colin Cross, David Brown, Kees Cook, Tony Luck,
	devicetree, linux-arm-kernel, linux-arm-msm, linux-kernel,
	linux-soc

In some cases drivers referencing a reserved-memory region might want to
remap the entire region, but when defining the reserved-memory by "size"
the client driver has no means to know the associated base address of
the reserved memory region.

This patch adds an accessor for such drivers to acquire a handle to
their associated reserved-memory for this purpose.

A complicating factor for the implementation is that the reserved_mem
objects are created from the flattened DeviceTree, as such we can't
use the device_node address for comparison. Fortunately the name of the
node will be used as "name" of the reserved_mem and will be used when
building the full_name, so we can compare the "name" with the basename
of the full_name to find the match.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- None

Changes since v1:
- Previous patch provided interface to resolve memory-region reference, instead
  of direct lookup by device_node

 drivers/of/of_reserved_mem.c    | 26 ++++++++++++++++++++++++++
 include/linux/of_reserved_mem.h |  5 +++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index d507c3569a88..b40cfce68fd4 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev)
 	rmem->ops->device_release(rmem, dev);
 }
 EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
+
+/**
+ * of_reserved_mem_get() - acquire reserved_mem from a device node
+ * @np:		node pointer of the desired reserved-memory region
+ *
+ * This function allows drivers to acquire a reference to the reserved_mem
+ * struct based on a device node handle.
+ *
+ * Returns a reserved_mem reference, or NULL on error.
+ */
+struct reserved_mem *of_reserved_mem_get(struct device_node *np)
+{
+	const char *name;
+	int i;
+
+	if (!np->full_name)
+		return NULL;
+
+	name = kbasename(np->full_name);
+	for (i = 0; i < reserved_mem_count; i++)
+		if (!strcmp(reserved_mem[i].name, name))
+			return &reserved_mem[i];
+
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(of_reserved_mem_get);
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index f8e1992d6423..91b1eb5076e4 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
 void fdt_init_reserved_mem(void);
 void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
 			       phys_addr_t base, phys_addr_t size);
+struct reserved_mem *of_reserved_mem_get(struct device_node *np);
 #else
 static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
 					struct device_node *np, int idx)
@@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { }
 static inline void fdt_init_reserved_mem(void) { }
 static inline void fdt_reserved_mem_save_node(unsigned long node,
 		const char *uname, phys_addr_t base, phys_addr_t size) { }
+static inline struct reserved_mem *of_reserved_mem_get(struct device_node *np)
+{
+	return NULL;
+}
 #endif
 
 /**
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/5] of: reserved_mem: Accessor for acquiring reserved_mem
@ 2017-10-05  3:32   ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

In some cases drivers referencing a reserved-memory region might want to
remap the entire region, but when defining the reserved-memory by "size"
the client driver has no means to know the associated base address of
the reserved memory region.

This patch adds an accessor for such drivers to acquire a handle to
their associated reserved-memory for this purpose.

A complicating factor for the implementation is that the reserved_mem
objects are created from the flattened DeviceTree, as such we can't
use the device_node address for comparison. Fortunately the name of the
node will be used as "name" of the reserved_mem and will be used when
building the full_name, so we can compare the "name" with the basename
of the full_name to find the match.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- None

Changes since v1:
- Previous patch provided interface to resolve memory-region reference, instead
  of direct lookup by device_node

 drivers/of/of_reserved_mem.c    | 26 ++++++++++++++++++++++++++
 include/linux/of_reserved_mem.h |  5 +++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index d507c3569a88..b40cfce68fd4 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev)
 	rmem->ops->device_release(rmem, dev);
 }
 EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
+
+/**
+ * of_reserved_mem_get() - acquire reserved_mem from a device node
+ * @np:		node pointer of the desired reserved-memory region
+ *
+ * This function allows drivers to acquire a reference to the reserved_mem
+ * struct based on a device node handle.
+ *
+ * Returns a reserved_mem reference, or NULL on error.
+ */
+struct reserved_mem *of_reserved_mem_get(struct device_node *np)
+{
+	const char *name;
+	int i;
+
+	if (!np->full_name)
+		return NULL;
+
+	name = kbasename(np->full_name);
+	for (i = 0; i < reserved_mem_count; i++)
+		if (!strcmp(reserved_mem[i].name, name))
+			return &reserved_mem[i];
+
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(of_reserved_mem_get);
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index f8e1992d6423..91b1eb5076e4 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
 void fdt_init_reserved_mem(void);
 void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
 			       phys_addr_t base, phys_addr_t size);
+struct reserved_mem *of_reserved_mem_get(struct device_node *np);
 #else
 static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
 					struct device_node *np, int idx)
@@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { }
 static inline void fdt_init_reserved_mem(void) { }
 static inline void fdt_reserved_mem_save_node(unsigned long node,
 		const char *uname, phys_addr_t base, phys_addr_t size) { }
+static inline struct reserved_mem *of_reserved_mem_get(struct device_node *np)
+{
+	return NULL;
+}
 #endif
 
 /**
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/5] dt-binding: soc: qcom: Add binding for rmtfs memory
  2017-10-05  3:32 ` Bjorn Andersson
@ 2017-10-05  3:32   ` Bjorn Andersson
  -1 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross
  Cc: Anton Vorontsov, Colin Cross, David Brown, Frank Rowand,
	Kees Cook, Rob Herring, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, linux-soc

This adds the binding for describing shared memory used to exchange file
system blocks between the RMTFS client and service. A client for this is
generally found in the modem firmware and is used for accessing
persistent storage for things such as radio calibration.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Renamed compatible to "rmtfs-mem" in attempt to clarify that this is not a
  file system, but some chunk of memory.

Changed since v1:
- Memory described in a single reserved-memory node, rather than by reference
  from a "dummy" node
- qcom,vmdid added

 .../bindings/reserved-memory/qcom,rmtfs-mem.txt    | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt

diff --git a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt
new file mode 100644
index 000000000000..8562ba1dce69
--- /dev/null
+++ b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt
@@ -0,0 +1,51 @@
+Qualcomm Remote File System Memory binding
+
+This binding describes the Qualcomm remote filesystem memory, which serves the
+purpose of describing the shared memory region used for remote processors to
+access block device data using the Remote Filesystem protocol.
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be:
+		    "qcom,rmtfs-mem"
+
+- reg:
+	Usage: required for static allocation
+	Value type: <prop-encoded-array>
+	Definition: must specify base address and size of the memory region,
+		    as described in reserved-memory.txt
+
+- size:
+	Usage: required for dynamic allocation
+	Value type: <prop-encoded-array>
+	Definition: must specify a size of the memory region, as described in
+		    reserved-memory.txt
+
+- qcom,client-id:
+	Usage: required
+	Value type: <u32>
+	Definition: identifier of the client to use this region for buffers.
+
+- qcom,vmid:
+	Usage: optional
+	Value type: <u32>
+	Definition: vmid of the remote processor, to set up memory protection.
+
+= EXAMPLE
+The following example shows the remote filesystem memory setup for APQ8016,
+with the rmtfs region for the Hexagon DSP (id #1) located at 0x86700000.
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		rmtfs@86700000 {
+			compatible = "qcom,rmtfs-mem";
+			reg = <0x0 0x86700000 0x0 0xe0000>;
+			no-map;
+
+			qcom,client-id = <1>;
+		};
+	};
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/5] dt-binding: soc: qcom: Add binding for rmtfs memory
@ 2017-10-05  3:32   ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

This adds the binding for describing shared memory used to exchange file
system blocks between the RMTFS client and service. A client for this is
generally found in the modem firmware and is used for accessing
persistent storage for things such as radio calibration.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Renamed compatible to "rmtfs-mem" in attempt to clarify that this is not a
  file system, but some chunk of memory.

Changed since v1:
- Memory described in a single reserved-memory node, rather than by reference
  from a "dummy" node
- qcom,vmdid added

 .../bindings/reserved-memory/qcom,rmtfs-mem.txt    | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt

diff --git a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt
new file mode 100644
index 000000000000..8562ba1dce69
--- /dev/null
+++ b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt
@@ -0,0 +1,51 @@
+Qualcomm Remote File System Memory binding
+
+This binding describes the Qualcomm remote filesystem memory, which serves the
+purpose of describing the shared memory region used for remote processors to
+access block device data using the Remote Filesystem protocol.
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be:
+		    "qcom,rmtfs-mem"
+
+- reg:
+	Usage: required for static allocation
+	Value type: <prop-encoded-array>
+	Definition: must specify base address and size of the memory region,
+		    as described in reserved-memory.txt
+
+- size:
+	Usage: required for dynamic allocation
+	Value type: <prop-encoded-array>
+	Definition: must specify a size of the memory region, as described in
+		    reserved-memory.txt
+
+- qcom,client-id:
+	Usage: required
+	Value type: <u32>
+	Definition: identifier of the client to use this region for buffers.
+
+- qcom,vmid:
+	Usage: optional
+	Value type: <u32>
+	Definition: vmid of the remote processor, to set up memory protection.
+
+= EXAMPLE
+The following example shows the remote filesystem memory setup for APQ8016,
+with the rmtfs region for the Hexagon DSP (id #1) located at 0x86700000.
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		rmtfs at 86700000 {
+			compatible = "qcom,rmtfs-mem";
+			reg = <0x0 0x86700000 0x0 0xe0000>;
+			no-map;
+
+			qcom,client-id = <1>;
+		};
+	};
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/5] soc: qcom: Remote filesystem memory driver
  2017-10-05  3:32 ` Bjorn Andersson
@ 2017-10-05  3:32   ` Bjorn Andersson
  -1 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross, Rob Herring
  Cc: Anton Vorontsov, Colin Cross, David Brown, Frank Rowand,
	Kees Cook, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, linux-soc

The Qualcomm remote file system protocol is used by certain remoteprocs,
in particular the modem, to read and write persistent storage in
platforms where only the application CPU has physical storage access.

The protocol is based on a set of QMI-encoded control-messages and a
shared memory buffer for exchaning the data. This driver implements the
latter, providing the user space service access to the carved out chunk
of memory.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Renamed driver to "rmtfs_mem" in attempt to clarify that this is not a
  file system, but some chunk of memory.

Changes since v1:
- RFSA device represented direclty by the reserved-memory node

 drivers/of/platform.c        |   1 +
 drivers/soc/qcom/Kconfig     |  11 ++
 drivers/soc/qcom/Makefile    |   1 +
 drivers/soc/qcom/rmtfs_mem.c | 272 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 285 insertions(+)
 create mode 100644 drivers/soc/qcom/rmtfs_mem.c

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ee89f096f0f3..e7548c9a9915 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -498,6 +498,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
 static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "qcom,rmtfs-mem" },
 	{ .compatible = "ramoops" },
 	{}
 };
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 9fca977ef18d..6dff89eaf3f8 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -24,6 +24,17 @@ config QCOM_PM
 	  modes. It interface with various system drivers to put the cores in
 	  low power modes.
 
+config QCOM_RMTFS_MEM
+	tristate "Qualcomm Remote Filesystem memory driver"
+	depends on ARCH_QCOM
+	help
+	  The Qualcomm remote filesystem memory driver is used for allocating
+	  and exposing regions of shared memory with remote processors for the
+	  purpose of exchanging sector-data between the remote filesystem
+	  service and its clients.
+
+	  Say y here if you intend to boot the modem remoteproc.
+
 config QCOM_SMEM
 	tristate "Qualcomm Shared Memory Manager (SMEM)"
 	depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 414f0de274fa..541c1f40d126 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)	+= mdt_loader.o
 obj-$(CONFIG_QCOM_PM)	+=	spm.o
+obj-$(CONFIG_QCOM_RMTFS_MEM)	+= rmtfs_mem.o
 obj-$(CONFIG_QCOM_SMD_RPM)	+= smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) +=	smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
new file mode 100644
index 000000000000..2e7c955e7cf0
--- /dev/null
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2017 Linaro Ltd.
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/cdev.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/of_fdt.h>
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include <linux/qcom_scm.h>
+
+#define QCOM_RMTFS_MEM_DEV_MAX	(MINORMASK + 1)
+
+static dev_t qcom_rmtfs_mem_major;
+
+struct qcom_rmtfs_mem {
+	struct device dev;
+	struct cdev cdev;
+
+	void *base;
+	phys_addr_t addr;
+	phys_addr_t size;
+
+	unsigned int client_id;
+};
+
+static ssize_t qcom_rmtfs_mem_show(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf);
+
+static DEVICE_ATTR(phys_addr, 0400, qcom_rmtfs_mem_show, NULL);
+static DEVICE_ATTR(size, 0400, qcom_rmtfs_mem_show, NULL);
+static DEVICE_ATTR(client_id, 0400, qcom_rmtfs_mem_show, NULL);
+
+static ssize_t qcom_rmtfs_mem_show(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = container_of(dev,
+							struct qcom_rmtfs_mem,
+							dev);
+
+	if (attr == &dev_attr_phys_addr)
+		return sprintf(buf, "%pa\n", &rmtfs_mem->addr);
+	if (attr == &dev_attr_size)
+		return sprintf(buf, "%pa\n", &rmtfs_mem->size);
+	if (attr == &dev_attr_client_id)
+		return sprintf(buf, "%d\n", rmtfs_mem->client_id);
+
+	return -EINVAL;
+}
+
+static struct attribute *qcom_rmtfs_mem_attrs[] = {
+	&dev_attr_phys_addr.attr,
+	&dev_attr_size.attr,
+	&dev_attr_client_id.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(qcom_rmtfs_mem);
+
+static int qcom_rmtfs_mem_open(struct inode *inode, struct file *filp)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = container_of(inode->i_cdev,
+							struct qcom_rmtfs_mem,
+							cdev);
+
+	get_device(&rmtfs_mem->dev);
+	filp->private_data = rmtfs_mem;
+
+	return 0;
+}
+static ssize_t qcom_rmtfs_mem_read(struct file *filp,
+			      char __user *buf, size_t count, loff_t *f_pos)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+
+	if (*f_pos >= rmtfs_mem->size)
+		return 0;
+
+	if (*f_pos + count >= rmtfs_mem->size)
+		count = rmtfs_mem->size - *f_pos;
+
+	if (copy_to_user(buf, rmtfs_mem->base + *f_pos, count))
+		return -EFAULT;
+
+	*f_pos += count;
+	return count;
+}
+
+static ssize_t qcom_rmtfs_mem_write(struct file *filp,
+			       const char __user *buf, size_t count,
+			       loff_t *f_pos)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+
+	if (*f_pos >= rmtfs_mem->size)
+		return 0;
+
+	if (*f_pos + count >= rmtfs_mem->size)
+		count = rmtfs_mem->size - *f_pos;
+
+	if (copy_from_user(rmtfs_mem->base + *f_pos, buf, count))
+		return -EFAULT;
+
+	*f_pos += count;
+	return count;
+}
+
+static int qcom_rmtfs_mem_release(struct inode *inode, struct file *filp)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+
+	put_device(&rmtfs_mem->dev);
+
+	return 0;
+}
+
+static const struct file_operations qcom_rmtfs_mem_fops = {
+	.owner = THIS_MODULE,
+	.open = qcom_rmtfs_mem_open,
+	.read = qcom_rmtfs_mem_read,
+	.write = qcom_rmtfs_mem_write,
+	.release = qcom_rmtfs_mem_release,
+	.llseek = default_llseek,
+};
+
+static void qcom_rmtfs_mem_release_device(struct device *dev)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = container_of(dev,
+							struct qcom_rmtfs_mem,
+							dev);
+
+	kfree(rmtfs_mem);
+}
+
+static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct reserved_mem *rmem;
+	struct qcom_rmtfs_mem *rmtfs_mem;
+	u32 client_id;
+	int ret;
+
+	rmem = of_reserved_mem_get(node);
+	if (!rmem) {
+		dev_err(&pdev->dev, "failed to acquire memory region\n");
+		return -EINVAL;
+	}
+
+	ret = of_property_read_u32(node, "qcom,client-id", &client_id);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to parse \"qcom,client-id\"\n");
+		return ret;
+
+	}
+
+	rmtfs_mem = kzalloc(sizeof(*rmtfs_mem), GFP_KERNEL);
+	if (!rmtfs_mem)
+		return -ENOMEM;
+
+	rmtfs_mem->addr = rmem->base;
+	rmtfs_mem->client_id = client_id;
+	rmtfs_mem->size = rmem->size;
+
+	device_initialize(&rmtfs_mem->dev);
+	rmtfs_mem->dev.parent = &pdev->dev;
+	rmtfs_mem->dev.groups = qcom_rmtfs_mem_groups;
+
+	rmtfs_mem->base = devm_memremap(&rmtfs_mem->dev, rmtfs_mem->addr,
+					rmtfs_mem->size, MEMREMAP_WC);
+	if (IS_ERR(rmtfs_mem->base)) {
+		dev_err(&pdev->dev, "failed to remap rmtfs_mem region\n");
+		ret = PTR_ERR(rmtfs_mem->base);
+		goto put_device;
+	}
+
+	cdev_init(&rmtfs_mem->cdev, &qcom_rmtfs_mem_fops);
+	rmtfs_mem->cdev.owner = THIS_MODULE;
+
+	dev_set_name(&rmtfs_mem->dev, "qcom_rmtfs_mem%d", client_id);
+	rmtfs_mem->dev.id = client_id;
+	rmtfs_mem->dev.devt = MKDEV(MAJOR(qcom_rmtfs_mem_major), client_id);
+
+	ret = cdev_device_add(&rmtfs_mem->cdev, &rmtfs_mem->dev);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add cdev: %d\n", ret);
+		goto put_device;
+	}
+
+	rmtfs_mem->dev.release = qcom_rmtfs_mem_release_device;
+
+	dev_set_drvdata(&pdev->dev, rmtfs_mem);
+
+	return 0;
+
+remove_cdev:
+	cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev);
+put_device:
+	put_device(&rmtfs_mem->dev);
+
+	return ret;
+}
+
+static int qcom_rmtfs_mem_remove(struct platform_device *pdev)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = dev_get_drvdata(&pdev->dev);
+
+	cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev);
+	put_device(&rmtfs_mem->dev);
+
+	return 0;
+}
+
+static const struct of_device_id qcom_rmtfs_mem_of_match[] = {
+	{ .compatible = "qcom,rmtfs-mem" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, qcom_rmtfs_mem_of_match);
+
+static struct platform_driver qcom_rmtfs_mem_driver = {
+	.probe = qcom_rmtfs_mem_probe,
+	.remove = qcom_rmtfs_mem_remove,
+	.driver  = {
+		.name  = "qcom_rmtfs_mem",
+		.of_match_table = qcom_rmtfs_mem_of_match,
+	},
+};
+
+static int qcom_rmtfs_mem_init(void)
+{
+	int ret;
+
+	ret = alloc_chrdev_region(&qcom_rmtfs_mem_major, 0,
+				  QCOM_RMTFS_MEM_DEV_MAX, "qcom_rmtfs_mem");
+	if (ret < 0) {
+		pr_err("qcom_rmtfs_mem: failed to allocate char dev region\n");
+		return ret;
+	}
+
+	ret = platform_driver_register(&qcom_rmtfs_mem_driver);
+	if (ret < 0) {
+		pr_err("qcom_rmtfs_mem: failed to register rmtfs_mem driver\n");
+		unregister_chrdev_region(qcom_rmtfs_mem_major,
+					 QCOM_RMTFS_MEM_DEV_MAX);
+	}
+
+	return ret;
+}
+module_init(qcom_rmtfs_mem_init);
+
+static void qcom_rmtfs_mem_exit(void)
+{
+	platform_driver_unregister(&qcom_rmtfs_mem_driver);
+	unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX);
+}
+module_exit(qcom_rmtfs_mem_exit);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/5] soc: qcom: Remote filesystem memory driver
@ 2017-10-05  3:32   ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

The Qualcomm remote file system protocol is used by certain remoteprocs,
in particular the modem, to read and write persistent storage in
platforms where only the application CPU has physical storage access.

The protocol is based on a set of QMI-encoded control-messages and a
shared memory buffer for exchaning the data. This driver implements the
latter, providing the user space service access to the carved out chunk
of memory.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Renamed driver to "rmtfs_mem" in attempt to clarify that this is not a
  file system, but some chunk of memory.

Changes since v1:
- RFSA device represented direclty by the reserved-memory node

 drivers/of/platform.c        |   1 +
 drivers/soc/qcom/Kconfig     |  11 ++
 drivers/soc/qcom/Makefile    |   1 +
 drivers/soc/qcom/rmtfs_mem.c | 272 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 285 insertions(+)
 create mode 100644 drivers/soc/qcom/rmtfs_mem.c

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ee89f096f0f3..e7548c9a9915 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -498,6 +498,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
 static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "qcom,rmtfs-mem" },
 	{ .compatible = "ramoops" },
 	{}
 };
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 9fca977ef18d..6dff89eaf3f8 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -24,6 +24,17 @@ config QCOM_PM
 	  modes. It interface with various system drivers to put the cores in
 	  low power modes.
 
+config QCOM_RMTFS_MEM
+	tristate "Qualcomm Remote Filesystem memory driver"
+	depends on ARCH_QCOM
+	help
+	  The Qualcomm remote filesystem memory driver is used for allocating
+	  and exposing regions of shared memory with remote processors for the
+	  purpose of exchanging sector-data between the remote filesystem
+	  service and its clients.
+
+	  Say y here if you intend to boot the modem remoteproc.
+
 config QCOM_SMEM
 	tristate "Qualcomm Shared Memory Manager (SMEM)"
 	depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 414f0de274fa..541c1f40d126 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)	+= mdt_loader.o
 obj-$(CONFIG_QCOM_PM)	+=	spm.o
+obj-$(CONFIG_QCOM_RMTFS_MEM)	+= rmtfs_mem.o
 obj-$(CONFIG_QCOM_SMD_RPM)	+= smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) +=	smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
new file mode 100644
index 000000000000..2e7c955e7cf0
--- /dev/null
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2017 Linaro Ltd.
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/cdev.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/of_fdt.h>
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include <linux/qcom_scm.h>
+
+#define QCOM_RMTFS_MEM_DEV_MAX	(MINORMASK + 1)
+
+static dev_t qcom_rmtfs_mem_major;
+
+struct qcom_rmtfs_mem {
+	struct device dev;
+	struct cdev cdev;
+
+	void *base;
+	phys_addr_t addr;
+	phys_addr_t size;
+
+	unsigned int client_id;
+};
+
+static ssize_t qcom_rmtfs_mem_show(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf);
+
+static DEVICE_ATTR(phys_addr, 0400, qcom_rmtfs_mem_show, NULL);
+static DEVICE_ATTR(size, 0400, qcom_rmtfs_mem_show, NULL);
+static DEVICE_ATTR(client_id, 0400, qcom_rmtfs_mem_show, NULL);
+
+static ssize_t qcom_rmtfs_mem_show(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = container_of(dev,
+							struct qcom_rmtfs_mem,
+							dev);
+
+	if (attr == &dev_attr_phys_addr)
+		return sprintf(buf, "%pa\n", &rmtfs_mem->addr);
+	if (attr == &dev_attr_size)
+		return sprintf(buf, "%pa\n", &rmtfs_mem->size);
+	if (attr == &dev_attr_client_id)
+		return sprintf(buf, "%d\n", rmtfs_mem->client_id);
+
+	return -EINVAL;
+}
+
+static struct attribute *qcom_rmtfs_mem_attrs[] = {
+	&dev_attr_phys_addr.attr,
+	&dev_attr_size.attr,
+	&dev_attr_client_id.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(qcom_rmtfs_mem);
+
+static int qcom_rmtfs_mem_open(struct inode *inode, struct file *filp)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = container_of(inode->i_cdev,
+							struct qcom_rmtfs_mem,
+							cdev);
+
+	get_device(&rmtfs_mem->dev);
+	filp->private_data = rmtfs_mem;
+
+	return 0;
+}
+static ssize_t qcom_rmtfs_mem_read(struct file *filp,
+			      char __user *buf, size_t count, loff_t *f_pos)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+
+	if (*f_pos >= rmtfs_mem->size)
+		return 0;
+
+	if (*f_pos + count >= rmtfs_mem->size)
+		count = rmtfs_mem->size - *f_pos;
+
+	if (copy_to_user(buf, rmtfs_mem->base + *f_pos, count))
+		return -EFAULT;
+
+	*f_pos += count;
+	return count;
+}
+
+static ssize_t qcom_rmtfs_mem_write(struct file *filp,
+			       const char __user *buf, size_t count,
+			       loff_t *f_pos)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+
+	if (*f_pos >= rmtfs_mem->size)
+		return 0;
+
+	if (*f_pos + count >= rmtfs_mem->size)
+		count = rmtfs_mem->size - *f_pos;
+
+	if (copy_from_user(rmtfs_mem->base + *f_pos, buf, count))
+		return -EFAULT;
+
+	*f_pos += count;
+	return count;
+}
+
+static int qcom_rmtfs_mem_release(struct inode *inode, struct file *filp)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+
+	put_device(&rmtfs_mem->dev);
+
+	return 0;
+}
+
+static const struct file_operations qcom_rmtfs_mem_fops = {
+	.owner = THIS_MODULE,
+	.open = qcom_rmtfs_mem_open,
+	.read = qcom_rmtfs_mem_read,
+	.write = qcom_rmtfs_mem_write,
+	.release = qcom_rmtfs_mem_release,
+	.llseek = default_llseek,
+};
+
+static void qcom_rmtfs_mem_release_device(struct device *dev)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = container_of(dev,
+							struct qcom_rmtfs_mem,
+							dev);
+
+	kfree(rmtfs_mem);
+}
+
+static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct reserved_mem *rmem;
+	struct qcom_rmtfs_mem *rmtfs_mem;
+	u32 client_id;
+	int ret;
+
+	rmem = of_reserved_mem_get(node);
+	if (!rmem) {
+		dev_err(&pdev->dev, "failed to acquire memory region\n");
+		return -EINVAL;
+	}
+
+	ret = of_property_read_u32(node, "qcom,client-id", &client_id);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to parse \"qcom,client-id\"\n");
+		return ret;
+
+	}
+
+	rmtfs_mem = kzalloc(sizeof(*rmtfs_mem), GFP_KERNEL);
+	if (!rmtfs_mem)
+		return -ENOMEM;
+
+	rmtfs_mem->addr = rmem->base;
+	rmtfs_mem->client_id = client_id;
+	rmtfs_mem->size = rmem->size;
+
+	device_initialize(&rmtfs_mem->dev);
+	rmtfs_mem->dev.parent = &pdev->dev;
+	rmtfs_mem->dev.groups = qcom_rmtfs_mem_groups;
+
+	rmtfs_mem->base = devm_memremap(&rmtfs_mem->dev, rmtfs_mem->addr,
+					rmtfs_mem->size, MEMREMAP_WC);
+	if (IS_ERR(rmtfs_mem->base)) {
+		dev_err(&pdev->dev, "failed to remap rmtfs_mem region\n");
+		ret = PTR_ERR(rmtfs_mem->base);
+		goto put_device;
+	}
+
+	cdev_init(&rmtfs_mem->cdev, &qcom_rmtfs_mem_fops);
+	rmtfs_mem->cdev.owner = THIS_MODULE;
+
+	dev_set_name(&rmtfs_mem->dev, "qcom_rmtfs_mem%d", client_id);
+	rmtfs_mem->dev.id = client_id;
+	rmtfs_mem->dev.devt = MKDEV(MAJOR(qcom_rmtfs_mem_major), client_id);
+
+	ret = cdev_device_add(&rmtfs_mem->cdev, &rmtfs_mem->dev);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add cdev: %d\n", ret);
+		goto put_device;
+	}
+
+	rmtfs_mem->dev.release = qcom_rmtfs_mem_release_device;
+
+	dev_set_drvdata(&pdev->dev, rmtfs_mem);
+
+	return 0;
+
+remove_cdev:
+	cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev);
+put_device:
+	put_device(&rmtfs_mem->dev);
+
+	return ret;
+}
+
+static int qcom_rmtfs_mem_remove(struct platform_device *pdev)
+{
+	struct qcom_rmtfs_mem *rmtfs_mem = dev_get_drvdata(&pdev->dev);
+
+	cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev);
+	put_device(&rmtfs_mem->dev);
+
+	return 0;
+}
+
+static const struct of_device_id qcom_rmtfs_mem_of_match[] = {
+	{ .compatible = "qcom,rmtfs-mem" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, qcom_rmtfs_mem_of_match);
+
+static struct platform_driver qcom_rmtfs_mem_driver = {
+	.probe = qcom_rmtfs_mem_probe,
+	.remove = qcom_rmtfs_mem_remove,
+	.driver  = {
+		.name  = "qcom_rmtfs_mem",
+		.of_match_table = qcom_rmtfs_mem_of_match,
+	},
+};
+
+static int qcom_rmtfs_mem_init(void)
+{
+	int ret;
+
+	ret = alloc_chrdev_region(&qcom_rmtfs_mem_major, 0,
+				  QCOM_RMTFS_MEM_DEV_MAX, "qcom_rmtfs_mem");
+	if (ret < 0) {
+		pr_err("qcom_rmtfs_mem: failed to allocate char dev region\n");
+		return ret;
+	}
+
+	ret = platform_driver_register(&qcom_rmtfs_mem_driver);
+	if (ret < 0) {
+		pr_err("qcom_rmtfs_mem: failed to register rmtfs_mem driver\n");
+		unregister_chrdev_region(qcom_rmtfs_mem_major,
+					 QCOM_RMTFS_MEM_DEV_MAX);
+	}
+
+	return ret;
+}
+module_init(qcom_rmtfs_mem_init);
+
+static void qcom_rmtfs_mem_exit(void)
+{
+	platform_driver_unregister(&qcom_rmtfs_mem_driver);
+	unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX);
+}
+module_exit(qcom_rmtfs_mem_exit);
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 5/5] arm64: dts: msm8916: Mark rmtfs node as qcom,rmtfs-mem compatible
  2017-10-05  3:32 ` Bjorn Andersson
@ 2017-10-05  3:32   ` Bjorn Andersson
  -1 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: Andy Gross
  Cc: Anton Vorontsov, Colin Cross, David Brown, Frank Rowand,
	Kees Cook, Rob Herring, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, linux-soc

Now that we have a binding defined for the shared file system memory use
this to describe the rmtfs memory region.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- None

Changes since v1:
- New patch

 arch/arm64/boot/dts/qcom/msm8916.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 039991f80831..f6ae6f9b27e1 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -69,8 +69,11 @@
 		};
 
 		rmtfs@86700000 {
+			compatible = "qcom,rmtfs-mem";
 			reg = <0x0 0x86700000 0x0 0xe0000>;
 			no-map;
+
+			qcom,client-id = <1>;
 		};
 
 		rfsa@867e00000 {
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 5/5] arm64: dts: msm8916: Mark rmtfs node as qcom, rmtfs-mem compatible
@ 2017-10-05  3:32   ` Bjorn Andersson
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Andersson @ 2017-10-05  3:32 UTC (permalink / raw)
  To: linux-arm-kernel

Now that we have a binding defined for the shared file system memory use
this to describe the rmtfs memory region.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- None

Changes since v1:
- New patch

 arch/arm64/boot/dts/qcom/msm8916.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 039991f80831..f6ae6f9b27e1 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -69,8 +69,11 @@
 		};
 
 		rmtfs at 86700000 {
+			compatible = "qcom,rmtfs-mem";
 			reg = <0x0 0x86700000 0x0 0xe0000>;
 			no-map;
+
+			qcom,client-id = <1>;
 		};
 
 		rfsa at 867e00000 {
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/5] soc: qcom: Remote filesystem memory driver
  2017-10-05  3:32   ` Bjorn Andersson
  (?)
@ 2017-10-10  0:49     ` Rob Herring
  -1 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:49 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Anton Vorontsov, Colin Cross, David Brown,
	Frank Rowand, Kees Cook, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, open list:ARM/QUALCOMM SUPPORT

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> The Qualcomm remote file system protocol is used by certain remoteprocs,
> in particular the modem, to read and write persistent storage in
> platforms where only the application CPU has physical storage access.
>
> The protocol is based on a set of QMI-encoded control-messages and a
> shared memory buffer for exchaning the data. This driver implements the
> latter, providing the user space service access to the carved out chunk
> of memory.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v2:
> - Renamed driver to "rmtfs_mem" in attempt to clarify that this is not a
>   file system, but some chunk of memory.
>
> Changes since v1:
> - RFSA device represented direclty by the reserved-memory node
>
>  drivers/of/platform.c        |   1 +
>  drivers/soc/qcom/Kconfig     |  11 ++
>  drivers/soc/qcom/Makefile    |   1 +
>  drivers/soc/qcom/rmtfs_mem.c | 272 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 285 insertions(+)
>  create mode 100644 drivers/soc/qcom/rmtfs_mem.c
>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index ee89f096f0f3..e7548c9a9915 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -498,6 +498,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
>
>  #ifndef CONFIG_PPC
>  static const struct of_device_id reserved_mem_matches[] = {
> +       { .compatible = "qcom,rmtfs-mem" },
>         { .compatible = "ramoops" },
>         {}
>  };
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 9fca977ef18d..6dff89eaf3f8 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -24,6 +24,17 @@ config QCOM_PM
>           modes. It interface with various system drivers to put the cores in
>           low power modes.
>
> +config QCOM_RMTFS_MEM
> +       tristate "Qualcomm Remote Filesystem memory driver"
> +       depends on ARCH_QCOM
> +       help
> +         The Qualcomm remote filesystem memory driver is used for allocating
> +         and exposing regions of shared memory with remote processors for the
> +         purpose of exchanging sector-data between the remote filesystem
> +         service and its clients.
> +
> +         Say y here if you intend to boot the modem remoteproc.
> +
>  config QCOM_SMEM
>         tristate "Qualcomm Shared Memory Manager (SMEM)"
>         depends on ARCH_QCOM
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 414f0de274fa..541c1f40d126 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_QCOM_GSBI)        +=      qcom_gsbi.o
>  obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
>  obj-$(CONFIG_QCOM_PM)  +=      spm.o
> +obj-$(CONFIG_QCOM_RMTFS_MEM)   += rmtfs_mem.o
>  obj-$(CONFIG_QCOM_SMD_RPM)     += smd-rpm.o
>  obj-$(CONFIG_QCOM_SMEM) +=     smem.o
>  obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> new file mode 100644
> index 000000000000..2e7c955e7cf0
> --- /dev/null
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -0,0 +1,272 @@
> +/*
> + * Copyright (c) 2017 Linaro Ltd.
> + *
> + * 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.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/cdev.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/of_reserved_mem.h>
> +#include <linux/of_fdt.h>

This shouldn't be needed?


> +#include <linux/dma-mapping.h>
> +#include <linux/slab.h>
> +#include <linux/uaccess.h>
> +#include <linux/io.h>
> +#include <linux/qcom_scm.h>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/5] soc: qcom: Remote filesystem memory driver
@ 2017-10-10  0:49     ` Rob Herring
  0 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:49 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Anton Vorontsov, Colin Cross, David Brown,
	Frank Rowand, Kees Cook, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, open list:ARM/QUALCOMM SUPPORT

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> The Qualcomm remote file system protocol is used by certain remoteprocs,
> in particular the modem, to read and write persistent storage in
> platforms where only the application CPU has physical storage access.
>
> The protocol is based on a set of QMI-encoded control-messages and a
> shared memory buffer for exchaning the data. This driver implements the
> latter, providing the user space service access to the carved out chunk
> of memory.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v2:
> - Renamed driver to "rmtfs_mem" in attempt to clarify that this is not a
>   file system, but some chunk of memory.
>
> Changes since v1:
> - RFSA device represented direclty by the reserved-memory node
>
>  drivers/of/platform.c        |   1 +
>  drivers/soc/qcom/Kconfig     |  11 ++
>  drivers/soc/qcom/Makefile    |   1 +
>  drivers/soc/qcom/rmtfs_mem.c | 272 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 285 insertions(+)
>  create mode 100644 drivers/soc/qcom/rmtfs_mem.c
>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index ee89f096f0f3..e7548c9a9915 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -498,6 +498,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
>
>  #ifndef CONFIG_PPC
>  static const struct of_device_id reserved_mem_matches[] = {
> +       { .compatible = "qcom,rmtfs-mem" },
>         { .compatible = "ramoops" },
>         {}
>  };
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 9fca977ef18d..6dff89eaf3f8 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -24,6 +24,17 @@ config QCOM_PM
>           modes. It interface with various system drivers to put the cores in
>           low power modes.
>
> +config QCOM_RMTFS_MEM
> +       tristate "Qualcomm Remote Filesystem memory driver"
> +       depends on ARCH_QCOM
> +       help
> +         The Qualcomm remote filesystem memory driver is used for allocating
> +         and exposing regions of shared memory with remote processors for the
> +         purpose of exchanging sector-data between the remote filesystem
> +         service and its clients.
> +
> +         Say y here if you intend to boot the modem remoteproc.
> +
>  config QCOM_SMEM
>         tristate "Qualcomm Shared Memory Manager (SMEM)"
>         depends on ARCH_QCOM
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 414f0de274fa..541c1f40d126 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_QCOM_GSBI)        +=      qcom_gsbi.o
>  obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
>  obj-$(CONFIG_QCOM_PM)  +=      spm.o
> +obj-$(CONFIG_QCOM_RMTFS_MEM)   += rmtfs_mem.o
>  obj-$(CONFIG_QCOM_SMD_RPM)     += smd-rpm.o
>  obj-$(CONFIG_QCOM_SMEM) +=     smem.o
>  obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> new file mode 100644
> index 000000000000..2e7c955e7cf0
> --- /dev/null
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -0,0 +1,272 @@
> +/*
> + * Copyright (c) 2017 Linaro Ltd.
> + *
> + * 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.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/cdev.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/of_reserved_mem.h>
> +#include <linux/of_fdt.h>

This shouldn't be needed?


> +#include <linux/dma-mapping.h>
> +#include <linux/slab.h>
> +#include <linux/uaccess.h>
> +#include <linux/io.h>
> +#include <linux/qcom_scm.h>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 4/5] soc: qcom: Remote filesystem memory driver
@ 2017-10-10  0:49     ` Rob Herring
  0 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> The Qualcomm remote file system protocol is used by certain remoteprocs,
> in particular the modem, to read and write persistent storage in
> platforms where only the application CPU has physical storage access.
>
> The protocol is based on a set of QMI-encoded control-messages and a
> shared memory buffer for exchaning the data. This driver implements the
> latter, providing the user space service access to the carved out chunk
> of memory.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v2:
> - Renamed driver to "rmtfs_mem" in attempt to clarify that this is not a
>   file system, but some chunk of memory.
>
> Changes since v1:
> - RFSA device represented direclty by the reserved-memory node
>
>  drivers/of/platform.c        |   1 +
>  drivers/soc/qcom/Kconfig     |  11 ++
>  drivers/soc/qcom/Makefile    |   1 +
>  drivers/soc/qcom/rmtfs_mem.c | 272 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 285 insertions(+)
>  create mode 100644 drivers/soc/qcom/rmtfs_mem.c
>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index ee89f096f0f3..e7548c9a9915 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -498,6 +498,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
>
>  #ifndef CONFIG_PPC
>  static const struct of_device_id reserved_mem_matches[] = {
> +       { .compatible = "qcom,rmtfs-mem" },
>         { .compatible = "ramoops" },
>         {}
>  };
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 9fca977ef18d..6dff89eaf3f8 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -24,6 +24,17 @@ config QCOM_PM
>           modes. It interface with various system drivers to put the cores in
>           low power modes.
>
> +config QCOM_RMTFS_MEM
> +       tristate "Qualcomm Remote Filesystem memory driver"
> +       depends on ARCH_QCOM
> +       help
> +         The Qualcomm remote filesystem memory driver is used for allocating
> +         and exposing regions of shared memory with remote processors for the
> +         purpose of exchanging sector-data between the remote filesystem
> +         service and its clients.
> +
> +         Say y here if you intend to boot the modem remoteproc.
> +
>  config QCOM_SMEM
>         tristate "Qualcomm Shared Memory Manager (SMEM)"
>         depends on ARCH_QCOM
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 414f0de274fa..541c1f40d126 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_QCOM_GSBI)        +=      qcom_gsbi.o
>  obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
>  obj-$(CONFIG_QCOM_PM)  +=      spm.o
> +obj-$(CONFIG_QCOM_RMTFS_MEM)   += rmtfs_mem.o
>  obj-$(CONFIG_QCOM_SMD_RPM)     += smd-rpm.o
>  obj-$(CONFIG_QCOM_SMEM) +=     smem.o
>  obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> new file mode 100644
> index 000000000000..2e7c955e7cf0
> --- /dev/null
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -0,0 +1,272 @@
> +/*
> + * Copyright (c) 2017 Linaro Ltd.
> + *
> + * 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.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/cdev.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <linux/of_reserved_mem.h>
> +#include <linux/of_fdt.h>

This shouldn't be needed?


> +#include <linux/dma-mapping.h>
> +#include <linux/slab.h>
> +#include <linux/uaccess.h>
> +#include <linux/io.h>
> +#include <linux/qcom_scm.h>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling
  2017-10-05  3:32   ` Bjorn Andersson
  (?)
@ 2017-10-10  0:50       ` Rob Herring
  -1 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:50 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Anton Vorontsov, Colin Cross, Frank Rowand,
	Kees Cook, Tony Luck, David Brown,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-msm,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	open list:ARM/QUALCOMM SUPPORT

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> By iterating over all /reserved-memory child nodes and match each one to
> a list of compatibles that we want to treat specially, we can easily
> extend the list of compatibles to handle - without having to resort to
> of_platform_populate() that would create unnecessary platform_devices.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---

Reviewed-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling
@ 2017-10-10  0:50       ` Rob Herring
  0 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:50 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Anton Vorontsov, Colin Cross, Frank Rowand,
	Kees Cook, Tony Luck, David Brown, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, open list:ARM/QUALCOMM SUPPORT

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> By iterating over all /reserved-memory child nodes and match each one to
> a list of compatibles that we want to treat specially, we can easily
> extend the list of compatibles to handle - without having to resort to
> of_platform_populate() that would create unnecessary platform_devices.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling
@ 2017-10-10  0:50       ` Rob Herring
  0 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> By iterating over all /reserved-memory child nodes and match each one to
> a list of compatibles that we want to treat specially, we can easily
> extend the list of compatibles to handle - without having to resort to
> of_platform_populate() that would create unnecessary platform_devices.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/5] of: reserved_mem: Accessor for acquiring reserved_mem
  2017-10-05  3:32   ` Bjorn Andersson
  (?)
@ 2017-10-10  0:52     ` Rob Herring
  -1 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:52 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Frank Rowand, Anton Vorontsov, Colin Cross,
	David Brown, Kees Cook, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, open list:ARM/QUALCOMM SUPPORT

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> In some cases drivers referencing a reserved-memory region might want to
> remap the entire region, but when defining the reserved-memory by "size"
> the client driver has no means to know the associated base address of
> the reserved memory region.
>
> This patch adds an accessor for such drivers to acquire a handle to
> their associated reserved-memory for this purpose.
>
> A complicating factor for the implementation is that the reserved_mem
> objects are created from the flattened DeviceTree, as such we can't
> use the device_node address for comparison. Fortunately the name of the
> node will be used as "name" of the reserved_mem and will be used when
> building the full_name, so we can compare the "name" with the basename
> of the full_name to find the match.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v2:
> - None
>
> Changes since v1:
> - Previous patch provided interface to resolve memory-region reference, instead
>   of direct lookup by device_node
>
>  drivers/of/of_reserved_mem.c    | 26 ++++++++++++++++++++++++++
>  include/linux/of_reserved_mem.h |  5 +++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index d507c3569a88..b40cfce68fd4 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev)
>         rmem->ops->device_release(rmem, dev);
>  }
>  EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
> +
> +/**
> + * of_reserved_mem_get() - acquire reserved_mem from a device node

*_get() generally implies reference counting. Maybe "lookup" instead. Otherwise,

Reviewed-by: Rob Herring <robh@kernel.org>

> + * @np:                node pointer of the desired reserved-memory region
> + *
> + * This function allows drivers to acquire a reference to the reserved_mem
> + * struct based on a device node handle.
> + *
> + * Returns a reserved_mem reference, or NULL on error.
> + */
> +struct reserved_mem *of_reserved_mem_get(struct device_node *np)
> +{
> +       const char *name;
> +       int i;
> +
> +       if (!np->full_name)
> +               return NULL;
> +
> +       name = kbasename(np->full_name);
> +       for (i = 0; i < reserved_mem_count; i++)
> +               if (!strcmp(reserved_mem[i].name, name))
> +                       return &reserved_mem[i];
> +
> +       return NULL;
> +}
> +EXPORT_SYMBOL_GPL(of_reserved_mem_get);
> diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
> index f8e1992d6423..91b1eb5076e4 100644
> --- a/include/linux/of_reserved_mem.h
> +++ b/include/linux/of_reserved_mem.h
> @@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
>  void fdt_init_reserved_mem(void);
>  void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
>                                phys_addr_t base, phys_addr_t size);
> +struct reserved_mem *of_reserved_mem_get(struct device_node *np);
>  #else
>  static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
>                                         struct device_node *np, int idx)
> @@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { }
>  static inline void fdt_init_reserved_mem(void) { }
>  static inline void fdt_reserved_mem_save_node(unsigned long node,
>                 const char *uname, phys_addr_t base, phys_addr_t size) { }
> +static inline struct reserved_mem *of_reserved_mem_get(struct device_node *np)
> +{
> +       return NULL;
> +}
>  #endif
>
>  /**
> --
> 2.12.0
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/5] of: reserved_mem: Accessor for acquiring reserved_mem
@ 2017-10-10  0:52     ` Rob Herring
  0 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:52 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Frank Rowand, Anton Vorontsov, Colin Cross,
	David Brown, Kees Cook, Tony Luck, devicetree, linux-arm-kernel,
	linux-arm-msm, linux-kernel, open list:ARM/QUALCOMM SUPPORT

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> In some cases drivers referencing a reserved-memory region might want to
> remap the entire region, but when defining the reserved-memory by "size"
> the client driver has no means to know the associated base address of
> the reserved memory region.
>
> This patch adds an accessor for such drivers to acquire a handle to
> their associated reserved-memory for this purpose.
>
> A complicating factor for the implementation is that the reserved_mem
> objects are created from the flattened DeviceTree, as such we can't
> use the device_node address for comparison. Fortunately the name of the
> node will be used as "name" of the reserved_mem and will be used when
> building the full_name, so we can compare the "name" with the basename
> of the full_name to find the match.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v2:
> - None
>
> Changes since v1:
> - Previous patch provided interface to resolve memory-region reference, instead
>   of direct lookup by device_node
>
>  drivers/of/of_reserved_mem.c    | 26 ++++++++++++++++++++++++++
>  include/linux/of_reserved_mem.h |  5 +++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index d507c3569a88..b40cfce68fd4 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev)
>         rmem->ops->device_release(rmem, dev);
>  }
>  EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
> +
> +/**
> + * of_reserved_mem_get() - acquire reserved_mem from a device node

*_get() generally implies reference counting. Maybe "lookup" instead. Otherwise,

Reviewed-by: Rob Herring <robh@kernel.org>

> + * @np:                node pointer of the desired reserved-memory region
> + *
> + * This function allows drivers to acquire a reference to the reserved_mem
> + * struct based on a device node handle.
> + *
> + * Returns a reserved_mem reference, or NULL on error.
> + */
> +struct reserved_mem *of_reserved_mem_get(struct device_node *np)
> +{
> +       const char *name;
> +       int i;
> +
> +       if (!np->full_name)
> +               return NULL;
> +
> +       name = kbasename(np->full_name);
> +       for (i = 0; i < reserved_mem_count; i++)
> +               if (!strcmp(reserved_mem[i].name, name))
> +                       return &reserved_mem[i];
> +
> +       return NULL;
> +}
> +EXPORT_SYMBOL_GPL(of_reserved_mem_get);
> diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
> index f8e1992d6423..91b1eb5076e4 100644
> --- a/include/linux/of_reserved_mem.h
> +++ b/include/linux/of_reserved_mem.h
> @@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
>  void fdt_init_reserved_mem(void);
>  void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
>                                phys_addr_t base, phys_addr_t size);
> +struct reserved_mem *of_reserved_mem_get(struct device_node *np);
>  #else
>  static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
>                                         struct device_node *np, int idx)
> @@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { }
>  static inline void fdt_init_reserved_mem(void) { }
>  static inline void fdt_reserved_mem_save_node(unsigned long node,
>                 const char *uname, phys_addr_t base, phys_addr_t size) { }
> +static inline struct reserved_mem *of_reserved_mem_get(struct device_node *np)
> +{
> +       return NULL;
> +}
>  #endif
>
>  /**
> --
> 2.12.0
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 2/5] of: reserved_mem: Accessor for acquiring reserved_mem
@ 2017-10-10  0:52     ` Rob Herring
  0 siblings, 0 replies; 22+ messages in thread
From: Rob Herring @ 2017-10-10  0:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 4, 2017 at 10:32 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> In some cases drivers referencing a reserved-memory region might want to
> remap the entire region, but when defining the reserved-memory by "size"
> the client driver has no means to know the associated base address of
> the reserved memory region.
>
> This patch adds an accessor for such drivers to acquire a handle to
> their associated reserved-memory for this purpose.
>
> A complicating factor for the implementation is that the reserved_mem
> objects are created from the flattened DeviceTree, as such we can't
> use the device_node address for comparison. Fortunately the name of the
> node will be used as "name" of the reserved_mem and will be used when
> building the full_name, so we can compare the "name" with the basename
> of the full_name to find the match.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> Changes since v2:
> - None
>
> Changes since v1:
> - Previous patch provided interface to resolve memory-region reference, instead
>   of direct lookup by device_node
>
>  drivers/of/of_reserved_mem.c    | 26 ++++++++++++++++++++++++++
>  include/linux/of_reserved_mem.h |  5 +++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index d507c3569a88..b40cfce68fd4 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev)
>         rmem->ops->device_release(rmem, dev);
>  }
>  EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
> +
> +/**
> + * of_reserved_mem_get() - acquire reserved_mem from a device node

*_get() generally implies reference counting. Maybe "lookup" instead. Otherwise,

Reviewed-by: Rob Herring <robh@kernel.org>

> + * @np:                node pointer of the desired reserved-memory region
> + *
> + * This function allows drivers to acquire a reference to the reserved_mem
> + * struct based on a device node handle.
> + *
> + * Returns a reserved_mem reference, or NULL on error.
> + */
> +struct reserved_mem *of_reserved_mem_get(struct device_node *np)
> +{
> +       const char *name;
> +       int i;
> +
> +       if (!np->full_name)
> +               return NULL;
> +
> +       name = kbasename(np->full_name);
> +       for (i = 0; i < reserved_mem_count; i++)
> +               if (!strcmp(reserved_mem[i].name, name))
> +                       return &reserved_mem[i];
> +
> +       return NULL;
> +}
> +EXPORT_SYMBOL_GPL(of_reserved_mem_get);
> diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
> index f8e1992d6423..91b1eb5076e4 100644
> --- a/include/linux/of_reserved_mem.h
> +++ b/include/linux/of_reserved_mem.h
> @@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
>  void fdt_init_reserved_mem(void);
>  void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
>                                phys_addr_t base, phys_addr_t size);
> +struct reserved_mem *of_reserved_mem_get(struct device_node *np);
>  #else
>  static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
>                                         struct device_node *np, int idx)
> @@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { }
>  static inline void fdt_init_reserved_mem(void) { }
>  static inline void fdt_reserved_mem_save_node(unsigned long node,
>                 const char *uname, phys_addr_t base, phys_addr_t size) { }
> +static inline struct reserved_mem *of_reserved_mem_get(struct device_node *np)
> +{
> +       return NULL;
> +}
>  #endif
>
>  /**
> --
> 2.12.0
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-10-10  0:52 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05  3:32 [PATCH v3 0/5] Qualcomm remote filesystem shared memory driver Bjorn Andersson
2017-10-05  3:32 ` Bjorn Andersson
2017-10-05  3:32 ` [PATCH v3 1/5] of/platform: Generalize /reserved-memory handling Bjorn Andersson
2017-10-05  3:32   ` Bjorn Andersson
2017-10-05  3:32   ` Bjorn Andersson
     [not found]   ` <20171005033258.12825-2-bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-10-10  0:50     ` Rob Herring
2017-10-10  0:50       ` Rob Herring
2017-10-10  0:50       ` Rob Herring
2017-10-05  3:32 ` [PATCH v3 2/5] of: reserved_mem: Accessor for acquiring reserved_mem Bjorn Andersson
2017-10-05  3:32   ` Bjorn Andersson
2017-10-10  0:52   ` Rob Herring
2017-10-10  0:52     ` Rob Herring
2017-10-10  0:52     ` Rob Herring
2017-10-05  3:32 ` [PATCH v3 3/5] dt-binding: soc: qcom: Add binding for rmtfs memory Bjorn Andersson
2017-10-05  3:32   ` Bjorn Andersson
2017-10-05  3:32 ` [PATCH v3 4/5] soc: qcom: Remote filesystem memory driver Bjorn Andersson
2017-10-05  3:32   ` Bjorn Andersson
2017-10-10  0:49   ` Rob Herring
2017-10-10  0:49     ` Rob Herring
2017-10-10  0:49     ` Rob Herring
2017-10-05  3:32 ` [PATCH v3 5/5] arm64: dts: msm8916: Mark rmtfs node as qcom,rmtfs-mem compatible Bjorn Andersson
2017-10-05  3:32   ` [PATCH v3 5/5] arm64: dts: msm8916: Mark rmtfs node as qcom, rmtfs-mem compatible Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.