From patchwork Tue Jul 7 21:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650271 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 7E6026C1 for ; Tue, 7 Jul 2020 21:00:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 600402077D for ; Tue, 7 Jul 2020 21:00:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="skhoYdka" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729184AbgGGVAq (ORCPT ); Tue, 7 Jul 2020 17:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728995AbgGGVAS (ORCPT ); Tue, 7 Jul 2020 17:00:18 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE730C061755 for ; Tue, 7 Jul 2020 14:00:17 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id u5so18952516pfn.7 for ; Tue, 07 Jul 2020 14:00:17 -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=T4hkCqVCeOMZgcGJmCmeYT1tYbutzJigRMD38BY9+lY=; b=skhoYdkaprvrrYvb7cLlxtvHSZIP1JXvNY5H59zSulwBZznsxe5PwG8/tb0EdKgMXu R94Beq1AyHUthM/hUUGgdj0vn7WRz4eaX4yJI9s1/5YbSlJiwUE+a2QFdR9vpsUp9ux8 3Lbtf80MKp8IgIpbKsCnhLgJiX3gcjczj0XLmhxVFZPZJgMFVakumZg79o/Fr9i8bbxP j43R8pBYDaGi8I7Mt4IxOcJX2X5XdUAsHZNL1BocEAB5z8K92AuwJC9GKQg5iKCPELJA O3mET5jlADa1Ny58wEWUehDhyskXRwJfPf0fwq6kO5C4XjTzSSMfPrCecT6suDJ3hTcv aomg== 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=T4hkCqVCeOMZgcGJmCmeYT1tYbutzJigRMD38BY9+lY=; b=lx6FU9tVC+lXOcqpfi5IxLIKRJYPg8BturfOsE7g2ILOUOVPjRDW1mGXbBO6y7VnZg hgr8twBqJzc/wVnJtTIIyEEyuLIPNpVMGkFSi3aiWMN5fq6tG1s73cYh0mZC8wYogGgV h6Qhof4wWkSQFHB+114KZ+8QUrKa8HEnD2txFJL8xSyj2LFgbj1Hl0969sBG1A2v6LBb nMmEb/t0iw8d0NmpJEjngrbGZHnyQMgdQZTYLE319NRKvmAkEWaDEiagC5d2dd/CfrR0 UCVhBa438FjFe4j/PTXvqx7BcA3ieU8GSV9z4yFq/yQdzjaoC+9Biyw7bQZ1JCf7k1+5 BsSA== X-Gm-Message-State: AOAM532CfkmU4JDGiT6kMSPCYwzYzyx5B5f9hlcNGaneLZ5LrHKZUtJ7 +yoCPzYuTEslP/gRNXG5kCZ/IA== X-Google-Smtp-Source: ABdhPJxZWe4+LqvbhLX+FR1pDBbdohuGLXTvW36qakI87t3n/y2FTLbHFO0wsREYVkEZkji1GFPqHA== X-Received: by 2002:a63:5004:: with SMTP id e4mr24268596pgb.208.1594155617393; Tue, 07 Jul 2020 14:00:17 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:17 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/9] remoteproc: Add new RPROC_DETACHED state Date: Tue, 7 Jul 2020 15:00:06 -0600 Message-Id: <20200707210014.927691-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 52b871327b55..264759713934 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -72,6 +72,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 Tue Jul 7 21:00:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650263 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 764D66C1 for ; Tue, 7 Jul 2020 21:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B70B20738 for ; Tue, 7 Jul 2020 21:00:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="twl7enwz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729091AbgGGVAW (ORCPT ); Tue, 7 Jul 2020 17:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729035AbgGGVAT (ORCPT ); Tue, 7 Jul 2020 17:00:19 -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 EFCC4C08C5E1 for ; Tue, 7 Jul 2020 14:00:18 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id l63so20547620pge.12 for ; Tue, 07 Jul 2020 14:00:18 -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=vVtbty6MuR7LBEWWuCJGvwLM4FSBtYk/iYw5ZIvpQoA=; b=twl7enwz7kHhrli2x2cq44nDscH6dGKdCAgl9f+ftKAMLM3qCH1z3Cd8eOuMmTwjBD pP2E+bDWwrI1VG6K1dJDCAPGf2PTRGzevND10bKqX/rIiQgAGbV/ExAVlQbUneFWdMcM mVvi2mxwtD0jwI3Tgeoe2+mDoefxbmvlFWbxfTqLqwIjTRi/mMLLpcufIstRcg8dHY0F VAVHdSDpGp2fcaaGdLxw7AnGM826Joap5sqxNo4Jz+ymlCp3QmijmAzEWG6vOP6ySPHP PB1oBhPhi2idwpn1AUCtb6UTk/vIsUXlZJ4Lnd+mZ0R84767rUAN+MDwKRMvincktecT VXgw== 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=vVtbty6MuR7LBEWWuCJGvwLM4FSBtYk/iYw5ZIvpQoA=; b=gj/zzswlpadV1l5zqrCk4iYK+1SVUIC+zMMtrrsgpSEO0EJiglnLKAx2nUBws8t8by O5Ldk+Scpij1BSZm2boMIabR3Bf2sKtJEvHuLpO99ZS9YMQaLFjMJVXhAnfLczyCL41E xfbn97nl04q1490pVBxNvOutPOnyFWEhNKLUqXMf7GdbWZvs3yKtgwuccTuK9hcvPmKF 2tvHSC8sDOD5NDmJuI7mFHfMVoAl6hOi+D5/26dNYGlIVDiKws3/u7iSnFdZgkq/zFIZ yyJyp74YR/JfPlaZ50T9+JQy389sBJk/5dBc10O4vr+hOXKto4IVTaJ+oDxZgUewiaPN YPDA== X-Gm-Message-State: AOAM533zVaYNAWCpKFUKB1SSmyU5bgN16UpkfpJ+LfXXd89CYKok+hom ktUJik+fJ0QBgQA6gHhg2y/kLw== X-Google-Smtp-Source: ABdhPJzbouKkw8rF4UU8dz3+uRSIpdjSqdZ9zhLg/igFtFrkRfUKweAwArYZzWKyqlnramTwIw5Raw== X-Received: by 2002:a65:5c0b:: with SMTP id u11mr10831269pgr.191.1594155618453; Tue, 07 Jul 2020 14:00:18 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:17 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/9] remoteproc: Add new attach() remoteproc operation Date: Tue, 7 Jul 2020 15:00:07 -0600 Message-Id: <20200707210014.927691-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 Tue Jul 7 21:00:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650265 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 524AE912 for ; Tue, 7 Jul 2020 21:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A94B20720 for ; Tue, 7 Jul 2020 21:00:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TbzgUrB5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729169AbgGGVAj (ORCPT ); Tue, 7 Jul 2020 17:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729060AbgGGVAU (ORCPT ); Tue, 7 Jul 2020 17:00:20 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E52C08C5EE for ; Tue, 7 Jul 2020 14:00:20 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id s26so5316182pfm.4 for ; Tue, 07 Jul 2020 14:00:20 -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=8sunMcTKPjbwKYnp90hWVpCyt/CSv+OqCWNA2DkJ6sI=; b=TbzgUrB52hbA9DlVLlHssDCL2QTuR8WCTGThnOs340crCeecRBPiRb4ufKe5At31zv Aq/Ae59u4kPc5Qk6CpiF/Qnf5gxIhLiXyv0Bhx/Yl+4Zglqw2Nccn1+ahVuBhqh+DvqM aHGRq78w281CFaZlp+QHanziR+wpNDtCGIHTnOCsEZjwMFw9bA6Cfv+YsWZwRW8Npo+f X0RvVuCJ01zTuJsFDJX3LauIDsQvNneEXXaAo7nm/rySC+voQIG56ZrWgInT3bA3vKpY FpIUEQpa23PMh47qSyZLdh6Q1ycBs6kKw5ZH4Be64RktpHU5vi7WOL7xbxqW+PlefpWF eg8Q== 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=8sunMcTKPjbwKYnp90hWVpCyt/CSv+OqCWNA2DkJ6sI=; b=GGudrrzUXhgMNpPQYcjomkVKm/KXPAbZ4mj2GxroHxOf7/4QNNAaY+Mi1dh4JkF8i0 jzacJ+x4NZbcTZhikl+kg+HVNSW29gYerSwfCgBcaHxuGdxHJ7GA+WAcjf4DngjT9tvI Jhk19LRNOlPCN7YvrQJQhapUK3WNLYykiQHG87IgEB4VVgkL+44KC0CbCEpGjfMv7kXF tuKjeD+CWeXaQ3UTCsZ5ldtDy6jKzkr8AGRTfnzYRxNMiBr5O8k5HuOYiVPQqrg3moPx XlUGdt7ntnarFnIKc+Zv2D8dniJjEWa9xt9WWA7D0Dx/jtxG0wqoFCtDZrSatQgZmHfJ YqCw== X-Gm-Message-State: AOAM531GqHeJLsAaYCvqG5cgAxK7B6S91DcexB6XE0wumbQMY3V4IpZd GDGtQfG6NO3GwQJNqGKQV96d+w== X-Google-Smtp-Source: ABdhPJw61LXCLsLXInVQUJvjD/cN5Uk98EXyubcSOTC+zhbv3uPPfcI+pW2+zbUOVmlwPp+mgjYtdQ== X-Received: by 2002:a63:6e4c:: with SMTP id j73mr45200937pgc.182.1594155619584; Tue, 07 Jul 2020 14:00:19 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:19 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/9] remoteproc: Introducing function rproc_attach() Date: Tue, 7 Jul 2020 15:00:08 -0600 Message-Id: <20200707210014.927691-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 0f95e025ba03..1e8e66a25bd6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1369,6 +1369,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 Tue Jul 7 21:00:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650267 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 89E9E14DD for ; Tue, 7 Jul 2020 21:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71D8F207C4 for ; Tue, 7 Jul 2020 21:00:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lN1AXlS/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729085AbgGGVAj (ORCPT ); Tue, 7 Jul 2020 17:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729066AbgGGVAW (ORCPT ); Tue, 7 Jul 2020 17:00:22 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80025C08C5DC for ; Tue, 7 Jul 2020 14:00:21 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id l6so203889pjq.1 for ; Tue, 07 Jul 2020 14:00:21 -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=bbYQfIqqJHKaf/AV7EAC2w0cpklnSxGXHmoxxnSA3xU=; b=lN1AXlS/JrrmRLIUyBjSFMpogicBURNVWYkAD5P93UAG2F9rf1AxJymtSUchh7oWxT iqxH+BkLEx0VrvI4qNWwaxsxMdv3F3cuzh6BC5p44DHLA6CC7SYOwfCNYdJBsZ0gduya XsGgA/b+6VCC8IO+8qy+U6VZkpTa3j3uRK+iMjKRBnii3wfTsO3xSNxyRsyIeOfeqRyq kRvN1uE5Qe3jB8i4yVBYtiYw9f4dRwzaZQHIAh2AlhwlNBUSXyE871ddBmJZryJ9Kf09 fBsKmcy4HOyqjGeFhh8Y72NYm2HdUY6OxOFoQwEWXBGvl21P1qRhS13WUeuueM49eedv L5xQ== 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=bbYQfIqqJHKaf/AV7EAC2w0cpklnSxGXHmoxxnSA3xU=; b=j3hZLa59LwyohgeRRUAoY30meuJNlL8YKY5BZKKg8FjScZi4XKQ4R2ibMSeo/88N34 DI9i5ZytX35mubzZJllO9z/XUEWUFiOpVz/RzOe7gZbZjgAYU/qyHVVhtWjso5UF+HDT egsBVAGQVu1LWoDqeafJTBlPSC8thahWHsQta9nkvFlJFFm4JgFPqoenK15waEJi/OK+ 83amTQ8bQHACOYq8HcbvNV1xaNKmWykVSos/KFq6JGPEVdmNxzcJ8EJIxjD0lvyfgfTp mFr2Q9PyIEx17RE8MyANZPfQaKRkK2TbJQob89jqjdzfiDT7tQzUS+TPcLfOEUl2CM1h gmdg== X-Gm-Message-State: AOAM530tNsVDu3uWMgsHQ+FTlPapKOcqnCPbmOmuDQLbNd2K8YwJDEcI /yRup8btfti8vlYAqHEYQ/kJja4t+Ow= X-Google-Smtp-Source: ABdhPJx3gwwwBEIT3dAT4JNWdPHKUJjmF3AXMNSxjdrwseqMA4lcVlcA7m+UcqoYaQFRhySIv9nB7A== X-Received: by 2002:a17:902:bc82:: with SMTP id bb2mr45907161plb.225.1594155620894; Tue, 07 Jul 2020 14:00:20 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:20 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/9] remoteproc: Introducing function rproc_actuate() Date: Tue, 7 Jul 2020 15:00:09 -0600 Message-Id: <20200707210014.927691-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 59 +++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1e8e66a25bd6..fd424662801f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1369,7 +1369,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; @@ -1490,6 +1490,63 @@ 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; + + /* + * 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); + return ret; + } + + /* 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); + return ret; +} + /* * take a firmware and boot it up. * From patchwork Tue Jul 7 21:00:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650269 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 16D476C1 for ; Tue, 7 Jul 2020 21:00:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F29D320720 for ; Tue, 7 Jul 2020 21:00:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KcE3vFoT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729165AbgGGVAj (ORCPT ); Tue, 7 Jul 2020 17:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729085AbgGGVAW (ORCPT ); Tue, 7 Jul 2020 17:00:22 -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 7B4C3C08C5E2 for ; Tue, 7 Jul 2020 14:00:22 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id cv18so1274234pjb.1 for ; Tue, 07 Jul 2020 14:00:22 -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=yhwZoAnzEhcEEldBirUE6UrK8n9jKUX6Rf1BSaeDteo=; b=KcE3vFoT4T4iNFbrk0y+HXUo4W+ZWNwjP0L6IR1g1OHWcbBfSKtExSvzRZYS3b9yCd +U/XfEYHmwY3Gdx5dHrml5vLKHDhFOd8g+10Yn4geAlXH4Oikl/w00w2TOE9Vl/Yu+DE APPqq+khoADK1goM0ttFnFWGJnqmZ0j6DKxln0GPBmw3mxrhsWNfXVc8I+6GLLfY6WhP Wta0ZwM+6N0l1Bf0md/pB4/rkueBueq35yX1779AisASor7K2FfXUqO4OsT0P3+eLo9L I1TabNL9iN8DOoxqaAngggKZmUuwEpG9XJ5mpeFcdN9LyqoY7qPx03bWMexvRHw/LGso 2Gng== 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=yhwZoAnzEhcEEldBirUE6UrK8n9jKUX6Rf1BSaeDteo=; b=q+1vLliQIQvwqMmyhNOOTzhssWFGVnQDZSCBN40Tm80OynUNuOBkBdhVHyJwHChSdv cj4shKIgBDSFDAkb1GOPQYT8RCc/7NDDowUCOZ2tmN73OFNKO8ppdzw2cbFzNWrDVD2M 14M/tOEgeeFrdquDoJJ6bghJ8Timpts88myjPoveDuk+4+gZemtlwSjGZWbM3lFu2zew lteTOdTPbqBclfNDxLefwMV0HixV02RFpX/CM0msc0ZqEoetXyk/jUPaXFP+NpKkTLHN pliNV1/CL3zK3l4xtY2PSX+LQ9ADjnBq01BXnxHnscDDYhkFNcEDze9vXmt0tumeYtsx 4emA== X-Gm-Message-State: AOAM532dCARz71NatUzi8k6x/4uXQkJ1ZVb3ETxnTyUQj8g+CoTFubC1 C1ZvFtOrR7AoIQclsuEM+50Xxw== X-Google-Smtp-Source: ABdhPJy4QJpzH/XmBzCGNu1gC/yOn8c4Bhc6mE4Lxk0rOxnc2ADK41OsJWqAIBxQ5eb9a/DHJBs9YQ== X-Received: by 2002:a17:902:8f96:: with SMTP id z22mr10578737plo.189.1594155621998; Tue, 07 Jul 2020 14:00:21 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:21 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 5/9] remoteproc: Introducing function rproc_validate() Date: Tue, 7 Jul 2020 15:00:10 -0600 Message-Id: <20200707210014.927691-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fd424662801f..ad500c291d5f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2040,6 +2040,43 @@ struct rproc *rproc_get_by_phandle(phandle phandle) #endif EXPORT_SYMBOL(rproc_get_by_phandle); +static int rproc_validate(struct rproc *rproc) +{ + switch (rproc->state) { + case RPROC_OFFLINE: + /* + * An offline processor without a start() + * function makes no sense. + */ + if (!rproc->ops->start) + return -EINVAL; + break; + case RPROC_DETACHED: + /* + * A remote processor in a detached state without an + * attach() function makes not sense. + */ + if (!rproc->ops->attach) + return -EINVAL; + /* + * 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) + return -EINVAL; + break; + default: + /* + * When adding a remote processor, the state of the device + * can be offline or detached, nothing else. + */ + return -EINVAL; + } + + return 0; +} + /** * rproc_add() - register a remote processor * @rproc: the remote processor handle to register @@ -2069,6 +2106,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 Tue Jul 7 21:00:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650261 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 D3C046C1 for ; Tue, 7 Jul 2020 21:00:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B85E020738 for ; Tue, 7 Jul 2020 21:00:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rWfnaSFW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729125AbgGGVAY (ORCPT ); Tue, 7 Jul 2020 17:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729105AbgGGVAX (ORCPT ); Tue, 7 Jul 2020 17:00:23 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B19EC061755 for ; Tue, 7 Jul 2020 14:00:23 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id m9so8689545pfh.0 for ; Tue, 07 Jul 2020 14:00:23 -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=XijBbeKyE9SPoHBAdYK5pDnTOJyJsJjOSAGz5audssw=; b=rWfnaSFW15Xw5FIltXzrZKUeN0skrtFSZBNZlW/9z3uCkDSE+53LBP131GuN8DCtPX GbCUPrtRoD6+4w7HOp9aYs47bAZ6uSNITfmLhFQAYYgHDu6oj3+4eqTmAk7+ncSEqgzt EqfS5+Df5YWsXZdKXQbolUlbAzPBNQCkL8MMww1Kp031zVDjaWucDg88HsTDzkVqJCAJ ga5RxaaKnZ0p+CXalBPW3H5kw70E6e5EVkt00KwyiMNeuW0Qe0d/if7nFioS08kfhaI3 WhrX+d5uV39vUFTxlfuGeYGVI0eHEs5P1qsp3vF4NuWjlPN1lg2U6vYdB/rX82AM4qQX mnjg== 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=XijBbeKyE9SPoHBAdYK5pDnTOJyJsJjOSAGz5audssw=; b=n0GoLYr0fhZ5yWoI2hGwF8a16x5VtQpdOI+bAYuA185DvI7Lt9UZhyk2/cSnGk6xEl doBA4+DJpKmiEExubDKurn3C+7c6Q6ohoW1aQlSJrEojtG1JzE8FNWxHI5ALTiCPI8Lw PZO4YkYrHZVd/Uk2cTZaPEoyzMCQnaqGuIKrhNp3qQP6r8p6tWEQsbxhpLWWg5z/h1LF 8Ou5De+DU79XkpYNLekdmKLE5fZmpXU4Y21R86vcOqTjDfMEfSMcEgX0ZBT5EaRvTnKa StecRAtPuyhcACPfFusMT8dB6O9PtaMHP8JB56dRtWpeH3KDhz9PSVpEE1Y7o9i3Db9a hrBg== X-Gm-Message-State: AOAM532/wzGrItfuc5EYp2HRJBMMzgdTCrfdxOVsK/vxNLUwERNuygIo AQCgGUdOMABRBQ73r1nY7PBO9Q== X-Google-Smtp-Source: ABdhPJxJfD0Jkh9Hb2JlSArI9twloH94qq4vcsjeQsCvULj9K2kwwtdLJpL4yLB3oPqMKhQvxU5N9g== X-Received: by 2002:aa7:9542:: with SMTP id w2mr6424266pfq.273.1594155623009; Tue, 07 Jul 2020 14:00:23 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:22 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 6/9] remoteproc: Refactor function rproc_boot() Date: Tue, 7 Jul 2020 15:00:11 -0600 Message-Id: <20200707210014.927691-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 ad500c291d5f..caea920ce4b8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1494,7 +1494,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; @@ -1905,24 +1905,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 Tue Jul 7 21:00:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650257 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 0751214DD for ; Tue, 7 Jul 2020 21:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0A7D206DF for ; Tue, 7 Jul 2020 21:00:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rfwH0VTL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbgGGVAZ (ORCPT ); Tue, 7 Jul 2020 17:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729131AbgGGVAY (ORCPT ); Tue, 7 Jul 2020 17:00:24 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC4FC08C5DC for ; Tue, 7 Jul 2020 14:00:24 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id cv18so1274275pjb.1 for ; Tue, 07 Jul 2020 14:00:24 -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=CrxX2JXLk7By8ga9VEaC+Xcvsnm0j8J0IxBxTmssNDs=; b=rfwH0VTLYZZfpHV63Dp/budgpOZjMaArCYgIyCaK90zpogDbRX/NKHoTHw0sy5YN60 DFjJOVUToIIIc/YkLBBsqpnBndbKElEt48QyLTda1KebXoUs+LhGXgCwLo7U8yBe0zWD Hm694uFnVIloiphmI09ewyNmLzY2AinF0moVoiExT8PT9EiJmYT+jP3VeT4tAyWNI16V A3dUI74cEmrwGnoVw4Lsrx7d1AQTVAJPDF0v+7HRAEp6FnPC+tnxdZpGyt+eLevsAGoc CZcp+pd1DcKRF7HXRKGs85pv3qIGcosP4HzZlgR2sPefvZ1aUFF78I6wMjiFCnXdCJIi gGjA== 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=CrxX2JXLk7By8ga9VEaC+Xcvsnm0j8J0IxBxTmssNDs=; b=l1ve7tLFKnNrXxWd8vW183pHEiP6uMVe5Vsub8ACE6sfMAPeFt3UzJXxqrY1XadBpJ aWOASkBOIvWJvZ95xyZ08N99jwFNiXyCT6VW2tHnb7nmHk6q1ZkbxlZVfFeMlkyXxjx4 nA+R6ZRRNq8VPj7CYqsWm+lkfeZg6Sw+vw9uJ/gPmL0OJMRhI8mBTgRdH8XDi2YB+TA8 a36EBVNRUhtd70LSnFd+mrsHcn1lFJfHZm/rf5HO4eclxAwTgdganA0OSjejJjJd2US4 i+N87ZQgt4OA+eplaFU8/I/4h7xuCeimif22miSWymHVGtYdKsQJnoju69y20YIILu3a IOVg== X-Gm-Message-State: AOAM5312e0iSpH9h91pzlD8A8vluMyKqDjPoYV/CZ737fxc4estaXIPd +czdCO+RZmetu8JEWdHVtsbCw4zcCyM= X-Google-Smtp-Source: ABdhPJy8dzi5/s6IOEmk3N8qQim+4h4YyMIkZ4M6MXsZyYRtLO3ad6OL4I9cszxg5Gx2y6vLV9zjWw== X-Received: by 2002:a17:902:a515:: with SMTP id s21mr40003804plq.192.1594155624167; Tue, 07 Jul 2020 14:00:24 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:23 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 7/9] remoteproc: Refactor function rproc_trigger_auto_boot() Date: Tue, 7 Jul 2020 15:00:12 -0600 Message-Id: <20200707210014.927691-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 caea920ce4b8..08de81828e4e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1568,6 +1568,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 Tue Jul 7 21:00:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650255 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 C4E2C6C1 for ; Tue, 7 Jul 2020 21:00:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAE4C20720 for ; Tue, 7 Jul 2020 21:00:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="C3Plflf4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbgGGVAc (ORCPT ); Tue, 7 Jul 2020 17:00:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729135AbgGGVA0 (ORCPT ); Tue, 7 Jul 2020 17:00:26 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC12CC08C5DC for ; Tue, 7 Jul 2020 14:00:25 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id 72so6662106ple.0 for ; Tue, 07 Jul 2020 14:00:25 -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=We64aO7YKIIjo14efasxM75BhUGKiURq6Zfe9ioCNz0=; b=C3Plflf4zDY0SRUHIW3sw1Di9srXzaWxPO4Tc2Y/LTr2431t/fTOEm9ks48kIuVK+C 7Ivelw/NqewhMQMWEaQqTmBjSqNkjEN6yKQO+1PU0gsWHLZpg5N1H3QQHAr+6z9/CI/C hSBM52mLajXKVYqufiKodDv/WH4y7gg9BodQNQi7xiX2/YIC96kb9zRHis0cF0cHApGo r2EHcvQ56UKaWjrVgdyQ/2vCHWkOPI5wrCLNxFG2uHQ5DlaK8jTFUvsSnV65UfcGQ521 /6jVBdr71eF57laK7IvYFHAQKDhU04JGrP4+ZfKgeRDyXco1ikjcFqQT+XP6zGSdQDRd KGSw== 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=We64aO7YKIIjo14efasxM75BhUGKiURq6Zfe9ioCNz0=; b=S85LsRKHwb+9wKXBmMCNbniLwQfnAnUnIaeSLZPLKH3nvwa5bF2zn/0VUCOTfrY6ne M6XVPoDeED9zL88olzE1pDVSY5KhCXBz53SBscIeQx5yEE4Vwx/qNVpSg4t7pbm4Qkqk yGkA4rv/kkPChJL3e7wqTERAk3K/p/fccrBI74XWNrMtH7H7DPZoN0zXjZ1C2lIa2RLy IZIiQUhXjJ6mvyd/yPeTQxVLN4to7pkpqYBrFNcfIfc6BVijermQMBjNeDyMQEGzYj76 drrLp4k4vUn+1i48kFxIgOKiWhHp4N08AVK4jamZvP268h7KhPZiQvPbISXd1yk1WRh4 c1Pw== X-Gm-Message-State: AOAM532GirB7el4WLQ0ZurWVg5AlwsXhSgEpkhG0RU6Ae+vpcKG12YKw RqEE/0tMS1GCmgHyTei8s6wdHA== X-Google-Smtp-Source: ABdhPJx2r2QLPIBuk24dxnit7yFc7cgFfC9vpIJBZrrTPUVl5biKWDknt+CevhUIDfxQczPGKKAobQ== X-Received: by 2002:a17:902:7008:: with SMTP id y8mr14614952plk.85.1594155625491; Tue, 07 Jul 2020 14:00:25 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:25 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 8/9] remoteproc: Refactor function rproc_free_vring() Date: Tue, 7 Jul 2020 15:00:13 -0600 Message-Id: <20200707210014.927691-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 08de81828e4e..6b6e4ec8cf3a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -410,10 +410,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 Tue Jul 7 21:00:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11650253 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 C4F08912 for ; Tue, 7 Jul 2020 21:00:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A528D20720 for ; Tue, 7 Jul 2020 21:00:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wCtNGckK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729144AbgGGVA1 (ORCPT ); Tue, 7 Jul 2020 17:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729143AbgGGVA1 (ORCPT ); Tue, 7 Jul 2020 17:00:27 -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 065E4C08C5DC for ; Tue, 7 Jul 2020 14:00:27 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id e18so20564612pgn.7 for ; Tue, 07 Jul 2020 14:00:27 -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=DXihWIxuNvTRnDoqQ/WGQ+3cWsaukK63XK7MoneTKGE=; b=wCtNGckKVZFCFAuUdZsUw9mSFizW/062kFnHcpDSKKzrt9wS+WWMTqcBQpPV31HmQs CRGM3WKA+gCXwrspMDYMYoeeKfPU6sVhpycFx4Hk2EQ6aQ+fGEGqVNrFboBiPwH9C//S niLoEyMvn1HAvphxxck3y7z/VcDKLIr53k5uyjqVFSR174th6lKWNOnKDrSsAGuCIVHZ I8BNJB5hnS+WiI2pDNMMro3t9z467k2JiraNB+kceNkiYcfSSuaQeBA50zIhwgkzO7r5 Nb/3UN/zTKgEP5O2fdvellFQ/bTAxfQBd2VOH/SU27mBK13FCuXy1NPGJ10rYjt4o+/C AGHQ== 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=DXihWIxuNvTRnDoqQ/WGQ+3cWsaukK63XK7MoneTKGE=; b=NldKiwzUy+J9EC/wnCLw4KNQlBQKPH4D4qXbxHXjmyQeiE3dmnR0n6ofUnJDqpPC9z Xs6KqZ8FwyOVAEz8hLdbP8HLZpT9fAwWh5Koo4FIyiletpXTDLq/U7u3oZ3YiFOfciwd yRM/hNERZKIMczfug+a82uI3lJZ4tyguiTU7dOlFXm8XMsz7FQT+NHFOOatnyZbHAA14 kCcACXqdi8pJISZ77X2/S6IGOMMICfeaGdLdQpnvBm/0jed1OelXFY8m8a7i7uJDBGl1 Lrz178Uo9FNqxzuAiIqVJW45w9veYmJJ07uORLE3UelsvGgDhFO43nN0+CcSKUoq/jD8 j2Ug== X-Gm-Message-State: AOAM530aVBvbJVmm9osigiFMQJj6xucrWJswY0Tze2/1XN/14zSLZind XZcdk1sVCZM9u3lHPtfpXz7snW05pfY= X-Google-Smtp-Source: ABdhPJw8VONUyHkapEOJN8eJzw+l3h8xertsjk/QdIylkXYno8uLy5Snd1L7vKjOLDF4ip3FnrSBJg== X-Received: by 2002:a62:ea03:: with SMTP id t3mr50358791pfh.57.1594155626491; Tue, 07 Jul 2020 14:00:26 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b21sm13738061pfb.45.2020.07.07.14.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:00:26 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 9/9] remoteproc: Properly handle firmware name when attaching Date: Tue, 7 Jul 2020 15:00:14 -0600 Message-Id: <20200707210014.927691-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707210014.927691-1-mathieu.poirier@linaro.org> References: <20200707210014.927691-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 Reviewed-by: Arnaud Pouliquen --- 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 6b6e4ec8cf3a..099c76ab198f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1624,6 +1624,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; @@ -2142,6 +2150,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 264759713934..eea514cec50e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -15,8 +15,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;