Received: by 10.223.185.116 with SMTP id b49csp2368253wrg; Thu, 15 Feb 2018 10:30:38 -0800 (PST) X-Google-Smtp-Source: AH8x227QbCLk71KVcG9ZL/jjiP8+7VYgfQKKvLr3rFDEJcmAItRwDSA05aFWH0ziQ3ISEMfEnHya X-Received: by 10.98.101.195 with SMTP id z186mr3447525pfb.47.1518719438227; Thu, 15 Feb 2018 10:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518719438; cv=none; d=google.com; s=arc-20160816; b=k0Jd2eiX3XXpTYxJoy1K6mrHu9uzfjNgfll//r+DHhSMOz4c//jHTMF/dILanO+y0o nXU80uMBUEGFtPfPCsLxwnsZqGi+WzWK9yulHqRwG4A7zZYOFFG2O6R1N0dRoBt0aOZl S4SocZsyL9LTr3zSZDiDXiACZU2UOFdYm5HtnPfweIyzVL6SIyFQMC46xNntSFuG4HeX WqRmDSgOQyLTVaOqvzYMobVs1XrHzKdq4/RaLRIpFrvCcUiOtb35M/wgjOVztXkOG4QI JXButmXx9N5Gx5/Iy0F6wjN4Ri7WwraX8LPfuC645wnsjaAbH+qWCyLN+AWD5aZY1ROh wdSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Gjabuhp1jefVo6LV9/BHRyqLTFn2gL/T/rTcGmMB6uQ=; b=xsicloWsPcKWRrFEwTCbKuJQcBoxkgQhHgdSy4lEjJ7Kfdn4Z5LU6Lcu4jJHye2t1c wjtK6uk2MV7vK+8vb2P2XboYkjdFpSuR2pvj/M3FKO/kmA5sP7Sr8zOYCx7XSd1X8Mx/ 3jck1QK5GeAd1dny65HhlU8Lei4CMQc2t/AojzgT9c8CjXf28oYe2YN2nNTbvbBstDzc ReJ8Mdaz53xl5TIzKvsz2IQTV1A9oZsD5p1Yyzv4rIcaxRN4V66ivUlFfDBMQk/FBaoq BCU3yQiNZdDZgHwnPCpgA0o0iGl/J9KVKScghS27dciNZ1/tWvYVq3T6N+yWB5v27T1E ayCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eGOCCWy+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9-v6si1915449pli.410.2018.02.15.10.30.23; Thu, 15 Feb 2018 10:30:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eGOCCWy+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166483AbeBOS3B (ORCPT + 99 others); Thu, 15 Feb 2018 13:29:01 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36643 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163184AbeBOS2n (ORCPT ); Thu, 15 Feb 2018 13:28:43 -0500 Received: by mail-pg0-f66.google.com with SMTP id j9so427385pgv.3 for ; Thu, 15 Feb 2018 10:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Gjabuhp1jefVo6LV9/BHRyqLTFn2gL/T/rTcGmMB6uQ=; b=eGOCCWy+P4bctR/8XQEeHzaII078chufzIAYzgRygW93qr1i9HUCu3yWnc+WPDdAg+ i/pnShdQKy+ogtTVDOiq354H0e5Mh9hqF9SSktFDMItCG8LDLbf8hqQsWtOVXuP8PXg7 1+Oh3WPSy/ho3udjxlF/yNuXCClGh2Z502SiQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Gjabuhp1jefVo6LV9/BHRyqLTFn2gL/T/rTcGmMB6uQ=; b=HXzmhSQ8JyIf40nSpLZpagvymBNBY+e8/2Ti41EDQ4Z1qm2+SssW0hJI+YdwP+zpXO QQae0lRlYobn1efP4MrZR0VTicLZ5+ZFY2vnVlf8sP15ZIq93QUdJrqN8OnNiGgruZuP d2SCaHh2+GUVXcbWK+FppVpSFbFIRYBfgTG0cbKxX/lG7V/CBWYz+IaMZzNZ/hbWosyQ PNorWFGMJ6KUf7m2oS9C5d4FkCSe036betsK2onwkl68Uj6fQUFRCxMdVCTmwQeZa3fi lBKx/K5gnyd2vHn1vKk7NjS51RjdQyf/wFTsBheuiz5g+Cdd6LMNStqxpcdTDnO0Rr+l pFjg== X-Gm-Message-State: APf1xPA9SytG+e4/Q5ONeHtJqsI732cGg8Z7BmI6vbjMoUpYxuv/n/qz K60mDq0jHVHHwcovWNcuzjB5NIMzS6k= X-Received: by 10.98.197.68 with SMTP id j65mr3425231pfg.93.1518719322923; Thu, 15 Feb 2018 10:28:42 -0800 (PST) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t8sm37025440pgr.21.2018.02.15.10.28.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Feb 2018 10:28:41 -0800 (PST) Date: Thu, 15 Feb 2018 10:28:39 -0800 From: Bjorn Andersson To: Chris Lew Cc: robh+dt@kernel.org, andy.gross@linaro.org, david.brown@linaro.org, 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 Subject: Re: [PATCH 3/6] rpmsg: glink: Add support for rpmsg glink chrdev Message-ID: <20180215182839.GA25607@builder> References: <1513634534-22861-1-git-send-email-clew@codeaurora.org> <1513634534-22861-4-git-send-email-clew@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1513634534-22861-4-git-send-email-clew@codeaurora.org> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 18 Dec 14:02 PST 2017, Chris Lew wrote: > 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 > --- > drivers/rpmsg/qcom_glink_native.c | 39 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > > diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c > index 179132226dc2..786f2eca01f1 100644 > --- a/drivers/rpmsg/qcom_glink_native.c > +++ b/drivers/rpmsg/qcom_glink_native.c > @@ -132,6 +132,13 @@ enum { > GLINK_STATE_CLOSING, > }; > > +struct qcom_glink_device { > + struct rpmsg_device rpdev; > + struct qcom_glink *glink; > +}; > + > +#define to_glink_device(_x) container_of(_x, struct qcom_glink_device, rpdev) > + > /** > * struct glink_channel - internal representation of a channel > * @rpdev: rpdev reference, only used for primary endpoints > @@ -1339,6 +1346,10 @@ static struct device_node *qcom_glink_match_channel(struct device_node *node, > return NULL; > } > > +static const struct rpmsg_device_ops glink_chrdev_ops = { > + .create_ept = qcom_glink_create_ept, > +}; I can't remember and I see no apparent reason why we don't just advertise the intents as the last step of create_ept, meaning that the difference in ops would go away. This would also make sure that we do advertise some intents for channels associated with the rpmsg_char - and even if we don't have an attached driver we can override the intent sizes on a channel. > + > static const struct rpmsg_device_ops glink_device_ops = { > .create_ept = qcom_glink_create_ept, > .announce_create = qcom_glink_announce_create, > @@ -1547,6 +1558,30 @@ 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 qcom_glink_device *gdev = to_glink_device(rpdev); > + > + kfree(gdev); > +} > + > +static int qcom_glink_create_chrdev(struct qcom_glink *glink) > +{ > + struct qcom_glink_device *gdev; > + > + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); > + if (!gdev) > + return -ENOMEM; > + > + gdev->glink = glink; > + gdev->rpdev.ops = &glink_chrdev_ops; > + gdev->rpdev.dev.parent = glink->dev; > + gdev->rpdev.dev.release = qcom_glink_device_release; > + > + return rpmsg_chrdev_register_device(&gdev->rpdev); This rpdev will end up being the first parameter to qcom_glink_create_ept() where we do: container_of(rpdev->ept, struct glink_channel, ept) to get the struct glink_channel that backs the endpoint of the passed rpmsg_device. So the registered rpdev must reference a rpmsg_endpoint that is contained within a glink_channel. So I think you need to create two objects here; a glink_channel with the glink pointer referencing the glink instance and a rpmsg_device referencing the rpmsg_endpoint of the channel. You can get a initialized (and dangling) glink_channel by calling qcom_glink_alloc_channel(). Note though that this element won't be freed automagically (the rpmsg_device will). > +} > + Regards, Bjorn