From patchwork Sat Jan 6 00:04:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123583 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1434368qgn; Fri, 5 Jan 2018 16:04:58 -0800 (PST) X-Google-Smtp-Source: ACJfBovBpHvcB8wyedmlB37U4TjPKu6+f+K+ggmzdVoQQXxBS5DVfiucdQyNpCL39YPcjZOuxrpj X-Received: by 10.101.73.15 with SMTP id p15mr3753946pgs.16.1515197098197; Fri, 05 Jan 2018 16:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515197098; cv=none; d=google.com; s=arc-20160816; b=FmF74mC4tt4lmGmMf3TRDiTmtjvlFhIiHaKOatxu3mP1RLB/iIJKOSoGZJUEVssvkq YcfpifJyCezurGWUTzxgTqPaQqDZFO0FK5H7iTuk6pZyh96CANo9dPRKM5EQaKkQmQ/0 aVpDgaWlRNGSse/NgsN2pvCpsWDIzp5/dEYD2KhRQXd2HutEbxdWVN7UzxaLM3X8a/gQ hq3UqGbYsUVs9wmHltSkIXvI6m3ZK+VaMAZ6I2Cs+2BDlaBelKw7q8VPfAF99ys2jAhW KTGqPnPgJlZB9InPnsssqs66CpcaZIP/xAVBc+YVi2e+FYrd9YoXV4NczaIdgTALRFYp M5dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1RY3dpURHCvgjCLnguODv9NRzb+bfv3M4cMa1W/uSh4=; b=V5CB3G+HSiUjTD+EQLzr1j334lTYcADQiQepzNQhN0zkilRHnCRuqSh+L42JwzXFLE RcS0W6Fspr+/ou0y3TFoBdTA8NmYfAUS+f2zVwkuD3IAla0e8aYPPvZgN3kb8xTG6V7S hdbSltmRyAL7ATjg1xlf2bGKZEpPb67nwQ978mC265hLOmc9foA1TJLEfSnQ6W1kd1Qy 5oEPt3OCMwMaYLetZuKPI+AMzNNUVxfK78lSqYv9XE0KLKmTop1t3Yh5/fLqLUfgJiKs 2PDPKT3HxTOUyXtUNn3ws8c5icx3e1pWOXDRzdvaBpVECvv1GiDQ2fYwT3ydAkitmRw2 2HFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TPZnmNYc; 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 x1si4762712pfj.295.2018.01.05.16.04.57; Fri, 05 Jan 2018 16:04:58 -0800 (PST) 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=TPZnmNYc; 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 S1753464AbeAFAEb (ORCPT + 28 others); Fri, 5 Jan 2018 19:04:31 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:37308 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423AbeAFAE2 (ORCPT ); Fri, 5 Jan 2018 19:04:28 -0500 Received: by mail-pl0-f66.google.com with SMTP id s3so3986657plp.4 for ; Fri, 05 Jan 2018 16:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1RY3dpURHCvgjCLnguODv9NRzb+bfv3M4cMa1W/uSh4=; b=TPZnmNYc2fZ0G6Io0I55m8SGVRPWAnXtUQFFo0bVLqr1QBqpm12H1V0efSQnRYpx7/ +J7EaF633fzc/SJjmN28TzBiETdtAIK7+IkzWTVVlGocqfPFcBsLj1WxDnRfXLhUFoPV 2RVO2h8zurTfW4LxtWnPFmSUgn/CSBrE6pE+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1RY3dpURHCvgjCLnguODv9NRzb+bfv3M4cMa1W/uSh4=; b=nmAPDK1WKDIAntGxjr1q4r0hzbPlQyBVQ3WpaTmDas6ee2EVKoXiN69h3lSVyc7D4D 3N4U60A5/VnZB238NMVPj1YHRYPKYZFDpOyZIsbq/3w7xCPAQXAddVDX3u38jzxXxZxo 7HGbPExs94NU5mU8RHfKhFimRWbC/QfX/ECj13/fX0eu4CRsepZbAvQ+bFjxDBVlK+ez zqOcxUGKw20F7+sV8qB3p1lisei7QW2zdofZbTv5+Q7pguWkP8eTyWuhkHWiGoWZdJkc Wt6mrml9sH2Vk3uhi+DfrsDk/RnBHErnPNi1+2p5Kp5obKhsxz60Mi3no0qO8LYLkief e2dg== X-Gm-Message-State: AKGB3mKIAQ+dV1hLWr3HTyi4ZArs/zfn7OeTNNVF/ICfds0Z0zh8O1ZC aV7moQYpSZaTKEC8b5OJu1uITR4ap0Y= X-Received: by 10.84.240.72 with SMTP id h8mr4692430plt.412.1515197067576; Fri, 05 Jan 2018 16:04:27 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id n186sm9385177pgn.11.2018.01.05.16.04.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 16:04:26 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Suman Anna , Avaneesh Kumar Dwivedi , Loic Pallardy Subject: [PATCH v3 3/4] soc: qcom: mdt-loader: Return relocation base Date: Fri, 5 Jan 2018 16:04:19 -0800 Message-Id: <20180106000420.10070-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180106000420.10070-1-bjorn.andersson@linaro.org> References: <20180106000420.10070-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to implement support for grabbing core dumps in remoteproc it's necessary to know the relocated base of the image, as the offsets from the virtual memory base might not be based on the physical address. Return the adjusted physical base address to the caller. Signed-off-by: Bjorn Andersson --- Changes since v2: - None Changes since v1: - New patch drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- drivers/media/platform/qcom/venus/firmware.c | 2 +- drivers/remoteproc/qcom_adsp_pil.c | 4 +++- drivers/remoteproc/qcom_wcnss.c | 3 ++- drivers/soc/qcom/mdt_loader.c | 7 ++++++- include/linux/soc/qcom/mdt_loader.h | 3 ++- 6 files changed, 16 insertions(+), 7 deletions(-) -- 2.15.0 diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index a1f4eeeb73e2..3cab1c74df84 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -87,14 +87,14 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname) */ if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) { ret = qcom_mdt_load(dev, fw, fwname, GPU_PAS_ID, - mem_region, mem_phys, mem_size); + mem_region, mem_phys, mem_size, NULL); } else { char newname[strlen("qcom/") + strlen(fwname) + 1]; sprintf(newname, "qcom/%s", fwname); ret = qcom_mdt_load(dev, fw, newname, GPU_PAS_ID, - mem_region, mem_phys, mem_size); + mem_region, mem_phys, mem_size, NULL); } if (ret) goto out; diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c index 521d4b36c090..c4a577848dd7 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -76,7 +76,7 @@ int venus_boot(struct device *dev, const char *fwname) } ret = qcom_mdt_load(dev, mdt, fwname, VENUS_PAS_ID, mem_va, mem_phys, - mem_size); + mem_size, NULL); release_firmware(mdt); diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 373c167892d7..833763aa3f2a 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -82,7 +82,9 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; return qcom_mdt_load(adsp->dev, fw, rproc->firmware, adsp->pas_id, - adsp->mem_region, adsp->mem_phys, adsp->mem_size); + adsp->mem_region, adsp->mem_phys, adsp->mem_size, + &adsp->mem_reloc); + } static int adsp_start(struct rproc *rproc) diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index 3f0609236a76..599c1aa73b7f 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -153,7 +153,8 @@ static int wcnss_load(struct rproc *rproc, const struct firmware *fw) struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; return qcom_mdt_load(wcnss->dev, fw, rproc->firmware, WCNSS_PAS_ID, - wcnss->mem_region, wcnss->mem_phys, wcnss->mem_size); + wcnss->mem_region, wcnss->mem_phys, + wcnss->mem_size, &wcnss->mem_reloc); } static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss) diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 08bd8549242a..17b314d9a148 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -83,12 +83,14 @@ EXPORT_SYMBOL_GPL(qcom_mdt_get_size); * @mem_region: allocated memory region to load firmware into * @mem_phys: physical address of allocated memory region * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation * * Returns 0 on success, negative errno otherwise. */ int qcom_mdt_load(struct device *dev, const struct firmware *fw, const char *firmware, int pas_id, void *mem_region, - phys_addr_t mem_phys, size_t mem_size) + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base) { const struct elf32_phdr *phdrs; const struct elf32_phdr *phdr; @@ -192,6 +194,9 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, memset(ptr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); } + if (reloc_base) + *reloc_base = mem_reloc; + out: kfree(fw_name); diff --git a/include/linux/soc/qcom/mdt_loader.h b/include/linux/soc/qcom/mdt_loader.h index bd8e0864b059..5b98bbdabc25 100644 --- a/include/linux/soc/qcom/mdt_loader.h +++ b/include/linux/soc/qcom/mdt_loader.h @@ -14,6 +14,7 @@ struct firmware; ssize_t qcom_mdt_get_size(const struct firmware *fw); int qcom_mdt_load(struct device *dev, const struct firmware *fw, const char *fw_name, int pas_id, void *mem_region, - phys_addr_t mem_phys, size_t mem_size); + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base); #endif From patchwork Sat Jan 6 00:04:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123582 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1434058qgn; Fri, 5 Jan 2018 16:04:35 -0800 (PST) X-Google-Smtp-Source: ACJfBosqFTXmXdHiRyzg/J+bX+bdviTXT0siBWLZhFzu4cX3Zx7xAqpXwSjO2eJGRozPTplj1nKT X-Received: by 10.84.235.204 with SMTP id m12mr4843167plt.110.1515197075872; Fri, 05 Jan 2018 16:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515197075; cv=none; d=google.com; s=arc-20160816; b=EFAs9p9ximBTUMia+v9jO0IcpR4E1ud8CJRvwH7o43lww+lDD8EQMsxdpa7h5rI4b7 /mO0y4yuTwgoqyj6wkdVCH8QRCPYvcFs/SP02lLCu8jM+jKFLgyATu+bmNT8vFwvvNtN lJ//QsBmtsd4HF7J918+vUNG8QQNlj/ZtPsTk4m71uQeQ+5lEy1UJsFvhB4Tz5sNX7Vf hZd/fWIGJbPb4/vK+6wt8gvHA0/QrfJOR80y4rudIPTTFyL4rgH20e7FDdFFK/y1ItWo Il5tWBkwIyjgMP8aGQydWvBGIilt5qx1veiQtLkIuYyJnYHppzc0Y7/HbcG4LND1/6bY pWgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Cz+CKekxbUP0KWI+AaSTK1yPmpou9MMSa6rOLHAqa84=; b=dxVZTNpyldecqCWqRFbb+5Ylakf5bOcF+mQTcgko9JDKK5/Z3BF/bc8jog8HrYe05g 417bF7pOHffOIWKu25NDOpdQbve7o1oxAs7W3pIfTIoUpOrlkX4EBM9fYoyr2UCRwETG 66IHU0vWG3XIb3/VUj6Fbby9/BcskvBEvG8MqtWSFkkGdK41+yq7QiNWfOVAcVetDtSM BhIhsimZG4rE7fIBE9oUk3/WGenwjRH3Ui/6Ol7uJDtGGKq+FU4b1icLbRWYpgnTO4WA kMq4x/uMQHNqf40sLKh1/XBWzvab+oX4r6bg9imveu+yzfVruku5t9mHKdByDCUzibHE mLqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h6tRsrOS; 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 d32si4751409pld.89.2018.01.05.16.04.35; Fri, 05 Jan 2018 16:04:35 -0800 (PST) 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=h6tRsrOS; 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 S1753506AbeAFAEe (ORCPT + 28 others); Fri, 5 Jan 2018 19:04:34 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:40827 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753425AbeAFAE3 (ORCPT ); Fri, 5 Jan 2018 19:04:29 -0500 Received: by mail-pl0-f66.google.com with SMTP id 62so3990285pld.7 for ; Fri, 05 Jan 2018 16:04:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cz+CKekxbUP0KWI+AaSTK1yPmpou9MMSa6rOLHAqa84=; b=h6tRsrOSyLIfsL0CEgMC7Yq0QQ8nJYnvte1YZWLJAJlgc//pS8DuDs34I9VZgfUN0O 5snCI5qtp8M4quDCFYEJJonEK3R+MawHKDElhKjsgFx6Ru4rqvOkdTPtMkjVVFnZnMFk a7o7sxgoQ3QrBHa3kyoNEWnxPypS5J8Fa9Kzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cz+CKekxbUP0KWI+AaSTK1yPmpou9MMSa6rOLHAqa84=; b=q/FhutqyWtF+ap3/P0eA8mZTRaahHyfJsVyTeZv39uEKYOGoyPjzjesuetmEdJJpt6 iC/+9tv7RLvdYgoLpx4NA0ubXt7r/jXEL7KAon2mNcF7Zg6GOaeHcLkongQNbdQkHjWz myZ6RsdSLbPHBjbpVsixkSRqNJKWISxDFfiSKaTgUMQDeTZhRkF6vLkFBeQOE33+OdWA rxyplsmYAE3qbU9CLZN5zOudZusUy2DtVWLNSWy2yF4ufjaGOfUkuExNex7yp1sCHn46 jqxkAvDRvsx/msrNltyGKzdUBiuq9vzbULPGNtTc3GjSPMVvXFj7PIBYbQgWUvcqbq1q 6PjQ== X-Gm-Message-State: AKGB3mLyYgoyOKZVlKQIVFvx8X5hAnbprm3iDxCC06KlZ/ydJDEyEyEm GWQlrDp0THxGK/5Fp9xc67wtvw== X-Received: by 10.84.235.134 with SMTP id p6mr4718383plk.114.1515197068718; Fri, 05 Jan 2018 16:04:28 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id n186sm9385177pgn.11.2018.01.05.16.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 16:04:28 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Suman Anna , Avaneesh Kumar Dwivedi , Loic Pallardy Subject: [PATCH v3 4/4] remoteproc: qcom: Register segments for core dump Date: Fri, 5 Jan 2018 16:04:20 -0800 Message-Id: <20180106000420.10070-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180106000420.10070-1-bjorn.andersson@linaro.org> References: <20180106000420.10070-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sarangdhar Joshi Register MDT segments with the remoteproc core dump functionality in order to include them in a core dump, in case of a recovery of the remote processor. Signed-off-by: Sarangdhar Joshi Signed-off-by: Bjorn Andersson --- Changes since v2: - None Changes since v1: - Extracted from first patch drivers/remoteproc/qcom_adsp_pil.c | 1 + drivers/remoteproc/qcom_common.c | 44 ++++++++++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_common.h | 2 ++ drivers/remoteproc/qcom_wcnss.c | 1 + 4 files changed, 48 insertions(+) -- 2.15.0 diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 833763aa3f2a..af12cdd45b71 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -179,6 +179,7 @@ static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, + .parse_fw = qcom_register_dump_segments, .load = adsp_load, }; diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 6eb9161f80b3..f9a0701c94e7 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "remoteproc_internal.h" #include "qcom_common.h" @@ -79,6 +80,49 @@ void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glin } EXPORT_SYMBOL_GPL(qcom_remove_glink_subdev); +/** + * qcom_register_dump_segments() - register segments for coredump + * @rproc: remoteproc handle + * @fw: firmware header + * + * Register all segments of the ELF in the remoteproc coredump segment list + * + * Return: 0 on success, negative errno on failure. + */ +int qcom_register_dump_segments(struct rproc *rproc, + const struct firmware *fw) +{ + const struct elf32_phdr *phdrs; + const struct elf32_phdr *phdr; + const struct elf32_hdr *ehdr; + int ret; + int i; + + ehdr = (struct elf32_hdr *)fw->data; + phdrs = (struct elf32_phdr *)(ehdr + 1); + + for (i = 0; i < ehdr->e_phnum; i++) { + phdr = &phdrs[i]; + + if (phdr->p_type != PT_LOAD) + continue; + + if ((phdr->p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) + continue; + + if (!phdr->p_memsz) + continue; + + ret = rproc_coredump_add_segment(rproc, phdr->p_paddr, + phdr->p_memsz); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_register_dump_segments); + static int smd_subdev_probe(struct rproc_subdev *subdev) { struct qcom_rproc_subdev *smd = to_smd_subdev(subdev); diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index 728be9834d8b..7e614520fb69 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -30,6 +30,8 @@ struct qcom_rproc_ssr { void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink); void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink); +int qcom_register_dump_segments(struct rproc *rproc, const struct firmware *fw); + void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index 599c1aa73b7f..e9f9ba4c584d 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -309,6 +309,7 @@ static const struct rproc_ops wcnss_ops = { .start = wcnss_start, .stop = wcnss_stop, .da_to_va = wcnss_da_to_va, + .parse_fw = qcom_register_dump_segments, .load = wcnss_load, };