From patchwork Tue Jul 14 19:50: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: 11663449 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 0F30760D for ; Tue, 14 Jul 2020 19:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6591224D2 for ; Tue, 14 Jul 2020 19:51:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vNSwVeB9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729605AbgGNTuk (ORCPT ); Tue, 14 Jul 2020 15:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729485AbgGNTuj (ORCPT ); Tue, 14 Jul 2020 15:50:39 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08C24C061794 for ; Tue, 14 Jul 2020 12:50:39 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id l63so8039500pge.12 for ; Tue, 14 Jul 2020 12:50: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=QuxJqBKRxLtj9joa7Fr05cH1nky6BP1NPkwydOl8hTU=; b=vNSwVeB9BGDWeBmn0zAOC1RJPtkDWODCQ2dc09UEnMBV9Us0uuWyuXliTjXG71Z26N dByrIDO/0wSu46SGAeypd2TDqRxKpAHdINXuMTE7hmGcjPujI90fLsd5oK6tQndskxCd /Z4VBzjqAfPWGlmz4LLwOqVh3U1/yW7C/Hmp3nyC1BiyqBuT0r2hLEJPz7khuqc66vOP Jlvw0JbqK4ywp1aqHxI6feIBh74xVuFQsDCpNB/CG1YyWBEAccEwaEno51gc7XXHIpIL KyjsWABr6j0+koAmbqsNtvdo8dKdYp3e/VYsV0sSn+bMdMuQmIxNzNJsRrfSO/R6aAr8 eM0Q== 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=QuxJqBKRxLtj9joa7Fr05cH1nky6BP1NPkwydOl8hTU=; b=ofuxiUcfMeZHrvBmdg97pDdzXvOEkI5xNS7wNapFS48ojuuwOn0OYHhMfgG1Hs3GHU 1xAiK1cwM+uf6QEpGpZ8zlAKcA4DPjl+qzZhO5VHTPgmymL5NI2ZBMbzE2NZUsEQAaNy 0wrNCQF2CQBCAJE8bQAKdTNvqOdNhV2lq7+Dj8c10ei6T0ZKxfWngEdDnvZ7BzBKPu4I NdxCMID6t08eAWIOaovOdmnI2Qa5onmkaWw4WHNP6JeOK99d2KwRr3FWy2gtvjj0Fmpv IAUxsDHFqoBO9rehBKvh9h0qbFqU7vKPEH/58mH/GQgsugj+jiRTQUK08872JwVeN2yw myFA== X-Gm-Message-State: AOAM532yAQx1cQ9aMQKpUatFAdFBMPRAmE0VhOcf12d0XSGFVqWdzemY 6dfB3kVbUcqw46fpv1EwEDNcog== X-Google-Smtp-Source: ABdhPJwhgswbKovs42U/OOB3jrsphvWgiWeGGx/Ndgg+PiZwOxz9VRZzNcHr7attqnGpMmMwTpFNaQ== X-Received: by 2002:aa7:9736:: with SMTP id k22mr5465615pfg.62.1594756238551; Tue, 14 Jul 2020 12:50:38 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:38 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/9] remoteproc: Add new RPROC_DETACHED state Date: Tue, 14 Jul 2020 13:50:27 -0600 Message-Id: <20200714195035.1426873-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a new RPROC_DETACHED state to take into account scenarios where the remoteproc core needs to attach to a remote processor that is booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 52b871327b55..264759713934 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -72,6 +72,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e7b7bab8b235..21182ad2d059 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -400,6 +400,8 @@ struct rproc_ops { * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery * @RPROC_DELETED: device is deleted + * @RPROC_DETACHED: device has been booted by another entity and waiting + * for the core to attach to it * @RPROC_LAST: just keep this one at the end * * Please note that the values of these states are used as indices @@ -414,7 +416,8 @@ enum rproc_state { RPROC_RUNNING = 2, RPROC_CRASHED = 3, RPROC_DELETED = 4, - RPROC_LAST = 5, + RPROC_DETACHED = 5, + RPROC_LAST = 6, }; /** From patchwork Tue Jul 14 19:50: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: 11663453 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 F398260D for ; Tue, 14 Jul 2020 19:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7BE7224D2 for ; Tue, 14 Jul 2020 19:51:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hlyWX+HO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729619AbgGNTvQ (ORCPT ); Tue, 14 Jul 2020 15:51:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729577AbgGNTuk (ORCPT ); Tue, 14 Jul 2020 15:50:40 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A38CC061755 for ; Tue, 14 Jul 2020 12:50:40 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id a24so2411495pfc.10 for ; Tue, 14 Jul 2020 12:50: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=PxMPjmCidB1VqxktAlXIXRqqTAOgcw26S01KAMxl9kw=; b=hlyWX+HOr/q+if9cMIgEmThC1u6vQtcFud5LQqCelC4HuFCu0EpDkdF9xErUX07pSQ D4eJkOOxFaXUHcz+ItpZp2f7hpPEJUV/CGnl3lAWsTJc02JO2ZHJhDGllw5jKtLsbGi1 xXsVZx3woaivaAzQXFUVidaqrx58bvxNSIuaaNrX3JySm+WZIUf21PV70kYJrQGcsTQp eQbOMUIj7sUvcB+jRECcStioJVoEX60Fc4MwZUIC+lYW4M/LdX18iIu7tSrTHge6GERS YMGOggkkhmnVei1AFpO+crOJWuKZLcIcdu8yoHjXPv2xSreiqw+lD2DFLkPfVvrlqdda tgbQ== 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=PxMPjmCidB1VqxktAlXIXRqqTAOgcw26S01KAMxl9kw=; b=tkuX5slTaYM6ChZqIr4LK3lG+9C0KPTAlNhEoUllfLwTOQOkSVoetM0y92HVCvMou5 IOllMPlKCEqjqaVK1eYol2DcNXSEaVARUpSe71yhzMTudSVQIiWgdXbng/jlNROzXB7i 0fTkflKH6zfevepZK8dMl78lGoDtjwOsxI0IxseBxm3sqwLok7MmHIMrcgc9IHaWzw/V dpPB9RoFqpAOkuDDPaxHvMGrts6MMsbgM+8zn61okRSHyM1+pHtGMIvMEbzDFJL0Qal3 DwgZtTmfcxulOzTLjmSjjKxasJCc9FCS9kDcoUUw5SSqY3b0XKU1WWsyrzpfabus3W3M AYVg== X-Gm-Message-State: AOAM530YcajiQ/iPTp90VS3B73Xc/HYs9v+MmiR2IzT0krBJ+lRWq1w+ px1eelnfgu+4TMUUv2HNvsgMZQ== X-Google-Smtp-Source: ABdhPJx3LAse7Jrv+E7Mxy835Oc9uLwqd1k3vr63RaMuHcjnc2iLNbKOmUK5SsuTLlOBkih3Detk1w== X-Received: by 2002:a63:475c:: with SMTP id w28mr4796471pgk.222.1594756239831; Tue, 14 Jul 2020 12:50:39 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:39 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/9] remoteproc: Add new attach() remoteproc operation Date: Tue, 14 Jul 2020 13:50:28 -0600 Message-Id: <20200714195035.1426873-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add an new attach() operation in order to properly deal with scenarios where the remoteproc core needs to attach to a remote processor that has been booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_internal.h | 8 ++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 4ba7cb59d3e8..fc710866f8ce 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -79,6 +79,14 @@ static inline int rproc_unprepare_device(struct rproc *rproc) return 0; } +static inline int rproc_attach_device(struct rproc *rproc) +{ + if (rproc->ops->attach) + return rproc->ops->attach(rproc); + + return 0; +} + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 21182ad2d059..bf6a310ba870 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -359,6 +359,7 @@ enum rsc_handling_status { * @unprepare: unprepare device after stop * @start: power on the device and boot it * @stop: power off the device + * @attach: attach to a device that his already powered up * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations * @parse_fw: parse firmware to extract information (e.g. resource table) @@ -379,6 +380,7 @@ struct rproc_ops { int (*unprepare)(struct rproc *rproc); int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); + int (*attach)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, size_t len); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); From patchwork Tue Jul 14 19:50: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: 11663451 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 AB97F722 for ; Tue, 14 Jul 2020 19:51:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9229522BEB for ; Tue, 14 Jul 2020 19:51:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="w1onkpR0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbgGNTvP (ORCPT ); Tue, 14 Jul 2020 15:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729619AbgGNTul (ORCPT ); Tue, 14 Jul 2020 15:50:41 -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 6E955C08C5DB for ; Tue, 14 Jul 2020 12:50:41 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id j19so8039100pgm.11 for ; Tue, 14 Jul 2020 12:50: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=Dkdk1HU4RvzeNvsp6TinYFs07yUk0YfjlyMcPX/N2O0=; b=w1onkpR0METlahp/EUYmJcn6mWjsIh2w1U7rLwYVuoEy65Ux3Cvt8dqR0ywX28J9do 1QqnVlHR24CaclQatHlIDa/QIToenuxeRPBco4ZpaT5U//3wkqnLYnOtJS8LheG3A5Wb uBiRjzoZ25c/bipZUnK9eg1EqXr1iSBQ4uwdFi871GEADiHCUTZ2hjrQNVXmcSaDjlGq U7Mkssbp8c5qhFG2x+puXK3BAv6xAWqiExRbz+2uhyFiMbbDqyrnjfy92Hu5js8p7arA HfOSJP5BRf85TLSmz/18fng4/Xr58rPI6Kyfl8urJ+mDTmZs1+4PHgGhkoVLcDdv+Gsp Jj0w== 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=Dkdk1HU4RvzeNvsp6TinYFs07yUk0YfjlyMcPX/N2O0=; b=tZN5pbZlnWlTgLK6PPuq3baL2yqp2EGvcoOGczCmdlyFLVIGhiH9nZ1Z28+/GjId5b 5pRctxCx7kcNOjNdbIHrDZapn7TZsDhCtLUWm+KeZHv7pLx6METy3VKm3WDIM/bi0sX+ 5+n1LNIP7IE3OA9sxPQ973P94ZeZ/P7npOKOne3q10LFsUg0cLRUHP2OfV5q82sSXcS+ p7hBIVvA1N+A0MsyDlkZc6lsgg1PXXDq3JA9+j4sNiAp5ox8KOmYO4ZSpLq/MyfJdxp+ Z5Kx4+2nNQgZWYQAQZYBVE2591sxpmX6CHQCxmTv13YNjqySZWlRE9il409kXpxHBzeu J4VA== X-Gm-Message-State: AOAM5315bB4SMNJ/DqLAfm0Ba1b9P8YbWsKkN03FnU9ti/rIKKY1DGeI LZn+UkThYmTqr0M59d8FaBfBWQ== X-Google-Smtp-Source: ABdhPJxGDve+4ouHSFclk3B4WQKVvxx6xzUCSPGKIHmneSYbayoSOqfgHE5SYmLNVv6A79SUzG33ZA== X-Received: by 2002:aa7:8550:: with SMTP id y16mr5379487pfn.151.1594756240988; Tue, 14 Jul 2020 12:50:40 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:40 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/9] remoteproc: Introducing function rproc_attach() Date: Tue, 14 Jul 2020 13:50:29 -0600 Message-Id: <20200714195035.1426873-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introducing function rproc_attach() to enact the same actions as rproc_start(), but without the steps related to the handling of a firmware image. That way we can properly deal with scenarios where the remoteproc core needs to attach with a remote processsor that has been booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0f95e025ba03..1e8e66a25bd6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1369,6 +1369,48 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } +static int __maybe_unused rproc_attach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = rproc_prepare_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to prepare subdevices for %s: %d\n", + rproc->name, ret); + goto out; + } + + /* Attach to the remote processor */ + ret = rproc_attach_device(rproc); + if (ret) { + dev_err(dev, "can't attach to rproc %s: %d\n", + rproc->name, ret); + goto unprepare_subdevices; + } + + /* Start any subdevices for the remote processor */ + ret = rproc_start_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to probe subdevices for %s: %d\n", + rproc->name, ret); + goto stop_rproc; + } + + rproc->state = RPROC_RUNNING; + + dev_info(dev, "remote processor %s is now attached\n", rproc->name); + + return 0; + +stop_rproc: + rproc->ops->stop(rproc); +unprepare_subdevices: + rproc_unprepare_subdevices(rproc); +out: + return ret; +} + /* * take a firmware and boot a remote processor with it. */ From patchwork Tue Jul 14 19:50: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: 11663445 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 C044B722 for ; Tue, 14 Jul 2020 19:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A66EA22BEB for ; Tue, 14 Jul 2020 19:51:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="D7G6DnxR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729732AbgGNTvI (ORCPT ); Tue, 14 Jul 2020 15:51:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729723AbgGNTum (ORCPT ); Tue, 14 Jul 2020 15:50:42 -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 7B921C08C5DD for ; Tue, 14 Jul 2020 12:50:42 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ch3so2102533pjb.5 for ; Tue, 14 Jul 2020 12:50: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=jY+hhKB0ddRkOQj+QLLC4GBsl3mMolKfuwtvmOZ1afk=; b=D7G6DnxRXvBsUxmYZu4OCJ1QzqB/HUCmIZPe6CGSR7XUDniZ5vTvX/eldrgOyDqZMC gg/vlKlxk3G9ckQFvjxqJrtLSdCInI6qFOZoQrAxPra//+Ai0qDJ77SQfpDUv6Ha2Ib3 9MBBDih8VptIniwyjNclOpZFUSUoOSOR3DzNhuAXBcBQnXQ+bH7ieqNmTXFZ4s0qcPuT DiVWGg39TXGZhWtllo6aq5WNL7ki4uBIlNq+PTrQoWYlGwX/Leavv+8y+QWDnAKg/LvX ca1QFmOfMF6feCcna9vVM5/Lxi+Q9bPmHaDNwPV0k9AeBS//7/7XYjyk1G4tWtgpZHfn FUNA== 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=jY+hhKB0ddRkOQj+QLLC4GBsl3mMolKfuwtvmOZ1afk=; b=nf4coZsUyXfU+5OGKggMDqu6nFG9HFkuhI7VmER1epJ740UGxeqo/zLJkb4Cgorypm +WxOwkFErvrBpUy1krQ+fVNbTIWy9VIAb5lFdpG0UfdmRbeUtZIhdHVSgMmDkiZblokU 1VCxAKfutYMaa6KUO/yxlPyd7SSQxpYqcYrxx/FDM+XTQG4kP2X+yDDUQ4QDzW43tfek ZGGCMtIDfVmmdvPAY662amRCW6l45Vs567lP5Fq6zt0W8JAvkBJgTLcF1xCcIfFLa5Df iDXfomhzM2g7OzNtv5MaXe/SmTV0PUulYxQD0yfzRwuDUBpfddJl4LQgkOfmKVM13YhG Xdcg== X-Gm-Message-State: AOAM533T2DZx2r4QoXF4eUkHwTHTQwiVDoNmCvkBs7encoW8HGCIwDzj iez5GHfukfncLUmSQTCxVlcOKw== X-Google-Smtp-Source: ABdhPJy0+Yjbb5Wid6Xe48CAfbptCtTGZF2jm/cc4qS7GYa62Ba4oin3KhNDZYaiwhjeq0d2EOcfYw== X-Received: by 2002:a17:90b:4b0c:: with SMTP id lx12mr5659999pjb.133.1594756242037; Tue, 14 Jul 2020 12:50:42 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:41 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/9] remoteproc: Introducing function rproc_actuate() Date: Tue, 14 Jul 2020 13:50:30 -0600 Message-Id: <20200714195035.1426873-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce function rproc_actuate() that provides the same functionatlity as rproc_fw_boot(), but without the steps that involve interaction with the firmware image. That way we can deal with scenarios where the remoteproc core is attaching to a remote processor that has already been started by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 59 +++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1e8e66a25bd6..fd424662801f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1369,7 +1369,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } -static int __maybe_unused rproc_attach(struct rproc *rproc) +static int rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1490,6 +1490,63 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } +/* + * Attach to remote processor - similar to rproc_fw_boot() but without + * the steps that deal with the firmware image. + */ +static int __maybe_unused rproc_actuate(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + /* + * if enabling an IOMMU isn't relevant for this rproc, this is + * just a nop + */ + ret = rproc_enable_iommu(rproc); + if (ret) { + dev_err(dev, "can't enable iommu: %d\n", ret); + return ret; + } + + /* reset max_notifyid */ + rproc->max_notifyid = -1; + + /* reset handled vdev */ + rproc->nb_vdev = 0; + + /* + * Handle firmware resources required to attach to a remote processor. + * Because we are attaching rather than booting the remote processor, + * we expect the platform driver to properly set rproc->table_ptr. + */ + ret = rproc_handle_resources(rproc, rproc_loading_handlers); + if (ret) { + dev_err(dev, "Failed to process resources: %d\n", ret); + goto disable_iommu; + } + + /* Allocate carveout resources associated to rproc */ + ret = rproc_alloc_registered_carveouts(rproc); + if (ret) { + dev_err(dev, "Failed to allocate associated carveouts: %d\n", + ret); + goto clean_up_resources; + } + + ret = rproc_attach(rproc); + if (ret) + goto clean_up_resources; + + return 0; + +clean_up_resources: + rproc_resource_cleanup(rproc); +disable_iommu: + rproc_disable_iommu(rproc); + return ret; +} + /* * take a firmware and boot it up. * From patchwork Tue Jul 14 19:50: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: 11663447 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 DD48214DD for ; Tue, 14 Jul 2020 19:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4403224D2 for ; Tue, 14 Jul 2020 19:51:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OIYV1sGp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729229AbgGNTvI (ORCPT ); Tue, 14 Jul 2020 15:51:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729732AbgGNTun (ORCPT ); Tue, 14 Jul 2020 15:50:43 -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 859C4C08C5E0 for ; Tue, 14 Jul 2020 12:50:43 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id gc15so1233202pjb.0 for ; Tue, 14 Jul 2020 12:50: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=1eSFoQYSsQoruZlP/q9EyfnIvN17R/2xMrjfEYAqKSc=; b=OIYV1sGpRaUJnQHs4p5xLWMtcQ0LMXsAemN/mCLTJYSrJXjDLa1S8w7T5pa+tMnG2o QcGEy1br+ZbTZKstyr1NFF+pcRceFNvpzRGulNo2kE0qR+fThh/q3WOm18VDCUOykfL8 p+pwtwlT0Cp6xGXbC3Qo1R8L/6k3qcTqXuja+YMEnS9wGvzQlYkiznI4PPmhpSKMLskY v4Ul70uaEcTT+0oes4nmD3YbRw0XTlx1XSvQsB8KtSmmEKe/oBhB/Y5Melc8Hwf2Al6g Ts4wa4yXMm/KajIsYNizGjV+jTmm2Gg+6/jCjhpttQf8ipBhC0YpdyFE6klrq+HGnNZ+ C2cQ== 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=1eSFoQYSsQoruZlP/q9EyfnIvN17R/2xMrjfEYAqKSc=; b=Ge6iLseeGrzUl2coihusyd3SzTjgEn3s6BWF1ziOZ7r/uKFQpwriqiLosMBNpKZJfk FGEYT/ochXN/hRWNOkGH+AuA+zYoZnCwGcsz3P1UPe4AWnCw/9vjF4pCi+BDDKE69CDK hfyFXjAYJJ1EmYE2dW1Q1p9+0z4tpS0emcxRRfB7Nx8ruaZ/99PJHpcYZriBVcnV/m3b dxBHDiX0vbZ+/XSBG2wIlazgqvo9lM6Cvv/cypl2rt2sdGUoGDoyOPYQOiXnS3Rfr4zB qF8UcZUdmADNngHVBhzy2IjUOFg5WkFzj/NbxTNAgKMJavFRfckYZzULdb73NB5XFjSV Wbgg== X-Gm-Message-State: AOAM533HA920gbu1pRvZQMZeYLdP1w2SxpxYcv1FEjBBn0CqZXzq4yNk a6Vn+W2/xo9wCUght5qM6iDA1A== X-Google-Smtp-Source: ABdhPJxBIN/ITlJK7W/GQE+x08lHLk5JUHk1qGfUrTa/pLV1ZtTdDit6+V4NHpzRRK8/epSQq9dUtw== X-Received: by 2002:a17:90b:300d:: with SMTP id hg13mr6668739pjb.212.1594756243122; Tue, 14 Jul 2020 12:50:43 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:42 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 5/9] remoteproc: Introducing function rproc_validate() Date: Tue, 14 Jul 2020 13:50:31 -0600 Message-Id: <20200714195035.1426873-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a new function to assert the general health of the remote processor before handing it to the remoteproc core. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fd424662801f..ad500c291d5f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2040,6 +2040,43 @@ struct rproc *rproc_get_by_phandle(phandle phandle) #endif EXPORT_SYMBOL(rproc_get_by_phandle); +static int rproc_validate(struct rproc *rproc) +{ + switch (rproc->state) { + case RPROC_OFFLINE: + /* + * An offline processor without a start() + * function makes no sense. + */ + if (!rproc->ops->start) + return -EINVAL; + break; + case RPROC_DETACHED: + /* + * A remote processor in a detached state without an + * attach() function makes not sense. + */ + if (!rproc->ops->attach) + return -EINVAL; + /* + * When attaching to a remote processor the device memory + * is already available and as such there is no need to have a + * cached table. + */ + if (rproc->cached_table) + return -EINVAL; + break; + default: + /* + * When adding a remote processor, the state of the device + * can be offline or detached, nothing else. + */ + return -EINVAL; + } + + return 0; +} + /** * rproc_add() - register a remote processor * @rproc: the remote processor handle to register @@ -2069,6 +2106,10 @@ int rproc_add(struct rproc *rproc) if (ret < 0) return ret; + ret = rproc_validate(rproc); + if (ret < 0) + return ret; + dev_info(dev, "%s is available\n", rproc->name); /* create debugfs entries */ From patchwork Tue Jul 14 19:50: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: 11663441 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 94780722 for ; Tue, 14 Jul 2020 19:51:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C38822B51 for ; Tue, 14 Jul 2020 19:51:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P0ch2eC3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730005AbgGNTu7 (ORCPT ); Tue, 14 Jul 2020 15:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729773AbgGNTuo (ORCPT ); Tue, 14 Jul 2020 15:50:44 -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 B88B0C061755 for ; Tue, 14 Jul 2020 12:50:44 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id k5so2014583pjg.3 for ; Tue, 14 Jul 2020 12:50: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=3SrIZnU0YUH2iCVYi8lfRsLpOXFKIkq3s3vt32Psx5U=; b=P0ch2eC3VgDErn1SdkPgrA9O7vWzyNVF0+/CuZx2zr1RX7beEuad1ItUQ5Yk2e5Tao 6WMZilyJm1rve62WyzDHnV4/ifH/0Cco6TmOVarRcmIFSoqvvgGqC5j/jhxSx06Bg4x5 xb3Ct+S+br+7+Vt1SY1mUy/wTOCIaP4R6tuwcmH10qWeCcju+YZUBG7R2CDMJF5YVIe1 tizkJ58r59ks+DJ/YW9winL4TuT/SOEdwEk+LuZKJPAaWrYFA/WiJ+PVTz4E+KRHEyyk 3rQchJzqCJhucGogm+J7pdhCTnDYJ9As1g0yCTWFRKjU1u0jdmIzRNX9gas3L1jKXN3R rauQ== 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=3SrIZnU0YUH2iCVYi8lfRsLpOXFKIkq3s3vt32Psx5U=; b=Qrjz/omywfL7wjH8NmveTCE/zcRaehGp/TqgCZKYge3C6IqsVp8cRXFocqVkYahi8r XX779DnMYPqxaPVo46sC4s899QJMdVnKBcq8HwGkhPtH3HVXzcYui9XMu7HocHRxYHUD YvVRU72A8bYGcw+zxgn7PpsU63wwU1wW8KncBjaV3gWPvDp3fNa8QfMKp3sYF/L8ZSL9 pc8GfB67eWFc/rHFkeUI0Ge2HZKPZhcYp7KIWJ+v4ie40lNhQc0TYlaxYWj9vr8MtfuH 6U4uO3Ioql2iTHelHEfgEfXknxgFoOufkdzJ7K2woYghGwJFuzxGdv3UORpR+e0zUsct JyXQ== X-Gm-Message-State: AOAM530Hbb1mJskp0N0yr/eZ7qc/7QJmz5XZML/08D3SWlLrALCE7W1N CUpjxf6JpoPx5K8ZgLhPXAkJ0Q== X-Google-Smtp-Source: ABdhPJyrbkdEAbkYD3wAsFkm3BMUneo+jO6xqtT8iXbLf4XSKSzO+p7LXqFG5L9YvyDhC0FuDmMaVA== X-Received: by 2002:a17:90b:1246:: with SMTP id gx6mr6463225pjb.85.1594756244300; Tue, 14 Jul 2020 12:50:44 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:43 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/9] remoteproc: Refactor function rproc_boot() Date: Tue, 14 Jul 2020 13:50:32 -0600 Message-Id: <20200714195035.1426873-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Refactor function rproc_boot() to properly deal with scenarios where the remoteproc core needs to attach with a remote processor that has already been booted by an external entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ad500c291d5f..caea920ce4b8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1494,7 +1494,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. */ -static int __maybe_unused rproc_actuate(struct rproc *rproc) +static int rproc_actuate(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1905,24 +1905,30 @@ int rproc_boot(struct rproc *rproc) goto unlock_mutex; } - /* skip the boot process if rproc is already powered up */ + /* skip the boot or attach process if rproc is already powered up */ if (atomic_inc_return(&rproc->power) > 1) { ret = 0; goto unlock_mutex; } - dev_info(dev, "powering up %s\n", rproc->name); + if (rproc->state == RPROC_DETACHED) { + dev_info(dev, "attaching to %s\n", rproc->name); - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto downref_rproc; - } + ret = rproc_actuate(rproc); + } else { + dev_info(dev, "powering up %s\n", rproc->name); - ret = rproc_fw_boot(rproc, firmware_p); + /* load firmware */ + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + goto downref_rproc; + } - release_firmware(firmware_p); + ret = rproc_fw_boot(rproc, firmware_p); + + release_firmware(firmware_p); + } downref_rproc: if (ret) From patchwork Tue Jul 14 19:50: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: 11663439 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 E6AA560D for ; Tue, 14 Jul 2020 19:50:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB55322B51 for ; Tue, 14 Jul 2020 19:50:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="X+2XZhU5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729830AbgGNTur (ORCPT ); Tue, 14 Jul 2020 15:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729795AbgGNTup (ORCPT ); Tue, 14 Jul 2020 15:50:45 -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 D79ABC08C5C1 for ; Tue, 14 Jul 2020 12:50:45 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id k5so7439610plk.13 for ; Tue, 14 Jul 2020 12:50: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=HqC/r0kZGRE0C9tFepj9Kth0ejpSIA3U+4WW75ILzcw=; b=X+2XZhU5UYCGPhuwRNJ+463fWfT4ufqSVSE9vwV5GAXH8K4noMZHqr/R9+Rev+GTHD nI7nnJa4b3Cr60ljApAjy7JHa7T7ZDX2l5MaOtVkJ8fZPRbQ/VWDGAs9b5tKrkBmlMZj mqr/nq/bX2nudSdkUPL1HQwr+0U3o9ByTpfuJFOabm5TawHJaDdRxPiPYqPKmj/ZKPLX MM2Oqi5U2Aq8miSEWJE4KhwvnFBvos24kQTdv4D3Kuz4SLmnQXXwRxARcERlskY9z0wx l9GN83NjlfsNLDVoflG8YVe6gCDVbGtj3QQ5xsSrY5xb7PKTBERqdEt94rPsvTE3lc5h G2gw== 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=HqC/r0kZGRE0C9tFepj9Kth0ejpSIA3U+4WW75ILzcw=; b=KPWz4/AXgXf1jcQUqn700v6iMr9cdPBUSCTnefR+9vr6RSw5uFtCPCXG/tt+QZxFpX am+dlsuFPg+fkAAOPKnYZqlr2pETP6CWPd/BL7WpVE6MNM+4EktuUO1o8BKJA6S0eBXN 6FeiwhkkUUODelBs7MgH9CX8xEbpFN0X349lLzogDsff4wW7zswxxmzZZ2bcY8j19gLd 1F+ejLU3l70MgPXG0ZOcBkeUR5yPfMjfUclr/MnI1kZUMVX7wlWk1u+K7M7bqMU20D4r Ozq5eglfvq56RVdLxGhnaRm0vNtYZEkB1gcy3pHSxxlfb5ITs/m47Orr6QUgsVI4+Pa4 TM2w== X-Gm-Message-State: AOAM5321cNwpI4hmy9zOo/i8MQmv51BoJ5xIIApcvEcTGXoxOxyAbxFl mD8HCycvW0rW5W7NuKZYTgo+6Q== X-Google-Smtp-Source: ABdhPJz5fnG+i3dbqwIWs+jFBwufIKFoal4ZG5OQg7uDu6XlcjoRvtcJSwzZednf3VeUffwJtZlZJw== X-Received: by 2002:a17:90a:3a81:: with SMTP id b1mr6446790pjc.217.1594756245406; Tue, 14 Jul 2020 12:50:45 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:44 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 7/9] remoteproc: Refactor function rproc_trigger_auto_boot() Date: Tue, 14 Jul 2020 13:50:33 -0600 Message-Id: <20200714195035.1426873-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Refactor function rproc_trigger_auto_boot() to properly deal with scenarios where the remoteproc core needs to attach with a remote processor that has already been booted by an external entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index caea920ce4b8..08de81828e4e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1568,6 +1568,15 @@ static int rproc_trigger_auto_boot(struct rproc *rproc) { int ret; + /* + * Since the remote processor is in a detached state, it has already + * been booted by another entity. As such there is no point in waiting + * for a firmware image to be loaded, we can simply initiate the process + * of attaching to it immediately. + */ + if (rproc->state == RPROC_DETACHED) + return rproc_boot(rproc); + /* * We're initiating an asynchronous firmware loading, so we can * be built-in kernel code, without hanging the boot process. From patchwork Tue Jul 14 19:50: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: 11663443 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 326EA14DD for ; Tue, 14 Jul 2020 19:51:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15C4422B51 for ; Tue, 14 Jul 2020 19:51:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bAhGruAw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729974AbgGNTu7 (ORCPT ); Tue, 14 Jul 2020 15:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729822AbgGNTuq (ORCPT ); Tue, 14 Jul 2020 15:50:46 -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 E2129C08C5C1 for ; Tue, 14 Jul 2020 12:50:46 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id x9so7463351plr.2 for ; Tue, 14 Jul 2020 12:50:46 -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=nMyi9G4SQ4whd75yWsK3XcIzJ3knuveu4wwY4ps0adQ=; b=bAhGruAwC8ofZckxr4Bc1z5NeDH/ZzOKiajCa4lg05QaBfUnVHPEWgYjSAsi7SqZhe CfujtZ4ErzL0fTYr5XlxD5jBxue3Gyim6FsVweK1WRNyCD9HzsA6MqMSeIuZSsMYUZiz xIUjqwBFLJjU00b4adosiyv3tC+2U8Imas6UCS924n4EC+9+MiOjolS//PBslNmxRGyP 6TeKhORVNYhSx4DdWRoZFHlb/1KpNxq6A44epNhsPHbUcaf9DebdIsaR2GuGBQCYGu42 99iHsvjghfqKBemizQkzN43tetUKz/DcVsaRuDlJoIb7uUsVC+5/hQ9gwTWzRjMDrnqZ Qe4Q== 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=nMyi9G4SQ4whd75yWsK3XcIzJ3knuveu4wwY4ps0adQ=; b=Q+Ys/s99ndFnwGmO+hWqAomB6P0hZae9ANOw9093BgZnWUfgxhCMVyN3KhymTZp3IT lV6mJOyqAUe4BfTp7Qg6pvkXI9qShfXZY68TNxUlo0wfYe+XjIFL0LHyllsheN9j42MQ tgwY8RLnzCinsC8vrGhCecD53bVAeMo9pbIzsVX0daAIMyVQvLevlnRX+2rgQ/Rp2zel 7gePrEqGOrVYnF5ct9HE2WKbF82GROiapcYwFsI4O4tnRlJcIZ6VC9BxWKnfFCHhJyNW xcJ2pphClnha0MQlnGOJV6bONHOcCDGRzZ9CxroxmnovHSX7xmEQ1GaPaVga3gLeY3yZ eC0g== X-Gm-Message-State: AOAM533/SM3F1TJHXIIXTIaX7iDiaMw9HnfrEyYwMs20MyS7nYkYkrS2 zonqFkrYZ1dhsqauk2Z6kTpoKw== X-Google-Smtp-Source: ABdhPJz2/oKVIa7YB+mIuN2swG7Ca/VMKtO0ZCgPjLyOHESdHDISHwd3fbG5yzu6V0bhvIMlNS7yKg== X-Received: by 2002:a17:90a:e987:: with SMTP id v7mr6121530pjy.56.1594756246494; Tue, 14 Jul 2020 12:50:46 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:46 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 8/9] remoteproc: Refactor function rproc_free_vring() Date: Tue, 14 Jul 2020 13:50:34 -0600 Message-Id: <20200714195035.1426873-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org When function rproc_free_vring() clears the virtio device section it does so on the cached resource table rather than the one installed in the remote processor memory. When a remote processor has been booted by another entity there is no need to use a cached table and as such, no need to clear the virtio device section in it. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 08de81828e4e..6b6e4ec8cf3a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -410,10 +410,22 @@ void rproc_free_vring(struct rproc_vring *rvring) idr_remove(&rproc->notifyids, rvring->notifyid); - /* reset resource entry info */ - rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; - rsc->vring[idx].da = 0; - rsc->vring[idx].notifyid = -1; + /* + * At this point rproc_stop() has been called and the installed resource + * table in the remote processor memory may no longer be accessible. As + * such and as per rproc_stop(), rproc->table_ptr points to the cached + * resource table (rproc->cached_table). The cached resource table is + * only available when a remote processor has been booted by the + * remoteproc core, otherwise it is NULL. + * + * Based on the above, reset the virtio device section in the cached + * resource table only if there is one to work with. + */ + if (rproc->table_ptr) { + rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; + rsc->vring[idx].da = 0; + rsc->vring[idx].notifyid = -1; + } } static int rproc_vdev_do_start(struct rproc_subdev *subdev) From patchwork Tue Jul 14 19:50: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: 11663437 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 27C6560D for ; Tue, 14 Jul 2020 19:50:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 098D422B51 for ; Tue, 14 Jul 2020 19:50:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pD5DjLXf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729874AbgGNTut (ORCPT ); Tue, 14 Jul 2020 15:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729862AbgGNTus (ORCPT ); Tue, 14 Jul 2020 15:50:48 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 097F4C061794 for ; Tue, 14 Jul 2020 12:50:48 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id t6so8067528pgq.1 for ; Tue, 14 Jul 2020 12:50: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=9e5oyw3EpEAUNXXC3D3Or5+u88XxZ2wDyvbuUGOopOQ=; b=pD5DjLXf5nvPsFgBiCu+GVplqB7wbFTW6k50Gw4oVWTQg2dYsBVSCDBHfv0Mz8jaIc 4TFVeD4ErhId3bwxwUaRLs0AKcHJVW/10Xiba+JZbR/AqzNa3FoJIN4IW5zBt/0+LIxk YMZIhlc89Xg4dSB67CpzbUJzsaZvK1fXMnXSZxeVY5b8xd0NoTOaMjGkGxIoWkq8HRdC FApoiyTsni8c9liw3rn3iFF0Bta9vY4kVtlMH5SnjFJqC8dIfUxNYJe7bw4mVu17DuHg RKIzcbp2u0yPY0wjdiTKpsIKHQABQZd1QYIhflQDzG9MOHQLgqWPHw6jACUrd5Xjxh2s zVLQ== 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=9e5oyw3EpEAUNXXC3D3Or5+u88XxZ2wDyvbuUGOopOQ=; b=PBStynzY2zvHZf5qj6x/kyobAMavUucGHP8mu61odosV2rdaTuRBeQ+531efL0bxtt gIfdCF0RncLkj6yRybWYCQ//O40jWHxcgA1L8Zx19wh1KlvRJydGchrYi4XvECVcHiyF jQv7kBtO58W8606VN2eFa/s6kGS2j5SciocE4oLmgX/cwNagoqV/J3bzr9xdoBBwJifx DESKeWp6RecMXExZoOOp8burgbxkTub8PHaZwqNvx0xDkoBsgJElZc/ghQBlicDZnZ7S rHcHqo0QSOFVfmSIpClJaEjL30VZLnEK+qIbMIUN5ZTtYBkIVT728KW1RjMEhQcQma7l wO+Q== X-Gm-Message-State: AOAM530nV1v5UXkfo7hmOQsR+BCEGM3AmKy20YYW5cBa0DixLhvF0S2i LGDRcPHJPV4j7EI7XykytbQ3Tw== X-Google-Smtp-Source: ABdhPJxnKdGpppGavOQKDJSfcPYLpFussnDxSqICbAETlSTje+PYY4ekJyYlYY9wyr2PzbmLNYHyQQ== X-Received: by 2002:a05:6a00:134c:: with SMTP id k12mr5482683pfu.313.1594756247557; Tue, 14 Jul 2020 12:50:47 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id g8sm16736689pgr.70.2020.07.14.12.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 12:50:47 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 9/9] remoteproc: Properly handle firmware name when attaching Date: Tue, 14 Jul 2020 13:50:35 -0600 Message-Id: <20200714195035.1426873-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org> References: <20200714195035.1426873-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org This patch prevents the firmware image name from being displayed when the remoteproc core is attaching to a remote processor. This is needed needed since there is no guarantee about the nature of the firmware image that is loaded by the external entity. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen Tested-by: Arnaud Pouliquen Reviewed-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 18 ++++++++++++++++++ drivers/remoteproc/remoteproc_sysfs.c | 16 ++++++++++++++-- include/linux/remoteproc.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 6b6e4ec8cf3a..099c76ab198f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1624,6 +1624,14 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->state = RPROC_OFFLINE; + /* + * The remote processor has been stopped and is now offline, which means + * that the next time it is brought back online the remoteproc core will + * be responsible to load its firmware. As such it is no longer + * autonomous. + */ + rproc->autonomous = false; + dev_info(dev, "stopped remote processor %s\n", rproc->name); return 0; @@ -2142,6 +2150,16 @@ int rproc_add(struct rproc *rproc) /* create debugfs entries */ rproc_create_debug_dir(rproc); + /* + * Remind ourselves the remote processor has been attached to rather + * than booted by the remoteproc core. This is important because the + * RPROC_DETACHED state will be lost as soon as the remote processor + * has been attached to. Used in firmware_show() and reset in + * rproc_stop(). + */ + if (rproc->state == RPROC_DETACHED) + rproc->autonomous = true; + /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) { ret = rproc_trigger_auto_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 264759713934..eea514cec50e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -15,8 +15,20 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rproc *rproc = to_rproc(dev); - - return sprintf(buf, "%s\n", rproc->firmware); + const char *firmware = rproc->firmware; + + /* + * If the remote processor has been started by an external + * entity we have no idea of what image it is running. As such + * simply display a generic string rather then rproc->firmware. + * + * Here we rely on the autonomous flag because a remote processor + * may have been attached to and currently in a running state. + */ + if (rproc->autonomous) + firmware = "unknown"; + + return sprintf(buf, "%s\n", firmware); } /* Change firmware name via sysfs */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index bf6a310ba870..cf5e31556780 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -491,6 +491,7 @@ struct rproc_dump_segment { * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU * @auto_boot: flag to indicate if remote processor should be auto-started + * @autonomous: true if an external entity has booted the remote processor * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc */ @@ -524,6 +525,7 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + bool autonomous; struct list_head dump_segments; int nb_vdev; u8 elf_class;