Merge tag 'rpmsg-v4.15' of git://github.com/andersson/remoteproc
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Nov 2017 04:12:08 +0000 (20:12 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Nov 2017 04:12:08 +0000 (20:12 -0800)
Pull rpmsg updates from Bjorn Andersson:

 - turn RPMSG_VIRTIO into a user selectable config

 - fix few bugs in GLINK

 - provide the support for specifying initial buffer sizes for GLINK
   channels.

* tag 'rpmsg-v4.15' of git://github.com/andersson/remoteproc:
  rpmsg: glink: The mbox client knows_txdone
  rpmsg: glink: Add missing MODULE_LICENSE
  rpmsg: glink: Use best fit intent during tx
  rpmsg: glink: Add support to preallocate intents
  dt-bindings: soc: qcom: Support GLINK intents
  rpmsg: glink: Initialize the "intent_req_comp" completion variable
  rpmsg: Allow RPMSG_VIRTIO to be enabled via menuconfig or defconfig

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt
drivers/remoteproc/Kconfig
drivers/rpmsg/Kconfig
drivers/rpmsg/qcom_glink_native.c

index b277eca861f72a45c7fa0bbd2d6d35656d730d39..9663cab5224626cd74a6ca0a724c1be09e0bd38c 100644 (file)
@@ -39,6 +39,14 @@ of these nodes are defined by the individual bindings for the specific function
        Definition: a list of channels tied to this function, used for matching
                    the function to a set of virtual channels
 
+- qcom,intents:
+       Usage: optional
+       Value type: <prop-encoded-array>
+       Definition: a list of size,amount pairs describing what intents should
+                   be preallocated for this virtual channel. This can be used
+                   to tweak the default intents available for the channel to
+                   meet expectations of the remote.
+
 = EXAMPLE
 The following example represents the GLINK RPM node on a MSM8996 device, with
 the function for the "rpm_request" channel defined, which is used for
@@ -69,6 +77,8 @@ regualtors and root clocks.
                        compatible = "qcom,rpm-msm8996";
                        qcom,glink-channels = "rpm_requests";
 
+                       qcom,intents = <0x400 5
+                                       0x800 1>;
                        ...
                };
        };
index bf04479456a050abb56290a71729a76f49a638b6..b609e1d3654ba65f13d480ce71834fb5b507773b 100644 (file)
@@ -28,7 +28,6 @@ config OMAP_REMOTEPROC
        depends on OMAP_IOMMU
        select MAILBOX
        select OMAP2PLUS_MBOX
-       select RPMSG_VIRTIO
        help
          Say y here to support OMAP's remote processors (dual M3
          and DSP on OMAP4) via the remote processor framework.
@@ -58,7 +57,6 @@ config DA8XX_REMOTEPROC
        tristate "DA8xx/OMAP-L13x remoteproc support"
        depends on ARCH_DAVINCI_DA8XX
        depends on DMA_CMA
-       select RPMSG_VIRTIO
        help
          Say y here to support DA8xx/OMAP-L13x remote processors via the
          remote processor framework.
@@ -79,7 +77,6 @@ config DA8XX_REMOTEPROC
 config KEYSTONE_REMOTEPROC
        tristate "Keystone Remoteproc support"
        depends on ARCH_KEYSTONE
-       select RPMSG_VIRTIO
        help
          Say Y here here to support Keystone remote processors (DSP)
          via the remote processor framework.
@@ -135,7 +132,6 @@ config ST_REMOTEPROC
        depends on ARCH_STI
        select MAILBOX
        select STI_MBOX
-       select RPMSG_VIRTIO
        help
          Say y here to support ST's adjunct processors via the remote
          processor framework.
index 0fe6eac465121d6bbf7c8c1ce9a8d06d21c0a7a6..65a9f6b892f06a9ffc06e93181a84cadefab09d2 100644 (file)
@@ -47,7 +47,8 @@ config RPMSG_QCOM_SMD
          platforms.
 
 config RPMSG_VIRTIO
