All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] rproc subdevice support
@ 2016-10-20  2:40 Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 01/11] remoteproc: Introduce subdevices Bjorn Andersson
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-remoteproc, linux-kernel, linux-arm-msm

This series consist of three sets of patches:

The first set introduces the concept of subdevices - entities that are probed
and removed following the running state of a remoteproc. This is then used by
the Qualcomm WCNSS PIL to control the life cycle of the associated SMD channels
and devices.

The second set starts by decoupling vring allocation from the virtio device,
both to make the vring allocation follow the style of carveout allocations and
to allow the virtio devices to be implemented as subdevices.

With the second set in place the third set cleans up the vdev resource handling
and lastly cleans up the table_ptr vs cached_table handling.

Bjorn Andersson (11):
  remoteproc: Introduce subdevices
  rpmsg: smd: Expose edge registration functions
  remoteproc: wcnss: Bond SMD edge to remoteproc
  dt-binding: remoteproc: wcnss: Allow describing smd edge
  remoteproc: Assign kref to rproc_vdev
  remoteproc: virtio: Anchor vring life cycle in vdev
  remoteproc: Further extend the vdev life cycle
  remoteproc: Decouple vdev resources and devices
  remoteproc: Update max_notifyid as we allocate vrings
  remoteproc: Remove custom vdev handler list
  remoteproc: Merge table_ptr and cached_table pointers

 .../bindings/remoteproc/qcom,wcnss-pil.txt         |  30 +++-
 drivers/remoteproc/qcom_wcnss.c                    |  27 +++
 drivers/remoteproc/remoteproc_core.c               | 188 +++++++++++++++------
 drivers/remoteproc/remoteproc_internal.h           |   1 +
 drivers/remoteproc/remoteproc_virtio.c             |  17 +-
 drivers/rpmsg/qcom_smd.c                           |   1 +
 include/linux/remoteproc.h                         |  34 +++-
 include/linux/rpmsg/qcom_smd.h                     |  33 ++++
 8 files changed, 267 insertions(+), 64 deletions(-)
 create mode 100644 include/linux/rpmsg/qcom_smd.h

-- 
2.5.0

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

* [PATCH 01/11] remoteproc: Introduce subdevices
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 02/11] rpmsg: smd: Expose edge registration functions Bjorn Andersson
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-remoteproc, linux-kernel, Sarangdhar Joshi, linux-arm-msm

A subdevice is an abstract entity that can be used to tie actions to the
booting and shutting down of a remote processor. The subdevice object is
expected to be embedded in concrete implementations, allowing for a
variety of use cases to be implemented.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 72 ++++++++++++++++++++++++++++++++++++
 include/linux/remoteproc.h           | 22 +++++++++++
 2 files changed, 94 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c6bfb3496684..4309996f4335 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -736,6 +736,34 @@ static int rproc_handle_resources(struct rproc *rproc, int len,
 	return ret;
 }
 
+static int rproc_probe_subdevices(struct rproc *rproc)
+{
+	struct rproc_subdev *subdev;
+	int ret;
+
+	list_for_each_entry(subdev, &rproc->subdevs, node) {
+		ret = subdev->probe(subdev);
+		if (ret)
+			goto unroll_registration;
+	}
+
+	return 0;
+
+unroll_registration:
+	list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node)
+		subdev->remove(subdev);
+
+	return ret;
+}
+
+static void rproc_remove_subdevices(struct rproc *rproc)
+{
+	struct rproc_subdev *subdev;
+
+	list_for_each_entry(subdev, &rproc->subdevs, node)
+		subdev->remove(subdev);
+}
+
 /**
  * rproc_resource_cleanup() - clean up and free all acquired resources
  * @rproc: rproc handle
@@ -878,12 +906,22 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
 		goto clean_up_resources;
 	}
 
+	/* probe any subdevices for the remote processor */
+	ret = rproc_probe_subdevices(rproc);
+	if (ret) {
+		dev_err(dev, "failed to probe subdevices for %s: %d\n",
+			rproc->name, ret);
+		goto stop_rproc;
+	}
+
 	rproc->state = RPROC_RUNNING;
 
 	dev_info(dev, "remote processor %s is now up\n", rproc->name);
 
 	return 0;
 
+stop_rproc:
+	rproc->ops->stop(rproc);
 clean_up_resources:
 	rproc_resource_cleanup(rproc);
 clean_up:
@@ -1121,6 +1159,9 @@ void rproc_shutdown(struct rproc *rproc)
 	if (!atomic_dec_and_test(&rproc->power))
 		goto out;
 
