From patchwork Wed Jun 7 01:44:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarangdhar Joshi X-Patchwork-Id: 9770481 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 9A7CE60353 for ; Wed, 7 Jun 2017 01:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78C8C28512 for ; Wed, 7 Jun 2017 01:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C9A528524; Wed, 7 Jun 2017 01:45:21 +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=unavailable 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 E3B4D28512 for ; Wed, 7 Jun 2017 01:45:20 +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: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:In-Reply-To: References:List-Owner; bh=kwNgTmFhcPGUz6qorWXLADXII9CGWaJnBznjXVMjEzE=; b=lXC h5mvPVaW+6oeDNXZ9S4rllAbTdDAaQdJuJfKjACULE+kcYBppzTBMrhm/7BKQztjIgC55xL3P3FGM Rzwvoqzkh7lgtkYpQjObQvHuUF8nMoBrdzNEjdUydHJpeu/F92iq6biXkjchVB+08zTRHWss9YH7a iZ3fN5XLJfJCaAK/oOOhhc2DYZoe2yI/iP86CfrjI43d8+7Pb9xvg5fqSKz2yG/gWbWQrEjn69fJ0 aizm3g0ZQ3oY9+32tcl9+I1yQSwbtK7N/JCyiQPfSgaRBi2B+YRwwI7CGWlctLSyopY6rtk8yffXz vGGxyPJ5WRumia6YI0COs4PD6mvyiUw==; 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 1dIQ28-00025R-38; Wed, 07 Jun 2017 01:45:16 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dIQ24-0000pZ-M9 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2017 01:45:14 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2782260A19; Wed, 7 Jun 2017 01:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1496799891; bh=g6YICc6SP06Oxb8yt5d5yth1CQimmFun7rXI6kuwPzk=; h=From:To:Cc:Subject:Date:From; b=afPf2Qsdk/KbuJWJtTnhjKaD7pe6khN3RT8hqH/WUwgfHnsDIKlNZ6Dq+LWujyerv AOskeNpkuMQSyIN6w+1qvhVZNSKxEMu1CVRlRBkIl1CkuqSJI4wJiAf1w3/3htwhmK 6A0YkTyr08rcclGCHWQWW9jw7eknWWCaFV6bddJY= 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 01315607BF; Wed, 7 Jun 2017 01:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1496799890; bh=g6YICc6SP06Oxb8yt5d5yth1CQimmFun7rXI6kuwPzk=; h=From:To:Cc:Subject:Date:From; b=o+cSpm1nv3pjCsT4qhqxuIwSw3UejjbtUxowSgmxZIwt9xFoMzqYsya1tvht3BsL0 c2jVlnYYacP7pq3w/X34/eCVeIvaPnkvLSBSvl+zIr4Kt7A/32+rYwX59C9MRzO6Gx 8LTAtkLiqz6QunBtrIBxKmC1UNyAsyJwxwOWOrdw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 01315607BF 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] remoteproc: qcom: mdt_loader: Fix rproc_da_to_va Date: Tue, 6 Jun 2017 18:44:41 -0700 Message-Id: <1496799881-11097-1-git-send-email-spjoshi@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170606_184512_787757_F7F1A986 X-CRM114-Status: GOOD ( 14.41 ) 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: linux-arm-msm@vger.kernel.org, Stephen Boyd , linux-kernel@vger.kernel.org, David Brown , Srinivas Kandagatla , Andy Gross , 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 Refactoring MDT loader broke rproc_da_to_va() for Qualcomm images. This causes an incorrect computation of offset and returns an incorrect virtual address for the relocatable segment(s). Fix this by adding an "out" parameter to qcom_mdt_loader() and setting the correct segment base address in that parameter. Fixes: 7f0dd07a9b29 ("remoteproc: qcom: mdt_loader: Refactor MDT loader") CC: Bjorn Andersson Signed-off-by: Sarangdhar Joshi --- drivers/remoteproc/qcom_adsp_pil.c | 3 ++- drivers/remoteproc/qcom_wcnss.c | 3 ++- drivers/soc/qcom/mdt_loader.c | 5 ++++- include/linux/soc/qcom/mdt_loader.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 49fe2f8..335066e 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -79,7 +79,8 @@ 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 const struct rproc_fw_ops adsp_fw_ops = { diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index a39a1a9..253f152e 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 const struct rproc_fw_ops wcnss_fw_ops = { diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index bd63df0..b4a30fc 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -83,12 +83,13 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) * @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 + * @img_base: base address of the firmware image * * 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 *img_base) { const struct elf32_phdr *phdrs; const struct elf32_phdr *phdr; @@ -193,6 +194,8 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, memset(ptr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); } + if (img_base) + *img_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 f423001..ea021b3 100644 --- a/include/linux/soc/qcom/mdt_loader.h +++ b/include/linux/soc/qcom/mdt_loader.h @@ -13,6 +13,6 @@ 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 *img_base); #endif