Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3516268imm; Tue, 29 May 2018 08:32:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKXv+a6vnbVuP0uMRWfH0NawT1RGX1jxZ+gzm/cMZf9yiJ8JS5tV/YZ/bjaYsMWNV+24nUu X-Received: by 2002:a62:418b:: with SMTP id g11-v6mr9574040pfd.51.1527607952670; Tue, 29 May 2018 08:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527607952; cv=none; d=google.com; s=arc-20160816; b=DVtt8715btFIKJ6KOb1vyrtBMrIABZWlhuNQnYcorLQ/rdswhiveeytaishAfVU1v6 SRKmySFUVLB4hYOJE+ZuvAuoLNIiWosgFHzogC6/1dPONaHMswp2PR/GUSBDltcfV6Et 7oNdsReojkH96GtKOG+Gg+qBLEqcZPmgle+nOMUlFKjCHn4aLZrHqV2+CbjWh5gu7aH4 7j8K+pm36HSs7JTTmvBjNwA1G7VGTwy52q8UEiCjSOCKmddnWE+0WTScsdGEmruL1tno 19Txo5Ox99ttWKmwSVbajjy3zWEKDEfZVnH6n2N7Sdhz4CVy0N58olTHo7TQ3+NDcU6Z XZ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Zb06UNIPcHSQr3SY/rmtHTO6lrDKD0E72QnPRB5LFqo=; b=rUbJ4eoXS0XY2iVgQu72VxOTfMfcc/lqqJ5VmVGtkFDbFH3/dTv/MpI0NchXWx7Ewy IVHWCdN5ksm2zY86aZB1hg+6lWOudzBPjLIi41RFBO/n48mjiUsyxufy8Ghz2+b5+oxc HB4gnnPwksbgIF72hRlYgad1uHGM1saGx04xxYgdbhmqOSktfrRxFW13KYKkP+twRIkm VQHFuPvcppa7pB1a+s7SMaJhygi43yF+6xXcBac0mLbMpe7Ao1YtGVESn21Ys74s6Ses QQudldnvNFXsmz0yAp1PumdYBchjdI5ZY1dreePYezjTCRaonAhFMzde4aAzcjwSVdod 4IpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wz5vW8vF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30-v6si32702544pld.528.2018.05.29.08.32.17; Tue, 29 May 2018 08:32:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wz5vW8vF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935287AbeE2Pbx (ORCPT + 99 others); Tue, 29 May 2018 11:31:53 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:53580 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935078AbeE2Pbv (ORCPT ); Tue, 29 May 2018 11:31:51 -0400 Received: by mail-it0-f66.google.com with SMTP id n64-v6so18922257itb.3 for ; Tue, 29 May 2018 08:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Zb06UNIPcHSQr3SY/rmtHTO6lrDKD0E72QnPRB5LFqo=; b=Wz5vW8vFTI5SMp9gRcgGzjOyYmFwOmHetOPSsNPC+X05c03kEa02gDW1TkTHlBhrYo cKwiKWB0lvkNJl03hGNk+O6sAV+6vTuFX55jZf+LM3XhKFsGr/BxuvgNMPtXRafb+558 xKN8YCVpcd16X/KCefSqAWAACuBDcdVTVtrqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Zb06UNIPcHSQr3SY/rmtHTO6lrDKD0E72QnPRB5LFqo=; b=UTR8LIuNlLCS+EhMteFd0gD8SNc3dIdcYQlCXHlIlYpkL8Y4H+o0JI/hsik+W2izV8 mY8Adew6HZfwDpj/81x8FIeaovNyvm6CSNxd6Ng032UriTqihBDpc9xURUgfWd/JLDBf x8EAMVbJUCPbvJoGeWD9JA5DwCIGEidboh4fdWtUS7F2RQvvENT/Upiyj+eFJ9IwmGoT 3I0DoyRmySSdvJpQQ+bwyRUB1fQZtCr6kVDCZR3xYOXeEH+wiBqNE2Pg1hZDxUVWxJTt V9q7tGnrw1qSnB3pTD4qjFKwo1amf74r3Km/kkIUKcSwUFO71Myb3GmKIO/x5P59R36F x3Hg== X-Gm-Message-State: ALKqPweWbiMeVjQqvxepwwXU1GgolLQBB/NjQNaH6nD/nS3vxGE2FjMz FE0sXWoGVhtkOWc/wuQQzWN4Ei9TKcc= X-Received: by 2002:a24:1d93:: with SMTP id 141-v6mr15566024itj.41.1527607910473; Tue, 29 May 2018 08:31:50 -0700 (PDT) Received: from [172.22.22.26] (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.googlemail.com with ESMTPSA id e1-v6sm7764709ita.23.2018.05.29.08.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:49 -0700 (PDT) Subject: Re: [PATCH 5/5] remoteproc: Introduce prepare and unprepare for subdevices To: Fabien DESSENNE , Arnaud POULIQUEN , "ohad@wizery.com" , "bjorn.andersson@linaro.org" Cc: "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20180515205345.8090-1-elder@linaro.org> <20180515205345.8090-6-elder@linaro.org> <90ecf369-517c-1741-0af2-c1988986d2a9@st.com> <872c26d7-52ff-d82f-373e-236fd713ec33@st.com> From: Alex Elder Message-ID: Date: Tue, 29 May 2018 10:31:49 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <872c26d7-52ff-d82f-373e-236fd713ec33@st.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/29/2018 10:30 AM, Fabien DESSENNE wrote: > Hi, > > Adding my 'Tested-by'. Normally you would say: Tested-by: Fabien DESSENNE The reason it might be important is you might wish to indicate the name and/or e-mail as something different from what you're now sending from. Is what I wrote above the way you would like it to appear? I will add that line to every one of my patches when I update them. Thanks. -Alex > > BR, > > Fabien > > > On 29/05/18 17:26, Arnaud Pouliquen wrote: >> Hi Fabien, >> Please , could you add your "Tested-by" as you test it on ST platform? >> >> Thanks >> Arnaud >> >> On 05/15/2018 10:53 PM, Alex Elder wrote: >>> From: Bjorn Andersson >>> >>> On rare occasions a subdevice might need to prepare some hardware >>> resources before a remote processor is booted, and clean up some >>> state after it has been shut down. >>> >>> One such example is the IP Accelerator found in various Qualcomm >>> platforms, which is accessed directly from both the modem remoteproc >>> and the application subsystem and requires an intricate lockstep >>> process when bringing the modem up and down. >>> >>> [elder@linaro.org: minor description and comment edits] >>> >>> Signed-off-by: Bjorn Andersson >>> Acked-by: Alex Elder > > Tested-by: Fabien Dessenne > >>> --- >>> drivers/remoteproc/remoteproc_core.c | 56 ++++++++++++++++++++++++++-- >>> include/linux/remoteproc.h | 4 ++ >>> 2 files changed, 57 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c >>> index 2ede7ae6f5bc..283b258f5e0f 100644 >>> --- a/drivers/remoteproc/remoteproc_core.c >>> +++ b/drivers/remoteproc/remoteproc_core.c >>> @@ -776,6 +776,30 @@ static int rproc_handle_resources(struct rproc *rproc, >>> return ret; >>> } >>> >>> +static int rproc_prepare_subdevices(struct rproc *rproc) >>> +{ >>> + struct rproc_subdev *subdev; >>> + int ret; >>> + >>> + list_for_each_entry(subdev, &rproc->subdevs, node) { >>> + if (subdev->prepare) { >>> + ret = subdev->prepare(subdev); >>> + if (ret) >>> + goto unroll_preparation; >>> + } >>> + } >>> + >>> + return 0; >>> + >>> +unroll_preparation: >>> + list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node) { >>> + if (subdev->unprepare) >>> + subdev->unprepare(subdev); >>> + } >>> + >>> + return ret; >>> +} >>> + >>> static int rproc_start_subdevices(struct rproc *rproc) >>> { >>> struct rproc_subdev *subdev; >>> @@ -810,6 +834,16 @@ static void rproc_stop_subdevices(struct rproc *rproc, bool crashed) >>> } >>> } >>> >>> +static void rproc_unprepare_subdevices(struct rproc *rproc) >>> +{ >>> + struct rproc_subdev *subdev; >>> + >>> + list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { >>> + if (subdev->unprepare) >>> + subdev->unprepare(subdev); >>> + } >>> +} >>> + >>> /** >>> * rproc_coredump_cleanup() - clean up dump_segments list >>> * @rproc: the remote processor handle >>> @@ -902,11 +936,18 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) >>> rproc->table_ptr = loaded_table; >>> } >>> >>> + ret = rproc_prepare_subdevices(rproc); >>> + if (ret) { >>> + dev_err(dev, "failed to prepare subdevices for %s: %d\n", >>> + rproc->name, ret); >>> + return ret; >>> + } >>> + >>> /* power up the remote processor */ >>> ret = rproc->ops->start(rproc); >>> if (ret) { >>> dev_err(dev, "can't start rproc %s: %d\n", rproc->name, ret); >>> - return ret; >>> + goto unprepare_subdevices; >>> } >>> >>> /* Start any subdevices for the remote processor */ >>> @@ -914,8 +955,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) >>> if (ret) { >>> dev_err(dev, "failed to probe subdevices for %s: %d\n", >>> rproc->name, ret); >>> - rproc->ops->stop(rproc); >>> - return ret; >>> + goto stop_rproc; >>> } >>> >>> rproc->state = RPROC_RUNNING; >>> @@ -923,6 +963,14 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) >>> dev_info(dev, "remote processor %s is now up\n", rproc->name); >>> >>> return 0; >>> + >>> +stop_rproc: >>> + rproc->ops->stop(rproc); >>> + >>> +unprepare_subdevices: >>> + rproc_unprepare_subdevices(rproc); >>> + >>> + return ret; >>> } >>> >>> /* >>> @@ -1035,6 +1083,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed) >>> return ret; >>> } >>> >>> + rproc_unprepare_subdevices(rproc); >>> + >>> rproc->state = RPROC_OFFLINE; >>> >>> dev_info(dev, "stopped remote processor %s\n", rproc->name); >>> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h >>> index 8f1426330cca..e3c5d856b6da 100644 >>> --- a/include/linux/remoteproc.h >>> +++ b/include/linux/remoteproc.h >>> @@ -477,15 +477,19 @@ struct rproc { >>> /** >>> * struct rproc_subdev - subdevice tied to a remoteproc >>> * @node: list node related to the rproc subdevs list >>> + * @prepare: prepare function, called before the rproc is started >>> * @start: start function, called after the rproc has been started >>> * @stop: stop function, called before the rproc is stopped; the @crashed >>> * parameter indicates if this originates from a recovery >>> + * @unprepare: unprepare function, called after the rproc has been stopped >>> */ >>> struct rproc_subdev { >>> struct list_head node; >>> >>> + int (*prepare)(struct rproc_subdev *subdev); >>> int (*start)(struct rproc_subdev *subdev); >>> void (*stop)(struct rproc_subdev *subdev, bool crashed); >>> + void (*unprepare)(struct rproc_subdev *subdev); >>> }; >>> >>> /* we currently support only two vrings per rvdev */ >>>