From patchwork Wed Jan 11 14:35:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9511597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2701F60231 for ; Wed, 11 Jan 2017 22:35:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 186E328697 for ; Wed, 11 Jan 2017 22:35:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8C4286BC; Wed, 11 Jan 2017 22:35:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BDE428697 for ; Wed, 11 Jan 2017 22:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757410AbdAKWei (ORCPT ); Wed, 11 Jan 2017 17:34:38 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:35413 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756371AbdAKWeh (ORCPT ); Wed, 11 Jan 2017 17:34:37 -0500 Received: by mail-pf0-f178.google.com with SMTP id f144so1040158pfa.2 for ; Wed, 11 Jan 2017 14:34:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=YJJhiUs+Si+pkCLLfvH8UGEC4/czn6cE1t5O2u+sfZ8=; b=PKYe7uYWGkhzZO7PGarGzgB5hoxvnCZPj5HQXq+Xiv7Se5ew2kArK+vDYyC7PhHgia tHH734mYI0o9OFR9xTZjr3yUTGdEuxbdvT7hFtZg75+mynO6M8ESTOh/BNK+9ROBG+EP irfkCvSIM1gNQH1QIm0YrjunQ6M/yvYa+grBw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YJJhiUs+Si+pkCLLfvH8UGEC4/czn6cE1t5O2u+sfZ8=; b=hZ9/xDOyv5FuAxpM/HlulGe9E7Ab93/c3KoPGn/GCeKoXf2cBsptG9BFmhqihL7EYe 3UpZJFYq5CeQieknUocwcdfsJngxBP4PiJw0lQaF4qy/qDkb44kqg+ZYOoc6qraQgq4b uySmliudPTkAxXEW1Ogbeg59BpWdHbICp5pJ52UG1ZaNA+tM8dPafHsVk/iAvJXnjIH0 GlCFP4rFjNxDI8tbqSvtK4TQhmI9freHu538SgsNKKyCpq1Uo0V+/+Bbw6BuCx5a3Ve3 XW0c1TIBtMjewlpWvxgG3vCdBaluNiE09iA8f/ttsY8czj+ELzW4X5D5+XzAd8Z086rl X/gg== X-Gm-Message-State: AIkVDXK0tpqY3Y5G9QVImceOUez2H/JmhlkkT+3n9IFhCE/WEhT4p9l0MtTu/qx38AqjR6O2 X-Received: by 10.84.233.133 with SMTP id l5mr16592010plk.129.1484174076778; Wed, 11 Jan 2017 14:34:36 -0800 (PST) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id o89sm16128591pfi.26.2017.01.11.14.34.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 14:34:35 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v3 1/4] rpmsg: Introduce "poll" to endpoint ops Date: Wed, 11 Jan 2017 06:35:10 -0800 Message-Id: <20170111143513.32251-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows rpmsg backends to implement polling of the outgoing buffer, which provides poll support to user space when using the rpmsg character device. Signed-off-by: Bjorn Andersson --- Changes since v2: - None Changes since v1: - New patch drivers/rpmsg/rpmsg_core.c | 20 ++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 3 +++ include/linux/rpmsg.h | 13 +++++++++++++ 3 files changed, 36 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index a79cb5a9e5f2..5ec8a06c24fa 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -240,6 +240,26 @@ int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) EXPORT_SYMBOL(rpmsg_trysendto); /** + * rpmsg_poll() - poll the endpoint's send buffers + * @ept: the rpmsg endpoint + * @filp: file for poll_wait() + * @wait: poll_table for poll_wait() + * + * Returns mask representing the current state of the endpoint's send buffers + */ +unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, + poll_table *wait) +{ + if (WARN_ON(!ept)) + return 0; + if (!ept->ops->poll) + return 0; + + return ept->ops->poll(ept, filp, wait); +} +EXPORT_SYMBOL(rpmsg_poll); + +/** * rpmsg_send_offchannel() - send a message using explicit src/dst addresses * @ept: the rpmsg endpoint * @src: source address diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 8075a20f919b..6176f2457b6b 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -21,6 +21,7 @@ #define __RPMSG_INTERNAL_H__ #include +#include #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) @@ -70,6 +71,8 @@ struct rpmsg_endpoint_ops { int (*trysendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); int (*trysend_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len); + unsigned int (*poll)(struct rpmsg_endpoint *ept, struct file *filp, + poll_table *wait); }; int rpmsg_register_device(struct rpmsg_device *rpdev); diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 18f9e1ae4b7e..10d6ae8bbb7d 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -41,6 +41,7 @@ #include #include #include +#include #define RPMSG_ADDR_ANY 0xFFFFFFFF @@ -156,6 +157,9 @@ int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len); +unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, + poll_table *wait); + #else static inline int register_rpmsg_device(struct rpmsg_device *dev) @@ -254,6 +258,15 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, return -ENXIO; } +static inline unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, + struct file *filp, poll_table *wait) +{ + /* This shouldn't be possible */ + WARN_ON(1); + + return 0; +} + #endif /* IS_ENABLED(CONFIG_RPMSG) */ /* use a macro to avoid include chaining to get THIS_MODULE */