+	/* remove any subdevices for the remote processor */
+	rproc_remove_subdevices(rproc);
+
 	/* power off the remote processor */
 	ret = rproc->ops->stop(rproc);
 	if (ret) {
@@ -1370,6 +1411,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
 	INIT_LIST_HEAD(&rproc->mappings);
 	INIT_LIST_HEAD(&rproc->traces);
 	INIT_LIST_HEAD(&rproc->rvdevs);
+	INIT_LIST_HEAD(&rproc->subdevs);
 
 	INIT_WORK(&rproc->crash_handler, rproc_crash_handler_work);
 	init_completion(&rproc->crash_comp);
@@ -1457,6 +1499,36 @@ int rproc_del(struct rproc *rproc)
 EXPORT_SYMBOL(rproc_del);
 
 /**
+ * rproc_add_subdev() - add a subdevice to a remoteproc
+ * @rproc: rproc handle to add the subdevice to
+ * @subdev: subdev handle to register
+ * @probe: function to call when the rproc boots
+ * @remove: function to call when the rproc shuts down
+ */
+void rproc_add_subdev(struct rproc *rproc,
+		      struct rproc_subdev *subdev,
+		      int (*probe)(struct rproc_subdev *subdev),
+		      void (*remove)(struct rproc_subdev *subdev))
+{
+	subdev->probe = probe;
+	subdev->remove = remove;
+
+	list_add_tail(&subdev->node, &rproc->subdevs);
+}
+EXPORT_SYMBOL(rproc_add_subdev);
+
+/**
+ * rproc_remove_subdev() - remove a subdevice from a remoteproc
+ * @rproc: rproc handle to remove the subdevice from
+ * @subdev: subdev handle, previously registered with rproc_add_subdev()
+ */
+void rproc_remove_subdev(struct rproc *rproc, struct rproc_subdev *subdev)
+{
+	list_del(&subdev->node);
+}
+EXPORT_SYMBOL(rproc_remove_subdev);
+
+/**
  * rproc_report_crash() - rproc crash reporter function
  * @rproc: remote processor
  * @type: crash type
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 930023b7c825..a05f4569a2a0 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -400,6 +400,7 @@ enum rproc_crash_type {
  * @firmware_loading_complete: marks e/o asynchronous firmware loading
  * @bootaddr: address of first instruction to boot rproc with (optional)
  * @rvdevs: list of remote virtio devices
+ * @subdevs: list of subdevices, to following the running state
  * @notifyids: idr for dynamically assigning rproc-wide unique notify ids
  * @index: index of this rproc device
  * @crash_handler: workqueue for handling a crash
@@ -431,6 +432,7 @@ struct rproc {
 	struct completion firmware_loading_complete;
 	u32 bootaddr;
 	struct list_head rvdevs;
+	struct list_head subdevs;
 	struct idr notifyids;
 	int index;
 	struct work_struct crash_handler;
@@ -444,6 +446,19 @@ struct rproc {
 	bool auto_boot;
 };
 
+/**
+ * struct rproc_subdev - subdevice tied to a remoteproc
+ * @node: list node related to the rproc subdevs list
+ * @probe: probe function, called as the rproc is started
+ * @remove: remove function, called as the rproc is stopped
+ */
+struct rproc_subdev {
+	struct list_head node;
+
+	int (*probe)(struct rproc_subdev *subdev);
+	void (*remove)(struct rproc_subdev *subdev);
+};
+
 /* we currently support only two vrings per rvdev */
 
 #define RVDEV_NUM_VRINGS 2
@@ -511,4 +526,11 @@ static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)
 	return rvdev->rproc;
 }
 
+void rproc_add_subdev(struct rproc *rproc,
+		      struct rproc_subdev *subdev,
+		      int (*probe)(struct rproc_subdev *subdev),
+		      void (*remove)(struct rproc_subdev *subdev));
+
+void rproc_remove_subdev(struct rproc *rproc, struct rproc_subdev *subdev);
+
 #endif /* REMOTEPROC_H */
-- 
2.5.0

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

* [PATCH 02/11] rpmsg: smd: Expose edge registration functions
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 01/11] remoteproc: Introduce subdevices Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 03/11] remoteproc: wcnss: Bond SMD edge to remoteproc Bjorn Andersson
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-remoteproc, linux-kernel, Sarangdhar Joshi, linux-arm-msm

The edge registration functions is to be used from a remoteproc driver
to register and unregister an edge as the remote processor comes and
goes.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/rpmsg/qcom_smd.c       |  1 +
 include/linux/rpmsg/qcom_smd.h | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 include/linux/rpmsg/qcom_smd.h

diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
index 952338a6296a..aded7352f089 100644
--- a/drivers/rpmsg/qcom_smd.c
+++ b/drivers/rpmsg/qcom_smd.c
@@ -25,6 +25,7 @@
 #include <linux/soc/qcom/smem.h>
 #include <linux/wait.h>
 #include <linux/rpmsg.h>
+#include <linux/rpmsg/qcom_smd.h>
 
 #include "rpmsg_internal.h"
 
