From patchwork Wed Oct 17 13:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10645657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3204715E2 for ; Wed, 17 Oct 2018 13:55:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BA6E2AE6D for ; Wed, 17 Oct 2018 13:55:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F7382AEAC; Wed, 17 Oct 2018 13:55:53 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8580E2AE6D for ; Wed, 17 Oct 2018 13:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbeJQVvk (ORCPT ); Wed, 17 Oct 2018 17:51:40 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43602 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeJQVvk (ORCPT ); Wed, 17 Oct 2018 17:51:40 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 14193602D7; Wed, 17 Oct 2018 13:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784551; bh=YS6bMC+ZrQm5W0ohmcG1d9cO5YpfeKnBOYZghR4rwfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIpFqriYTK1LmogPz7BTmJr7cK4uJRpNbbLzWmzBbecEd6SEVNPIMlX0oQGIMwg83 YeHNOiWWK56NgJskEZwsgyFoHsxsbkUijBdbdiSkx5LbFqLDmS86QiB3htYRnYmnar YRtSYbWVhySPNLhTapDXiZKxKDiAOYUHSHJgc76g= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 23C2461325; Wed, 17 Oct 2018 13:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784550; bh=YS6bMC+ZrQm5W0ohmcG1d9cO5YpfeKnBOYZghR4rwfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A0sG40g3ciCiuIjCSwCIVdnAnGmHiOtY3m5DoMcqhPTxduzAlDZDgtdmYbrnRFDBy Ws6cJMsBXGWBMKC2mxu0S5uwa3KVonOv6EbAq7VI8AbwsN3DvXpY7mS4EPAd930K7t qg9MCBIHvCLwX0w0icRfTe18ybp2MmHvD9ru//RU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 23C2461325 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=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tsoni@codeaurora.org, sricharan@codeaurora.org, akdwived@codeaurora.org, kyan@codeaurora.org, Sibi Sankar Subject: [PATCH v5 1/5] remoteproc: Introduce custom dump function for each remoteproc segment Date: Wed, 17 Oct 2018 19:25:23 +0530 Message-Id: <20181017135527.30592-2-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181017135527.30592-1-sibis@codeaurora.org> References: <20181017135527.30592-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce custom dump function and private data per remoteproc dump segment. The dump function is responsible for filling the device memory segment associated with coredump Signed-off-by: Sibi Sankar --- drivers/remoteproc/remoteproc_core.c | 16 ++++++++++------ include/linux/remoteproc.h | 6 ++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index aa6206706fe3..afa4274b6ccd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1183,14 +1183,18 @@ static void rproc_coredump(struct rproc *rproc) phdr->p_flags = PF_R | PF_W | PF_X; phdr->p_align = 0; - ptr = rproc_da_to_va(rproc, segment->da, segment->size); - if (!ptr) { - dev_err(&rproc->dev, + if (segment->dump) { + segment->dump(rproc, segment, data + offset); + } else { + ptr = rproc_da_to_va(rproc, segment->da, segment->size); + if (!ptr) { + dev_err(&rproc->dev, "invalid coredump segment (%pad, %zu)\n", &segment->da, segment->size); - memset(data + offset, 0xff, segment->size); - } else { - memcpy(data + offset, ptr, segment->size); + memset(data + offset, 0xff, segment->size); + } else { + memcpy(data + offset, ptr, segment->size); + } } offset += phdr->p_filesz; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e3c5d856b6da..2a93e102d2ad 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -399,6 +399,9 @@ enum rproc_crash_type { * @node: list node related to the rproc segment list * @da: device address of the segment * @size: size of the segment + * @priv: private data associated with the dump_segment + * @dump: custom dump function to fill device memory segment associated + * with coredump */ struct rproc_dump_segment { struct list_head node; @@ -406,6 +409,9 @@ struct rproc_dump_segment { dma_addr_t da; size_t size; + void *priv; + void (*dump)(struct rproc *rproc, struct rproc_dump_segment *segment, + void *dest); loff_t offset; }; From patchwork Wed Oct 17 13:55:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10645663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3B6515E2 for ; Wed, 17 Oct 2018 13:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 920492AEA5 for ; Wed, 17 Oct 2018 13:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 857742AEAC; Wed, 17 Oct 2018 13:56:03 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 305902AEA5 for ; Wed, 17 Oct 2018 13:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727495AbeJQVvq (ORCPT ); Wed, 17 Oct 2018 17:51:46 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44094 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeJQVvq (ORCPT ); Wed, 17 Oct 2018 17:51:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B2F1C61371; Wed, 17 Oct 2018 13:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784555; bh=E732yZacHh5Js6UCJf8iPHfocQFXpXKKNzpzQXWw0EY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oi+WE38fCCOjczbvV037oxHFUp2x4ym7NKymICFGOXe9hwcK4GhFddQ93uzQT7s6T yQREeDCSElB/3xOkFmjNmKnvnUKa6hUeI3dNyo3YZ0IAkzlu0k2HEmDrqBTqRQkt8X q5XuTy1XkQhhaSnv4aN6Cmkxx0IM1QVbWH5t5h6Y= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 20BF761364; Wed, 17 Oct 2018 13:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784555; bh=E732yZacHh5Js6UCJf8iPHfocQFXpXKKNzpzQXWw0EY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oi+WE38fCCOjczbvV037oxHFUp2x4ym7NKymICFGOXe9hwcK4GhFddQ93uzQT7s6T yQREeDCSElB/3xOkFmjNmKnvnUKa6hUeI3dNyo3YZ0IAkzlu0k2HEmDrqBTqRQkt8X q5XuTy1XkQhhaSnv4aN6Cmkxx0IM1QVbWH5t5h6Y= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 20BF761364 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=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tsoni@codeaurora.org, sricharan@codeaurora.org, akdwived@codeaurora.org, kyan@codeaurora.org, Sibi Sankar Subject: [PATCH v5 2/5] remoteproc: Add mechanism for custom dump function assignment Date: Wed, 17 Oct 2018 19:25:24 +0530 Message-Id: <20181017135527.30592-3-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181017135527.30592-1-sibis@codeaurora.org> References: <20181017135527.30592-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a mechanism for assigning each rproc dump segment with a custom dump function and private data. The dump function is to be called for each rproc segment during coredump if assigned. Signed-off-by: Sibi Sankar --- drivers/remoteproc/remoteproc_core.c | 39 ++++++++++++++++++++++++++++ include/linux/remoteproc.h | 5 ++++ 2 files changed, 44 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index afa4274b6ccd..076579f44c3a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1121,6 +1121,45 @@ int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size) } EXPORT_SYMBOL(rproc_coredump_add_segment); +/** + * rproc_coredump_add_custom_segment() - add segment of device memory to + * coredump and extend it with custom + * dump function + * @rproc: handle of a remote processor + * @da: device address + * @size: size of segment + * @priv: private data + * @dumpfn: custom dump function called for each segment during coredump + * + * Add device memory to the list of segments to be included in the coredump + * and associate the segment with the given custom dump function and private + * data. + * + * Return: 0 on success, negative errno on error. + */ +int rproc_coredump_add_custom_segment(struct rproc *rproc, + dma_addr_t da, size_t size, void *priv, + void (*dumpfn)(struct rproc *rproc, + struct rproc_dump_segment *segment, + void *dest)) +{ + struct rproc_dump_segment *segment; + + segment = kzalloc(sizeof(*segment), GFP_KERNEL); + if (!segment) + return -ENOMEM; + + segment->da = da; + segment->size = size; + segment->priv = priv; + segment->dump = dumpfn; + + list_add_tail(&segment->node, &rproc->dump_segments); + + return 0; +} +EXPORT_SYMBOL(rproc_coredump_add_custom_segment); + /** * rproc_coredump() - perform coredump * @rproc: rproc handle diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 2a93e102d2ad..0003b23ab117 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -563,6 +563,11 @@ int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); +int rproc_coredump_add_custom_segment(struct rproc *rproc, + dma_addr_t da, size_t size, void *priv, + void (*dumpfn)(struct rproc *rproc, + struct rproc_dump_segment *segment, + void *dest)); static inline struct rproc_vdev *vdev_to_rvdev(struct virtio_device *vdev) { From patchwork Wed Oct 17 13:55:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10645665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF67F15E2 for ; Wed, 17 Oct 2018 13:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD1B82AE9A for ; Wed, 17 Oct 2018 13:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B14BC2AEAE; Wed, 17 Oct 2018 13:56:06 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E72B32AE9A for ; Wed, 17 Oct 2018 13:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbeJQVvy (ORCPT ); Wed, 17 Oct 2018 17:51:54 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44306 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeJQVvy (ORCPT ); Wed, 17 Oct 2018 17:51:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C65D761314; Wed, 17 Oct 2018 13:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784564; bh=LL7T7jSHsuDu8KIlw8/Wcco5BmJa0AGETQjeTJIOPPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOt7xNhztcEHW3vzcXuBsEGs2JJLZ6ue+ul0LXCOtYg3IAuv8JQRYEkc8Am8k1F47 /kCSX3YDduDOPbf0mKNRi6/2jVNIhmD57dNsDkp9POWYLThqjL9GPm+TO73v3Jusem Cas/iiNZryztYk9rC+2g7piGiYEAkVhvkEzI4/ec= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 15C7D60F39; Wed, 17 Oct 2018 13:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784560; bh=LL7T7jSHsuDu8KIlw8/Wcco5BmJa0AGETQjeTJIOPPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEvSvPVcYBaKaHPgzzUw2jKPa/2Aw8Aee4+x77GRbDUrCG258jGKeAdVr/4sf40Dv 0VIfqXTAq3wp9PjrSSmC22BOCTu+maxdpmPb2Fy6QvbaPRTiuSDVAqLZlVGqoGeyPc xa5uofwk5uL4TFDBKPyjIFAgdnedQP5UyTX4WKhs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 15C7D60F39 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=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tsoni@codeaurora.org, sricharan@codeaurora.org, akdwived@codeaurora.org, kyan@codeaurora.org, Sibi Sankar Subject: [PATCH v5 3/5] remoteproc: qcom: q6v5-mss: Refactor mba load/unload sequence Date: Wed, 17 Oct 2018 19:25:25 +0530 Message-Id: <20181017135527.30592-4-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181017135527.30592-1-sibis@codeaurora.org> References: <20181017135527.30592-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Refactor re-useable parts of mba load/unload sequence into mba_load and mba_reclaim respectively. This is done in order to prevent code duplication for modem coredump, which requires the mba to be loaded before dumping the segments. The following changes in functionality are intended: * Add software bypass to avoid high MX current in mpss error path. * Remove the proxy votes of clk/regs only after the active/reset clks/regs. * Reclaim MBA memory after mpss_load failure in mba_reclaim func. * Set/Unset the dump_mba_loaded flag on mba_load/mba_reclaim respectively. Signed-off-by: Sibi Sankar --- drivers/remoteproc/qcom_q6v5_mss.c | 308 ++++++++++++++++------------- 1 file changed, 170 insertions(+), 138 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index f52b64120877..87d7f4d0c176 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -167,6 +167,7 @@ struct q6v5 { bool running; + bool dump_mba_loaded; phys_addr_t mba_phys; void *mba_region; size_t mba_size; @@ -679,6 +680,171 @@ static bool q6v5_phdr_valid(const struct elf32_phdr *phdr) return true; } +static int q6v5_mba_load(struct q6v5 *qproc) +{ + int ret; + int xfermemop_ret; + + qcom_q6v5_prepare(&qproc->q6v5); + + ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, + qproc->proxy_reg_count); + if (ret) { + dev_err(qproc->dev, "failed to enable proxy supplies\n"); + goto disable_irqs; + } + + ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks, + qproc->proxy_clk_count); + if (ret) { + dev_err(qproc->dev, "failed to enable proxy clocks\n"); + goto disable_proxy_reg; + } + + ret = q6v5_regulator_enable(qproc, qproc->active_regs, + qproc->active_reg_count); + if (ret) { + dev_err(qproc->dev, "failed to enable supplies\n"); + goto disable_proxy_clk; + } + + ret = q6v5_clk_enable(qproc->dev, qproc->reset_clks, + qproc->reset_clk_count); + if (ret) { + dev_err(qproc->dev, "failed to enable reset clocks\n"); + goto disable_vdd; + } + + ret = q6v5_reset_deassert(qproc); + if (ret) { + dev_err(qproc->dev, "failed to deassert mss restart\n"); + goto disable_reset_clks; + } + + ret = q6v5_clk_enable(qproc->dev, qproc->active_clks, + qproc->active_clk_count); + if (ret) { + dev_err(qproc->dev, "failed to enable clocks\n"); + goto assert_reset; + } + + /* Assign MBA image access in DDR to q6 */ + ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, + qproc->mba_phys, qproc->mba_size); + if (ret) { + dev_err(qproc->dev, + "assigning Q6 access to mba memory failed: %d\n", ret); + goto disable_active_clks; + } + + writel(qproc->mba_phys, qproc->rmb_base + RMB_MBA_IMAGE_REG); + + ret = q6v5proc_reset(qproc); + if (ret) + goto reclaim_mba; + + ret = q6v5_rmb_mba_wait(qproc, 0, 5000); + if (ret == -ETIMEDOUT) { + dev_err(qproc->dev, "MBA boot timed out\n"); + goto halt_axi_ports; + } else if (ret != RMB_MBA_XPU_UNLOCKED && + ret != RMB_MBA_XPU_UNLOCKED_SCRIBBLED) { + dev_err(qproc->dev, "MBA returned unexpected status %d\n", ret); + ret = -EINVAL; + goto halt_axi_ports; + } + + qproc->dump_mba_loaded = true; + return 0; + +halt_axi_ports: + q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6); + q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); + q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); + +reclaim_mba: + xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, false, + qproc->mba_phys, + qproc->mba_size); + if (xfermemop_ret) { + dev_err(qproc->dev, + "Failed to reclaim mba buffer, system may become unstable\n"); + } + +disable_active_clks: + q6v5_clk_disable(qproc->dev, qproc->active_clks, + qproc->active_clk_count); +assert_reset: + q6v5_reset_assert(qproc); +disable_reset_clks: + q6v5_clk_disable(qproc->dev, qproc->reset_clks, + qproc->reset_clk_count); +disable_vdd: + q6v5_regulator_disable(qproc, qproc->active_regs, + qproc->active_reg_count); +disable_proxy_clk: + q6v5_clk_disable(qproc->dev, qproc->proxy_clks, + qproc->proxy_clk_count); +disable_proxy_reg: + q6v5_regulator_disable(qproc, qproc->proxy_regs, + qproc->proxy_reg_count); +disable_irqs: + qcom_q6v5_unprepare(&qproc->q6v5); + + return ret; +} + +static void q6v5_mba_reclaim(struct q6v5 *qproc) +{ + int ret; + u32 val; + + qproc->dump_mba_loaded = false; + + q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6); + q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); + q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); + if (qproc->version == MSS_MSM8996) { + /* + * To avoid high MX current during LPASS/MSS restart. + */ + val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG); + val |= Q6SS_CLAMP_IO | QDSP6v56_CLAMP_WL | + QDSP6v56_CLAMP_QMC_MEM; + writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG); + } + + ret = q6v5_xfer_mem_ownership(qproc, &qproc->mpss_perm, + false, qproc->mpss_phys, + qproc->mpss_size); + WARN_ON(ret); + + q6v5_reset_assert(qproc); + + q6v5_clk_disable(qproc->dev, qproc->reset_clks, + qproc->reset_clk_count); + q6v5_clk_disable(qproc->dev, qproc->active_clks, + qproc->active_clk_count); + q6v5_regulator_disable(qproc, qproc->active_regs, + qproc->active_reg_count); + + /* In case of failure or coredump scenario where reclaiming MBA memory + * could not happen reclaim it here. + */ + ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, false, + qproc->mba_phys, + qproc->mba_size); + WARN_ON(ret); + + ret = qcom_q6v5_unprepare(&qproc->q6v5); + if (ret) { + q6v5_clk_disable(qproc->dev, qproc->proxy_clks, + qproc->proxy_clk_count); + q6v5_regulator_disable(qproc, qproc->proxy_regs, + qproc->proxy_reg_count); + } +} + static int q6v5_mpss_load(struct q6v5 *qproc) { const struct elf32_phdr *phdrs; @@ -801,74 +967,9 @@ static int q6v5_start(struct rproc *rproc) int xfermemop_ret; int ret; - qcom_q6v5_prepare(&qproc->q6v5); - - ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, - qproc->proxy_reg_count); - if (ret) { - dev_err(qproc->dev, "failed to enable proxy supplies\n"); - goto disable_irqs; - } - - ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks, - qproc->proxy_clk_count); - if (ret) { - dev_err(qproc->dev, "failed to enable proxy clocks\n"); - goto disable_proxy_reg; - } - - ret = q6v5_regulator_enable(qproc, qproc->active_regs, - qproc->active_reg_count); - if (ret) { - dev_err(qproc->dev, "failed to enable supplies\n"); - goto disable_proxy_clk; - } - - ret = q6v5_clk_enable(qproc->dev, qproc->reset_clks, - qproc->reset_clk_count); - if (ret) { - dev_err(qproc->dev, "failed to enable reset clocks\n"); - goto disable_vdd; - } - - ret = q6v5_reset_deassert(qproc); - if (ret) { - dev_err(qproc->dev, "failed to deassert mss restart\n"); - goto disable_reset_clks; - } - - ret = q6v5_clk_enable(qproc->dev, qproc->active_clks, - qproc->active_clk_count); - if (ret) { - dev_err(qproc->dev, "failed to enable clocks\n"); - goto assert_reset; - } - - /* Assign MBA image access in DDR to q6 */ - ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true, - qproc->mba_phys, qproc->mba_size); - if (ret) { - dev_err(qproc->dev, - "assigning Q6 access to mba memory failed: %d\n", ret); - goto disable_active_clks; - } - - writel(qproc->mba_phys, qproc->rmb_base + RMB_MBA_IMAGE_REG); - - ret = q6v5proc_reset(qproc); + ret = q6v5_mba_load(qproc); if (ret) - goto reclaim_mba; - - ret = q6v5_rmb_mba_wait(qproc, 0, 5000); - if (ret == -ETIMEDOUT) { - dev_err(qproc->dev, "MBA boot timed out\n"); - goto halt_axi_ports; - } else if (ret != RMB_MBA_XPU_UNLOCKED && - ret != RMB_MBA_XPU_UNLOCKED_SCRIBBLED) { - dev_err(qproc->dev, "MBA returned unexpected status %d\n", ret); - ret = -EINVAL; - goto halt_axi_ports; - } + return ret; dev_info(qproc->dev, "MBA booted, loading mpss\n"); @@ -897,42 +998,7 @@ static int q6v5_start(struct rproc *rproc) false, qproc->mpss_phys, qproc->mpss_size); WARN_ON(xfermemop_ret); - -halt_axi_ports: - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); - -reclaim_mba: - xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, false, - qproc->mba_phys, - qproc->mba_size); - if (xfermemop_ret) { - dev_err(qproc->dev, - "Failed to reclaim mba buffer, system may become unstable\n"); - } - -disable_active_clks: - q6v5_clk_disable(qproc->dev, qproc->active_clks, - qproc->active_clk_count); - -assert_reset: - q6v5_reset_assert(qproc); -disable_reset_clks: - q6v5_clk_disable(qproc->dev, qproc->reset_clks, - qproc->reset_clk_count); -disable_vdd: - q6v5_regulator_disable(qproc, qproc->active_regs, - qproc->active_reg_count); -disable_proxy_clk: - q6v5_clk_disable(qproc->dev, qproc->proxy_clks, - qproc->proxy_clk_count); -disable_proxy_reg: - q6v5_regulator_disable(qproc, qproc->proxy_regs, - qproc->proxy_reg_count); - -disable_irqs: - qcom_q6v5_unprepare(&qproc->q6v5); + q6v5_mba_reclaim(qproc); return ret; } @@ -941,7 +1007,6 @@ static int q6v5_stop(struct rproc *rproc) { struct q6v5 *qproc = (struct q6v5 *)rproc->priv; int ret; - u32 val; qproc->running = false; @@ -949,40 +1014,7 @@ static int q6v5_stop(struct rproc *rproc) if (ret == -ETIMEDOUT) dev_err(qproc->dev, "timed out on wait\n"); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); - if (qproc->version == MSS_MSM8996) { - /* - * To avoid high MX current during LPASS/MSS restart. - */ - val = readl(qproc->reg_base + QDSP6SS_PWR_CTL_REG); - val |= Q6SS_CLAMP_IO | QDSP6v56_CLAMP_WL | - QDSP6v56_CLAMP_QMC_MEM; - writel(val, qproc->reg_base + QDSP6SS_PWR_CTL_REG); - } - - - ret = q6v5_xfer_mem_ownership(qproc, &qproc->mpss_perm, false, - qproc->mpss_phys, qproc->mpss_size); - WARN_ON(ret); - - q6v5_reset_assert(qproc); - - ret = qcom_q6v5_unprepare(&qproc->q6v5); - if (ret) { - q6v5_clk_disable(qproc->dev, qproc->proxy_clks, - qproc->proxy_clk_count); - q6v5_regulator_disable(qproc, qproc->proxy_regs, - qproc->proxy_reg_count); - } - - q6v5_clk_disable(qproc->dev, qproc->reset_clks, - qproc->reset_clk_count); - q6v5_clk_disable(qproc->dev, qproc->active_clks, - qproc->active_clk_count); - q6v5_regulator_disable(qproc, qproc->active_regs, - qproc->active_reg_count); + q6v5_mba_reclaim(qproc); return 0; } From patchwork Wed Oct 17 13:55:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10645669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7703215E2 for ; Wed, 17 Oct 2018 13:56:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64D3B2AE9A for ; Wed, 17 Oct 2018 13:56:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58FB52AEAB; Wed, 17 Oct 2018 13:56:13 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F29DB2AE9A for ; Wed, 17 Oct 2018 13:56:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727567AbeJQVv6 (ORCPT ); Wed, 17 Oct 2018 17:51:58 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44438 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeJQVv5 (ORCPT ); Wed, 17 Oct 2018 17:51:57 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AC7586132F; Wed, 17 Oct 2018 13:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784567; bh=04y2TahKeW7N1261nI48AyV+3lS5X15YaOUQyCHohC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DlXaLHqh/k0zJxxdxayV07Yw47igGXfDSXRS5HzfVlgeTdlSp5icZHrJAJA3cfWGM DnvJujxBhOAypI92hiyurodS9yVOJJue6FNSUMK4iYAqhKRzFeSsvHVDqzgihH+sNC KHguRAtPdvKakyvQpto6Qws+k4vOAJTRJ6hWZ4uM= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 634A26130F; Wed, 17 Oct 2018 13:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784566; bh=04y2TahKeW7N1261nI48AyV+3lS5X15YaOUQyCHohC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmP2j8pdS+k4/lXflBhq7260k1PvCPFvs4X9LFUveNQN1EMdKks7zdMpHHbg/rAjO Fmr+kyEWkLGJlOt14ThOnJcV2yYQZX4zESDgCDYxSByYYJk+9sDmg4+/jjjcifzkay 2yHMigCQMayEo73HXFtIuBVZWSYTFUjGuPKNv3No= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 634A26130F 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=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tsoni@codeaurora.org, sricharan@codeaurora.org, akdwived@codeaurora.org, kyan@codeaurora.org, Sibi Sankar Subject: [PATCH v5 4/5] remoteproc: qcom: q6v5-mss: Add custom dump function for modem Date: Wed, 17 Oct 2018 19:25:26 +0530 Message-Id: <20181017135527.30592-5-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181017135527.30592-1-sibis@codeaurora.org> References: <20181017135527.30592-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The per segment dump function is responsible for loading the mba before device memory segments associated with coredump can be populated and for cleaning up the resources post coredump. Signed-off-by: Sibi Sankar --- drivers/remoteproc/qcom_q6v5_mss.c | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 87d7f4d0c176..0d3b9d70823e 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -168,6 +168,9 @@ struct q6v5 { bool running; bool dump_mba_loaded; + unsigned long dump_segment_mask; + unsigned long dump_complete_mask; + phys_addr_t mba_phys; void *mba_region; size_t mba_size; @@ -961,6 +964,33 @@ static int q6v5_mpss_load(struct q6v5 *qproc) return ret < 0 ? ret : 0; } +static void qcom_q6v5_dump_segment(struct rproc *rproc, + struct rproc_dump_segment *segment, + void *dest) +{ + int ret = 0; + struct q6v5 *qproc = rproc->priv; + unsigned long mask = BIT((unsigned long)segment->priv); + void *ptr = rproc_da_to_va(rproc, segment->da, segment->size); + + /* Unlock mba before copying segments */ + if (!qproc->dump_mba_loaded) + ret = q6v5_mba_load(qproc); + + if (!ptr || ret) + memset(dest, 0xff, segment->size); + else + memcpy(dest, ptr, segment->size); + + qproc->dump_segment_mask |= mask; + + /* Reclaim mba after copying segments */ + if (qproc->dump_segment_mask == qproc->dump_complete_mask) { + if (qproc->dump_mba_loaded) + q6v5_mba_reclaim(qproc); + } +} + static int q6v5_start(struct rproc *rproc) { struct q6v5 *qproc = (struct q6v5 *)rproc->priv; @@ -989,6 +1019,9 @@ static int q6v5_start(struct rproc *rproc) if (xfermemop_ret) dev_err(qproc->dev, "Failed to reclaim mba buffer system may become unstable\n"); + + /* Reset Dump Segment Mask */ + qproc->dump_segment_mask = 0; qproc->running = true; return 0; From patchwork Wed Oct 17 13:55:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 10645673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5DF8109C for ; Wed, 17 Oct 2018 13:56:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D31B32AE9A for ; Wed, 17 Oct 2018 13:56:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C15DB2AEAB; Wed, 17 Oct 2018 13:56:19 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53D1C2AE9A for ; Wed, 17 Oct 2018 13:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727587AbeJQVwC (ORCPT ); Wed, 17 Oct 2018 17:52:02 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44534 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbeJQVwC (ORCPT ); Wed, 17 Oct 2018 17:52:02 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3CEE161323; Wed, 17 Oct 2018 13:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784572; bh=+LblrXMLhtDQ9Kdc3zpoX4sqvJus1UMjS5/fDiaXT64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VT3MTbU33k5rppo7Bbg41U9AOPHQ/0NYt/Cm/3B9nO3YVP06uEW4IzQ3fut5GlZ9V KjSdbpzaLdP+m2Z1mpMnbi78/FRbVyqNbbriRP/IJ+GeeZoU/INNx6yNCIwvVmiQqC EMMtijOBT6SVUycOswFyRwNeanKADPH4+yY5VCWc= Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 98A9261400; Wed, 17 Oct 2018 13:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539784571; bh=+LblrXMLhtDQ9Kdc3zpoX4sqvJus1UMjS5/fDiaXT64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IV/8CfOjzdQeMbL7ub/51AcPjN5bYP2ThGz85hI0iH6ZA80CHilEyBcQTmM0Y3+NH bqKXK7x0g9MTvBrDB4ygBiKLmzb6KCG19ON9Pj1oO2LmlOUzx6ZM0FewUPseCMovAP 2IPfPR0XI25VnLWSBh9A+LxfO44lWobeLl2KZg2E= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 98A9261400 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=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tsoni@codeaurora.org, sricharan@codeaurora.org, akdwived@codeaurora.org, kyan@codeaurora.org, Sibi Sankar Subject: [PATCH v5 5/5] remoteproc: qcom: q6v5-mss: Register segments/dumpfn for coredump Date: Wed, 17 Oct 2018 19:25:27 +0530 Message-Id: <20181017135527.30592-6-sibis@codeaurora.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181017135527.30592-1-sibis@codeaurora.org> References: <20181017135527.30592-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Register the MDT segments, custom dumpfn and private data with the remoteproc core dump functionality. Signed-off-by: Sibi Sankar --- drivers/remoteproc/qcom_q6v5_mss.c | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 0d3b9d70823e..8ceebde75d02 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1064,10 +1064,52 @@ static void *q6v5_da_to_va(struct rproc *rproc, u64 da, int len) return qproc->mpss_region + offset; } +static int qcom_q6v5_register_dump_segments(struct rproc *rproc, + const struct firmware *mba_fw) +{ + const struct firmware *fw; + const struct elf32_phdr *phdrs; + const struct elf32_phdr *phdr; + const struct elf32_hdr *ehdr; + struct q6v5 *qproc = rproc->priv; + unsigned long i; + int ret; + + ret = request_firmware(&fw, "modem.mdt", qproc->dev); + if (ret < 0) { + dev_err(qproc->dev, "unable to load modem.mdt\n"); + return ret; + } + + ehdr = (struct elf32_hdr *)fw->data; + phdrs = (struct elf32_phdr *)(ehdr + 1); + qproc->dump_complete_mask = 0; + + for (i = 0; i < ehdr->e_phnum; i++) { + phdr = &phdrs[i]; + + if (!q6v5_phdr_valid(phdr)) + continue; + + ret = rproc_coredump_add_custom_segment(rproc, phdr->p_paddr, + phdr->p_memsz, + (void *)i, + qcom_q6v5_dump_segment); + if (ret) + break; + + qproc->dump_complete_mask |= BIT(i); + } + + release_firmware(fw); + return ret; +} + static const struct rproc_ops q6v5_ops = { .start = q6v5_start, .stop = q6v5_stop, .da_to_va = q6v5_da_to_va, + .parse_fw = qcom_q6v5_register_dump_segments, .load = q6v5_load, };