From patchwork Tue May 2 20:59:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarangdhar Joshi X-Patchwork-Id: 9708591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 640F560349 for ; Tue, 2 May 2017 20:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 531882858D for ; Tue, 2 May 2017 20:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 458BA285EF; Tue, 2 May 2017 20:59:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A30B1285E2 for ; Tue, 2 May 2017 20:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=v4h6fN/Dd+hSRqWvye0mQW0B2PuLVnDZSEfBuLlV17A=; b=Z6kvGGPU2m6yNmnJ+F78stOFpl D80PT7zpFrmzuFRmKZDQ2u/7Wp0FHKnVgFhCwZgwIssCk+2xBHuNHxB7kPbsLps286gGNbUEOmLk+ lGfVX6TntmNnVAsCX7yv2iFaX9HRHnbdFXRFm86HMGnM4uKJDRmIhocAXqEKtjPcypCVvhoovEiE9 rXUgLyyWjxG/GQZc5Pf9bt3MX0pVNmQEn8v7eOs9XH6oqEJswWhmlHPc6gV2DuNlinOZRItrnr1oO D7WJHI1VwDMhkFaYU9RTIjMASafQc0TPJPSOcw6mGP/lW0CcXP/JyuuKlM1+0H1Cbfbv/5QdkT2L+ qFTV37tg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d5etW-0003II-86; Tue, 02 May 2017 20:59:38 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d5etT-0003GB-Dn for linux-arm-kernel@lists.infradead.org; Tue, 02 May 2017 20:59:36 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 450DD60B7D; Tue, 2 May 2017 20:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1493758757; bh=uEaydPDEWPDBek+I3i3tV0NjzusrPSvpZTl9uk9ztGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8r7sLyhWpDhrF6BJMX1sIZPCPiHGupogkeliKMfMeYPFyTAoPJYcYQ07mZHEXewo y7NdZTbbKQROHE8iebxIxe7PIGnR236xjQpV3cnVHh5fu5hvcxUegL5UQkWiX3drWF VVxbyyXsGVRZqW0Z7BTjys16nUrIhFuWrcA+Cp7A= Received: from spjoshi-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: spjoshi@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 22CEB607E1; Tue, 2 May 2017 20:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1493758756; bh=uEaydPDEWPDBek+I3i3tV0NjzusrPSvpZTl9uk9ztGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T6nx3fHep+6oNhW4Xb4I+kX5yZ0F4IlkogqWGfIAlEucEhJBZ+I5kQlUEWxBIhaws kpMIcPp8Uz7x7jfIKa8dhK5cVo8WBjdm0l6iPqisJ5kP5u+awjLitcEwBMbmV0FkPR i5J8GnBpoiX/IjK/MomGpzjjY8EyvqRFIji07OrQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 22CEB607E1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=spjoshi@codeaurora.org From: Sarangdhar Joshi To: Ohad Ben-Cohen , Bjorn Andersson , Loic Pallardy Subject: [PATCH 2/2] remoteproc: Rearrange code to avoid duplication Date: Tue, 2 May 2017 13:59:02 -0700 Message-Id: <1493758742-26148-2-git-send-email-spjoshi@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493758742-26148-1-git-send-email-spjoshi@codeaurora.org> References: <1493758742-26148-1-git-send-email-spjoshi@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170502_135935_511976_89376BB0 X-CRM114-Status: GOOD ( 15.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trilok Soni , linux-arm-msm@vger.kernel.org, Stephen Boyd , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Lot of code from rproc_fw_boot() and rproc_shutdown() has been duplicated in rproc_start() and rproc_stop() respectively. Refactor the code, so that rproc_start() and rproc_stop() can be called from boot up and shutdown path directly, instead of having the unnecessary duplication of code. Signed-off-by: Sarangdhar Joshi --- drivers/remoteproc/remoteproc_core.c | 58 +++--------------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 169abb3..a5b72b1 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -913,7 +913,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) { struct device *dev = &rproc->dev; const char *name = rproc->firmware; - struct resource_table *table, *loaded_table; + struct resource_table *table; int ret, tablesz; ret = rproc_fw_sanity_check(rproc, fw); @@ -962,48 +962,12 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) goto clean_up_resources; } - /* load the ELF segments to memory */ - ret = rproc_load_segments(rproc, fw); - if (ret) { - dev_err(dev, "Failed to load program segments: %d\n", ret); - goto clean_up_resources; - } - - /* - * The starting device has been given the rproc->table_ptr as the - * resource table. The address of the vring along with the other - * allocated resources (carveouts etc) is stored in table_ptr. - * In order to pass this information to the remote device we must copy - * this information to device memory. We also update the table_ptr so - * that any subsequent changes will be applied to the loaded version. - */ - loaded_table = rproc_find_loaded_rsc_table(rproc, fw); - if (loaded_table) - memcpy(loaded_table, rproc->table_ptr, tablesz); - - /* 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); + ret = rproc_start(rproc, fw); + if (ret) goto clean_up_resources; - } - - /* probe any subdevices for the remote processor */ - ret = rproc_probe_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 up\n", rproc->name); return 0; -stop_rproc: - rproc->ops->stop(rproc); clean_up_resources: rproc_resource_cleanup(rproc); clean_up: @@ -1265,14 +1229,9 @@ void rproc_shutdown(struct rproc *rproc) if (!atomic_dec_and_test(&rproc->power)) goto out; - /* remove any subdevices for the remote processor */ - rproc_remove_subdevices(rproc); - - /* power off the remote processor */ - ret = rproc->ops->stop(rproc); + ret = rproc_stop(rproc); if (ret) { atomic_inc(&rproc->power); - dev_err(dev, "can't stop rproc: %d\n", ret); goto out; } @@ -1284,15 +1243,6 @@ void rproc_shutdown(struct rproc *rproc) /* Free the copy of the resource table */ kfree(rproc->table_ptr); rproc->table_ptr = NULL; - - /* if in crash state, unlock crash handler */ - if (rproc->state == RPROC_CRASHED) - complete_all(&rproc->crash_comp); - - rproc->state = RPROC_OFFLINE; - - dev_info(dev, "stopped remote processor %s\n", rproc->name); - out: mutex_unlock(&rproc->lock); }