-       tristate
+       tristate "Virtio RPMSG bus driver"
+       depends on HAS_DMA
        select RPMSG
        select VIRTIO
 
index 5dcc9bf1c5bc5de65af2bfc5d778c4d494b20cee..40d76d2a5efff58339c0b823be3678591c99482e 100644 (file)
@@ -227,6 +227,7 @@ static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink,
 
        init_completion(&channel->open_req);
        init_completion(&channel->open_ack);
+       init_completion(&channel->intent_req_comp);
 
        INIT_LIST_HEAD(&channel->done_intents);
        INIT_WORK(&channel->intent_work, qcom_glink_rx_done_work);
@@ -1148,19 +1149,38 @@ static struct rpmsg_endpoint *qcom_glink_create_ept(struct rpmsg_device *rpdev,
 static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
 {
        struct glink_channel *channel = to_glink_channel(rpdev->ept);
-       struct glink_core_rx_intent *intent;
+       struct device_node *np = rpdev->dev.of_node;
        struct qcom_glink *glink = channel->glink;
-       int num_intents = glink->intentless ? 0 : 5;
+       struct glink_core_rx_intent *intent;
+       const struct property *prop = NULL;
+       __be32 defaults[] = { cpu_to_be32(SZ_1K), cpu_to_be32(5) };
+       int num_intents;
+       int num_groups = 1;
+       __be32 *val = defaults;
+       int size;
+
+       if (glink->intentless)
+               return 0;
+
+       prop = of_find_property(np, "qcom,intents", NULL);
+       if (prop) {
+               val = prop->value;
+               num_groups = prop->length / sizeof(u32) / 2;
+       }
 
        /* Channel is now open, advertise base set of intents */
-       while (num_intents--) {
-               intent = qcom_glink_alloc_intent(glink, channel, SZ_1K, true);
-               if (!intent)
-                       break;
+       while (num_groups--) {
+               size = be32_to_cpup(val++);
+               num_intents = be32_to_cpup(val++);
+               while (num_intents--) {
+                       intent = qcom_glink_alloc_intent(glink, channel, size,
+                                                        true);
+                       if (!intent)
+                               break;
 
-               qcom_glink_advertise_intent(glink, channel, intent);
+                       qcom_glink_advertise_intent(glink, channel, intent);
+               }
        }
-
        return 0;
 }
 
@@ -1237,11 +1257,16 @@ static int __qcom_glink_send(struct glink_channel *channel,
                        spin_lock_irqsave(&channel->intent_lock, flags);
                        idr_for_each_entry(&channel->riids, tmp, iid) {
                                if (tmp->size >= len && !tmp->in_use) {
-                                       tmp->in_use = true;
-                                       intent = tmp;
-                                       break;
+                                       if (!intent)
+                                               intent = tmp;
+                                       else if (intent->size > tmp->size)
+                                               intent = tmp;
+                                       if (intent->size == len)
+                                               break;
                                }
                        }
+                       if (intent)
+                               intent->in_use = true;
                        spin_unlock_irqrestore(&channel->intent_lock, flags);
 
                        /* We found an available intent */
@@ -1551,6 +1576,7 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
        idr_init(&glink->rcids);
 
        glink->mbox_client.dev = dev;
+       glink->mbox_client.knows_txdone = true;
        glink->mbox_chan = mbox_request_channel(&glink->mbox_client, 0);
        if (IS_ERR(glink->mbox_chan)) {
                if (PTR_ERR(glink->mbox_chan) != -EPROBE_DEFER)
@@ -1616,3 +1642,6 @@ void qcom_glink_native_unregister(struct qcom_glink *glink)
        device_unregister(glink->dev);
 }
 EXPORT_SYMBOL_GPL(qcom_glink_native_unregister);
+
+MODULE_DESCRIPTION("Qualcomm GLINK driver");
+MODULE_LICENSE("GPL v2");