diff --git a/include/linux/rpmsg/qcom_smd.h b/include/linux/rpmsg/qcom_smd.h
new file mode 100644
index 000000000000..7c12637a500e
--- /dev/null
+++ b/include/linux/rpmsg/qcom_smd.h
@@ -0,0 +1,33 @@
+
+#ifndef _LINUX_RPMSG_QCOM_SMD_H
+#define _LINUX_RPMSG_QCOM_SMD_H
+
+#include <linux/device.h>
+
+struct qcom_smd_edge;
+
+#if IS_ENABLED(CONFIG_RPMSG_QCOM_SMD)
+
+struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
+					     struct device_node *node);
+int qcom_smd_unregister_edge(struct qcom_smd_edge *edge);
+
+#else
+
+static inline struct qcom_smd_edge *
+qcom_smd_register_edge(struct device *parent,
+		       struct device_node *node)
+{
+	return ERR_PTR(-ENXIO);
+}
+
+static inline int qcom_smd_unregister_edge(struct qcom_smd_edge *edge)
+{
+	/* This shouldn't be possible */
+	WARN_ON(1);
+	return -ENXIO;
+}
+
+#endif
+
+#endif
-- 
2.5.0

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

* [PATCH 03/11] remoteproc: wcnss: Bond SMD edge to remoteproc
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 01/11] remoteproc: Introduce subdevices Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 02/11] rpmsg: smd: Expose edge registration functions Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 04/11] dt-binding: remoteproc: wcnss: Allow describing smd edge Bjorn Andersson
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-remoteproc, linux-kernel, Sarangdhar Joshi, linux-arm-msm

Allow the wcnss smd edge to be described as a child of the wcnss
remoteproc node and make the edge life cycle follow the running state of
the remoteproc.

This bond is necessary to clean up the smd state when the remote
processor is suddenly removed, and in some cases even when it shut down
in a controlled fasion.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/qcom_wcnss.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
index f5cedeaafba1..0c47fa286794 100644
--- a/drivers/remoteproc/qcom_wcnss.c
+++ b/drivers/remoteproc/qcom_wcnss.c
@@ -30,6 +30,7 @@
 #include <linux/remoteproc.h>
 #include <linux/soc/qcom/smem.h>
 #include <linux/soc/qcom/smem_state.h>
+#include <linux/rpmsg/qcom_smd.h>
 
 #include "qcom_mdt_loader.h"
 #include "remoteproc_internal.h"
@@ -94,6 +95,10 @@ struct qcom_wcnss {
 	phys_addr_t mem_reloc;
 	void *mem_region;
 	size_t mem_size;
+
+	struct device_node *smd_node;
+	struct qcom_smd_edge *smd_edge;
+	struct rproc_subdev smd_subdev;
 };
 
 static const struct wcnss_data riva_data = {
@@ -396,6 +401,23 @@ static irqreturn_t wcnss_stop_ack_interrupt(int irq, void *dev)
 	return IRQ_HANDLED;
 }
 
+static int wcnss_smd_probe(struct rproc_subdev *subdev)
+{
+	struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev);
+
+	wcnss->smd_edge = qcom_smd_register_edge(wcnss->dev, wcnss->smd_node);
+
+	return IS_ERR(wcnss->smd_edge) ? PTR_ERR(wcnss->smd_edge) : 0;
+}
+
+static void wcnss_smd_remove(struct rproc_subdev *subdev)
+{
+	struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev);
+
+	qcom_smd_unregister_edge(wcnss->smd_edge);
+	wcnss->smd_edge = NULL;
+}
+
 static int wcnss_init_regulators(struct qcom_wcnss *wcnss,
 				 const struct wcnss_vreg_info *info,
 				 int num_vregs)
@@ -578,6 +600,10 @@ static int wcnss_probe(struct platform_device *pdev)
 		}
 	}
 
+	wcnss->smd_node = of_get_child_by_name(pdev->dev.of_node, "smd-edge");
+	if (wcnss->smd_node)
+		rproc_add_subdev(rproc, &wcnss->smd_subdev, wcnss_smd_probe, wcnss_smd_remove);
+
 	ret = rproc_add(rproc);
 	if (ret)
 		goto free_rproc;
@@ -596,6 +622,7 @@ static int wcnss_remove(struct platform_device *pdev)
 
 	of_platform_depopulate(&pdev->dev);
 
+	of_node_put(wcnss->smd_node);
 	qcom_smem_state_put(wcnss->state);
 	rproc_del(wcnss->rproc);
 	rproc_free(wcnss->rproc);
-- 
2.5.0

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

* [PATCH 04/11] dt-binding: remoteproc: wcnss: Allow describing smd edge
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (2 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 03/11] remoteproc: wcnss: Bond SMD edge to remoteproc Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-11-10  0:45     ` Rob Herring
  2016-10-20  2:40 ` [PATCH 05/11] remoteproc: Assign kref to rproc_vdev Bjorn Andersson
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson, Rob Herring, Mark Rutland
  Cc: linux-remoteproc, linux-kernel, devicetree, Sarangdhar Joshi,
	linux-arm-msm

