From patchwork Tue Aug 16 00:17:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73949 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1712376qga; Mon, 15 Aug 2016 17:19:47 -0700 (PDT) X-Received: by 10.98.152.6 with SMTP id q6mr7905090pfd.86.1471306786968; Mon, 15 Aug 2016 17:19:46 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gp10si29010697pac.79.2016.08.15.17.19.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Aug 2016 17:19:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZS5a-0003s5-JN; Tue, 16 Aug 2016 00:18:42 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZS4i-0003QS-00 for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2016 00:17:53 +0000 Received: by mail-pa0-x234.google.com with SMTP id pp5so20344975pac.3 for ; Mon, 15 Aug 2016 17:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cuo9VdQDQWnc8/k9g3SymhYBhtYhCPj2VmKXc/eJj2s=; b=LfQrCOlz/oGbRrH1SoYZZQE7uczbEV608USrWSjQvJ52t6QEGPKSS5HDu9YmCE0q6z uKjf67OvTNzsN5NnsPxKAZTFJ9Ea8WV13tqMLDHf6VrMHygc2YQCC62VQ6PharGGE17L 98z4gaZvSkky2seSIzSUJWMw4gGIU7m4fnSFY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cuo9VdQDQWnc8/k9g3SymhYBhtYhCPj2VmKXc/eJj2s=; b=KaMxSs4VMfC3Mk810RhVrkl2oC1ZmjsXkPRjI6H9oq8OJbvMKt3KQIS9vj/DgBjZmT TTmbXU47kwiW6cBVzcCxt9eP00SPUwBP+RawFaaYqpAldy+dq6rjzuDDcNfe973ElgKo GhaZsN1ZbXnauUKKf/v5lLAW5lluMycdCQeQD/mVWS30+9PacbglNav/5rIN1eLGVpxF Pld/KHcwioqMH/jmAVY8mmCqhIuIfI7rV/SEASWuFIM1VwHsmvD83EP8Z0fYR7upCPS7 /ZVGorZSb5e3OeaKJCLGJt3hGio4MbWalJn1Ru0Nzr6xCwRko3YFRFvspdMC0SrStXwh +04A== X-Gm-Message-State: AEkoouuzzr8ygzNMkjdcPaJ1bnwebxdvs/G/sTc3tLbZVBaY0/gvU4OwCJq+iLMlIY4j7jZP X-Received: by 10.66.146.69 with SMTP id ta5mr7755975pab.157.1471306646852; Mon, 15 Aug 2016 17:17:26 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id p187sm34047931pfb.5.2016.08.15.17.17.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 17:17:26 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH 03/14] rpmsg: rpmsg_send() operations takes rpmsg_endpoint Date: Mon, 15 Aug 2016 17:17:09 -0700 Message-Id: <1471306640-29917-4-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1471306640-29917-1-git-send-email-bjorn.andersson@linaro.org> References: <1471306640-29917-1-git-send-email-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160815_171748_254061_EDB2C428 X-CRM114-Status: GOOD ( 13.99 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:234 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The rpmsg_send() operations has been taking a rpmsg_device, but this forces users of secondary rpmsg_endpoints to use the rpmsg_sendto() interface - by extracting source and destination from the given data structures. If we instead pass the rpmsg_endpoint to these functions a service can use rpmsg_sendto() to respond to messages, even on secondary endpoints. In addition this would allow us to support operations on multiple channels in future backends that does not support off-channel operations. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/virtio_rpmsg_bus.c | 4 +-- include/linux/rpmsg.h | 70 +++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 32 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index c4bd89ea7681..1b63f4b7c2bd 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -382,7 +382,7 @@ static int rpmsg_dev_probe(struct device *dev) nsm.addr = rpdev->src; nsm.flags = RPMSG_NS_CREATE; - err = rpmsg_sendto(rpdev, &nsm, sizeof(nsm), RPMSG_NS_ADDR); + err = rpmsg_sendto(rpdev->ept, &nsm, sizeof(nsm), RPMSG_NS_ADDR); if (err) dev_err(dev, "failed to announce service %d\n", err); } @@ -407,7 +407,7 @@ static int rpmsg_dev_remove(struct device *dev) nsm.addr = rpdev->src; nsm.flags = RPMSG_NS_DESTROY; - err = rpmsg_sendto(rpdev, &nsm, sizeof(nsm), RPMSG_NS_ADDR); + err = rpmsg_sendto(rpdev->ept, &nsm, sizeof(nsm), RPMSG_NS_ADDR); if (err) dev_err(dev, "failed to announce service %d\n", err); } diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 2b97c711a5e3..88e302c011e6 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -193,13 +193,14 @@ rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); /** * rpmsg_send() - send a message across to the remote processor - * @rpdev: the rpmsg channel + * @ept: the rpmsg endpoint * @data: payload of message * @len: length of payload * - * This function sends @data of length @len on the @rpdev channel. - * The message will be sent to the remote processor which the @rpdev - * channel belongs to, using @rpdev's source and destination addresses. + * This function sends @data of length @len on the @ept endpoint. + * The message will be sent to the remote processor which the @ept + * endpoint belongs to, using @ept's address and its associated rpmsg + * device destination addresses. * In case there are no TX buffers available, the function will block until * one becomes available, or a timeout of 15 seconds elapses. When the latter * happens, -ERESTARTSYS is returned. @@ -208,23 +209,24 @@ rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); * * Returns 0 on success and an appropriate error value on failure. */ -static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len) +static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) { - u32 src = rpdev->src, dst = rpdev->dst; + struct rpmsg_channel *rpdev = ept->rpdev; + u32 src = ept->addr, dst = rpdev->dst; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); } /** * rpmsg_sendto() - send a message across to the remote processor, specify dst - * @rpdev: the rpmsg channel + * @ept: the rpmsg endpoint * @data: payload of message * @len: length of payload * @dst: destination address * * This function sends @data of length @len to the remote @dst address. - * The message will be sent to the remote processor which the @rpdev - * channel belongs to, using @rpdev's source address. + * The message will be sent to the remote processor which the @ept + * endpoint belongs to, using @ept's address as source. * In case there are no TX buffers available, the function will block until * one becomes available, or a timeout of 15 seconds elapses. When the latter * happens, -ERESTARTSYS is returned. @@ -234,16 +236,17 @@ static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len) * Returns 0 on success and an appropriate error value on failure. */ static inline -int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) +int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) { - u32 src = rpdev->src; + struct rpmsg_channel *rpdev = ept->rpdev; + u32 src = ept->addr; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); } /** * rpmsg_send_offchannel() - send a message using explicit src/dst addresses - * @rpdev: the rpmsg channel + * @ept: the rpmsg endpoint * @src: source address * @dst: destination address * @data: payload of message @@ -251,8 +254,8 @@ int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) * * This function sends @data of length @len to the remote @dst address, * and uses @src as the source address. - * The message will be sent to the remote processor which the @rpdev - * channel belongs to. + * The message will be sent to the remote processor which the @ept + * endpoint belongs to. * In case there are no TX buffers available, the function will block until * one becomes available, or a timeout of 15 seconds elapses. When the latter * happens, -ERESTARTSYS is returned. @@ -262,21 +265,24 @@ int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) * Returns 0 on success and an appropriate error value on failure. */ static inline -int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, +int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len) { + struct rpmsg_channel *rpdev = ept->rpdev; + return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); } /** * rpmsg_send() - send a message across to the remote processor - * @rpdev: the rpmsg channel + * @ept: the rpmsg endpoint * @data: payload of message * @len: length of payload * - * This function sends @data of length @len on the @rpdev channel. - * The message will be sent to the remote processor which the @rpdev - * channel belongs to, using @rpdev's source and destination addresses. + * This function sends @data of length @len on the @ept endpoint. + * The message will be sent to the remote processor which the @ept + * endpoint belongs to, using @ept's addres as source and its associated + * rpdev's address as destination. * In case there are no TX buffers available, the function will immediately * return -ENOMEM without waiting until one becomes available. * @@ -285,23 +291,24 @@ int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, * Returns 0 on success and an appropriate error value on failure. */ static inline -int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len) +int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) { - u32 src = rpdev->src, dst = rpdev->dst; + struct rpmsg_channel *rpdev = ept->rpdev; + u32 src = ept->addr, dst = rpdev->dst; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); } /** * rpmsg_sendto() - send a message across to the remote processor, specify dst - * @rpdev: the rpmsg channel + * @ept: the rpmsg endpoint * @data: payload of message * @len: length of payload * @dst: destination address * * This function sends @data of length @len to the remote @dst address. - * The message will be sent to the remote processor which the @rpdev - * channel belongs to, using @rpdev's source address. + * The message will be sent to the remote processor which the @ept + * endpoint belongs to, using @ept's address as source. * In case there are no TX buffers available, the function will immediately * return -ENOMEM without waiting until one becomes available. * @@ -310,16 +317,17 @@ int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len) * Returns 0 on success and an appropriate error value on failure. */ static inline -int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) +int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) { - u32 src = rpdev->src; + struct rpmsg_channel *rpdev = ept->rpdev; + u32 src = ept->addr; return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); } /** * rpmsg_send_offchannel() - send a message using explicit src/dst addresses - * @rpdev: the rpmsg channel + * @ept: the rpmsg endpoint * @src: source address * @dst: destination address * @data: payload of message @@ -327,8 +335,8 @@ int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) * * This function sends @data of length @len to the remote @dst address, * and uses @src as the source address. - * The message will be sent to the remote processor which the @rpdev - * channel belongs to. + * The message will be sent to the remote processor which the @ept + * endpoint belongs to. * In case there are no TX buffers available, the function will immediately * return -ENOMEM without waiting until one becomes available. * @@ -337,9 +345,11 @@ int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) * Returns 0 on success and an appropriate error value on failure. */ static inline -int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, +int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len) { + struct rpmsg_channel *rpdev = ept->rpdev; + return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); }