From patchwork Wed Aug 26 16:45:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11739169 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 26B6C138A for ; Wed, 26 Aug 2020 16:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F04B2078B for ; Wed, 26 Aug 2020 16:49:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="f9AZkUF8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727943AbgHZQtD (ORCPT ); Wed, 26 Aug 2020 12:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbgHZQpe (ORCPT ); Wed, 26 Aug 2020 12:45:34 -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 EF553C061757 for ; Wed, 26 Aug 2020 09:45:32 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id y6so1153103plk.10 for ; Wed, 26 Aug 2020 09:45:32 -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=jCF/a0xKIWqbt7wIUY8AEgGbHy28w20HVJLneFBKefA=; b=f9AZkUF8HwjIrp6vPGOuGK5/BZQ33xA15gaimxyXyvQqbYPMj/aTBZyE79upHJXcyx g0QJuEEu5J6Y1FHXlnQhPuuAeC0D40IYRf81gM2IaC7kqLRVpFie8Eft3ETUodKI4Clk fRWIkJmznBpF/DtjU6iC04NjhKCfy5PL4vbyxzu7KGSFFTf45esVto7O31wAJ1QzCFxa /XgqHeg+eK0QHle+WRUMi9uCgz70vNlJh3foE2Ey/zxfILokqIfynvcBv4K3fwOIaWFq g0+3JbAgzeAoP34ux82szDlXvf3kv6Cp7FfXZBQtWFPAL8uOb7k8zLrJo3hPsaj2QDTA MTOA== 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=jCF/a0xKIWqbt7wIUY8AEgGbHy28w20HVJLneFBKefA=; b=a9HweQl0lYt1obxllRVH1iOQkX4IIPhg7MIuMyfzfIJQT5r6vsV1AIMfMymPEfLsZl sgiN72WHBkVMTjihitcutoDbLcLAFAMIx88lWhRuTykFG2EYlS+yJCmJVQ/Ffx9AXxo4 DrVJBav2918baM9cVcmihBxTHz2N3H0zzRfaak7CoHwWEsinCWfaTrsC468Qurez5XQX akcb/z7+mIu2CGTLMBYd1KuDgSUoo8tjcaO7agl59Da/R2QCl30sTp/zutVERZ9gGiwe iGrsQJJPVjdSiVS9HFUXwkkf5M9uv7ke/1WTecBtgn0y4XbhJXBLt35z6SQnMKlbK/oH 9uMQ== X-Gm-Message-State: AOAM531xhh4eBen5nLg7qTNtjCJ+6HQJhKVBoNVC53VfE70WEPWRs+b1 Fe6+1m7LQx6daGGnyy77T9M6mfFn27rHTA== X-Google-Smtp-Source: ABdhPJxEUc2ptVXTNpO+YXWFtlc9/9RA87PwcwkcXOQDJRawbIyXYC5dSKq0dPbyN6OxLL9jL1icBQ== X-Received: by 2002:a17:902:b28b:: with SMTP id u11mr3741410plr.117.1598460332525; Wed, 26 Aug 2020 09:45:32 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:32 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/13] remoteproc: Re-check state in rproc_shutdown() Date: Wed, 26 Aug 2020 10:45:17 -0600 Message-Id: <20200826164529.224476-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 state of the remote processor may have changed between the time a call to rproc_shutdown() was made and the time it is executed. To avoid moving forward with an operation that may have been cancelled, recheck while holding the mutex. Cc: Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7f90eeea67e2..fb2632cbd2df 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1834,6 +1834,9 @@ void rproc_shutdown(struct rproc *rproc) return; } + if (rproc->state != RPROC_RUNNING) + goto out; + /* if the remote proc is still needed, bail out */ if (!atomic_dec_and_test(&rproc->power)) goto out; From patchwork Wed Aug 26 16:45:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11739167 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 6AFD414E5 for ; Wed, 26 Aug 2020 16:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 508A02080C for ; Wed, 26 Aug 2020 16:48:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qf8ULyJn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbgHZQss (ORCPT ); Wed, 26 Aug 2020 12:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbgHZQpf (ORCPT ); Wed, 26 Aug 2020 12:45:35 -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 189E4C061795 for ; Wed, 26 Aug 2020 09:45:34 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h2so1154456plr.0 for ; Wed, 26 Aug 2020 09:45:34 -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=UBjkd/nhJw+5eFsm4c9uEVXQEw9HU2zN9X5gsAn0rmo=; b=Qf8ULyJn2F0iIwf8dA+aVpTzmLX0NtkKs/Jg3rzWujRiqTX/BHskaLds1G56xa3F29 FTRgUuV6keGhWYBXOPLaqAXhI7qkN7cMWY10ZU6ejxCHlUV+8K6bP9PuHM3NEASjyvJE nBDfvDxgy0jcWkglP3DTRGGkN7DLsjFFis7JQ5SRvPY+4w4XSdpm4GzCerzPaturE5KD +H/uDvHagHaN16pGk3gDL/jHhsQJD7wPXm1Xe6oSEnUTNbVWbqE7xIlmRXN+SsOGczdC 3/sjiH0qrIOqBUdxrw2KKAvnUK1YNxOFkaowjK5A78JQuwO5/7meLRB6Qjcnaf23tqFV k+4w== 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=UBjkd/nhJw+5eFsm4c9uEVXQEw9HU2zN9X5gsAn0rmo=; b=f3JZMIuZvrrlJer+xvq3DDDSUlYd37Eu1t6buiNm7Apz2PTeifquTgJlsfCabS//YC wytuv21I1WIssAaVDOT8BoMGUCJijUqmlDBudgn/BF+1PY5PdQI+c2u0MW7oKQ+R1scZ wvgulsyvC/i20UO2MVIEUcNF51O8p+nq7DlaJ1+EhyGm5AS1UZwyX0r8GFLWc3md2Voi mhNIsJ2dP/mZkSXnVHxCv7uNNU/Zi8mzh6zVXraS5thB95AFWIbgzVYfZ6hk0JCWVGm6 k9+y5qk1DbwZgRY3AUfSZUf/mPTU9TuTa9vB4mBb7EUwqLbjJGHbfFVsw9rcsgTpSCQx kTRg== X-Gm-Message-State: AOAM530YvOzolRcmnDZdZas3iU/s5Vo/L/Zzjzv8DdBSJwqMt9kzRTAr 4yqdnjLN5nXUWStPioTZLSk9GQ== X-Google-Smtp-Source: ABdhPJylZ5yXv125kk5hDT9ig5MisH34jLUAAF9+rT46jI+xNbUFWx4mK/gKw6o8/rZiB4tbO9QS2A== X-Received: by 2002:a17:90a:8904:: with SMTP id u4mr7075859pjn.87.1598460333569; Wed, 26 Aug 2020 09:45:33 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:33 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/13] remoteproc: Remove useless check in rproc_del() Date: Wed, 26 Aug 2020 10:45:18 -0600 Message-Id: <20200826164529.224476-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 Whether started at probe() time or thereafter from the command line, a remote processor needs to be shutdown before the final cleanup phases can happen. Otherwise the system may be left in an unpredictable state where the remote processor is expecting the remoteproc core to be providing services when in fact it no longer exist. Invariably calling rproc_shutdown() is fine since it will return immediately if the remote processor has already been switched off. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fb2632cbd2df..7d78c9a9d88f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2260,10 +2260,8 @@ int rproc_del(struct rproc *rproc) if (!rproc) return -EINVAL; - /* if rproc is marked always-on, rproc_add() booted it */ /* TODO: make sure this works with rproc->power > 1 */ - if (rproc->auto_boot) - rproc_shutdown(rproc); + rproc_shutdown(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; From patchwork Wed Aug 26 16:45:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11739165 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 155651751 for ; Wed, 26 Aug 2020 16:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F053C2074A for ; Wed, 26 Aug 2020 16:48:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dm3yYqUI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728173AbgHZQsr (ORCPT ); Wed, 26 Aug 2020 12:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbgHZQpf (ORCPT ); Wed, 26 Aug 2020 12:45:35 -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 082C7C061796 for ; Wed, 26 Aug 2020 09:45:35 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id mw10so1120024pjb.2 for ; Wed, 26 Aug 2020 09:45:35 -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=TcCaJSWZ5zZ/Rso84Md8LnddY1FwOKOfNkmuWIoFYnQ=; b=dm3yYqUInguZ89okbV11/vGYlFn82cIagLPzf0RhAV98yFFrfo6gFzi0A+Am5O0Gyc ugVm7/J+o0C60T8u1lkYXbgxuDp1uAWUunJ4hDDQ6aktWXMBcZcE3DFRx7rsZb89V79i phENsosVHMy2FmSQuDkPI5t6YiewbvczlZtupyC7tmVaN41rqiIdwoDsCtwPA3MDM+Um gLbdNlYPKztMByVz7kSoS+1PGlCUjk4Zo6ygy3N0o0rBpLcg2ra4fIgrqwapiqO+xrjZ VqXiWhvM/h4yeN6eBeemv9FFKc6okpYMaLjygSLWkdgijMGF8eATrWjRFfFolw5fBiq7 pD+A== 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=TcCaJSWZ5zZ/Rso84Md8LnddY1FwOKOfNkmuWIoFYnQ=; b=sVCqE7867eT82qPGY2FcFQwl0Sw4KNbgShxZOf9NN4gtaDtc09VT1R7t52cizq6nCY LkBPxmlrK/5CrRrrSv2Fe6b4+Zjs5YHqOCqdHCHDAOi/8kIH81HfyPlW6y8Sc6uKsHTH fs7uCLACkhDcxjkj863FI5diqbGfR0nYl/InFkIzTaluK8ICh0UGnWgPCE5Oz/7+HInn 8N2LSwBlkAVt0mat4SFRRIsQUOollpB7yLgihRRX/jakH20hkQsdkVoKlDshcMsCTnYd oKX6L/fI5yf+lkYosBCBMCyAzFkJzd72PQMNa+WBiQrSj7imYT3HkTiPuv4J2QDwbrGV Hx6Q== X-Gm-Message-State: AOAM530l366+ZFLBLe6I0TxfJcZKj5Kt1WsXdubtlG2J7oXloeMDmI9Q ktLmdk9GUJp+ncMfzN5s2HJrDg== X-Google-Smtp-Source: ABdhPJzHWCXaJwC+6m4F9wmmPbzgzuPs4WmDpHbnpqyB7UWrdT1pyuF+UfV2jrrtlse91ns9DP7Dbw== X-Received: by 2002:a17:90a:8909:: with SMTP id u9mr6936602pjn.119.1598460334598; Wed, 26 Aug 2020 09:45:34 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:34 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/13] remoteproc: Add new RPROC_ATTACHED state Date: Wed, 26 Aug 2020 10:45:19 -0600 Message-Id: <20200826164529.224476-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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_ATTACHED 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: Peng Fan --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index eea514cec50e..2d575e6c9eb8 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -84,6 +84,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 2fa68bf5aa4f..4e107615121a 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -403,6 +403,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_ATTACHED: device has been booted by another entity and the core + * has attached to it * @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 @@ -419,8 +421,9 @@ enum rproc_state { RPROC_RUNNING = 2, RPROC_CRASHED = 3, RPROC_DELETED = 4, - RPROC_DETACHED = 5, - RPROC_LAST = 6, + RPROC_ATTACHED = 5, + RPROC_DETACHED = 6, + RPROC_LAST = 7, }; /** From patchwork Wed Aug 26 16:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11739163 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 D7326138A for ; Wed, 26 Aug 2020 16:48:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B90EA2080C for ; Wed, 26 Aug 2020 16:48:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LSXlMfoo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727990AbgHZQsp (ORCPT ); Wed, 26 Aug 2020 12:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727889AbgHZQpl (ORCPT ); Wed, 26 Aug 2020 12:45: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 0EC2FC061574 for ; Wed, 26 Aug 2020 09:45:36 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id i13so1150894pjv.0 for ; Wed, 26 Aug 2020 09:45:36 -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=lxIye1BxXlig0joxvfV3TjTIbmhtulHfHUSFeSKXwpg=; b=LSXlMfoos36WBF/fpaBmObLrfS1kz0HZZI2Qgav75AsUjAKat8LuytVTlC0tyS0ayL RmAE0lhS8q1WNT0AnpU1kPZ4ydgT6kTymvspcSOCHCDEXUeamTtWMnPpQTB67chGltwO oPP1bSkN5CCVyDqotivlmwRE5n9N0GRhpMWtF2V994hRuEBNPzgxHA7ZtI8AaBNIU+os fxeN2gTVacLnlgxmWfJYN7t1tAVx4t3LlgSfN3B7lmf13hh206NOXwHNMvrV+wRfvoV3 MdMPZsAfM+hvLddQn61WosUesty0T8QDlAT8TaoYf9k7/o4kmxjq0j5aXMjQTxQUN7my FOjg== 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=lxIye1BxXlig0joxvfV3TjTIbmhtulHfHUSFeSKXwpg=; b=XX9Q1XK970VY01OqykrooYfvU03s06Mx0UZEQHOzWOiXPnKfyG0r8V1F5CQ+Hpv7mQ 9kO1ysOpnU0up2qTs8d2Xr1XkCo3VxIqN/UriWinzoDzbnJs5okdBcc5Xq4kkzNvpBGL r4sqIIAotSoGQQNDjcGJG3t2kGGz9LH5Qzrf4z1qySyVVmTb1RY/n/r+e98picV9GmNV n9EKZzofShl5lX2d6zrcbQmjYjyjj3PeuvFbvMvG1EZGLmGMkBy+nfohr8p8PymYvZAz zvhSp1L+gyJVkKY3Q0mR2ECG8GROEjfw5ZE9fdvsfySslXDlgbDgW0KhunzDnE/gx8wB KWWw== X-Gm-Message-State: AOAM532PG2cFpWx1HFB0LAUXU2u/0TjHq/UgG4fAC4MnFz/hWem2dAXM Ci4bHnOSYOWJzk3N2KlqrVAhzg== X-Google-Smtp-Source: ABdhPJy7qksIbBbnDIJyu4KWGBE7pRUmbDYs2d7RkCBEnoXMIwUj0YzTJsrjyyZjXZAGIvc9BSbi8Q== X-Received: by 2002:a17:902:8208:: with SMTP id x8mr1135726pln.65.1598460335543; Wed, 26 Aug 2020 09:45:35 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:35 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/13] remoteproc: Properly represent the attached state Date: Wed, 26 Aug 2020 10:45:20 -0600 Message-Id: <20200826164529.224476-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 There is a need to know when a remote processor has been attached to rather than booted by the remoteproc core. In order to avoid manipulating two variables, i.e rproc::autonomous and rproc::state, get rid of the former and simply use the newly introduced RPROC_ATTACHED state. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 20 +------------------- drivers/remoteproc/remoteproc_sysfs.c | 5 +---- include/linux/remoteproc.h | 2 -- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7d78c9a9d88f..bffaa9ea7c8f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1421,7 +1421,7 @@ static int rproc_attach(struct rproc *rproc) goto stop_rproc; } - rproc->state = RPROC_RUNNING; + rproc->state = RPROC_ATTACHED; dev_info(dev, "remote processor %s is now attached\n", rproc->name); @@ -1636,14 +1636,6 @@ 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; @@ -1994,16 +1986,6 @@ int rproc_add(struct rproc *rproc) if (ret < 0) return ret; - /* - * 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 2d575e6c9eb8..c152d11a4d3c 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -21,11 +21,8 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, * 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) + if (rproc->state == RPROC_ATTACHED) firmware = "unknown"; return sprintf(buf, "%s\n", firmware); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 4e107615121a..fe383392a821 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -510,7 +510,6 @@ 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 * @char_dev: character device of the rproc @@ -547,7 +546,6 @@ 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; From patchwork Wed Aug 26 16:45:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11739147 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 4AFE014E5 for ; Wed, 26 Aug 2020 16:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33D0B2078B for ; Wed, 26 Aug 2020 16:46:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qm/4WZiz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728067AbgHZQp6 (ORCPT ); Wed, 26 Aug 2020 12:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbgHZQpn (ORCPT ); Wed, 26 Aug 2020 12:45:43 -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 123F9C061799 for ; Wed, 26 Aug 2020 09:45:37 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id z18so1148413pjr.2 for ; Wed, 26 Aug 2020 09:45:37 -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=lYOgLwnu7WcXXfGvAZrIa+HvcswO98ITukkP4wr02mQ=; b=Qm/4WZizP1KnyzgrqrSHdleNAP9snMSeWa1K5KztBk5eaOiDE1sfr5M06EEs7mq51Q ojW3MSEtGwhKk0v0h5flQ3LUG8aI68i2z2HYgyTb8rNm6N3QTm2iqZbnPrVaUuPMeCum cqpoYqEHg3wO/Xc0VJMXnoCEbD8G82Eqnv9KsmcoaNAU00Xuz23+s7qmIJK5az0cXhio jy77TmnzR4OTRHk25OIsp6rz5RrlvgQe+x+JeEwjQyqrKROf2EqT0XIjUOeVEyHKvLsz AwILZNfUx/NmEXjBUnfUMdCAMWAPUFgM9Kmp9ehd+2DpSLHzR77lVA57Ujw3FmYtrIQa bqlg== 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=lYOgLwnu7WcXXfGvAZrIa+HvcswO98ITukkP4wr02mQ=; b=t3R0Ga5HMP4iqfSVTll65M4vCffcMfOi0nyOil2rT/LAMa8SIJO4+PGeMFs5vcvIWs gnh+t4eg01s+hv9Tb9GC6SGtmkQPrNZqTgIECNT+pXi6XRO1rfUiGw9AtrYoK8XBhi4p AVqdwr14R2pRP4yLn/Z0LBf2DBm+TPdqXRU/A5nk7g2U+qNaBbYvvyvSQTUAWxmpUd84 n2hjIcBnof7GhzlWIfDLBEwE4fuMv8pifFW+U9ao4miWVT27+BNwTQfG6ebHUK7Czqke lyMHS8uWgbs256VJpkzPAyKuhjmh59sSUQ6w+IsRROIUTkNoibMpL29qtzELyMc43P3W 5NAw== X-Gm-Message-State: AOAM531jZ+o14mRxvWc/C0ctWTbcwFGWQAd2bTzbWOUgn4Oka1fck2LU jlsDVNJLg5jAbislU0jNhij7R9lde0o1/A== X-Google-Smtp-Source: ABdhPJweiYXaAr9UZI8x6z3Q44YMLqlq8O7xiCK7/w7vL2hDv8FZ/av6l24rnOYusePiQaYrD9OW2w== X-Received: by 2002:a17:90a:39c8:: with SMTP id k8mr7142436pjf.19.1598460336599; Wed, 26 Aug 2020 09:45:36 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:36 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/13] remoteproc: Add new detach() remoteproc operation Date: Wed, 26 Aug 2020 10:45:21 -0600 Message-Id: <20200826164529.224476-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 detach() operation in order to support scenarios where the remoteproc core is going away but the remote processor is kept operating. This could be the case when the system is rebooted or when the platform driver is removed. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- include/linux/remoteproc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index fe383392a821..1a57e165da2c 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -361,6 +361,7 @@ enum rsc_handling_status { * @start: power on the device and boot it * @stop: power off the device * @attach: attach to a device that his already powered up + * @detach: tell the remote processor that the core is going away * @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) @@ -382,6 +383,7 @@ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); int (*attach)(struct rproc *rproc); + int (*detach)(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 Wed Aug 26 16:45: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: 11739145 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 9BC8614E5 for ; Wed, 26 Aug 2020 16:45:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EF552074A for ; Wed, 26 Aug 2020 16:45:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Baz4t0Ul" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726767AbgHZQpy (ORCPT ); Wed, 26 Aug 2020 12:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728008AbgHZQpn (ORCPT ); Wed, 26 Aug 2020 12:45:43 -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 168C4C06179B for ; Wed, 26 Aug 2020 09:45:38 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id y6so1154381plt.3 for ; Wed, 26 Aug 2020 09:45:38 -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=ge2KsJvwuhlm+r4J63UN3uyDACII1r8lxNC/L+4iQUs=; b=Baz4t0UlEiKvXXEcGCQFy1LCd7CA7ydvEsN9JNvj8Uu0iDUjh51jMX791NKnutvndD bcEchugiLEj7UdoF+fx/VNcpyA9R4IHkYAp8jlKGV6QCuFjDi9JNjhYU55VCDDKvYCbc ZtTJitekE4uxWOwd/4VJH50Ssa+b5kwDCs0eQD0jBz/xDLtjXFEd3zN5uZm8MylD+kiC RkClUWVTfOw2DSNB4X6m/MYqjmuJGBx/UV/78oF56kjbH11AS6W6wUoQxCDfSLl1f1O5 xNJ5bVnMC7kGhbtOPT2c4saUIh/5mn6fT9XQ4XHDvUVsKVtMuX31MWiUeHTO5xkeSXcr wesw== 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=ge2KsJvwuhlm+r4J63UN3uyDACII1r8lxNC/L+4iQUs=; b=G1HXGSu1DfogGq4+YhQiDppf3GhHXOLjbKzEF9W8Xr8cXgxvrGR6kwz+qn+qUBUzH5 C1ba6ZUuyAo94PcLatSvMiJ/03QmkXl2gEU5SCHnlYm5KEkbGaYD5JQDgqxfHbQusu5Y ed5VEltHs0uglQBS0oLz7DmTZ8s0xz5pfE9YcxqwZRmXgBlHICWOxywNMQ5r8GeRwZRy RpmKTfr3W4faJKEqBGt3X/phTtPE6sgIIX7abGBXlvqPqInx8CtCB8pduE4/HsqhYUMA hvY/iY+0pDrORxRRyhJ5wVTx/3k4T33fbCtGxU48GP+KYE8DTLjZFdAhtUzPXEowIrLW XNsw== X-Gm-Message-State: AOAM530IrvUL01UcvhBeuLSMnrZqzjzgtC6zboOgZWakb3FokNVt7Efa a057LbI75rGnzZWWpQT3JtmDug== X-Google-Smtp-Source: ABdhPJxDQFBQv8ALN+gaTkci32Mt/yvuWhIU99J28awxznb+Ef2mxlvE0Ze/xFwAAyI0jBo2Rp/2XA== X-Received: by 2002:a17:90a:8d84:: with SMTP id d4mr5023378pjo.165.1598460337657; Wed, 26 Aug 2020 09:45:37 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:37 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/13] remoteproc: Introduce function __rproc_detach() Date: Wed, 26 Aug 2020 10:45:22 -0600 Message-Id: <20200826164529.224476-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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_detach() to perform the same kind of operation as rproc_stop(), but instead of switching off the remote processor using rproc->ops->stop(), it uses rproc->ops->detach(). That way it is possible for the core to release the resources associated with a remote processor while the latter is kept operating. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index bffaa9ea7c8f..7a1fc7e0620f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1641,6 +1641,37 @@ static int rproc_stop(struct rproc *rproc, bool crashed) return 0; } +/* + * __rproc_detach(): Does the opposite of rproc_attach() + */ +static int __maybe_unused __rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + /* No need to continue if a detach() operation has not been provided */ + if (!rproc->ops->detach) + return -EINVAL; + + /* Stop any subdevices for the remote processor */ + rproc_stop_subdevices(rproc, false); + + /* Tell the remote processor the core isn't available anymore */ + ret = rproc->ops->detach(rproc); + if (ret) { + dev_err(dev, "can't detach from rproc: %d\n", ret); + rproc_start_subdevices(rproc); + return ret; + } + + rproc_unprepare_subdevices(rproc); + + rproc->state = RPROC_DETACHED; + + dev_info(dev, "detached remote processor %s\n", rproc->name); + + return 0; +} /** * rproc_trigger_recovery() - recover a remoteproc From patchwork Wed Aug 26 16:45: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: 11739161 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 59AAA1751 for ; Wed, 26 Aug 2020 16:48:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BBC02080C for ; Wed, 26 Aug 2020 16:48:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nMLNjq8y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728037AbgHZQsT (ORCPT ); Wed, 26 Aug 2020 12:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbgHZQpn (ORCPT ); Wed, 26 Aug 2020 12:45:43 -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 20B67C0617A0 for ; Wed, 26 Aug 2020 09:45:39 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id mw10so1120118pjb.2 for ; Wed, 26 Aug 2020 09:45: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=PNFft0GFzwMNPipG6PxUltilEz9gyBFGoUVi1I8lj4Q=; b=nMLNjq8yjm/NUynPzx37UUN9LqO3b27Jf++W8JLhDrjddCoJMAFPApmaVpsY6VrM7u xq/L4oBUsy38SMEIU2cyaIsp44HuUlgmZBYIj6G8uO+76QHGFCI/qxWK28uXsjrBeYM4 EBfdP0ZJeqOkliiX9A6yTH0HwDy3JIKO/x2Vy8vndeFHkLHDN+W0lPqYoCNu5cIWSddx 2d35R31AOfNwu4etj7+guYWGUz9IQM33sr/pJIAQUY7MkHmThG9rT7ZeyyY1OrTfbOqY Lq8NJvePTZZxR9sIzfy+aXfm4lylDezwswwAGdXvnRp1xKyFeh+yqpopC/VILgI8dW/2 81ZA== 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=PNFft0GFzwMNPipG6PxUltilEz9gyBFGoUVi1I8lj4Q=; b=syk513lbbPzYiVRzXb9eZPfnaaPWDW5nR6PibbFp72baOwE0VJt+wR8kXBBRZZLH2x PvnfmOYy0vu0lQ22dgZVrhamLN1DLrBUEGoapagEyJ6ZUYnrStA9TSOO5znGEj29tF8N 6mhW2fS9IgamX/yJDp40VEO3WQXzFdPKV6u4E9Mor8kX1WLKTWoKfI/fVgumcLInHngr wX8VxRTnZa3e497ovaLlZTmNFNv74KGSXJtM7N5m+WXarBxp/9RJ/Sa/9hL+1r8S/0jQ APshI1a+yO7FEbaj5HD1idSF7gg7N7DBrLK6DIpwjDF8lu1Dq+U5tLsmePuRTkPrXCIR WVMQ== X-Gm-Message-State: AOAM533iSoyKz+I0n0LuUz8bjATmPCSZNDjACk4B4scZkTrsPRMkyCKs eu+I6M+uwZFpUlk/+/wC9ymNBg== X-Google-Smtp-Source: ABdhPJy1MJxT7kKGzzFPpIVippgTa9e/nZKttQoTzJf1s3N5NpD6NJUh9Oeyl9EmUFcR4xSb8qD7qg== X-Received: by 2002:a17:90a:1955:: with SMTP id 21mr6700880pjh.230.1598460338618; Wed, 26 Aug 2020 09:45:38 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:38 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/13] remoteproc: Introduce function rproc_detach() Date: Wed, 26 Aug 2020 10:45:23 -0600 Message-Id: <20200826164529.224476-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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_detach() to enable the remoteproc core to release the resources associated with a remote processor without stopping its operation. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 65 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 1 + 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7a1fc7e0620f..f3943a1e2754 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1644,7 +1644,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed) /* * __rproc_detach(): Does the opposite of rproc_attach() */ -static int __maybe_unused __rproc_detach(struct rproc *rproc) +static int __rproc_detach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1887,6 +1887,69 @@ void rproc_shutdown(struct rproc *rproc) } EXPORT_SYMBOL(rproc_shutdown); +/** + * rproc_detach() - Detach the remote processor from the + * remoteproc core + * + * @rproc: the remote processor + * + * Detach a remote processor (previously attached to with rproc_actuate()). + * + * In case @rproc is still being used by an additional user(s), then + * this function will just decrement the power refcount and exit, + * without disconnecting the device. + * + * Function rproc_detach() calls __rproc_detach() in order to let a remote + * processor know that services provided by the application processor are + * no longer available. From there it should be possible to remove the + * platform driver and even power cycle the application processor (if the HW + * supports it) without needing to switch off the remote processor. + */ +int rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = mutex_lock_interruptible(&rproc->lock); + if (ret) { + dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); + return ret; + } + + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) { + ret = -EPERM; + goto out; + } + + /* if the remote proc is still needed, bail out */ + if (!atomic_dec_and_test(&rproc->power)) { + ret = -EBUSY; + goto out; + } + + ret = __rproc_detach(rproc); + if (ret) { + atomic_inc(&rproc->power); + goto out; + } + + /* clean up all acquired resources */ + rproc_resource_cleanup(rproc); + + rproc_disable_iommu(rproc); + + /* + * Set the remote processor's table pointer to NULL. Since mapping + * of the resource table to a virtual address is done in the platform + * driver, unmapping should also be done there. + */ + rproc->table_ptr = NULL; +out: + mutex_unlock(&rproc->lock); + return ret; +} +EXPORT_SYMBOL(rproc_detach); + /** * rproc_get_by_phandle() - find a remote processor by phandle * @phandle: phandle to the rproc diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 1a57e165da2c..6250491ee851 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -656,6 +656,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); +int rproc_detach(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); int rproc_coredump_add_custom_segment(struct rproc *rproc, From patchwork Wed Aug 26 16:45: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: 11739159 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 95AA61751 for ; Wed, 26 Aug 2020 16:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E8822078B for ; Wed, 26 Aug 2020 16:48:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nXRZ7wbX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbgHZQsT (ORCPT ); Wed, 26 Aug 2020 12:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728037AbgHZQpn (ORCPT ); Wed, 26 Aug 2020 12:45:43 -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 325C7C0617A1 for ; Wed, 26 Aug 2020 09:45:40 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id w186so1316695pgb.8 for ; Wed, 26 Aug 2020 09:45: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=dL9tfSUkFyPuvtiKmoHXxOSSKMmvouLhdaI7n7GXPMo=; b=nXRZ7wbXj6Yjj00jDZ4A8PJU7BVP76i8CVaoyZQ9eIBNGejqdVLMw/2FcEtskj4o8s uAc22g/QyUXcuwZj0/8uLoFXmOhJgaoNv/PnmWKksjMGMS/AcrBWR0cuucf+iIyunae/ C3J0Vk1p54uOJglqvINLZdlNs7a5c1wkqSZxRhaIrx4RqRbFdrDbSdEcMH4Ebxo2q+QB UoqjTzVU8pXwf9tetqpqeL/p/1kulqSdFdAz7o4skGUxg6Z+hY5Dr7DjUZdTTWId4JYq jied080lnmYvxfszbWLJJw5h5dTtiC/EUgcz9SacdOSoDeN/hiVKrBIUhgn8aFEx3qFO S0mg== 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=dL9tfSUkFyPuvtiKmoHXxOSSKMmvouLhdaI7n7GXPMo=; b=WhtamPEYddR0+ihHbzfnFaaR+YIC8j6XoO/1PDt0FNdhuOg4yyRLgDpzGgeoMjNGdY F35j/nzGKsVsaslF+sySrOI712vGeIT0jULiWIQQJrLuFOG4LLNRnezuqkP/zR5Zussx eHtyjJhxzwbQYNb6EIVpobUq2VHVs9fOPZILjhsq8CfZf85QygHe9K6QDetbZxxrTg6J +uKhipIcw+q+0FtNOsXlRsjtmwHmOVfjnNN3jPileDM06i9x0/vVOVqghKKrpdqUpqpY M2OHDr6M69Or5hnIMRPe6LHjtFpZ+8YB06K/7c4LnQVPgMmv5Y1j9bZPMCk8zypK8GQY RmTg== X-Gm-Message-State: AOAM532RbIlObv1DbLHJTAbNE+zxa9ujtYrRDq1vgl7Drs9LY40JJdrJ QMRor4MSoam5drwM1gdxSp9j5lNhzRzutg== X-Google-Smtp-Source: ABdhPJzuZQ1lIacAimgfc2XPYOHki9uGBagGms3yAZQ+2MT+AfhexnSds4k4Pz5q9j1hYN3kf9HRzw== X-Received: by 2002:a62:cf85:: with SMTP id b127mr13145936pfg.89.1598460339728; Wed, 26 Aug 2020 09:45:39 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:39 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/13] remoteproc: Rename function rproc_actuate() Date: Wed, 26 Aug 2020 10:45:24 -0600 Message-Id: <20200826164529.224476-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 Align what was done for rproc_detach() by renaming function rproc_actuate(). That way it is easier to figure out the opposite of each functions. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f3943a1e2754..c4b80ce6f22d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1393,7 +1393,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } -static int rproc_attach(struct rproc *rproc) +static int __rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1518,7 +1518,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 rproc_actuate(struct rproc *rproc) +static int rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1558,7 +1558,7 @@ static int rproc_actuate(struct rproc *rproc) goto clean_up_resources; } - ret = rproc_attach(rproc); + ret = __rproc_attach(rproc); if (ret) goto clean_up_resources; @@ -1802,7 +1802,7 @@ int rproc_boot(struct rproc *rproc) if (rproc->state == RPROC_DETACHED) { dev_info(dev, "attaching to %s\n", rproc->name); - ret = rproc_actuate(rproc); + ret = rproc_attach(rproc); } else { dev_info(dev, "powering up %s\n", rproc->name); @@ -1893,7 +1893,7 @@ EXPORT_SYMBOL(rproc_shutdown); * * @rproc: the remote processor * - * Detach a remote processor (previously attached to with rproc_actuate()). + * Detach a remote processor (previously attached to with rproc_attach()). * * In case @rproc is still being used by an additional user(s), then * this function will just decrement the power refcount and exit, From patchwork Wed Aug 26 16:45: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: 11739149 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 2C2CD138A for ; Wed, 26 Aug 2020 16:46:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14A8A2074A for ; Wed, 26 Aug 2020 16:46:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="llSh/MRQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbgHZQp4 (ORCPT ); Wed, 26 Aug 2020 12:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728067AbgHZQpn (ORCPT ); Wed, 26 Aug 2020 12:45:43 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BC51C0617A3 for ; Wed, 26 Aug 2020 09:45:41 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id b11so1153872pld.7 for ; Wed, 26 Aug 2020 09:45: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=YL/Sg/ido3nRXf9+K+B0ZGztjS76f+wRUkN5ABypJJk=; b=llSh/MRQjoPCkFBUmv+ZHdNFCA9rxTof14asW/mqtl3PbCW0jhUZmFnVCB8kF1AX1x 0h8OMb88w4G9oqHicx/VgeqPNyllOsMxcGY7YMM9g3JYCWHqpfmM0goIE/wiJsus9cNc 58ufuaIggowlZopT9LCbePIDt1IP4A6MoXseqEKqbXv0xympsV3/pU1m9mr+U6+V7k38 BJxlygn/eRUsMIQn0YmRbWCZ+tvYKaAcwFVqRi9rLUniTHbyCk+qSm27Lkb8ECzOW/wE oAMLp2VBQjDZcjrsgLQjc1K557kNeIr4cW8Sn+FAtDMYdFiAuOJhmh3TZrWdeeID46gP frcQ== 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=YL/Sg/ido3nRXf9+K+B0ZGztjS76f+wRUkN5ABypJJk=; b=K9KxTuLHEXsS3EqBPZihjiUykEpRjGDWvpWfCf1j7jWu/GxOadBYeoMg0t4oile/U8 +1bjPhgVa3cxImc6NQeyTTuPPduhv/lQNuEZDTqorY+ZaZrlTzVGBgTW93QAz/cLvUkl 05gqcq5jKuSHYK8vlAHLogQMi1mjiKIH8GIG39cpkv2XYOk65itpZqla2HNAZ/ZPJ+DU aKXz6NjQOs7cRHqllxpcqpiGIJMqwY96W4Hh/iXXSYMhDuNbfGi/kK8PMBI5dXgJ35W+ veD0Te0u2GLpPZpoUusRGUIsP1l7hwH6i8qgnbyhgDFGo4ATJyn7izb8PSA8DtWm2vJD +XWA== X-Gm-Message-State: AOAM5336ia7nN7oiR70VjSHdG/yY7tYw1CjKZGKr+d722Ftjfhe62WM9 BnhKrVZQ9yIN7/o9ZIT7GItihw== X-Google-Smtp-Source: ABdhPJz4bgJ9Qs3HN3AeYmZDXALGjdQsejVr1bJ0QB/xxzkWFOR1280yNygLNcyehVIf7qJEfvii5A== X-Received: by 2002:a17:90b:3688:: with SMTP id mj8mr1724768pjb.141.1598460340708; Wed, 26 Aug 2020 09:45:40 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:40 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/13] remoteproc: Add return value to function rproc_shutdown() Date: Wed, 26 Aug 2020 10:45:25 -0600 Message-Id: <20200826164529.224476-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 return value to function rproc_shutdown() in order to properly deal with error conditions that may occur. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 13 +++++++++---- include/linux/remoteproc.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c4b80ce6f22d..c6c6aba66098 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1846,7 +1846,7 @@ EXPORT_SYMBOL(rproc_boot); * returns, and users can still use it with a subsequent rproc_boot(), if * needed. */ -void rproc_shutdown(struct rproc *rproc) +int rproc_shutdown(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1854,15 +1854,19 @@ void rproc_shutdown(struct rproc *rproc) ret = mutex_lock_interruptible(&rproc->lock); if (ret) { dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); - return; + return ret; } - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING) { + ret = -EPERM; goto out; + } /* if the remote proc is still needed, bail out */ - if (!atomic_dec_and_test(&rproc->power)) + if (!atomic_dec_and_test(&rproc->power)) { + ret = -EBUSY; goto out; + } ret = rproc_stop(rproc, false); if (ret) { @@ -1884,6 +1888,7 @@ void rproc_shutdown(struct rproc *rproc) rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); + return ret; } EXPORT_SYMBOL(rproc_shutdown); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 6250491ee851..40eccfbc1357 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -655,7 +655,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, u32 da, const char *name, ...); int rproc_boot(struct rproc *rproc); -void rproc_shutdown(struct rproc *rproc); +int rproc_shutdown(struct rproc *rproc); int rproc_detach(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); From patchwork Wed Aug 26 16:45: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: 11739157 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 2A6B914E5 for ; Wed, 26 Aug 2020 16:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 120AE2078B for ; Wed, 26 Aug 2020 16:48:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UdinP/Yb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727877AbgHZQsR (ORCPT ); Wed, 26 Aug 2020 12:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgHZQps (ORCPT ); Wed, 26 Aug 2020 12:45: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 2F107C0617A5 for ; Wed, 26 Aug 2020 09:45:42 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h2so1154611plr.0 for ; Wed, 26 Aug 2020 09:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wk7DlN4RR6k6lg+nX/WYTS8+aJhqAF/kFILSCMp8TGw=; b=UdinP/YbA0u1t4KDbjuAf+r71DAWjgY3RPz9ZScLNzkB7tPAhMeHX9QmzC9malvaJF hoj9Qwbdr4GuV/WOxVpVYRdSZi46IYmQXewQvgP6oA1/VfZ6BFNX6Bd9YHSeErmBJqv8 yiP3pd4ykmjYYOi/+0ds2XovLu2/QdPHghSjYtKuw5i8xKHp5waepuCI/l2+9IciBIJd 3wI5yo+0meEJJg5WPfOX/Zx/4R4WNhVfcFKPW7GQ6fVFsmsvcXUjO16zSVY7TJph+RUC WPwsHa7jskkpIjIuBp1MnDdy9KRecBHrpp8IBOMggvj7+3+aTWG/1gSXa5fistCF+sx7 Kg1A== 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=wk7DlN4RR6k6lg+nX/WYTS8+aJhqAF/kFILSCMp8TGw=; b=X5Doh4usYNPX7jRXsX2HD5V2xQK3+Kf8QuXD5FrINo7TBIuot5yQPxPtedtNqE9nu+ hjK2Lpz/vRXz/Or2+q3ijytgbFT9rKzUwM5skz57OvTE65lBGOQphpPrapcug0tlfvXu n/Qs/+jInNDTgvn7oWUQIfnHJRlWJZoq6w3MLR/UZj05pD4Ak4y6vLllM2lWLM4Y5O2o ots9NupM9aIM5n+G5iYCWMn3u6heBSHsBewrMQaY2kEEocuAr9m/5TsFpiaF7owk+qyD mU8TBaTpC90pHflDxfMo1o2IhAnJ7HHraElH89nAEYNoo2K+4iQvVZCF64hgfZQwLApI TGqw== X-Gm-Message-State: AOAM532euA3TbRqOUIl7Q8RhlTh+IxWgDelO+6948HClA1NeQX++isDE SvOI1bUjg1PYdWs1KmQjD6IOAw== X-Google-Smtp-Source: ABdhPJwFq1VHZ9E5J6KXkMZQVDNWMO5HD2gW4DuTbXKm53qunGivmzlikr0J4TcdsZaxi16+X87t0w== X-Received: by 2002:a17:90a:d908:: with SMTP id c8mr1106186pjv.4.1598460341768; Wed, 26 Aug 2020 09:45:41 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:41 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/13] remoteproc: Properly deal with a stop request when attached Date: Wed, 26 Aug 2020 10:45:26 -0600 Message-Id: <20200826164529.224476-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 introduces the capability to stop a remote processor that has been attached to by the remoteproc core. For that to happen a rproc::ops::stop() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_cdev.c | 5 +++-- drivers/remoteproc/remoteproc_core.c | 6 +++++- drivers/remoteproc/remoteproc_sysfs.c | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b19ea3057bde..d06f8d4919c7 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -37,10 +37,11 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ ret = rproc_boot(rproc); } else if (!strncmp(cmd, "stop", len)) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); ret = -EINVAL; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c6c6aba66098..95bb40b4ebb3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1619,6 +1619,10 @@ static int rproc_stop(struct rproc *rproc, bool crashed) struct device *dev = &rproc->dev; int ret; + /* No need to continue if a stop() operation has not been provided */ + if (!rproc->ops->stop) + return -EINVAL; + /* Stop any subdevices for the remote processor */ rproc_stop_subdevices(rproc, crashed); @@ -1857,7 +1861,7 @@ int rproc_shutdown(struct rproc *rproc) return ret; } - if (rproc->state != RPROC_RUNNING) { + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) { ret = -EPERM; goto out; } diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index c152d11a4d3c..6134d2f083ce 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -113,10 +113,11 @@ static ssize_t state_store(struct device *dev, if (ret) dev_err(&rproc->dev, "Boot failed: %d\n", ret); } else if (sysfs_streq(buf, "stop")) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Wed Aug 26 16:45: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: 11739155 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 3ED7C14E5 for ; Wed, 26 Aug 2020 16:47:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 259832078B for ; Wed, 26 Aug 2020 16:47:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="u4MqR1kf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728228AbgHZQrv (ORCPT ); Wed, 26 Aug 2020 12:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728115AbgHZQps (ORCPT ); Wed, 26 Aug 2020 12:45:48 -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 2D847C0613ED for ; Wed, 26 Aug 2020 09:45:43 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id s2so528120pjr.4 for ; Wed, 26 Aug 2020 09:45: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=vD2rRkpHQd7S7fgYM9UtluBQRAWNlF6cNXgHEuKBTDo=; b=u4MqR1kfjSxsFjxQ0PC6CVjxgQW0LN3TJ+f5D5WxPBbfYC7VvbcnbDe6a2bsjweMD0 zqA0IvUIthS4sUphaqwCH0nFieEOcHnKksL0wv2C9jzLeZUP6R7/VnUoG5X0fDF/Zort O6tTF023b0+CKYMxv1qDpgPMNneIPHm8Js2tzpU7KU2SwgUqeSP8ZUBIryDQ/VD8kTcB Iah0xIR/R0yB9nB1NY/Ue3ZnarEhN+fkVgmGGKsVP7Yuw4/iSSTjTmCOLH1FpaASL3T5 J9eD7F7tlXchyJQSE42YPgiBpdC7nM5HbjRZE5W/hKT32qW+jk36o9D9MI00tNeNGSSA 5D9w== 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=vD2rRkpHQd7S7fgYM9UtluBQRAWNlF6cNXgHEuKBTDo=; b=ReDpblDbrWMDjktQmOIEopKrFaHT73Aj7x7KPIe5AR06NZCjytKdd9yMEng+e8ogcI 0UOsQ0EsXSu/4l4NF15VkXcbKWHGXGLNjrFbRQl3VqGye3zOT54RL3GloaF7Z1rYbZVg E7whpdM1ddYR3WVQxtxVa8QpiLmAnXrJUCyScwDh01c/5xxEZFEYL3feGJvGFuZxdlma MX3dEMVykdKkpHlOraiFvg91kZMi6ePzesLNlm8qLlerFryivtvddHjwIYO1Ct8sin7m BHzNsKqfEPjad4ROmXqZF6k6oTa0Gav33OSlUes2L0TqFaWO6ytxP+rNAbqTOznUdMuG 4egA== X-Gm-Message-State: AOAM531XVv4ISFjDQrkmmbwmvJxAAIwETMiEPzYDFpZk+b1dS16zS/a1 AtMqkGc8tBVlUPfMJZk0P4WFGw== X-Google-Smtp-Source: ABdhPJwLOPNkqm5e+DQ+X7A/oEpZmAGhLQhscSDhlh/mGOryZjdpE/jnG4AFfe2aiQaYUUcS6lZ34A== X-Received: by 2002:a17:90a:d3c2:: with SMTP id d2mr6797133pjw.112.1598460342752; Wed, 26 Aug 2020 09:45:42 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:42 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/13] remoteproc: Properly deal with detach request Date: Wed, 26 Aug 2020 10:45:27 -0600 Message-Id: <20200826164529.224476-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 introduces the capability to detach a remote processor that has been attached to or booted by the remoteproc core. For that to happen a rproc::ops::detach() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index d06f8d4919c7..3a3830e27050 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -42,6 +42,12 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EINVAL; ret = rproc_shutdown(rproc); + } else if (!strncmp(cmd, "detach", len)) { + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); ret = -EINVAL; diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 6134d2f083ce..013231f69837 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -118,6 +118,12 @@ static ssize_t state_store(struct device *dev, return -EINVAL; ret = rproc_shutdown(rproc); + } else if (sysfs_streq(buf, "detach")) { + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; From patchwork Wed Aug 26 16:45: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: 11739153 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 57F5B138A for ; Wed, 26 Aug 2020 16:47:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 403C02080C for ; Wed, 26 Aug 2020 16:47:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k+qNTns/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728216AbgHZQrk (ORCPT ); Wed, 26 Aug 2020 12:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbgHZQpt (ORCPT ); Wed, 26 Aug 2020 12:45:49 -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 42451C061795 for ; Wed, 26 Aug 2020 09:45:44 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id nv17so1144838pjb.3 for ; Wed, 26 Aug 2020 09:45: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=oxBIu0NnSAiLhfjGgDwxzLw/4/EIRT2u79pWVsdwMLg=; b=k+qNTns/opkjJEZ2Dfhp3nSo+/gW/l2mqzUB7ZbUnn1SNzUJkPTwH85YhOHspy5Vzm 8C9wf8/Fd1RmmE1VOJ6mzWgbzVHJJxiF/O6nCczbJWfkB8iAkjc0ABmO2n4fWC38V+3s BzxF3qvJtruDwI6eBJMgLFBei+5H23OQsItgXm5BhM/wP5PU0e13zhErdowD2rtvN01U YwtSnXT8idDk1mrJl/WS+YHu/eq/oYezZMR5Tr8PCDtJTA0j5Mh/rG5Cr9FSUtztzxyj yZRvbD2PyEjw7yGVLtIh4QWTABpdtvrsR7SWP2Xl3oJZbgV+uWPqgTS+BUXIz8hrN2S+ imdQ== 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=oxBIu0NnSAiLhfjGgDwxzLw/4/EIRT2u79pWVsdwMLg=; b=b8ka65x8HuKqKSzRk0r2aar9dC5MPoseLaTBpek1bZD7wUd6EUlzfOONhh2W355rC4 prtpGJsZ2ixV+sezoM2cV75ambVJLQ6Ub4tZoSFEIZCj1QhUuOV3bQCTrn9RTDoMb/9w ocrDQ7JJnekpEY8nwiGHS464IkD5QT821q2mP08k3Qb7QzdaJyvNYeP6WB0s24XW0vZY ED0QCb6qmq+Xd+rcroWsqPuFxCJkav+Fwn6Y/odBKufu73nm6iDO/Yn5fyZH9CcZU/lx M2+WGQXVtzobXHYIVdhcDeyGSXvcfwM9wKHfPKKvjVL6HmtraxrcL+jtRuqNJdFiALAm FOXA== X-Gm-Message-State: AOAM532QH83UeFQ/hr+5zj9aiwvBqAhQadeQXmhxysM7paMSUKeklcY3 oixpeogf7ChQfuATU8MzUpinMO3gOo95CA== X-Google-Smtp-Source: ABdhPJw1FGuVfhmWkCr4RLXbFoDk8hnd4hktva/TxRidLNKsDXaL4s5yS4kF0snQuBUj1uaNtUJeMA== X-Received: by 2002:a17:902:7603:: with SMTP id k3mr12394135pll.113.1598460343792; Wed, 26 Aug 2020 09:45:43 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:43 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/13] remoteproc: Refactor rproc delete and cdev release path Date: Wed, 26 Aug 2020 10:45:28 -0600 Message-Id: <20200826164529.224476-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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_del() and rproc_cdev_release() to take into account scenarios where the remote processor has been attached to. If the remote processor has been started by the remoteproc core then switch it off, and if it was attached to detach from it. This heuristic is simple and can be enhanced easily if there is a need to. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_cdev.c | 7 ++++++- drivers/remoteproc/remoteproc_core.c | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 3a3830e27050..18cffbe588c1 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -87,8 +87,13 @@ static int rproc_cdev_release(struct inode *inode, struct file *filp) { struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev); - if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING) + if (!rproc->cdev_put_on_release) + return 0; + + if (rproc->state == RPROC_RUNNING) rproc_shutdown(rproc); + else if (rproc->state == RPROC_ATTACHED) + rproc_detach(rproc); return 0; } diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 95bb40b4ebb3..5586582f54c5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2346,7 +2346,10 @@ int rproc_del(struct rproc *rproc) return -EINVAL; /* TODO: make sure this works with rproc->power > 1 */ - rproc_shutdown(rproc); + if (rproc->state == RPROC_RUNNING) + rproc_shutdown(rproc); + else if (rproc->state == RPROC_ATTACHED) + rproc_detach(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; From patchwork Wed Aug 26 16:45: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: 11739151 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 88166138A for ; Wed, 26 Aug 2020 16:46:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FA20214F1 for ; Wed, 26 Aug 2020 16:46:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="J+4aQEtM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbgHZQqq (ORCPT ); Wed, 26 Aug 2020 12:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728130AbgHZQpu (ORCPT ); Wed, 26 Aug 2020 12:45:50 -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 3A869C061797 for ; Wed, 26 Aug 2020 09:45:45 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id k18so1264816pfp.7 for ; Wed, 26 Aug 2020 09:45: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=Tv4kkgaRKTSg5mtSljLIfWbV/kKMUzinzR1WF6eOzEg=; b=J+4aQEtMWRdEKu9phF530PTZGUl/xpTYrzdCpeHbB+8t4qEY57QZZ57Oy0uPAG7nWx 4o1yCxg/bHvHeUri+8M0acPYPfr4CtxUJh5903KOR4u2OSWncpgRUzGawcbXVZ+UX3NC uyqfGC7n8eDOLw/mt2lHyNZq35ay3Dv7HTxUNXpgAa+7aVb9IAQgHUOPWw9J3RZi0my2 9Ghv7Soy2weYsjF3W4KQ+m/rX+jwIpGLFwkr1JjOH2R8eENS0dYzpmE4chQDSw6TlNn7 2wVCYXB6Jo/RUhdA8a9m7+P3piMKVs3mHmP54Vi8b92dfQv7zzr57oeQuGFoZOaYcJ3T 6tsA== 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=Tv4kkgaRKTSg5mtSljLIfWbV/kKMUzinzR1WF6eOzEg=; b=qozEBxLIv7bnNg6Br6Dq75N5bnLljABnijfJAqQlC1mQwFr2rLjWwMhBK/XWyFf7GT uYwbJdk80az+1OEqBXuC3ierXVXi2eVb9fJkljl4772pweDxmj7YVOUGi4rXsBmyI+z0 dYzzrd78M1KUr+oBxA/efK3X90SuG0hjKptrL3RtPjOBsw3L7NUG+KJt2FfcaPoTqzW3 Wo8hm90O1cGkChMrh5pYKuy1HhTHxxJ0KYFLnLA8nCk8h1Lh0LMjv1AW7kcw40xbGU84 p7JU8QXWkJFLptJbMCE+DfmZtBLKyRqvfEtUxqktL49hhh4IV7EADivQO06SgG5ITsj8 TgZA== X-Gm-Message-State: AOAM532NyCdkzIv3D25oh+3r0HlbVcaeMB8fm6Z0f5gxACpxZ5/78Mc7 88uEwCTudTyE9Y4Vzmzgaap5cg== X-Google-Smtp-Source: ABdhPJxyzlVX/8Rvvcg9V+qehVKYMWuW/NjS+sBb919BgJbJyrH7K1Tk5T+Ui8lWqsfYm9kSDScjwQ== X-Received: by 2002:a63:1d01:: with SMTP id d1mr6076566pgd.437.1598460344844; Wed, 26 Aug 2020 09:45:44 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:44 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/13] remoteproc: Properly deal with a kernel panic when attached Date: Wed, 26 Aug 2020 10:45:29 -0600 Message-Id: <20200826164529.224476-14-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-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 panic handler operation of registered remote processors should also be called when remote processors have been attached to. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5586582f54c5..54b5e3437ab5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2491,7 +2491,11 @@ static int rproc_panic_handler(struct notifier_block *nb, unsigned long event, rcu_read_lock(); list_for_each_entry_rcu(rproc, &rproc_list, node) { - if (!rproc->ops->panic || rproc->state != RPROC_RUNNING) + if (!rproc->ops->panic) + continue; + + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) continue; d = rproc->ops->panic(rproc);