Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3678367ybb; Tue, 31 Mar 2020 09:48:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtZFoN/W/ZLmTT0ZdTnvgWT7/2+7DaHKnKBCe/OZow0KYaC+x7WmdNwOysXVUBOlPj5ACJR X-Received: by 2002:aca:cf8a:: with SMTP id f132mr2588933oig.151.1585673339007; Tue, 31 Mar 2020 09:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585673338; cv=none; d=google.com; s=arc-20160816; b=FGuQ/TEO6XRVy6vOXbUj50jRkAOIll0/zYoVrFwXS1Ik1b3X1kI0616igVWZGXwe3a 047CduEQ8xQ2rc1aykpV8NPQdPG36/fQbcalkH9/DdMP+5iQtkE6efCTG4QBKGwGN7qb F5+FfSjZVQb6Y7avr7iSRumbjbeJSNpWzsb+TMZOMoKuWzOx5jXFf2FR3KZpuZKXyG/o KQjkIm7+JrU9YSnxd8PwPNAX4tmhfaqpoPhe8XliBxC7YCtnaCayMKgoQt1ZMM0/ZtvF VnvIJJKYCDphLbWxfg8wlEkFJeftZEW2l07kgBwrTFNvGBtf9kgQaazW2GNsulR0XmOn q8XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OT4pMSpiK/UC4Mr+9RHkJgxu5bDQsWsl1DR3uPPrhxA=; b=XhajAYxcgeCInsh6BA48BxP82gzfvKz+MPsuTEhXJd6nHwnQfxj2XMkm1DDRt4dkpk +mHHEYKi+tU0PBwFAdssUMq86ntf3vFUsh1f3YzZuU2XN/JXVgbS3NlrbJg3wmVkSiOI j/r7Rhm/fmNUcSZPCMI7/6OSI0QBUFkT32RQWBBTnYv2UzWbAEbHxafopgmimLX8HmoF ZHg3XTg1zzMxV593OmOscZTq8TlHGl5h9FdqHgd/CehKhPcPB6XVWnPM02v3NtmBRIni kw2k67XXTuP9lkLlXPe64xkBUFMe/jete56bn3eC9OAtP5kqRRxTnffROBZNcyfFNqw/ 1tGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vB974iQR; 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 n26si7787697otr.78.2020.03.31.09.48.44; Tue, 31 Mar 2020 09:48:58 -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=vB974iQR; 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 S1731097AbgCaQrW (ORCPT + 99 others); Tue, 31 Mar 2020 12:47:22 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:39662 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730442AbgCaQrW (ORCPT ); Tue, 31 Mar 2020 12:47:22 -0400 Received: by mail-il1-f194.google.com with SMTP id r5so20085539ilq.6 for ; Tue, 31 Mar 2020 09:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OT4pMSpiK/UC4Mr+9RHkJgxu5bDQsWsl1DR3uPPrhxA=; b=vB974iQR0mwNOw4ta4Za0CbIwf55mbOkr3ld8d5uyxVx1ETSjNjcsojv8CjlVRaW0d Gd/6PSilrRsC9ppGDDcw3+4Wr9f78Gl5i/HuB5ClEaIwfsiLc0DOhy1esQP7pRmCVUOt KcRcAjZef+0tqaMXcKR19EGP2qhCF8eA3tPvD+EPk/xj0paOd7wC/YpE0UpQYsIjCy93 PWlotFT+sOebVgEqUSVEBl+mmTCf1bhkEroEw78q49EACEqSBmSD/ukqYYnN6/alzi8T 6pN4oM265p982ZorEQpqMrPEDrvnZQcjt2JOsabPyT3MKYdflD5v/QaIYEgkaNBAkzi9 ydPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OT4pMSpiK/UC4Mr+9RHkJgxu5bDQsWsl1DR3uPPrhxA=; b=COQyGOhNmFLx2uFxmWnnOCt2edU7KEJyYehWzy7nD76puQWH41LCEHv+Xx7R02KB55 b+7AGNPF7eFMPKUvEAu89AgNO0tByFl88RLUhBBwI3TnA6elrUlZkojMzNyxb1fpQpGf gNnVFegg0+ipCoiXG1v9PK8uIuTq56fDCsogPxyojJmVl5Dje8Nrv8T+Zwo06nuhsFGX SjamKnyDHLg/N3v8CNtAl5EdEwFnnlONUN9CEbsFPOqsA0q3k/j/imgraNIHtgy0fYP4 wdDsXS+H/e0VwLDCWRdtNV1hzMb2iXqpFMlTdaMLzujNR94/2hmaJ/L1r1LFRMTvDT/H HERw== X-Gm-Message-State: ANhLgQ0M/rIqHTODA94aDrcqg2hxHJqQE8BJ5UGoogOvgO20rdWt63gW ZSn2fmeFrK+FbjrRyGBTcHmVeclzQ0lMtHQLzw8IqQ== X-Received: by 2002:a92:8352:: with SMTP id f79mr16835440ild.58.1585673239840; Tue, 31 Mar 2020 09:47:19 -0700 (PDT) MIME-Version: 1.0 References: <1585241440-7572-1-git-send-email-rishabhb@codeaurora.org> <1585241440-7572-2-git-send-email-rishabhb@codeaurora.org> <20200330221245.GA17782@xps15> <20200330224554.GD215915@minitux> In-Reply-To: <20200330224554.GD215915@minitux> From: Mathieu Poirier Date: Tue, 31 Mar 2020 10:47:08 -0600 Message-ID: Subject: Re: [PATCH 1/2] remoteproc: Add userspace char device driver To: Bjorn Andersson Cc: Rishabh Bhatnagar , Linux Kernel Mailing List , linux-remoteproc , Ohad Ben-Cohen , psodagud@codeaurora.org, tsoni@codeaurora.org, Siddharth Gupta Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Mar 2020 at 16:45, Bjorn Andersson wrote: > > 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. The modem will crash when attempting an IO while rmtfs is down? > > 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. I have a better idea of what is going on now - thanks for writing this up. I would make this feature a kernel configurable option as some people may not want it. I also think having "/dev/remoteprocX" is fine, so no need to change anything currently visible in sysfs. Mathieu > > [1] https://github.com/andersson/rmtfs > > Regards, > Bjorn