Allow the associated smd edge to be described within the wcnss
remoteproc node. This creates a bond between the remoteproc and the
associated smd channels and devices, showing the interaction between the
two parts and provides both a natural reference to the other.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 .../bindings/remoteproc/qcom,wcnss-pil.txt         | 30 ++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,wcnss-pil.txt b/Documentation/devicetree/bindings/remoteproc/qcom,wcnss-pil.txt
index 0d2361ebe3d7..d420f84ddfb0 100644
--- a/Documentation/devicetree/bindings/remoteproc/qcom,wcnss-pil.txt
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,wcnss-pil.txt
@@ -60,8 +60,8 @@ on the Qualcomm WCNSS core.
 		    see ../reserved-memory/reserved-memory.txt
 
 = SUBNODES
-A single subnode of the WCNSS PIL describes the attached rf module and its
-resource dependencies.
+A required subnode of the WCNSS PIL is used to describe the attached rf module
+and its resource dependencies. It is described by the following properties:
 
 - compatible:
 	Usage: required
@@ -90,6 +90,11 @@ resource dependencies.
 	Definition: reference to the regulators to be held on behalf of the
 		    booting of the WCNSS core
 
+
+The wcnss node can also have an subnode named "smd-edge" that describes the SMD
+edge, channels and devices related to the WCNSS.
+See ../soc/qcom/qcom,smd.txt for details on how to describe the SMD edge.
+
 = EXAMPLE
 The following example describes the resources needed to boot control the WCNSS,
 with attached WCN3680, as it is commonly found on MSM8974 boards.
@@ -129,4 +134,25 @@ pronto@fb204000 {
 		vddpa-supply = <&pm8941_l19>;
 		vdddig-supply = <&pm8941_s3>;
 	};
+
+	smd-edge {
+		interrupts = <0 142 1>;
+
+		qcom,ipc = <&apcs 8 17>;
+		qcom,smd-edge = <6>;
+		qcom,remote-pid = <4>;
+
+		label = "pronto";
+
+		wcnss {
+			compatible = "qcom,wcnss";
+			qcom,smd-channels = "WCNSS_CTRL";
+
+			qcom,mmio = <&pronto>;
+
+			bt {
+				compatible = "qcom,wcnss-bt";
+			};
+		};
+	};
 };
-- 
2.5.0

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

* [PATCH 05/11] remoteproc: Assign kref to rproc_vdev
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (3 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 04/11] dt-binding: remoteproc: wcnss: Allow describing smd edge Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 06/11] remoteproc: virtio: Anchor vring life cycle in vdev Bjorn Andersson
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel

No functional change

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c     | 10 ++++++++++
 drivers/remoteproc/remoteproc_internal.h |  1 +
 drivers/remoteproc/remoteproc_virtio.c   | 10 ++++++----
 include/linux/remoteproc.h               |  3 +++
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 4309996f4335..c978907498d0 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -356,6 +356,8 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 	if (!rvdev)
 		return -ENOMEM;
 
+	kref_init(&rvdev->refcount);
+
 	rvdev->rproc = rproc;
 
 	/* parse the vrings */
@@ -384,6 +386,14 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 	return ret;
 }
 
