Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2908080ybb; Mon, 30 Mar 2020 15:47:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuuxWAasFC1ioe7i9UyBc0pleG1PQwZbR4gly0gAkpIpyX+iSK9kPamtnCLTwXYgmtIqqGP X-Received: by 2002:aca:c6ca:: with SMTP id w193mr223308oif.165.1585608464932; Mon, 30 Mar 2020 15:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585608464; cv=none; d=google.com; s=arc-20160816; b=wJhj2iuWpPbTY/ab7oyO3sgdmr97GVw6F5eU1BkVUfDkxY/+NgAbRuaoZfwKNQYr8s RZNmGZJCuIW/w9Ac+zybVO5f7uktFOtQN80JLNLhhSs4IUkdbeIf9vpyt9YNYIxXQWXp 2g9IE6H1I7/HJO/DoJ4l2P+utVhtznlHR9AuiIemgc4i/JX7NHVd2oII7lMt5XsChUKA Mw1oIf1Y6mXomi3YAqeMYkBDA+Kj7tCvPAPoThcaApmHNm+n4XSWPCMTTc2ChiYQ28Ly Fm7JC5IbwSyRrX05LuX6yjFDJXLWDnRwXr2lntY/nAqG84goa83HKJCXe7R2HtZGD/ct msZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zZ9zHEhLIDqVsi6Cz+Zx6pbNZgHca94Pq7iQclalSOI=; b=CN4YDv95z+pDum+oY3D9mA13Acj+rh2LXjJ/U6ray3wJ2h8A6IbHQmKrbggAEsq01A ItYqGd7y0KYpY9ZmBEk5pIHTRsrGGzDtNFPsjFpbVjHqSjtjx0EX9s/yMy357a54tcvr z6bw/bL1P8vX8xFp6vM3kYbPuO3hmmq1FbWSKD33OnLFyzgUO5JA9a9PBrdyvGqhdcUx iP5rYJWpCPww9AfwsEPtj+T0Gm3mX3pCi/FE7adHT6M7Moh7wo9TooDptPnDpPwkL+Zp MJk/dfqPO/dnvqZ1LtjAJN/lqSWO+D7hVw+EFWPCu70uAqYsfbaQuRh2qkv6f3fPaFik GNhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=osQM7ADN; 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 y123si6407889oia.141.2020.03.30.15.47.31; Mon, 30 Mar 2020 15:47:44 -0700 (PDT) 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=osQM7ADN; 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 S1729239AbgC3WqA (ORCPT + 99 others); Mon, 30 Mar 2020 18:46:00 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:51653 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728876AbgC3WqA (ORCPT ); Mon, 30 Mar 2020 18:46:00 -0400 Received: by mail-pj1-f67.google.com with SMTP id w9so249424pjh.1 for ; Mon, 30 Mar 2020 15:45:58 -0700 (PDT) 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; bh=zZ9zHEhLIDqVsi6Cz+Zx6pbNZgHca94Pq7iQclalSOI=; b=osQM7ADN7pHOs4QtANYPrQcf5eG7G8m92LOwSLs0JSthCMXUBFxP+wyvM8YP3JhC2a AZo0H0//ibzz2m9AQg+xVCh9jUylgQDjX6Wk26XyQqv+NZZqxvC9FsIdJopqSWtyLJXH EdY9NaywEKpupY8IPpKiSqCIKGctJOszxEQyUEv91a8U0zgpEGk0RRSwRO204XGE24oq sJzsTX3rkQ/cwyDWwMj408dsTJPN5XZB3+iF2WOo5Et0EPS+pn00A4xfyqxVKi9STGtC DpkwgsY0PmqW+qhArXAQoFLmyyYRROgs3ySzkZEz/JtqDFqpCg+v+Ozx1lj8N6OEiH7Y +/iA== 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; bh=zZ9zHEhLIDqVsi6Cz+Zx6pbNZgHca94Pq7iQclalSOI=; b=mgbrMAQprLTWfSAWWo+T+vqOCnksDIjKQRdVyLyXFZir9qJZiZjcQQiecpiiDYiIpj Wp1EIksTFgqIynZlm273asda/RQxYSriWqf0QAxLTWn7DE50S8QlLb/FrDFU5A9TfnGh c3eB+2auZ1P75v4PNy7qNh3McXznFz3l6PIvOSb8+Srn10G83Az2mM4k4K4ZDHLR6oRP Tc4lUbJk0TKbCO+R6bVxs4K6jSTfCRPo53+l5wao13fmPHE3cWKc491rbA/S5DAeN7G8 g4SySRnE64A4LTYvsLRB44/Ose2JJy/bcXe5oz6eKcZeHVfvSZ41QVEywrWfntgl1w0R kr6A== X-Gm-Message-State: AGi0PubcSkF3F595aFJKo3tIRTSXN1qm6rFy4YpsMD7rWfsAe+qMhq8o UstdciYBUDIE8wf7sE3R8NUJ1A== X-Received: by 2002:a17:90a:5802:: with SMTP id h2mr358500pji.141.1585608357469; Mon, 30 Mar 2020 15:45:57 -0700 (PDT) Received: from minitux (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id z17sm11041812pff.12.2020.03.30.15.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 15:45:56 -0700 (PDT) Date: Mon, 30 Mar 2020 15:45:54 -0700 From: Bjorn Andersson To: Mathieu Poirier Cc: Rishabh Bhatnagar , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, ohad@wizery.com, psodagud@codeaurora.org, tsoni@codeaurora.org, sidgup@codeaurora.org Subject: Re: [PATCH 1/2] remoteproc: Add userspace char device driver Message-ID: <20200330224554.GD215915@minitux> References: <1585241440-7572-1-git-send-email-rishabhb@codeaurora.org> <1585241440-7572-2-git-send-email-rishabhb@codeaurora.org> <20200330221245.GA17782@xps15> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200330221245.GA17782@xps15> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 30 Mar 15:12 PDT 2020, Mathieu Poirier wrote: [..] > > + struct rproc *rproc; > > + > > + rproc = container_of(inode->i_cdev, struct rproc, char_dev); > > + if (!rproc) > > + return -EINVAL; > > + > > + rproc_shutdown(rproc); > > The scenario I see here is that a userspace program will call > open(/dev/rproc_xyz, SOME_OPTION) when it is launched. The file stays open > until either the application shuts down, in which case it calls close() or it > crashes. In that case the system will automatically close all file descriptors > that were open by the application, which will also call rproc_shutdown(). > > To me the same functionality can be achieved with the current functionality > provided by sysfs. > > When the application starts it needs to read > "/sys/class/remoteproc/remoteprocX/state". If the state is "offline" then > "start" should be written to "/sys/.../state". If the state is "running" the > application just crashed and got restarted. In which case it needs to stop the > remote processor and start it again. > A case when this would be useful is the Qualcomm modem, which relies on disk access through a "remote file system service" [1]. Today we register the service (a few layers ontop of rpmsg/GLINK) then find the modem remoteproc and write "start" into the state sysfs file. When we get a signal for termination we write "stop" into state to stop the remoteproc before exiting. There is however no way for us to indicate to the modem that rmtfs just died, e.g. a kill -9 on the process will result in the modem continue and the next IO request will fail which in most cases will be fatal. So instead having rmtfs holding /dev/rproc_foo open would upon its termination cause the modem to be stopped automatically, and as the system respawns rmtfs the modem would be started anew and the two sides would be synced up again. [1] https://github.com/andersson/rmtfs Regards, Bjorn