Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3670520pxj; Tue, 1 Jun 2021 10:26:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7kH9ZzIryO/n0wGCwqfOgNFxkv8bTM4fQGudAjX17uPpQYYWoXs2apM5ru8Epp6jQtloQ X-Received: by 2002:a17:906:d297:: with SMTP id ay23mr22401873ejb.418.1622568382436; Tue, 01 Jun 2021 10:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622568382; cv=none; d=google.com; s=arc-20160816; b=Z/HVBAUsIYZNOVnctsYfVSJ6d1hy7W9JjGAqiXhqonubLkVQ3LCwM7zBcFUWZIWE5O rS/tRdaJlvFD3f196o06S9ZU64eBymX/nIA3D7IoCnthmXiFhYA9ro8ximsv0/Qd9IO2 CKRNgPKW4CC7NNLPHMQi0yhFGWe3a+tYkWFSu0A4nobGITARB9wN529GB2gOaO0uw1mo ZRq4NJE2hW2ruoLzDEdHopRxaNW3HYEcVEvXPY72iT30rX7QobRqa2jcK1rK3L4brMXv c81IlsQ1Agvwa6lQedSRF+fhJI+vG3frnanh83R7uRnFpb/20DWKe2ZFNDuE1YTaa1EX i+9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Wn+gKBGF4EW/y5WIOTECsgw0m1+QurVLeNYFkfOOlsc=; b=Z5U0cgo3U72LSjI0am3gDFOpCDFqIxGV+JgxYvGMdG1nGmULWh20ktXbQQsv4nhyW5 edzZhngAMSvFRZWRZLFmMiRDsXKExcEqw8em7HIKKM769QvosNCwqRflxa+87vJHRU+9 v/hquoYJYsP2esYC2bf8zpxxW0/aMpri/pHQNzKX3QxSMyulDGxqs39lzmBOcF/Ommku YFqXt7iTmvnD8TXGNoZ70V2rJSlnIOBRrIS3bS/AJtsphw4cc1OHb4UaDDR/1Rp4TvGE EyC22q9X0liwwLNNe4+xcY1qglXRtIJn2tStTmzRgSNaioXobnFYN2g85PnsAWnEB8fT kU6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KaKo3ASi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id rk21si9617890ejb.212.2021.06.01.10.25.57; Tue, 01 Jun 2021 10:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KaKo3ASi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233925AbhFARYi (ORCPT + 99 others); Tue, 1 Jun 2021 13:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233871AbhFARYg (ORCPT ); Tue, 1 Jun 2021 13:24:36 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F313C06174A for ; Tue, 1 Jun 2021 10:22:53 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id e7so5177066plj.7 for ; Tue, 01 Jun 2021 10:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Wn+gKBGF4EW/y5WIOTECsgw0m1+QurVLeNYFkfOOlsc=; b=KaKo3ASizyyNS70aGjfD2CcGO1zJazK2GwwfwvSDL1366zyLuIx9NfJKBHPZcjAhcR vX0AbC2oHljZnGGRc/XS5xCmjuDsk609QOjj7IVVjsb+V9QpFznQxRSuC505guk3wOFU DmgriTVuhb6AKOHffCMEcxz3gtIvMTmjnZ8k156lEkXSjCHnCLv7KrUyLYYP5G3Q3dUW 6U5Sou2Lagvt4fEcYIYMQlFZxvcx8uZOEItvN+JUOrgmwd7BCt/XDIJtmmBGL23i0XGr A1iqUDqigsFVP8B4rQgIcPWbEAEjavVSdYiMVtQMfZXSCLNkxxd9sZcx1DlmipZ3Q3OO P5OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Wn+gKBGF4EW/y5WIOTECsgw0m1+QurVLeNYFkfOOlsc=; b=Z1Hjqv4CbawGC80DtjwsxsQL8xRMKS822q7MOy+KQhwe4c68vqkZyGSdrZLgtRPiuE YyXYiHB9lSIbV21IJL9TZUbSLDeW1w1bTksMjfK03EepMxANshu8A40krcN4MN4UsyJY kC689Uae71OxWW6wA6uKlj1NLNvwxGm7pGNFlq6PTPBKW9gdkSIk7oMjRXkIBZl7VUw0 8yhygVqOCmqzS4PRRbIoPeB7VPWDHHRS3PvGrAOmvOdiWQ7LuNMxa92lcM0R47ltxYoR BbBfkdCNGI+0xCuA5ZB6OScvycQ1+QAuERgRJKIetf4O6yFRP3gyq2XtbTczLX3knKUz eP+A== X-Gm-Message-State: AOAM531n2eotR8WrBIMSYyeN5M9IaFG4dyGzqfGn/YFNU7wZ1T+hPuJl z4HXL0ocg4N+nuodUHEOEXGs8A== X-Received: by 2002:a17:903:248e:b029:101:fa49:3f96 with SMTP id p14-20020a170903248eb0290101fa493f96mr17923282plw.16.1622568172919; Tue, 01 Jun 2021 10:22:52 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id y5sm6870301pfb.19.2021.06.01.10.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 10:22:52 -0700 (PDT) Date: Tue, 1 Jun 2021 11:22:50 -0600 From: Mathieu Poirier To: Suman Anna Cc: Bjorn Andersson , Lokesh Vutla , Tero Kristo , linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/6] remoteproc: k3-r5: Refactor mbox request code in start Message-ID: <20210601172250.GD1759269@xps15> References: <20210522000309.26134-1-s-anna@ti.com> <20210522000309.26134-4-s-anna@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210522000309.26134-4-s-anna@ti.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 07:03:06PM -0500, Suman Anna wrote: > Refactor out the mailbox request and associated ping logic code > from k3_r5_rproc_start() function into its own separate function > so that it can be re-used in the soon to be added .attach() ops > callback. > > Signed-off-by: Suman Anna > --- > drivers/remoteproc/ti_k3_r5_remoteproc.c | 66 ++++++++++++++---------- > 1 file changed, 40 insertions(+), 26 deletions(-) > Reviewed-by: Mathieu Poirier > diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c > index 2975393ebacd..e7e1ca71763e 100644 > --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c > +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c > @@ -376,6 +376,44 @@ static inline int k3_r5_core_run(struct k3_r5_core *core) > 0, PROC_BOOT_CTRL_FLAG_R5_CORE_HALT); > } > > +static int k3_r5_rproc_request_mbox(struct rproc *rproc) > +{ > + struct k3_r5_rproc *kproc = rproc->priv; > + struct mbox_client *client = &kproc->client; > + struct device *dev = kproc->dev; > + int ret; > + > + client->dev = dev; > + client->tx_done = NULL; > + client->rx_callback = k3_r5_rproc_mbox_callback; > + client->tx_block = false; > + client->knows_txdone = false; > + > + kproc->mbox = mbox_request_channel(client, 0); > + if (IS_ERR(kproc->mbox)) { > + ret = -EBUSY; > + dev_err(dev, "mbox_request_channel failed: %ld\n", > + PTR_ERR(kproc->mbox)); > + return ret; > + } > + > + /* > + * Ping the remote processor, this is only for sanity-sake for now; > + * there is no functional effect whatsoever. > + * > + * Note that the reply will _not_ arrive immediately: this message > + * will wait in the mailbox fifo until the remote processor is booted. > + */ > + ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); > + if (ret < 0) { > + dev_err(dev, "mbox_send_message failed: %d\n", ret); > + mbox_free_channel(kproc->mbox); > + return ret; > + } > + > + return 0; > +} > + > /* > * The R5F cores have controls for both a reset and a halt/run. The code > * execution from DDR requires the initial boot-strapping code to be run > @@ -495,38 +533,14 @@ static int k3_r5_rproc_start(struct rproc *rproc) > { > struct k3_r5_rproc *kproc = rproc->priv; > struct k3_r5_cluster *cluster = kproc->cluster; > - struct mbox_client *client = &kproc->client; > struct device *dev = kproc->dev; > struct k3_r5_core *core; > u32 boot_addr; > int ret; > > - client->dev = dev; > - client->tx_done = NULL; > - client->rx_callback = k3_r5_rproc_mbox_callback; > - client->tx_block = false; > - client->knows_txdone = false; > - > - kproc->mbox = mbox_request_channel(client, 0); > - if (IS_ERR(kproc->mbox)) { > - ret = -EBUSY; > - dev_err(dev, "mbox_request_channel failed: %ld\n", > - PTR_ERR(kproc->mbox)); > + ret = k3_r5_rproc_request_mbox(rproc); > + if (ret) > return ret; > - } > - > - /* > - * Ping the remote processor, this is only for sanity-sake for now; > - * there is no functional effect whatsoever. > - * > - * Note that the reply will _not_ arrive immediately: this message > - * will wait in the mailbox fifo until the remote processor is booted. > - */ > - ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); > - if (ret < 0) { > - dev_err(dev, "mbox_send_message failed: %d\n", ret); > - goto put_mbox; > - } > > boot_addr = rproc->bootaddr; > /* TODO: add boot_addr sanity checking */ > -- > 2.30.1 >