Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1521781pxj; Fri, 21 May 2021 17:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT7LKGu/WG47yRymdnxBG8wume3MqvFFNgv7WnERgsHHX6Y+BEjOLzCl7PaKaWgQZeC5Ij X-Received: by 2002:a05:6402:5241:: with SMTP id t1mr4655370edd.161.1621641902454; Fri, 21 May 2021 17:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621641902; cv=none; d=google.com; s=arc-20160816; b=iMQTrpFbt1DsvhiUsQ3dVCnD/lsDgyaCQ0sulcHzYY6zDNmp8uw+w7FEV1gvMQRkY7 9Sm4Xzdl43OuJfY+VyIwnpXxsgY84HzQNaW3ijLHgAqiC0P5w2ReuN7/MwjPE0hvudFK c6ktStM7GIk/Iou7zhNLcx+52uQBzELB12aV4lxc8XfTMUeneN+GIvYQQg8WhBJdCkwq LhtaBgoQwl4ER2TpKAI/94WrR/UGKb+uJp24Hvo7b7SoCiaatWdtyZDZ/oRTVSW5yz3p 574zYQJnRVD0kIXZlJDXNGBihZeXOTY6rDqZuTWK4aLVhyOktCwbEwqe0qxdGAn+tdg4 v7kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UkoUZkPkCCCsnshJegh0RG0trp7zoNqgIxYeUxoJ6L8=; b=ZfrkqDr5oOyT8a8xbsIkwFlepz7/Sn2+A4LBEAkmrATv3dhrEWqYrJbHkrfGXg5e/n g8Um8w9E1oS3HH/8xAtFoDJB23fKmg01Ac9vGrugc04wL0PYCUspAux8x2MZowLPYkkx 3vXcobj6dSOFYNSij3vpwnFTv74QKYNpjPnyMECRateY+4JaQIgqrx57K/wtadNf8BcX f+iPfU666o7lvNnhzVTxZ6KhIsb6lSB2xMAs0AzW5OLLbkWm8nypS1VXDJwARH5vC/I0 Pjd1jdYge10Oiqsnw1e6o5NU8EiClAyHZiwF3HsZnyQFKAi6IkmdCK8UO7IOzIV+F85r pt0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=n1X7KUQ1; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si5122427edb.184.2021.05.21.17.04.39; Fri, 21 May 2021 17:05:02 -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=@ti.com header.s=ti-com-17Q1 header.b=n1X7KUQ1; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbhEVAFF (ORCPT + 99 others); Fri, 21 May 2021 20:05:05 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:58088 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbhEVAE7 (ORCPT ); Fri, 21 May 2021 20:04:59 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 14M03RGR027040; Fri, 21 May 2021 19:03:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1621641807; bh=UkoUZkPkCCCsnshJegh0RG0trp7zoNqgIxYeUxoJ6L8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=n1X7KUQ12Vvuy8fns7YsebOBqr+RlVirgHl2bq4dtughsvW5j8s/rNBrHvra3bgkE 3IAKplLJALX5qj5RBK5L4c2Sk5JCgcQgtxsVNEsA9Bbf7/gnubaoplKC/izKIfwOu6 7FFjFYsqcaoNhZ7m1z9i8N85PsbUA3hbJlup7mYg= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 14M03QF0062807 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 21 May 2021 19:03:27 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 21 May 2021 19:03:26 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Fri, 21 May 2021 19:03:26 -0500 Received: from fllv0103.dal.design.ti.com (fllv0103.dal.design.ti.com [10.247.120.73]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 14M03QmP113360; Fri, 21 May 2021 19:03:26 -0500 Received: from localhost ([10.250.35.153]) by fllv0103.dal.design.ti.com (8.14.7/8.14.7) with ESMTP id 14M03QU5091539; Fri, 21 May 2021 19:03:26 -0500 From: Suman Anna To: Bjorn Andersson , Mathieu Poirier CC: Lokesh Vutla , Tero Kristo , , , , Suman Anna Subject: [PATCH 3/6] remoteproc: k3-r5: Refactor mbox request code in start Date: Fri, 21 May 2021 19:03:06 -0500 Message-ID: <20210522000309.26134-4-s-anna@ti.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210522000309.26134-1-s-anna@ti.com> References: <20210522000309.26134-1-s-anna@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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