From patchwork Tue Feb 21 11:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 59869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1811158wrn; Tue, 21 Feb 2023 03:33:30 -0800 (PST) X-Google-Smtp-Source: AK7set/n1eROkaKK8ZOULveedNHRuVDssSg7Js+0+58OV+EHrZ8iqLjPwueNBZnT7RHeO2UKV6JQ X-Received: by 2002:a17:906:37cb:b0:8b1:2867:380 with SMTP id o11-20020a17090637cb00b008b128670380mr11450298ejc.22.1676979209947; Tue, 21 Feb 2023 03:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979209; cv=none; d=google.com; s=arc-20160816; b=tmRrPSlMvNe2LaoON6R6G8xC1xcGw8cMctu8K3SKlUltTkauuvWcV+KOCTqk+1mpLx a9KO9uQXx+bKNp9B7s/0v2PdECqnoPZlOuEROEHqQRa0UDdepjg3uvHzfeyzIRyofecA 5HKNvI7VMBtqz4Z7kM7FJLLgspWwDPwcK+ANUUO+vkf86MzjsOLY3+zNC/PBIFgA8Cgd /a+S4X9kW7Hu26TSLq6dzvqQzrvztgPnY13J7x7oxELdkIDSi87LgE1N6LjpuG7pBaT8 V3CtIPIuvQqjlLoprsVaiEC/yYXl/9WFggDmrxO5G9n9Ui2jqwyYccmlkSyua5zR+H5Y 2UrA== 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=U7Ig3IE5fo7SE41rFy4VhcRxPmN7M6LM1tNdPJNMAhQ=; b=GfwNGr/Kdun7SOK9lYnFlwXmRsWOtpAUWrTlz4FnaUw0CK8m0HuHs3+kR1briUX+co BrRqwmY2NHnjDNRefcm5ZWH853jwXXnu34hi/iKW/0S0OaCkaYmE/kXYxuJ+mdkGThK4 37rSLNqAVPMS5QW79PpKdNhRX1JspEWSFjU+KQijHlCNcezm4x12R2mIfzc1DmWkxJfV HVR2s4z+hp5mfdZMsDeGFcECzFtpGwc45F7UozTdFq90yctweqx8YQe/f19wd+5pykHF Qf064CeUrhrgtv1o0agFaNkPw9QCci8stPIGGCu5/gcqdnIyfHxcYJJIm1NYaEltZ21L 8qLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="Cy1/IJIK"; 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 h15-20020a17090791cf00b008b9b135aee9si11522943ejz.350.2023.02.21.03.33.06; Tue, 21 Feb 2023 03:33:29 -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="Cy1/IJIK"; 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 S234107AbjBUL0g (ORCPT + 99 others); Tue, 21 Feb 2023 06:26:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234084AbjBUL0c (ORCPT ); Tue, 21 Feb 2023 06:26:32 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 963DF24111; Tue, 21 Feb 2023 03:26:31 -0800 (PST) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31L6l5fL012496; Tue, 21 Feb 2023 11:26:08 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=U7Ig3IE5fo7SE41rFy4VhcRxPmN7M6LM1tNdPJNMAhQ=; b=Cy1/IJIKs4Ewn/bTwfQYm72RG5SNodmXGIailyj4P4LuY0I9d2znWUCH++L+4ZHH44iU 8APskfyRRqsgjUxH383MhsEXQ6pqCcChEUZ3UER7Ti+xphLZu6kwcdOi3yve5sHsrvXl 4+tWBIdoqVZRu/QM62mfi7hLu1kkMYy9NuGLKyNlWUu4fV2SoSXgWmd9PUBMKWTIpgPP GW4HkjnggNhuOf1Ec3KGaJlgaRwcxazty02TvyU9nBGJlFB5pdqWMUEv98j4DLarIgVp UAs+JNbhpLdzvOZrpw8FFxvCeq+MBcTgCJbgFsWL5eZyApTXttl3O8AC6IQwyJ+XuKh0 /g== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nvnbt925a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:08 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31LBQ7EZ005736 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:07 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 21 Feb 2023 03:26:03 -0800 From: Mukesh Ojha To: , , , , , , , CC: , , , , , Mukesh Ojha Subject: [RFC PATCH 1/6] remoteproc: qcom: Expand MD_* as MINIDUMP_* Date: Tue, 21 Feb 2023 16:55:08 +0530 Message-ID: <1676978713-7394-2-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> References: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: XFJKOYhY_hNxtALDJ_ket4wCfQ3a-7dX X-Proofpoint-ORIG-GUID: XFJKOYhY_hNxtALDJ_ket4wCfQ3a-7dX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_06,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210098 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758440152349033059?= X-GMAIL-MSGID: =?utf-8?q?1758440152349033059?= Expand MD_* as MINIDUMP_* which makes more sense than the abbreviation. Signed-off-by: Mukesh Ojha --- drivers/remoteproc/qcom_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 020349f..95bd4b8 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -29,9 +29,9 @@ #define MAX_NUM_OF_SS 10 #define MAX_REGION_NAME_LENGTH 16 #define SBL_MINIDUMP_SMEM_ID 602 -#define MD_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) -#define MD_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) -#define MD_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) +#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) +#define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) +#define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) /** * struct minidump_region - Minidump region @@ -123,7 +123,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy for (i = 0; i < seg_cnt; i++) { memcpy_fromio(®ion, ptr + i, sizeof(region)); - if (region.valid == MD_REGION_VALID) { + if (region.valid == MINIDUMP_REGION_VALID) { name = kstrdup(region.name, GFP_KERNEL); if (!name) { iounmap(ptr); @@ -163,8 +163,8 @@ void qcom_minidump(struct rproc *rproc, unsigned int minidump_id) */ if (subsystem->regions_baseptr == 0 || le32_to_cpu(subsystem->status) != 1 || - le32_to_cpu(subsystem->enabled) != MD_SS_ENABLED || - le32_to_cpu(subsystem->encryption_status) != MD_SS_ENCR_DONE) { + le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED || + le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) { dev_err(&rproc->dev, "Minidump not ready, skipping\n"); return; } From patchwork Tue Feb 21 11:25:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 59870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1811460wrn; Tue, 21 Feb 2023 03:34:14 -0800 (PST) X-Google-Smtp-Source: AK7set/tPWrjcwcMU2Z6vqFb/jwh9zbqnvR2fHIkcfZxCV7Q7Pe/7tvCL/i0mhY1+ZUw8eLxXvyM X-Received: by 2002:a17:906:f0c9:b0:888:a72f:1599 with SMTP id dk9-20020a170906f0c900b00888a72f1599mr12094829ejb.11.1676979254759; Tue, 21 Feb 2023 03:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979254; cv=none; d=google.com; s=arc-20160816; b=eEI0rtwnckOO04n/WtWH0bIaMb8meT7liVxxEKqC1Rk88NhWNN2OIrOwQxuyIcMQBo XSJKCn1zC6StYXuFttKoY/xSEFSjkK2dxBmOCeFCuPWOB1UsJUAedNJ2MlGmqGpnyjQn 2r3Brpdgm9pPxy2SqTofTiOSqUmHMrUoJwvCHie57+VKHJ1D09MiWEDzx8+nh+3RTIQs VZ7iPf30CYGtb7kVaROqVIe3PT6xLPDLpdzPUikle9LtRdk4ve4l7+k41tZoBMupjnyp UVwRMBla0aEuxYmbEYMctqCJgzkaxUctKJEEq/SG6+ztUE+u3xZ5O9pRVF3JzhPPaAUk uApw== 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=i9/eXDC7+ABUy/tkJpe1AroYlLaA7XpwZhp3IPWGHJE=; b=EVuZypxKEkw2wQszXQiNY9GDC2wPZL3/fZ5L6S0QMn8KPDI/Z2cw9j2INfAoPOJgnU OVGcrMgj/H+HfVvoWLDyGP5Q1idec+/yUtFzwblOR2QlxPgFJvksJHd7CnJoQ5pmiHs2 S/HXWdH5lTyHnIw3kvHFZrYtxRc80p52VqmKn9WWOsK3zy08sMTEyf2Yy0YU6nZM+8S0 +j3kzW0NmwWNvXaBLodBoRt2wREA2gmo7dNTshwDE5LVE4p4wN6vIlIesVkNeaxpbX8Y yKk711ptfqP1lJu1NKkFcPooo0cklwrcUv6KHJ55sNCBBvFWN+9ENTBzXonqzmUuK/Bj aGeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GJbasN01; 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 vf17-20020a170907239100b008b126f9cebasi15714690ejb.228.2023.02.21.03.33.51; Tue, 21 Feb 2023 03:34:14 -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=GJbasN01; 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 S234140AbjBUL0r (ORCPT + 99 others); Tue, 21 Feb 2023 06:26:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbjBUL0m (ORCPT ); Tue, 21 Feb 2023 06:26:42 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7844126861; Tue, 21 Feb 2023 03:26:39 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31LB4Oks011354; Tue, 21 Feb 2023 11:26:15 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=i9/eXDC7+ABUy/tkJpe1AroYlLaA7XpwZhp3IPWGHJE=; b=GJbasN01XgpQgTYPEUHwc/hMZypm5T5Z84DoDXQfZA/6/KVvi8Tf1owtA8Sqm78Mh3qE 1P+jQpl1R8AsRDgpML+sKH2vsZ891UKaSJd3VTGN+lwuA4wpbfm/1qVewXubUdtSPvE8 XYSxC0uJRjQalMN4plTVSRVTWl33OTEqWSr15FM3DMz1mD0iTa0R93N++4SCt7AxAIMc WUB/sOdbESJrXEk/hiea15enqXQ3C3XETzZEr8wuofZo0RHzy6FQX8T3jzP8JeV+CPYv esEhK3yqX41LbHwn9/CrQsicu6C71qsSysl5NWpoKyPjq5g3v7nyY1fZDq96U0m+lw+H jQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nvvrrg19b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:14 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31LBQDhu029657 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:13 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 21 Feb 2023 03:26:09 -0800 From: Mukesh Ojha To: , , , , , , , CC: , , , , , Mukesh Ojha Subject: [RFC PATCH 2/6] remoteproc: qcom: Move minidump specific data to qcom_minidump.h Date: Tue, 21 Feb 2023 16:55:09 +0530 Message-ID: <1676978713-7394-3-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> References: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: c6O32QGEWfOPG2pl56voEtP72yixj9xO X-Proofpoint-ORIG-GUID: c6O32QGEWfOPG2pl56voEtP72yixj9xO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_06,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 bulkscore=0 phishscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210098 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758440198994399677?= X-GMAIL-MSGID: =?utf-8?q?1758440198994399677?= Move minidump specific data types and macros to a separate internal header(qcom_minidump.h) so that it can be shared among different Qualcomm drivers. There is no change in functional behavior after this. Signed-off-by: Mukesh Ojha --- drivers/remoteproc/qcom_common.c | 56 +--------------------------------- include/soc/qcom/qcom_minidump.h | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 55 deletions(-) create mode 100644 include/soc/qcom/qcom_minidump.h diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 95bd4b8..f607e1e 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "remoteproc_internal.h" #include "qcom_common.h" @@ -26,61 +27,6 @@ #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev) #define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev) -#define MAX_NUM_OF_SS 10 -#define MAX_REGION_NAME_LENGTH 16 -#define SBL_MINIDUMP_SMEM_ID 602 -#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) -#define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) -#define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) - -/** - * struct minidump_region - Minidump region - * @name : Name of the region to be dumped - * @seq_num: : Use to differentiate regions with same name. - * @valid : This entry to be dumped (if set to 1) - * @address : Physical address of region to be dumped - * @size : Size of the region - */ -struct minidump_region { - char name[MAX_REGION_NAME_LENGTH]; - __le32 seq_num; - __le32 valid; - __le64 address; - __le64 size; -}; - -/** - * struct minidump_subsystem - Subsystem's SMEM Table of content - * @status : Subsystem toc init status - * @enabled : if set to 1, this region would be copied during coredump - * @encryption_status: Encryption status for this subsystem - * @encryption_required : Decides to encrypt the subsystem regions or not - * @region_count : Number of regions added in this subsystem toc - * @regions_baseptr : regions base pointer of the subsystem - */ -struct minidump_subsystem { - __le32 status; - __le32 enabled; - __le32 encryption_status; - __le32 encryption_required; - __le32 region_count; - __le64 regions_baseptr; -}; - -/** - * struct minidump_global_toc - Global Table of Content - * @status : Global Minidump init status - * @md_revision : Minidump revision - * @enabled : Minidump enable status - * @subsystems : Array of subsystems toc - */ -struct minidump_global_toc { - __le32 status; - __le32 md_revision; - __le32 enabled; - struct minidump_subsystem subsystems[MAX_NUM_OF_SS]; -}; - struct qcom_ssr_subsystem { const char *name; struct srcu_notifier_head notifier_list; diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h new file mode 100644 index 0000000..84c8605 --- /dev/null +++ b/include/soc/qcom/qcom_minidump.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Qualcomm minidump shared data structures and macros + * + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _QCOM_MINIDUMP_H_ +#define _QCOM_MINIDUMP_H_ + +#define MAX_NUM_OF_SS 10 +#define MAX_REGION_NAME_LENGTH 16 +#define SBL_MINIDUMP_SMEM_ID 602 +#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) +#define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) +#define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) + +/** + * struct minidump_region - Minidump region + * @name : Name of the region to be dumped + * @seq_num: : Use to differentiate regions with same name. + * @valid : This entry to be dumped (if set to 1) + * @address : Physical address of region to be dumped + * @size : Size of the region + */ +struct minidump_region { + char name[MAX_REGION_NAME_LENGTH]; + __le32 seq_num; + __le32 valid; + __le64 address; + __le64 size; +}; + +/** + * struct minidump_subsystem - Subsystem's SMEM Table of content + * @status : Subsystem toc init status + * @enabled : if set to 1, this region would be copied during coredump + * @encryption_status: Encryption status for this subsystem + * @encryption_required : Decides to encrypt the subsystem regions or not + * @region_count : Number of regions added in this subsystem toc + * @regions_baseptr : regions base pointer of the subsystem + */ +struct minidump_subsystem { + __le32 status; + __le32 enabled; + __le32 encryption_status; + __le32 encryption_required; + __le32 region_count; + __le64 regions_baseptr; +}; + +/** + * struct minidump_global_toc - Global Table of Content + * @status : Global Minidump init status + * @md_revision : Minidump revision + * @enabled : Minidump enable status + * @subsystems : Array of subsystems toc + */ +struct minidump_global_toc { + __le32 status; + __le32 md_revision; + __le32 enabled; + struct minidump_subsystem subsystems[MAX_NUM_OF_SS]; +}; + +#endif /* _QCOM_MINIDUMP_H_ */ From patchwork Tue Feb 21 11:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 59881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1812504wrn; Tue, 21 Feb 2023 03:36:55 -0800 (PST) X-Google-Smtp-Source: AK7set/WrYLBKzRGN3TV0MjE/M0max3U0csxPl4Wjzgxq/SE2hAYucA4LvgFXbBsBXIHoPY5V+ur X-Received: by 2002:aa7:d907:0:b0:4ac:b6db:3ed0 with SMTP id a7-20020aa7d907000000b004acb6db3ed0mr4083558edr.39.1676979415001; Tue, 21 Feb 2023 03:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979414; cv=none; d=google.com; s=arc-20160816; b=IyJGj/1AKuiqI5t8RqPS5NBO38n/7l34sp5ceoURHEF8kj7myPMHe2d/qub/0LB3xl fP4rsFSgjSwHgO+kqLEkhCH854y9DQaMBCe2RkPAoXyOR/vDEo//sj1KAo/Bm07hgjHW AjzEbTriSR1BcJ+4hKVMI6Y1EE0pn7n9ctdCXNtKQ3Ycsgr81tARV/0t8QQl4tPJ5M9U nTZVyAVbrnOvXVVrGCrizg3EpxIyhv9quN1LgzCIlOXoqIXu2zAQc4jnT4YhoGaTkvfx GRwaJSI54rEBCdmer9MvlAJ9dJVdqezLUj+229EwlIAq7T/ocp26VZ5GcsbCHabIN1z3 01cA== 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=aDJdc46ciEbcmg8N7guWmrC6jlLdSNh/d9sODEykd8U=; b=mu0HYliPP4NirvZ+vYywAYB4En6em0hdeOklvixdd67bOlibSHzEygQTx/gwjVMbaD 4taDquS9E33sDxQniu6ZCt4Vm4gsuFh4OJrhZ409sVeW0F00FEtTN7xs3bAxkHD9yeWd ERMqTpcJCY8aFnEmzwJ0S0qZ6YeWFnW/phwLk/bc0Ixsa8EU+UcD1Z+KCSkFMpb0mvfl f7R7yneAOdC/ebbh0BvjWEB/F9uCZguOkDcMf/XxhpytWtnSi9VuBiFJzcYcoWEZ9aE5 SmA50dpaOZp6+U3DH+uBcUGXckyskHaeodC5RPnEoUMqL0Sua4rNZpvQorH9xLqnO7IS 6yJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=W1ip6lbn; 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 o2-20020a056402038200b004ad79746598si6836472edv.173.2023.02.21.03.36.31; Tue, 21 Feb 2023 03:36:54 -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=W1ip6lbn; 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 S234161AbjBUL06 (ORCPT + 99 others); Tue, 21 Feb 2023 06:26:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234121AbjBUL0p (ORCPT ); Tue, 21 Feb 2023 06:26:45 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7810265BF; Tue, 21 Feb 2023 03:26:40 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31L8HWt6022994; Tue, 21 Feb 2023 11:26:20 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=aDJdc46ciEbcmg8N7guWmrC6jlLdSNh/d9sODEykd8U=; b=W1ip6lbnVtqN7IE5iUtToDWRPbUcogx602CVp+gcphITCQ5Jfq73kmcI0A4uBmM64i2U xYD8PX7pEstsFH+6O9OEVaXi+NDa6q+0EK+bGx5rTx3uCdW5YsWz+kDjT55LNkqyT8Rf dD7Y2yPw0giUwi2YLbrnpNOnEWpkV9njNYbR0MaQznSJjiYBslthzl0NL93WVrz+8qNd ZmNcl4drWhQWE+TbwzNZXJgMcV0U91+/A9e45ME/NotXRJEBBOlCO1AceOgDJh6a7Gnq 87Y8wTVKq8WAXP1m13go5DN4OKq2z+JmoUtnPAuWYqh9SsBP5szsSh1TsF8yY8NuXmur Jw== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ntp98fqqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:19 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31LBQIV3007338 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:18 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 21 Feb 2023 03:26:13 -0800 From: Mukesh Ojha To: , , , , , , , CC: , , , , , Mukesh Ojha Subject: [RFC PATCH 3/6] soc: qcom: Add Qualcomm minidump kernel driver Date: Tue, 21 Feb 2023 16:55:10 +0530 Message-ID: <1676978713-7394-4-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> References: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: CxuctJqEPe3-pEh0Ym9ZCgsuETAefZXn X-Proofpoint-ORIG-GUID: CxuctJqEPe3-pEh0Ym9ZCgsuETAefZXn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_06,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 adultscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210098 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758440366664572216?= X-GMAIL-MSGID: =?utf-8?q?1758440366664572216?= Minidump is a best effort mechanism to collect useful and predefined data for first level of debugging on end user devices running on Qualcomm SoCs. It is built on the premise that System on Chip (SoC) or subsystem part of SoC crashes, due to a range of hardware and software bugs. Hence, the ability to collect accurate data is only a best-effort. The data collected could be invalid or corrupted, data collection itself could fail, and so on. Qualcomm devices in engineering mode provides a mechanism for generating full system ramdumps for post mortem debugging. But in some cases it's however not feasible to capture the entire content of RAM. The minidump mechanism provides the means for selecting region should be included in the ramdump. The solution supports extracting the ramdump/minidump produced either over USB or stored to an attached storage device. The core of minidump feature is part of Qualcomm's boot firmware code. It initializes shared memory(SMEM), which is a part of DDR and allocates a small section of it to minidump table i.e also called global table of content (G-ToC). Each subsystem (APSS, ADSP, ...) has their own table of segments to be included in the minidump, all references from a descriptor in SMEM (G-ToC). Each segment/region has some details like name, physical address and it's size etc. and it could be anywhere scattered in the DDR. Minidump kernel driver adds the capability to add linux region to be dumped as part of ram dump collection. It provides appropriate symbol to check its enablement and register client regions. To simplify post mortem debugging, it creates and maintain an ELF header as first region that gets updated with upon registration of a new region. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/Kconfig | 14 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_minidump.c | 490 +++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/minidump.h | 40 ++++ include/soc/qcom/qcom_minidump.h | 24 +- 5 files changed, 568 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/qcom/qcom_minidump.c create mode 100644 include/soc/qcom/minidump.h diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index ae504c4..0fc7698 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -248,4 +248,18 @@ config QCOM_ICC_BWMON the fixed bandwidth votes from cpufreq (CPU nodes) thus achieve high memory throughput even with lower CPU frequencies. +config QCOM_MINIDUMP + bool "QCOM Minidump Support" + depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SMEM + help + Enablement of core minidump feature is controlled from boot firmware + side, and this config allow linux to query and manages APPS minidump + table. + + Client drivers can register their internal data structures and debug + messages as part of the minidump region and when the SoC is crashed, + these selective regions will be dumped instead of the entire DDR. + This saves significant amount of time and/or storage space. + endmenu diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index d66604a..e1ff492 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -29,3 +29,4 @@ obj-$(CONFIG_QCOM_RPMHPD) += rpmhpd.o obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) += kryo-l2-accessors.o obj-$(CONFIG_QCOM_ICC_BWMON) += icc-bwmon.o +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c new file mode 100644 index 0000000..eb63b75 --- /dev/null +++ b/drivers/soc/qcom/qcom_minidump.c @@ -0,0 +1,490 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#define pr_fmt(fmt) "Minidump: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * DOC: Overview + * + * +-----------------------------------------------+ + * | DDR +-------------+ | + * | | SS0-ToC| | + * | +----------------+ +----------------+ | | + * | |Shared memory | | SS1-ToC| | | + * | |(SMEM) | | | | | + * | | | +-->|--------+ | | | + * | |G-ToC | | | SS-ToC \ | | | + * | |+-------------+ | | | +-----------+ | | | + * | ||-------------| | | | |-----------| | | | + * | || SS0-ToC | | | +-|<|SS1 region1| | | | + * | ||-------------| | | | | |-----------| | | | + * | || SS1-ToC |-|>+ | | |SS1 region2| | | | + * | ||-------------| | | | |-----------| | | | + * | || SS2-ToC | | | | | ... | | | | + * | ||-------------| | | | |-----------| | | | + * | || ... | | |-|<|SS1 regionN| | | | + * | ||-------------| | | | |-----------| | | | + * | || SSn-ToC | | | | +-----------+ | | | + * | |+-------------+ | | | | | | + * | | | | |----------------| | | + * | | | +>| regionN | | | + * | | | | |----------------| | | + * | +----------------+ | | | | | + * | | |----------------| | | + * | +>| region1 | | | + * | |----------------| | | + * | | | | | + * | |----------------|-+ | + * | | region5 | | + * | |----------------| | + * | | | | + * | Region information +----------------+ | + * | +---------------+ | + * | |region name | | + * | |---------------| | + * | |region address | | + * | |---------------| | + * | |region size | | + * | +---------------+ | + * +-----------------------------------------------+ + * G-ToC: Global table of content + * SS-ToC: Subsystem table of content + * SS0-SSn: Subsystem numbered from 0 to n + * + * The core of minidump feature is part of Qualcomm's boot firmware code. + * It initializes shared memory(SMEM), which is a part of DDR and + * allocates a small section of it to minidump table i.e also called + * global table of content (G-ToC). + * + * Each subsystem (APSS, ADSP, ...) has their own table of segments to be + * included in the minidump, all references from a descriptor in SMEM + * (G-ToC). Each segment/region has some details like name, physical + * address and it's size etc. and it could be anywhere scattered + * in the DDR. + * + * Qualcomm SoCs supports extracting the ramdump/minidump produced + * either over USB or stored to an attached storage device. + * + */ + +/** + * struct minidump_elfhdr - Minidump table elf header + * @ehdr: Elf main header + * @shdr: Section header + * @phdr: Program header + * @elf_offset: Section offset in elf + * @strtable_idx: String table current index position + */ +struct minidump_elfhdr { + struct elfhdr *ehdr; + struct elf_shdr *shdr; + struct elf_phdr *phdr; + size_t elf_offset; + size_t strtable_idx; +}; + +/** + * struct minidump - Minidump driver private data + * @md_gbl_toc : Global TOC pointer + * @md_ss_toc : High level OS TOC pointer + * @md_regions : High level OS region base pointer + * @elf : Minidump elf header + */ +struct minidump { + struct minidump_global_toc *md_gbl_toc; + struct minidump_subsystem *md_ss_toc; + struct minidump_region *md_regions; + struct minidump_elfhdr elf; +}; + +/* + * In some of the Old Qualcomm devices, boot firmware statically allocates 300 + * as total number of supported region (including all co-processors) in + * minidump table out of which linux was using 200. In future, this limitation + * from boot firmware might get removed by allocating the region dynamically. + * So, keep it compatible with older devices, we can the current limit for Linux + * to 200. + */ +#define MAX_NUM_ENTRIES 200 + +static struct minidump minidump; +static DEFINE_MUTEX(minidump_lock); + +static struct elf_shdr *elf_shdr_entry_addr(struct elfhdr *ehdr, int idx) +{ + struct elf_shdr *eshdr = (struct elf_shdr *)((size_t)ehdr + ehdr->e_shoff); + + return &eshdr[idx]; +} + +static struct elf_phdr *elf_phdr_entry_addr(struct elfhdr *ehdr, int idx) +{ + struct elf_phdr *ephdr = (struct elf_phdr *)((size_t)ehdr + ehdr->e_phoff); + + return &ephdr[idx]; +} + +static char *elf_str_table_start(struct elfhdr *ehdr) +{ + struct elf_shdr *eshdr; + + if (ehdr->e_shstrndx == SHN_UNDEF) + return NULL; + + eshdr = elf_shdr_entry_addr(ehdr, ehdr->e_shstrndx); + return (char *)ehdr + eshdr->sh_offset; +} + +static unsigned int append_str_to_strtable(const char *name) +{ + char *strtab = elf_str_table_start(minidump.elf.ehdr); + unsigned int old_idx = minidump.elf.strtable_idx; + unsigned int ret; + + if (!strtab || !name) + return 0; + + ret = old_idx; + old_idx += strscpy((strtab + old_idx), name, MAX_REGION_NAME_LENGTH); + minidump.elf.strtable_idx = old_idx + 1; + return ret; +} + +static int get_minidump_region_index(const struct qcom_minidump_region *region) +{ + struct minidump_region *mdr; + unsigned int i; + unsigned int count; + + count = le32_to_cpu(minidump.md_ss_toc->region_count); + for (i = 0; i < count; i++) { + mdr = &minidump.md_regions[i]; + if (!strcmp(mdr->name, region->name)) + return i; + } + return -ENOENT; +} + +/* Update ELF header */ +static void minidump_update_elf_header(const struct qcom_minidump_region *region) +{ + struct elfhdr *ehdr = minidump.elf.ehdr; + struct elf_shdr *shdr; + struct elf_phdr *phdr; + + shdr = elf_shdr_entry_addr(ehdr, ehdr->e_shnum++); + phdr = elf_phdr_entry_addr(ehdr, ehdr->e_phnum++); + + shdr->sh_type = SHT_PROGBITS; + shdr->sh_name = append_str_to_strtable(region->name); + shdr->sh_addr = (elf_addr_t)region->virt_addr; + shdr->sh_size = region->size; + shdr->sh_flags = SHF_WRITE; + shdr->sh_offset = minidump.elf.elf_offset; + shdr->sh_entsize = 0; + + phdr->p_type = PT_LOAD; + phdr->p_offset = minidump.elf.elf_offset; + phdr->p_vaddr = (elf_addr_t)region->virt_addr; + phdr->p_paddr = region->phys_addr; + phdr->p_filesz = phdr->p_memsz = region->size; + phdr->p_flags = PF_R | PF_W; + minidump.elf.elf_offset += shdr->sh_size; +} + +/* Add region in subsystem ToC */ +static void minidump_ss_add_region(const struct qcom_minidump_region *region) +{ + struct minidump_region *mdr; + unsigned int region_cnt = le32_to_cpu(minidump.md_ss_toc->region_count); + + mdr = &minidump.md_regions[region_cnt]; + strscpy(mdr->name, region->name, sizeof(mdr->name)); + mdr->address = cpu_to_le64(region->phys_addr); + mdr->size = cpu_to_le64(region->size); + mdr->valid = cpu_to_le32(MINIDUMP_REGION_VALID); + region_cnt++; + minidump.md_ss_toc->region_count = cpu_to_le32(region_cnt); +} + +static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region) +{ + return region && + strnlen(region->name, MAX_NAME_LENGTH) < MAX_NAME_LENGTH && + region->virt_addr && + region->size && + IS_ALIGNED(region->size, 4); +} + +#define MAX_STRTBL_SIZE (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH) +static int minidump_add_elf_header(void) +{ + struct qcom_minidump_region elfregion; + struct elfhdr *ehdr; + struct elf_shdr *shdr; + struct elf_phdr *phdr; + unsigned int elfh_size; + unsigned int strtbl_off; + unsigned int phdr_off; + char *banner; + unsigned int banner_len; + + banner_len = strlen(linux_banner); + /* + * Header buffer contains: + * ELF header, (MAX_NUM_ENTRIES + 4) of Section and Program ELF headers, + * where, 4 additional entries, one for empty header, one for string table + * one for minidump table and one for linux banner. + * + * Linux banner is stored in minidump to aid post mortem tools to determine + * the kernel version. + */ + elfh_size = sizeof(*ehdr); + elfh_size += MAX_STRTBL_SIZE; + elfh_size += banner_len + 1; + elfh_size += ((sizeof(*shdr) + sizeof(*phdr)) * (MAX_NUM_ENTRIES + 4)); + elfh_size = ALIGN(elfh_size, 4); + + minidump.elf.ehdr = kzalloc(elfh_size, GFP_KERNEL); + if (!minidump.elf.ehdr) + return -ENOMEM; + + /* Register ELF header as first region */ + strscpy(elfregion.name, "KELF_HEADER", sizeof(elfregion.name)); + elfregion.virt_addr = minidump.elf.ehdr; + elfregion.phys_addr = virt_to_phys(minidump.elf.ehdr); + elfregion.size = elfh_size; + minidump_ss_add_region(&elfregion); + + ehdr = minidump.elf.ehdr; + /* Assign Section/Program headers offset */ + minidump.elf.shdr = shdr = (struct elf_shdr *)(ehdr + 1); + minidump.elf.phdr = phdr = (struct elf_phdr *)(shdr + MAX_NUM_ENTRIES); + phdr_off = sizeof(*ehdr) + (sizeof(*shdr) * MAX_NUM_ENTRIES); + + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELF_CLASS; + ehdr->e_ident[EI_DATA] = ELF_DATA; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELF_OSABI; + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_ehsize = sizeof(*ehdr); + ehdr->e_phoff = phdr_off; + ehdr->e_phentsize = sizeof(*phdr); + ehdr->e_shoff = sizeof(*ehdr); + ehdr->e_shentsize = sizeof(*shdr); + ehdr->e_shstrndx = 1; + + minidump.elf.elf_offset = elfh_size; + + /* + * The zeroth index of the section header is reserved and is rarely used. + * Set the section header as null (SHN_UNDEF) and move to the next one. + * 2nd Section is String table. + */ + minidump.elf.strtable_idx = 1; + strtbl_off = sizeof(*ehdr) + ((sizeof(*phdr) + sizeof(*shdr)) * MAX_NUM_ENTRIES); + shdr++; + shdr->sh_type = SHT_STRTAB; + shdr->sh_offset = (elf_addr_t)strtbl_off; + shdr->sh_size = MAX_STRTBL_SIZE; + shdr->sh_entsize = 0; + shdr->sh_flags = 0; + shdr->sh_name = append_str_to_strtable("STR_TBL"); + shdr++; + + /* 3rd Section is for Minidump_table VA, used by parsers */ + shdr->sh_type = SHT_PROGBITS; + shdr->sh_entsize = 0; + shdr->sh_flags = 0; + shdr->sh_addr = (elf_addr_t)&minidump; + shdr->sh_name = append_str_to_strtable("minidump_table"); + shdr++; + + /* 4th Section is Linux banner */ + banner = (char *)ehdr + strtbl_off + MAX_STRTBL_SIZE; + memcpy(banner, linux_banner, banner_len); + + shdr->sh_type = SHT_PROGBITS; + shdr->sh_offset = (elf_addr_t)(strtbl_off + MAX_STRTBL_SIZE); + shdr->sh_size = banner_len + 1; + shdr->sh_addr = (elf_addr_t)linux_banner; + shdr->sh_entsize = 0; + shdr->sh_flags = SHF_WRITE; + shdr->sh_name = append_str_to_strtable("linux_banner"); + + phdr->p_type = PT_LOAD; + phdr->p_offset = (elf_addr_t)(strtbl_off + MAX_STRTBL_SIZE); + phdr->p_vaddr = (elf_addr_t)linux_banner; + phdr->p_paddr = virt_to_phys(linux_banner); + phdr->p_filesz = phdr->p_memsz = banner_len + 1; + phdr->p_flags = PF_R | PF_W; + + /* Update headers count*/ + ehdr->e_phnum = 1; + ehdr->e_shnum = 4; + return 0; +} + +static int qcom_minidump_init(void) +{ + struct minidump_subsystem *mdsstoc; + + mdsstoc = qcom_minidump_subsystem_desc(MINIDUMP_APSS_DESC); + if (IS_ERR(mdsstoc)) + return -EINVAL; + + minidump.md_regions = kcalloc(MAX_NUM_ENTRIES, + sizeof(struct minidump_region), GFP_KERNEL); + if (!minidump.md_regions) + return -ENOMEM; + + minidump.md_ss_toc = mdsstoc; + /* Share memory table update */ + mdsstoc->regions_baseptr = cpu_to_le64(virt_to_phys(minidump.md_regions)); + /* Tell bootloader not to encrypt the regions of this subsystem */ + mdsstoc->encryption_status = cpu_to_le32(MINIDUMP_SS_ENCR_DONE); + mdsstoc->encryption_required = cpu_to_le32(MINIDUMP_SS_ENCR_NOTREQ); + + mdsstoc->enabled = cpu_to_le32(MINIDUMP_SS_ENABLED); + mdsstoc->status = cpu_to_le32(1); + mdsstoc->region_count = cpu_to_le32(0); + + return 0; +} + +/** + * qcom_minidump_ready - Check, if minidump is ready for client registration or not. + * + * Return: zero on success and negative on failure. + * + * Qualcomm minidump feature is dependent on Qualcomm's shared memory and it is + * possible for a arm64 target to not have it's device tree entry present, for + * such case, qcom_minidump_ready() returns -ENODEV and client should not further + * try to register their region with minidump driver. + */ +int qcom_minidump_ready(void) +{ + void *ptr; + struct device_node *np; + static bool is_smem_available = true; + + if (!is_smem_available || !(np = of_find_compatible_node(NULL, NULL, "qcom,smem"))) { + is_smem_available = false; + return -ENODEV; + } + + of_node_put(np); + ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL); + if (IS_ERR(ptr)) + return PTR_ERR(ptr); + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_minidump_ready); + +/** + * qcom_minidump_subsystem_desc() - Get minidump subsystem descriptor. + * @minidump_index: minidump index for a subsystem in minidump table + * + * Return: minidump subsystem descriptor address on success and error + * on failure + */ +struct minidump_subsystem *qcom_minidump_subsystem_desc(unsigned int minidump_index) +{ + struct minidump_global_toc *mdgtoc; + size_t size; + + mdgtoc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size); + if (IS_ERR(mdgtoc)) { + pr_err("Unable to find minidump smem item\n"); + return ERR_CAST(mdgtoc); + } + + if (size < sizeof(*mdgtoc) || !mdgtoc->status) { + pr_err("Minidump table is not initialized\n"); + return ERR_PTR(-EINVAL); + } + + return &mdgtoc->subsystems[minidump_index]; +} +EXPORT_SYMBOL_GPL(qcom_minidump_subsystem_desc); + +/** + * qcom_minidump_region_register() - Register a region in Minidump table. + * @region: minidump region. + * + * Client should not call this directly instead first call qcom_minidump_ready() + * to check if minidump is ready to do registration if yes, then call this API. + * + * Return: On success, it returns region index in minidump table and negative + * error value on failure. + */ +int qcom_minidump_region_register(const struct qcom_minidump_region *region) +{ + static bool minidump_init_done; + unsigned int num_region; + int ret; + + /* Initialize minidump context on first call */ + mutex_lock(&minidump_lock); + if (!minidump_init_done) { + ret = qcom_minidump_init(); + if (ret) + goto unlock; + + minidump_init_done = true; + /* First entry would be ELF header */ + ret = minidump_add_elf_header(); + if (ret) { + kfree(minidump.md_regions); + goto unlock; + } + } + + if (!qcom_minidump_valid_region(region)) { + ret = -EINVAL; + goto unlock; + } + + ret = get_minidump_region_index(region); + if (ret >= 0) { + pr_info("%s region is already registered\n", region->name); + ret = -EEXIST; + goto unlock; + } + + /* Check if there is a room for a new entry */ + ret = num_region = le32_to_cpu(minidump.md_ss_toc->region_count); + if (num_region >= MAX_NUM_ENTRIES) { + pr_err("maximum region limit %u reached\n", num_region); + ret = -ENOSPC; + goto unlock; + } + + minidump_ss_add_region(region); + minidump_update_elf_header(region); +unlock: + mutex_unlock(&minidump_lock); + return ret; +} +EXPORT_SYMBOL_GPL(qcom_minidump_region_register); diff --git a/include/soc/qcom/minidump.h b/include/soc/qcom/minidump.h new file mode 100644 index 0000000..a50843f --- /dev/null +++ b/include/soc/qcom/minidump.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _MINIDUMP_H_ +#define _MINIDUMP_H_ + +#include + +#define MAX_NAME_LENGTH 12 + +/** + * struct qcom_minidump_region - Minidump region information + * + * @name: Entry name, Minidump will dump binary with this name. + * @virt_addr: Virtual address of the entry. + * @phys_addr: Physical address of the entry to dump. + * @size: Number of byte to dump from @address location, + * and it should be 4 byte aligned. + */ +struct qcom_minidump_region { + char name[MAX_NAME_LENGTH]; + void *virt_addr; + phys_addr_t phys_addr; + size_t size; +}; + +#if IS_ENABLED(CONFIG_QCOM_MINIDUMP) +extern int qcom_minidump_ready(void); +extern int qcom_minidump_region_register(const struct qcom_minidump_region *entry); +#else +static inline int qcom_minidump_ready(void) { return 0; } +static inline int qcom_minidump_region_register(const struct qcom_minidump_region *entry) +{ + /* Return quietly, if minidump is not enabled */ + return 0; +} +#endif +#endif /* _MINIDUMP_H_ */ diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h index 84c8605..e8630ed 100644 --- a/include/soc/qcom/qcom_minidump.h +++ b/include/soc/qcom/qcom_minidump.h @@ -10,11 +10,25 @@ #define MAX_NUM_OF_SS 10 #define MAX_REGION_NAME_LENGTH 16 + +#define MINIDUMP_REVISION 1 #define SBL_MINIDUMP_SMEM_ID 602 + +/* Application processor minidump descriptor */ +#define MINIDUMP_APSS_DESC 0 +#define SMEM_ENTRY_SIZE 40 + #define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) +#define MINIDUMP_REGION_INVALID ('I' << 24 | 'N' << 16 | 'V' << 8 | 'A' << 0) +#define MINIDUMP_REGION_INIT ('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' << 0) +#define MINIDUMP_REGION_NOINIT 0 + +#define MINIDUMP_SS_ENCR_REQ (0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0) +#define MINIDUMP_SS_ENCR_NOTREQ (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0) +#define MINIDUMP_SS_ENCR_NONE ('N' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) #define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) +#define MINIDUMP_SS_ENCR_START ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 0) #define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) - /** * struct minidump_region - Minidump region * @name : Name of the region to be dumped @@ -63,4 +77,12 @@ struct minidump_global_toc { struct minidump_subsystem subsystems[MAX_NUM_OF_SS]; }; +#if IS_ENABLED(CONFIG_QCOM_MINIDUMP) +extern struct minidump_subsystem *qcom_minidump_subsystem_desc(unsigned int minidump_index); +#else +static inline struct minidump_subsystem *qcom_minidump_subsystem_desc(unsigned int minidump_index) +{ + return NULL; +} +#endif #endif /* _QCOM_MINIDUMP_H_ */ From patchwork Tue Feb 21 11:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 59880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1812478wrn; Tue, 21 Feb 2023 03:36:48 -0800 (PST) X-Google-Smtp-Source: AK7set90GhUmpsJAl1+HTGXNskxi6k4CTsoHFoKIS+AddwH69sL6l7RbYVnbd5T5xMeZXLhVfeEu X-Received: by 2002:a17:907:3e26:b0:8af:6c2:1e83 with SMTP id hp38-20020a1709073e2600b008af06c21e83mr21737706ejc.35.1676979408253; Tue, 21 Feb 2023 03:36:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979408; cv=none; d=google.com; s=arc-20160816; b=dH+S3NZN+mx2aJhioKIebfsPHKHEX1GhOf3qBFaGHsNqeO/Bs+1S4zjPDy7vwnMQ2y 6nBjP0mokYyYM1K4XFJ/3yYj6GPqRLJ9Zr72nbk0Dh7DUyYIsF3l9w3+8hsuOSf5kfjI ISzoimPhFaQCqh03FofjGMUIKLL1ietJC+tF6yrZUpNbZ0RbyqmO1sVuvt2NPlS1k4F/ quRKR+xlueelhkk7aTLnXwlEBdeIER/qNdLKRt0+t4RIHFMGpG0SS10XntjeCtBaN4Q5 PH+XQIu7pY8FuHQ2+hyh60qFeo3Eml5J/AdgEPG+ImfXtMRAZpuPS2kbwIRZttkfIW34 Wksw== 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=4F/eh7ONK9atW2typBWWH5MgXERlB2dJb3Mki6A3qIw=; b=fZ2ZtpI2gMFuIwQG8LmMAP3FBkE40pwWOCv0D6CYRpV/bEX2hviWRil7ehtVLlt5QT kqmVVR9VHe2KW3VqIrhagDXE3NqVFnkM8E9SXXNNFwjQ9Rb590NfeJfiLUxi0EBIPYqQ 3OPz9m3xMGhlpXUy4tIk4KCVbVNtREhkQleHRGmrOoTVdTWyqPck6DV78unnE1+zl2h+ 2LKsoFNDSXs5dR/5a7GMMEUDbbFPn1uFKv0QusvTixWo0WKu6zkbxvTtXcI75BHai6GA EZqJhIZiQvu9Mc/8+gJKhDUhDj+jJBGagnp5NhjqhXh/ybKQWcoHHA9M8nbjag9FrEsp I3Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=arfehBlB; 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 p22-20020a170907911600b008caedbfc3acsi8919060ejq.419.2023.02.21.03.36.24; Tue, 21 Feb 2023 03:36:48 -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=arfehBlB; 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 S232956AbjBUL0w (ORCPT + 99 others); Tue, 21 Feb 2023 06:26:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234122AbjBUL0n (ORCPT ); Tue, 21 Feb 2023 06:26:43 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB6526CF3; Tue, 21 Feb 2023 03:26:40 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31L9rFRd014277; Tue, 21 Feb 2023 11:26:24 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=4F/eh7ONK9atW2typBWWH5MgXERlB2dJb3Mki6A3qIw=; b=arfehBlBUmotPV0vJR3xlPcaIegVBtWRYcsgnK0TgMqTFce1ELiGI8f0my/fQyJ20syY MntSubtR3YaqPlWMIc89ELPHcMMhIaGhRKyEn8xAEqZDvRIB+2koK4OkA52cUYtyxtXC MnVgjAlt9146WdPYAdH/hzsV9TZ4VtkDHytvAP+gxjCqnU7K10yB9x4GIs/yY1L4uc5v 8+U+/vWKNCDOinQVWZ4GOKrZ34ySlI1IxYaioyoSkIVgFq3c/9JRFOVpjJZov5dq6ErS Tf8/pNok36WtBwDoTO1pdHskzq28AoT5tkDvpDKciJrpoxLqAOaN8mp2yfmN9KLO4Jlu 7Q== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ntmcm7kjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:23 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31LBQN6t019098 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:23 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 21 Feb 2023 03:26:18 -0800 From: Mukesh Ojha To: , , , , , , , CC: , , , , , Mukesh Ojha Subject: [RFC PATCH 4/6] arm64: defconfig: Enable Qualcomm minidump driver Date: Tue, 21 Feb 2023 16:55:11 +0530 Message-ID: <1676978713-7394-5-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> References: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: cAU-dQwezPj6H1X7xojbBe3iyyQ8CaU4 X-Proofpoint-GUID: cAU-dQwezPj6H1X7xojbBe3iyyQ8CaU4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_06,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 phishscore=0 clxscore=1015 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=553 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210098 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758440360105404933?= X-GMAIL-MSGID: =?utf-8?q?1758440360105404933?= Previous patches add the Qualcomm minidump driver support, so lets enable minidump config so that it can be used by kernel clients. Signed-off-by: Mukesh Ojha --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 989183c..d87800b 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -1211,6 +1211,7 @@ CONFIG_QCOM_STATS=m CONFIG_QCOM_WCNSS_CTRL=m CONFIG_QCOM_APR=m CONFIG_QCOM_ICC_BWMON=m +CONFIG_QCOM_MINIDUMP=y CONFIG_ARCH_R8A77995=y CONFIG_ARCH_R8A77990=y CONFIG_ARCH_R8A77950=y From patchwork Tue Feb 21 11:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 59871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1811811wrn; Tue, 21 Feb 2023 03:35:03 -0800 (PST) X-Google-Smtp-Source: AK7set8JBnP01rgKGFu3r+AkA714yEopguIVQK7xaspngGO1/+tgqugz79zL9dD5fi2DQIhwIkiG X-Received: by 2002:a17:906:55d2:b0:878:7a0e:5730 with SMTP id z18-20020a17090655d200b008787a0e5730mr12999821ejp.56.1676979303753; Tue, 21 Feb 2023 03:35:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979303; cv=none; d=google.com; s=arc-20160816; b=f9e1cQ93AdNZmmYoqQfPo4YplgiQPCRaI2KettYKpDy/Qk6VV4B4bruldgV9D65Q5z ITv77giVurc2zYqxLCaSma8EuRc2I7aQZe5/UhvTuqki4CEbgkieuDDqlVUI2SywJ/wL CFP06rT5TAAYoVCmwWHgTE5IYSr3BZrCWno1NrCv8EUBmj3Utc5XPc3U1QatqFYSLkeU /9kCAlEucbwd7JzhL2UBkDOaCiY0uoIrICGROt9RnFDhBuh7o0Lc90aaKJ1MiiA2Fe7a 0iO5DLxl8NhC6v2kYhef9XhCTfvSbK6eocpVq8OCZlt8ER98hm/6xLrVAfl47sjXF1nd 9JwQ== 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=TcziFNzo6w/1eDpF33ybbfCgf5liqThhc/yZzX+FQd0=; b=c6rLe0JrgZFg4mN5Yiyw+dgWsvnLLEQjHDny0QMKQjHTjOjblVhUoiigEaFK8WUOSc 4q/QMIOU9KxOMDjMy9EKQDSYWhE3sYgWBZC5huXRRbLJMX/JumvYHnUV+zdYgP8vueJF dNwdqoQIRSQUTT8JMJ6r5f6l2SxbzFQatC1WPfYhapcptf7RqwFlH0VsF4GjpHHuqA6U BLx5OlgJ723xMnB61DY909idw/xQYU9EVdDZqAL0fbVTEueuRoucoZcbYpZBp7oN/mJe GR32qDEgm+9F1bbwZUSYWe6YlUK5qcwCZ/knYrHtYeawsHarEb4PgHCoIV8wvGN+HQKt GL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="HkO6/mMk"; 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 10-20020a170906208a00b008cb24fbfaa2si11263369ejq.992.2023.02.21.03.34.40; Tue, 21 Feb 2023 03:35:03 -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="HkO6/mMk"; 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 S233719AbjBUL1M (ORCPT + 99 others); Tue, 21 Feb 2023 06:27:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbjBUL0x (ORCPT ); Tue, 21 Feb 2023 06:26:53 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA1325BB2; Tue, 21 Feb 2023 03:26:43 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31L6tqin018089; Tue, 21 Feb 2023 11:26:28 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=TcziFNzo6w/1eDpF33ybbfCgf5liqThhc/yZzX+FQd0=; b=HkO6/mMkV1JBvZXK5rIdpO5Fk5o+2dCg6us+OAxSosgJ/wHdUX0ipMG2PZ+vDwsRqIlo uPd2kqiojfY4ScUc/5/mRF7WEj1AN72siwm3y1jyTuDzX50QzZBv5HOF9Rr1yt24xNRl W2PCjW//0v618qxe0UcaXqcLI0eEwOHwepTUg+xyxazzvno/3IcTmwSRKQs/kJInswfn nouIE8Q/RtT5QrxABOJ99W7uDN9vQBvCYJ0gnA/GXmZq9NlZOVBBOt71/mjPMHOH1N9k W8fe35w7RvQ3dTWx3yqJxmgn/8B1ohT0IbtbYYrXbgZQTQBmLj60U8FZ8nY6vj9bA1xj tQ== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nvprgrvyk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:28 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31LBQRkv007449 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:27 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 21 Feb 2023 03:26:23 -0800 From: Mukesh Ojha To: , , , , , , , CC: , , , , , Mukesh Ojha Subject: [RFC PATCH 5/6] remoterproc: qcom: refactor to leverage exported minidump symbol Date: Tue, 21 Feb 2023 16:55:12 +0530 Message-ID: <1676978713-7394-6-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> References: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: b7-B17u5Sf5A51gBHlHomjhYIwez2F5m X-Proofpoint-ORIG-GUID: b7-B17u5Sf5A51gBHlHomjhYIwez2F5m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_06,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210098 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758440250242840433?= X-GMAIL-MSGID: =?utf-8?q?1758440250242840433?= qcom_minidump driver provides qcom_minidump_subsystem_desc() exported API which other driver can use it query subsystem descriptor. Refactor qcom_minidump() to use this symbol. Signed-off-by: Mukesh Ojha --- drivers/remoteproc/qcom_common.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index f607e1e..273f92b 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -89,19 +89,10 @@ void qcom_minidump(struct rproc *rproc, unsigned int minidump_id) { int ret; struct minidump_subsystem *subsystem; - struct minidump_global_toc *toc; - /* Get Global minidump ToC*/ - toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL); - - /* check if global table pointer exists and init is set */ - if (IS_ERR(toc) || !toc->status) { - dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n"); + subsystem = qcom_minidump_subsystem_desc(minidump_id); + if (IS_ERR(subsystem)) return; - } - - /* Get subsystem table of contents using the minidump id */ - subsystem = &toc->subsystems[minidump_id]; /** * Collect minidump if SS ToC is valid and segment table From patchwork Tue Feb 21 11:25:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 59872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1811839wrn; Tue, 21 Feb 2023 03:35:06 -0800 (PST) X-Google-Smtp-Source: AK7set/AGrM3NP8W71Ze6MI2azQ4MZC+egTawXddRaGMhi5vrDyDLLKO7UFxFyASvwHTAsFbREvu X-Received: by 2002:a17:907:1612:b0:8b1:2eef:154c with SMTP id hb18-20020a170907161200b008b12eef154cmr12564815ejc.0.1676979306419; Tue, 21 Feb 2023 03:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676979306; cv=none; d=google.com; s=arc-20160816; b=a3bgn06XRREEht8o4LlQNWWP//trcXrfuLp13l8OoxQNyJzlE/LIM3M0WuI9KxBQhC 8i94CDTIpVBCiwH+yeKpAQjJno5p+TR/XFEnUE8igaA/L+x77FkeajsVXqpY08S6XBrj 2/vX5/V8V1+D3fFXz1d09V/La0WwAsUx9t4ECWfzOXdOa2pzssZqVFau5f24KxBSkDQu xkt6+Fq9s/YXrX19Y0Xpoc8y0cjEBLsuuAlW1InCjizBX8ya6ukiVRSgFXNobS/rGyd4 +9sfs/T3pHnGGIULFMMjBrXU4Lp000ZTD2Nj+C+cKgI5qsUofCaylKk1Xu25lPRIQXi9 7+iw== 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=YGKDvxRdX84ObfDEJmxXQZDtKg1Ik+7klLgTt5oEQtQ=; b=hvRoA01a3Oa4O8/xetJnUcCeNCzNxqctW80Io+CkSa7DGT5V8f/hK0cJDNdN8cnSNT 76DBNgfdCWALgHGUn5O+GUeIGfnmpk3gyX0UpLpHKtzMb4iPKt9Tc9WfGfKMc4M+OPDQ heqDY1/8Q8x6PyCtBk3ndJ67LQWIq5gltek0lck1cYSZ2KeuUhu8F5/JOXK8OWf0esN9 P/CSNbIh+hDKuOe2PjFDUv8WOcjnMBWaH7iPJ4uUuI4nWlaJW8bAVHFlphmJOeEhaVLj Te5fixHyNVq252wTLbLNTv1PtaAPFEF6ghMsc5hHVTKz0a7pdhCWR/knu4KxU57nUQaD ZS5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LjyjvlpZ; 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 up34-20020a170907cca200b008c215db35a8si9585065ejc.626.2023.02.21.03.34.43; Tue, 21 Feb 2023 03:35:06 -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=LjyjvlpZ; 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 S234121AbjBUL1U (ORCPT + 99 others); Tue, 21 Feb 2023 06:27:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234187AbjBUL1L (ORCPT ); Tue, 21 Feb 2023 06:27:11 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E788926867; Tue, 21 Feb 2023 03:26:47 -0800 (PST) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31L9lasu013842; Tue, 21 Feb 2023 11:26:32 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=YGKDvxRdX84ObfDEJmxXQZDtKg1Ik+7klLgTt5oEQtQ=; b=LjyjvlpZlRzKYIUGjHL7VuoOEEQ7aFYV72x7RtmeCIBWY+0JVEqzYknqYaxDCbuE2enw yoFHdjqgjmjhUNStY0qKj510XV3VpQRfP3aAl6A4qWHE6A1oJFFbBLWAk02Ayau81fWc 5ZxTd5po3nq+VYTN/X6zZSdR2fJUjloWBYbTyzDiGk1QJahHEi6+aIbGObfA3viSi8Xe HMY5FOES/Ox1Rn/+ZATXMdhfLpuWeZEgHccEVjVJ82t59WepnaBBQS8bpV9IOVTcXVIS Q0IacJXl5LnXRi0NA07oYv9xy9XvNVYoNPoE4LvOV+IgULYywNiH0i1qcZL/fB4O7Df8 dw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nvp4v0y6y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:32 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31LBQWqE019224 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Feb 2023 11:26:32 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 21 Feb 2023 03:26:27 -0800 From: Mukesh Ojha To: , , , , , , , CC: , , , , , Mukesh Ojha Subject: [RFC PATCH 6/6] pstore/ram: Register context with minidump Date: Tue, 21 Feb 2023 16:55:13 +0530 Message-ID: <1676978713-7394-7-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> References: <1676978713-7394-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 39Q1ejLA4uIACmh6IhozW6TddRXj8vlA X-Proofpoint-GUID: 39Q1ejLA4uIACmh6IhozW6TddRXj8vlA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-21_06,2023-02-20_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 spamscore=0 phishscore=0 suspectscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302210098 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758440252842388947?= X-GMAIL-MSGID: =?utf-8?q?1758440252842388947?= There are system which does not uses pstore directly but may have the interest in the context saved by pstore. Register pstore regions with minidump so that it get dumped on minidump collection. Signed-off-by: Mukesh Ojha --- fs/pstore/ram.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index ade66db..038da1a 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "internal.h" #include "ram_internal.h" @@ -714,6 +715,74 @@ static int ramoops_parse_dt(struct platform_device *pdev, return 0; } +#if IS_ENABLED(CONFIG_QCOM_MINIDUMP) +static int ramoops_qcom_minidump_register(struct ramoops_context *cxt) +{ + struct qcom_minidump_region pstore_entry; + struct persistent_ram_zone *prz; + int ret = 0; + int i; + + for (i = 0; i < cxt->max_dump_cnt; i++) { + prz = cxt->dprzs[i]; + scnprintf(pstore_entry.name, sizeof(pstore_entry.name), + "KDMESG%d", i); + pstore_entry.virt_addr = prz->vaddr; + pstore_entry.phys_addr = prz->paddr; + pstore_entry.size = prz->size; + ret = qcom_minidump_region_register(&pstore_entry); + if (ret < 0) { + pr_err("failed to add dmesg in minidump: err: %d\n", ret); + return ret; + } + } + + if (cxt->console_size) { + prz = cxt->cprz; + strlcpy(pstore_entry.name, "KCONSOLE", sizeof(pstore_entry.name)); + pstore_entry.virt_addr = prz->vaddr; + pstore_entry.phys_addr = prz->paddr; + pstore_entry.size = prz->size; + ret = qcom_minidump_region_register(&pstore_entry); + if (ret < 0) { + pr_err("failed to add console in minidump: err: %d\n", ret); + return ret; + } + } + + for (i = 0; i < cxt->max_ftrace_cnt; i++) { + prz = cxt->fprzs[i]; + scnprintf(pstore_entry.name, sizeof(pstore_entry.name), + "KFTRACE%d", i); + pstore_entry.virt_addr = prz->vaddr; + pstore_entry.phys_addr = prz->paddr; + pstore_entry.size = prz->size; + ret = qcom_minidump_region_register(&pstore_entry); + if (ret < 0) { + pr_err("failed to add ftrace in minidump: err: %d\n", ret); + return ret; + } + } + + if (cxt->pmsg_size) { + prz = cxt->mprz; + strlcpy(pstore_entry.name, "KPMSG", sizeof(pstore_entry.name)); + pstore_entry.virt_addr = prz->vaddr; + pstore_entry.phys_addr = prz->paddr; + pstore_entry.size = prz->size; + ret = qcom_minidump_region_register(&pstore_entry); + if (ret < 0) { + pr_err("failed to add pmsg in minidump: err: %d\n", ret); + return ret; + } + } + + return ret; +} +#else +static int ramoops_qcom_minidump_register(struct ramoops_context *cxt) { return 0; } +#endif + static int ramoops_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -724,6 +793,10 @@ static int ramoops_probe(struct platform_device *pdev) phys_addr_t paddr; int err = -EINVAL; + err = qcom_minidump_ready(); + if (err && err != -ENODEV) + return -EPROBE_DEFER; + /* * Only a single ramoops area allowed at a time, so fail extra * probes. @@ -841,6 +914,10 @@ static int ramoops_probe(struct platform_device *pdev) } } + err = ramoops_qcom_minidump_register(cxt); + if (err < 0) + goto fail_buf; + err = pstore_register(&cxt->pstore); if (err) { pr_err("registering with pstore failed\n");