From patchwork Wed Dec 13 18:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Viswanathan X-Patchwork-Id: 178230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7971196dys; Wed, 13 Dec 2023 10:13:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IErPKR3VNfBzs+gRZinCtrwujTbmLEgviccMeZkwuEcVOYIc6iLttd6Xa8z/3Y6mDdIWk8J X-Received: by 2002:a05:6a20:431a:b0:18c:9856:8ce with SMTP id h26-20020a056a20431a00b0018c985608cemr4997633pzk.6.1702491226908; Wed, 13 Dec 2023 10:13:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702491226; cv=none; d=google.com; s=arc-20160816; b=J6/0NyDop7oKDcrXz0uASH8p0yxq7q/1iuUakY4FGpdhKG0Iy5vjunJBBeNgc7QFyD U81Um7DJ9o0LeRt5MGnOC1LvkmwMJPXJkTDk3cc27KEWemxIci12lU+vVdBQFLN2dF7e nB18iqUGlqBRN6Vf+IdM4A2XLO3zzPun35Zm5sWaMfOGHaRBy6pRufL7hWA3szVX5I58 1GM/OOOsEmEGk94D9q0g27S7TnHif3uIlzBs/2/oZUR8FBrrbP/aGVqTwHOtxlii0BLQ f122a/5fE82k07J3EKctJWC9n1cNcYvFUxIhwsqUVAcj4aZyEelX0rSePqw6AQnvCAK2 tCkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=iXUSdzlWhi9I84iGPxMHNa5qw5UEecWxK8/qXwJLZSc=; fh=gfKkchR19O4mr62XneF+KKrYWdW4kO0Cervoks0nsQI=; b=tmH9ObfChjQ9eXB/LubtqIrt/WLUwSAzuNHpOhXXvfDGrPgZQE6Lwh7iSy1Mx/SRfU 8MVpMhJd+V0Z+x3Be4R+Y0/HXf8yD7sFplxapxLAWFc3eaafw1lbC/zSadj6oWqLkwc8 D25DvzPxKVSCw3oJH64evVjq1x952UY2wX1gnFlZHapfTe3DCQG1hLMGqx0w5hXCw5zm 7nkOFW4WSj/Lgg6dmq3qQNRz3JgIICr5MLObxR3aguL7xabb90+sbPttuwA4rdtDCL0w ehbLKnSKGn5rgC+gk4yAXUj9P6we0F8AepC3o3L95LYXMmwL91Qb0fn27d370mVhwZOP FBaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UScuhTB2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id p9-20020a056a000b4900b006cdf0b9051dsi10013239pfo.186.2023.12.13.10.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:13:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UScuhTB2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A45D8808577A; Wed, 13 Dec 2023 10:13:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235449AbjLMSNd (ORCPT + 99 others); Wed, 13 Dec 2023 13:13:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233776AbjLMSNb (ORCPT ); Wed, 13 Dec 2023 13:13:31 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E3C5F2; Wed, 13 Dec 2023 10:13:37 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BDEdBZJ001943; Wed, 13 Dec 2023 18:13:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=iXUSdzl Whi9I84iGPxMHNa5qw5UEecWxK8/qXwJLZSc=; b=UScuhTB2JCMTA2RwUI2hBYM k9vjjcXjQjK8ccwmhv5LfoyRSiIYTVHLjsCBIbKxivc/d49AKvZBNvQ6fR+XZXVJ 2k5OCM66uvJS+Ce4V0XSmRc5X3HmLbvKVo2raB3hazYdiSyLEzHW7YcTNjStpa8H tvaitdnaN7ppB2FtPGRnMUBj+Uor0iJjLmMKelXGyYWzbnvBNgl3RWSEtWg4BDy6 vu9aTCcf04LdvMYGs01s2+812W6ZVlBSvfHMtmX9Zl0e8X5YSGZIUlE16HBPuivk 6OX8zwIqWW8Sa/elImi3XUuleR/BbodNQh19bU4L2kpXZHWsgGahKnHT2FDIabQ= = Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uy7j7skm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 18:13:33 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BDIDWL1025998 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 18:13:32 GMT Received: from hu-viswanat-blr.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 13 Dec 2023 10:13:28 -0800 From: Vignesh Viswanathan To: , , , , , , CC: , , "Vignesh Viswanathan" Subject: [PATCH] remoteproc: qcom: q6v5_mpd: Add custom coredump segments Date: Wed, 13 Dec 2023 23:43:14 +0530 Message-ID: <20231213181314.271484-1-quic_viswanat@quicinc.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: kHQ0fPJlbkhyp9k2wsUktSa-KRB2btFJ X-Proofpoint-ORIG-GUID: kHQ0fPJlbkhyp9k2wsUktSa-KRB2btFJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 mlxlogscore=799 phishscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312130129 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:13:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785191440972390142 X-GMAIL-MSGID: 1785191440972390142 IPQ9574 and IPQ5332 can have multiple reserved memory regions that needs to be collected as part of the coredump. Loop through all the regions defined under reserved-memory node in the devicetree for the remoteproc and add each as a custom segment for coredump. Also, update the ELF info for coredump collection for multipd remoteprocs. This patch depends on [1] which adds support for IPQ9574 and IPQ5332 remoteproc q5v5_mpd driver. [1]: https://lore.kernel.org/all/20231110091939.3025413-1-quic_mmanikan@quicinc.com/ Signed-off-by: Vignesh Viswanathan --- drivers/remoteproc/qcom_q6v5_mpd.c | 71 +++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_q6v5_mpd.c b/drivers/remoteproc/qcom_q6v5_mpd.c index 839f6a15b88d..901b0b0da8f2 100644 --- a/drivers/remoteproc/qcom_q6v5_mpd.c +++ b/drivers/remoteproc/qcom_q6v5_mpd.c @@ -443,11 +443,77 @@ static unsigned long q6_wcss_panic(struct rproc *rproc) return qcom_q6v5_panic(&wcss->q6); } +static void q6_wcss_copy_segment(struct rproc *rproc, + struct rproc_dump_segment *segment, + void *dest, size_t offset, size_t size) +{ + struct q6_wcss *wcss = rproc->priv; + struct device *dev = wcss->dev; + int base; + void *ptr; + + base = segment->da + offset - wcss->mem_reloc; + + if (base < 0 || base + size > wcss->mem_size) { + ptr = devm_ioremap_wc(dev, segment->da, segment->size); + memcpy(dest, ptr + offset, size); + devm_iounmap(dev, ptr); + } else { + memcpy(dest, wcss->mem_region + offset, size); + } +} + +static int q6_wcss_dump_segments(struct rproc *rproc, + const struct firmware *fw) +{ + struct device *dev = rproc->dev.parent; + struct reserved_mem *rmem = NULL; + struct device_node *node; + int num_segs, index = 0; + int ret; + + /* Parse through additional reserved memory regions for the rproc + * and add them to the coredump segments + */ + num_segs = of_count_phandle_with_args(dev->of_node, + "memory-region", NULL); + while (index < num_segs) { + node = of_parse_phandle(dev->of_node, + "memory-region", index); + if (!node) + return -EINVAL; + + rmem = of_reserved_mem_lookup(node); + if (!rmem) { + dev_err(dev, "unable to acquire memory-region index %d num_segs %d\n", + index, num_segs); + return -EINVAL; + } + + of_node_put(node); + + dev_dbg(dev, "Adding segment 0x%pa size 0x%pa", + &rmem->base, &rmem->size); + ret = rproc_coredump_add_custom_segment(rproc, + rmem->base, + rmem->size, + q6_wcss_copy_segment, + NULL); + if (ret) + return ret; + + index++; + } + + return 0; +} + static const struct rproc_ops wcss_ops = { .start = wcss_pd_start, .stop = wcss_pd_stop, .load = wcss_pd_load, .get_boot_addr = rproc_elf_get_boot_addr, + .parse_fw = q6_wcss_dump_segments, }; static const struct rproc_ops q6_wcss_ops = { @@ -457,6 +523,7 @@ static const struct rproc_ops q6_wcss_ops = { .load = q6_wcss_load, .get_boot_addr = rproc_elf_get_boot_addr, .panic = q6_wcss_panic, + .parse_fw = q6_wcss_dump_segments, }; static int q6_alloc_memory_region(struct q6_wcss *wcss) @@ -672,6 +739,7 @@ static int q6_register_userpd(struct platform_device *pdev, goto free_rproc; rproc->auto_boot = false; + rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE); ret = rproc_add(rproc); if (ret) goto free_rproc; @@ -731,9 +799,10 @@ static int q6_wcss_probe(struct platform_device *pdev) goto free_rproc; qcom_add_glink_subdev(rproc, &wcss->glink_subdev, "q6wcss"); - qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, "q6wcss"); + qcom_add_ssr_subdev(rproc, &wcss->ssr_subdev, pdev->name); rproc->auto_boot = false; + rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE); ret = rproc_add(rproc); if (ret) goto free_rproc;