From patchwork Sat Sep 15 00:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 146734 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1279207ljw; Fri, 14 Sep 2018 17:37:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ/35PsPEu1qOSCpP90tNBlU/hifHK0jRWYIlzJjz4mQj/Ryhbdmqs0iRchkYcDXB5hSnqc X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr14156101pga.181.1536971862192; Fri, 14 Sep 2018 17:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536971862; cv=none; d=google.com; s=arc-20160816; b=N9Cqh4LNfW243K1V80jzrJv0T6B1WOyBiIH9HB9XvGrhMUzUCtcr1onu7vd/hGsoeH MAxKp3blVp+lbmG41wGdPEnQiFGaE9MpVsBZoO1D/qQu8xPvywWjxvPso5/3RzgO+wxt 1u/Do27t4dVKrN2szhk2CE2zXUblyn62tosMLCgQnrdmJ4UOFyOrZZhR3crll+evt/BQ X7RVhAFkWTKLfw98f525qm+0fh//P0EE/PK+fjc2C1zfUWZhWgxCfYgoMT/zKfWNMG+w B8jvqBceNtf20m0eSUB5B1Kf9pXh12PvqTbzcd0AK177xO8uIjT6V7HA0tQ8PaH0vAie Hv9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IB39Nnh1RI4spJd8J9S80MU30mSuXvMxoKfq0ImOMGw=; b=0Zr9/2wBnre1LNWasmUVatmEdjPfhkm0gydWA987q9NVEHzDaucb7994VIH+SLJebY nQKxd2svyQXW5gIma5eG0jb5BiE2UWCV5gRlWjmXEea4dP8Ror9moNsQItYKF7U8bUt1 gUd1o5R43U/7lQtwnvvNCOaaOBGPYbWn3qVSRJcmv14mWI+AVDzbpD/c4650YPMLFSgV RIc+6jU3K/KURgDVQt4JGVlTIfmc2tRhKiqx8fAK1NHZczmngqkLsErvvu6Ynw27JJ1K ZJXaVR0lZUChWyhzuHqOABegGoJUtDpJO7x1SZqK1lHoZ39n4FtQxKdqVE27P92SnzX3 YUQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qz8QoENf; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21-v6si8751393pgs.520.2018.09.14.17.37.41; Fri, 14 Sep 2018 17:37:42 -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=@ti.com header.s=ti-com-17Q1 header.b=qz8QoENf; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbeIOFyU (ORCPT + 32 others); Sat, 15 Sep 2018 01:54:20 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:42468 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbeIOFyT (ORCPT ); Sat, 15 Sep 2018 01:54:19 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8F0bR1t046767; Fri, 14 Sep 2018 19:37:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536971847; bh=IB39Nnh1RI4spJd8J9S80MU30mSuXvMxoKfq0ImOMGw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qz8QoENf1mqypDLikPBWqqbDexI8Q5dHoKzjbfgD/02p9UTSxp0RoyL5cX6wMBHgs hzDp6oSsPxQ7OEivXNKW+fVuMu5M2dm2uaC3zbojDwP8JxDSPAor39ebLOGmxPGtGy VeE80mhLywh5pEtvb5Nyx1sGCtONgxtApu3DaRhE= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bRZH032375; Fri, 14 Sep 2018 19:37:27 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 14 Sep 2018 19:37:28 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 14 Sep 2018 19:37:27 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bRDh002123; Fri, 14 Sep 2018 19:37:27 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8F0bRx13339; Fri, 14 Sep 2018 19:37:27 -0500 (CDT) From: Suman Anna To: Bjorn Andersson CC: Ohad Ben-Cohen , Loic Pallardy , Arnaud Pouliquen , , , Suman Anna Subject: [PATCH 1/5] remoteproc: Fix unbalanced boot with sysfs for no auto-boot rprocs Date: Fri, 14 Sep 2018 19:37:21 -0500 Message-ID: <20180915003725.17549-2-s-anna@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180915003725.17549-1-s-anna@ti.com> References: <20180915003725.17549-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The remoteproc core performs automatic boot and shutdown of a remote processor during rproc_add() and rproc_del() for remote processors supporting 'auto-boot'. The remoteproc devices not using 'auto-boot' require either a remoteproc client driver or a userspace client to use the sysfs 'state' variable to perform the boot and shutdown. The in-kernel client drivers hold the corresponding remoteproc driver module's reference count when they acquire a rproc handle through the rproc_get_by_phandle() API, but there is no such support for userspace applications performing the boot through sysfs interface. The shutdown of a remoteproc upon removing a remoteproc platform driver is automatic only with 'auto-boot' and this can cause a remoteproc with no auto-boot to stay powered on and never freed up if booted using the sysfs interface without a matching stop, and when the remoteproc driver module is removed or unbound from the device. This will result in a memory leak as well as the corresponding remoteproc ida being never deallocated. Fix this by holding a module reference count for the remoteproc's driver during a sysfs 'start' and releasing it during the sysfs 'stop' operation. Signed-off-by: Suman Anna --- drivers/remoteproc/remoteproc_sysfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.18.0 Acked-by: Arnaud Pouliquen diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 47be411400e5..2142b3ea726e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -11,6 +11,7 @@ * GNU General Public License for more details. */ +#include #include #include "remoteproc_internal.h" @@ -100,14 +101,27 @@ static ssize_t state_store(struct device *dev, if (rproc->state == RPROC_RUNNING) return -EBUSY; + /* + * prevent underlying implementation from being removed + * when remoteproc does not support auto-boot + */ + if (!rproc->auto_boot && + !try_module_get(dev->parent->driver->owner)) + return -EINVAL; + ret = rproc_boot(rproc); - if (ret) + if (ret) { dev_err(&rproc->dev, "Boot failed: %d\n", ret); + if (!rproc->auto_boot) + module_put(dev->parent->driver->owner); + } } else if (sysfs_streq(buf, "stop")) { if (rproc->state != RPROC_RUNNING) return -EINVAL; rproc_shutdown(rproc); + if (!rproc->auto_boot) + module_put(dev->parent->driver->owner); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Sat Sep 15 00:37:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 146733 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1279199ljw; Fri, 14 Sep 2018 17:37:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaTwCATNEPnAU9vgIy7dL97oqOcfekBGw8PKsm47mt4wAeSBOC51GGqfkNwOUx3RcHByMnf X-Received: by 2002:a63:4283:: with SMTP id p125-v6mr13904715pga.142.1536971861582; Fri, 14 Sep 2018 17:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536971861; cv=none; d=google.com; s=arc-20160816; b=JVJdiJDwM8RuH5Tsw1ahzE18/QMprn9Bo6kjXLgqqWDvLF1sglAhdfT7QiJT1iQHv3 yBBqVpKFfJySlqjkFm05pBojqxk4fiujVyFBUO4ExDE5d7NyFZUOiveil9lmybZi/vH0 rRYTw32slUMpXryqHplKlA1Dz5mh4uoMKMjXz5dKW+ZGndy5yTsoBOKkkO8IQ3Pj/SdN PdkNSC/gJSj5uGTEWbqxxjGbGPACP1YlKtTf4/h8rrY/o7Oa6jRG/FYOlu2qI4aoRXPh eMV9fWN3bUmQEIOyc+NQwMwfHE682nj9GfEvIERYxWTZaRF0JKAbpsNJoLNUvYIhQKGI ODJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=v8u+nQm4s2HkguvF0FiGDM58lOA20Cgf/t4d0m1gS3g=; b=rHqk4x6bJIHpUaO1UDcEGoHXSfdvy+b2bJBMSlt2DLlzHIpgwOERkaoESMyZVoipgm TDaoYhgvA0iEgq3tFzpJiInVOIkscvYfv1cXsGgwu67iB7RoSkdBqcJ8r9fs2dsf7kl5 AnkZFo9Dw99DpTqEjRoH7MdH53gID5uH7wtls84FYIEaT7hT/ULTKd1uYKwxA5m44Cl6 qWvpMutfz9ZMcatuDLK08L3ygPd1zPeg4NWhkqYFXFnaUp/22+mrTjZhW3ufGgZnAUEX KYqFDdtaYTEYWN97LcxQ4iDJ9iBMJvl1R1nFRnjj84JBBy85hma16x3io+t9JqdtVADi Zxhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="iS/Mf6Y+"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21-v6si8751393pgs.520.2018.09.14.17.37.41; Fri, 14 Sep 2018 17:37:41 -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=@ti.com header.s=ti-com-17Q1 header.b="iS/Mf6Y+"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbeIOFyS (ORCPT + 32 others); Sat, 15 Sep 2018 01:54:18 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:37362 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbeIOFyS (ORCPT ); Sat, 15 Sep 2018 01:54:18 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8F0bSMt071587; Fri, 14 Sep 2018 19:37:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536971848; bh=v8u+nQm4s2HkguvF0FiGDM58lOA20Cgf/t4d0m1gS3g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=iS/Mf6Y+XZG0b+XSCWiS//+/lII24xptKqP3NYRFSNTxVBLQhHMLPTcN5ESs2icVN RZpmKQeVOH3IPgeEluXFnmCR/nz6NWgjw6bLQgCdIGkpjEpETRYd+ewQxNsr9mrkAy 9mMWoZY1xoqtoxiSmiVy6crDOJf7TjHdtwQmMLfI= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bRik023602; Fri, 14 Sep 2018 19:37:28 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 14 Sep 2018 19:37:28 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 14 Sep 2018 19:37:27 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bR7H002128; Fri, 14 Sep 2018 19:37:27 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8F0bRx13343; Fri, 14 Sep 2018 19:37:27 -0500 (CDT) From: Suman Anna To: Bjorn Andersson CC: Ohad Ben-Cohen , Loic Pallardy , Arnaud Pouliquen , , , Suman Anna Subject: [PATCH 2/5] remoteproc: Check for NULL firmwares in sysfs interface Date: Fri, 14 Sep 2018 19:37:22 -0500 Message-ID: <20180915003725.17549-3-s-anna@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180915003725.17549-1-s-anna@ti.com> References: <20180915003725.17549-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The remoteproc framework provides a sysfs file 'firmware' for modifying the firmware image name from userspace. Add an additional check to ensure NULL firmwares are errored out right away, rather than getting a delayed error while requesting a firmware during the start of a remoteproc later on. Signed-off-by: Suman Anna --- drivers/remoteproc/remoteproc_sysfs.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.18.0 Tested-by: Arnaud Pouliquen diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 2142b3ea726e..ce93f4d710f3 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -49,6 +49,11 @@ static ssize_t firmware_store(struct device *dev, } len = strcspn(buf, "\n"); + if (!len) { + dev_err(dev, "can't provide a NULL firmware\n"); + err = -EINVAL; + goto out; + } p = kstrndup(buf, len, GFP_KERNEL); if (!p) { From patchwork Sat Sep 15 00:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 146735 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1279210ljw; Fri, 14 Sep 2018 17:37:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaWswjqGiWdG8BtRgEiJiJr2XgzpQwgiT6yvZNDZrqKKVnGBA6CUk17w6RUisY+Nykf65vD X-Received: by 2002:a63:170b:: with SMTP id x11-v6mr13491299pgl.364.1536971862661; Fri, 14 Sep 2018 17:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536971862; cv=none; d=google.com; s=arc-20160816; b=L+WxwC0nRsmhfPdAqBmBJ7UK7/cLewEubzSG/MXcTfbBv2Y7ZI2auAg6BWFV9Z9P8o mHEL+dij14NB8m9vMPUeYnHvxYFRtcpP2G64pcsB0pCWiaArMKrB8FK0B/e6uodSGjiS KDFyCyi3bt9luBVk/uxdI6dVMhXAgYaERi37mIblKZ2jqA35hGc8LcDRb3TRIYo6z9Za AwO8Xg/Ui+zRVSR5oiWMis3FQ9sHdl26XeyeKQlYUQEmYbRCRqL9KLbEsrISCtCpYviR MGirhg1JD4kpbPIUE0Tvhc1iLNYw9Xc2VMUM6sfgOoFtq1vPXmhKWZle4qnTaace7AUZ Nd8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=xnvtoqichP3Dhx06FPNggRPmID5Dra8hbZBo1afAyZ8=; b=gVFTGU65dpyLt6SJLIzfW0j2Da/S3mh3ag36Cu2Vy86HY/+hNAWefwQq4tgZGt2kTL RnttgFzmNKrbRII9zM5OvCXBQkl5BF5uwb2fRyT8K4nANGMoD6KiBw5d5b/ewu891Deg VqBVyISTsrjqgQsQcdCrOoK+aPQiRfYPlDjbtn77Ek53UJsTeKGAesw7O3BKOV5fhpKQ 9ozLazLPSOCkOJlAfNGT7ODgymrTWuZX1cV5mdWgrQbbnZdbAAn/+ToeG8t9/D1QpgWm 1or/Z2qmB3HuBXc2WJfPoNglruevlfd5XpLBGuEjHD1epjxLHilaPF8cuX40Cs2ZHtdX +rJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wxa62eyi; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21-v6si8751393pgs.520.2018.09.14.17.37.42; Fri, 14 Sep 2018 17:37:42 -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=@ti.com header.s=ti-com-17Q1 header.b=wxa62eyi; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbeIOFyU (ORCPT + 32 others); Sat, 15 Sep 2018 01:54:20 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:42466 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725754AbeIOFyS (ORCPT ); Sat, 15 Sep 2018 01:54:18 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8F0bSuN046772; Fri, 14 Sep 2018 19:37:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536971848; bh=xnvtoqichP3Dhx06FPNggRPmID5Dra8hbZBo1afAyZ8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wxa62eyiR2fUtusKklpIVKdeW2otk31u/Q0WCP6hIVgpKRi0SswsnxJgb2SFE4/l2 F6f/k/9LXNKs0myboMx1ydi8DwhjNTj73LIyMhDx0t2iWve7bDl3aY9rgBs2MayCS/ NidfudpfBar2xaCXOj/z+Mx/XvAIEAZOYplAQNNE= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bSuN023608; Fri, 14 Sep 2018 19:37:28 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 14 Sep 2018 19:37:28 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 14 Sep 2018 19:37:28 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bRvN010467; Fri, 14 Sep 2018 19:37:27 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8F0bRx13347; Fri, 14 Sep 2018 19:37:27 -0500 (CDT) From: Suman Anna To: Bjorn Andersson CC: Ohad Ben-Cohen , Loic Pallardy , Arnaud Pouliquen , , , Suman Anna Subject: [PATCH 3/5] remoteproc: Add missing kernel-doc comment for auto-boot Date: Fri, 14 Sep 2018 19:37:23 -0500 Message-ID: <20180915003725.17549-4-s-anna@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180915003725.17549-1-s-anna@ti.com> References: <20180915003725.17549-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit ddf711872c9d ("remoteproc: Introduce auto-boot flag") introduced the auto-boot flag but missed adding the corresponding kernel-doc comment. Add the same. Signed-off-by: Suman Anna --- include/linux/remoteproc.h | 1 + 1 file changed, 1 insertion(+) -- 2.18.0 diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e3c5d856b6da..75f9ca05b865 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -439,6 +439,7 @@ struct rproc_dump_segment { * @cached_table: copy of the resource table * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU + * @auto_boot: flag to indicate if remote processor should be auto-started * @dump_segments: list of segments in the firmware */ struct rproc { From patchwork Sat Sep 15 00:37:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 146737 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1279274ljw; Fri, 14 Sep 2018 17:37:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYqSua5DgsOvYohCPHqD9urAKnsxym1NAh9WthyMIwcbGvGBrYHPvz3x2WKv5HdW7kncD2t X-Received: by 2002:a17:902:76c5:: with SMTP id j5-v6mr14385271plt.140.1536971871323; Fri, 14 Sep 2018 17:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536971871; cv=none; d=google.com; s=arc-20160816; b=e+oX+K5Ix3zoeJ3176GpIffdM7iFlu6+xZzfIKXPYEhWpz1Ev3wCALl7Ccs/ZeiG5f pRySsobvIvGvNlMuNqX1ayll2UBpWO0CYKy2POpfpLI7zj9yPqdTcowMH1d+PUF0lydH 1rbJ3QQxeCYIU7fNOwWa3hX/EGl+QTumL1SZnFiQg60UZQkaADroAcVtzuAi+OEEVQSi 0EHi6HDW3Eh8qMWIYZk0GRxdsKNffr+RQY0iD0NcjR8jilMuU0MQBpRGSRjS6h0Ek2EW JXI/BMXSc68muDay9EkE3/Xp4xk4G5gRZ4W9VD/OeP5gVZo9hgt8HJpUXm1q5ud6VaE0 1hdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=wLEYCzC9XufBzVfjjUNucSdiCcLogJD4kaqjN567E+s=; b=sOrDKd7c/s23aMMrKlUdXV0hdzABnsS7TfVVvgZcehtWcXzKMkSUiovJ8sy2yKPnZV GkNt8O+SX17yKHvwZsyMZmxdmjElLn+vfMqUr28/sv2oipwmvmzVtCo3fK90ymFkZqex NT88d5ujzv/gvTmSxR0pQNA5RolC6rn/5HY8FqVpT/G3biIfZPtmI+sZWlc9mG7d0CiA MdG7rSc/of2FTIsxNk7ocRRIF+rbDo14XVkMIp+FE2ZDE8mHUkOGh7mvdgE2RebfTAI/ FYxKi29YCH+xoZUqzVgStbYXiPQSy8TytG4nXcEOXY3Z+f1a2rv+V2icFrTz9keZ5hnI bj+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GImp8Plq; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3-v6si8408047pga.137.2018.09.14.17.37.51; Fri, 14 Sep 2018 17:37:51 -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=@ti.com header.s=ti-com-17Q1 header.b=GImp8Plq; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727225AbeIOFyc (ORCPT + 32 others); Sat, 15 Sep 2018 01:54:32 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:37496 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbeIOFyT (ORCPT ); Sat, 15 Sep 2018 01:54:19 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8F0bSGX030650; Fri, 14 Sep 2018 19:37:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536971848; bh=wLEYCzC9XufBzVfjjUNucSdiCcLogJD4kaqjN567E+s=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=GImp8Plq9X0wJlxcM7EmsAIuMPRjI0lcXNCaDb/ZM/iCpEyF4oDP4SiP8RcUBECcF Si8H9yyuP6OZdFi0Tq66D9EL3HrHXKz3h9F7Nq9qMW/a6KQVNT7qkWcicgd1iaIJUS G2MFnLydd1iT/0dXbwp1Dkk3R7MSjGpKOQCFP/Ns= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bSPf023617; Fri, 14 Sep 2018 19:37:28 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 14 Sep 2018 19:37:28 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 14 Sep 2018 19:37:28 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bSx9018266; Fri, 14 Sep 2018 19:37:28 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8F0bRx13351; Fri, 14 Sep 2018 19:37:27 -0500 (CDT) From: Suman Anna To: Bjorn Andersson CC: Ohad Ben-Cohen , Loic Pallardy , Arnaud Pouliquen , , , Suman Anna Subject: [PATCH 4/5] remoteproc: Introduce deny_sysfs_ops flag Date: Fri, 14 Sep 2018 19:37:24 -0500 Message-ID: <20180915003725.17549-5-s-anna@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180915003725.17549-1-s-anna@ti.com> References: <20180915003725.17549-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The remoteproc framework provides sysfs interfaces for changing the firmware name and for starting/stopping a remote processor through the sysfs files 'state' and 'firmware'. These interfaces are currently allowed irrespective of how the remoteprocs were booted (like remoteproc self auto-boot, remoteproc client-driven boot etc). These interfaces can adversely affect a remoteproc and its clients especially when a remoteproc is being controlled by a remoteproc client driver(s). Also, not all remoteproc drivers may want to support the sysfs interfaces by default. Add support to deny the sysfs state/firmware change by introducing a state flag 'deny_sysfs_ops' that the individual remoteproc drivers can set based on their usage needs. The default behavior is to allow the sysfs operations as before. Signed-off-by: Suman Anna --- drivers/remoteproc/remoteproc_sysfs.c | 8 ++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 10 insertions(+) -- 2.18.0 diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index ce93f4d710f3..b2d8c11b89d0 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -36,6 +36,10 @@ static ssize_t firmware_store(struct device *dev, char *p; int err, len = count; + /* restrict sysfs operations if not allowed by remoteproc drivers */ + if (rproc->deny_sysfs_ops) + return -EPERM; + err = mutex_lock_interruptible(&rproc->lock); if (err) { dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, err); @@ -102,6 +106,10 @@ static ssize_t state_store(struct device *dev, struct rproc *rproc = to_rproc(dev); int ret = 0; + /* restrict sysfs operations if not allowed by remoteproc drivers */ + if (rproc->deny_sysfs_ops) + return -EPERM; + if (sysfs_streq(buf, "start")) { if (rproc->state == RPROC_RUNNING) return -EBUSY; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 75f9ca05b865..d21252b4f758 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -440,6 +440,7 @@ struct rproc_dump_segment { * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU * @auto_boot: flag to indicate if remote processor should be auto-started + * @deny_sysfs_ops: flag to not permit sysfs operations on state and firmware * @dump_segments: list of segments in the firmware */ struct rproc { @@ -472,6 +473,7 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + bool deny_sysfs_ops; struct list_head dump_segments; }; From patchwork Sat Sep 15 00:37:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 146738 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1279308ljw; Fri, 14 Sep 2018 17:37:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYqb6yuMCIR/H90EkWbUX8PGrNvHsQAP0Em2/NEtm6ZGIbv5sP6MI23q0f38q54A6qfSlf5 X-Received: by 2002:a63:ab0c:: with SMTP id p12-v6mr14186824pgf.190.1536971874992; Fri, 14 Sep 2018 17:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536971874; cv=none; d=google.com; s=arc-20160816; b=k4voeD12uekonSA/Ib96/iTNqIOudPzOMSlPOfTumhw81MFJnsUqZuxUx+osuINtdj dsZK6dxhfu6//k31AyvMl1qedonm+Oxl1IYb7CrqXdAVuNl9aY1wupvjKDw3xg04rotz /M8Gl8NvAPkHNW/KfBsJzr8VvSBiPKAdIgRLJavyRSyb+f/D9oIbQd3fuWdH2KqzhEOi YGC3N3KayFktEZ0UWeAJlqcE3vIVjin75UCmLTSeyiH4Nfi4MAGifEz+5GUq9eUs/6Y0 d8KDvajiryp673uLwIAXasLpxpQQ+LpvzT/jwe90YRr7k5aqoXPjSMFazHxkGA7TuFpe vVBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=U/URxLYk+u/unXsblN+t/eH+5kYwXM1lAsKzPedS5Ho=; b=wBh/4etmGQQrJJtVej0r0qtwyrAukGfdSn+OVY8Us6W+rM+0tlGElSjdBScDm+ic2B V9sg72WEc8T31AK+Sedr6xN3HmEUdrUigx5QL7A48JL1TuogyB+mwOrH2Fnhr3n4YogX BbYp6HGsopHA+/Uzq0Fnikzq+fScLUKMt4tXpQtN8Coyx8zHjfKbL9AwhPAnT0h0TMQg /PV7z1RZsWOZxKMs3xPe+nUhTns54jNdAS04u0K/QxWhzw3IpSWyow+b5JvpJhaI0ScG gk2uk1Xn3WQQduDFXwwRrIEExJLvs7uxgr/2UGd0Uc3DceGIXsJzkvyqS+kw/oxknsnT XTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="nRoJ+O/G"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 30-v6si8312894pgt.678.2018.09.14.17.37.54; Fri, 14 Sep 2018 17:37:54 -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=@ti.com header.s=ti-com-17Q1 header.b="nRoJ+O/G"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbeIOFyk (ORCPT + 32 others); Sat, 15 Sep 2018 01:54:40 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:37494 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbeIOFyT (ORCPT ); Sat, 15 Sep 2018 01:54:19 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8F0bSur030654; Fri, 14 Sep 2018 19:37:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1536971848; bh=U/URxLYk+u/unXsblN+t/eH+5kYwXM1lAsKzPedS5Ho=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nRoJ+O/GXT3mzr4/zEp9L/B9UeGQb13BDDQEC3BnBaAHsvRMeqzG8PDczZWieVwvH hFhzghnafEXZ8ogIoYRSM4MksG/mZkh4mqqIl/81tYdtGYfb0/ZYX49hTuxBmxhrjQ dI5iu+AsDFuAQKjx/jVILrFH8c8sTbD9UoSPFLmY= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bSkv032390; Fri, 14 Sep 2018 19:37:28 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 14 Sep 2018 19:37:28 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 14 Sep 2018 19:37:28 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8F0bSVV010482; Fri, 14 Sep 2018 19:37:28 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.58.153]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w8F0bSx13355; Fri, 14 Sep 2018 19:37:28 -0500 (CDT) From: Suman Anna To: Bjorn Andersson CC: Ohad Ben-Cohen , Loic Pallardy , Arnaud Pouliquen , , , Suman Anna Subject: [PATCH 5/5] remoteproc/wkup_m3: Set deny_sysfs_ops flag Date: Fri, 14 Sep 2018 19:37:25 -0500 Message-ID: <20180915003725.17549-6-s-anna@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180915003725.17549-1-s-anna@ti.com> References: <20180915003725.17549-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Wakeup M3 remote processor is controlled by the wkup_m3_ipc client driver, so set the newly introduced 'deny_sysfs_ops' flag to not allow any overriding of the remoteproc firmware or state from userspace. Signed-off-by: Suman Anna --- drivers/remoteproc/wkup_m3_rproc.c | 1 + 1 file changed, 1 insertion(+) -- 2.18.0 diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c index 1ada0e51fef6..327757fd4d8f 100644 --- a/drivers/remoteproc/wkup_m3_rproc.c +++ b/drivers/remoteproc/wkup_m3_rproc.c @@ -168,6 +168,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) } rproc->auto_boot = false; + rproc->deny_sysfs_ops = true; wkupm3 = rproc->priv; wkupm3->rproc = rproc;