+void rproc_vdev_release(struct kref *ref)
+{
+	struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
+
+	list_del(&rvdev->node);
+	kfree(rvdev);
+}
+
 /**
  * rproc_handle_trace() - handle a shared trace buffer resource
  * @rproc: the remote processor
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index 4cf93ca2816e..fe5a570b6c2b 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -49,6 +49,7 @@ struct rproc_fw_ops {
 void rproc_release(struct kref *kref);
 irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
 int rproc_boot_nowait(struct rproc *rproc);
+void rproc_vdev_release(struct kref *ref);
 
 /* from remoteproc_virtio.c */
 int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 01870a16d6d2..0d1ad3ed149d 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -282,14 +282,13 @@ static const struct virtio_config_ops rproc_virtio_config_ops = {
  * Never call this function directly; it will be called by the driver
  * core when needed.
  */
-static void rproc_vdev_release(struct device *dev)
+static void rproc_virtio_dev_release(struct device *dev)
 {
 	struct virtio_device *vdev = dev_to_virtio(dev);
 	struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
 	struct rproc *rproc = vdev_to_rproc(vdev);
 
-	list_del(&rvdev->node);
-	kfree(rvdev);
+	kref_put(&rvdev->refcount, rproc_vdev_release);
 
 	put_device(&rproc->dev);
 }
@@ -313,7 +312,7 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
 	vdev->id.device	= id,
 	vdev->config = &rproc_virtio_config_ops,
 	vdev->dev.parent = dev;
-	vdev->dev.release = rproc_vdev_release;
+	vdev->dev.release = rproc_virtio_dev_release;
 
 	/*
 	 * We're indirectly making a non-temporary copy of the rproc pointer
@@ -325,6 +324,9 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
 	 */
 	get_device(&rproc->dev);
 
+	/* Reference the vdev and vring allocations */
+	kref_get(&rvdev->refcount);
+
 	ret = register_virtio_device(vdev);
 	if (ret) {
 		put_device(&rproc->dev);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index a05f4569a2a0..dbcd967dd2e7 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -487,6 +487,7 @@ struct rproc_vring {
 
 /**
  * struct rproc_vdev - remoteproc state for a supported virtio device
+ * @refcount: reference counter for the vdev and vring allocations
  * @node: list node
  * @rproc: the rproc handle
  * @vdev: the virio device
@@ -494,6 +495,8 @@ struct rproc_vring {
  * @rsc_offset: offset of the vdev's resource entry
  */
 struct rproc_vdev {
+	struct kref refcount;
+
 	struct list_head node;
 	struct rproc *rproc;
 	struct virtio_device vdev;
-- 
2.5.0

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

* [PATCH 06/11] remoteproc: virtio: Anchor vring life cycle in vdev
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (4 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 05/11] remoteproc: Assign kref to rproc_vdev Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 07/11] remoteproc: Further extend the vdev life cycle Bjorn Andersson
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel

Instead of having the vrings being allocated and freed as they are
requested by the virtio device tie their life cycle to the vdev
resource. This allows us to decouple the vdev resource management from
the virtio device management.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c   | 20 ++++++++++++++++++++
 drivers/remoteproc/remoteproc_virtio.c |  7 +------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c978907498d0..e4509c8dd8e8 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -370,6 +370,13 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 	/* remember the resource offset*/
 	rvdev->rsc_offset = offset;
 
+	/* allocate the vring resources */
+	for (i = 0; i < rsc->num_of_vrings; i++) {
+		ret = rproc_alloc_vring(rvdev, i);
+		if (ret)
+			goto unwind_vring_allocations;
+	}
+
 	list_add_tail(&rvdev->node, &rproc->rvdevs);
 
 	/* it is now safe to add the virtio device */
@@ -379,6 +386,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 
 	return 0;
 
+unwind_vring_allocations:
+	for (i--; i >= 0; i--)
+		rproc_free_vring(&rvdev->vring[i]);
 remove_rvdev:
 	list_del(&rvdev->node);
 free_rvdev:
@@ -389,6 +399,16 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 void rproc_vdev_release(struct kref *ref)
 {
 	struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
+	struct rproc_vring *rvring;
+	int id;
+
+	for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) {
+		rvring = &rvdev->vring[id];
+		if (!rvring->va)
+			continue;
+
+		rproc_free_vring(rvring);
+	}
 
 	list_del(&rvdev->node);
 	kfree(rvdev);
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 0d1ad3ed149d..364411fb7734 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -79,7 +79,7 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev,
 	struct rproc_vring *rvring;
 	struct virtqueue *vq;
 	void *addr;
-	int len, size, ret;
+	int len, size;
 
 	/* we're temporarily limited to two virtqueues per rvdev */
 	if (id >= ARRAY_SIZE(rvdev->vring))
@@ -88,10 +88,6 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev,
 	if (!name)
 		return NULL;
 
-	ret = rproc_alloc_vring(rvdev, id);
-	if (ret)
-		return ERR_PTR(ret);
-
 	rvring = &rvdev->vring[id];
 	addr = rvring->va;
 	len = rvring->len;
@@ -130,7 +126,6 @@ static void __rproc_virtio_del_vqs(struct virtio_device *vdev)
 		rvring = vq->priv;
 		rvring->vq = NULL;
 		vring_del_virtqueue(vq);
-		rproc_free_vring(rvring);
 	}
 }
 
-- 
2.5.0

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

* [PATCH 07/11] remoteproc: Further extend the vdev life cycle
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (5 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 06/11] remoteproc: virtio: Anchor vring life cycle in vdev Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 08/11] remoteproc: Decouple vdev resources and devices Bjorn Andersson
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel

Tie the vdev (and hence vring) life cycle to the resource parsing and
resource cleanup operations, allowing us to safely register and
unregister virtio devices on the go.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index e4509c8dd8e8..1d2f4b2dd05d 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -377,6 +377,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 			goto unwind_vring_allocations;
 	}
 
+	/* track the rvdevs list reference */
+	kref_get(&rvdev->refcount);
+
 	list_add_tail(&rvdev->node, &rproc->rvdevs);
 
 	/* it is now safe to add the virtio device */
@@ -839,8 +842,10 @@ static void rproc_resource_cleanup(struct rproc *rproc)
 	}
 
 	/* clean up remote vdev entries */
