From patchwork Tue Sep 25 08:06:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 147404 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp421936lji; Tue, 25 Sep 2018 01:03:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+nHIGGMi2utD9DxITXtXiO73eekX4ab4zRLFlvL6Lnk6GE9cmBgA8JyGjyAgRx4NvjT2/ X-Received: by 2002:a63:2041:: with SMTP id r1-v6mr24255pgm.424.1537862624267; Tue, 25 Sep 2018 01:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537862624; cv=none; d=google.com; s=arc-20160816; b=m1JlWLx2E8FHfusf9Fh1LNl1vofAXZgBr9jKLr22yNOiMJyWevzqPQZ5NR8LGBNeVp K+/RhI+Ah6xfZc57+ulbmU5hrJvSfxoS2ZyseU+pbr9UQ+QGxDFE8vdLrIOombVL0MXA 7Qz0LCGf55F5LRoD8aw3En26jNiupaSC7vbqnE/P051014Gb/tFFeMnmTg3c33zT1qo1 8TE87THxIEljMvEEAs8JcBJ6AkhLef20DxjB4w2Ug+WheLRneyZCI42ZHKoHB47In7iw OgvXkOIpG8j+9YlH2+aqvbygpfj5WsPbsJvYYAPSfG2lSBrwLgqJw4B9KWyvnqc900Yf ReRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=+KON09110A72XVzaovlJFvPoSYpVq29B6AgkhSw+3bo=; b=eWgbIDNGkvAZOop71/ZbSc47sO2tHoQQUpRsn1Jjb5YtuAvnh7dVttgO9ZnSqz3Dyq sMC4psqRQ6GZmm6xvoF01CeE6CVpJkRwXwCs3r20i6T6oK0ss5ZcRS3P1BR7SGPOM7YI pTgz/PBEkVdeG2RVbvaHYIFlA2lv1wMo2fZzlSQV3VmjrHWlXJFqbYm4TjZMWd82Bmtd waUo3+HPmpQaxPPyXtnFkhXRaDHvz52pFk1yvN070Zf4Ca+ZMvXCoHduY49DZr0Ng0Eq eXctpQe6UecruxEcnh1e9+6vj38F3smNpxGCv5q/dz84/Au0UO0RiL8Iwm4poMQMgrw6 chcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cfYfgeZl; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 j14-v6si1809408pgs.694.2018.09.25.01.03.44; Tue, 25 Sep 2018 01:03:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=cfYfgeZl; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1726208AbeIYOKC (ORCPT + 6 others); Tue, 25 Sep 2018 10:10:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37519 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbeIYOKC (ORCPT ); Tue, 25 Sep 2018 10:10:02 -0400 Received: by mail-pf1-f194.google.com with SMTP id x26-v6so621480pfn.4 for ; Tue, 25 Sep 2018 01:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=+KON09110A72XVzaovlJFvPoSYpVq29B6AgkhSw+3bo=; b=cfYfgeZlLyBsPgO8ZzyNen8N1VnWy0XPLpfqhtm7hHYJM41kS6BMb6hA6SU2kdzaeH zt1SOqOIaurxwQDRht5kIU0d4LAn80hkUbiW23snu6wSIPlm9QlfcY8h6s/DrWMpffnq 4VdIztRuyOmNFZAhXPLZ9zb/SVfbetMkfvvMQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+KON09110A72XVzaovlJFvPoSYpVq29B6AgkhSw+3bo=; b=peCGMIY/2DPkibDM+qguG/heW5baktVU5oiYgAhHtnJU4j2j2PNI2Ta3H+XlYu5KL0 4Ldv6wghaIZKV/3RvICg/hT7Nflxwsjf2B4hhlRLFigIpwjp4nlKGo6lkXhCK7yw7ZdW 6dUjR+fByUVzsxGRlm/WciGYnNuBGxjlW2loblK3UBm+WfeSj4MR5TqOX+7lxa5U9tP6 Z9Nh7WKJ3TGYaej1p00u4avWW39BOai8Atf7WI2Gw1GdcVblb2BBnf2hqVKsY7wjBWca bGW9e3j9n1SFvTFU3tG5Y9pNg3QTyruu8lIW9/EnwgWNS5DYT07Bhzja0WxM8Lxa9YaR LE3g== X-Gm-Message-State: ABuFfoiJs+pNExaacM/ZONNKL6FfmQI3IZTFnaa2Pbapb4kUUhAticgV uloS4V5yo4wmW0av92NBAwiIzA== X-Received: by 2002:a17:902:bf46:: with SMTP id u6-v6mr2419099pls.105.1537862622010; Tue, 25 Sep 2018 01:03:42 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id x4-v6sm1879646pfm.119.2018.09.25.01.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 01:03:41 -0700 (PDT) From: Bjorn Andersson To: Rob Herring , Mark Rutland , Andy Gross , David Brown , Sibi Sankar , Avaneesh Kumar Dwivedi Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Subject: [RFC PATCH] soc: qcom: rmtfs_mem: Control remoteproc from rmtfs_mem Date: Tue, 25 Sep 2018 01:06:07 -0700 Message-Id: <20180925080607.30565-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org rmtfs_mem provides access to physical storage and is crucial for the operation of the Qualcomm modem subsystem. The rmtfs_mem implementation must be available before the modem subsystem is booted and a solution where the modem remoteproc will verify that the rmtfs_mem is available has been discussed in the past. But this would not handle the case where the rmtfs_mem provider is restarted, which would cause fatal loss of access to the storage device for the modem. The suggestion is therefor to link the rmtfs_mem to its associated remote processor instance and control it based on the availability of the rmtfs_mem implementation. Signed-off-by: Bjorn Andersson --- The currently implemented workaround in the Linaro QCOMLT releases is to blacklist the qcom_q6v5_pil kernel module and load this explicitly after rmtfs has been started. With this patch the modem module can be loaded automatically by the platform_bus and will only be booted as the rmtfs becomes available. Performing actions such as upgrading (and restarting) the rmtfs service will cause the modem to automatically restart and hence continue to function after the upgrade. .../reserved-memory/qcom,rmtfs-mem.txt | 7 ++++++ drivers/remoteproc/qcom_q6v5_pil.c | 1 + drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/rmtfs_mem.c | 23 ++++++++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) -- 2.18.0 diff --git a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt index 8562ba1dce69..95b209e7f5d1 100644 --- a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt +++ b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt @@ -32,6 +32,13 @@ access block device data using the Remote Filesystem protocol. Value type: Definition: vmid of the remote processor, to set up memory protection. +- rproc: + Usage: optional + Value type: + Definition: reference to a remoteproc node, that should be powered up + while the remote file system memory instance is ready to + handle requests from the remote subsystem. + = EXAMPLE The following example shows the remote filesystem memory setup for APQ8016, with the rmtfs region for the Hexagon DSP (id #1) located at 0x86700000. diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index d7a4b9eca5d2..1445a38e8b34 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -1142,6 +1142,7 @@ static int q6v5_probe(struct platform_device *pdev) qproc = (struct q6v5 *)rproc->priv; qproc->dev = &pdev->dev; qproc->rproc = rproc; + rproc->auto_boot = false; platform_set_drvdata(pdev, qproc); ret = q6v5_init_mem(qproc, pdev); diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 01fb6aba61d2..1109272479b9 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -88,6 +88,7 @@ config QCOM_QMI_HELPERS config QCOM_RMTFS_MEM tristate "Qualcomm Remote Filesystem memory driver" depends on ARCH_QCOM + depends on REMOTEPROC select QCOM_SCM help The Qualcomm remote filesystem memory driver is used for allocating diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 8a3678c2e83c..8b08be310397 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,8 @@ struct qcom_rmtfs_mem { unsigned int client_id; unsigned int perms; + + struct rproc *rproc; }; static ssize_t qcom_rmtfs_mem_show(struct device *dev, @@ -80,11 +83,18 @@ static int qcom_rmtfs_mem_open(struct inode *inode, struct file *filp) struct qcom_rmtfs_mem *rmtfs_mem = container_of(inode->i_cdev, struct qcom_rmtfs_mem, cdev); + int ret = 0; get_device(&rmtfs_mem->dev); filp->private_data = rmtfs_mem; - return 0; + if (rmtfs_mem->rproc) { + ret = rproc_boot(rmtfs_mem->rproc); + if (ret) + put_device(&rmtfs_mem->dev); + } + + return ret; } static ssize_t qcom_rmtfs_mem_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) @@ -127,6 +137,9 @@ static int qcom_rmtfs_mem_release(struct inode *inode, struct file *filp) { struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data; + if (rmtfs_mem->rproc) + rproc_shutdown(rmtfs_mem->rproc); + put_device(&rmtfs_mem->dev); return 0; @@ -156,6 +169,7 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) struct qcom_scm_vmperm perms[2]; struct reserved_mem *rmem; struct qcom_rmtfs_mem *rmtfs_mem; + phandle rproc_phandle; u32 client_id; u32 vmid; int ret; @@ -181,6 +195,13 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) rmtfs_mem->client_id = client_id; rmtfs_mem->size = rmem->size; + ret = of_property_read_u32(node, "rproc", &rproc_phandle); + if (!ret) { + rmtfs_mem->rproc = rproc_get_by_phandle(rproc_phandle); + if (!rmtfs_mem->rproc) + return -EPROBE_DEFER; + } + device_initialize(&rmtfs_mem->dev); rmtfs_mem->dev.parent = &pdev->dev; rmtfs_mem->dev.groups = qcom_rmtfs_mem_groups;