[V2,05/11] remoteproc: qcom_q6v5_mss: revert "map/unmap metadata region before/after use"
Message ID | 20230109034843.23759-6-quic_sibis@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1961927wrt; Sun, 8 Jan 2023 19:52:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7kcVQpinvt1rOJJyeia3skjHumQG5Gjwo1Lo2Xe/jEpWYplZNRXeGkPSGcXfuiPAF/Isl X-Received: by 2002:a17:907:d606:b0:84c:d34a:b4e7 with SMTP id wd6-20020a170907d60600b0084cd34ab4e7mr20623545ejc.75.1673236325857; Sun, 08 Jan 2023 19:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673236325; cv=none; d=google.com; s=arc-20160816; b=dsKiisWD087uxyhYA9sgO9ryjjmR9PPGwMjFvCTNR1EN+cEdtduCfS4x+DGHHw9yWU 003R73QlKDwsXBkqJSVD2L64BgyoqAh7AzzOV6Hj3m6o4l9XxGqlH/kcxuSa3XibHP04 v8NI030Xfp9803aAKKoous6t2ZwsAOjH9riSRNDXSh4GTkWse6apF0cD+9CiKkqsh3iJ ep1eg+oUk1031gONgprRfHDV4DMFZ8HG55cXo9wuk7Ds6WxXsjYD0dCG5gby9lbI5rn3 XCsNTNBYJ+J+EWJy0ARz2PEAKV3v/SrK8+CmobpKe0lKEqRVJeNZVxVQ/JsBlBZuMzRF ygMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X4o0c+iu9ptJuyazWKsjXHhMRyUedIVlnBh35PNY+zs=; b=YeaKS/O+5w5TijMRna5BNC8g9spSjWyz0TuHwUsszqmIle03YouMxrYdMNXOo+1RFr EazuvbdlfuHHIIDy/hDAW0gh3sacEjYuuKCfsXOK3vovsQ6NzMNqHSF5A63sM3juHDhr TdLF3q38F4I5aBsWE3OeDJvi1vmaxdx1yDD+l2jRWvXX0TZscNWloY5XviSqdZ3oX1fp ILyhznVQ5A4PaBWlPGovxUY9lkuUFbpIV2abW022BmL6WbcxfDzlg7VHgsbamkBBLXLZ q36N8azOELwhN2ESh7IpboHXdfRB7vW+Wn3OtGlTbQyr8uiwRwDjy8B8qCZd80ZQ/ppY mI1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eSedsSz4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp27-20020a1709071b1b00b0081987ff7158si8601653ejc.862.2023.01.08.19.51.43; Sun, 08 Jan 2023 19:52:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eSedsSz4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236307AbjAIDvL (ORCPT <rfc822;jian.xie.xdx@gmail.com> + 99 others); Sun, 8 Jan 2023 22:51:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233690AbjAIDun (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 8 Jan 2023 22:50:43 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D6CAB1F3; Sun, 8 Jan 2023 19:50:42 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3093HvMe005657; Mon, 9 Jan 2023 03:50:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=X4o0c+iu9ptJuyazWKsjXHhMRyUedIVlnBh35PNY+zs=; b=eSedsSz4uM1AHYVQW+VtuVKY1wqf0PPW9cRzj5m7bQyNVz8G7gWrINShs4T9WDtEF6OH KcslipdNmJMjrlaW7fb8hAP9/qrGm3Dl3LPu2du9FzRtbqemZYbpybgI6x7ypJmm9VyR OJIPw2em6iXRDbanbKC/Lwef5cFxVkfBwPg4/joAdo1XFWIsC/uB/wJODmCuBLigHfl4 DN+ILZhQBbeSlTwLUYnDx7s5HL1s8C2oWkyrhVaN03iqT0pm6y2GQiZ2GeLwiTxgIYW6 HBl7G5mLdYxp5r7fBW5eN9nPT2SGduAktFtzwsMVl5QAThjXn1K5d+QDnjhuxmqLSicm RQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3my14ft6qm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 03:50:31 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3093oTgH031383 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 03:50:29 GMT Received: from blr-ubuntu-87.ap.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 8 Jan 2023 19:50:25 -0800 From: Sibi Sankar <quic_sibis@quicinc.com> To: <andersson@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>, <robh+dt@kernel.org>, <manivannan.sadhasivam@linaro.org>, <robin.murphy@arm.com> CC: <agross@kernel.org>, <linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <konrad.dybcio@somainline.org>, <amit.pundir@linaro.org>, <regressions@leemhuis.info>, <sumit.semwal@linaro.org>, <will@kernel.org>, <catalin.marinas@arm.com>, Sibi Sankar <quic_sibis@quicinc.com> Subject: [PATCH V2 05/11] remoteproc: qcom_q6v5_mss: revert "map/unmap metadata region before/after use" Date: Mon, 9 Jan 2023 09:18:37 +0530 Message-ID: <20230109034843.23759-6-quic_sibis@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109034843.23759-1-quic_sibis@quicinc.com> References: <20230109034843.23759-1-quic_sibis@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: nbAq3DpxYQF3QiUVh29G3RwKSRhwfNaq X-Proofpoint-ORIG-GUID: nbAq3DpxYQF3QiUVh29G3RwKSRhwfNaq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-08_19,2023-01-06_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090025 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754515453173000478?= X-GMAIL-MSGID: =?utf-8?q?1754515453173000478?= |
Series |
Fix XPU violation during modem metadata authentication
|
|
Commit Message
Sibi Sankar
Jan. 9, 2023, 3:48 a.m. UTC
This reverts commit fc156629b23a21181e473e60341e3a78af25a1d4.
The memory region allocated using dma_alloc_attr with no kernel mapping
attribute set would still be a part of the linear kernel map. Hence as a
precursor to using reserved memory for modem metadata region, revert back
to the simpler way of dynamic memory allocation.
Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
---
drivers/remoteproc/qcom_q6v5_mss.c | 38 +++++-------------------------
1 file changed, 6 insertions(+), 32 deletions(-)
Comments
+ Christoph Hi Sibi, On Mon, Jan 09, 2023 at 09:18:37AM +0530, Sibi Sankar wrote: > This reverts commit fc156629b23a21181e473e60341e3a78af25a1d4. > > The memory region allocated using dma_alloc_attr with no kernel mapping > attribute set would still be a part of the linear kernel map. Hence as a > precursor to using reserved memory for modem metadata region, revert back > to the simpler way of dynamic memory allocation. > > Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> Christoph already submitted a patch that reverts fc156629b23a: https://lore.kernel.org/linux-arm-msm/20221223092703.61927-2-hch@lst.de/ Thanks, Mani > --- > drivers/remoteproc/qcom_q6v5_mss.c | 38 +++++------------------------- > 1 file changed, 6 insertions(+), 32 deletions(-) > > diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c > index 2f4027664a0e..e2f765f87ec9 100644 > --- a/drivers/remoteproc/qcom_q6v5_mss.c > +++ b/drivers/remoteproc/qcom_q6v5_mss.c > @@ -10,7 +10,6 @@ > #include <linux/clk.h> > #include <linux/delay.h> > #include <linux/devcoredump.h> > -#include <linux/dma-map-ops.h> > #include <linux/dma-mapping.h> > #include <linux/interrupt.h> > #include <linux/kernel.h> > @@ -961,52 +960,27 @@ static void q6v5proc_halt_axi_port(struct q6v5 *qproc, > static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, > const char *fw_name) > { > - unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS | DMA_ATTR_NO_KERNEL_MAPPING; > - unsigned long flags = VM_DMA_COHERENT | VM_FLUSH_RESET_PERMS; > - struct page **pages; > - struct page *page; > + unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS; > dma_addr_t phys; > void *metadata; > int mdata_perm; > int xferop_ret; > size_t size; > - void *vaddr; > - int count; > + void *ptr; > int ret; > - int i; > > metadata = qcom_mdt_read_metadata(fw, &size, fw_name, qproc->dev); > if (IS_ERR(metadata)) > return PTR_ERR(metadata); > > - page = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); > - if (!page) { > + ptr = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); > + if (!ptr) { > kfree(metadata); > dev_err(qproc->dev, "failed to allocate mdt buffer\n"); > return -ENOMEM; > } > > - count = PAGE_ALIGN(size) >> PAGE_SHIFT; > - pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL); > - if (!pages) { > - ret = -ENOMEM; > - goto free_dma_attrs; > - } > - > - for (i = 0; i < count; i++) > - pages[i] = nth_page(page, i); > - > - vaddr = vmap(pages, count, flags, pgprot_dmacoherent(PAGE_KERNEL)); > - kfree(pages); > - if (!vaddr) { > - dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n", &phys, size); > - ret = -EBUSY; > - goto free_dma_attrs; > - } > - > - memcpy(vaddr, metadata, size); > - > - vunmap(vaddr); > + memcpy(ptr, metadata, size); > > /* Hypervisor mapping to access metadata by modem */ > mdata_perm = BIT(QCOM_SCM_VMID_HLOS); > @@ -1036,7 +1010,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, > "mdt buffer not reclaimed system may become unstable\n"); > > free_dma_attrs: > - dma_free_attrs(qproc->dev, size, page, phys, dma_attrs); > + dma_free_attrs(qproc->dev, size, ptr, phys, dma_attrs); > kfree(metadata); > > return ret < 0 ? ret : 0; > -- > 2.17.1 >
Hey Mani, Thanks for taking time to review the series. On 1/9/23 13:48, Manivannan Sadhasivam wrote: > + Christoph > > Hi Sibi, > > On Mon, Jan 09, 2023 at 09:18:37AM +0530, Sibi Sankar wrote: >> This reverts commit fc156629b23a21181e473e60341e3a78af25a1d4. >> >> The memory region allocated using dma_alloc_attr with no kernel mapping >> attribute set would still be a part of the linear kernel map. Hence as a >> precursor to using reserved memory for modem metadata region, revert back >> to the simpler way of dynamic memory allocation. >> >> Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> >> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> > > Christoph already submitted a patch that reverts fc156629b23a: > https://lore.kernel.org/linux-arm-msm/20221223092703.61927-2-hch@lst.de/ Having ^^ revert as part of the this series makes more sense. I'll just replace my patch with ^^ in the next re-spin. > > Thanks, > Mani > >> --- >> drivers/remoteproc/qcom_q6v5_mss.c | 38 +++++------------------------- >> 1 file changed, 6 insertions(+), 32 deletions(-) >> >> diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c >> index 2f4027664a0e..e2f765f87ec9 100644 >> --- a/drivers/remoteproc/qcom_q6v5_mss.c >> +++ b/drivers/remoteproc/qcom_q6v5_mss.c >> @@ -10,7 +10,6 @@ >> #include <linux/clk.h> >> #include <linux/delay.h> >> #include <linux/devcoredump.h> >> -#include <linux/dma-map-ops.h> >> #include <linux/dma-mapping.h> >> #include <linux/interrupt.h> >> #include <linux/kernel.h> >> @@ -961,52 +960,27 @@ static void q6v5proc_halt_axi_port(struct q6v5 *qproc, >> static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, >> const char *fw_name) >> { >> - unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS | DMA_ATTR_NO_KERNEL_MAPPING; >> - unsigned long flags = VM_DMA_COHERENT | VM_FLUSH_RESET_PERMS; >> - struct page **pages; >> - struct page *page; >> + unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS; >> dma_addr_t phys; >> void *metadata; >> int mdata_perm; >> int xferop_ret; >> size_t size; >> - void *vaddr; >> - int count; >> + void *ptr; >> int ret; >> - int i; >> >> metadata = qcom_mdt_read_metadata(fw, &size, fw_name, qproc->dev); >> if (IS_ERR(metadata)) >> return PTR_ERR(metadata); >> >> - page = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); >> - if (!page) { >> + ptr = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); >> + if (!ptr) { >> kfree(metadata); >> dev_err(qproc->dev, "failed to allocate mdt buffer\n"); >> return -ENOMEM; >> } >> >> - count = PAGE_ALIGN(size) >> PAGE_SHIFT; >> - pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL); >> - if (!pages) { >> - ret = -ENOMEM; >> - goto free_dma_attrs; >> - } >> - >> - for (i = 0; i < count; i++) >> - pages[i] = nth_page(page, i); >> - >> - vaddr = vmap(pages, count, flags, pgprot_dmacoherent(PAGE_KERNEL)); >> - kfree(pages); >> - if (!vaddr) { >> - dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n", &phys, size); >> - ret = -EBUSY; >> - goto free_dma_attrs; >> - } >> - >> - memcpy(vaddr, metadata, size); >> - >> - vunmap(vaddr); >> + memcpy(ptr, metadata, size); >> >> /* Hypervisor mapping to access metadata by modem */ >> mdata_perm = BIT(QCOM_SCM_VMID_HLOS); >> @@ -1036,7 +1010,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, >> "mdt buffer not reclaimed system may become unstable\n"); >> >> free_dma_attrs: >> - dma_free_attrs(qproc->dev, size, page, phys, dma_attrs); >> + dma_free_attrs(qproc->dev, size, ptr, phys, dma_attrs); >> kfree(metadata); >> >> return ret < 0 ? ret : 0; >> -- >> 2.17.1 >> >
On Mon, Jan 09, 2023 at 03:30:22PM +0530, Sibi Sankar wrote: > Hey Mani, > Thanks for taking time to review the series. > > On 1/9/23 13:48, Manivannan Sadhasivam wrote: > > + Christoph > > > > Hi Sibi, > > > > On Mon, Jan 09, 2023 at 09:18:37AM +0530, Sibi Sankar wrote: > > > This reverts commit fc156629b23a21181e473e60341e3a78af25a1d4. > > > > > > The memory region allocated using dma_alloc_attr with no kernel mapping > > > attribute set would still be a part of the linear kernel map. Hence as a > > > precursor to using reserved memory for modem metadata region, revert back > > > to the simpler way of dynamic memory allocation. > > > > > > Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > > > Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> > > > > Christoph already submitted a patch that reverts fc156629b23a: > > https://lore.kernel.org/linux-arm-msm/20221223092703.61927-2-hch@lst.de/ > > Having ^^ revert as part of the this series makes more sense. I'll > just replace my patch with ^^ in the next re-spin. > That makes sense to me. Thanks, Mani > > > > Thanks, > > Mani > > > > > --- > > > drivers/remoteproc/qcom_q6v5_mss.c | 38 +++++------------------------- > > > 1 file changed, 6 insertions(+), 32 deletions(-) > > > > > > diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c > > > index 2f4027664a0e..e2f765f87ec9 100644 > > > --- a/drivers/remoteproc/qcom_q6v5_mss.c > > > +++ b/drivers/remoteproc/qcom_q6v5_mss.c > > > @@ -10,7 +10,6 @@ > > > #include <linux/clk.h> > > > #include <linux/delay.h> > > > #include <linux/devcoredump.h> > > > -#include <linux/dma-map-ops.h> > > > #include <linux/dma-mapping.h> > > > #include <linux/interrupt.h> > > > #include <linux/kernel.h> > > > @@ -961,52 +960,27 @@ static void q6v5proc_halt_axi_port(struct q6v5 *qproc, > > > static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, > > > const char *fw_name) > > > { > > > - unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS | DMA_ATTR_NO_KERNEL_MAPPING; > > > - unsigned long flags = VM_DMA_COHERENT | VM_FLUSH_RESET_PERMS; > > > - struct page **pages; > > > - struct page *page; > > > + unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS; > > > dma_addr_t phys; > > > void *metadata; > > > int mdata_perm; > > > int xferop_ret; > > > size_t size; > > > - void *vaddr; > > > - int count; > > > + void *ptr; > > > int ret; > > > - int i; > > > metadata = qcom_mdt_read_metadata(fw, &size, fw_name, qproc->dev); > > > if (IS_ERR(metadata)) > > > return PTR_ERR(metadata); > > > - page = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); > > > - if (!page) { > > > + ptr = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); > > > + if (!ptr) { > > > kfree(metadata); > > > dev_err(qproc->dev, "failed to allocate mdt buffer\n"); > > > return -ENOMEM; > > > } > > > - count = PAGE_ALIGN(size) >> PAGE_SHIFT; > > > - pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL); > > > - if (!pages) { > > > - ret = -ENOMEM; > > > - goto free_dma_attrs; > > > - } > > > - > > > - for (i = 0; i < count; i++) > > > - pages[i] = nth_page(page, i); > > > - > > > - vaddr = vmap(pages, count, flags, pgprot_dmacoherent(PAGE_KERNEL)); > > > - kfree(pages); > > > - if (!vaddr) { > > > - dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n", &phys, size); > > > - ret = -EBUSY; > > > - goto free_dma_attrs; > > > - } > > > - > > > - memcpy(vaddr, metadata, size); > > > - > > > - vunmap(vaddr); > > > + memcpy(ptr, metadata, size); > > > /* Hypervisor mapping to access metadata by modem */ > > > mdata_perm = BIT(QCOM_SCM_VMID_HLOS); > > > @@ -1036,7 +1010,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, > > > "mdt buffer not reclaimed system may become unstable\n"); > > > free_dma_attrs: > > > - dma_free_attrs(qproc->dev, size, page, phys, dma_attrs); > > > + dma_free_attrs(qproc->dev, size, ptr, phys, dma_attrs); > > > kfree(metadata); > > > return ret < 0 ? ret : 0; > > > -- > > > 2.17.1 > > > > >
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 2f4027664a0e..e2f765f87ec9 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -10,7 +10,6 @@ #include <linux/clk.h> #include <linux/delay.h> #include <linux/devcoredump.h> -#include <linux/dma-map-ops.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h> @@ -961,52 +960,27 @@ static void q6v5proc_halt_axi_port(struct q6v5 *qproc, static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, const char *fw_name) { - unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS | DMA_ATTR_NO_KERNEL_MAPPING; - unsigned long flags = VM_DMA_COHERENT | VM_FLUSH_RESET_PERMS; - struct page **pages; - struct page *page; + unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS; dma_addr_t phys; void *metadata; int mdata_perm; int xferop_ret; size_t size; - void *vaddr; - int count; + void *ptr; int ret; - int i; metadata = qcom_mdt_read_metadata(fw, &size, fw_name, qproc->dev); if (IS_ERR(metadata)) return PTR_ERR(metadata); - page = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); - if (!page) { + ptr = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs); + if (!ptr) { kfree(metadata); dev_err(qproc->dev, "failed to allocate mdt buffer\n"); return -ENOMEM; } - count = PAGE_ALIGN(size) >> PAGE_SHIFT; - pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL); - if (!pages) { - ret = -ENOMEM; - goto free_dma_attrs; - } - - for (i = 0; i < count; i++) - pages[i] = nth_page(page, i); - - vaddr = vmap(pages, count, flags, pgprot_dmacoherent(PAGE_KERNEL)); - kfree(pages); - if (!vaddr) { - dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n", &phys, size); - ret = -EBUSY; - goto free_dma_attrs; - } - - memcpy(vaddr, metadata, size); - - vunmap(vaddr); + memcpy(ptr, metadata, size); /* Hypervisor mapping to access metadata by modem */ mdata_perm = BIT(QCOM_SCM_VMID_HLOS); @@ -1036,7 +1010,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, "mdt buffer not reclaimed system may become unstable\n"); free_dma_attrs: - dma_free_attrs(qproc->dev, size, page, phys, dma_attrs); + dma_free_attrs(qproc->dev, size, ptr, phys, dma_attrs); kfree(metadata); return ret < 0 ? ret : 0;