-	list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node)
+	list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) {
 		rproc_remove_virtio_dev(rvdev);
+		kref_put(&rvdev->refcount, rproc_vdev_release);
+	}
 }
 
 /*
-- 
2.5.0

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

* [PATCH 08/11] remoteproc: Decouple vdev resources and devices
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (6 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 07/11] remoteproc: Further extend the vdev life cycle Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 09/11] remoteproc: Update max_notifyid as we allocate vrings Bjorn Andersson
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel

Represent the virtio device part of the vdev resources as remoteproc
subdevices to finalize the decoupling of the virtio resource and device
handling.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 35 ++++++++++++++++++++---------------
 include/linux/remoteproc.h           |  5 +++++
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 1d2f4b2dd05d..c242ca016496 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -296,6 +296,20 @@ void rproc_free_vring(struct rproc_vring *rvring)
 	rsc->vring[idx].notifyid = -1;
 }
 
+static int rproc_vdev_do_probe(struct rproc_subdev *subdev)
+{
+	struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
+
+	return rproc_add_virtio_dev(rvdev, rvdev->id);
+}
+
+static void rproc_vdev_do_remove(struct rproc_subdev *subdev)
+{
+	struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
+
+	rproc_remove_virtio_dev(rvdev);
+}
+
 /**
  * rproc_handle_vdev() - handle a vdev fw resource
  * @rproc: the remote processor
@@ -358,6 +372,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 
 	kref_init(&rvdev->refcount);
 
+	rvdev->id = rsc->id;
 	rvdev->rproc = rproc;
 
 	/* parse the vrings */
@@ -382,18 +397,14 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
 
 	list_add_tail(&rvdev->node, &rproc->rvdevs);
 
-	/* it is now safe to add the virtio device */
-	ret = rproc_add_virtio_dev(rvdev, rsc->id);
-	if (ret)
-		goto remove_rvdev;
+	rproc_add_subdev(rproc, &rvdev->subdev,
+			 rproc_vdev_do_probe, rproc_vdev_do_remove);
 
 	return 0;
 
 unwind_vring_allocations:
 	for (i--; i >= 0; i--)
 		rproc_free_vring(&rvdev->vring[i]);
-remove_rvdev:
-	list_del(&rvdev->node);
 free_rvdev:
 	kfree(rvdev);
 	return ret;
@@ -403,6 +414,7 @@ void rproc_vdev_release(struct kref *ref)
 {
 	struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
 	struct rproc_vring *rvring;
+	struct rproc *rproc = rvdev->rproc;
 	int id;
 
 	for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) {
@@ -413,6 +425,7 @@ void rproc_vdev_release(struct kref *ref)
 		rproc_free_vring(rvring);
 	}
 
+	rproc_remove_subdev(rproc, &rvdev->subdev);
 	list_del(&rvdev->node);
 	kfree(rvdev);
 }
@@ -842,10 +855,8 @@ static void rproc_resource_cleanup(struct rproc *rproc)
 	}
 
 	/* clean up remote vdev entries */
-	list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) {
-		rproc_remove_virtio_dev(rvdev);
+	list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node)
 		kref_put(&rvdev->refcount, rproc_vdev_release);
