From patchwork Fri Apr 24 20:01:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509013 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 CE70C81 for ; Fri, 24 Apr 2020 20:02:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2D072173E for ; Fri, 24 Apr 2020 20:02:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nt/55U5N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729335AbgDXUBk (ORCPT ); Fri, 24 Apr 2020 16:01:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729313AbgDXUBj (ORCPT ); Fri, 24 Apr 2020 16:01:39 -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 35EC4C09B04B for ; Fri, 24 Apr 2020 13:01:39 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id ay1so4142898plb.0 for ; Fri, 24 Apr 2020 13:01:39 -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=7WYYSWCoYertzlXmUk0igZ0mJKKLhDAn/b6CFJphVPg=; b=nt/55U5NI5dfKt9QvTQuHK0Y7/cYI4ooo/5w+CzvNdl9Z8saBzFkI/mr2tSG4RP3rQ pLWXLnh5BcW7YgVEE21CJeNsqmhb/8snQDpxuWsxxHqdm6fgDtTRK8VEanYY38SFcHLx +gcESSvV8mDPrpHO/B1S7ldXHkUrvHZtGRdRRw6qc8w0ynfU5T/DBhddEsHAOwfp6VAr O18fBTcY5nQOWanAv08pgL7f4s0TEs9nPch30CZ7MLNtqDCAvhv50psfcR2gkv+waNPM MCugBIa+HbthMXOflJQ1UX1if3A/VCIfOIWoFxtnQy8TvjPsuVNLDpO3YSACMMcKgsxE aDUA== 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=7WYYSWCoYertzlXmUk0igZ0mJKKLhDAn/b6CFJphVPg=; b=qQKa0Ku0hJbid7kmHfb3Fs3IqDLTRz7XPbQkPNntcsrygzWJHwQSJxCy1PE1tq6BvG yjEYVSkw2cFmTc+h2CSM9SsOY6cipuoUCVHZzXP2cGZu6QHdZvudujj3H4zoMKW7sxqI xhzk8/ZSTI541JDtpq2zQiXOe2zTN4D37c2hvoE7DR6v/y0+mN3UZ5G/c+qWWoY/Ik3l l/vrV7bkzCHbCgzKFyMC+5KICz3OYzXYiMtn93Ly8tW4c/tq2UlyWteeJhHgvh2y1JUY ln03gkGjhA86rbCwYr/Qa+pogM9PoXNvYfLHLDgieGdO9utozj+X0CHcNQR0/nclv2Ux XoLA== X-Gm-Message-State: AGi0PuZ1Nth4N1PYMbJPvvIat1wf9lse2oKUxTDcE8HYEOMUV6AnSoAD gAJ4En6q0QVRyQGLzN9g6csJrg== X-Google-Smtp-Source: APiQypIYhJnlilq+7BARS7IBMXCokCWqUiSZO2Lahmi5Xxyd4HmRHz5pBYNr1rXum+k7aGV77bK9Ww== X-Received: by 2002:a17:90a:498a:: with SMTP id d10mr8507309pjh.194.1587758498612; Fri, 24 Apr 2020 13:01:38 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:38 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 01/14] remoteproc: Make core operations optional Date: Fri, 24 Apr 2020 14:01:22 -0600 Message-Id: <20200424200135.28825-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 synchronizing with a remote processor, it is entirely possible that the remoteproc core is not the life cycle manager. In such a case core operations don't exist and should not be called. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_internal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index b389dc79da81..59fc871743c7 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -67,7 +67,7 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->sanity_check) + if (rproc->ops && rproc->ops->sanity_check) return rproc->ops->sanity_check(rproc, fw); return 0; @@ -76,7 +76,7 @@ int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) static inline u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->get_boot_addr) + if (rproc->ops && rproc->ops->get_boot_addr) return rproc->ops->get_boot_addr(rproc, fw); return 0; @@ -85,7 +85,7 @@ u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) static inline int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->load) + if (rproc->ops && rproc->ops->load) return rproc->ops->load(rproc, fw); return -EINVAL; @@ -93,7 +93,7 @@ int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->parse_fw) + if (rproc->ops && rproc->ops->parse_fw) return rproc->ops->parse_fw(rproc, fw); return 0; @@ -103,7 +103,7 @@ static inline int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, int avail) { - if (rproc->ops->handle_rsc) + if (rproc->ops && rproc->ops->handle_rsc) return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, avail); @@ -114,7 +114,7 @@ static inline struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->find_loaded_rsc_table) + if (rproc->ops && rproc->ops->find_loaded_rsc_table) return rproc->ops->find_loaded_rsc_table(rproc, fw); return NULL; From patchwork Fri Apr 24 20:01:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509011 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 2A01F81 for ; Fri, 24 Apr 2020 20:02:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F04B218AC for ; Fri, 24 Apr 2020 20:02:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hTGfqd8y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729389AbgDXUBl (ORCPT ); Fri, 24 Apr 2020 16:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbgDXUBk (ORCPT ); Fri, 24 Apr 2020 16:01:40 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D72C09B048 for ; Fri, 24 Apr 2020 13:01:40 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id p25so5297213pfn.11 for ; Fri, 24 Apr 2020 13:01:40 -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=waQEaUAc8T/vBKYd/zXfwKYFWqlxffUg008FrjfIrmw=; b=hTGfqd8yUCMrEdbo4rCuRrcxrgEuIVxsi1FKpsn5N9UVWk0yhp8NSaQUCiTweALuTl nSsjV+VSYO34bwnqqtZVCDRTL1kN6AZ/b2OmfeMgy13IG8dHrg7cgyE0a88sR1mMoywU Rkf3TXu2y2l9NgvP5jlyQRXcTjLLdpsEGmp1spmaHKWht3WF+oaFfxr3NDvCABivdKDw wB2B7y6DKbqoOoevPhDD9+sWs4AZr1deXLnLmUWvvifSKPwfsyjQzN6g+o7qN40U9k2B v3Y5xi26tYT2O3tApbY+hsoralVI34cTrxMeJYG4pyYpMPor+ewEgJO3BMWx9UE9r7DU xJzw== 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=waQEaUAc8T/vBKYd/zXfwKYFWqlxffUg008FrjfIrmw=; b=D/XGrFvt0F2Zsal1l0JJNsjdim7M5f0VGKUDZmogebj2SSakzj+pL5qv+DbP2TXsfh RyCKIaYDN4nVEPMlpBD5vETUP6PgFKiyZgCDown7XvxRceRNttPgcckqY1FH89yhazEN 6Flz9CI1HldLTbicsu3pUdSp/qgIaX1kwwD1Oq1Jejh8mn5Ih3GTYe2BWz9VotnF24+K 2hQJEeIsj4SSjgac4zheL2G+Pkae+YIQwARKk0GC8/T2qCxSRLyjI0vQWPEPW6Vczyb8 kYdzj1Hy4smfufCBF4d6q/x9N3IQu1hNV8N35V/EAyMRwm6GrseDu8dQWOagkuOYVHzz 8Q6Q== X-Gm-Message-State: AGi0PuYk+D/RY+81ENEtLgLgpV1mOv+N2JRvgXqRTGKa5exypSLVaBSo EXkE+U/8+UTmMrZ8CaTMtFhDHw== X-Google-Smtp-Source: APiQypJXz4J3bpJOYburAtZcTnIr5jdsIwknm2zBGZGBjDvTEnEyq+jyTMnkG66K+fPMs/ob8wx0mA== X-Received: by 2002:a63:6285:: with SMTP id w127mr3451248pgb.449.1587758500035; Fri, 24 Apr 2020 13:01:40 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:39 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/14] remoteproc: Introduce function rproc_alloc_internals() Date: Fri, 24 Apr 2020 14:01:23 -0600 Message-Id: <20200424200135.28825-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 In scenarios where the remote processor's lifecycle is entirely managed by another entity there is no point in allocating memory for a firmware name since it will never be used. The same goes for a core set of operations. As such introduce function rproc_alloc_internals() to decide if the allocation of a firmware name and the core operations need to be done. That way rproc_alloc() can be kept as clean as possible. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 31 +++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 448262470fc7..1b4756909584 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2076,6 +2076,30 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops) return 0; } +static int rproc_alloc_internals(struct rproc *rproc, + const struct rproc_ops *ops, + const char *name, const char *firmware) +{ + int ret; + + /* + * In scenarios where the remote processor's lifecycle is entirely + * managed by another entity there is no point in carrying a set + * of operations that will never be used. + * + * And since no firmware will ever be loaded, there is no point in + * allocating memory for it either. + */ + if (!ops) + return 0; + + ret = rproc_alloc_firmware(rproc, name, firmware); + if (ret) + return ret; + + return rproc_alloc_ops(rproc, ops); +} + /** * rproc_alloc() - allocate a remote processor handle * @dev: the underlying device @@ -2105,7 +2129,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, { struct rproc *rproc; - if (!dev || !name || !ops) + if (!dev || !name) return NULL; rproc = kzalloc(sizeof(struct rproc) + len, GFP_KERNEL); @@ -2128,10 +2152,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, if (!rproc->name) goto put_device; - if (rproc_alloc_firmware(rproc, name, firmware)) - goto put_device; - - if (rproc_alloc_ops(rproc, ops)) + if (rproc_alloc_internals(rproc, ops, name, firmware)) goto put_device; /* Assign a unique device index and name */ From patchwork Fri Apr 24 20:01:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11508987 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 4619192A for ; Fri, 24 Apr 2020 20:01:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D84A20857 for ; Fri, 24 Apr 2020 20:01:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="eSxZwEFf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729412AbgDXUBn (ORCPT ); Fri, 24 Apr 2020 16:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729397AbgDXUBl (ORCPT ); Fri, 24 Apr 2020 16:01:41 -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 C9950C09B049 for ; Fri, 24 Apr 2020 13:01:41 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t40so4307139pjb.3 for ; Fri, 24 Apr 2020 13:01:41 -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=DSQAs1pyeXSdHFfEklHiIPoOPEI9zHd+d7BuRSs6Od0=; b=eSxZwEFfKnuIM0S/KHiUNpAB3J8WWlQRENNwDJ3lqJc/7J33wR1YPhhk53Pp6qnaxE /v2zf/xJXZIfyukH+kyvCiHWsu7QqW9DLaWPrizPuEeKbWJsm4MyMEikpEeOTUC/N8ze ChYX37s65pO9fY/CiXSTPAPGy7qPgIv+Gravd8fWDxZ9NnbRetZF0zdQdoZ3aL18D7SQ yq9uYf0q4upNgi6GQziPpQ7BL34H2YIvrdxKcMP8lzKv1M1IQ+2gGPxhK7pAzXFxv8Om UGtzjl0KknzzrE2wNmg55XjvePichK/mfGiVNygI0me1yuTh47CJkbldpxLTDkZfV8Dw sjBA== 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=DSQAs1pyeXSdHFfEklHiIPoOPEI9zHd+d7BuRSs6Od0=; b=mVmRrPalY+WFAXFEMLtHNAWRStJeceXsvRJYO7hkN5XoX//Oo5v4z/LhipZVZXsTeo Dn9azdqYPGzjaTyMbC7L9wivLX8H8NKvxJPLbINknmiuEWY5rPZ4T0hEdMomu96ZLv2e risKK0h9s0ph2DiAfcjYPbdyf0gnqrkeLRXextcBAiSaOJSl+5RQqARC+WRiREaQCHPO G8n2BeoLDR7R39QrsbM5oiKRLPbIXBApyP0+Qq3ohdFtCr3ZuU2iyWVdeeVB+t0ggY/+ kWk6UvPO3r4Z+4WHDoc5yotXlXYI+3vFIM2FlKFd7MqnWQxH0ii+98KJwMCR0WLVbqMX gb+w== X-Gm-Message-State: AGi0PubUYRbeK/oZu8dSXJZdVt+wQU8w48ikimsbnxtz+VP/eXlWRY1G DKh4MvZFECK9Zxry8QZsz8yccw== X-Google-Smtp-Source: APiQypKc2PEovjUbAPLQNBF63e7xg2Xir211PVAlvWUrPr2CEuv5H4vtH+D1u1ORnTvWTNYECb8U8Q== X-Received: by 2002:a17:90a:d14d:: with SMTP id t13mr8196049pjw.175.1587758501177; Fri, 24 Apr 2020 13:01:41 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:40 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/14] remoteproc: Add new operation and flags for synchronistation Date: Fri, 24 Apr 2020 14:01:24 -0600 Message-Id: <20200424200135.28825-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 sync_ops to support use cases where the remoteproc core is synchronising with the remote processor. Exactly when to use the synchronisation operations is directed by the flags in structure rproc_sync_flags. Signed-off-by: Mathieu Poirier --- include/linux/remoteproc.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ac4082f12e8b..ceb3b2bba824 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -353,6 +353,23 @@ enum rsc_handling_status { RSC_IGNORED = 1, }; +/** + * struct rproc_sync_flags - platform specific flags indicating which + * rproc_ops to use at specific times during + * the rproc lifecycle. + * @on_init: true if synchronising with the remote processor at + * initialisation time + * @after_stop: true if synchronising with the remote processor after it was + * stopped from the cmmand line + * @after_crash: true if synchronising with the remote processor after + * it has crashed + */ +struct rproc_sync_flags { + bool on_init; + bool after_stop; + bool after_crash; +}; + /** * struct rproc_ops - platform-specific device handlers * @start: power on the device and boot it @@ -459,6 +476,9 @@ struct rproc_dump_segment { * @firmware: name of firmware file to be loaded * @priv: private data which belongs to the platform-specific rproc module * @ops: platform-specific start/stop rproc handlers + * @sync_ops: platform-specific start/stop rproc handlers when + * synchronising with a remote processor. + * @sync_flags: Determine the rproc_ops to choose in specific states. * @dev: virtual device for refcounting and common remoteproc behavior * @power: refcount of users who need this rproc powered up * @state: state of the device @@ -482,6 +502,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 + * @sync_with_rproc: true if currently synchronising with the rproc * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc */ @@ -492,6 +513,8 @@ struct rproc { const char *firmware; void *priv; struct rproc_ops *ops; + struct rproc_ops *sync_ops; + struct rproc_sync_flags sync_flags; struct device dev; atomic_t power; unsigned int state; @@ -515,6 +538,7 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + bool sync_with_rproc; struct list_head dump_segments; int nb_vdev; u8 elf_class; From patchwork Fri Apr 24 20:01:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11508989 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 9FAF992A for ; Fri, 24 Apr 2020 20:01:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88674214AF for ; Fri, 24 Apr 2020 20:01:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OEce7CVY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729426AbgDXUBq (ORCPT ); Fri, 24 Apr 2020 16:01:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729417AbgDXUBn (ORCPT ); Fri, 24 Apr 2020 16:01:43 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1946BC09B048 for ; Fri, 24 Apr 2020 13:01:43 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o15so5135662pgi.1 for ; Fri, 24 Apr 2020 13:01: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=thvt7ABu2oknElk6aMlYpSKsdaIxDnUq/lm1lGmYKAw=; b=OEce7CVYAQrD+2/fCQ7jAAUkpy1uaYWusDID0du7fpICLUzFqnf6/1vU0bUtxkf6vw aNOjg8KrkImP9oAqyhCCte3mkPwmu7Ykwimj3EuqY0HjMsKjw5kbjLt1SbiMWGDm7qQ7 US0tREGO3J5hUBiThXe/u8ffLLhBOB+lKPFkClNBWVftYk4Pu6TpAc4WzPmS+2UkGU4K 7fHt/V27b33sABBBZvhD+1nwXCDUvbIOIiSHakEwhIdNQiMGNW9NzBWy9OH3UP0hHrJM mpvXwr4yua+xFlFktoRHVNwY5rCQaiipj1NZx4rX/kBQ4st6hj6pm78MK1ZZZZf1Sit3 EXAg== 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=thvt7ABu2oknElk6aMlYpSKsdaIxDnUq/lm1lGmYKAw=; b=XbrnNLIj/HZ8RAoIZO3J+V5Xs4NdphPGhmNG9WPh28ywfpV4ffIWuoGqWktgAbTXxA Hcqn2PnmvREWPTJaxyeU7PUXde17IN5xLYuIkze1eQ2CPweCCV3tTKVMGKFdBkKqb7xE vQpc0K8o8y4NeGTrro1aFEyFpr8wU2ClOIXqdTkXk91fKTy7zdw02dvhvDxEBgvoernT nvo/41429RbHIjwCnCWRgRnkP25Kflm0IXTZ44xhRZT1w3rXig5hOb5GfPPAI1pjtWen +ObmWihgMfyP3dPatRLul6PcCt2vMHqOax8ef63hFGyEhJkka6Oc1eKWFdnRUwLEuvhH vI1A== X-Gm-Message-State: AGi0PuZdkGyGPGElHKffq+IR+IdQ33XeMgmDRxk/XDrF1aOhV1rmc3Uv Wj9r3Qr0gSJ5D6+zQ9vjx63sIA== X-Google-Smtp-Source: APiQypK7A3kQi4xZwp9Up10ceDilox6vD3IgS1MUQXhRxkQuczYicJnzio3ayo8mu7gV6CdUXZe2bg== X-Received: by 2002:a62:5ec7:: with SMTP id s190mr11118517pfb.130.1587758502506; Fri, 24 Apr 2020 13:01:42 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:41 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/14] remoteproc: Refactor function rproc_boot() Date: Fri, 24 Apr 2020 14:01:25 -0600 Message-Id: <20200424200135.28825-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 Refactoring function rproc_boot() in order to properly handle cases where the core needs to synchronise with a remote processor rather than booting it. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 25 ++++++++++++++++-------- drivers/remoteproc/remoteproc_internal.h | 5 +++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1b4756909584..a02593b75bec 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1762,7 +1762,9 @@ static void rproc_crash_handler_work(struct work_struct *work) * rproc_boot() - boot a remote processor * @rproc: handle of a remote processor * - * Boot a remote processor (i.e. load its firmware, power it on, ...). + * Boot or synchronise with a remote processor. In the former case the + * firmware is loaded and the remote processor powered on, in the latter + * those steps are simply skipped. * * If the remote processor is already powered on, this function immediately * returns (successfully). @@ -1771,8 +1773,9 @@ static void rproc_crash_handler_work(struct work_struct *work) */ int rproc_boot(struct rproc *rproc) { - const struct firmware *firmware_p; + const struct firmware *firmware_p = NULL; struct device *dev; + bool syncing; int ret; if (!rproc) { @@ -1788,6 +1791,8 @@ int rproc_boot(struct rproc *rproc) return ret; } + syncing = rproc_needs_syncing(rproc); + if (rproc->state == RPROC_DELETED) { ret = -ENODEV; dev_err(dev, "can't boot deleted rproc %s\n", rproc->name); @@ -1800,13 +1805,17 @@ int rproc_boot(struct rproc *rproc) goto unlock_mutex; } - dev_info(dev, "powering up %s\n", rproc->name); + dev_info(dev, "%s %s\n", + !syncing ? "powering up" : "syncing with", 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; + + /* load firmware if not syncing with remote processor */ + if (!syncing) { + 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_fw_boot(rproc, firmware_p); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 59fc871743c7..47b500e40dd9 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -64,6 +64,11 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, struct rproc_mem_entry * rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); +static inline bool rproc_needs_syncing(struct rproc *rproc) +{ + return rproc->sync_with_rproc; +} + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { From patchwork Fri Apr 24 20:01:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509005 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 58B5292A for ; Fri, 24 Apr 2020 20:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41D452166E for ; Fri, 24 Apr 2020 20:02:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RvBfnECV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729447AbgDXUBr (ORCPT ); Fri, 24 Apr 2020 16:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729359AbgDXUBp (ORCPT ); Fri, 24 Apr 2020 16:01:45 -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 8BD6EC09B04C for ; Fri, 24 Apr 2020 13:01:44 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id h12so2929634pjz.1 for ; Fri, 24 Apr 2020 13:01: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=I3pq49DfqQ/ckFGrpIA0ri6MxM3SY7oSpR206BKLReM=; b=RvBfnECVGRBFpGe7Ml1Sb2DYgUm31X/1Kjs0QSoP53VSoyWHlDvTjMyAdwfQtgb1oB SIP7ucvumIlGe4Y8w4/v3uT0T+RmsjazOXm8eGhHN0k6RqG4V9Y12YJh1rMYAFjZOaOr yEoXM9t068vePXtUfnFdQnYlomkH4HvyckiRCRWDdT4ZebgMerXokHQM+EIKuDannvo/ tlo7GCM6f+jdWZySjce0E3R/1+8QLDtDhMg3mPNo514RtgaxIFzjcr1hRSONYkAfQEky 0UGT8WfuhaoNOwKAWAt09wqGaKCpSc/TlJl8uI+7x608sAA2ZrhtlF3AajBQyyWTWSpv HQWw== 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=I3pq49DfqQ/ckFGrpIA0ri6MxM3SY7oSpR206BKLReM=; b=lmgUywk5Kbwlqv8LHdqQAs4QoE6WORTb0cZ2wtnPf1cRUJs3LmDykLMeypyTcwre56 SzajR7dX4c4dwpMdzCjVig/e+MEi37vBqO2xelpQt4KLszoECamlsQStKGbti2UIsUKr 6IjEINYDahJj4TxG6VLIJFvpOaNVKTJIPm9fBX/MryiZ35btYVzB30xYPhgnbYIaDgPW x1UHOOd/HvNoKR5B+4GKg4mrOfVcwNlLr0sswFTzSSMUwQDiZy4qPZQ+Kdtcu51CT0bt 8UMXw20OVSKVzj5uVK6Pg83BsYXzkWH04TPfz2+jS79Uj/muSa5f5uokslV3+DqfZEbR RkuA== X-Gm-Message-State: AGi0PuajxMY51XCE38QUM16TR49O4luWCX/qKaqsDxJAyWnWS2GKsUCM DvEsSRSRBWjCwB0/Ep/eP9a3UA== X-Google-Smtp-Source: APiQypI4vcIlb92FluKaP2+RUFEleVp9k5T2KYJQcvG3Ppxjwx90KAeEDkP8AdnSbiXOHlPI5IJZBA== X-Received: by 2002:a17:90a:d3cc:: with SMTP id d12mr8187396pjw.158.1587758503926; Fri, 24 Apr 2020 13:01:43 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:43 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/14] remoteproc: Refactor function rproc_fw_boot() Date: Fri, 24 Apr 2020 14:01:26 -0600 Message-Id: <20200424200135.28825-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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_fw_boot() in order to better reflect the work that is done when supporting scenarios where the remoteproc core is synchronising with a remote processor. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a02593b75bec..e90a21de9de1 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1370,9 +1370,9 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) } /* - * take a firmware and boot a remote processor with it. + * boot or synchronise with a remote processor. */ -static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) +static int rproc_actuate_device(struct rproc *rproc, const struct firmware *fw) { struct device *dev = &rproc->dev; const char *name = rproc->firmware; @@ -1382,7 +1382,9 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) if (ret) return ret; - dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size); + if (!rproc_needs_syncing(rproc)) + dev_info(dev, "Booting fw image %s, size %zd\n", + name, fw->size); /* * if enabling an IOMMU isn't relevant for this rproc, this is @@ -1818,7 +1820,7 @@ int rproc_boot(struct rproc *rproc) } } - ret = rproc_fw_boot(rproc, firmware_p); + ret = rproc_actuate_device(rproc, firmware_p); release_firmware(firmware_p); From patchwork Fri Apr 24 20:01:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509009 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 4216C81 for ; Fri, 24 Apr 2020 20:02:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A26121D80 for ; Fri, 24 Apr 2020 20:02:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="h89uziQx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729460AbgDXUC3 (ORCPT ); Fri, 24 Apr 2020 16:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729437AbgDXUBr (ORCPT ); Fri, 24 Apr 2020 16:01:47 -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 EDC73C09B04F for ; Fri, 24 Apr 2020 13:01:45 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id t9so4311802pjw.0 for ; Fri, 24 Apr 2020 13:01: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=UgVYOEmLZR8T9VFdpsNRc2Uupq9jBoUolgKHoUHryRE=; b=h89uziQxnhqYDcmCgJtLSGdwCmHn0rC3Bu6mCDpOZ1qvYGWQlY3Z/6z+q6XrQXUluw nBTa+n77E8ofbTHybs+f9luqWuEGK2sawnmbePJGXfy0Oc0mXGNd4b8etpYU09LVnKpa MTlPo9c+GaghCNR8InPWnE9jvvacc0i224AGTD5P+PxgUr1eaHcNoYS4mSvrOgKyMmAl 3na+xIhktKRyb3SSIQVjk1ypUZxjl0/3pGUtbgGKS8NWqEW0twKZzV1lRfw2OuRBYGZq +moyE4C56HRvW/psOtJRhtJCti2DhCRmKO8k55+XHzf0FvEMYgBsdZDUX0eV3AxvaRPz N7Ag== 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=UgVYOEmLZR8T9VFdpsNRc2Uupq9jBoUolgKHoUHryRE=; b=NgryutxHLcONd3r0p+dmmoeXdu+ZswwfLfzYa3yFa3lDjvTrma3HNznBEWHBjcINA/ 8utdKW3/btVf/eNNFv2h2I31eiDErl1vtzvSN9sVutFwXQjeHBfB4vcOI2GelzztF+Tp uQ8ZJqIrnVpgT5cWQK35239oXsDP3S/YHKa7evSwe+Nf575ub5LQLuw3bezEqj17jFBh XW56OAiAMHRz2lQKT6I3BeCF2McTW0QBxFpwSl6gFcIb5WaayBfXscgt7R8p1ATPD400 8YBIA4HzBh2FVPcPPhk+waujb8TAIksnannHqTjIwj9PoHP1hboSqxN74eryQ4ANptEA w+lQ== X-Gm-Message-State: AGi0PuZbVgGCPHb52CAB+WQhQNezp5wy8x8XHHARF2gznrU/RrsRi3A8 0SOWmvW3hBTqId3pQpWpJjq2fg== X-Google-Smtp-Source: APiQypJ83gbDmQF4KfzVXB98/GgtBjTuNiayG+21Qtkv8hHGZIq9fXWsjiw9IoOg1wXRMARx3iDpOw== X-Received: by 2002:a17:90a:e608:: with SMTP id j8mr8415911pjy.44.1587758505366; Fri, 24 Apr 2020 13:01:45 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:44 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/14] remoteproc: Refactor function rproc_trigger_auto_boot() Date: Fri, 24 Apr 2020 14:01:27 -0600 Message-Id: <20200424200135.28825-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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() so that it can deal with scenarios where the remote processor is already running. As such give it a new name to better represent the capabilities and add a call to rproc_boot() if instructed by the platform code to synchronise with the remote processor rather than boot it from scratch. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e90a21de9de1..9de0e2b7ca2b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1457,10 +1457,17 @@ static void rproc_auto_boot_callback(const struct firmware *fw, void *context) release_firmware(fw); } -static int rproc_trigger_auto_boot(struct rproc *rproc) +static int rproc_trigger_auto_initiate(struct rproc *rproc) { int ret; + /* + * If the remote processor is already booted, all we need to do is + * synchronise it it. No point in dealing with a firmware image. + */ + if (rproc_needs_syncing(rproc)) + return rproc_boot(rproc); + /* * We're initiating an asynchronous firmware loading, so we can * be built-in kernel code, without hanging the boot process. @@ -1971,9 +1978,12 @@ int rproc_add(struct rproc *rproc) /* create debugfs entries */ rproc_create_debug_dir(rproc); - /* if rproc is marked always-on, request it to boot */ + /* + * If the auto boot flag is set, request to boot the remote + * processor or synchronise with it. + */ if (rproc->auto_boot) { - ret = rproc_trigger_auto_boot(rproc); + ret = rproc_trigger_auto_initiate(rproc); if (ret < 0) return ret; } From patchwork Fri Apr 24 20:01:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509007 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 6807081 for ; Fri, 24 Apr 2020 20:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50BC72166E for ; Fri, 24 Apr 2020 20:02:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="d7r4l7Na" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729444AbgDXUC3 (ORCPT ); Fri, 24 Apr 2020 16:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729434AbgDXUBr (ORCPT ); Fri, 24 Apr 2020 16:01:47 -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 17A82C09B04A for ; Fri, 24 Apr 2020 13:01:47 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id 7so4949292pjo.0 for ; Fri, 24 Apr 2020 13:01: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=FBdqDq0VMaj7zwangCHWNwKrKJkwsKj44UAlSOD4+hI=; b=d7r4l7Na8FJeJ/BgUKfyHxZF4kOAr524AMcWcrx7Wl+nAP2MT1cVwKm/K0x9jC+E9V wjGCifTbwvuY97Xaq96AhpZHGRgLSPU3cdsjiiqXcQ7aW/+RmZcf82B+NWqq25RYCYDH EkbZxXecCLTk5//7lSBZE5YfxTyslPWOt3vMrME4zrLiOeJ1eeuFoHg0YEGdi7d0ImDy VNNmm0xrZIv5JnoW0JgPK4uHDhhlOqdaciDoHtcwPTvR3w8NQMWPAEdRVNuSkIOxGc76 O7g7EYBKtLjvfVeEw1Z42FjkUEqCMV+Kr1HT65HBvr86KoVlBJ+v713FQhFQq2UTZdSA NSyg== 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=FBdqDq0VMaj7zwangCHWNwKrKJkwsKj44UAlSOD4+hI=; b=eAt2tbT+IyYEcbWwORqTQbprfqQb4dmzj2anjddbxLNQierh89zCjA97SH8M4aq11B nn8fkqnIiebZhj3EVEA7GrxUjHXeW7JYuGlgYElqgkRvkRg0e7X4T2/fAnLw+nAqZVG3 oYmixbs6heHEwujdThKf15lPA5HFT6Qtz3oCAYb68x8xpOsyfrCiElYqcWxg20Q+B8sz 4InRGeHSUEV6sksnfHXPKztJSF3owiJi5+3bPo5OeR/iNryaIY80UWhyndUrlPrjt0e+ bVtQCF1+lUn6+yRuPDZGtfiNYJZhJUdrDgBOcTbG7UIYKqbXVcRByXwRe8DsDL9HMnCa UXaA== X-Gm-Message-State: AGi0Puaxauxu54BS8cw1zoetHYiKJnOq8r10n1FgieBlSPXGKfB/zr3w E8oFioULW/MceGmqpR3EiUL4bg== X-Google-Smtp-Source: APiQypLgAeie2x7ivDbbviyB5xQucMuPuY1GziJxdG1upZHceYt6LjmgNtHV4dxErjTY9cA3zY8Rdg== X-Received: by 2002:a17:90a:a591:: with SMTP id b17mr8308969pjq.90.1587758506525; Fri, 24 Apr 2020 13:01:46 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:46 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/14] remoteproc: Introducting new start and stop functions Date: Fri, 24 Apr 2020 14:01:28 -0600 Message-Id: <20200424200135.28825-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 new functions to replace direct calling of rproc->ops->start() and rproc->ops->stop(). That way different behaviour can be played out when booting a remote processor or synchronising with it. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 6 +++--- drivers/remoteproc/remoteproc_internal.h | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9de0e2b7ca2b..ef88d3e84bfb 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1339,7 +1339,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) } /* power up the remote processor */ - ret = rproc->ops->start(rproc); + ret = rproc_start_device(rproc); if (ret) { dev_err(dev, "can't start rproc %s: %d\n", rproc->name, ret); goto unprepare_subdevices; @@ -1360,7 +1360,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return 0; stop_rproc: - rproc->ops->stop(rproc); + rproc_stop_device(rproc); unprepare_subdevices: rproc_unprepare_subdevices(rproc); reset_table_ptr: @@ -1493,7 +1493,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->table_ptr = rproc->cached_table; /* power off the remote processor */ - ret = rproc->ops->stop(rproc); + ret = rproc_stop_device(rproc); if (ret) { dev_err(dev, "can't stop rproc: %d\n", ret); return ret; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 47b500e40dd9..dda7044c4b3e 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -125,6 +125,22 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, return NULL; } +static inline int rproc_start_device(struct rproc *rproc) +{ + if (rproc->ops && rproc->ops->start) + return rproc->ops->start(rproc); + + return 0; +} + +static inline int rproc_stop_device(struct rproc *rproc) +{ + if (rproc->ops && rproc->ops->stop) + return rproc->ops->stop(rproc); + + return 0; +} + static inline bool rproc_u64_fit_in_size_t(u64 val) { From patchwork Fri Apr 24 20:01:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509003 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 E9E9E81 for ; Fri, 24 Apr 2020 20:02:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDA782166E for ; Fri, 24 Apr 2020 20:02:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="r/j9BvpK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729463AbgDXUBt (ORCPT ); Fri, 24 Apr 2020 16:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729359AbgDXUBs (ORCPT ); Fri, 24 Apr 2020 16:01:48 -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 70DDFC09B049 for ; Fri, 24 Apr 2020 13:01:48 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id ay1so4143078plb.0 for ; Fri, 24 Apr 2020 13:01: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=ACPRkKaJUyZo8C7iIU0IKcYFjC5Ccd7f4ibW90mBkI0=; b=r/j9BvpKD2+h7VVgkG6ZqnvbwTKfJUON8chtw0D9EhgYbrohwaxbHnSVC6DKEdMEoe oUXUi8/KX/T7uSpfkE4CekO3PnJenQRoXtAgul+AqPvsi9ow75wBY9tjEYhz6nTdaqVv 4rG72mUD5zmnY1U56LkaTOIe79apgYVIYuaDdelF24YVNO12eYio7lJ/BvWIwgM/Dfjc oTm1k2Zqjev5iWhdRYVG1o2lZQ0HszP/yehulR/satJVmmY7IK32kv4qPzMJgc5Ip3DC c0kEPOPrsCds0d6wzib3xL7J3JBfcXPJbr9I1gFyucTNRsTuVHqP+okYgh+Uapw2Eot6 sUGw== 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=ACPRkKaJUyZo8C7iIU0IKcYFjC5Ccd7f4ibW90mBkI0=; b=CC3WlWbOSX7LxQU9Cx6ux1vBkI/S0kbBu9pLKn8hxWywgcA+w6WgsZICqa3egdgN4i YIdDQvYrRkX4Ybo1wsWMBpM5H0vfPYvvdhdEbCoQKj18B+35YMWchR5nX6vlh0P+JoXQ Ltw+v2sKDg/0/1b+B3MSHglivsPnw1G8FxPnmvztxxe4gTpHRGlitnhXf2emIctp739K dezThzZpqbofeWJs1GbUFVpGBUz0ibVIcmYmnzNfy4PbZzqFuKTDH9bIuP9ySvxmSz3/ EcWmzTQaBXrZHwErow3fGgTtdZtO69ajhDj5XYnkLJ85vBCuTx+wqfH1Q++xseDW/Duf 6TPw== X-Gm-Message-State: AGi0Pubz4r3He/5u0EZO4RWGYTF75MXNxZqTAj3vUL/PQY3ghaXWGxTI Tx3QwXUdNshn+2/yWILjT7SOZQ== X-Google-Smtp-Source: APiQypKfmGSdN3v0D8zcRUOZanqmk0b+MRKxMtXLO8IYCYWXEgvCIFclKnMbij53lOKaXmiqTriYqA== X-Received: by 2002:a17:90a:276a:: with SMTP id o97mr8248471pje.194.1587758507788; Fri, 24 Apr 2020 13:01:47 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:47 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/14] remoteproc: Call core functions based on synchronisation flag Date: Fri, 24 Apr 2020 14:01:29 -0600 Message-Id: <20200424200135.28825-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 Call the right core function based on whether we should synchronise with a remote processor or boot it from scratch. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_internal.h | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index dda7044c4b3e..3985c084b184 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -72,6 +72,12 @@ static inline bool rproc_needs_syncing(struct rproc *rproc) static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->sanity_check) + return rproc->sync_ops->sanity_check(rproc, fw); + return 0; + } + if (rproc->ops && rproc->ops->sanity_check) return rproc->ops->sanity_check(rproc, fw); @@ -81,6 +87,12 @@ int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) static inline u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->get_boot_addr) + return rproc->sync_ops->get_boot_addr(rproc, fw); + return 0; + } + if (rproc->ops && rproc->ops->get_boot_addr) return rproc->ops->get_boot_addr(rproc, fw); @@ -90,6 +102,12 @@ u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) static inline int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->load) + return rproc->sync_ops->load(rproc, fw); + return 0; + } + if (rproc->ops && rproc->ops->load) return rproc->ops->load(rproc, fw); @@ -98,6 +116,12 @@ int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->parse_fw) + return rproc->sync_ops->parse_fw(rproc, fw); + return 0; + } + if (rproc->ops && rproc->ops->parse_fw) return rproc->ops->parse_fw(rproc, fw); @@ -108,6 +132,13 @@ static inline int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, int avail) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->handle_rsc) + return rproc->sync_ops->handle_rsc(rproc, rsc_type, + rsc, offset, avail); + return 0; + } + if (rproc->ops && rproc->ops->handle_rsc) return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, avail); @@ -119,6 +150,13 @@ static inline struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->find_loaded_rsc_table) + return rproc->sync_ops->find_loaded_rsc_table(rproc, + fw); + return NULL; + } + if (rproc->ops && rproc->ops->find_loaded_rsc_table) return rproc->ops->find_loaded_rsc_table(rproc, fw); @@ -127,6 +165,12 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, static inline int rproc_start_device(struct rproc *rproc) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->start) + return rproc->sync_ops->start(rproc); + return 0; + } + if (rproc->ops && rproc->ops->start) return rproc->ops->start(rproc); @@ -135,6 +179,12 @@ static inline int rproc_start_device(struct rproc *rproc) static inline int rproc_stop_device(struct rproc *rproc) { + if (rproc_needs_syncing(rproc)) { + if (rproc->sync_ops && rproc->sync_ops->stop) + return rproc->sync_ops->stop(rproc); + return 0; + } + if (rproc->ops && rproc->ops->stop) return rproc->ops->stop(rproc); From patchwork Fri Apr 24 20:01:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11509001 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 30BC081 for ; Fri, 24 Apr 2020 20:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 153D72166E for ; Fri, 24 Apr 2020 20:02:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GBDPdl81" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729550AbgDXUCP (ORCPT ); Fri, 24 Apr 2020 16:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729468AbgDXUBu (ORCPT ); Fri, 24 Apr 2020 16:01:50 -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 C1975C09B04A for ; Fri, 24 Apr 2020 13:01:49 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id c21so3308799plz.4 for ; Fri, 24 Apr 2020 13:01: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=6OcPgDxlDoD3A3IbU3oJZ47tnyLvhscA3C6+vgH47qU=; b=GBDPdl81YS026oKzjxXalCH6SHeaqvcvC7z4GqxoOJ9/4sSYXchN9jlXGBaM5n53v1 cUGXZfYryAKTHCEnzG2UwQTSiLlpewsIJ3HyIAh3mcP+c6I4C4Mp/jpBDd0ivuPgrsZE SBBocN43/WUaJESo54oRwvcqCNY4j+CP++qehXbutx+HfQiQi4koJu4fyS9L+7v7roSF kHtBT9bmEfPCcZkJ9QT6wr99E8IRlXAucA8pUK4Hh7hhlD/d8lpOTN67thGHvALHrAHP 4ASJMNACPCTnLiUoScLWds/NldfdCjpBsRdivCwDMqdiqlhCl5/fbLJ6h0XQsLAOg8cz 6brg== 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=6OcPgDxlDoD3A3IbU3oJZ47tnyLvhscA3C6+vgH47qU=; b=ipKtQLDjCs9nIef0QM2GkNxTibLbrkRCDFgYl6anCKuZ4keiaCTn7cVDrCWH7uJ5QE 19Ud+QGb8QigKj1kU7IirPkoLV1FXhE5aBBw3C9UMvXqW81dSbu9UvPRe0fpwdJ6y3MT 3wddLzzp89VsMtF7M/c0UrP28JbPiTZBo0Q7WlFP9iaVAK995df3OIrIeqk7b95uWhGT YfBhp3dgG0b/NbQ4bQkdRhXY556gJp/MdgJ4s7StXDLnFfcniKgSQ9vhJldS+L5VoAk7 cZcZErGUcKzOUTjZ7SDlPtNdsHqGVGfbTfE1W3tIYJK1odnOx0T4OwphXbVRov+UqRz0 EINQ== X-Gm-Message-State: AGi0Pubn+RejV5gHy5wr9pVYpHVXiN+tNanLQTfL3xzHBdHlw32Unnf7 9Mt9/RIsbwKbGYXglbrQSVNdGw== X-Google-Smtp-Source: APiQypLxQAxSRxFaS8jwHQdEsmoKibuUvOLUt19m1OR62aHIl5MDSfr/ah8WdHpf+QpT6Z3S9r/97A== X-Received: by 2002:a17:90a:f995:: with SMTP id cq21mr8167228pjb.56.1587758509098; Fri, 24 Apr 2020 13:01:49 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:48 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/14] remoteproc: Deal with synchronisation when crashing Date: Fri, 24 Apr 2020 14:01:30 -0600 Message-Id: <20200424200135.28825-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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_recovery() in order to avoid reloading the firmware image when synchronising with a remote processor rather than booting it. Also part of the process, properly set the synchronisation flag in order to properly recover the system. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 23 ++++++++++++++------ drivers/remoteproc/remoteproc_internal.h | 27 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ef88d3e84bfb..3a84a38ba37b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1697,7 +1697,7 @@ static void rproc_coredump(struct rproc *rproc) */ int rproc_trigger_recovery(struct rproc *rproc) { - const struct firmware *firmware_p; + const struct firmware *firmware_p = NULL; struct device *dev = &rproc->dev; int ret; @@ -1718,14 +1718,16 @@ int rproc_trigger_recovery(struct rproc *rproc) /* generate coredump */ rproc_coredump(rproc); - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto unlock_mutex; + /* load firmware if need be */ + if (!rproc_needs_syncing(rproc)) { + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + goto unlock_mutex; + } } - /* boot the remote processor up again */ + /* boot up or synchronise with the remote processor again */ ret = rproc_start(rproc, firmware_p); release_firmware(firmware_p); @@ -1761,6 +1763,13 @@ static void rproc_crash_handler_work(struct work_struct *work) dev_err(dev, "handling crash #%u in %s\n", ++rproc->crash_cnt, rproc->name); + /* + * The remote processor has crashed - tell the core what operation + * to use from hereon, i.e whether an external entity will reboot + * the MCU or it is now the remoteproc core's responsability. + */ + rproc_set_sync_flag(rproc, RPROC_SYNC_STATE_CRASHED); + mutex_unlock(&rproc->lock); if (!rproc->recovery_disabled) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 3985c084b184..61500981155c 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -24,6 +24,33 @@ struct rproc_debug_trace { struct rproc_mem_entry trace_mem; }; +/* + * enum rproc_sync_states - remote processsor sync states + * + * @RPROC_SYNC_STATE_CRASHED state to use after the remote processor + * has crashed but has not been recovered by + * the remoteproc core yet. + * + * Keeping these separate from the enum rproc_state in order to avoid + * introducing coupling between the state of the MCU and the synchronisation + * operation to use. + */ +enum rproc_sync_states { + RPROC_SYNC_STATE_CRASHED, +}; + +static inline void rproc_set_sync_flag(struct rproc *rproc, + enum rproc_sync_states state) +{ + switch (state) { + case RPROC_SYNC_STATE_CRASHED: + rproc->sync_with_rproc = rproc->sync_flags.after_crash; + break; + default: + break; + } +} + /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); From patchwork Fri Apr 24 20:01: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: 11508999 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 1F83392A for ; Fri, 24 Apr 2020 20:02:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 071F3214AF for ; Fri, 24 Apr 2020 20:02:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bkgpsJhe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbgDXUCP (ORCPT ); Fri, 24 Apr 2020 16:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729457AbgDXUBv (ORCPT ); Fri, 24 Apr 2020 16:01:51 -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 2E1CCC09B04B for ; Fri, 24 Apr 2020 13:01:51 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id t4so4111608plq.12 for ; Fri, 24 Apr 2020 13:01: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=/8EQG22JXL8ro/80I28EMVnMy622Pquoagwe6M0KrVU=; b=bkgpsJheMHUDzSTUosy/UAmwFCjhd6C93gLM9hF6tuH8HE0JtCUDwchMJgA4bHZwLP 4+f1x8+0v/848OOPExzbK2I3sunvdbo5trOn22INE8ZwrpXG0YsszY6YCNaTw1LFt4lY XN72vfCJQTu+zmfwmIj5CHhW3OjXO2uMxf+/NdOGySfetVTtMhHgSzuchXCmesiwvz61 sctlSYlMaonWSsoBknhQ0UeQXNbWCA5tw9GbaJPOEjMemh924mF1FKK/BSqAELRs7mpc 1OLxUhPRlrtGb02Ieerk9XKr3T05xZzlamq5SxmhEy/mXhO79lDkbcb/RGM90w2y/YOM te2A== 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=/8EQG22JXL8ro/80I28EMVnMy622Pquoagwe6M0KrVU=; b=VDhX2+ht28jNob/ikrwobyea3FNhJuPiYgat4pQD0FV4wM8ZgrB+M4Fq5N+JKbwPnH 9WPHuA2gQvggIKogdd0x1hiYWXwtz5FmJ09I3E6bJS3OEpDlDkoLmCRG9+X17dAH9rmN Yyelom/joRl5/cRb+xiTEGhdXHlA9p6KZwb6q3f3HXZev+2JEAENAjILrNXcN+yPILs9 tcasFWXTwxl6z0FA6YvuRuhKq+SDf0aJeRGLkxCnFml8tnMygMAgTLV1sADha5ExUjd1 9vDhwFpv0lg8UrEwttzx0GlYtVAbARV2Sz67yPfuI3IodqYX7ROiOmNY3Y2ZibpEYqYB O5WQ== X-Gm-Message-State: AGi0Pubfk1cKFEGn0WqL5/aATUboi89S6GIIbxSgavz9qHtKUIOR9kmW Gp/kXLOepM/R68a+B/5PvjHERw== X-Google-Smtp-Source: APiQypJUSxhtBMeJ7MpTSeNvVV+NwnzwtOy8Co1PRQCOAmo3YYA+dJdsE6uygCk7p+wHrej+onVEZg== X-Received: by 2002:a17:90a:c702:: with SMTP id o2mr8185535pjt.196.1587758510506; Fri, 24 Apr 2020 13:01:50 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:49 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/14] remoteproc: Deal with synchronisation when shutting down Date: Fri, 24 Apr 2020 14:01:31 -0600 Message-Id: <20200424200135.28825-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 The remoteproc core must not allow function rproc_shutdown() to proceed if currently synchronising with a remote processor and the synchronisation operations of that remote processor does not support it. Also part of the process is to set the synchronisation flag so that the remoteproc core can make the right decisions when restarting the system. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 32 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 7 ++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3a84a38ba37b..48afa1f80a8f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1849,6 +1849,27 @@ int rproc_boot(struct rproc *rproc) } EXPORT_SYMBOL(rproc_boot); +static bool rproc_can_shutdown(struct rproc *rproc) +{ + /* + * The remoteproc core is the lifecycle manager, no problem + * calling for a shutdown. + */ + if (!rproc_needs_syncing(rproc)) + return true; + + /* + * The remoteproc has been loaded by another entity (as per above + * condition) and the platform code has given us the capability + * of stopping it. + */ + if (rproc->sync_ops->stop) + return true; + + /* Any other condition should not be allowed */ + return false; +} + /** * rproc_shutdown() - power off the remote processor * @rproc: the remote processor @@ -1879,6 +1900,9 @@ void rproc_shutdown(struct rproc *rproc) return; } + if (!rproc_can_shutdown(rproc)) + goto out; + /* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test(&rproc->power)) goto out; @@ -1898,6 +1922,14 @@ void rproc_shutdown(struct rproc *rproc) kfree(rproc->cached_table); rproc->cached_table = NULL; rproc->table_ptr = NULL; + + /* + * The remote processor has been switched off - tell the core what + * operation to use from hereon, i.e whether an external entity will + * reboot the remote processor or it is now the remoteproc core's + * responsability. + */ + rproc_set_sync_flag(rproc, RPROC_SYNC_STATE_SHUTDOWN); out: mutex_unlock(&rproc->lock); } diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 61500981155c..7dcc0a26892b 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -27,6 +27,9 @@ struct rproc_debug_trace { /* * enum rproc_sync_states - remote processsor sync states * + * @RPROC_SYNC_STATE_SHUTDOWN state to use after the remoteproc core + * has shutdown (rproc_shutdown()) the + * remote processor. * @RPROC_SYNC_STATE_CRASHED state to use after the remote processor * has crashed but has not been recovered by * the remoteproc core yet. @@ -36,6 +39,7 @@ struct rproc_debug_trace { * operation to use. */ enum rproc_sync_states { + RPROC_SYNC_STATE_SHUTDOWN, RPROC_SYNC_STATE_CRASHED, }; @@ -43,6 +47,9 @@ static inline void rproc_set_sync_flag(struct rproc *rproc, enum rproc_sync_states state) { switch (state) { + case RPROC_SYNC_STATE_SHUTDOWN: + rproc->sync_with_rproc = rproc->sync_flags.after_stop; + break; case RPROC_SYNC_STATE_CRASHED: rproc->sync_with_rproc = rproc->sync_flags.after_crash; break; From patchwork Fri Apr 24 20:01: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: 11508997 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 E92E481 for ; Fri, 24 Apr 2020 20:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D13A92166E for ; Fri, 24 Apr 2020 20:02:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qszvw6G5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729499AbgDXUCP (ORCPT ); Fri, 24 Apr 2020 16:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbgDXUBw (ORCPT ); Fri, 24 Apr 2020 16:01:52 -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 6852FC09B04C for ; Fri, 24 Apr 2020 13:01:52 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id h12so2929747pjz.1 for ; Fri, 24 Apr 2020 13:01:52 -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=x5AHzcS8sGC9RgEnYTkEdMtqDh+A4mE2SJWyouyzavc=; b=Qszvw6G5hey/OgSVSi18emlbljJRMDrWac3iPQQrHxseohEWF+b/gOBuTe3FeI7Rdi N70dW6ppXpbePUI7XLXYE6qv9No8YpF1Ny00lB2qULYDCzvKaofA/IW632rEAqAbS2lP KuDNIbU6Rdf1A4AG2Z+UGWblwCigb/HunNdtWjlx9O69ntpyYF0M2UOlA/L9Duznq0TV es9aiuHwxnHRCL5ovv90Er7EuA96nL6RsxDq2+St98vJuOpgiWwX3T3og+9O4ZWVCyqo RecNKOO5in7OfsMy/oSIDBE60tOaS0WJpLc+NlQZmQVK+kHkLCNeCCQsNgcIOzWlsblK 9IKA== 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=x5AHzcS8sGC9RgEnYTkEdMtqDh+A4mE2SJWyouyzavc=; b=LP0P5imxcPioKrZiCLXrc2rsQBYVdU0OwDNJQopTpasFgQydF331RHaGK5WUQWwyV+ 2iU62mpFIuqJLC5Sdnk5KEt1pLyBhce5I8PNHne5PhoPt6JcIQ/43hMcKrw4PF26GeWb mSHxWvESiwRdxjcCxU384slbTQ3bndd9AJPa7ZVLKY83M2oYUilQ+DIwt1/rYQUX6LCD 05M8SdqCWBW6qAcvmY6kqgukC5bYEV2q8p4yUzJuZO940hroa0cbb5qwJLrbumTGrE8r 5KjdPYj8dwAXULJOSimAZs8jrYzRt2jiNX3ure9i4qy1Y0S7RFl6OdgyQdND3jGEMt0w e6zg== X-Gm-Message-State: AGi0PuZccKgb1Z+a2Y0SXQCXbezEmDd1nXIkMu7sN/2vjelbrNPYpSAI ycrTlRlGE04a8d/rmHvp724ovw== X-Google-Smtp-Source: APiQypIGm772GdNEbMZRG1Sl2BHW92OFtPhGXH1b/EFdq/5lG+DrWOi9wf3UyXMrfeaSEtc6o2N63A== X-Received: by 2002:a17:90a:5d02:: with SMTP id s2mr7992200pji.148.1587758511852; Fri, 24 Apr 2020 13:01:51 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:51 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/14] remoteproc: Deal with synchronisation when changing FW image Date: Fri, 24 Apr 2020 14:01:32 -0600 Message-Id: <20200424200135.28825-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 from being displayed or changed when the remoteproc core is synchronising with a remote processor. This is 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_sysfs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 7f8536b73295..cdd322a6ecfa 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -13,9 +13,20 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, char *buf) { + ssize_t ret; struct rproc *rproc = to_rproc(dev); - return sprintf(buf, "%s\n", rproc->firmware); + /* + * In most instances there is no guarantee about the firmware + * that was loaded by the external entity. As such simply don't + * print anything. + */ + if (rproc_needs_syncing(rproc)) + ret = sprintf(buf, "\n"); + else + ret = sprintf(buf, "%s\n", rproc->firmware); + + return ret; } /* Change firmware name via sysfs */ @@ -39,6 +50,17 @@ static ssize_t firmware_store(struct device *dev, goto out; } + /* + * There is no point in trying to change the firmware if loading the + * image of the remote processor is done by another entity. + */ + if (rproc_needs_syncing(rproc)) { + dev_err(dev, + "can't change firmware while synchronising with MCU\n"); + err = -EBUSY; + goto out; + } + len = strcspn(buf, "\n"); if (!len) { dev_err(dev, "can't provide a NULL firmware\n"); From patchwork Fri Apr 24 20:01: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: 11508993 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 A609B14B4 for ; Fri, 24 Apr 2020 20:02:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86406214AF for ; Fri, 24 Apr 2020 20:02:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qHNLIcrp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729497AbgDXUBz (ORCPT ); Fri, 24 Apr 2020 16:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729483AbgDXUBy (ORCPT ); Fri, 24 Apr 2020 16:01:54 -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 BAE8AC09B04A for ; Fri, 24 Apr 2020 13:01:53 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o185so5133623pgo.3 for ; Fri, 24 Apr 2020 13:01:53 -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=+KtUuv8wxKYeUMEMfd8cqZZsyE2X/a3TCFtZ9LiwPgw=; b=qHNLIcrp17ncZ7tnqZas6mqCu4R32bRGgjFzeM/nXSxBxQxPd4xlqXM/ryo6VRXwvu uoA6s1kueOmbPWyJXv5Jw0Cj9Jqa7NDKDTIt1b1eIqlL5uNJ2alrOusFzleBjalPaB/A Qnh+jFLQg+3oRD7gv7PNKUlQUMUjwJKPJtnfDYOoohcRhTVPnEhnbu15RO+9zVjYZhxM p6Vcb0g1FsQx1JQh1DWNinCWR2ayqPIEs1H4qO+GDcwis+wpM2OIv//7323uCQ8M7X2c ijYozKLcfgtb6a+qy9wTOGE2WcVvujOz0HBOicN3e1zrDmZs1reAkEx3Jyp8Zem3I4ZA PLjw== 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=+KtUuv8wxKYeUMEMfd8cqZZsyE2X/a3TCFtZ9LiwPgw=; b=m74CDcRcnYIP3KDNQVrtIYH16WEycB72QA0N7Nn+8PKM5rrXIJ+SbIlRCNVMbhn6cI Nm/mrwOfiFCwLy431cfLoN+xouOMJP02PUP+2+UiPfKEuSxdYiNnbyto6Q5Gq95L+4RR Yvh6o0rcQz2Py8GyH9HujerKmjMOrmDCGLXgE53sIp8WcJFDNtrOhHGL0SViAdTbRkuP Ci8WbCpZGFQ76hNS9z6PYDnG/583l3ZVYmYNV0Sp0eFP5V9/M9+QdRIxMVrTIPHTEaKc tZGJsD3bkW576WWLlYEOcj/wiL6ZiFhrQrCDJDNNS5EObdesbP1YLDZIDzMYcN2FXHn2 8ykA== X-Gm-Message-State: AGi0Pubx5Rf9P18wu2MtGvxIKV2589VGJtwICgmlNnqOc2iOvHZPUeip BEGCaHuPGavchWhM8AcMPXUElQ== X-Google-Smtp-Source: APiQypID6xmKC+2YIB8cnOB/Aes9uvT8JmBrhPiyr9CKzPytdnzwMZiL3/8V5pnpJFtOoW6Ey2PGnQ== X-Received: by 2002:a62:b40e:: with SMTP id h14mr10763306pfn.88.1587758513048; Fri, 24 Apr 2020 13:01:53 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:52 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/14] remoteproc: Introducing function rproc_set_state_machine() Date: Fri, 24 Apr 2020 14:01:33 -0600 Message-Id: <20200424200135.28825-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 Introducting function rproc_set_state_machine() to add operations and a set of flags to use when synchronising with a remote processor. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 54 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 6 +++ include/linux/remoteproc.h | 3 ++ 3 files changed, 63 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 48afa1f80a8f..5c48714e8702 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2065,6 +2065,59 @@ int devm_rproc_add(struct device *dev, struct rproc *rproc) } EXPORT_SYMBOL(devm_rproc_add); +/** + * rproc_set_state_machine() - Set a synchronisation ops and set of flags + * to use with a remote processor + * @rproc: The remote processor to work with + * @sync_ops: The operations to use when synchronising with a remote + * processor + * @sync_flags: The flags to use when deciding if the remoteproc core + * should be synchronising with a remote processor + * + * Returns 0 on success, an error code otherwise. + */ +int rproc_set_state_machine(struct rproc *rproc, + const struct rproc_ops *sync_ops, + struct rproc_sync_flags sync_flags) +{ + if (!rproc || !sync_ops) + return -EINVAL; + + /* + * No point in going further if we never have to synchronise with + * the remote processor. + */ + if (!sync_flags.on_init && + !sync_flags.after_stop && !sync_flags.after_crash) + return 0; + + /* + * Refuse to go further if remoteproc operations have been allocated + * but they will never be used. + */ + if (rproc->ops && sync_flags.on_init && + sync_flags.after_stop && sync_flags.after_crash) + return -EINVAL; + + /* + * Don't allow users to set this more than once to avoid situations + * where the remote processor can't be recovered. + */ + if (rproc->sync_ops) + return -EINVAL; + + rproc->sync_ops = kmemdup(sync_ops, sizeof(*sync_ops), GFP_KERNEL); + if (!rproc->sync_ops) + return -ENOMEM; + + rproc->sync_flags = sync_flags; + /* Tell the core what to do when initialising */ + rproc_set_sync_flag(rproc, RPROC_SYNC_STATE_INIT); + + return 0; +} +EXPORT_SYMBOL(rproc_set_state_machine); + /** * rproc_type_release() - release a remote processor instance * @dev: the rproc's device @@ -2088,6 +2141,7 @@ static void rproc_type_release(struct device *dev) kfree_const(rproc->firmware); kfree_const(rproc->name); kfree(rproc->ops); + kfree(rproc->sync_ops); kfree(rproc); } diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 7dcc0a26892b..c1a293a37c78 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -27,6 +27,8 @@ struct rproc_debug_trace { /* * enum rproc_sync_states - remote processsor sync states * + * @RPROC_SYNC_STATE_INIT state to use when the remoteproc core + * is initialising. * @RPROC_SYNC_STATE_SHUTDOWN state to use after the remoteproc core * has shutdown (rproc_shutdown()) the * remote processor. @@ -39,6 +41,7 @@ struct rproc_debug_trace { * operation to use. */ enum rproc_sync_states { + RPROC_SYNC_STATE_INIT, RPROC_SYNC_STATE_SHUTDOWN, RPROC_SYNC_STATE_CRASHED, }; @@ -47,6 +50,9 @@ static inline void rproc_set_sync_flag(struct rproc *rproc, enum rproc_sync_states state) { switch (state) { + case RPROC_SYNC_STATE_INIT: + rproc->sync_with_rproc = rproc->sync_flags.on_init; + break; case RPROC_SYNC_STATE_SHUTDOWN: rproc->sync_with_rproc = rproc->sync_flags.after_stop; break; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ceb3b2bba824..a75ed92b3de6 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -619,6 +619,9 @@ struct rproc *rproc_get_by_child(struct device *dev); struct rproc *rproc_alloc(struct device *dev, const char *name, const struct rproc_ops *ops, const char *firmware, int len); +int rproc_set_state_machine(struct rproc *rproc, + const struct rproc_ops *sync_ops, + struct rproc_sync_flags sync_flags); void rproc_put(struct rproc *rproc); int rproc_add(struct rproc *rproc); int rproc_del(struct rproc *rproc); From patchwork Fri Apr 24 20:01: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: 11508995 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 3116092A for ; Fri, 24 Apr 2020 20:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1828C216FD for ; Fri, 24 Apr 2020 20:02:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nQ2U1b8k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729535AbgDXUCI (ORCPT ); Fri, 24 Apr 2020 16:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729502AbgDXUB4 (ORCPT ); Fri, 24 Apr 2020 16:01:56 -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 2FE98C09B04C for ; Fri, 24 Apr 2020 13:01:55 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a7so4308046pju.2 for ; Fri, 24 Apr 2020 13:01:55 -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=Rb70E/sjGdouOLoWnX7vl3Ag+u7wzfoBCVwZVo3HJd8=; b=nQ2U1b8khZFfIfjOuvs7xqMrSwowogjemD4mPQXzUxFybJtnqqu0wz83C9Xy9WzxjK BR5SM0fkeuVtP00aV10s31vFYUrPfKfroOSGtQ+x6c7zp9iEYrg9LYxy2nQo6XVNJK9o tA1hkmNN3wXKGrpFuueUK2WquyplBhHywJqkjiteGWj/SpancKa4wHsaBVd3r+ITQLt5 nZYDGLys/6olCPsbJAs2TYqvlArstuJvbBTyyWSo1tvYu1Yfjaa8t/JPfuKttZwiLnGS kmn3KZKlGNFMPu+I4r7/7/mGV+j+taV3mOtBzqEvITyaCXnXG+PF4q1J1AJATywYH+TO AAhQ== 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=Rb70E/sjGdouOLoWnX7vl3Ag+u7wzfoBCVwZVo3HJd8=; b=E3Ds/aYRk3ixnTpjTadtLsn3yFf4KMbT/3f3gZJG4NfxZW26SSuQ0MpYG1O6HgsY7Y 06ol51ggk3hZSViikp3WfHT80GFeR7r3JS3GT1zuHCTA7x1GQ6wIoudwmxcyMTGQX1ST MZoARaDZjU3qwgMt56QkWy/Aven6VjtBfiTQDOhazxx2jIlPMoWWvNhgE2JpAwFENuQE SHP1fohTGCEZ8qTQFB4MWtIv4Wu3v4gSE2jz+3WTNxIdv8FcqHb5061tVq8lW6EHgpO2 0O13/9Q46l+qXZoaL6ogQ4t2b01DJmDVpMM2VDiVEjyqyB26rBl7vKOAUKEB9GMCLsd/ 9FsQ== X-Gm-Message-State: AGi0PubT/ZDOS45Y+PtP/0C4D5PpF6qgfR4+yMZ9ail8PFPZShvL1+Rp Psp7uwoEIffRFz1RPdqBnhlzv+Jr6LQ= X-Google-Smtp-Source: APiQypK4C28yh0PLdX0/fSmEWnxbUJ2uF1f02JWzlTKDSyT3ZBXAedHvxEuxZren5njEVG7AHjvb4A== X-Received: by 2002:a17:90a:1b67:: with SMTP id q94mr8348667pjq.84.1587758514536; Fri, 24 Apr 2020 13:01:54 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:53 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/14] remoteproc: Document function rproc_set_state_machine() Date: Fri, 24 Apr 2020 14:01:34 -0600 Message-Id: <20200424200135.28825-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 few words on the newly added rproc_set_state_machine() in order to adversite the new API and help put people into context. Signed-off-by: Mathieu Poirier --- Documentation/remoteproc.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/remoteproc.txt b/Documentation/remoteproc.txt index 2be1147256e0..550ed9a06a27 100644 --- a/Documentation/remoteproc.txt +++ b/Documentation/remoteproc.txt @@ -132,6 +132,23 @@ On success, the new rproc is returned, and on failure, NULL. **never** directly deallocate @rproc, even if it was not registered yet. Instead, when you need to unroll rproc_alloc(), use rproc_free(). +:: + + int rproc_set_state_machine(struct rproc *rproc, + const struct rproc_ops *sync_ops, + struct rproc_sync_flags sync_flags) + +This function should be called for cases where the remote processor has +been started by another entity, be it a boot loader or trusted environment, +and the remoteproc core is to synchronise with the remote processor rather +then boot it. The synchronisation flags @sync_flags tell the core whether +it should synchronise with a remote processor when the core initialises, after +a remote processor has crashed and after it was voluntarily stopped. Operations +provided in the @sync_ops should reflect the reality of the use case. For +example if the remoteproc core is to synchronise with a remote processor at +initialisation time, sync_ops::find_loaded_rsc_table should provide a pointer to +the resource table in memory rather than fetch it from the firmware image. + :: void rproc_free(struct rproc *rproc) From patchwork Fri Apr 24 20:01: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: 11508991 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 D084581 for ; Fri, 24 Apr 2020 20:02:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B88FA214AF for ; Fri, 24 Apr 2020 20:02:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HmiyDdp1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbgDXUCD (ORCPT ); Fri, 24 Apr 2020 16:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729449AbgDXUB5 (ORCPT ); Fri, 24 Apr 2020 16:01:57 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C700C09B048 for ; Fri, 24 Apr 2020 13:01:56 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id g6so5113685pgs.9 for ; Fri, 24 Apr 2020 13:01:56 -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=eewTcbuSLQRCFeSiAoYYX0+XB7BDJvlp2EU0H6eGjY4=; b=HmiyDdp1jKoJRJ08HAwnGFrLp2BqyTXeVlxNgf+lTmmyTS8yOuVzEJl6XmSBvWkAS/ v/JwQlGdlmMeH1Xd2BZ21I5FEC/BV6wHAGRCVgAcB1lwzZxKnZIpNlLZKOWVsyGJbyoC KtPcO3HbrrJWEEOr6guTSb+qPCw8jozVoSA/MrrMeuM6iNlHvF1jx3hXzlHEcdZn6hpj 5NatL9qSFglUvtASP78GysB2bsqBosJIQfd3d0g1fkisR7rgNut1AfGdF+fffrUNEz71 r6AvQvD/tP1ZkkRjfAX8kAyamS0lQCLChUKc9kr/vLDxhkPNWR10WS1BDEXYXm6d3zVP kBBQ== 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=eewTcbuSLQRCFeSiAoYYX0+XB7BDJvlp2EU0H6eGjY4=; b=p3b+V0JPn2U4Ax/gszxeTPxKQ4UMr339Pz8fih0MlhSyLvy8ztK1UmShSJlkw9UOtx 3UFY/0uAmBSe5qsYsbS04OwHCjZVPIbOhzwzdGvr7Gi5PxF93tu38nMPe/5OB3ISTz5G Lox3OlDLswj05KHFnHfY+PUwLOp1m+P8/ntGW2X+Lzty334guOFIppVh46ADJQDhHyYg M+YAIRon001Tiqa/Gwhi9enJeD8wbKiSC6Bpxy5sysj14mu4+jf1ksJtrYWjwvMVTgEe uYugE42fdz93kR20qHNBd7UU32SIe98P3IZm9FIWdHDW3bBdRvpLLzlH8SMJm8iveN4Q p11A== X-Gm-Message-State: AGi0PuYUtBiAWYhdcCk0SwhQvGPpcnnzP9/Wn256NTjvQXOQz0M4sIO0 5/sVDDlXYQqo2ZODyN9ipeN7lA== X-Google-Smtp-Source: APiQypKrHJCG5PxycsdeNY28g4yilDbLzXrizVM7n33WA5yRahh5tr3biAmtw3GGMoaVwRFNakd1jA== X-Received: by 2002:a62:2b06:: with SMTP id r6mr11126923pfr.249.1587758515825; Fri, 24 Apr 2020 13:01:55 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o11sm5532224pgd.58.2020.04.24.13.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 13:01:55 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com, linux-remoteproc@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 14/14] remoteproc: Expose synchronisation flags via debugfs Date: Fri, 24 Apr 2020 14:01:35 -0600 Message-Id: <20200424200135.28825-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424200135.28825-1-mathieu.poirier@linaro.org> References: <20200424200135.28825-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 debugfs entry that reflects the value of the current synchronisation flags used by the remoteproc core. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_debugfs.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c index 732770e92b99..3dde24e62cd8 100644 --- a/drivers/remoteproc/remoteproc_debugfs.c +++ b/drivers/remoteproc/remoteproc_debugfs.c @@ -291,6 +291,25 @@ static int rproc_carveouts_show(struct seq_file *seq, void *p) DEFINE_SHOW_ATTRIBUTE(rproc_carveouts); + /* Expose synchronisation states via debugfs */ +static int rproc_sync_flags_show(struct seq_file *seq, void *p) +{ + struct rproc *rproc = seq->private; + + seq_printf(seq, "Sync with rproc: %s\n", + rproc->sync_with_rproc ? "true" : "false"); + seq_printf(seq, "On init: %s\n", + rproc->sync_flags.on_init ? "true" : "false"); + seq_printf(seq, "After stop: %s\n", + rproc->sync_flags.after_stop ? "true" : "false"); + seq_printf(seq, "After crash: %s\n", + rproc->sync_flags.after_crash ? "true" : "false"); + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(rproc_sync_flags); + void rproc_remove_trace_file(struct dentry *tfile) { debugfs_remove(tfile); @@ -337,6 +356,8 @@ void rproc_create_debug_dir(struct rproc *rproc) rproc, &rproc_rsc_table_fops); debugfs_create_file("carveout_memories", 0400, rproc->dbg_dir, rproc, &rproc_carveouts_fops); + debugfs_create_file("sync_flags", 0400, rproc->dbg_dir, + rproc, &rproc_sync_flags_fops); } void __init rproc_init_debugfs(void)