From patchwork Mon Jun 1 17:51:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48415159A for ; Mon, 1 Jun 2020 17:52:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 310F92076B for ; Mon, 1 Jun 2020 17:52:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BWXu/xDa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbgFARwY (ORCPT ); Mon, 1 Jun 2020 13:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgFARvn (ORCPT ); Mon, 1 Jun 2020 13:51:43 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6952CC08C5C0 for ; Mon, 1 Jun 2020 10:51:42 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id n2so228838pld.13 for ; Mon, 01 Jun 2020 10:51: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=P8PjysMxQsTesyBq9RtPxt40SNxrNk3UpGWSe+KaZAk=; b=BWXu/xDaB7Gom168KNfT9sEGUCx9HCvG2fUEZZzcFrkLnf5pak77an8GMxPHPV3YG9 jAzqED+enSbOrtks+Jj5ZMLpCDxB1t/ppugU8ByhTPalu3JGukALAk4DBEd4tNP5Sw5m 6rycEYQ+9FQmP5PY6T2ZsS4fM08Rmr2tF2yWS4SGWDNNp/hLmAvu/wYut4z7LBqIjopY j60SEWC1Lfro3r+KbKVlCI1YsRUqdEknRi1S1EUTOT5cgiewamDhcIAqiLHrcdJd3gJL VmwNw8Z2MkXlfb9WuMWiNehklpcZs5IG8gnB/qHXf60jtNRUGRmlVhX1R8NEBQKgw4g5 R4bg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=P8PjysMxQsTesyBq9RtPxt40SNxrNk3UpGWSe+KaZAk=; b=j+mU2NbZeX9ynDhf/WwRcXaouEnbP8Inr75WLfmFiOobJTWPpLJ5TbcJin2rfD2Uf3 EqfyX3MAxj260Q88x450c4oyCMlb6HYOH12xgggp9/0vKQQ1ELQ/s7dymi+jHKJHCeJh 0vtE7xPwJ/qf5xx2nlbMErUG4qFIcS+Y4decb80k9dXWk3t+h9d7xsW+ExpnswJAOXid B5PWvQEU1e77VvifutnjRTZ9h9q83OsQtl3UhMu/OhXygOChtTJDdBKed4CKG7SSFqwk Eajt0dhJkq6UbJlyXn4c+WB2zVxnoUXB9IE+HRhKzaTk8NqHz9RiQy0JuRmoEdWEZVaA pMYg== X-Gm-Message-State: AOAM5339jZYyzbkHe4GioiQTdZd1wOQdyfWMPlAxA4f8oURplA5PANAX 3wDnJWiLTmamQmKkj1kA1LOGzy8OqjM= X-Google-Smtp-Source: ABdhPJzJOOqWX1Cc09sbwBv76StaoRsG2l4moo5y7S//tSakbFo5u5KUbupcc8+mwKQBM+f4s/w13w== X-Received: by 2002:a17:902:bb94:: with SMTP id m20mr9344835pls.148.1591033901984; Mon, 01 Jun 2020 10:51:41 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:41 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 1/9] remoteproc: Add new RPROC_DETACHED state Date: Mon, 1 Jun 2020 11:51:31 -0600 Message-Id: <20200601175139.22097-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a new RPROC_DETACHED state to take into account scenarios where the remoteproc core needs to attach to a remote processor that is booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 7f8536b73295..8b462c501465 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -71,6 +71,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e7b7bab8b235..21182ad2d059 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -400,6 +400,8 @@ struct rproc_ops { * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery * @RPROC_DELETED: device is deleted + * @RPROC_DETACHED: device has been booted by another entity and waiting + * for the core to attach to it * @RPROC_LAST: just keep this one at the end * * Please note that the values of these states are used as indices @@ -414,7 +416,8 @@ enum rproc_state { RPROC_RUNNING = 2, RPROC_CRASHED = 3, RPROC_DELETED = 4, - RPROC_LAST = 5, + RPROC_DETACHED = 5, + RPROC_LAST = 6, }; /** From patchwork Mon Jun 1 17:51:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DCD590 for ; Mon, 1 Jun 2020 17:52:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5E882076B for ; Mon, 1 Jun 2020 17:52:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XMh2YQ00" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728285AbgFARwY (ORCPT ); Mon, 1 Jun 2020 13:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbgFARvn (ORCPT ); Mon, 1 Jun 2020 13:51:43 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884C7C08C5C9 for ; Mon, 1 Jun 2020 10:51:43 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id p30so3828371pgl.11 for ; Mon, 01 Jun 2020 10:51:43 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=MbOKQVccoNk2iiaBCxRQwqrB6pY9V3Ek5XyuyrPL344=; b=XMh2YQ00G3/iFxRJLp5X+Ffu1aDH9sHaBAby+8PDY928HiuKVov7KQ/xyV987CcyRn 3R4aqvM9gLbpYp4UbAzd3d5iFf6wumH1UmIPXZ2p4vbGJZZ+QxntY4uYK0dKEUTUleJs dOrScvgMF+nbeES+cIfHO/ygGL4HzwCZyxNXui/59j7FOGinXLVFjU3BCmjA7bu7x3Pk VnaiHoI+QznyvPmUjFzS9gsGhjwGM9C7UhD/yfhMw5fKoAcUd+ykW/WFDi+PKgCafX2y QYa8ivZLmAXdOnHbmdWvicXI0ZyHbptrKor6POUKGswFRWrDNCaPDkKdQgLAHbZROHJu 9fsA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=MbOKQVccoNk2iiaBCxRQwqrB6pY9V3Ek5XyuyrPL344=; b=ZWgvHI1MNYfTKfyuWu7CiNKAtHdpg15hBbEJXxip8kE4Q9840N54jifUMmUwc8Xblu vw3PUpoUQs4+obhbZUzByN35sc0dZX9dBsDiojsAJTRLXOscB1vx2329EPrC+pxnHArj 37tf9lFppQcdndWtz7azjD4kP4tL93XCPUqPlQYxItIu35R6tK2uFNKB69bIQOFuh3jL ZSS0Ar4OzL5bD0VVbdJxzwu0G+dGYVyq6/YcuC5bsKqwv/O5i3bFaphlUikPkCMdkACn 7XrW/ET7ntaYitfFUUSHfF8OeieUU9OyjW46HSOtkmZ6ejIDLHxLp63gSaqvtoktGOlO meFA== X-Gm-Message-State: AOAM532CB6cUi1us05oJaFBzMZqo8v6cg9YwRKXxV5ijplezI4TbendZ A1Pr1m3rPPASg90iS7CkMRgj9A== X-Google-Smtp-Source: ABdhPJyThCX4Ai+3IbVSLO17nsi28llbYdW3I8iACfWmVTPeTmDXfBXGql/ZgbvdMUU1Q/L9K+JNbw== X-Received: by 2002:a62:3381:: with SMTP id z123mr22115539pfz.274.1591033903039; Mon, 01 Jun 2020 10:51:43 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:42 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 2/9] remoteproc: Add new attach() remoteproc operation Date: Mon, 1 Jun 2020 11:51:32 -0600 Message-Id: <20200601175139.22097-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add an new attach() operation in order to properly deal with scenarios where the remoteproc core needs to attach to a remote processor that has been booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_internal.h | 8 ++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 4ba7cb59d3e8..fc710866f8ce 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -79,6 +79,14 @@ static inline int rproc_unprepare_device(struct rproc *rproc) return 0; } +static inline int rproc_attach_device(struct rproc *rproc) +{ + if (rproc->ops->attach) + return rproc->ops->attach(rproc); + + return 0; +} + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 21182ad2d059..bf6a310ba870 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -359,6 +359,7 @@ enum rsc_handling_status { * @unprepare: unprepare device after stop * @start: power on the device and boot it * @stop: power off the device + * @attach: attach to a device that his already powered up * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations * @parse_fw: parse firmware to extract information (e.g. resource table) @@ -379,6 +380,7 @@ struct rproc_ops { int (*unprepare)(struct rproc *rproc); int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); + int (*attach)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, size_t len); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); From patchwork Mon Jun 1 17:51:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 130A5913 for ; Mon, 1 Jun 2020 17:52:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF163207DF for ; Mon, 1 Jun 2020 17:52:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lg+3hcJ4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbgFARwV (ORCPT ); Mon, 1 Jun 2020 13:52:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbgFARvp (ORCPT ); Mon, 1 Jun 2020 13:51:45 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2E32C08C5C9 for ; Mon, 1 Jun 2020 10:51:44 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id k2so146628pjs.2 for ; Mon, 01 Jun 2020 10:51:44 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=FItOKgdj0uldhq4ThGfwK1TNrUS2A/jMnQRmSCeHCgM=; b=lg+3hcJ4uWV77YK1218h714AN6E1Y48qGMiFQ6RgI3YGMxx4yf+DSbsdjFIU6DI4VB v2uks0KMjYfjzc+VGgdeGxpwmNX9fbhjtG9jG5nUzbfYx6BO5uHZtMxpT9JgBEvYf0Yd zbOgym5mr+oJMp7CFoj8jTWHWJfbavzYE3HjDvsorp5GVn5UXh7tx6+pRHxB5/rhGT+3 8uVl5Yl8xjf+s518G/KLq5Gvmbf5NUDn3wcERtZLIzDCkzTpMPFI4qwAkdpCTpNTpEmk KQpZeGsEjcBAL8I5qmGUzKSn2wYhdkcVN9allh6etYaUUM62K0v1e1bQUdUfCa+QxpcL O4iA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=FItOKgdj0uldhq4ThGfwK1TNrUS2A/jMnQRmSCeHCgM=; b=Uq9lwKK4CZyg+u0dA7YUen45nhCKz8VLdo5QJWwLogvcecm1d9a5MZgvvbQUxOv+EL /ApiQmaqTNn7VTbR18gI0tOQRT6SzSb0jXLD19vVgP8orVgWPFrhe1oT/lASh0VS+Sjk kQF6ldJM9Px20lueZNQ+/deimRICaIk5m20lXOfpymZZmIh/Rjjlb1Ku8qyKx4ABNoSr fjc8gKzOyWQaTCK49vUkoZLDc7ZYsca9PiwBbF80dQ28fyu2b69LTNe79aKv+un09LzT xxKyk1AUOSbq+ZWBu/tHsIk4znoHC8luZzV0Y6qwTyBeXQ93ayZbSrx5dwNbqTSS0ctF 9Kkg== X-Gm-Message-State: AOAM530T/ox0BwGNGViHo7fY0kly8CttpHOQbAbsbitfAPJ8e1sq1Qt4 i2jZutmPo/jTAybRVKPxmv1LSyeXXJ0= X-Google-Smtp-Source: ABdhPJytXJC13MoeIXNHI+CzrFwM69Q2/+HS7YEgvViTh3vSIhNXtLzF9YHtK5en9do1wF3fsWE31Q== X-Received: by 2002:a17:902:b484:: with SMTP id y4mr21539701plr.21.1591033904237; Mon, 01 Jun 2020 10:51:44 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:43 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 3/9] remoteproc: Introducing function rproc_attach() Date: Mon, 1 Jun 2020 11:51:33 -0600 Message-Id: <20200601175139.22097-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introducing function rproc_attach() to enact the same actions as rproc_start(), but without the steps related to the handling of a firmware image. That way we can properly deal with scenarios where the remoteproc core needs to attach with a remote processsor that has been booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9f04c30c4aaf..0b323f6b554b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1370,6 +1370,48 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } +static int __maybe_unused rproc_attach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = rproc_prepare_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to prepare subdevices for %s: %d\n", + rproc->name, ret); + goto out; + } + + /* Attach to the remote processor */ + ret = rproc_attach_device(rproc); + if (ret) { + dev_err(dev, "can't attach to rproc %s: %d\n", + rproc->name, ret); + goto unprepare_subdevices; + } + + /* Start any subdevices for the remote processor */ + ret = rproc_start_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to probe subdevices for %s: %d\n", + rproc->name, ret); + goto stop_rproc; + } + + rproc->state = RPROC_RUNNING; + + dev_info(dev, "remote processor %s is now attached\n", rproc->name); + + return 0; + +stop_rproc: + rproc->ops->stop(rproc); +unprepare_subdevices: + rproc_unprepare_subdevices(rproc); +out: + return ret; +} + /* * take a firmware and boot a remote processor with it. */ From patchwork Mon Jun 1 17:51:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5280913 for ; Mon, 1 Jun 2020 17:52:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBE00207BB for ; Mon, 1 Jun 2020 17:52:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="efnU2p08" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728077AbgFARvr (ORCPT ); Mon, 1 Jun 2020 13:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728002AbgFARvq (ORCPT ); Mon, 1 Jun 2020 13:51:46 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6D61C08C5C0 for ; Mon, 1 Jun 2020 10:51:45 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 185so3832887pgb.10 for ; Mon, 01 Jun 2020 10:51:45 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=95EWc68nYSQ/9MObgW9pgJNxpvrSjDNtZ8lwnmoabNI=; b=efnU2p08BqycqkIC+/it/z8qsI4D9aw7hkyuo9zzFXED+ybHh99HDWDw94cqh+v4vS krELd4kmJ7hhpMsAkY4zHemblrWZVSEDSds6JLHWkic8k1mG5YBMtwEj8DITFkaopGcT QRjvlKvFmc5DCV02ynFCokL6DPKP6v+yiGBkJrUdfm1pLaup0mrvnV+FbHsIjF0INsU+ IitAagIxRMdfi1ND0oRHpfgMgpJ9cUT+Fmk55Qs5vTMxFis728kV+4lbantjqfG3sRQj RwnIwtojv+TqGsLrSHrs9QdSR8GAeAExdMm6tYckRsz7UXyg7igpQ5uGN8Ld4UuM3SJE tepQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=95EWc68nYSQ/9MObgW9pgJNxpvrSjDNtZ8lwnmoabNI=; b=C01dx7sal7OBteLJWkpV++5l8kYxmqWmVQV/v3KXds69LXgfaxW/Sk4vX17aZIenBn sEjqkLmX30zJMd4NJf2Y+6AjD1ho+oPrijWW5d4TeYcrrj3M2Q5TuS5iMX26NB6kZpX6 5yZ2yiNvrso/yKMipFGEcokJrgIYOaPxODwoOiPNaJ/LEbn5kjiwoaZjkO4kZ+Uu7OFw 0rCfiGLAqRKQ75YwbioYN5nCbapxbqHvCu7wynrF36t5/UwE70uKYaZRPQk7y240Nayb TqN6T98yek36QhFNSeg2Kkj2ZtzfmTjcmFSpMI8mnDZQ4xYGi3b+NLUzQYZTiCU33BZf dwJg== X-Gm-Message-State: AOAM532Oq40Niw3XM6U3MhVXKT6p5XYWtQjqhFFq7tFWO+M5CCLLHeNo FGo4GMw15GGem0cs3c1+qBzL7Q== X-Google-Smtp-Source: ABdhPJzO9KDg1cvTMWlJ7X3FLWugqoAab26LXHV5AeczKSEmLVpsQI1Q3xgOrMrZ9SS7uubJ8I8xQQ== X-Received: by 2002:aa7:9488:: with SMTP id z8mr10280347pfk.157.1591033905381; Mon, 01 Jun 2020 10:51:45 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:44 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 4/9] remoteproc: Introducing function rproc_actuate() Date: Mon, 1 Jun 2020 11:51:34 -0600 Message-Id: <20200601175139.22097-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce function rproc_actuate() that provides the same functionatlity as rproc_fw_boot(), but without the steps that involve interaction with the firmware image. That way we can deal with scenarios where the remoteproc core is attaching to a remote processor that has already been started by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 68 +++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0b323f6b554b..c70fa0372d07 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1370,7 +1370,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } -static int __maybe_unused rproc_attach(struct rproc *rproc) +static int rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1499,6 +1499,72 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } +/* + * Attach to remote processor - similar to rproc_fw_boot() but without + * the steps that deal with the firmware image. + */ +static int __maybe_unused rproc_actuate(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + /* Tell the PM runtime core we need to keep this device powered */ + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "pm_runtime_get_sync failed: %d\n", ret); + return ret; + } + + /* + * if enabling an IOMMU isn't relevant for this rproc, this is + * just a nop + */ + ret = rproc_enable_iommu(rproc); + if (ret) { + dev_err(dev, "can't enable iommu: %d\n", ret); + goto put_pm_runtime; + } + + /* reset max_notifyid */ + rproc->max_notifyid = -1; + + /* reset handled vdev */ + rproc->nb_vdev = 0; + + /* + * Handle firmware resources required to attach to a remote processor. + * Because we are attaching rather than booting the remote processor, + * we expect the platform driver to properly set rproc->table_ptr. + */ + ret = rproc_handle_resources(rproc, rproc_loading_handlers); + if (ret) { + dev_err(dev, "Failed to process resources: %d\n", ret); + goto disable_iommu; + } + + /* Allocate carveout resources associated to rproc */ + ret = rproc_alloc_registered_carveouts(rproc); + if (ret) { + dev_err(dev, "Failed to allocate associated carveouts: %d\n", + ret); + goto clean_up_resources; + } + + ret = rproc_attach(rproc); + if (ret) + goto clean_up_resources; + + return 0; + +clean_up_resources: + rproc_resource_cleanup(rproc); +disable_iommu: + rproc_disable_iommu(rproc); +put_pm_runtime: + pm_runtime_put(dev); + return ret; +} + /* * take a firmware and boot it up. * From patchwork Mon Jun 1 17:51:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CACD9159A for ; Mon, 1 Jun 2020 17:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2E19206E2 for ; Mon, 1 Jun 2020 17:52:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P7z6mupH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbgFARvr (ORCPT ); Mon, 1 Jun 2020 13:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbgFARvr (ORCPT ); Mon, 1 Jun 2020 13:51:47 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C48DC08C5C9 for ; Mon, 1 Jun 2020 10:51:47 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id 185so3832916pgb.10 for ; Mon, 01 Jun 2020 10:51:47 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=B6+pUeAejjtzVfaBN0FavjPBfNkLhu10xe20LReaYXA=; b=P7z6mupHizFgqgL7AXpjElLYchS8p4ojFpzVQL8VmARsn64VsmdOongaf+12Ia9uga 33hW6V9eKYfBSMzd9KEn6T2yiq1k1HSU6iqFiRTdpJoaNf+bBWxBuQOugbrNyh35d6O0 6K7IF8Gn79C6pckdbuKrauGBz2NWPL8xLxAJaCBonxKCvFLnE3SMevPawMcs5daGU5L6 wbIm1oFCB9V4jCua9LEGOE1HLYqTOLGk4C9eif/E8R3cAmBoAZ9LE6pZmzvtRxK1Ndeo 8S1pjzSGAMfmjn99d92ip/qB1qWrC+0Bb11oRaqPPFRvqSVvGnHW3Hm9WUabdDY/PmWe lhOw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=B6+pUeAejjtzVfaBN0FavjPBfNkLhu10xe20LReaYXA=; b=fZpJA1zUXEEYlKDCuuiqg/YYzhCdU2f+AwvtCrIL2CqIOJAnoEsh4p0Jvx6BfRjzOc VwdrGby0bZF+09pJVuKxqjqZ8grNYRuqKEKfqLs0vdOLucG9XYi1mdLS7NlfUOHTTsnh 0SKeDVnhk8eFbwSpkIxu63VqxauPvzMY4ELZMWloTwrULKEHM8LMq9vQ6bDs0/EWsRoP G2eijmUXwqsw6GDR6K3iuFfRkEgNwNhgxrKHvrHePsmCXmPItyZ/g0MQ8rbiOHnqQW9V GzVHfyZbn1Tlz5js5PP+Lk6zjp/nBpuEmq/lTLoxmW1hnwWXopR/QFbDEso1ul5Q3IdK IvJw== X-Gm-Message-State: AOAM533p8LKenUVrUWRzD/cBgkBbCa+wKYlPBGQNSVR8SKGJLaxBqKCf nawWYR0hEWOysuGm+rJTZe99HndSvcc= X-Google-Smtp-Source: ABdhPJw6ow2Vt30SZPXJYfXOQB2Gr70Ayo0LDI8dl3mtw6J1ZVM2PdDyfrBFrcmDDH/LyQ5n6Uj2Pw== X-Received: by 2002:a63:3e46:: with SMTP id l67mr19818480pga.430.1591033906497; Mon, 01 Jun 2020 10:51:46 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:46 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 5/9] remoteproc: Introducing function rproc_validate() Date: Mon, 1 Jun 2020 11:51:35 -0600 Message-Id: <20200601175139.22097-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a new function to assert the general health of the remote processor before handing it to the remoteproc core. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c70fa0372d07..0be8343dd851 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2060,6 +2060,47 @@ struct rproc *rproc_get_by_phandle(phandle phandle) #endif EXPORT_SYMBOL(rproc_get_by_phandle); +static int rproc_validate(struct rproc *rproc) +{ + /* + * When adding a remote processor, the state of the device + * can be offline or detached, nothing else. + */ + if (rproc->state != RPROC_OFFLINE && + rproc->state != RPROC_DETACHED) + goto inval; + + if (rproc->state == RPROC_OFFLINE) { + /* + * An offline processor without a start() + * function makes no sense. + */ + if (!rproc->ops->start) + goto inval; + } + + if (rproc->state == RPROC_DETACHED) { + /* + * A remote processor in a detached state without an + * attach() function makes not sense. + */ + if (!rproc->ops->attach) + goto inval; + /* + * When attaching to a remote processor the device memory + * is already available and as such there is no need to have a + * cached table. + */ + if (rproc->cached_table) + goto inval; + } + + return 0; + +inval: + return -EINVAL; +} + /** * rproc_add() - register a remote processor * @rproc: the remote processor handle to register @@ -2089,6 +2130,10 @@ int rproc_add(struct rproc *rproc) if (ret < 0) return ret; + ret = rproc_validate(rproc); + if (ret < 0) + return ret; + dev_info(dev, "%s is available\n", rproc->name); /* create debugfs entries */ From patchwork Mon Jun 1 17:51:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A44F90 for ; Mon, 1 Jun 2020 17:51:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50813206E2 for ; Mon, 1 Jun 2020 17:51:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jsMA2JyG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbgFARvt (ORCPT ); Mon, 1 Jun 2020 13:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728090AbgFARvs (ORCPT ); Mon, 1 Jun 2020 13:51:48 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20547C05BD43 for ; Mon, 1 Jun 2020 10:51:48 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id n9so260041plk.1 for ; Mon, 01 Jun 2020 10:51:48 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=H4kQzqlSCAiGDPrwPoS10a6NS/WJiGKixInVwf23N/g=; b=jsMA2JyGDIA2nuPm/U8Q8emjpcS27scT4vh7LMJR8IPXxQsLi1oUbUHzimNDNTqPIa b1isEdpMDotZ0t9TLHTxyFpsHUX8Zf90IRJh6BKLJ9m5rgS7x5dFu3MnvbbD+ev0L+HQ ZVYTUKwVibT61Pv5o1OT4DhH8GY3h8Ux6dlxSO26HZZGpNf2OLWdpvyFpzLMd3P1dO6r ZvxhQirCPqo7fCWMMMZCGjhuPTgh3STIZwlyKSdVsosdrccbn0bZCxYBYQomYci+X08O cAOrV/Smjbyqm34RyA+QlZbH9QQHsFUS+OfqYVNjqzcpPZMUgY93oj14gxO/Hso1Jv2e 4xyA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=H4kQzqlSCAiGDPrwPoS10a6NS/WJiGKixInVwf23N/g=; b=EcBwiBw78dZOjsaTouvgVxwyS17BqsCrUSSZS4KLNPCDZCyrQdnIW9BkzvaR5ZeMQo e2BvmcSKyk5RYnzLq0Y6DFB9XnmOY47cjc/YICV97Azw7EIE5dHdTxZCtQJ39h0sGpwQ M9Aehu0Pv8hoQsILDVzSmr2ueUcS91FP7FwD4XRtTb4YKe6SOYb3ib8enS/Yvl4OGkn2 7iO3/PCbEG5djmOaMBuEgw5n6JSbBUL6dxRXaciHGwrI8PQ9gB0ZG4cJlMdohOaHY2T/ KdqvIRAFYFADV4OkhLj4pF0yBmMQqBEpLw7/jszqODosOwmq4LQhjz6pj9qPEcot/fke BKjw== X-Gm-Message-State: AOAM533CiQrspx8fWjcnS3XGuzy7yZyEFM9lLjiAd3ORjCm4Trn0l7hK euL1nfoTHsH9aSURDNxRjOj5xPANI88= X-Google-Smtp-Source: ABdhPJzgGKvoHRtBwkv2pzmRwy7lyhLJmxlvRmupu2umM7NcN6smBZrrcXePAmh3ySolMbCMraLA/Q== X-Received: by 2002:a17:902:6b0a:: with SMTP id o10mr19376036plk.121.1591033907658; Mon, 01 Jun 2020 10:51:47 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:47 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 6/9] remoteproc: Refactor function rproc_boot() Date: Mon, 1 Jun 2020 11:51:36 -0600 Message-Id: <20200601175139.22097-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Refactor function rproc_boot() to properly deal with scenarios where the remoteproc core needs to attach with a remote processor that has already been booted by an external entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0be8343dd851..48ddc29814be 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1503,7 +1503,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. */ -static int __maybe_unused rproc_actuate(struct rproc *rproc) +static int rproc_actuate(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1923,24 +1923,30 @@ int rproc_boot(struct rproc *rproc) goto unlock_mutex; } - /* skip the boot process if rproc is already powered up */ + /* skip the boot or attach process if rproc is already powered up */ if (atomic_inc_return(&rproc->power) > 1) { ret = 0; goto unlock_mutex; } - dev_info(dev, "powering up %s\n", rproc->name); + if (rproc->state == RPROC_DETACHED) { + dev_info(dev, "attaching to %s\n", rproc->name); - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto downref_rproc; - } + ret = rproc_actuate(rproc); + } else { + dev_info(dev, "powering up %s\n", rproc->name); - ret = rproc_fw_boot(rproc, firmware_p); + /* load firmware */ + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + goto downref_rproc; + } - release_firmware(firmware_p); + ret = rproc_fw_boot(rproc, firmware_p); + + release_firmware(firmware_p); + } downref_rproc: if (ret) From patchwork Mon Jun 1 17:51:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF4BF913 for ; Mon, 1 Jun 2020 17:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D36A420872 for ; Mon, 1 Jun 2020 17:52:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="koUUxIAJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726901AbgFARwG (ORCPT ); Mon, 1 Jun 2020 13:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbgFARvt (ORCPT ); Mon, 1 Jun 2020 13:51:49 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1261DC05BD43 for ; Mon, 1 Jun 2020 10:51:49 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id n9so260050plk.1 for ; Mon, 01 Jun 2020 10:51:49 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=HuK+8lYq2MurWahP0YDt+ZKf6I/9GaLpDEv4/D3a90U=; b=koUUxIAJB8sNAZ/BIgVmeJjrfw7ai/Y7R0/F0CDKaSTqluC4KHJERTw83l37owKl+u si/lOnIB8HfwzIwKrA6mx7oczePRijGsawk6uHFwdZMfExTe/TZktA75HEebMZq2gDHw wRZKNZYs9qxyuQ10Wv63hELl91OhPnSx95HrCMZ+Tcr2HFVLdjJZjO1WNY7m1D7NSxaM OFkO2i8aVsD6AnnQQGQ1AODa2PKcHJo9LWMRALOdj0+GWZ4MRqMP7TMsf3jOqkewVH5F 4QFMCBQSCmTIy9sEUjxTzHqMBNKk9Vd7dORwFGUWDh4k9WjKeYTIS4EprHV7oToG0ceP B+qQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=HuK+8lYq2MurWahP0YDt+ZKf6I/9GaLpDEv4/D3a90U=; b=C5JcoLe4sRyVerQw+7vRFbogUN9RHpKTVJMuOUHL84/P93qlwv+W2sPRc8M7y30NxW PTFEtzFEtHNZfOBgy0hgNJIzaNUO64wLGiFYC0/DwhDI3GbYu8p1u4wjNvtPt/Iw5Cy0 47uSo7hbObX7LWHpsxyHfodNuNGyo50XS2cOgQP48eik7m7yXzAI0cWC1//pMHLqgssr VaiITQYsazawwcfNLmmX9JMJwUxnB43XIDiamxDXBW7xxGpjcrAYpO5vIKJAFRokfA1l weOUqCZu34VIHgKdfJXe5mHuXGb36SqJaoCVvW0UMZqpIL1FUzkKNFuxcwKrIZRX5Vbm v7kw== X-Gm-Message-State: AOAM5306BGIX5g1kQTrzmmMoY98CYIWMbktPXjvvKkIMECZZ/psIcisu OjFARiN0l0HocP90ERgbSiMVDw== X-Google-Smtp-Source: ABdhPJwX0c8InqxDLHSYUpgobxDg57wx0RGXH2kegjZmGSR+B8TSixZWGNT3dhCGZM+KwEyxDCJdWg== X-Received: by 2002:a17:90a:d3d6:: with SMTP id d22mr585255pjw.184.1591033908665; Mon, 01 Jun 2020 10:51:48 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:48 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 7/9] remoteproc: Refactor function rproc_trigger_auto_boot() Date: Mon, 1 Jun 2020 11:51:37 -0600 Message-Id: <20200601175139.22097-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Refactor function rproc_trigger_auto_boot() to properly deal with scenarios where the remoteproc core needs to attach with a remote processor that has already been booted by an external entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 48ddc29814be..d32ac8f0c872 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1586,6 +1586,15 @@ static int rproc_trigger_auto_boot(struct rproc *rproc) { int ret; + /* + * Since the remote processor is in a detached state, it has already + * been booted by another entity. As such there is no point in waiting + * for a firmware image to be loaded, we can simply initiate the process + * of attaching to it immediately. + */ + if (rproc->state == RPROC_DETACHED) + return rproc_boot(rproc); + /* * We're initiating an asynchronous firmware loading, so we can * be built-in kernel code, without hanging the boot process. From patchwork Mon Jun 1 17:51:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A692990 for ; Mon, 1 Jun 2020 17:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BD6B206E2 for ; Mon, 1 Jun 2020 17:52:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o5Aq+ozp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbgFARwG (ORCPT ); Mon, 1 Jun 2020 13:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgFARvu (ORCPT ); Mon, 1 Jun 2020 13:51:50 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B259C08C5C9 for ; Mon, 1 Jun 2020 10:51:50 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id i12so144853pju.3 for ; Mon, 01 Jun 2020 10:51:50 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=8/x/Azb6Kg/NbqI55RX5Ve/Ez0un3vqYQH7pMGZ5AbE=; b=o5Aq+ozpRTnKAIKVImlb5AcOZXP4grSiV+mfEH/upXXatlwIxF/j5A5cANcnl0AHgT jwuCkOrSk0rsG3fXuif/iF5bxYGB8prSvJiICxP32EF5/T0GUEPXqLZULvoljkIlZqXM jpJmUm4TBT5etW6/epjCRJxgVL2c2Y2a+a2c7HM6+KoUqyTZ21P7xV+jddLDnzltZ/5D kyFyWW/mg3iu6RClpV91KwnVVSeK9rphak2IroFFJx5NYsHoGz5JVkxucX7oV6qw+DFD 1P6TXhA/dQ1Oxyg6R++p2P44qAoqCS+U1lcjr/nnitGTaM3r700ATuqt+QqHIYyDMW6j XAcQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=8/x/Azb6Kg/NbqI55RX5Ve/Ez0un3vqYQH7pMGZ5AbE=; b=Q7MvEYhpl2qWIgsHDGk4tKnw72DeiFPixZwFcJBMTRufsHVZCiCGEumpr3ecFDdMkJ K+7R1mQ+1y3HPEjCG1bWJTQk7t4bbLVI7rfkMQ8+OctBhTHRyMvNbEMczKUtfO4BqY0g 0XBJ+Jm4NcQ4zmZCFoxsFxdHq3FpYzRS8Rt9huqZW8x78n1qfFC8cAZ6ci+uvpoeb783 aQ4GERfsdTzbIbfJSCIL3W8UKn78swiYDq8lZ7lIpXAOxc7d27KZjR/LVEH6x3Dxt3em V7mKv3CXwgXMMy6X0n+qVDOfHSQUWqU10YIvO3/qEA1Kq2lnMajzHn312tJYsWKZ5q8+ ATZw== X-Gm-Message-State: AOAM53010DphWmyZ3wQ7lb9nWjRsun2aBEM9sVV6MsQrUhVaF/LTaqN8 /0cbjtFitgHI3+RG57Gi+/P5qQ== X-Google-Smtp-Source: ABdhPJz2XBksbMn0b1dSVqWqAtwyfVpq/mky7/dIjOLWcXgf9hlsILKNhfxKUy0icTxrOVKr8FVMaA== X-Received: by 2002:a17:902:b097:: with SMTP id p23mr10131955plr.14.1591033909721; Mon, 01 Jun 2020 10:51:49 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:49 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 8/9] remoteproc: Refactor function rproc_free_vring() Date: Mon, 1 Jun 2020 11:51:38 -0600 Message-Id: <20200601175139.22097-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org When function rproc_free_vring() clears the virtio device section it does so on the cached resource table rather than the one installed in the remote processor memory. When a remote processor has been booted by another entity there is no need to use a cached table and as such, no need to clear the virtio device section in it. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index d32ac8f0c872..0e23284fbd25 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -411,10 +411,22 @@ void rproc_free_vring(struct rproc_vring *rvring) idr_remove(&rproc->notifyids, rvring->notifyid); - /* reset resource entry info */ - rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; - rsc->vring[idx].da = 0; - rsc->vring[idx].notifyid = -1; + /* + * At this point rproc_stop() has been called and the installed resource + * table in the remote processor memory may no longer be accessible. As + * such and as per rproc_stop(), rproc->table_ptr points to the cached + * resource table (rproc->cached_table). The cached resource table is + * only available when a remote processor has been booted by the + * remoteproc core, otherwise it is NULL. + * + * Based on the above, reset the virtio device section in the cached + * resource table only if there is one to work with. + */ + if (rproc->table_ptr) { + rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; + rsc->vring[idx].da = 0; + rsc->vring[idx].notifyid = -1; + } } static int rproc_vdev_do_start(struct rproc_subdev *subdev) From patchwork Mon Jun 1 17:51:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11582431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D961990 for ; Mon, 1 Jun 2020 17:51:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9B832073B for ; Mon, 1 Jun 2020 17:51:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xV8yuXtw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728162AbgFARvw (ORCPT ); Mon, 1 Jun 2020 13:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728144AbgFARvv (ORCPT ); Mon, 1 Jun 2020 13:51:51 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51720C08C5CB for ; Mon, 1 Jun 2020 10:51:51 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id m7so251442plt.5 for ; Mon, 01 Jun 2020 10:51:51 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=pqpjieqWzPdW4kzMNpwF5pnX0DXNGRCF4a9MybtJdT0=; b=xV8yuXtwUh++8lV8BVnmVOMFKn53SmBmnp2YNZxGf8Trj+639nR8oSYo80GhJ9HoEM Cyxq9yEixuV9BAacNnNlsgDlyNdb7ep1rEknCXcA6JL18jGHKKllU3mWDIOz5Q+QWLPR CqcqTdHCs2ddxMFa+7kjz4tDJB7JBC/D9LbnPDLUh5+KBLCkz/birKGLRY4fyLXQaC+2 e0BzZyj+uFckAtUW4EPOfaiLudrq5/5K8qaepd4twB6/4f+pKxeUSQGYe9kXTlo5ZxSM GoPCUnixn2Ad9tWPZYRUExGsMKJ1vQRnkwQJrz1avpfJRh5s6o8Lhi9VENgDu9QQy7Ls fO4Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=pqpjieqWzPdW4kzMNpwF5pnX0DXNGRCF4a9MybtJdT0=; b=PDE6QC5vskvOi5MHW1x5QvM4l18u39mpEIR5dMpYIMtUajsZx10H9ZRKKpgrqxVc+r ABmlZdGHrQI4JZM117xlSESne1raz8tM9HznBHeqVmqz8shm/xyn50znU/Xih9G+8QZu OreZEd18VI37A9rnJbJVgxUp6RKfOeE0rlWRuWh4fT4KCHSg2k7BXv5QlPAY+K/2KQvq JsFnWs5jmd1ffZBmZhy2yDbQT+uaoU+Z8B5Uh2GUTbARPnNqiJzAWLMwd8Ffx1K6tEwe tJTJQwA08CIxWTCFf+WijcAtsBVCmTamRNekG2u/oXyoURg6g6eCKKGcy7y9NlN4Pvg/ obAg== X-Gm-Message-State: AOAM530KNDFEdHG+pZVeiuyirMRz3woivTVBCLBRROnDDC/m13vqTY+U UaPxNmRFt39/RQV7C/e9f8Y5tg== X-Google-Smtp-Source: ABdhPJzUdnArY7LUm+Nti3l1o/PEa4bBNpE6E6cm6T4db8FdE0WHvO5lbq7oqp2iucgX6qWRh5QGkA== X-Received: by 2002:a17:90b:3651:: with SMTP id nh17mr629350pjb.4.1591033910795; Mon, 01 Jun 2020 10:51:50 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:50 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 9/9] remoteproc: Properly handle firmware name when attaching Date: Mon, 1 Jun 2020 11:51:39 -0600 Message-Id: <20200601175139.22097-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org This patch prevents the firmware image name from being displayed when the remoteproc core is attaching to a remote processor. This is needed needed since there is no guarantee about the nature of the firmware image that is loaded by the external entity. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 18 ++++++++++++++++++ drivers/remoteproc/remoteproc_sysfs.c | 16 ++++++++++++++-- include/linux/remoteproc.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0e23284fbd25..a8adc712e7f6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1642,6 +1642,14 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->state = RPROC_OFFLINE; + /* + * The remote processor has been stopped and is now offline, which means + * that the next time it is brought back online the remoteproc core will + * be responsible to load its firmware. As such it is no longer + * autonomous. + */ + rproc->autonomous = false; + dev_info(dev, "stopped remote processor %s\n", rproc->name); return 0; @@ -2166,6 +2174,16 @@ int rproc_add(struct rproc *rproc) /* create debugfs entries */ rproc_create_debug_dir(rproc); + /* + * Remind ourselves the remote processor has been attached to rather + * than booted by the remoteproc core. This is important because the + * RPROC_DETACHED state will be lost as soon as the remote processor + * has been attached to. Used in firmware_show() and reset in + * rproc_stop(). + */ + if (rproc->state == RPROC_DETACHED) + rproc->autonomous = true; + /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) { ret = rproc_trigger_auto_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 8b462c501465..4ee158431f67 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -14,8 +14,20 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rproc *rproc = to_rproc(dev); - - return sprintf(buf, "%s\n", rproc->firmware); + const char *firmware = rproc->firmware; + + /* + * If the remote processor has been started by an external + * entity we have no idea of what image it is running. As such + * simply display a generic string rather then rproc->firmware. + * + * Here we rely on the autonomous flag because a remote processor + * may have been attached to and currently in a running state. + */ + if (rproc->autonomous) + firmware = "unknown"; + + return sprintf(buf, "%s\n", firmware); } /* Change firmware name via sysfs */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index bf6a310ba870..cf5e31556780 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -491,6 +491,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 + * @autonomous: true if an external entity has booted the remote processor * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc */ @@ -524,6 +525,7 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + bool autonomous; struct list_head dump_segments; int nb_vdev; u8 elf_class;