-	}
 }
 
 /*
@@ -1505,8 +1516,6 @@ EXPORT_SYMBOL(rproc_put);
  */
 int rproc_del(struct rproc *rproc)
 {
-	struct rproc_vdev *rvdev, *tmp;
-
 	if (!rproc)
 		return -EINVAL;
 
@@ -1518,10 +1527,6 @@ int rproc_del(struct rproc *rproc)
 	if (rproc->auto_boot)
 		rproc_shutdown(rproc);
 
-	/* clean up remote vdev entries */
-	list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node)
-		rproc_remove_virtio_dev(rvdev);
-
 	/* the rproc is downref'ed as soon as it's removed from the klist */
 	mutex_lock(&rproc_list_mutex);
 	list_del(&rproc->node);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index dbcd967dd2e7..ff05b88730ad 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -488,6 +488,8 @@ struct rproc_vring {
 /**
  * struct rproc_vdev - remoteproc state for a supported virtio device
  * @refcount: reference counter for the vdev and vring allocations
+ * @subdev: handle for registering the vdev as a rproc subdevice
+ * @id: virtio device id (as in virtio_ids.h)
  * @node: list node
  * @rproc: the rproc handle
  * @vdev: the virio device
@@ -497,6 +499,9 @@ struct rproc_vring {
 struct rproc_vdev {
 	struct kref refcount;
 
+	struct rproc_subdev subdev;
+
+	unsigned int id;
 	struct list_head node;
 	struct rproc *rproc;
 	struct virtio_device vdev;
-- 
2.5.0

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

* [PATCH 09/11] remoteproc: Update max_notifyid as we allocate vrings
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (7 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 08/11] remoteproc: Decouple vdev resources and devices Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 10/11] remoteproc: Remove custom vdev handler list Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 11/11] remoteproc: Merge table_ptr and cached_table pointers Bjorn Andersson
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel

Vrings are now allocated as we parse the resource table, before we
boot the rproc or register any virtio devices, so it's safe to bump
max_notifyid as part of this process.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c242ca016496..57f12421fdd2 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -236,6 +236,10 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
 	}
 	notifyid = ret;
 
+	/* Potentially bump max_notifyid */
+	if (notifyid > rproc->max_notifyid)
+		rproc->max_notifyid = notifyid;
+
 	dev_dbg(dev, "vring%d: va %p dma %pad size 0x%x idr %d\n",
 		i, va, &dma, size, notifyid);
 
@@ -719,15 +723,6 @@ static int rproc_handle_carveout(struct rproc *rproc,
 	return ret;
 }
 
-static int rproc_count_vrings(struct rproc *rproc, struct fw_rsc_vdev *rsc,
-			      int offset, int avail)
-{
-	/* Summarize the number of notification IDs */
-	rproc->max_notifyid += rsc->num_of_vrings;
-
-	return 0;
-}
-
 /*
  * A lookup table for resource handlers. The indices are defined in
  * enum fw_resource_type.
@@ -736,7 +731,7 @@ static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = {
 	[RSC_CARVEOUT] = (rproc_handle_resource_t)rproc_handle_carveout,
 	[RSC_DEVMEM] = (rproc_handle_resource_t)rproc_handle_devmem,
 	[RSC_TRACE] = (rproc_handle_resource_t)rproc_handle_trace,
-	[RSC_VDEV] = (rproc_handle_resource_t)rproc_count_vrings,
+	[RSC_VDEV] = NULL,
 };
 
 static rproc_handle_resource_t rproc_vdev_handler[RSC_LAST] = {
-- 
2.5.0

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

* [PATCH 10/11] remoteproc: Remove custom vdev handler list
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (8 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 09/11] remoteproc: Update max_notifyid as we allocate vrings Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  2016-10-20  2:40 ` [PATCH 11/11] remoteproc: Merge table_ptr and cached_table pointers Bjorn Andersson
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel

The vdev handler is now just another resource allocator, so handle all
resource types in a single pass.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 57f12421fdd2..f31783d27196 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -731,10 +731,6 @@ static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = {
 	[RSC_CARVEOUT] = (rproc_handle_resource_t)rproc_handle_carveout,
 	[RSC_DEVMEM] = (rproc_handle_resource_t)rproc_handle_devmem,
 	[RSC_TRACE] = (rproc_handle_resource_t)rproc_handle_trace,
-	[RSC_VDEV] = NULL,
-};
-
-static rproc_handle_resource_t rproc_vdev_handler[RSC_LAST] = {
 	[RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev,
 };
 
@@ -905,13 +901,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
 	/* reset max_notifyid */
 	rproc->max_notifyid = -1;
 
-	/* look for virtio devices and register them */
-	ret = rproc_handle_resources(rproc, tablesz, rproc_vdev_handler);
-	if (ret) {
-		dev_err(dev, "Failed to handle vdev resources: %d\n", ret);
-		goto clean_up;
-	}
-
 	/* handle fw resources which are required to boot rproc */
 	ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers);
 	if (ret) {
-- 
2.5.0

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

* [PATCH 11/11] remoteproc: Merge table_ptr and cached_table pointers
  2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
                   ` (9 preceding siblings ...)
  2016-10-20  2:40 ` [PATCH 10/11] remoteproc: Remove custom vdev handler list Bjorn Andersson
@ 2016-10-20  2:40 ` Bjorn Andersson
  10 siblings, 0 replies; 14+ messages in thread
From: Bjorn Andersson @ 2016-10-20  2:40 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-remoteproc, linux-kernel, linux-arm-msm

As all vdev resources are allocated before we boot the remote processor
we no longer need to support modifying the resource table while the
remote is running.

This saves us from the table_ptr dance, but more importantly allow the
remote processor to enable security lock down of the loaded table memory
region.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 26 ++++++++++----------------
 include/linux/remoteproc.h           |  4 +---
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f31783d27196..46078c959a9c 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -889,15 +889,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
 	/*
 	 * Create a copy of the resource table. When a virtio device starts
 	 * and calls vring_new_virtqueue() the address of the allocated vring
-	 * will be stored in the cached_table. Before the device is started,
-	 * cached_table will be copied into device memory.
+	 * will be stored in the table_ptr. Before the device is started,
+	 * table_ptr will be copied into device memory.
 	 */
-	rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
-	if (!rproc->cached_table)
+	rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL);
+	if (!rproc->table_ptr)
 		goto clean_up;
 
-	rproc->table_ptr = rproc->cached_table;
-
 	/* reset max_notifyid */
 	rproc->max_notifyid = -1;
 
@@ -916,18 +914,16 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
 	}
 
 	/*
-	 * The starting device has been given the rproc->cached_table as the
+	 * The starting device has been given the rproc->table_ptr as the
 	 * resource table. The address of the vring along with the other
-	 * allocated resources (carveouts etc) is stored in cached_table.
+	 * allocated resources (carveouts etc) is stored in table_ptr.
 	 * In order to pass this information to the remote device we must copy
 	 * this information to device memory. We also update the table_ptr so
 	 * that any subsequent changes will be applied to the loaded version.
 	 */
 	loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
-	if (loaded_table) {
-		memcpy(loaded_table, rproc->cached_table, tablesz);
-		rproc->table_ptr = loaded_table;
-	}
+	if (loaded_table)
+		memcpy(loaded_table, rproc->table_ptr, tablesz);
 
 	/* power up the remote processor */
 	ret = rproc->ops->start(rproc);
@@ -955,8 +951,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
 clean_up_resources:
 	rproc_resource_cleanup(rproc);
 clean_up:
-	kfree(rproc->cached_table);
-	rproc->cached_table = NULL;
+	kfree(rproc->table_ptr);
 	rproc->table_ptr = NULL;
 
 	rproc_disable_iommu(rproc);
@@ -1206,8 +1201,7 @@ void rproc_shutdown(struct rproc *rproc)
 	rproc_disable_iommu(rproc);
 
 	/* Free the copy of the resource table */
-	kfree(rproc->cached_table);
-	rproc->cached_table = NULL;
+	kfree(rproc->table_ptr);
 	rproc->table_ptr = NULL;
 
 	/* if in crash state, unlock crash handler */
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index ff05b88730ad..51662ee7d032 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -408,8 +408,7 @@ enum rproc_crash_type {
  * @crash_comp: completion used to sync crash handler and the rproc reload
  * @recovery_disabled: flag that state if recovery was disabled
  * @max_notifyid: largest allocated notify id.
- * @table_ptr: pointer to the resource table in effect
- * @cached_table: copy of the resource table
+ * @table_ptr: our copy of the resource table
  * @has_iommu: flag to indicate if remote processor is behind an MMU
  */
 struct rproc {
@@ -441,7 +440,6 @@ struct rproc {
 	bool recovery_disabled;
 	int max_notifyid;
 	struct resource_table *table_ptr;
-	struct resource_table *cached_table;
 	bool has_iommu;
 	bool auto_boot;
 };
-- 
2.5.0

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

* Re: [PATCH 04/11] dt-binding: remoteproc: wcnss: Allow describing smd edge
@ 2016-11-10  0:45     ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2016-11-10  0:45 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Ohad Ben-Cohen, Mark Rutland, linux-remoteproc, linux-kernel,
	devicetree, Sarangdhar Joshi, linux-arm-msm

On Wed, Oct 19, 2016 at 07:40:05PM -0700, Bjorn Andersson wrote:
> Allow the associated smd edge to be described within the wcnss
> remoteproc node. This creates a bond between the remoteproc and the
> associated smd channels and devices, showing the interaction between the
> two parts and provides both a natural reference to the other.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  .../bindings/remoteproc/qcom,wcnss-pil.txt         | 30 ++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)

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

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

* Re: [PATCH 04/11] dt-binding: remoteproc: wcnss: Allow describing smd edge
@ 2016-11-10  0:45     ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2016-11-10  0:45 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Ohad Ben-Cohen, Mark Rutland,
	linux-remoteproc-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Sarangdhar Joshi,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA

On Wed, Oct 19, 2016 at 07:40:05PM -0700, Bjorn Andersson wrote:
> Allow the associated smd edge to be described within the wcnss
> remoteproc node. This creates a bond between the remoteproc and the
> associated smd channels and devices, showing the interaction between the
> two parts and provides both a natural reference to the other.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  .../bindings/remoteproc/qcom,wcnss-pil.txt         | 30 ++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)

Acked-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] 14+ messages in thread

end of thread, other threads:[~2016-11-10  0:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-20  2:40 [PATCH 00/11] rproc subdevice support Bjorn Andersson
2016-10-20  2:40 ` [PATCH 01/11] remoteproc: Introduce subdevices Bjorn Andersson
2016-10-20  2:40 ` [PATCH 02/11] rpmsg: smd: Expose edge registration functions Bjorn Andersson
2016-10-20  2:40 ` [PATCH 03/11] remoteproc: wcnss: Bond SMD edge to remoteproc Bjorn Andersson
2016-10-20  2:40 ` [PATCH 04/11] dt-binding: remoteproc: wcnss: Allow describing smd edge Bjorn Andersson
2016-11-10  0:45   ` Rob Herring
2016-11-10  0:45     ` Rob Herring
2016-10-20  2:40 ` [PATCH 05/11] remoteproc: Assign kref to rproc_vdev Bjorn Andersson
2016-10-20  2:40 ` [PATCH 06/11] remoteproc: virtio: Anchor vring life cycle in vdev Bjorn Andersson
2016-10-20  2:40 ` [PATCH 07/11] remoteproc: Further extend the vdev life cycle Bjorn Andersson
2016-10-20  2:40 ` [PATCH 08/11] remoteproc: Decouple vdev resources and devices Bjorn Andersson
2016-10-20  2:40 ` [PATCH 09/11] remoteproc: Update max_notifyid as we allocate vrings Bjorn Andersson
2016-10-20  2:40 ` [PATCH 10/11] remoteproc: Remove custom vdev handler list Bjorn Andersson
2016-10-20  2:40 ` [PATCH 11/11] remoteproc: Merge table_ptr and cached_table pointers 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.