From patchwork Thu Apr 26 22:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lew X-Patchwork-Id: 10366975 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 9842D6032C for ; Thu, 26 Apr 2018 23:00:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91DD42924B for ; Thu, 26 Apr 2018 23:00:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 868E729267; Thu, 26 Apr 2018 23:00:18 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, 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 392412924B for ; Thu, 26 Apr 2018 23:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755522AbeDZW7d (ORCPT ); Thu, 26 Apr 2018 18:59:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37852 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757029AbeDZW72 (ORCPT ); Thu, 26 Apr 2018 18:59:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4C98A60FE9; Thu, 26 Apr 2018 22:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524783568; bh=gBNq7CPMXI5mKPGKVEfvnz7ABvtYh3xEj+J9UbKqPsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hYVzetEJb0VX0Kn4KvvmdA8FV9GSsbTOkzkRn1KDQvJuZfk37oPKkS2Omn5nQCH0t BHvuQNOnQDONa3tcSw2E9TveFsxHrZ2q7XqN9Tgo1eOI2m4HAF3y+W/jqyohnVYLsq cUnwdghOvLRkXfzswZIFJFtGM1eVza0kzGNztUWg= Received: from clew-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: clew@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 32E4860F93; Thu, 26 Apr 2018 22:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524783567; bh=gBNq7CPMXI5mKPGKVEfvnz7ABvtYh3xEj+J9UbKqPsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VzLaE5bpuYznSQiDXKkf/XhQ7bpWDhs5rgcWR6sqjKdwEgJ475sHMwgPsE7Nnxlu1 22M7ZkInc3qUA2wLflwtoU2hAzNR70a6/SXMg01DclYkYhv0N3fGIH3y9dgwXjb6su V6dBO4HyRrUQBRhUeYBAKhB1nRzQ6CILHc3Z0LJ0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 32E4860F93 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=clew@codeaurora.org From: Chris Lew To: bjorn.andersson@linaro.org, andy.gross@linaro.org, david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: aneela@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, clew@codeaurora.org Subject: [PATCH v3 5/6] rpmsg: glink: Add support for rpmsg glink chrdev Date: Thu, 26 Apr 2018 15:59:04 -0700 Message-Id: <1524783545-21951-6-git-send-email-clew@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524783545-21951-1-git-send-email-clew@codeaurora.org> References: <1524783545-21951-1-git-send-email-clew@codeaurora.org> 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 RPMSG provides a char device interface to userspace. Probe the rpmsg chrdev channel to enable the rpmsg_ctrl device creation on glink transports. Signed-off-by: Chris Lew --- Changes since v1: - Use qcom_glink_alloc_channel to create the chrdev rpmsg device drivers/rpmsg/qcom_glink_native.c | 40 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 120d6b9bb9f3..1418926f6110 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1166,7 +1166,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev) __be32 *val = defaults; int size; - if (glink->intentless) + if (glink->intentless || !completion_done(&channel->open_ack)) return 0; prop = of_find_property(np, "qcom,intents", NULL); @@ -1552,6 +1552,40 @@ static void qcom_glink_work(struct work_struct *work) } } +static void qcom_glink_device_release(struct device *dev) +{ + struct rpmsg_device *rpdev = to_rpmsg_device(dev); + struct glink_channel *channel = to_glink_channel(rpdev->ept); + + /* Release qcom_glink_alloc_channel() reference */ + kref_put(&channel->refcount, qcom_glink_channel_release); + kfree(rpdev); +} + +static int qcom_glink_create_chrdev(struct qcom_glink *glink) +{ + struct rpmsg_device *rpdev; + struct glink_channel *channel; + + rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL); + if (!rpdev) + return -ENOMEM; + + channel = qcom_glink_alloc_channel(glink, "rpmsg_chrdev"); + if (IS_ERR(channel)) { + kfree(rpdev); + return PTR_ERR(channel); + } + channel->rpdev = rpdev; + + rpdev->ept = &channel->ept; + rpdev->ops = &glink_device_ops; + rpdev->dev.parent = glink->dev; + rpdev->dev.release = qcom_glink_device_release; + + return rpmsg_chrdev_register_device(rpdev); +} + struct qcom_glink *qcom_glink_native_probe(struct device *dev, unsigned long features, struct qcom_glink_pipe *rx, @@ -1611,6 +1645,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, if (ret) return ERR_PTR(ret); + ret = qcom_glink_create_chrdev(glink); + if (ret) + dev_err(glink->dev, "failed to register chrdev\n"); + return glink; } EXPORT_SYMBOL_GPL(qcom_glink_native_probe);