From patchwork Wed Jun 28 12:34:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8899179vqr; Wed, 28 Jun 2023 05:51:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6x6QSj4P8DZWLH9H/ZEB6hs5EPBHFlTsVlamWOKciMSXjJWvgvSXXH0W9dJrsflqPf9zts X-Received: by 2002:a17:907:3e82:b0:991:f9e2:a418 with SMTP id hs2-20020a1709073e8200b00991f9e2a418mr7092619ejc.28.1687956717775; Wed, 28 Jun 2023 05:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956717; cv=none; d=google.com; s=arc-20160816; b=DAjJEn3f8vZ/I+Ip6BjDuOMPIkcvSw40mZ45g77d2gW5KE7tWXx9mZQjv20+7i9osU fqx/s9DJwTEzqhROvNj8AIhDgtTIEpsd6MSc0ACb1qEmmxmnSvQ2W3TrmeserIvYp0uG TFLK9M0kStFyEFLFH/4zo9YWsLIvi+HP2dsUTiyk1dAmWRCQfWyOyHU4IWFfwCkqK2bq tOOdcuNIALCCl+ktfBZjVnSYU2jlyIxly8iFs89Ybu6C3mVKpQAXhf5fuD3khumzLjCK uyCGXqve8olHJTMEIoksqtgOTfpzgeo/pE5zgZhzjoZn/5MRdlO1rpGIZw23cWZcQBQw qwsA== 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=JSeJz6vmPXLz33wUlydFQ74f+iZyLf0EKLfg0q3PF5E=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=lBDaytGYgrT31prf3gPXhNVLG8TRQ5MBwQR0eE8hv5S+76uSpD7fCusb6f0EsDmRyU QufaZ34iggeazV1ajimQnW/HkV5QE/ti3TzR7PgFgpVHG7gSBITMMgDutsosOfj3IAm+ La7eJcGi0eW7Pf63TM3gViejlXKEp+QDcAnCcittKNK6cRC7Df3d42oaPBD0J/C4ApEL ouA5U2y5Kq3GdtXtgU4cX+ty2fODoQc1lEBSJC8ZrgaJh9zY9KhUAsWICXvenhbBF1GL 0LkSmcx/gyxIh1jRI0mS8oD8D3vIJoQj8SCO/2TKYpy0nv8s5REKKqAmgbSJfpvYgb4J Zu/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=H27ML2s7; 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 qp7-20020a170907206700b00988588cab8csi5236128ejb.749.2023.06.28.05.51.34; Wed, 28 Jun 2023 05:51:57 -0700 (PDT) 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=H27ML2s7; 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 S231967AbjF1Miu (ORCPT + 99 others); Wed, 28 Jun 2023 08:38:50 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:21442 "EHLO mx0a-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231583AbjF1Mg6 (ORCPT ); Wed, 28 Jun 2023 08:36:58 -0400 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 35S5hCU6026329; Wed, 28 Jun 2023 12:35:22 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=JSeJz6vmPXLz33wUlydFQ74f+iZyLf0EKLfg0q3PF5E=; b=H27ML2s7GPpH7Ph8f7sdf1Yd6lB1Pqx+7YrDbHpoL4SUpBBctm+zujZgaDsTbHxQgGit FpZJR3iPG8uYZYx0erRreuLM2vBw4wSTEnPxuVMS81OY9gaajGSmVMTKF2k5CBf6BkgD qKVwBUy7J1Xo9XIt9gKWO5EtfjYBXxKdabDp5T557BJpfigOeitrBGvH3fKUWf6dVoTS prSTeJL/VxS1JAv1bRnUMzp/sTFI+VB9/XmFGVeh49bPykWoAhtbgfMHzwaqxQknRaJ8 Ac7sdbe1NUgASHjGKUAuP165aVL7Ql0K7jGcxTUhSXW5y7auYilnJSLxd9QG8g4A6xW2 pQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgextgwv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:21 +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 35SCZKKx029062 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:20 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.42; Wed, 28 Jun 2023 05:35:14 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide Date: Wed, 28 Jun 2023 18:04:28 +0530 Message-ID: <1687955688-20809-2-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: hAb0oc_PLuXPEomLl0jYT4OvLrOJPJmz X-Proofpoint-GUID: hAb0oc_PLuXPEomLl0jYT4OvLrOJPJmz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950903424708476?= X-GMAIL-MSGID: =?utf-8?q?1769950903424708476?= Add the qualcomm minidump guide for the users which tries to cover the dependency and the way to test and collect minidump on Qualcomm supported platforms. Signed-off-by: Mukesh Ojha --- Documentation/admin-guide/index.rst | 1 + Documentation/admin-guide/qcom_minidump.rst | 293 ++++++++++++++++++++++++++++ 2 files changed, 294 insertions(+) create mode 100644 Documentation/admin-guide/qcom_minidump.rst diff --git a/Documentation/admin-guide/index.rst b/Documentation/admin-guide/index.rst index 43ea35613dfc..251d070486c2 100644 --- a/Documentation/admin-guide/index.rst +++ b/Documentation/admin-guide/index.rst @@ -120,6 +120,7 @@ configure specific aspects of kernel behavior to your liking. perf-security pm/index pnp + qcom_minidump rapidio ras rtc diff --git a/Documentation/admin-guide/qcom_minidump.rst b/Documentation/admin-guide/qcom_minidump.rst new file mode 100644 index 000000000000..a3a8cfee4555 --- /dev/null +++ b/Documentation/admin-guide/qcom_minidump.rst @@ -0,0 +1,293 @@ +Qualcomm Minidump Feature +========================= + +Introduction +------------ + +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 RAM dumps 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. + +:: + + +-----------------------------------------------+ + | 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 contents + SS-ToC: Subsystem table of contents + SS0-SSn: Subsystem numbered from 0 to n + +It depends on targets how the underlying hardware taking care of the +implementation part for minidump like above diagram is for shared +memory and it is possible that this could be implemented via memory +mapped regions but the general idea remain same. + +In this document, SMEM will be used as the backend implementation of +minidump. + +SMEM as backend +---------------- + +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 contents (G-ToC). Each subsystem (APSS, ADSP, ...) has +its 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 its size etc. and it +could be anywhere scattered in the DDR. + +Minidump kernel driver concept +------------------------------ +:: + + Minidump Client-1 Client-2 Client-5 Client-n + | | | | + | | ... | ... | + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | +---+--------------+----+ | + +-----------+ qcom_minidump(core) +--------+ + | | + +------+-----+------+---+ + | | | + | | | + +---------------+ | +--------------------+ + | | | + | | | + | | | + v v v + +-------------------+ +-------------------+ +------------------+ + |qcom_minidump_smem | |qcom_minidump_mmio | | qcom_minidump_rm | + | | | | | | + +-------------------+ +-------------------+ +------------------+ + Shared memory Memory mapped IO Resource manager + (backend) (backend) (backend) + + +Kernel implementation of minidump driver is divided into two parts one is, +the core implementation called frontend driver ``qcom_minidump.c`` and this +is the driver will be exposing the API for clients and the other part is, +backend driver and its depends whether it is based on SMEM, MMIO or some +other way corressponding driver will be hooking itself up with the core +driver to get itself working. As of now, at a time one and only one backend +can be attached to the front-end either it is HOST or a guest VM. + +Qualcomm minidump kernel driver adds the capability to add Linux region +to be dumped as part of RAM dump collection. At the moment, shared memory +driver creates platform device for minidump driver and give a means to +APSS minidump to initialize itself on probe. + +This driver provides ``qcom_minidump_region_register`` and +``qcom_minidump_region_unregister`` API's to register and unregister +APSS minidump region. It also gives a mechanism to update physical/virtual +address for the client whose addresses keeps on changing, e.g., current stack +address of task keeps on changing on context switch for each core. So these +clients can update their addresses with ``qcom_minidump_update_region`` +API. + +The driver also supports registration for the clients who came before +minidump driver was initialized. It maintains pending list of clients +who came before minidump and once minidump is initialized it registers +them in one go. + +To simplify post-mortem debugging, driver creates and maintain an ELF +header as first region that gets updated each time a new region gets +registered. + +The solution supports extracting the RAM dump/minidump produced either +over USB or stored to an attached storage device. + +Dependency of minidump kernel driver +------------------------------------ + +It is to note that whole of minidump depends on Qualcomm boot +firmware whether it supports minidump or not. So, if the minidump +SMEM ID is present in shared memory, it indicates that minidump +is supported from boot firmware and it is possible to dump Linux +(APSS) region as part of minidump collection. + +How a kernel client driver can register region with minidump +------------------------------------------------------------ + +Client driver can use ``qcom_minidump_region_register`` API's to +register and ``qcom_minidump_region_unregister`` to unregister +their region from minidump driver. + +Client needs to fill their region by filling ``qcom_minidump_region`` +structure object which consists of the region name, region's +virtual and physical address and its size. + +Below is one sample client driver snippet which tries to allocate +a region from kernel heap of certain size and it writes a certain +known pattern (that can help in verification after collection +that we got the exact pattern, what we wrote) and registers it with +minidump. + + .. code-block:: c + + #include + [...] + + + [... inside a function ...] + struct qcom_minidump_region region; + + [...] + + client_mem_region = kzalloc(region_size, GFP_KERNEL); + if (!client_mem_region) + return -ENOMEM; + + [... Just write a pattern ...] + memset(client_mem_region, 0xAB, region_size); + + [... Fill up the region object ...] + strlcpy(region.name, "REGION_A", sizeof(region.name)); + region.virt_addr = client_mem_region; + region.phys_addr = virt_to_phys(client_mem_region); + region.size = region_size; + + ret = qcom_minidump_region_register(®ion); + if (ret < 0) { + pr_err("failed to add region in minidump: err: %d\n", ret); + return ret; + } + + [...] + + +Test +---- + +Existing Qualcomm devices already supports entire RAM dump (also called +full dump) by writing appropriate value to Qualcomm's top control and +status register (tcsr) in ``driver/firmware/qcom_scm.c`` . + +SCM device Tree bindings required to support download mode +For example (sm8450) :: + + / { + + [...] + + firmware { + scm: scm { + compatible = "qcom,scm-sm8450", "qcom,scm"; + [... tcsr register ... ] + qcom,dload-mode = <&tcsr 0x13000>; + + [...] + }; + }; + + [...] + + soc: soc@0 { + + [...] + + tcsr: syscon@1fc0000 { + compatible = "qcom,sm8450-tcsr", "syscon"; + reg = <0x0 0x1fc0000 0x0 0x30000>; + }; + + [...] + }; + [...] + + }; + +User of minidump can pass ``qcom_scm.download_mode="mini"`` to kernel +commandline to set the current download mode to minidump. +Similarly, ``"full"`` is passed to set the download mode to full dump +where entire RAM dump will be collected while setting it ``"full,mini"`` +will collect minidump along with fulldump. + +Writing to sysfs node can also be used to set the mode to minidump:: + + echo "mini" > /sys/module/qcom_scm/parameter/download_mode + +Once the download mode is set, any kind of crash will make the device collect +respective dump as per set download mode. + +Dump collection +--------------- + +The solution supports extracting the minidump produced either over USB or +stored to an attached storage device. + +By default, dumps are downloaded via USB to the attached x86_64 machine +running PCAT (Qualcomm tool) software. Upon download, we will see +a set of binary blobs starting with name ``md_*`` in PCAT configured directory +in x86_64 machine, so for above example from the client it will be +``md_REGION_A.BIN``. This binary blob depends on region content to determine +whether it needs external parser support to get the content of the region, +so for simple plain ASCII text we don't need any parsing and the content +can be seen just opening the binary file. + +To collect the dump to attached storage type, one needs to write appropriate +value to IMEM register, in that case dumps are collected in rawdump +partition on the target device itself. + +One needs to read the entire rawdump partition and pull out content to +save it onto the attached x86_64 machine over USB. Later, this rawdump +can be passed to another tool (``dexter.exe`` [Qualcomm tool]) which converts +this into the similar binary blobs which we have got it when download type +was set to USB, i.e. a set of registered regions as blobs and their name +starts with ``md_*``. + +Replacing the ``dexter.exe`` with some open source tool can be added as future +scope of this document. From patchwork Wed Jun 28 12:34:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8899154vqr; Wed, 28 Jun 2023 05:51:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MZ3SK4basck3qKyX3MtoBtdmivSwPHIrlcFhgp15VLKNpR46/10lrNRGO6zEHAxDBt/+O X-Received: by 2002:a17:907:6088:b0:988:c97b:894b with SMTP id ht8-20020a170907608800b00988c97b894bmr27356500ejc.68.1687956715211; Wed, 28 Jun 2023 05:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956715; cv=none; d=google.com; s=arc-20160816; b=aa7GBO1KnYnIHd/IsQq+M7Lbs900b04fjlUo6oThUsvvXbgMHVS2srgyjqRBsaXeia QcnA9dTQ+KQN/SXPS12Ac8nC107uZRpm6z78UQygQ4ti9OgGor6coOaSudkBf2DRqBEP 9XA1O+h4N11b8AZZtpjLMWyYWib7cHIfWDDcg+ZCmLuy+zTI8yhVDmfJzLWSizNuniSd mNfNlMTfdXdTSgTcK+xmKLcgInMNLx5iuAJr7+k7wxAoAR+U7stS8auH+3lnUd71HdKf qm7XsznyGF1GEtT7KOR48yOcUcQzhxEtp3DUlzLqMFMMhYWlWlb1NLFZ4zRud5AwSjcb VzUg== 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=z/38/L7Qb4rY0gn24IqUDEH0xFQsfWB9pSUqCcrV3P8=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=CsSMYDKnYVtAo5CNG/IeIGZ7jEVBm/bDN2px0+7wKwSsTdJv0k81vkDy1S+sIwMWuc tokPPDjokEgdRW7SpAVczF+A5wC7VQ66HYRNZEHR+ESnghweWtHQb8Gr2JPQdKpsIUxw YpkBV3OtqPSQXb/NNExRS/fp4bxBwYeh8o2K8eReMazfuoHFM6Uzdgn75PiP2GhukuCz olpC1A2blLo7O7chOjx7bzLsdlWymy8hPQh30eJXAjVKkOqbdPOXGe8SWShQw+DbXktd INCa5KeLvgybbUC++jOPf0bU4m1MzSrpcGLYc/h4zZj5pMSefvIoUDSuVMniSQdqlXo/ Osew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="HNt/zEUQ"; 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 q17-20020a170906b29100b0098276521c40si5405439ejz.901.2023.06.28.05.51.31; Wed, 28 Jun 2023 05:51:55 -0700 (PDT) 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="HNt/zEUQ"; 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 S231350AbjF1MgM (ORCPT + 99 others); Wed, 28 Jun 2023 08:36:12 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:30942 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231303AbjF1MgA (ORCPT ); Wed, 28 Jun 2023 08:36:00 -0400 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 35SBBj0W032212; Wed, 28 Jun 2023 12:35:29 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=z/38/L7Qb4rY0gn24IqUDEH0xFQsfWB9pSUqCcrV3P8=; b=HNt/zEUQKPRanF5fARYX0Inv7LCG2imfF6HYWksc/Eli2gqIe2VjIiOwyMrLlCPlZq19 l7bZCVuDQIuguhcfQV4LBj2QX6OqqTet7/YZqtdc9aRZ4ZfFrnMzqqGdEOOe0454ugB3 2gHE8oIBdGiJ06ixILlRJyde0MVBVa/Wno6UPBe81pLh74ci9+r1ej5jdcEDUxdB/e+m D9e6DFlPygSCp1mGmaDrpB+oe0G5Nr265ncA/pUoLUCtmh0Dhq1lbmGQSHVzMV6xCzWK g1PFLDK/ezpJc9LCowsl1GwG81f0kMZS0Wwb2aDUM5/GqYYYjdeDIWHLrTdPBU6stiFJ gw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgetpgw4j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:28 +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 35SCZRr3025624 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35: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.42; Wed, 28 Jun 2023 05:35:20 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name Date: Wed, 28 Jun 2023 18:04:29 +0530 Message-ID: <1687955688-20809-3-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: cdOZ3jlYYRrz3hYIl8DadVmQZGPwRH6s X-Proofpoint-GUID: cdOZ3jlYYRrz3hYIl8DadVmQZGPwRH6s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950900900844095?= X-GMAIL-MSGID: =?utf-8?q?1769950900900844095?= Module like minidump providing debugging support will need to get the symbol information from the core kernel e.g to get the linux_banner, kernel section addresses bss, data, ro etc. commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name due to lack of in-tree user of the symbol. Now, that minidump will one of its user, export it. Signed-off-by: Mukesh Ojha --- kernel/kallsyms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 77747391f49b..34a074f58736 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -283,7 +283,7 @@ unsigned long kallsyms_lookup_name(const char *name) return module_kallsyms_lookup_name(name); } - +EXPORT_SYMBOL_GPL(kallsyms_lookup_name); /* * Iterate over all symbols in vmlinux. For symbols from modules use * module_kallsyms_on_each_symbol instead. From patchwork Wed Jun 28 12:34:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8900831vqr; Wed, 28 Jun 2023 05:55:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DIuFvbiM0o/yKu6rkJutvyUWX9trhb9wB0YtRTXaLzaS0d/ogZiyM1G5Q18gtp3i3W3s7 X-Received: by 2002:a17:907:d0b:b0:974:55ea:1ad8 with SMTP id gn11-20020a1709070d0b00b0097455ea1ad8mr38085664ejc.63.1687956909411; Wed, 28 Jun 2023 05:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956909; cv=none; d=google.com; s=arc-20160816; b=UjYSP8ZwNkuwF0GGdWZSbuibgAmBBc9ZWh9IPiMFaA7dltE7CLG3ZYA6mcxICu6xW5 QKIad23KziL9o+L3HS1XVK7NvOzm1zBKjwITJhnXVNRSdwJt9vXWyaIpo3fHNFPxd5Fo WlPd1VDvqzaWOX01Rh35tQPDw+qMdxJwZ4uoiHsxA0LHbFoz5Ru962tOINjLR0j82aHH i1CExMfkHaniFwi37KUSBwoPoS9BbKKD1kG1xw4fogRfwhUHLuioJ1nzyeMqUNatSwb8 RufDqqxqXT7AbIxqKV4ttDT5EsjAZi6kA3BjnWWxwsyiT4CUAFGkPG7JGUuuTQs9q1gN 0dDg== 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=QmPTvnuCX9nTTcTKJzsrAxvtP/T8wK3/aBYs6dPtSDI=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=wJK5yq7RIj2CI/BbjOiY3wJ3K6iyTYIiVQpMBg1vLKk0KDbPKRHOKYg7kOZztZlFBQ j9CXXzJZIDNGsrcy4EAsBu0hvLYr62KOHq+oWLLt/+vBXGvlCsBRFtf5Dy3K2GhuGG/E yEhvdviRpP/YnLeCUkdlAICIlRJU6PPP7hj7CHwkP6n5Af3xPPxlyHzt/LZcGycgDFxq jokR2DNZ5HedIFenuHr5tpz1Ps5jfObWC8RR2I0hjaDxOHmfJGa6jAxeD/ifKSYxWrUP kU+oWQKl9GK5bkgXwb32GeO1yolX9Pai3lLHetU3XKZ68wTnIYt146yvNV0jFbtOLyy5 rsXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Ierbl0Lv; 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 k25-20020a17090666d900b00988907e3aaesi5752337ejp.428.2023.06.28.05.54.46; Wed, 28 Jun 2023 05:55:09 -0700 (PDT) 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=Ierbl0Lv; 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 S231430AbjF1MiS (ORCPT + 99 others); Wed, 28 Jun 2023 08:38:18 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:2428 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbjF1Mgk (ORCPT ); Wed, 28 Jun 2023 08:36:40 -0400 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 35S7R01Z029236; Wed, 28 Jun 2023 12:35:37 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=QmPTvnuCX9nTTcTKJzsrAxvtP/T8wK3/aBYs6dPtSDI=; b=Ierbl0LvulKXCI+Dz6XQC3UdYbrYlrZS0tR4q0MBlUktdtEqvx2n6tXi379tRuiLGqQs ZlaHvQ8KGcrwc9sKDX9vrqc3MJN54GOaLSY3C7LMcZXvXRzqaZXLNbz74Ee9VL5qdgLY fGdje59auLxBoEFaZtssqR9Xj/Hzylj0k3N3HmoVWxwc4xP7oIrDs6tUctq78RRSPk1d EGqL1ioVGw9FGMYiBSiS+x5KixChWZUJAE/z8cczyVTd8JN/oQG+8euPwE3BIsjTej88 aXihprM1c18RE9J0k5Cl9RW5yOVD63DMK4V5ne5GoWuQlijZ/WjUOGb7Re05LtyA0O0S DA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgbfss8d0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:36 +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 35SCZZpe029190 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:35 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.42; Wed, 28 Jun 2023 05:35:27 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module Date: Wed, 28 Jun 2023 18:04:30 +0530 Message-ID: <1687955688-20809-4-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: 8vbZ3mHqD4PnjLNlGLMFmmrv47sJ7uZj X-Proofpoint-ORIG-GUID: 8vbZ3mHqD4PnjLNlGLMFmmrv47sJ7uZj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769951104319073027?= X-GMAIL-MSGID: =?utf-8?q?1769951104319073027?= Add qcom_minidump_smem module in a preparation to remove smem based minidump specific code from driver/remoteproc/qcom_common.c and provide needed exported API, this abstract minidump specific data layout from qualcomm's remoteproc driver. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/Kconfig | 8 ++ drivers/soc/qcom/qcom_minidump_smem.c | 147 ++++++++++++++++++++++++++++++++++ include/soc/qcom/qcom_minidump.h | 24 ++++++ 3 files changed, 179 insertions(+) create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c create mode 100644 include/soc/qcom/qcom_minidump.h diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index a491718f8064..982310b5a1cb 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -279,4 +279,12 @@ config QCOM_INLINE_CRYPTO_ENGINE tristate select QCOM_SCM +config QCOM_MINIDUMP_SMEM + tristate "QCOM Minidump SMEM (as backend) Support" + depends on ARCH_QCOM + depends on QCOM_SMEM + help + Enablement of core minidump feature is controlled from boot firmware + side, and this config allow linux to query minidump segments associated + with the remote processor and check its validity. endmenu diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c new file mode 100644 index 000000000000..b588833ea26e --- /dev/null +++ b/drivers/soc/qcom/qcom_minidump_smem.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ +#include +#include +#include +#include +#include + +#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]; +}; + +/** + * qcom_ss_md_mapped_base() - For getting subsystem iomapped base segment address + * for given minidump index. + * + * @minidump_id: Subsystem minidump index. + * @seg_cnt: Segment count for a given minidump index + * + * Return: On success, it returns iomapped base segment address, otherwise NULL on error. + */ +void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt) +{ + struct minidump_global_toc *toc; + struct minidump_subsystem *subsystem; + + /* + * Get global minidump ToC and check if global table + * pointer exists and init is set. + */ + toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL); + if (IS_ERR(toc) || !toc->status) + return NULL; + + /* Get subsystem table of contents using the minidump id */ + subsystem = &toc->subsystems[minidump_id]; + + /** + * Collect minidump if SS ToC is valid and segment table + * is initialized in memory and encryption status is set. + */ + if (subsystem->regions_baseptr == 0 || + le32_to_cpu(subsystem->status) != 1 || + le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED || + le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) + return NULL; + + *seg_cnt = le32_to_cpu(subsystem->region_count); + + return ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr), + *seg_cnt * sizeof(struct minidump_region)); +} +EXPORT_SYMBOL_GPL(qcom_ss_md_mapped_base); + +/** + * qcom_ss_valid_segment_info() - Checks segment sanity and gets it's details + * + * @ptr: Segment IO-mapped base address. + * @i: Segment index. + * @name: Segment name. + * @da: Segment physical address. + * @size: Segment size. + * + * Return: It returns 0 on success and 1 if the segment is invalid and negative + * value on error. + */ +int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t *da, size_t *size) +{ + struct minidump_region __iomem *tmp; + struct minidump_region region; + + if (!ptr) + return -EINVAL; + + tmp = ptr; + memcpy_fromio(®ion, tmp + i, sizeof(region)); + + /* If it is not valid region, skip it */ + if (le32_to_cpu(region.valid) != MINIDUMP_REGION_VALID) + return 1; + + *name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL); + if (!*name) + return -ENOMEM; + + *da = le64_to_cpu(region.address); + *size = le64_to_cpu(region.size); + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_ss_valid_segment_info); + +MODULE_DESCRIPTION("Qualcomm Minidump SMEM as backend driver"); +MODULE_LICENSE("GPL"); diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h new file mode 100644 index 000000000000..d7747c27fd45 --- /dev/null +++ b/include/soc/qcom/qcom_minidump.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _QCOM_MINIDUMP_H_ +#define _QCOM_MINIDUMP_H_ + +#if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM) +void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt); +int qcom_ss_valid_segment_info(void *ptr, int i, char **name, + dma_addr_t *da, size_t *size); +#else +static inline void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt) +{ + return NULL; +} +static inline int qcom_ss_valid_segment_info(void *ptr, int i, char **name, + dma_addr_t *da, size_t *size) +{ + return -EINVAL; +} +#endif /* CONFIG_QCOM_MINIDUMP_SMEM */ +#endif /* _QCOM_MINIDUMP_H_ */ From patchwork Wed Jun 28 12:34:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8898776vqr; Wed, 28 Jun 2023 05:51:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6b42RqxcmHmgo/1oJkZEBzyjcjC2mDwMp3CDISwkAN7yOlfzzk4HYDKP5FH73vvdG29Zul X-Received: by 2002:a17:907:2d8f:b0:992:5399:2543 with SMTP id gt15-20020a1709072d8f00b0099253992543mr2534874ejc.30.1687956672873; Wed, 28 Jun 2023 05:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956672; cv=none; d=google.com; s=arc-20160816; b=yfiLMm3qoqqwDCw9tPrFLCb9xdpcoqnhM9NTz3ShjQdMCNfLMic2pL5phM4GCY+2Z4 ru5qfSKJ2Vx1EEfvMfplCq/13eJrHG9x6jDTVJYs9ooyevpNM3xgY0Jei4n9q1zCOyvx X26OF8GGyIS4VYX0yEyZ0wdBiR+/vj/JAxtnkfIBPhTIYNCfNSlIj57BBDb5kJEQ86WY haNgm1gyK4XeeiktcWo6Sby0L4BbOAZpJYJCeF0bOcFWgVuul7L1eIqp8IlHl/bipC1m MgrtLon1Kzlk13tuMB1szQICMnAa5WlMIXo4MR8ont2qckAwyeo4r3Z094uSbXvoi6nC JLiQ== 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=reR/OBRi++6hTO4s+OJ86kHXDpuVnRYQwHnvTltWSGo=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=y6kRdkZKkWGdXV8Y5aikt5dxy4mrlWMUXa0bjtz9f5IuYMgA62/zF+vskiFN7qTsUv TrjCNTW/1X7yPjfc8fDL4sTFy+gWHrjDgrOPERH2Pqsn2XHafom5IQlGqUHrjQhljk5T e0yn7PGiablJzVuVnANQKDX6TQC2N6HKDfUlL8NPD1nGgxIiGPftQipmOhwdhcQH9SFO CLg071J/obd79X5UTm2y9213tCGqE+ZCR9vBwMV9iQe3zUd3w4+rr1sWoWq8wrRofPU/ 1v+8RCZ7vyXU4udzkW2edTaRipue2/QDrkcXcpmPo4TamcrhkXmEINOxuLAQKCmMWhbI V4/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gXtjStU5; 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 ca15-20020a170906a3cf00b009924806cd0asi1638713ejb.295.2023.06.28.05.50.48; Wed, 28 Jun 2023 05:51:12 -0700 (PDT) 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=gXtjStU5; 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 S231542AbjF1Mgv (ORCPT + 99 others); Wed, 28 Jun 2023 08:36:51 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:48294 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbjF1MgT (ORCPT ); Wed, 28 Jun 2023 08:36:19 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SCT5mO017762; Wed, 28 Jun 2023 12:35:44 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=reR/OBRi++6hTO4s+OJ86kHXDpuVnRYQwHnvTltWSGo=; b=gXtjStU5Py+hhGwOiJX2l5jfJutoviW8q3ypLVL8KiD0BeqWKcmOKf/+PjhEuHhs9CP9 M1k5mpzb/bGJ1IMMGS7c8clnhLKEabxwIwZH681FNrXvFG2cTkKs5NcoXRODdPGnlXid 4wnICb3Rwal3JkNr/61DVS+i58mOWONlZY2FB2YJ5caH498lK+vWB3iNRX8QPw3yl2g5 +JqLWWJknJTSnN+6FfrwO4lFpwCvh35TpNOCBfyTDAp0c7d8Y7tpaCPNkQ3Cg7ymCp0/ 6Ochk5Jyn0lqnVZ1AMZ3axQaTPaDo64iRn1MxrwFQdwm7H26ee56hjyjWsSQXWDLPGlp cg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rfrdtbq7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:43 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCZgl5023662 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:42 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.42; Wed, 28 Jun 2023 05:35:35 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support Date: Wed, 28 Jun 2023 18:04:31 +0530 Message-ID: <1687955688-20809-5-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: oTb39OZ0yM19lZfwqLm3QZKACOst7Nyu X-Proofpoint-GUID: oTb39OZ0yM19lZfwqLm3QZKACOst7Nyu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950855886053333?= X-GMAIL-MSGID: =?utf-8?q?1769950855886053333?= 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. Minidump kernel driver implementation is divided into two parts for simplicity, one is minidump core which can also be called minidump frontend(As API gets exported from this driver for registration with backend) and the other part is minidump backend i.e, where the underlying implementation of minidump will be there. There could be different way how the backend is implemented like Shared memory, Memory mapped IO or Resource manager based where the guest region information is passed to hypervisor via hypercalls. Minidump Client-1 Client-2 Client-5 Client-n | | | | | | ... | ... | | | | | | | | | | | | | | | | | | | | | | | | | | +---+--------------+----+ | +-----------+ qcom_minidump(core) +--------+ | | +------+-----+------+---+ | | | | | | +---------------+ | +--------------------+ | | | | | | | | | v v v +-------------------+ +-------------------+ +------------------+ |qcom_minidump_smem | |qcom_minidump_mmio | | qcom_minidump_rm | | | | | | | +-------------------+ +-------------------+ +------------------+ Shared memory Memory mapped IO Resource manager (backend) (backend) (backend) Here, we will be giving all analogy of backend with SMEM as it is the only implemented backend at present but general idea remains the same. 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. qcom_minidump(core or frontend) driver adds the capability to add APSS region to be dumped as part of ram dump collection. It provides appropriate symbol register/unregister client regions. To simplify post mortem debugging, it creates and maintain an ELF header as first region that gets updated upon registration of a new region. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/Kconfig | 15 + drivers/soc/qcom/Makefile | 2 + drivers/soc/qcom/qcom_minidump.c | 456 ++++++++++++++++++++++++++++++ drivers/soc/qcom/qcom_minidump_internal.h | 75 +++++ include/soc/qcom/qcom_minidump.h | 35 +++ 5 files changed, 583 insertions(+) create mode 100644 drivers/soc/qcom/qcom_minidump.c create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 982310b5a1cb..874ee8c3efe0 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE tristate select QCOM_SCM +config QCOM_MINIDUMP + tristate "QCOM Minidump APSS Core Infrastructure" + depends on ARCH_QCOM + help + This config allow linux core infrastructure for APSS minidump for + underlying backend(smem etc.) which can hook themselves to this and + work as one unit. So, this config should be selected in combination + with its backend. + + After this Linux clients driver can register their internal data + structures and debug messages as part of the apss minidump region + and when the SoC is crashed, and these selective regions will be + dumped instead of the entire DDR. This saves significant amount + of time and/or storage space. + config QCOM_MINIDUMP_SMEM tristate "QCOM Minidump SMEM (as backend) Support" depends on ARCH_QCOM diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index 89b775512bef..737d868757ac 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) += kryo-l2-accessors.o obj-$(CONFIG_QCOM_ICC_BWMON) += icc-bwmon.o qcom_ice-objs += ice.o obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE) += qcom_ice.o +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o +obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c new file mode 100644 index 000000000000..7744e57843ab --- /dev/null +++ b/drivers/soc/qcom/qcom_minidump.c @@ -0,0 +1,456 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "qcom_minidump_internal.h" + +/* + * 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 201. In future, this limitation + * from boot firmware might get removed by allocating the region dynamically. + * So, keep it compatible with older devices, we can keep the current limit for + * Linux to 201. + */ +#define MAX_NUM_ENTRIES 201 +#define MAX_STRTBL_SIZE (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH) + +/* + * md_lock protects "md" during calls to qcom_minidump_backend_register(), + * qcom_minidump_backend_unregister(). + */ +static DEFINE_MUTEX(md_lock); + +/* Only one front end will be attached to one back-end */ +static struct minidump *md; +static char *md_backend; + +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 char *elf_lookup_string(struct elfhdr *ehdr, int offset) +{ + char *strtab = elf_str_table_start(ehdr); + + if (!strtab || (md->elf.strtable_idx < offset)) + return NULL; + + return strtab + offset; +} + +static unsigned int append_str_to_strtable(struct minidump *md, const char *name) +{ + char *strtab = elf_str_table_start(md->elf.ehdr); + unsigned int old_idx = md->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); + md->elf.strtable_idx = old_idx + 1; + + return ret; +} + +static int qcom_minidump_clear_header(const struct qcom_minidump_region *region) +{ + struct elfhdr *ehdr = md->elf.ehdr; + struct elf_shdr *shdr; + struct elf_shdr *tmp_shdr; + struct elf_phdr *phdr; + struct elf_phdr *tmp_phdr; + unsigned int phidx; + unsigned int shidx; + unsigned int len; + unsigned int i; + char *shname; + + for (i = 0; i < ehdr->e_phnum; i++) { + phdr = elf_phdr_entry_addr(ehdr, i); + if (phdr->p_paddr == region->phys_addr && + phdr->p_memsz == region->size) + break; + } + + if (i == ehdr->e_phnum) { + dev_err(md->dev, "Cannot find program header entry in elf\n"); + return -EINVAL; + } + + phidx = i; + for (i = 0; i < ehdr->e_shnum; i++) { + shdr = elf_shdr_entry_addr(ehdr, i); + shname = elf_lookup_string(ehdr, shdr->sh_name); + if (shname && !strcmp(shname, region->name) && + shdr->sh_addr == (elf_addr_t)region->virt_addr && + shdr->sh_size == region->size) + break; + } + + if (i == ehdr->e_shnum) { + dev_err(md->dev, "Cannot find section header entry in elf\n"); + return -EINVAL; + } + + shidx = i; + if (shdr->sh_offset != phdr->p_offset) { + dev_err(md->dev, "Invalid entry details for region: %s\n", region->name); + return -EINVAL; + } + + /* Clear name in string table */ + len = strlen(shname) + 1; + memmove(shname, shname + len, md->elf.strtable_idx - shdr->sh_name - len); + md->elf.strtable_idx -= len; + + /* Clear program header */ + tmp_phdr = elf_phdr_entry_addr(ehdr, phidx); + for (i = phidx; i < ehdr->e_phnum - 1; i++) { + tmp_phdr = elf_phdr_entry_addr(ehdr, i + 1); + phdr = elf_phdr_entry_addr(ehdr, i); + memcpy(phdr, tmp_phdr, sizeof(struct elf_phdr)); + phdr->p_offset = phdr->p_offset - region->size; + } + memset(tmp_phdr, 0, sizeof(struct elf_phdr)); + ehdr->e_phnum--; + + /* Clear section header */ + tmp_shdr = elf_shdr_entry_addr(ehdr, shidx); + for (i = shidx; i < ehdr->e_shnum - 1; i++) { + tmp_shdr = elf_shdr_entry_addr(ehdr, i + 1); + shdr = elf_shdr_entry_addr(ehdr, i); + memcpy(shdr, tmp_shdr, sizeof(struct elf_shdr)); + shdr->sh_offset -= region->size; + shdr->sh_name -= len; + } + + memset(tmp_shdr, 0, sizeof(struct elf_shdr)); + ehdr->e_shnum--; + md->elf.elf_offset -= region->size; + + return 0; +} + +static void qcom_md_update_elf_header(const struct qcom_minidump_region *region) +{ + struct elfhdr *ehdr = md->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(md, region->name); + shdr->sh_addr = (elf_addr_t)region->virt_addr; + shdr->sh_size = region->size; + shdr->sh_flags = SHF_WRITE; + shdr->sh_offset = md->elf.elf_offset; + shdr->sh_entsize = 0; + + phdr->p_type = PT_LOAD; + phdr->p_offset = md->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; + md->elf.elf_offset += shdr->sh_size; +} + +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); +} + +/** + * qcom_minidump_region_register() - Register region in APSS Minidump table. + * @region: minidump region. + * + * Return: On success, it returns 0 and negative error value on failure. + */ +int qcom_minidump_region_register(const struct qcom_minidump_region *region) +{ + int ret; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md_lock); + if (!md) { + mutex_unlock(&md_lock); + pr_err("No backend registered yet, try again.."); + return -EPROBE_DEFER; + } + + ret = md->ops->md_region_register(md, region); + if (ret) + goto unlock; + + qcom_md_update_elf_header(region); +unlock: + mutex_unlock(&md_lock); + return ret; +} +EXPORT_SYMBOL_GPL(qcom_minidump_region_register); + +/** + * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table. + * @region: minidump region. + * + * Return: On success, it returns 0 and negative error value on failure. + */ +int qcom_minidump_region_unregister(const struct qcom_minidump_region *region) +{ + int ret; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md_lock); + if (!md) { + mutex_unlock(&md_lock); + pr_err("No backend registered yet, try again.."); + return -EPROBE_DEFER; + } + + ret = md->ops->md_region_unregister(md, region); + if (ret) + goto unlock; + + ret = qcom_minidump_clear_header(region); +unlock: + mutex_unlock(&md_lock); + return ret; +} +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister); + +static int qcom_minidump_add_elf_header(struct minidump *md_data) +{ + 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 *linux_banner; + unsigned int banner_len; + char *banner; + + linux_banner = (char *)kallsyms_lookup_name("linux_banner"); + 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); + + md_data->elf.ehdr = devm_kzalloc(md_data->dev, elfh_size, GFP_KERNEL); + if (!md_data->elf.ehdr) + return -ENOMEM; + + ehdr = md_data->elf.ehdr; + /* Assign Section/Program headers offset */ + md_data->elf.shdr = shdr = (struct elf_shdr *)(ehdr + 1); + md_data->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; + + md_data->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. + */ + md_data->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(md_data, "STR_TBL"); + shdr++; + + /* 3rd 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(md_data, "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; + + /* + * Above are some prdefined sections/program header used + * for debug, update their count here. + */ + ehdr->e_phnum = 1; + ehdr->e_shnum = 3; + + /* Register ELF header as first region */ + strscpy(elfregion.name, "KELF_HEADER", sizeof(elfregion.name)); + elfregion.virt_addr = md_data->elf.ehdr; + elfregion.phys_addr = virt_to_phys(md_data->elf.ehdr); + elfregion.size = elfh_size; + + return md_data->ops->md_region_register(md_data, &elfregion); +} + +/** + * qcom_minidump_backend_register() - Register backend minidump device. + * @md_data: minidump backend driver data + * + * Return: On success, it returns 0 and negative error value on failure. + */ +int qcom_minidump_backend_register(struct minidump *md_data) +{ + int ret; + + if (!md_data->name || !md_data->dev || + !md_data->ops || + !md_data->ops->md_table_init || + !md_data->ops->md_region_register || + !md_data->ops->md_region_unregister || + !md_data->ops->md_table_exit) { + pr_warn("backend '%s' must fill/implement necessary fields\n", md->name); + return -EINVAL; + } + + if (md_backend && strcmp(md_backend, md_data->name)) { + pr_warn("backend '%s' already in use: ignoring '%s'\n", + md_backend, md_data->name); + return -EBUSY; + } + + mutex_lock(&md_lock); + if (md) { + dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n", + md->name, md_data->name); + ret = -EBUSY; + goto unlock; + } + + if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES) + md_data->max_region_limit = MAX_NUM_ENTRIES; + + ret = md_data->ops->md_table_init(md_data); + if (ret) { + dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret); + goto unlock; + } + + /* First entry would be ELF header */ + ret = qcom_minidump_add_elf_header(md_data); + if (ret) { + dev_err(md_data->dev, "Failed to add elf header: %d\n", ret); + md_data->ops->md_table_exit(md_data); + goto unlock; + } + + md = md_data; + md_backend = kstrdup(md->name, GFP_KERNEL); + dev_info(md->dev, "Registered minidump backend : %s\n", md->name); + +unlock: + mutex_unlock(&md_lock); + return ret; +} +EXPORT_SYMBOL_GPL(qcom_minidump_backend_register); + +/** + * qcom_minidump_backend_unregister() - Unregister backend minidump device. + * @md_data: minidump backend driver data + */ +void qcom_minidump_backend_unregister(struct minidump *md_data) +{ + mutex_lock(&md_lock); + /* Only one backend can be registered at a time. */ + if (WARN_ON(md_data != md)) + goto unlock; + + dev_info(md_data->dev, "Unregistered %s as minidump backend\n", md_data->name); + md_data->ops->md_table_exit(md_data); + kfree(md_backend); + md_backend = NULL; + md = NULL; +unlock: + mutex_unlock(&md_lock); +} +EXPORT_SYMBOL_GPL(qcom_minidump_backend_unregister); + +MODULE_DESCRIPTION("Qualcomm minidump core"); +MODULE_LICENSE("GPL"); diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h new file mode 100644 index 000000000000..9031b1b0a046 --- /dev/null +++ b/drivers/soc/qcom/qcom_minidump_internal.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _QCOM_MINIDUMP_INTERNAL_H_ +#define _QCOM_MINIDUMP_INTERNAL_H_ + +#include +#include + +#define MAX_REGION_NAME_LENGTH 16 + +struct minidump; +/** + * struct minidump_ops - APSS Minidump operation structure, each underlying + * backend need to add their hooks to it. + * + * @md_table_init: Get the hold of APSS minidump table for the backend + * and initialize it with details. + * @md_table_exit: Clean up the stuff populated while md_table_init() + * @md_region_register: Callback to register the region at the backend. + * @md_region_unregister: Callback to unregister the region at the backend. + */ +struct minidump_ops { + int (*md_table_init)(struct minidump *md); + int (*md_table_exit)(struct minidump *md); + int (*md_region_register)(struct minidump *md, + const struct qcom_minidump_region *region); + int (*md_region_unregister)(struct minidump *md, + const struct qcom_minidump_region *region); +}; + +/** + * 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 - Qualcomm minidump core information + * @name : Minidump backend name + * @ops : set of callback need to be implemented + * @elf : Minidump elf header + * @dev : Minidump backend device + * @max_num_limit : Maximum number of region limit + * @apss_data : Backend driver's private data pointer + */ +struct minidump { + const char *name; + struct minidump_ops *ops; + struct minidump_elfhdr elf; + struct device *dev; + unsigned int max_region_limit; + void *apss_data; +}; + +#if IS_ENABLED(CONFIG_QCOM_MINIDUMP) +int qcom_minidump_backend_register(struct minidump *md); +void qcom_minidump_backend_unregister(struct minidump *md); +#else +int qcom_minidump_backend_register(struct minidump *md) { return 0; } +void qcom_minidump_backend_unregister(struct minidump *md) {} +#endif /* CONFIG_QCOM_MINIDUMP */ +#endif /* _QCOM_MINIDUMP_INTERNAL_H_ */ diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h index d7747c27fd45..d0bebc3daac5 100644 --- a/include/soc/qcom/qcom_minidump.h +++ b/include/soc/qcom/qcom_minidump.h @@ -1,11 +1,46 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* + * This file contains data structure which should be used by the + * APSS minidump clients. + * * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _QCOM_MINIDUMP_H_ #define _QCOM_MINIDUMP_H_ +#define MAX_NAME_LENGTH 12 +/** + * struct qcom_minidump_region - APSS 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) +int qcom_minidump_region_register(const struct qcom_minidump_region *region); +int qcom_minidump_region_unregister(const struct qcom_minidump_region *region); +#else +static inline int qcom_minidump_region_register(const struct qcom_minidump_region *region) +{ + /* Return quietly, if minidump is not enabled */ + return 0; +} +static inline int qcom_minidump_region_unregister(const struct qcom_minidump_region *region) +{ + return 0; +} +#endif /* CONFIG_QCOM_MINIDUMP */ + #if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM) void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt); int qcom_ss_valid_segment_info(void *ptr, int i, char **name, From patchwork Wed Jun 28 12:34:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8896064vqr; Wed, 28 Jun 2023 05:46:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GWrtJxNjFWQSnnFWr+6DtLUL0psc6ewSrvsyCWRhpoox2wM5sS/0+04ytb1xJfmrSLdUd X-Received: by 2002:a17:907:8a0c:b0:992:48b7:99e3 with SMTP id sc12-20020a1709078a0c00b0099248b799e3mr3154313ejc.63.1687956382595; Wed, 28 Jun 2023 05:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956382; cv=none; d=google.com; s=arc-20160816; b=oZUV0wEgS0STFzGXcbAhluKNIGGE+rw7IBHZWtf5LV93nZ9zQ8qqGOKj4ssN8mhrpT s4mQeIzsupaAZ98MpqZ0l0mXY+O7+J21ICM1vFH6U1V4xv3IJM33NQ/ymdHXXiBXvRWw vOeH5eP395uzZJoLmYk+5aQb96w5YaZtUrAGo7eoi0wt3lmfFw+RgJVjtModaL8dzJCD ud+TBUyml8oB5kSEnWtvNIMVnsp5p45wAUfHIDOoITM6k347E/m8ToRpoPDyq0y893E8 Kj6yyw8ZUz34oPJZp+oSBLO5/eWG2e1dSlRybH4gch1CjV0Id064+GrkErvMkNAgipXb p8jQ== 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=q7eMGPWHW8Qdlj/xARxpF3rf5Aw7Mja6chBsgEl+PdM=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=Q5vv0dNmInF4e9qZPpInd8tg8m33aJoaAzLRJBTYIGfCcIIDcALpwzaEboQFoT8DPJ QTioPVnQ70WkTJa59+M2RY+V1eF/ObKILcYdgqNAVzH/AZGvwBHWOHAwak9u2jgDX8Bl yOlG+Q8TkUqftQqY+gJyWVOS0LPiIf5qiyrW67Ra9WnjtmA0+GF9qQHn7GPJa3wHxS2A P1QZ+qR4XaGNIRfcC5cyOTp0/s9kerZ+5G6ojJocGdv2JgeATKHYAmcK635fboj6tr3P 1SCI+AwSyU8jYmMdLMViExzKT1p/nl70C5fxGlUAtc0juI4t0dDwQQQ/5pyGCf+fN6E0 aB5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Lwf88naV; 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-20020a170906590f00b00982cebc5042si5724278ejq.844.2023.06.28.05.45.58; Wed, 28 Jun 2023 05:46:22 -0700 (PDT) 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=Lwf88naV; 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 S231390AbjF1Mgn (ORCPT + 99 others); Wed, 28 Jun 2023 08:36:43 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:44466 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbjF1MgO (ORCPT ); Wed, 28 Jun 2023 08:36:14 -0400 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 35S5EVNh008250; Wed, 28 Jun 2023 12:35:51 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=q7eMGPWHW8Qdlj/xARxpF3rf5Aw7Mja6chBsgEl+PdM=; b=Lwf88naVZM9rqLg6zUWbsXtU/n4cPzhukm4YcQ4d2+8ehyZ8/UzLHDBmjCk0qQ3mFVIJ 87D1GTq1QzZHuij4+lksoZQooaLcJtq3KDezaVzDq5koUvTTgP6Auho2kr0GsA3jd2ng Nv7+uOtLN6KV/mvsNvdoazjGlFRtwC4r8ulwEO8jwbZCQjD9sm1aw07aWNJTdDub8bPv x6IQAsuPXXa3SmBoQNpHQm2+5ZvZKRIWUgb8i22Ge036Y8Esn2kDPPJWe/YHazOqt7a8 1O/hE7YWxrBlm4q9L9TjkngHlr5Y8QfnF3nbLAoJFDB+VUa+oS0Z3gpRRT/vFzZZXvVO zQ== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rg7x3sksv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:50 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCZnc5023752 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:49 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.42; Wed, 28 Jun 2023 05:35:42 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 05/21] soc: qcom: Add linux minidump smem backend driver support Date: Wed, 28 Jun 2023 18:04:32 +0530 Message-ID: <1687955688-20809-6-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: kVGVTzD2a7UtHGXgP73bXyhZaBJfOJMh X-Proofpoint-GUID: kVGVTzD2a7UtHGXgP73bXyhZaBJfOJMh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950551890318745?= X-GMAIL-MSGID: =?utf-8?q?1769950551890318745?= Add shared memory based minidump backend driver and hook it with minidump core (qcom_minidump) by registering SMEM as backend device. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/Kconfig | 8 +- drivers/soc/qcom/qcom_minidump_smem.c | 231 +++++++++++++++++++++++++++++++++- drivers/soc/qcom/smem.c | 9 ++ 3 files changed, 240 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 874ee8c3efe0..1834213fd652 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -298,8 +298,12 @@ config QCOM_MINIDUMP_SMEM tristate "QCOM Minidump SMEM (as backend) Support" depends on ARCH_QCOM depends on QCOM_SMEM + select QCOM_MINIDUMP help Enablement of core minidump feature is controlled from boot firmware - side, and this config allow linux to query minidump segments associated - with the remote processor and check its validity. + side, and this config allow linux to query and manages minidump + table for remote processors as well as APSS. + + This config should be enabled if the low level minidump is implemented + as part of SMEM. endmenu diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c index b588833ea26e..bdc75aa2f518 100644 --- a/drivers/soc/qcom/qcom_minidump_smem.c +++ b/drivers/soc/qcom/qcom_minidump_smem.c @@ -2,18 +2,34 @@ /* * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ +#include +#include +#include +#include +#include #include #include -#include +#include +#include #include -#include + +#include "qcom_minidump_internal.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) + +#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_START ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 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) + +#define MINIDUMP_APSS_DESC 0 /** * struct minidump_region - Minidump region @@ -64,6 +80,16 @@ struct minidump_global_toc { }; /** + * struct minidump_ss_data - Minidump subsystem private data + * @md_ss_toc : Application Subsystem TOC pointer + * @md_regions : Application Subsystem region base pointer + */ +struct minidump_ss_data { + struct minidump_subsystem *md_ss_toc; + struct minidump_region *md_regions; +}; + +/** * qcom_ss_md_mapped_base() - For getting subsystem iomapped base segment address * for given minidump index. * @@ -143,5 +169,198 @@ int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t *da, si } EXPORT_SYMBOL_GPL(qcom_ss_valid_segment_info); +static int smem_md_get_region_index(struct minidump_ss_data *mdss_data, + const struct qcom_minidump_region *region) +{ + struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc; + struct minidump_region *mdr; + unsigned int i; + unsigned int count; + + count = le32_to_cpu(mdss_toc->region_count); + for (i = 0; i < count; i++) { + mdr = &mdss_data->md_regions[i]; + if (!strcmp(mdr->name, region->name)) + return i; + } + + return -ENOENT; +} + +static void smem_md_add_region(struct minidump_ss_data *mdss_data, + const struct qcom_minidump_region *region) +{ + struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc; + struct minidump_region *mdr; + unsigned int region_cnt; + + region_cnt = le32_to_cpu(mdss_toc->region_count); + mdr = &mdss_data->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++; + mdss_toc->region_count = cpu_to_le32(region_cnt); +} + +static int smem_md_region_register(struct minidump *md, + const struct qcom_minidump_region *region) +{ + struct minidump_ss_data *mdss_data = md->apss_data; + struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc; + unsigned int num_region; + int ret; + + ret = smem_md_get_region_index(mdss_data, region); + if (ret >= 0) { + dev_info(md->dev, "%s region is already registered\n", region->name); + return -EEXIST; + } + + /* Check if there is a room for a new entry */ + num_region = le32_to_cpu(mdss_toc->region_count); + if (num_region >= md->max_region_limit) { + dev_err(md->dev, "maximum region limit %u reached\n", num_region); + return -ENOSPC; + } + + smem_md_add_region(mdss_data, region); + + return 0; +} + +static int smem_md_region_unregister(struct minidump *md, + const struct qcom_minidump_region *region) +{ + struct minidump_ss_data *mdss_data = md->apss_data; + struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc; + struct minidump_region *mdr; + unsigned int region_cnt; + unsigned int idx; + int ret; + + ret = smem_md_get_region_index(mdss_data, region); + if (ret < 0) { + dev_err(md->dev, "%s region is not present\n", region->name); + return ret; + } + + idx = ret; + mdr = &mdss_data->md_regions[0]; + region_cnt = le32_to_cpu(mdss_toc->region_count); + /* + * Left shift all the regions exist after this removed region + * index by 1 to fill the gap and zero out the last region + * present at the end. + */ + memmove(&mdr[idx], &mdr[idx + 1], + (region_cnt - idx - 1) * sizeof(struct minidump_region)); + memset(&mdr[region_cnt - 1], 0, sizeof(struct minidump_region)); + region_cnt--; + mdss_toc->region_count = cpu_to_le32(region_cnt); + + return 0; +} + +static int smem_md_table_init(struct minidump *md) +{ + struct minidump_global_toc *mdgtoc; + struct minidump_ss_data *mdss_data; + struct minidump_subsystem *mdss_toc; + size_t size; + int ret; + + mdgtoc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size); + if (IS_ERR(mdgtoc)) { + ret = PTR_ERR(mdgtoc); + dev_err(md->dev, "Couldn't find minidump smem item: %d\n", ret); + return ret; + } + + if (size < sizeof(mdgtoc) || !mdgtoc->status) { + ret = -EINVAL; + dev_err(md->dev, "minidump table is not initialized: %d\n", ret); + return ret; + } + + mdss_data = devm_kzalloc(md->dev, sizeof(*mdss_data), GFP_KERNEL); + if (!mdss_data) + return -ENOMEM; + + mdss_data->md_ss_toc = &mdgtoc->subsystems[MINIDUMP_APSS_DESC]; + mdss_data->md_regions = devm_kcalloc(md->dev, md->max_region_limit, + sizeof(struct minidump_region), GFP_KERNEL); + if (!mdss_data->md_regions) + return -ENOMEM; + + mdss_toc = mdss_data->md_ss_toc; + mdss_toc->regions_baseptr = cpu_to_le64(virt_to_phys(mdss_data->md_regions)); + mdss_toc->enabled = cpu_to_le32(MINIDUMP_SS_ENABLED); + mdss_toc->status = cpu_to_le32(1); + mdss_toc->region_count = cpu_to_le32(0); + + /* Tell bootloader not to encrypt the regions of this subsystem */ + mdss_toc->encryption_status = cpu_to_le32(MINIDUMP_SS_ENCR_DONE); + mdss_toc->encryption_required = cpu_to_le32(MINIDUMP_SS_ENCR_NOTREQ); + md->apss_data = mdss_data; + + return 0; +} + +static int smem_md_table_exit(struct minidump *md) +{ + struct minidump_ss_data *mdss_data; + + mdss_data = md->apss_data; + memset(mdss_data->md_ss_toc, + cpu_to_le32(0), sizeof(struct minidump_subsystem)); + + return 0; +} + +static struct minidump_ops smem_md_ops = { + .md_table_init = smem_md_table_init, + .md_table_exit = smem_md_table_exit, + .md_region_register = smem_md_region_register, + .md_region_unregister = smem_md_region_unregister, +}; + +static int qcom_minidump_smem_probe(struct platform_device *pdev) +{ + struct minidump *md; + + md = devm_kzalloc(&pdev->dev, sizeof(*md), GFP_KERNEL); + if (!md) + return -ENOMEM; + + md->dev = &pdev->dev; + md->ops = &smem_md_ops; + md->name = "smem"; + platform_set_drvdata(pdev, md); + + return qcom_minidump_backend_register(md); +} + +static int qcom_minidump_smem_remove(struct platform_device *pdev) +{ + struct minidump *md = platform_get_drvdata(pdev); + + qcom_minidump_backend_unregister(md); + + return 0; +} + +static struct platform_driver qcom_minidump_smem_driver = { + .probe = qcom_minidump_smem_probe, + .remove = qcom_minidump_smem_remove, + .driver = { + .name = "qcom-minidump-smem", + }, +}; + +module_platform_driver(qcom_minidump_smem_driver); + MODULE_DESCRIPTION("Qualcomm Minidump SMEM as backend driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:qcom-minidump-smem"); diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 6be7ea93c78c..af582aa7f9a3 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -269,6 +269,7 @@ struct smem_region { * @partitions: list of partitions of current processor/host * @item_count: max accepted item number * @socinfo: platform device pointer + * @minidump: minidump platform device pointer * @num_regions: number of @regions * @regions: list of the memory regions defining the shared memory */ @@ -279,6 +280,7 @@ struct qcom_smem { u32 item_count; struct platform_device *socinfo; + struct platform_device *minidump; struct smem_ptable *ptable; struct smem_partition global_partition; struct smem_partition partitions[SMEM_HOST_COUNT]; @@ -1151,11 +1153,18 @@ static int qcom_smem_probe(struct platform_device *pdev) if (IS_ERR(smem->socinfo)) dev_dbg(&pdev->dev, "failed to register socinfo device\n"); + smem->minidump = platform_device_register_data(&pdev->dev, "qcom-minidump-smem", + PLATFORM_DEVID_NONE, NULL, + 0); + if (IS_ERR(smem->minidump)) + dev_dbg(&pdev->dev, "failed to register minidump device\n"); + return 0; } static int qcom_smem_remove(struct platform_device *pdev) { + platform_device_unregister(__smem->minidump); platform_device_unregister(__smem->socinfo); hwspin_lock_free(__smem->hwlock); From patchwork Wed Jun 28 12:34:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8891785vqr; Wed, 28 Jun 2023 05:38:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LSAhB85UoJB5bRU2D663uzcprWwSxBwMPkRHKAPj1PDC8WH9KZoy0g0PMBkOMBEqulJrv X-Received: by 2002:a17:907:60d4:b0:988:a986:b11c with SMTP id hv20-20020a17090760d400b00988a986b11cmr21571180ejc.29.1687955932189; Wed, 28 Jun 2023 05:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687955932; cv=none; d=google.com; s=arc-20160816; b=J7cULTy7fzqnpr9Iip4ZNFPbiC9GQ8PnQRkGiYBq18S+/hYN7KFBwImhk27PdmJF2g Mfw1YbYKbUfsrJPbkhfk0Uz2In24nVUNlneEn+sQkHttCK5YHrfz6wfA47h4qtneGbUG prBXW8SBdlZ2oIdGvz9nMwMVsIZ6iSMLwNgfuj59G6gKWb8OZJFjmjz73mM9uJN40zfx I7CRv7vIQDcHI1mx/n0Cxx2DW/EQltXr7D672B0XMlW0Dk0ImD9WfQcbOpx/letCGTZt ZU3vH8UcEMnW7AQ8DKfz13+i9ZzOEWt2diqibzUpuhkG3qmsmGfuoLTB9G/8Q31Dt/r5 Msaw== 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=tS6lGkX8CHBycfdhWdiPwgr8+XHLSbQNBox00mN4HUE=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=KS56/QxtNvNgmwPRIbakclTwSKciF8ThonuTZ4h3CQeWf6UnTHnnRbSGLmkI3oV3s0 B4haszxGkqzl58Sj1hvdcMKC1PylS95cLRiaf3+HBToWL1K9B9j+AvTc7VcLhoti0SKf 0wht1gN4VgTBeO/+3HIexF3urw4NoGvRndxwb62icqewMkPu0S+sCdVFibC44q/wDiOo HhKe7nJ7U0umcKYoT2GbQ5otn8jF1clq0D/Bomg+tv8WTdERSlRdRtw0a06gpraRa3nH Q9c4S8fXKlNod9tmzpX0v34Dd+d9W1EBV2GrT7gXmRtC3w/wmZwU/eWw7s+ahunFuGuP tC+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NW1gxG4w; 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 i15-20020a170906850f00b00973a7283de2si5471635ejx.505.2023.06.28.05.38.28; Wed, 28 Jun 2023 05:38:52 -0700 (PDT) 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=NW1gxG4w; 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 S230445AbjF1Mgr (ORCPT + 99 others); Wed, 28 Jun 2023 08:36:47 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:45604 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjF1MgQ (ORCPT ); Wed, 28 Jun 2023 08:36:16 -0400 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35S9nKm9003322; Wed, 28 Jun 2023 12:35:57 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=tS6lGkX8CHBycfdhWdiPwgr8+XHLSbQNBox00mN4HUE=; b=NW1gxG4wdwB9zb7phKTlbtE9dXGtJywK9EsSLPiHVS6Xfe6Zv4fnVOGZifwagqncS35k K8mUvEtPLQVGYKPRzKk3KySiTvZluAvPP+r44P6kgiP6tIKIOwbEIC6IxtWOGsUc0JNW c82V7+kpdlb9q7kVoa7L/GuyP3XXT6qXf5o8llyJLXfOYShkNgZey7kCKe21QZEz6kFu S9Bwx0e195ZZ2XEU1llwL5pgB0IyPJaTwGZW2Qafymff8pH67pgFGX6ts1sVVSkMEfNO fAk82ps+QH//S+nE2gs0+h7kyB6uUfeVw0v+zBhUoyFW/4dUowHimz0PU/Rv8qGMro2n Fg== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rg9pb1ese-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:57 +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 35SCZuhK029721 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:35:56 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.42; Wed, 28 Jun 2023 05:35:49 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 06/21] soc: qcom: minidump: Add pending region registration support Date: Wed, 28 Jun 2023 18:04:33 +0530 Message-ID: <1687955688-20809-7-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: n2xHEv_GvbGRgwFkrml1q7DhTpJMKIKO X-Proofpoint-ORIG-GUID: n2xHEv_GvbGRgwFkrml1q7DhTpJMKIKO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950079664203891?= X-GMAIL-MSGID: =?utf-8?q?1769950079664203891?= Pending regions are those apss minidump regions which came for registration before minidump was initialized or ready to do register the region. We can add regions to pending region list and register them from apss minidump driver probe in one go. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/qcom_minidump.c | 87 ++++++++++++++++++++++++++++--- drivers/soc/qcom/qcom_minidump_internal.h | 20 +++++++ 2 files changed, 99 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c index 7744e57843ab..cfdb63cc29d6 100644 --- a/drivers/soc/qcom/qcom_minidump.c +++ b/drivers/soc/qcom/qcom_minidump.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,10 @@ static DEFINE_MUTEX(md_lock); /* Only one front end will be attached to one back-end */ static struct minidump *md; static char *md_backend; +static struct minidump_plist md_plist = { + .plist = LIST_HEAD_INIT(md_plist.plist), + .pregion_cnt = 0, +}; static struct elf_shdr *elf_shdr_entry_addr(struct elfhdr *ehdr, int idx) { @@ -201,6 +206,26 @@ static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region IS_ALIGNED(region->size, 4); } +static struct minidump_pregion * +check_if_pending_region_exist(const struct qcom_minidump_region *region) +{ + struct minidump_pregion *md_pregion; + struct minidump_pregion *tmp; + bool found = false; + + list_for_each_entry_safe(md_pregion, tmp, &md_plist.plist, list) { + struct qcom_minidump_region *md_region; + + md_region = &md_pregion->region; + if (!strcmp(md_region->name, region->name)) { + found = true; + break; + } + } + + return found ? md_pregion : NULL; +} + /** * qcom_minidump_region_register() - Register region in APSS Minidump table. * @region: minidump region. @@ -209,16 +234,40 @@ static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region */ int qcom_minidump_region_register(const struct qcom_minidump_region *region) { - int ret; + struct minidump_pregion *md_pregion; + int ret = 0; if (!qcom_minidump_valid_region(region)) return -EINVAL; mutex_lock(&md_lock); if (!md) { - mutex_unlock(&md_lock); - pr_err("No backend registered yet, try again.."); - return -EPROBE_DEFER; + if (md_plist.pregion_cnt >= MAX_NUM_ENTRIES - 1) { + pr_err("maximum region limit %u reached\n", md_plist.pregion_cnt); + ret = -ENOSPC; + goto unlock; + } + + md_pregion = check_if_pending_region_exist(region); + if (md_pregion) { + pr_info("%s region is already exist\n", region->name); + ret = -EEXIST; + goto unlock; + } + /* + * Maintain a list of client regions which came before + * minidump driver was ready and once it is ready, + * register them in one go from minidump probe function. + */ + md_pregion = kzalloc(sizeof(*md_pregion), GFP_KERNEL); + if (!md_pregion) { + ret = -ENOMEM; + goto unlock; + } + md_pregion->region = *region; + list_add_tail(&md_pregion->list, &md_plist.plist); + md_plist.pregion_cnt++; + goto unlock; } ret = md->ops->md_region_register(md, region); @@ -240,16 +289,22 @@ EXPORT_SYMBOL_GPL(qcom_minidump_region_register); */ int qcom_minidump_region_unregister(const struct qcom_minidump_region *region) { - int ret; + struct minidump_pregion *md_pregion; + int ret = 0; if (!qcom_minidump_valid_region(region)) return -EINVAL; mutex_lock(&md_lock); if (!md) { - mutex_unlock(&md_lock); - pr_err("No backend registered yet, try again.."); - return -EPROBE_DEFER; + md_pregion = check_if_pending_region_exist(region); + if (!md_pregion) + goto unlock; + + list_del(&md_pregion->list); + kfree(md_pregion); + md_plist.pregion_cnt--; + goto unlock; } ret = md->ops->md_region_unregister(md, region); @@ -378,6 +433,8 @@ static int qcom_minidump_add_elf_header(struct minidump *md_data) */ int qcom_minidump_backend_register(struct minidump *md_data) { + struct minidump_pregion *md_pregion; + struct minidump_pregion *tmp; int ret; if (!md_data->name || !md_data->dev || @@ -425,6 +482,20 @@ int qcom_minidump_backend_register(struct minidump *md_data) md_backend = kstrdup(md->name, GFP_KERNEL); dev_info(md->dev, "Registered minidump backend : %s\n", md->name); + list_for_each_entry_safe(md_pregion, tmp, &md_plist.plist, list) { + struct qcom_minidump_region *region; + + region = &md_pregion->region; + ret = md->ops->md_region_register(md, region); + if (ret) + goto unlock; + + qcom_md_update_elf_header(region); + list_del(&md_pregion->list); + kfree(md_pregion); + md_plist.pregion_cnt--; + } + unlock: mutex_unlock(&md_lock); return ret; diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h index 9031b1b0a046..6993e3be10c2 100644 --- a/drivers/soc/qcom/qcom_minidump_internal.h +++ b/drivers/soc/qcom/qcom_minidump_internal.h @@ -65,6 +65,26 @@ struct minidump { void *apss_data; }; +/** + * struct minidump_pregion - Minidump pending region + * @list : Pending region list pointer + * @region : APSS minidump client region + */ +struct minidump_pregion { + struct list_head list; + struct qcom_minidump_region region; +}; + +/** + * struct minidump_plist - Minidump pending region list + * @plist : List of pending region to be registered + * @pregion_cnt : Count of the pending region to be registered + */ +struct minidump_plist { + struct list_head plist; + int pregion_cnt; +}; + #if IS_ENABLED(CONFIG_QCOM_MINIDUMP) int qcom_minidump_backend_register(struct minidump *md); void qcom_minidump_backend_unregister(struct minidump *md); From patchwork Wed Jun 28 12:34:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8897823vqr; Wed, 28 Jun 2023 05:49:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56CkBh6pCHbjslXnO1f60EIuB1Fciq4KJkCzP1VEvXlGpU+oMZwApyaVGQJUjY33BrLg+V X-Received: by 2002:a17:906:4fc5:b0:982:82aa:86b1 with SMTP id i5-20020a1709064fc500b0098282aa86b1mr27564905ejw.43.1687956576913; Wed, 28 Jun 2023 05:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956576; cv=none; d=google.com; s=arc-20160816; b=NpUXbr9Tlbv5JcsGH1l0ceWPa/UzGpNahafCRVsyKakKcts/dGbt9G7iV1xAsiBuyX CJBylesvlv4q7jHyZ93cRj5aGBMnG5yFX+P0V7y/vyr5ACJgiT2IjRF6ON+sLDkbcCOH UjM/bgQ0WDL/7KElvtWZ5MZNbsXqfMfW7Aag4bQE8Ud4Fe5HdfDRrJpv+J5sSoFcoEMp zgM4p85n3lGM37/dOjOpVvSwVSXLkaTqdnAfwKxKNxDoQjOoVR8dLI+dxN97LS7U20gV Y5D5DDxm8NnqJ/FbTlgQu57uH0FLNmICpAR4fqK/4fGSUVzeIFDAZzpZoBnE73Kbx2in NX/g== 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=zUyJ/QKLk3qWrZpElgacmwy8J+Ca7776duwwY9ZJ+Hw=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=qCOmTVHW87QBXTYofTCHli2axocFKkWFeDKsN6/gan8m7W96P/gPFZRtFLCDRGnn5t TP0FCU8sZzgbZmBQeL3YLJaQ94L1i/Kvwu98tjowWNQpaQRb1tXzlZxU2Bp/QOchPN+w DYxyypZudY/sBHeq+aZ0SOdfRz9phDj0/bHgPLtY0+NSYYkqUb8D0wgCl9susD+hnI9n 2R77NQt8m74y35uBw52c35G1Nyt4U+B7eJJzm/OdSIS2EbbbZ494m74uoNEclcc/Lqwr +M8C9csVTAF/dEr2323fSSUi4HuQWfd4es/51jf8m4gxR7doH4PabS9Mt8T0+VXCuRA4 JvRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=F5PuK+eA; 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 bx13-20020a170906a1cd00b00982733d446csi5711728ejb.410.2023.06.28.05.49.13; Wed, 28 Jun 2023 05:49:36 -0700 (PDT) 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=F5PuK+eA; 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 S232198AbjF1Mhy (ORCPT + 99 others); Wed, 28 Jun 2023 08:37:54 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:62976 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbjF1Mgg (ORCPT ); Wed, 28 Jun 2023 08:36:36 -0400 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 35S7R01b029236; Wed, 28 Jun 2023 12:36:04 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=zUyJ/QKLk3qWrZpElgacmwy8J+Ca7776duwwY9ZJ+Hw=; b=F5PuK+eAdFLoh1DqWB6Yi76yJ4s+iW4IO3VfeaiPetFSuyNl8kZPT8QKbRbBe1u+fcZX CtNkwzW9uZrAE0ljfr/OINZF4aXt0aXmiSSGVTaO/Q+khiCqmFauwbprp0zXELhtfaOM 0EpVNRoAFprjW1jGInhcUu78LOnSZQB6oCbH3IDcuwizKwtekAcdVLk5S+uo2yjFOTnF pyGfuoiceFokYEjz3IMKbsCKYiCwDz3ayOY7++F9UlKgsodTn9Za20S9cZCj8Xk9SIUz pNL/3rzqklxf/5lGlv75zI4XB/QkFZZp2HOYJQNqhYih6UrVk832+Do7rajOZIwM3dzr 1Q== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgbfss8dn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:04 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCa3Ee024026 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:03 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.42; Wed, 28 Jun 2023 05:35:56 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 07/21] soc: qcom: minidump: Add update region support Date: Wed, 28 Jun 2023 18:04:34 +0530 Message-ID: <1687955688-20809-8-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: pJ9iiLd8x4SKlSEio83461EBkiGyS2qz X-Proofpoint-ORIG-GUID: pJ9iiLd8x4SKlSEio83461EBkiGyS2qz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950755829794220?= X-GMAIL-MSGID: =?utf-8?q?1769950755829794220?= Add support to update client's region physical/virtual addresses, which is useful for dynamic loadable modules, dynamic address changing clients like if we want to collect current stack information for each core and the current stack is changing on each sched_switch event, So here virtual/physical address of the current stack is changing. So, to cover such use cases add the update region support in minidump driver and the corresponding smem backend support. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/qcom_minidump.c | 55 +++++++++++++++++++++++++++++++ drivers/soc/qcom/qcom_minidump_internal.h | 3 ++ drivers/soc/qcom/qcom_minidump_smem.c | 21 ++++++++++++ include/soc/qcom/qcom_minidump.h | 5 +++ 4 files changed, 84 insertions(+) diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c index cfdb63cc29d6..37d6ceb4d85c 100644 --- a/drivers/soc/qcom/qcom_minidump.c +++ b/drivers/soc/qcom/qcom_minidump.c @@ -318,6 +318,61 @@ int qcom_minidump_region_unregister(const struct qcom_minidump_region *region) } EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister); +/** + * qcom_minidump_update_region() - Update region information with new physical + * address and virtual address for already registered region e.g, current task + * stack for a core keeps on changing on each context switch, there it needs to + * change registered region with new updated addresses. + * + * @region: Should be already registered minidump region. + * + * Return: On success, it returns 0 and negative error value on failure. + */ +int qcom_minidump_update_region(const struct qcom_minidump_region *region) +{ + struct minidump_pregion *md_pregion; + struct qcom_minidump_region *tmp; + struct elfhdr *ehdr; + struct elf_shdr *shdr; + struct elf_phdr *phdr; + int idx; + int ret = 0; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md_lock); + if (!md) { + md_pregion = check_if_pending_region_exist(region); + if (!md_pregion) { + ret = -ENOENT; + goto unlock; + } + tmp = &md_pregion->region; + tmp->phys_addr = region->phys_addr; + tmp->virt_addr = region->virt_addr; + goto unlock; + } + + ret = md->ops->md_update_region(md, &idx, region); + if (ret) + goto unlock; + + /* Skip predefined shdr/phdr header entry at the start */ + ehdr = md->elf.ehdr; + shdr = elf_shdr_entry_addr(ehdr, idx + 4); + phdr = elf_phdr_entry_addr(ehdr, idx + 1); + + shdr->sh_addr = (elf_addr_t)region->virt_addr; + phdr->p_vaddr = (elf_addr_t)region->virt_addr; + phdr->p_paddr = region->phys_addr; + +unlock: + mutex_unlock(&md_lock); + return ret; +} +EXPORT_SYMBOL_GPL(qcom_minidump_update_region); + static int qcom_minidump_add_elf_header(struct minidump *md_data) { struct qcom_minidump_region elfregion; diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h index 6993e3be10c2..dc1e76c1f063 100644 --- a/drivers/soc/qcom/qcom_minidump_internal.h +++ b/drivers/soc/qcom/qcom_minidump_internal.h @@ -21,6 +21,7 @@ struct minidump; * @md_table_exit: Clean up the stuff populated while md_table_init() * @md_region_register: Callback to register the region at the backend. * @md_region_unregister: Callback to unregister the region at the backend. + * @md_update_region: Callback to update address of already registered regions. */ struct minidump_ops { int (*md_table_init)(struct minidump *md); @@ -29,6 +30,8 @@ struct minidump_ops { const struct qcom_minidump_region *region); int (*md_region_unregister)(struct minidump *md, const struct qcom_minidump_region *region); + int (*md_update_region)(struct minidump *md, int *idx, + const struct qcom_minidump_region *region); }; /** diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c index bdc75aa2f518..9d4021a5e4c8 100644 --- a/drivers/soc/qcom/qcom_minidump_smem.c +++ b/drivers/soc/qcom/qcom_minidump_smem.c @@ -263,6 +263,26 @@ static int smem_md_region_unregister(struct minidump *md, return 0; } +static int smem_md_update_region(struct minidump *md, int *idx, + const struct qcom_minidump_region *region) +{ + struct minidump_ss_data *mdss_data = md->apss_data; + struct minidump_region *mdr; + int ret; + + ret = smem_md_get_region_index(mdss_data, region); + if (ret < 0) { + dev_err(md->dev, "%s region is not present\n", region->name); + return ret; + } + + *idx = ret; + mdr = &mdss_data->md_regions[*idx]; + mdr->address = cpu_to_le64(region->phys_addr); + + return 0; +} + static int smem_md_table_init(struct minidump *md) { struct minidump_global_toc *mdgtoc; @@ -324,6 +344,7 @@ static struct minidump_ops smem_md_ops = { .md_table_exit = smem_md_table_exit, .md_region_register = smem_md_region_register, .md_region_unregister = smem_md_region_unregister, + .md_update_region = smem_md_update_region, }; static int qcom_minidump_smem_probe(struct platform_device *pdev) diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h index d0bebc3daac5..a86b0313698f 100644 --- a/include/soc/qcom/qcom_minidump.h +++ b/include/soc/qcom/qcom_minidump.h @@ -29,6 +29,7 @@ struct qcom_minidump_region { #if IS_ENABLED(CONFIG_QCOM_MINIDUMP) int qcom_minidump_region_register(const struct qcom_minidump_region *region); int qcom_minidump_region_unregister(const struct qcom_minidump_region *region); +int qcom_minidump_update_region(const struct qcom_minidump_region *region); #else static inline int qcom_minidump_region_register(const struct qcom_minidump_region *region) { @@ -39,6 +40,10 @@ static inline int qcom_minidump_region_unregister(const struct qcom_minidump_reg { return 0; } +static inline int qcom_minidump_update_region(const struct qcom_minidump_region *region) +{ + return 0; +} #endif /* CONFIG_QCOM_MINIDUMP */ #if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM) From patchwork Wed Jun 28 12:34:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8897272vqr; Wed, 28 Jun 2023 05:48:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hWFsT8RIRotn3Y+EPM5L5HK9vFtTC2AlnbWp946ySrW2GsN1F4J5yfhxnfkUsgP91XJCv X-Received: by 2002:a05:6402:3c3:b0:51d:d4de:bcce with SMTP id t3-20020a05640203c300b0051dd4debccemr182609edw.15.1687956511671; Wed, 28 Jun 2023 05:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956511; cv=none; d=google.com; s=arc-20160816; b=saMikHrwcN4tG2NoUS2njyRmLzMhtqdcHx8g/t7hk/Gkn9wDPlvlnAI8erP8Ljx+3W vctBsX3Vj7xIAkefHci/uwLb5Ah7VJ5rto/QJCvpyLni1RMAF+ZGaWYt3jcfy+6nJ8Y6 kPMIqnumfj6CCekRqKxzk54S1sOD3UTJOZgd6Nz3nhfrdum2DYAFPdIj7o6LP6jdIX6V jbRN9b1PvJinEPSRpu4+y2eaYvoYz6g+4Dszr/VyrAFS7ih05nvnH6LOm+Q5GpvaUo4W y64pCr3bJb/E031h4BaWZNj4u/8pYmJT8/1aNQfQJX+e5Bh/dABphGDU4om+fBX5c4GH 5DFA== 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=vKhd0hCzjKWECoQ8ex5R8NLhg6eW+IOM7kKZ7L7MqSE=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=fcu1kQrZIGyHF6LxNFcV6OP1S7/c1Jz+wQyPex3LwGst/EfHyLPNLmjBC77q0Pe4gw GqBoC2yB2VPjYTYhc7ZqKQ0k1tl2UBo1172UYdLGq9gv95OnNBkdEvSHAxElmx//D4bX 8s7qp6o4r7Xi3Tg5aCuYPeFDIGCeBiaAos92RMF6aKcBUW/DymU04FzCeSRlnSXV5eKy CcomXGxNed5RnlJJj3I3pP7jhzJfh+ZHy0CRooiSd23WlNQmp8z9ATrYqs6PFs1f94CP xH0KDqiZ3WCkx4YEUIJXYyMMVBk9P7rc789zgCpI/rmbjE+vg7u/gG3n08Y0rilDcg/L zT8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Zs1EZfc8; 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 w5-20020a056402128500b0051bfa4a927esi5080401edv.472.2023.06.28.05.48.07; Wed, 28 Jun 2023 05:48:31 -0700 (PDT) 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=Zs1EZfc8; 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 S232277AbjF1MiJ (ORCPT + 99 others); Wed, 28 Jun 2023 08:38:09 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:63262 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbjF1Mgg (ORCPT ); Wed, 28 Jun 2023 08:36:36 -0400 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SCTrlE025858; Wed, 28 Jun 2023 12:36:11 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=vKhd0hCzjKWECoQ8ex5R8NLhg6eW+IOM7kKZ7L7MqSE=; b=Zs1EZfc8tYL6+zA4HDFM8a8S284LoYDJvhhSmynmVoQAfG4HWIv+KZwfW8hpkt2jsw4e B2i6O96FrkdplsKWQFsMJ4fRVkMyinJhg/koZt4xvcoOLwQjLbloWUs6yL/ASZQlpju9 2lWsOkgaTQ9ILaoBtIr5l98ED2jXjiUa273i+7ZkX9+W1+fTZQH1i0OgfqAbJ8AxGX0I t6v+lSgJ065vd2YqiZr/exXhPUo94+6zwMVoZXdPTWY+i3boR/OwQ7xuPasu+GKkwbkA c2XUJSKjaEtL4JwtwrCRSnrFpjjJwf+fJlFD+Kzcj6g9qyjO/ecY/OJNsmPD6iiwipMN XQ== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rg9pb1esy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:10 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCa9Mb024209 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:09 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.42; Wed, 28 Jun 2023 05:36:03 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding Date: Wed, 28 Jun 2023 18:04:35 +0530 Message-ID: <1687955688-20809-9-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: lMrIh8eaOsYycp--0WBftOdLtQt8YtVb X-Proofpoint-ORIG-GUID: lMrIh8eaOsYycp--0WBftOdLtQt8YtVb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950687140601499?= X-GMAIL-MSGID: =?utf-8?q?1769950687140601499?= Qualcomm ramoops minidump logger provide a means of storing the ramoops data to some dynamically reserved memory instead of traditionally implemented ramoops where the region should be statically fixed ram region. Its device tree binding would be exactly same as ramoops device tree binding and is going to contain traditional ramoops frontend data and this content will be collected via Qualcomm minidump infrastructure provided from the boot firmware. Signed-off-by: Mukesh Ojha --- .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml new file mode 100644 index 000000000000..b1fdcf3f8ad4 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml @@ -0,0 +1,126 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm Ramoops minidump logger + +description: | + Qualcomm ramoops minidump logger provide a means of storing the ramoops + data to some dynamically reserved memory instead of traditionally + implemented ramoops where the region should be statically fixed ram + region. Because of its similarity with ramoops it will also have same + set of property what ramoops have it in its schema and is going to + contain traditional ramoops frontend data and this region will be + collected via Qualcomm minidump infrastructure provided from the + boot firmware. + +maintainers: + - Mukesh Ojha + +properties: + compatible: + items: + - enum: + - qcom,sm8450-ramoops + - const: qcom,ramoops + + memory-region: + maxItems: 1 + description: handle to memory reservation for qcom,ramoops region. + + ecc-size: + $ref: /schemas/types.yaml#/definitions/uint32 + description: enables ECC support and specifies ECC buffer size in bytes + default: 0 # no ECC + + record-size: + $ref: /schemas/types.yaml#/definitions/uint32 + description: maximum size in bytes of each kmsg dump + default: 0 + + console-size: + $ref: /schemas/types.yaml#/definitions/uint32 + description: size in bytes of log buffer reserved for kernel messages + default: 0 + + ftrace-size: + $ref: /schemas/types.yaml#/definitions/uint32 + description: size in bytes of log buffer reserved for function tracing and profiling + default: 0 + + pmsg-size: + $ref: /schemas/types.yaml#/definitions/uint32 + description: size in bytes of log buffer reserved for userspace messages + default: 0 + + mem-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: if present, sets the type of mapping is to be used to map the reserved region. + default: 0 + oneOf: + - const: 0 + description: write-combined + - const: 1 + description: unbuffered + - const: 2 + description: cached + + max-reason: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 2 # log oopses and panics + maximum: 0x7fffffff + description: | + If present, sets maximum type of kmsg dump reasons to store. + This can be set to INT_MAX to store all kmsg dumps. + See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values. + Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be + controlled by the printk.always_kmsg_dump boot param. + If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX). + + flags: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0 + description: | + If present, pass ramoops behavioral flags + (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values). + + no-dump-oops: + deprecated: true + type: boolean + description: | + Use max_reason instead. If present, and max_reason is not specified, + it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC). + + unbuffered: + deprecated: true + type: boolean + description: | + Use mem_type instead. If present, and mem_type is not specified, + it is equivalent to mem_type = 1 and uses unbuffered mappings to map + the reserved region (defaults to buffered mappings mem_type = 0). + If both are specified -- "mem_type" overrides "unbuffered". + +unevaluatedProperties: false + +required: + - compatible + - memory-region + +anyOf: + - required: [record-size] + - required: [console-size] + - required: [ftrace-size] + - required: [pmsg-size] + +examples: + - | + + qcom_ramoops { + compatible = "qcom,sm8450-ramoops", "qcom,ramoops"; + memory-region = <&qcom_ramoops_region>; + console-size = <0x8000>; /* 32kB */ + record-size = <0x400>; /* 1kB */ + ecc-size = <16>; + }; From patchwork Wed Jun 28 12:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8892316vqr; Wed, 28 Jun 2023 05:39:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5kjMHt8im8+m2SpkGClNzLidGFhtpz97blhZSuXBkjSqqHyq0KG6GI/kTc6hJZCseJE5sf X-Received: by 2002:aa7:d51a:0:b0:51a:4451:564d with SMTP id y26-20020aa7d51a000000b0051a4451564dmr1226987edq.18.1687955991382; Wed, 28 Jun 2023 05:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687955991; cv=none; d=google.com; s=arc-20160816; b=jsV6JmKYts+bEhKSaL0wIhXk69FYTlvjt4/BBBiRfO21rEESbTw3BDStEmkbYvn7iA 4bdPxjbpyIG1S8gmInyLiDaHDTYwd/mbD6vBnM8DIDYKtSE4C2U50d5hNgsYsVSDU5+q Y8tgIl75iOX1a+dwRoCYWeXqSWm5CB9fIUORgE4ybA3nXFHAjoixizWsjh3b4YsrCd9I dNdcoSVMPrgowPfMKvLMclhdQlyD29G8U5dt66400D5dnpySYD4yTqbiEitkkM6dcZjI R7AmNrZ/zdk0BrbmVNgzfFMinUJaiQuP4cf+b+8jOOaJ/hqfgYf8J9ThsZ4dtRFfeB8p ZZwQ== 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=P2QBL+7zGMKDj1s/OV57kLVSn1SCcUja5763zLo1cZM=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=J+592yihSxc+GGSD7d8P7PL/Ei7/W9WgSuUmlpnuZeVQp+yReH5UkuxvLBeHRYE+Ew 2//G1yUyupbnJtzyZOHrAx+2ZJanr9EIGhyQAPtv7BpCu9yJqjJ2Sp4kHKMlZmiDDwZ1 cRw/V5dygMiMAJ8ibWx7vUi67EjUJVjToQHqSXIduROJyv4UgqWwHQoHNPfu0SwVAx9J gAOzBZ4nqHDFychvjKWnJ+Idz86KKM0od+FDdRjoVCmXjBoDETRGcR5O/5/Lb7I312pH zXuoz52cO6HCk59BbHalMxkkpGH2xSBBUfE7Im7RScC4OnOW+mOPS8YfNehht3Ig6PYn zgfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=d9tPUeWH; 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 b17-20020aa7d491000000b0051d88350109si4950749edr.328.2023.06.28.05.39.26; Wed, 28 Jun 2023 05:39:51 -0700 (PDT) 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=d9tPUeWH; 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 S232227AbjF1MiA (ORCPT + 99 others); Wed, 28 Jun 2023 08:38:00 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:63716 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231821AbjF1Mgg (ORCPT ); Wed, 28 Jun 2023 08:36:36 -0400 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 35SB2tG3012176; Wed, 28 Jun 2023 12:36:18 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=P2QBL+7zGMKDj1s/OV57kLVSn1SCcUja5763zLo1cZM=; b=d9tPUeWHLHRKTfxZHWo6EMSVNoJA21gzQQKvkikc5/i8hxvN0fk38LK8oZLeX7bOovnD OwRtaDyoVhj0OSEIwjk4naLKtRaI+LpwjySwbcRkItMc/cLOB2ihwZUQW2vGhOip3hAe 9cS15yWyV00EiH5mtq1fbz8PGF2uFr9nMDyA6RyV2VkLH52ysfnYHCeAJzmiKpIpgPe1 DKGM1tOiKhZPo4/Cx+9Zue7I0ElwpGI5C3vsKFiWiPAmmz1IxNf9/0lLfX8tO+kZf19o RtoTE3uE5YDuc0N8Y1eEDmXeE2yH7rDp3mo6iknjgYp9fgSSgC9XTCPnWf2BjE0XQH90 mA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgetpgw5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:17 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCaGEs024716 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:16 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.42; Wed, 28 Jun 2023 05:36:10 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 09/21] pstore/ram : Export ramoops_parse_dt() symbol Date: Wed, 28 Jun 2023 18:04:36 +0530 Message-ID: <1687955688-20809-10-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: ZoEjWss5MTUTidHK6qRrwbz1QzIG9cbn X-Proofpoint-GUID: ZoEjWss5MTUTidHK6qRrwbz1QzIG9cbn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950141509441802?= X-GMAIL-MSGID: =?utf-8?q?1769950141509441802?= It is possible if some driver do not want ramoops region to be static instead it sets up the mem_address and mem_size and use everything what this driver has to offer. To offer this convenience export ramoops_parse_dt() function. Signed-off-by: Mukesh Ojha --- fs/pstore/ram.c | 26 ++++++++++++++++++-------- include/linux/pstore_ram.h | 2 ++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index ade66dbe5f39..6bb66d044bef 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -638,7 +638,7 @@ static int ramoops_parse_dt_u32(struct platform_device *pdev, return 0; } -static int ramoops_parse_dt(struct platform_device *pdev, +int ramoops_parse_dt(struct platform_device *pdev, struct ramoops_platform_data *pdata) { struct device_node *of_node = pdev->dev.of_node; @@ -649,15 +649,24 @@ static int ramoops_parse_dt(struct platform_device *pdev, dev_dbg(&pdev->dev, "using Device Tree\n"); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, - "failed to locate DT /reserved-memory resource\n"); - return -EINVAL; + /* + * It is possible if some driver do not want ramoops + * region to be static instead it sets up the mem_address + * and mem_size and use everything what this driver has + * to offer. + */ + if (!pdata->mem_address && !pdata->mem_size) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, + "failed to locate DT /reserved-memory resource\n"); + return -EINVAL; + } + + pdata->mem_size = resource_size(res); + pdata->mem_address = res->start; } - pdata->mem_size = resource_size(res); - pdata->mem_address = res->start; /* * Setting "unbuffered" is deprecated and will be ignored if * "mem_type" is also specified. @@ -713,6 +722,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, return 0; } +EXPORT_SYMBOL_GPL(ramoops_parse_dt); static int ramoops_probe(struct platform_device *pdev) { diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index 9d65ff94e216..55df4e631a25 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -8,6 +8,7 @@ #ifndef __LINUX_PSTORE_RAM_H__ #define __LINUX_PSTORE_RAM_H__ +#include #include struct persistent_ram_ecc_info { @@ -39,4 +40,5 @@ struct ramoops_platform_data { struct persistent_ram_ecc_info ecc_info; }; +int ramoops_parse_dt(struct platform_device *, struct ramoops_platform_data *); #endif From patchwork Wed Jun 28 12:34:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8899056vqr; Wed, 28 Jun 2023 05:51:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44r6TsO5+avG+Fz/Q/EuGRwm2MOFs89VHdaNNLrP5rjgSxy5XBRvn6BSlhpfP7ePjoQTS9 X-Received: by 2002:aa7:cb50:0:b0:51d:95ac:22ed with SMTP id w16-20020aa7cb50000000b0051d95ac22edmr1420980edt.1.1687956706367; Wed, 28 Jun 2023 05:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956706; cv=none; d=google.com; s=arc-20160816; b=pJwZu7h92p9uiT1Q0YJfwge4gDV5d0TSkB4ePr8Wvm7GtunRnran9zVolVZHEzbkMj SqIv5QoOTTNmkC+6Xp9JolGFcHdqOgWenXfaaSYRqQVyksjdOtnqJsKUv+eF/8QMn+Oy 3zSVmuUiXIhOVey6vGcJqdH0Plk+dkZ3UK4JnhDD2gkKu1jttcVg380kTj+v7C6V3SQq dbEJWhCIaQPWpzK5tXIICLwkDFMNRiX3IG/EaRb7R/D3etm0+2CsJs90grn0RFv6rfcN f6L9JM8nowSqvhDYEUNq1G6m1Vki8B6BA6LBX1D2+WwihI0ukGLrUptK0D6Ockb7638Q yMag== 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=2yMC5EEtMJQ03Yo9VfVD/9tJuZx2c76pv/N/G2ETIXU=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=AXLvMiSsXby2aoNFp1AeFeNo3Dpj3ejQCMI3EdxVjvb4QIqpltGxW8dnWZAydbqRjF lO4v3oSGsTqVYpYTvZLUh8xWqRx0/rgdw3LCeaglPETb7lmSE9t0khFwWDRr9Bv7BI0g kz0HKIOl2bT98gnRMYXGeUnjun5/LL15Q7JTSkGPv3aU2Qp+JfSlhUMjLsXcC+zTI3Hx j2Y+62CRtpQ117lKHnxQF+7QR93uUdPxEyepLvJ1sGiV5SY56GVauVd9Q2DVAtckg9Bx G+r5SC7RfKJpO1QOHmm/tZw9UaPvJxYeI0gLuRPElzmX/oHMSVfNdRDZoPyXlfTHpmaM 4bCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bo5FTF7H; 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 g7-20020aa7c587000000b0051d96d158f8si3887067edq.581.2023.06.28.05.51.22; Wed, 28 Jun 2023 05:51:46 -0700 (PDT) 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=bo5FTF7H; 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 S232046AbjF1MjZ (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:25 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:35612 "EHLO mx0a-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231993AbjF1MhN (ORCPT ); Wed, 28 Jun 2023 08:37:13 -0400 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 35SBBFbJ018314; Wed, 28 Jun 2023 12:36: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=2yMC5EEtMJQ03Yo9VfVD/9tJuZx2c76pv/N/G2ETIXU=; b=bo5FTF7HYw/8bXG19p2kS4CzT5k3WIqxwLHn6P3eLVnt4P9ZhrKmld19gqbm3uy7xhYG 1OPAQAuxcX9On03qaxmvHCklLlWv1F0C2XbTeRdmazqEi1C4eS8b0kq8dYWmXNC2R0wI UR1NGc56bH8BfOunkX7hqDn0lH7xFvgzIT9FY9ZztSQ50ly1c/c5DoZZBNe425Kh2ctb Xha+gMQ2uwsyvc9wgnxPO8QRO3erELxgkpfr7VKVgrumJd9lWIO50hmiz9UjzVlgA+On dUx8tXvcePK3N+Km/+vYLavuESJk5cXKzNdQT4J04TVnRs/xk+HqzT2sd1R5PcJ6bwjn Gg== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgfp3rrmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:24 +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 35SCaN2T008058 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36: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.42; Wed, 28 Jun 2023 05:36:16 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support Date: Wed, 28 Jun 2023 18:04:37 +0530 Message-ID: <1687955688-20809-11-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: o27mVxlRyUT0vrSiZbVQV3GHBpbdK86u X-Proofpoint-ORIG-GUID: o27mVxlRyUT0vrSiZbVQV3GHBpbdK86u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 bulkscore=0 malwarescore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950891323421387?= X-GMAIL-MSGID: =?utf-8?q?1769950891323421387?= This driver was inspired from the fact pstore ram region should be fixed and boot firmware need to have awarness about this region, so that it will be persistent across boot. But, there are many QCOM SoC which does not support warm boot from hardware but they have minidump support from the software, and for them, there is no need of this pstore ram region to be fixed, but at the same time have interest in the pstore frontends data. So, this driver get the dynamic reserved region from the ram and register the ramoops platform device. +---------+ +---------+ +--------+ +---------+ | console | | pmsg | | ftrace | | dmesg | +---------+ +---------+ +--------+ +---------+ | | | | | | | | +------------------------------------------+ | \ / +----------------+ (1) |pstore frontends| +----------------+ | \ / +------------------- + (2) | pstore backend(ram)| +--------------------+ | \ / +--------------------+ (3) |qcom_pstore_minidump| +--------------------+ | \ / +---------------+ (4) | qcom_minidump | +---------------+ This driver will route all the pstore front data to the stored in qcom pstore reserved region and the reason of showing an arrow from (3) to (4) as qcom_pstore_minidump driver will register all the available frontends region with qcom minidump driver in upcoming patch. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/Kconfig | 12 +++++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 1834213fd652..fbf08e30feda 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM This config should be enabled if the low level minidump is implemented as part of SMEM. + +config QCOM_PSTORE_MINIDUMP + tristate "Pstore support for QCOM Minidump" + depends on ARCH_QCOM + depends on PSTORE_RAM + depends on QCOM_MINIDUMP + help + Enablement of this driver ensures that ramoops region can be anywhere + reserved in ram instead of being fixed address which needs boot firmware + awareness. So, this driver creates plaform device and registers available + frontend region with the Qualcomm's minidump driver. + endmenu diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index 737d868757ac..1ab59c1b364d 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -36,3 +36,4 @@ qcom_ice-objs += ice.o obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE) += qcom_ice.o obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o +obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c new file mode 100644 index 000000000000..b07cd10340df --- /dev/null +++ b/drivers/soc/qcom/qcom_pstore_minidump.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include + +struct qcom_ramoops_dd { + struct ramoops_platform_data qcom_ramoops_pdata; + struct platform_device *ramoops_pdev; +}; + +static int qcom_ramoops_probe(struct platform_device *pdev) +{ + struct device_node *of_node = pdev->dev.of_node; + struct qcom_ramoops_dd *qcom_rdd; + struct ramoops_platform_data *pdata; + struct reserved_mem *rmem; + struct device_node *node; + long ret; + + node = of_parse_phandle(of_node, "memory-region", 0); + if (!node) + return -ENODEV; + + rmem = of_reserved_mem_lookup(node); + of_node_put(node); + if (!rmem) { + dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n"); + return -EINVAL; + } + + qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL); + if (!qcom_rdd) + return -ENOMEM; + + pdata = &qcom_rdd->qcom_ramoops_pdata; + pdata->mem_size = rmem->size; + pdata->mem_address = rmem->base; + ramoops_parse_dt(pdev, pdata); + + qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1, + pdata, sizeof(*pdata)); + if (IS_ERR(qcom_rdd->ramoops_pdev)) { + ret = PTR_ERR(qcom_rdd->ramoops_pdev); + dev_err(&pdev->dev, "could not create platform device: %ld\n", ret); + qcom_rdd->ramoops_pdev = NULL; + } + platform_set_drvdata(pdev, qcom_rdd); + + return ret; +} + +static void qcom_ramoops_remove(struct platform_device *pdev) +{ + struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev); + + platform_device_unregister(qcom_rdd->ramoops_pdev); + qcom_rdd->ramoops_pdev = NULL; +} + +static const struct of_device_id qcom_ramoops_of_match[] = { + { .compatible = "qcom,ramoops"}, + {} +}; +MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match); + +static struct platform_driver qcom_ramoops_drv = { + .driver = { + .name = "qcom,ramoops", + .of_match_table = qcom_ramoops_of_match, + }, + .probe = qcom_ramoops_probe, + .remove_new = qcom_ramoops_remove, +}; + +module_platform_driver(qcom_ramoops_drv); + +MODULE_DESCRIPTION("Qualcomm ramoops minidump driver"); +MODULE_LICENSE("GPL"); From patchwork Wed Jun 28 12:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8899369vqr; Wed, 28 Jun 2023 05:52:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mM/D+k5UKSL67G2BFCrfkJYVUONQK4yHGArzlhxoB6N3PTzNgVDATcTBhYMidBFD4ymBv X-Received: by 2002:a17:906:da8b:b0:982:26c5:6525 with SMTP id xh11-20020a170906da8b00b0098226c56525mr34581003ejb.60.1687956737280; Wed, 28 Jun 2023 05:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956737; cv=none; d=google.com; s=arc-20160816; b=bUHwUu7inAl0sfh3mQPatN6ghYaY7frTzuAQdWnw1WHo0Xsa9M9Sjl9UB6XUp3GnVx xNV5oDNQHivVHJL+K3V7PZ5nY1DiLAgc6bsw3+XnlZEWkDRzOFvSqOTBRQX5wEO0hzWo /5IPCrsByaesMIElEYGt3KDvV4vuo868QnIqVMcXft5dyer+OiMmlVmTH1RBCxdcDp9h JWeVUDaOL6UGrWwZVRQMFhv0koN3KjkXjGafHTsOV+yErWkHMSwgSJyPvb9VXwwYWIYR wYwvgv4joXIZkpc5+n9BYR8kUM8qOUQzGrw3/bKdu4ndnkMiZDHwrIows98MktoXf4Os mVHg== 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=PUdvcBK75eQiAmB1sFgB1b8PFy9LJu6zPkzkKOvP6QQ=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=Y5c+DfUE6aSajo5v5gf6he35VLYDnVT+J7lXiWdifKkzmwsKNqZAQTo5aWULXYfpol 5MfV11qJgvIijNhLUe1Nl4SXQMHK8CLAZ5ut5TRAkGNxAXKYwJbl4w21x77Ouawj7DMb wjNdQPIuiFOk0z456BKa8sFQURYaPLmmwy/Y7x/27LByr7gATfOI0CnitXBI03XtVINt DcgWbeLCMfhrdqVwGeh7K9GJNSL2/dPSZbNvtr5NFon/8C0B0DoL0KBPr3ayeAsJPvAE jtv7oobKFdgac51o49JU4wubiD/p+smsxAIOWbAUWC1RuI1v2C9cT7b2NNJi79Vur5SA Ld/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Jcfa0Ua8; 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 y9-20020a170906914900b0096f56df6a00si4925406ejw.661.2023.06.28.05.51.52; Wed, 28 Jun 2023 05:52:17 -0700 (PDT) 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=Jcfa0Ua8; 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 S232552AbjF1MjB (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:01 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:25678 "EHLO mx0a-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231946AbjF1MhC (ORCPT ); Wed, 28 Jun 2023 08:37:02 -0400 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 35SCOe3T014964; Wed, 28 Jun 2023 12:36: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=PUdvcBK75eQiAmB1sFgB1b8PFy9LJu6zPkzkKOvP6QQ=; b=Jcfa0Ua8h2oBaEN5PrunYOiEcHx5upAgq00w0USn6FQfoYlwbTP9/b+Sr6Sh1cjmGy4I R9WfzskLKSwNWHhY/Z1gIJxRDUA8DSs0e1+ugkMUzD7je12h6pN81JYshc2gRJEmXhx7 FT4hhxWZS1avLVetpCt52OmPodsV1QIK8RcC9md70l52un8hVe6ConfMf8s7ufawVlze gMNoPs5N6m+VjMD4JITAiWeSbQy4bkOGnWBBypkttN0LtfiWg3doUZDSMDBtY03RkjyH deRRYAVI9hm64oF/uPEU0dP5I2nTQXcGBm0pNptsrKKAixrGJ8bsogLcw/mmb+h+PgBS Lg== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgaxcs94e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:31 +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 35SCaU70008488 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:30 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.42; Wed, 28 Jun 2023 05:36:23 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump Date: Wed, 28 Jun 2023 18:04:38 +0530 Message-ID: <1687955688-20809-12-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: x6ZlZc7YHcNUisVbetG2IdTSFdzK1QbR X-Proofpoint-ORIG-GUID: x6ZlZc7YHcNUisVbetG2IdTSFdzK1QbR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950923804488743?= X-GMAIL-MSGID: =?utf-8?q?1769950923804488743?= Since qcom_pstore_minidump driver creates platform device for qualcomm devices, so it knows the physical addresses of the frontend region now. Let's register the regions with qcom_minidump driver. Signed-off-by: Mukesh Ojha --- drivers/soc/qcom/qcom_pstore_minidump.c | 131 +++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c index b07cd10340df..f17384dd2d72 100644 --- a/drivers/soc/qcom/qcom_pstore_minidump.c +++ b/drivers/soc/qcom/qcom_pstore_minidump.c @@ -9,12 +9,120 @@ #include #include #include +#include struct qcom_ramoops_dd { struct ramoops_platform_data qcom_ramoops_pdata; struct platform_device *ramoops_pdev; + struct device *dev; + struct qcom_minidump_region **dmesg_region; + struct qcom_minidump_region *console_region; + struct qcom_minidump_region *pmsg_region; + struct qcom_minidump_region **ftrace_region; + unsigned int max_dump_cnt; + unsigned int max_ftrace_cnt; }; +static int qcom_ramoops_md_region_register(struct device *dev, struct qcom_minidump_region **zone, + const char *name, phys_addr_t phys_addr, + unsigned long size) +{ + struct qcom_minidump_region *md_region; + int ret; + + if (!size) + return 0; + + md_region = devm_kzalloc(dev, sizeof(*md_region), GFP_KERNEL); + if (!md_region) + return -ENOMEM; + + strscpy(md_region->name, name, sizeof(md_region->name)); + md_region->phys_addr = phys_addr; + md_region->virt_addr = phys_to_virt(phys_addr); + md_region->size = size; + *zone = md_region; + ret = qcom_minidump_region_register(md_region); + if (ret) + dev_err(dev, "failed to add %s in minidump: err: %d\n", name, ret); + + return ret; +} + +static int qcom_ramoops_minidump_register(struct qcom_ramoops_dd *qcom_rdd) +{ + struct ramoops_platform_data *pdata = &qcom_rdd->qcom_ramoops_pdata; + char name[MAX_NAME_LENGTH]; + size_t zone_sz; + phys_addr_t phys_addr; + int ret = 0; + int i; + + phys_addr = pdata->mem_address; + for (i = 0; i < qcom_rdd->max_dump_cnt; i++) { + scnprintf(name, sizeof(name), "KDMSG%d", i); + ret = qcom_ramoops_md_region_register(qcom_rdd->dev, + &qcom_rdd->dmesg_region[i], name, phys_addr, + pdata->record_size); + if (ret) + return ret; + + phys_addr += pdata->record_size; + } + + ret = qcom_ramoops_md_region_register(qcom_rdd->dev, + &qcom_rdd->console_region, "KCONSOLE", phys_addr, + pdata->console_size); + if (ret) + return ret; + + phys_addr += pdata->console_size; + + ret = qcom_ramoops_md_region_register(qcom_rdd->dev, + &qcom_rdd->pmsg_region, "KPMSG", phys_addr, + pdata->pmsg_size); + if (ret) + return ret; + + phys_addr += pdata->pmsg_size; + + zone_sz = pdata->ftrace_size / qcom_rdd->max_ftrace_cnt; + for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++) { + ret = qcom_ramoops_md_region_register(qcom_rdd->dev, + &qcom_rdd->ftrace_region[i], "KFTRACE", phys_addr, + zone_sz); + if (ret) + return ret; + + phys_addr += zone_sz; + } + + return ret; +} + +static void qcom_ramoops_minidump_unregister(struct qcom_ramoops_dd *qcom_rdd) +{ + struct ramoops_platform_data *pdata; + int i; + + pdata = &qcom_rdd->qcom_ramoops_pdata; + if (pdata->record_size) { + for (i = 0; i < qcom_rdd->max_dump_cnt; i++) + qcom_minidump_region_unregister(qcom_rdd->dmesg_region[i]); + } + + if (pdata->console_size) + qcom_minidump_region_unregister(qcom_rdd->console_region); + + if (pdata->pmsg_size) + qcom_minidump_region_unregister(qcom_rdd->pmsg_region); + + if (pdata->ftrace_size) { + for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++) + qcom_minidump_region_unregister(qcom_rdd->ftrace_region[i]); + } +} + static int qcom_ramoops_probe(struct platform_device *pdev) { struct device_node *of_node = pdev->dev.of_node; @@ -22,6 +130,7 @@ static int qcom_ramoops_probe(struct platform_device *pdev) struct ramoops_platform_data *pdata; struct reserved_mem *rmem; struct device_node *node; + size_t dump_mem_sz; long ret; node = of_parse_phandle(of_node, "memory-region", 0); @@ -39,27 +148,43 @@ static int qcom_ramoops_probe(struct platform_device *pdev) if (!qcom_rdd) return -ENOMEM; + qcom_rdd->dev = &pdev->dev; pdata = &qcom_rdd->qcom_ramoops_pdata; pdata->mem_size = rmem->size; pdata->mem_address = rmem->base; - ramoops_parse_dt(pdev, pdata); - + ret = ramoops_parse_dt(pdev, pdata); + if (ret < 0) + return ret; + + dump_mem_sz = pdata->mem_size - pdata->console_size - pdata->ftrace_size + - pdata->pmsg_size; + if (!dump_mem_sz || !pdata->record_size) + qcom_rdd->max_dump_cnt = 0; + else + qcom_rdd->max_dump_cnt = dump_mem_sz / pdata->record_size; + + qcom_rdd->max_ftrace_cnt = (pdata->flags & RAMOOPS_FLAG_FTRACE_PER_CPU) + ? nr_cpu_ids + : 1; qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1, pdata, sizeof(*pdata)); if (IS_ERR(qcom_rdd->ramoops_pdev)) { ret = PTR_ERR(qcom_rdd->ramoops_pdev); dev_err(&pdev->dev, "could not create platform device: %ld\n", ret); qcom_rdd->ramoops_pdev = NULL; + return ret; } + platform_set_drvdata(pdev, qcom_rdd); - return ret; + return qcom_ramoops_minidump_register(qcom_rdd); } static void qcom_ramoops_remove(struct platform_device *pdev) { struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev); + qcom_ramoops_minidump_unregister(qcom_rdd); platform_device_unregister(qcom_rdd->ramoops_pdev); qcom_rdd->ramoops_pdev = NULL; } From patchwork Wed Jun 28 12:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8900251vqr; Wed, 28 Jun 2023 05:54:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6p4s5yuPajDCflAiusJ1hVqfqog+r8fvsw1pjuMebxGz1ePWw5aMf6V/zUuVAWKrl5AFhx X-Received: by 2002:a05:6402:759:b0:51a:7bcf:c8f5 with SMTP id p25-20020a056402075900b0051a7bcfc8f5mr19509776edy.1.1687956843703; Wed, 28 Jun 2023 05:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956843; cv=none; d=google.com; s=arc-20160816; b=iMtBCpM735DAsweLto2JsrILJ2JRDLjUUXY7nH4OaaC+WLezeSsQPng3AgBRzNByW1 TKNakIIcsyhTViKxRY4PYrBOXBAKF2uOVcx16bBfqvsVpZYC6Vnq6E0X6OzItHKAUBzF VFuY1uxL56aN+jinDzasltonvvprolE5eyRm3yKrK0p7PKVX4nd2azufKG/79PCquvE9 TLRB1SadMXYUsG5Qy9oLaKrp7F0NWNm/M3F8QHJ5vkTbKkyx7Wfx/wczdErPMHVptt0I ogzv2abir41ri3KHmOpAmt9yal2/ueIIf9xKIvSHrFnMlUJEHVFz2/34AOSgJxme+4py iHRQ== 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=djE97bwYNjcxAluIW2+Cfgiqlpbzj4NG+dPedZwtHls=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=IBkai2M+8Hnktlb5/gosTHFltoOh6BDU48UZL0qrKYvRAQRe7pqk6oY5mrn4KDAqlv Vhz/TXccYvlvIUtDx1LgAdjBIq6blCdl1d4BMYl7/exJ0lO2XYAWDpVlPPycqd9wL9gN 6DtCTTQ953L9b3EP8WWpzBzYY1kjhLK0tZrEcavIAz9zZR+e9BH2D52q8GVCjJjkn+y4 BvGJRhHrFAIkwo5cF6t2qjt6p24/ds8CMP3FPUxYq0IaFw7moT73P2uh/CCGlsmd/3kn TwJSc16chnTdm/oO1pjsaUA3EYU/PAb28UrNV9qm9yTGR7xPF27ds74q8s4LdUrJDQsG ykNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZkqpxLSH; 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 r18-20020aa7cb92000000b0051be93a4395si5138435edt.52.2023.06.28.05.53.39; Wed, 28 Jun 2023 05:54:03 -0700 (PDT) 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=ZkqpxLSH; 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 S231422AbjF1Mio (ORCPT + 99 others); Wed, 28 Jun 2023 08:38:44 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:19726 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbjF1Mg5 (ORCPT ); Wed, 28 Jun 2023 08:36:57 -0400 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 35S6A6Mp009106; Wed, 28 Jun 2023 12:36:39 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=djE97bwYNjcxAluIW2+Cfgiqlpbzj4NG+dPedZwtHls=; b=ZkqpxLSH9zR99JHx/OcyvykWqTnmoepPGhrHscWSAH3MpiJDNeYbGbmpyKbIULzsDvyd iMHPWOX0HXTt02oNetLKgrcmEPkuY3dnjKnEECKhcOoaHmJc80noGp9EXrrcUL3/6KFP o/lbMeGYZx6MmELU2UbIcjjgWtTvq1LR5YIUYG3epD6TuRpSfSHgBeEDtpgTjLvwi3wu hnhOu7IMXR+9t7wrwthveErQVZ+rv4BCveiBe3WAx7vz31PsiT2NpYXXeC1KuvZI/Gm9 HT1bMY0fKig8EfaeL4Q1orQ5kKYXEOBUQ1B7xhMpFlEDncMZm5IGd9Gx0XzEXfu9F/Jg IQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgemk0x78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:38 +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 35SCab3x026965 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:37 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.42; Wed, 28 Jun 2023 05:36:30 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 12/21] remoteproc: qcom: Expand MD_* as MINIDUMP_* Date: Wed, 28 Jun 2023 18:04:39 +0530 Message-ID: <1687955688-20809-13-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: I06AKbz5qS12S7u74FTJu05S2HG2AFk- X-Proofpoint-ORIG-GUID: I06AKbz5qS12S7u74FTJu05S2HG2AFk- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769951035345592476?= X-GMAIL-MSGID: =?utf-8?q?1769951035345592476?= 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 a0d4238492e9..805e525df3b5 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 @@ -125,7 +125,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 (le32_to_cpu(region.valid) == MD_REGION_VALID) { + if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) { name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL); if (!name) { iounmap(ptr); @@ -168,8 +168,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 Wed Jun 28 12:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8898749vqr; Wed, 28 Jun 2023 05:51:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64riW6Yq4GTSeRPOnqz8AOQZ3RHmzBmfYTH+LFGEHnZDCRfUpC9UMi7ve+BiPjxBa2BLo/ X-Received: by 2002:a17:907:1c1c:b0:992:5deb:db89 with SMTP id nc28-20020a1709071c1c00b009925debdb89mr2771952ejc.22.1687956670310; Wed, 28 Jun 2023 05:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956670; cv=none; d=google.com; s=arc-20160816; b=LbnjMEysu6yRtdM7tlXw7DpmT3/hOyKBHwxM0rp30ndfwOAiM+lUd+oYIFf+eXcmRo 6jh15MLLZqb/Z+A2Jsia3gPgtk3DnTt9NI3FTuz36mun07EPqVl23IK4z3kVUU+5XcIy jC0ODByUGMPocEomHfBQsL7AVOaNtRcrvUU6uVY763OuCTcAbWwBcl+AliSR8OYua65L eoLlui1yaP9rHC3pwFKrQ6LbaQV2REo8tJ4yiXZhTbHUbids94p8H2k/LCmt5viY7ToK UHmw7tEw3cgkjxnXhurazhVIAdp97D20Ed/850ksJ3Sa10AYuaGOun0rID4wSuoYu3IT d/IA== 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=bXAVQ/l1JxtYIrEXFz1M9FxwE6mSfXNtpjd0vCm4a9I=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=aiS69uDQztkndAiRmFav8NCTkNchG4ccCY1hfjM6LJiXYtU3w8/rLEiPi0GYhMNsA8 Odgj2+DYpRinzylYXLfb5HtwMOB0RVH1VjZFPKsEGrqjEfBdIawYuGWbCKdAOwR7eqF0 kRFjSj3Uk8k//J6rNnBWQbv/80GaA42Laq16ltU/RjXOSFnJ4bn8nE1RphDtb32SsbqB 9VUgMKLUxs1fCjuEzKOHzygNgYJo7wtgB+cUHFdjAxLu4sGDEvLj5twwMvkVewylpisa VQd4ToXnn1Dgo5Wp+WvtrClplWwzzg2nUMIWJ3+Bqcvc81OGyvrQsveCBFuMwv9WktmL GiYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="H+v+fC/e"; 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 jx20-20020a170906ca5400b00991f1e4b041si3300579ejb.737.2023.06.28.05.50.45; Wed, 28 Jun 2023 05:51:10 -0700 (PDT) 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="H+v+fC/e"; 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 S231466AbjF1Mjg (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:36 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:43138 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231659AbjF1MhZ (ORCPT ); Wed, 28 Jun 2023 08:37:25 -0400 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 35SCSGE4001841; Wed, 28 Jun 2023 12:36:45 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=bXAVQ/l1JxtYIrEXFz1M9FxwE6mSfXNtpjd0vCm4a9I=; b=H+v+fC/e/Zumcaxk4l3a+nsDLVUDme3xGCs+UaZwDau8NJHhd6EYi2n5C7QjmmapP5PN IPwJ5SAFoVDQLNYW951fN5o8oCaqrUK2XtIXRuo4I/kzwF/DYjCqgmb1TWb2QZrXZW/c A1Fvu7ElQ2G6guGdq+pOGSW8ExxSM1ieZJ+/HAAO+55ALlDozoquvObfNGgHxura+mA1 9/g/+gtW31yy5QY/9K8qeSJ6O99tB6Q9K2ibgLtU/XCxLp9qDPvG914muYfjL5FBkeid vyO5oXdMRq/UCu8hToRQ4ssEI71yGiPm8weI6Bnlf4lcDtkKLyQ6fF0rf+utxaPeZTH9 NA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgetpgw6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:45 +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 35SCaiuY008625 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:44 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.42; Wed, 28 Jun 2023 05:36:37 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol Date: Wed, 28 Jun 2023 18:04:40 +0530 Message-ID: <1687955688-20809-14-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: c0s6xSyHVbDjNhTuabGX7nTgJRy1rqii X-Proofpoint-GUID: c0s6xSyHVbDjNhTuabGX7nTgJRy1rqii X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950853582727056?= X-GMAIL-MSGID: =?utf-8?q?1769950853582727056?= There is no need remoteproc code(driver/remoteproc/qcom_common.c) to know about minidump data structure layout instead it should better use the minidump exported symbol to get the required information. Refactor the qcom_minidump() function and remove the minidump related data structure from driver/remoteproc/qcom_common.c . Signed-off-by: Mukesh Ojha --- drivers/remoteproc/qcom_common.c | 142 +++++++-------------------------------- 1 file changed, 25 insertions(+), 117 deletions(-) diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 805e525df3b5..24e8b692cd2c 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; @@ -101,85 +47,47 @@ static void qcom_minidump_cleanup(struct rproc *rproc) } } -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem, - void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment, - void *dest, size_t offset, size_t size)) +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id, + void (*rproc_dumpfn_t)(struct rproc *rproc, + struct rproc_dump_segment *segment, void *dest, size_t offset, + size_t size)) { - struct minidump_region __iomem *ptr; - struct minidump_region region; - int seg_cnt, i; dma_addr_t da; size_t size; + int seg_cnt; char *name; + void *ptr; + int ret; + int i; if (WARN_ON(!list_empty(&rproc->dump_segments))) { dev_err(&rproc->dev, "dump segment list already populated\n"); - return -EUCLEAN; + return; } - seg_cnt = le32_to_cpu(subsystem->region_count); - ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr), - seg_cnt * sizeof(struct minidump_region)); + ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt); if (!ptr) - return -EFAULT; + return; for (i = 0; i < seg_cnt; i++) { - memcpy_fromio(®ion, ptr + i, sizeof(region)); - if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) { - name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL); - if (!name) { - iounmap(ptr); - return -ENOMEM; - } - da = le64_to_cpu(region.address); - size = le64_to_cpu(region.size); - rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name); + ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size); + if (ret < 0) { + iounmap(ptr); + dev_err(&rproc->dev, + "Failed with error: %d while adding minidump entries\n", + ret); + goto clean_minidump; } - } - - iounmap(ptr); - return 0; -} - -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id, - void (*rproc_dumpfn_t)(struct rproc *rproc, - struct rproc_dump_segment *segment, void *dest, size_t offset, - size_t size)) -{ - 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"); - 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 - * is initialized in memory and encryption status is set. - */ - if (subsystem->regions_baseptr == 0 || - le32_to_cpu(subsystem->status) != 1 || - 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; + /* if it is a valid segment */ + if (!ret) + rproc_coredump_add_custom_segment(rproc, da, size, + rproc_dumpfn_t, name); } - ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t); - if (ret) { - dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret); - goto clean_minidump; - } + iounmap(ptr); rproc_coredump_using_sections(rproc); + clean_minidump: qcom_minidump_cleanup(rproc); } From patchwork Wed Jun 28 12:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8899216vqr; Wed, 28 Jun 2023 05:52:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zAlzpKWcx+CJw7ESGusR1bo+rBlbYpI7SUS6az7RsHrgbUJ7WN8EENehFUbW9gbvsSaOD X-Received: by 2002:a17:907:9815:b0:96f:94f1:b0a5 with SMTP id ji21-20020a170907981500b0096f94f1b0a5mr1285041ejc.8.1687956721636; Wed, 28 Jun 2023 05:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956721; cv=none; d=google.com; s=arc-20160816; b=cf+YJxPtAIsHNoVRDc+/ALNB/3uLeM/Hb6XUfUOXablqe7I8o1BvRyloANH/sgRtBv wRLeEeS9UGxWOCi0S1a4GbTmP5zGlDO2AAypaU0fTguhYHQb7em53EtT7uQl2MWfowLN nYQgMs2PvmLBCqnEGuW87qX6tr49Jdi8oZox/7KLGt2BLePmsDDJSJJFlm8NotIw1cDv eKEAqfc4Bh9LfqGx8p3Lcq7jOym35d3hxTCdTiyyKnhXvmNKQFoont/ISSVqKfRZ4ooa mqv04VA1baqso8mCN8rQcxwvHz8aJqgFYHe79otvZN5zqvCPVrvai1Qp/QUUGvRzkiVL CLTA== 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=XLYT34qEjQ6HYGUoTlDKe0dodFK4dwkxLz1rB6s8Nxo=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=EhmFW3T23UTInuVvIfgRbWItFy5sCeqg1K7xutnWRd3tDSXb8/tLuB7CSk2ZJBBE8y vhgDRmK4UL+gPhcdzsh6wALoBskefP9YiyWvwN3KpZrmN6g6WWfZapmYVsSIeiZ307Fa tbtsVlRfOTuFKHgej8ff32J1doTmH6FVcbzjvaKmGC8sNtWuY1ENpuWPURAY/sb3YdP2 F5+hm2oHS+uvuViLlUJkgMA9VESilxbJzA9so+CZsKvg/I5YEewU9u6uAFCpHOuRytcP L2cAcqu4diSfEnp/BIKeQ5pYV74wyOUSAEd3nYxpZnI0J8HoaA4MK90AjsE1kt+Lr8nN QdyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZGh7DURW; 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 bx14-20020a170906a1ce00b00982a6e33d3esi4896304ejb.1046.2023.06.28.05.51.37; Wed, 28 Jun 2023 05:52:01 -0700 (PDT) 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=ZGh7DURW; 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 S232035AbjF1MjV (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:21 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:35192 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbjF1MhP (ORCPT ); Wed, 28 Jun 2023 08:37:15 -0400 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 35SAmFnQ002193; Wed, 28 Jun 2023 12:36:52 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=XLYT34qEjQ6HYGUoTlDKe0dodFK4dwkxLz1rB6s8Nxo=; b=ZGh7DURWPbXgzTB2X8Mo8jnHLKshi1d9e4v1QwvYltciCsgU7NIo5UidbwqNj4sjv7R3 uMK2Fy/Xj2ZyiFyH6Pl8PFKMYLlPSqKRH9T5wUZxAfDHknD8qYNbbbF65lrwZVYml2cE egTvAH1rTGtH7dd9A3DSlNX1d+/Kmfhv2qJcjiWEcTWGABQEqsCBKXFBc/mAczIHmGDX Y/mkBKYOrU0Bbmw5HOceFBh246kUZa1C97PoWBht/onenvqlh2aYtq1MM/Tqh8FMnelL CfTP5I4EkqTU7yVYnjljgC8wKRWPC0BWbPyeX10fNGAgyI2FAIXsUXFgJyFYZHGQCFTA KA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgemk0x7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:52 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCapLE025340 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:51 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.42; Wed, 28 Jun 2023 05:36:44 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 14/21] MAINTAINERS: Add entry for minidump driver related support Date: Wed, 28 Jun 2023 18:04:41 +0530 Message-ID: <1687955688-20809-15-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: K4JMMEe9pinGGLQoI6BjoAoext74H8Hs X-Proofpoint-ORIG-GUID: K4JMMEe9pinGGLQoI6BjoAoext74H8Hs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=977 impostorscore=0 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950907099039274?= X-GMAIL-MSGID: =?utf-8?q?1769950907099039274?= Add the entries for all the files added as a part qualcomm minidump driver support. Signed-off-by: Mukesh Ojha --- MAINTAINERS | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index a82795114ad4..8cbbe3e662e5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17551,6 +17551,14 @@ S: Maintained F: Documentation/devicetree/bindings/regulator/vqmmc-ipq4019-regulator.yaml F: drivers/regulator/vqmmc-ipq4019-regulator.c +QUALCOMM MINIDUMP DRIVER +M: Mukesh Ojha +L: linux-arm-msm@vger.kernel.org +S: Maintained +F: Documentation/admin-guide/qcom_minidump.rst +F: drivers/soc/qcom/qcom_minidump.c +F: drivers/soc/qcom/qcom_minidump_smem.c + QUALCOMM NAND CONTROLLER DRIVER M: Manivannan Sadhasivam L: linux-mtd@lists.infradead.org @@ -17559,6 +17567,13 @@ S: Maintained F: Documentation/devicetree/bindings/mtd/qcom,nandc.yaml F: drivers/mtd/nand/raw/qcom_nandc.c +QUALCOMM PSTORE MINIDUMP DRIVER +M: Mukesh Ojha +L: linux-arm-msm@vger.kernel.org +S: Maintained +F: drivers/soc/qcom/qcom_pstore_minidump.c +F: Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml + QUALCOMM RMNET DRIVER M: Subash Abhinov Kasiviswanathan M: Sean Tranchetti From patchwork Wed Jun 28 12:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8893257vqr; Wed, 28 Jun 2023 05:41:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5L+8pzZatjC0jp6xFd+s8fwBEsVxVmD0OtN/eD4gWc9wpakC/MV20QN5k7sqqwSFwhUctl X-Received: by 2002:aa7:c9d0:0:b0:51d:9a0f:129c with SMTP id i16-20020aa7c9d0000000b0051d9a0f129cmr6320304edt.6.1687956087811; Wed, 28 Jun 2023 05:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956087; cv=none; d=google.com; s=arc-20160816; b=OPLR/z4TQ5Aca51Ouc+n/l0o+J5jEnAML7E2tsxi5K/4UjJYZyvyIOB2gBwF8mN4Hf sezxq8IKCHj1PS3OCsnr1xdBYq5VtInSHYVFjcBx9Y/4jpcMrb74syssr7iVBp7p6lGu Du5r2I8erNXXuA/Xl6h49+2x0SsonKI6N6MGx9J/KT2Stft8vBwG2qFeINnG8hAtACB0 Yx5ECcm8UtXluT8yRG3XHEYgSp0bB6kQEl0DWUV860zjoFhF8flMjRCDNC36gWbnn1NJ 7vlzvjr2cnQMd9zcIlcBGfzacjQIa+6Qk5A6JC0h0J/Kvlg7joDtHwkQBCZrftjCAoQJ f6GA== 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=KAy0dDEQPIdnGKN2nXiyLNVCeTxTN4ebpmPagwN0fjI=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=hmGM1HVXUdA2q8IFX15EoxDGLEEhjsAVN3yEteWoKo9be+swcaNX5RbXrtLrQ6ZKpC 3LiBLSn/x9d/7gnY1s8MTbKeJbjd1qpWGItlDW65PfZkN3h2PXFTZMTtwEb57qGkWKXy vK5e+pUt1HAMU9F2wBhRT4WEoDEoCLSyRj7ZHqWnCTnYic+yQJ+cBBbzTjIDRB6QFJUR dhXomLJi2X2vg8bTzYfGadcezcQEfk5vGfh3gkRZYSZOCBm05ASYo/0ZTe7+F5+CCuqi ma9xJ+AE9Fzag5Jgv51HkLO6M5PCUsqxx+gs+7h/wZH8B8xXwoPH41UFaDBiOT+LvbpL IJoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Qmny8C65; 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 a23-20020aa7d757000000b0051d96435b79si3659147eds.600.2023.06.28.05.41.02; Wed, 28 Jun 2023 05:41:27 -0700 (PDT) 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=Qmny8C65; 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 S232787AbjF1Mjr (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:47 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:36182 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbjF1MhR (ORCPT ); Wed, 28 Jun 2023 08:37:17 -0400 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 35SAcRSt000997; Wed, 28 Jun 2023 12:37:00 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=KAy0dDEQPIdnGKN2nXiyLNVCeTxTN4ebpmPagwN0fjI=; b=Qmny8C65ILTdFtje80edUb4ALz7tmy+1V7WUUrlanuDn/LU20D4TToNpxUda+gt0AtjM hB9iLQnTPoh7ssh42ylbSBIuoo8ILwKtbzbW0mYt6qh9B6tvt1Pze++RJIXg1NKsIibC YeAUpuQovhKni126GpJg+I4+DDwz/2Swjg75oTkk17X4TnHkesge6gdXyIzymVVvWV82 MVZubNDX5uc/GwsncZp1iUfzv+1paOY2JUF2EiSZHzMmCceshPcvaahvjIKn/cJEt78J PzKgZVySf211qc0e+X87BigDutJ0nT178pAt9mvprLqZvR4lp94ujoYGCq1rjAQdI/uW Rg== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgetpgw6x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:59 +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 35SCawgB001666 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:36:58 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.42; Wed, 28 Jun 2023 05:36:51 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 15/21] arm64: defconfig: Enable Qualcomm Minidump related drivers Date: Wed, 28 Jun 2023 18:04:42 +0530 Message-ID: <1687955688-20809-16-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: pwVBtz3NNSnWi7-Xb-Wr7yb4JUxjTDLQ X-Proofpoint-GUID: pwVBtz3NNSnWi7-Xb-Wr7yb4JUxjTDLQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxlogscore=863 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950242471589800?= X-GMAIL-MSGID: =?utf-8?q?1769950242471589800?= Enable QCOM_MINIDUMP_SMEM backend driver which automatically selects QCOM_MINIDUMP core for its functionality to work. While at it, also enable clients of minidump driver which is QCOM_PSTORE_MINIDUMP that uses PSTORE_RAM and PSTORE_CONSOLE to capture console logs into minidump. Signed-off-by: Mukesh Ojha --- arch/arm64/configs/defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index a24609e14d50..9a47c9ec0391 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -1250,6 +1250,8 @@ CONFIG_QCOM_STATS=m CONFIG_QCOM_WCNSS_CTRL=m CONFIG_QCOM_APR=m CONFIG_QCOM_ICC_BWMON=m +CONFIG_QCOM_MINIDUMP_SMEM=m +CONFIG_QCOM_PSTORE_MINIDUMP=m CONFIG_ARCH_R8A77995=y CONFIG_ARCH_R8A77990=y CONFIG_ARCH_R8A77951=y @@ -1445,6 +1447,8 @@ CONFIG_HUGETLBFS=y CONFIG_CONFIGFS_FS=y CONFIG_EFIVAR_FS=y CONFIG_SQUASHFS=y +CONFIG_PSTORE_CONSOLE=y +CONFIG_PSTORE_RAM=y CONFIG_NFS_FS=y CONFIG_NFS_V4=y CONFIG_NFS_V4_1=y From patchwork Wed Jun 28 12:34:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8898958vqr; Wed, 28 Jun 2023 05:51:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6K/BJh4WCVrW7ihOW+h4hr6paALGDC1jsFvjSi5OFFat6TwSatgdico5ZZWwepjGTpFHD+ X-Received: by 2002:a05:6512:401e:b0:4f9:a232:f09c with SMTP id br30-20020a056512401e00b004f9a232f09cmr8280342lfb.63.1687956694037; Wed, 28 Jun 2023 05:51:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956694; cv=none; d=google.com; s=arc-20160816; b=C/lqwEUJqIskgSiGpxetWhOGezYagFU+0d5Ih2L16DGXFr6k3jY++cTEArwv1/EHp1 WYcP2dot+P4j11wluPEbZksduf58+yM2r+jUiepPCZma1ttihIaKdY4G9UWbKIaGSyaN Yd+shWo0DW6IYPv8x0HSEEY4/rUecgC7MaOEAJ/42uyaQxUDxfDBfGgIQhD6LqKYNBOj YTTCSaa0unVuyf9ht2Ml1iLaPn32tFh/Lcf38M6O6vI12IjTqAE4xQq+8q6+LIVFecqh KAHZ7DsKoqn6Xc26PV+YhcVxODXQnc42q4EEJOZFWbqfFcK9HDsE/wptnoyY53FpjnTx QTyw== 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=U9YcbtW13rSnb+eJW5/EwukE3syszirXrljsJPnuYiE=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=Qb65H1FpO+Eu80tF97Jl0d/Xyn04kbYDDlVxUBq4Wuow8tqEezgp8723E6gNoXlsck 2PAEK9wOVqE+jYreR2Yxa7tgqTJaw/xL1buoNnVYDZkdOFHdaH0eesehs7avoSgAgfTE 3RkFugZZwr2WwtoNq7xRP6h7DBl9XIH027tTSvUX1A7JenoTCNr6WlHRmrzQJtp6rRbm Q55M3GQM0uw/WIvNlhsKTqShDXIc2Qoc+wjwZIoONXZBv09y7YtiVgGpcztIsoYkYXQ3 O+SEsBjVY/r5DBZcFY2uVBvZFe+9jStnCnzgpFZ6yvdoXXNLmNY6Wz6rJGh+tHXBDU2C HlJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=pTs2+cqG; 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 l5-20020aa7c3c5000000b0051d91aab043si4490643edr.243.2023.06.28.05.51.10; Wed, 28 Jun 2023 05:51:34 -0700 (PDT) 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=pTs2+cqG; 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 S231372AbjF1Mjc (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:32 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:41794 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbjF1MhY (ORCPT ); Wed, 28 Jun 2023 08:37:24 -0400 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 35SCQhnK017176; Wed, 28 Jun 2023 12:37:06 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=U9YcbtW13rSnb+eJW5/EwukE3syszirXrljsJPnuYiE=; b=pTs2+cqG0aIGf0MxNi1esLfl19T+FW5ol56Sidi7p3jNWkzG5slIz76M7qMVtJD91Ka9 9cW1s6dxmdzP9Hz1yYSkaRP2RKFy9p2kIhTDtyWwyus4KEPl4Y41ca+0hH0X28pZUTJz 2j4t47eCkxz3i1Lq+VCqs001YT40EMpHgkIsNt1cpzlZOEWbkS2l9VoiSYhdAAmlC83G /ptf7z8ZaCAw9XzQOomrECa4i/vYhtkYZDt1bxis9qunSiQZHO0Db5/fZZtwf67SV0M2 nI0gdplNGGn58zdtxQUkC2+4R5fSwNHlnwzfvG7Q1OJnrXmFW+4pdxB4EYylAJsMdgxK iw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgemk0x7w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:06 +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 35SCb5Yl001788 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:05 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.42; Wed, 28 Jun 2023 05:36:59 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 16/21] arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node Date: Wed, 28 Jun 2023 18:04:43 +0530 Message-ID: <1687955688-20809-17-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: Xxc5kBzwneapvXCcAtwYDi2X0zb4Fq1n X-Proofpoint-ORIG-GUID: Xxc5kBzwneapvXCcAtwYDi2X0zb4Fq1n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=975 impostorscore=0 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950877905887905?= X-GMAIL-MSGID: =?utf-8?q?1769950877905887905?= This enable dynamic reserve memory for Qualcomm ramoops device, which will be used to save ramoops frontend data and this region gets dumped on crash via Qualcomm's minidump infrastructure. qcom_pstore_minidump is the associated driver for this node. Signed-off-by: Mukesh Ojha --- arch/arm64/boot/dts/qcom/sm8450.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8450.dtsi b/arch/arm64/boot/dts/qcom/sm8450.dtsi index d59ea8ee7111..0b1dedee606b 100644 --- a/arch/arm64/boot/dts/qcom/sm8450.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8450.dtsi @@ -390,6 +390,12 @@ }; }; + ramoops-minidump { + compatible = "qcom,sm8450-ramoops", "qcom,ramoops"; + console-size = <0x200000>; + memory-region = <&qcom_ramoops>; + }; + reserved_memory: reserved-memory { #address-cells = <2>; #size-cells = <2>; @@ -623,6 +629,12 @@ reg = <0x0 0xed900000 0x0 0x3b00000>; no-map; }; + + qcom_ramoops: ramoops { + alloc-ranges = <0x0 0x00000000 0xffffffff 0xffffffff>; + size = <0x0 0x200000>; + no-map; + }; }; smp2p-adsp { From patchwork Wed Jun 28 12:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8897198vqr; Wed, 28 Jun 2023 05:48:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60WrY9kFGYVg++x7zkOKzG5LKVdsZjJurL133H+ggnvWAjiVyaMszSxbYAWkM/CWAOIiVD X-Received: by 2002:a05:6402:759:b0:51a:7bcd:a82d with SMTP id p25-20020a056402075900b0051a7bcda82dmr21396433edy.23.1687956503720; Wed, 28 Jun 2023 05:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956503; cv=none; d=google.com; s=arc-20160816; b=Z7tQlYd2b6+BZgHspkO2p65xz8cEv7dQ3BLxnI28Rz+v4FoXOrSkqs4VQ09i9+LefU ugKTyrgOpNT6jPN06MOogBzGO92ukckaKGOu4ePgzG1UudklB/HyOIM0DS1o+9gIIr8V 0h8pWyOwBMxBrxVyddbcJHUXn2r/8FhOUYh8mfNpzA2WxkLpnrjTGuptb2e3xi0sEEUh CePuTknK9kClVeu2MJogS43QG/q+jxsZxXgOUe2MT3aiy5/1TsFBdzVUhzZlfR4TD5AP s365rBmRPaa/g7xatrDsKntdbVl22ABNqxkqGa/kYRS+bWltgs8UcXCwTW8dApLXxpQv jWoQ== 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=voO1wmpy58Dpce/ayyfsuuOHNRZFLt28O+ScPtTvxDU=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=oempj31zISPh8xErLZVwaUiqYMPAB7CRAF5tg8YsyL8JR4Fu4DOnppnHgS1n0uqxe5 mbeT8mmFvsye5GYcn1BJm6ZNIFgAMA56U4dhnox1NILC/lsURW7VBvT88j2ha/prBhQq PARGZVxjtLkGe3bOzorE7Ewdw9zdekAybAE4qXRMCRU2RiVGoeiAl+lxjWayYb26Kzpf +XGVYD2ohwwuYxQJUEErcNr+/0mspl2q2QSRduC8rVHLBsUChmzocn0kJSdEhqXrS/r0 gMGvlYSSCmimHFGcr79ADeumypN9h00WxUqEcgreRTu89eqsG/L7L1d1hsILO50V8jmi IsnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="U2rtcJ/Z"; 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 g25-20020a056402181900b0051db246c805si1215675edy.382.2023.06.28.05.47.59; Wed, 28 Jun 2023 05:48:23 -0700 (PDT) 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="U2rtcJ/Z"; 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 S232736AbjF1Mjm (ORCPT + 99 others); Wed, 28 Jun 2023 08:39:42 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:50678 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232100AbjF1Mhd (ORCPT ); Wed, 28 Jun 2023 08:37:33 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SCQcpx013316; Wed, 28 Jun 2023 12:37:13 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=voO1wmpy58Dpce/ayyfsuuOHNRZFLt28O+ScPtTvxDU=; b=U2rtcJ/ZAL/atIwFCGFN28JlUInAruvSQINjwU6cgKCnlNO/TkrNkoGv+VKQcpOHJJfv RILmfmti9Y7TjfEhmV70HaMrg+QOa7IRDDccOX3afk/MT7sPAnw5oRy0HkqAjuOtxR9A 5V24edg0RnlO7sWp/tmsackW0JgVYNklXdBW6amoEjHu1mYv2U0YCWY2z4OPGSr3s2/x PQJOJFehWkWJEnUI3PiObxYO0z2qDeyGyUsOU/DppVptiEsOfz3KR7o79xZ9TlZBP3d5 lPZr3eEFRpW0vFpcVmZvxeof+dWcgTM3WjDKG2Uw0slxAtBtu+s+O1HAsWXRaF+FNTP1 Hg== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rfrdtbqa0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:13 +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 35SCbCFL002061 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:12 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.42; Wed, 28 Jun 2023 05:37:05 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function Date: Wed, 28 Jun 2023 18:04:44 +0530 Message-ID: <1687955688-20809-18-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: vfaykQFcelw4SH3fZYkfHb4aTKdaVkU3 X-Proofpoint-GUID: vfaykQFcelw4SH3fZYkfHb4aTKdaVkU3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 suspectscore=0 phishscore=0 mlxlogscore=797 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950678898893041?= X-GMAIL-MSGID: =?utf-8?q?1769950678898893041?= It was realized by Srinivas K. that there is a need of read-modify-write scm exported function so that it can be used by multiple clients. Let's introduce qcom_scm_io_update_field() which masks out the bits and write the passed value to that bit-offset. Subsequent patch will use this function. Suggested-by: Srinivas Kandagatla Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 15 +++++++++++++++ include/linux/firmware/qcom/qcom_scm.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index fde33acd46b7..104d86e49b97 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id) } EXPORT_SYMBOL(qcom_scm_set_remote_state); +int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val) +{ + unsigned int old, new; + int ret; + + ret = qcom_scm_io_readl(addr, &old); + if (ret) + return ret; + + new = (old & ~mask) | (val & mask); + + return qcom_scm_io_writel(addr, new); +} +EXPORT_SYMBOL(qcom_scm_io_update_field); + static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) { struct qcom_scm_desc desc = { diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h index 250ea4efb7cb..ca41e4eb33ad 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -84,6 +84,8 @@ extern bool qcom_scm_pas_supported(u32 peripheral); extern int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val); extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val); +extern int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, + unsigned int val); extern bool qcom_scm_restore_sec_cfg_available(void); extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare); From patchwork Wed Jun 28 12:34:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8898778vqr; Wed, 28 Jun 2023 05:51:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZtD+AaUKr4AsMvcemM/pSsD/AP756hxCM6q3nVfY19hXwl/l688cvSYSfb3+i59eaC1JP X-Received: by 2002:a05:6402:1601:b0:51b:e89e:a846 with SMTP id f1-20020a056402160100b0051be89ea846mr14433677edv.19.1687956672954; Wed, 28 Jun 2023 05:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956672; cv=none; d=google.com; s=arc-20160816; b=H+g5Wl3yQXNEiSBZyMu22yGgy87e5UIcWC3QjsXrgSyco8NF4KRCo26KlehHJwDNA8 fL5HjHO9KGR1NPlgfgxtuo7igb5ESV2c79yuCWhbOXB/zaq5hHPa5YI8pNvkVAOSyX2d y6onAksByAkN4SUN/cqpJ7BAyD4Qg6HGCNLzy/zh09h9/dmNHwtMMol0TLwdfiFHaCCb qMADRAb8ikqF2T5R39qGregkB1XZxk39D8CeWI+HqitNP+rJP8283M4IJE18EF+Q7mm9 XuSDLX4kOII54yDgLVdtZvbtvgMvOh1la39aC75aKyULWt29uEef4/2FNgkZUmATn6ZN uiLg== 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=jirypYn/l5H9pX+tgaMIYr1LepA3IkncZEaWrvK3Yog=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=RdP8e7pzmEW6VUlLi8VEJXFd5q+Hxx8kt1SBUsnpwBLUlcjzd1eiPCyuVDvKvfb3fB eJ4VWV+EcNxxI+18SrEKiNhIgT1m6R7KTVZw1JarjNIIbMtZmCtuW+SxTFgvNuEaxa1u hg3EPB6/HV2Hg4BCTa3EBMk9BAOWqmbyH+GnQFVjsgNdmQNCeaia1UXVLjIzpeiG/g8I 1ejFlE6V6QWwfaJH9OIl1MqMIZV7+bJGmCCRrciLaoZKXQf99PJmpOFYV2U7QE5sBR9b r13c0TPcwxan0jXUNr2eY7B6w0G9dMnqhqbhE8TevNAH5Dvdg/ILMhSU+pNR8NxGiKCF ru9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IrI3QiEu; 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 c9-20020aa7d609000000b005149e94233esi4951705edr.121.2023.06.28.05.50.48; Wed, 28 Jun 2023 05:51:12 -0700 (PDT) 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=IrI3QiEu; 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 S231214AbjF1Mk0 (ORCPT + 99 others); Wed, 28 Jun 2023 08:40:26 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:52800 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231706AbjF1Mhg (ORCPT ); Wed, 28 Jun 2023 08:37:36 -0400 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 35SBDGQm002370; Wed, 28 Jun 2023 12:37: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=jirypYn/l5H9pX+tgaMIYr1LepA3IkncZEaWrvK3Yog=; b=IrI3QiEuouHDdScyw2E4Z94ukTES20W3LZvX5/la8kT0FartU23ky/RAVSAJNZfymVGZ iiiL4zdmrCti1HX/BOBYSoGcyeNVBzI9jE+kpPHQcMlLrblFT4b89qLdfn/e2PZeWcmj vbzxPnPIBlMFOtKzFPHeelpKi9InYSW4Pb0yf9NQRqydl6wReuC7q4jwY+L85as0G5LV XWRm0pqxfmNGYgdBJRX9G+fW+AQFk8w8kHSFi3UmcfjmUEutaH94rVxWUZj0pPKEZyfO pxEf2kJrF1+xM+lmwdZP+zsvmfZXP+EACKHlwqW+PLselI6FaFXcLRC9hauaraUiQGVe Bw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgetpgw7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:20 +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 35SCbJPk028450 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:19 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.42; Wed, 28 Jun 2023 05:37:12 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field() Date: Wed, 28 Jun 2023 18:04:45 +0530 Message-ID: <1687955688-20809-19-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: LkvDYJLcaIHW74S5BXOR2kSeIJcmyq30 X-Proofpoint-GUID: LkvDYJLcaIHW74S5BXOR2kSeIJcmyq30 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxlogscore=903 spamscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950856002936594?= X-GMAIL-MSGID: =?utf-8?q?1769950856002936594?= Use qcom_scm_io_update_field() exported function introduced in last commit. Acked-by: Linus Walleij Signed-off-by: Mukesh Ojha --- drivers/pinctrl/qcom/pinctrl-msm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index c5f52d4f7781..f31b54bf98e4 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -1041,6 +1041,7 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) const struct msm_pingroup *g; unsigned long flags; bool was_enabled; + u32 mask; u32 val; if (msm_gpio_needs_dual_edge_parent_workaround(d, type)) { @@ -1075,23 +1076,20 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type) * With intr_target_use_scm interrupts are routed to * application cpu using scm calls. */ + mask = (GENMASK(2, 0) << g->intr_target_bit); if (pctrl->intr_target_use_scm) { u32 addr = pctrl->phys_base[0] + g->intr_target_reg; int ret; - qcom_scm_io_readl(addr, &val); - - val &= ~(7 << g->intr_target_bit); - val |= g->intr_target_kpss_val << g->intr_target_bit; - - ret = qcom_scm_io_writel(addr, val); + val = g->intr_target_kpss_val << g->intr_target_bit; + ret = qcom_scm_io_update_field(addr, mask, val); if (ret) dev_err(pctrl->dev, "Failed routing %lu interrupt to Apps proc", d->hwirq); } else { val = msm_readl_intr_target(pctrl, g); - val &= ~(7 << g->intr_target_bit); + val &= ~mask; val |= g->intr_target_kpss_val << g->intr_target_bit; msm_writel_intr_target(val, pctrl, g); } From patchwork Wed Jun 28 12:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8899159vqr; Wed, 28 Jun 2023 05:51:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4r0MC4UgXtjFUO6GlI3v6rrgJTeUabpG744mNeMeRXqXYa6ILLkBczv/0gI23ODG3ZuAk7 X-Received: by 2002:a17:906:8468:b0:991:bb53:f76c with SMTP id hx8-20020a170906846800b00991bb53f76cmr5490424ejc.11.1687956715626; Wed, 28 Jun 2023 05:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956715; cv=none; d=google.com; s=arc-20160816; b=CCw901fkDtEP4BHLGtgcXc0M5cU/pMsHtvjJB7QOu1a6nC+VW1XuJWBtLp84WZD9u2 KREgX4lBFjXnha2/bPm1lE3dQPY9NnsKPltvPR0GvmXFSjeTebsWn+WVNUAN9S5LE/KG 9ZyRO7ho8h86ae3zJ8dneVcfhh87hsVaMkNhTC3hjpkqEzgTPeKhWTFJd3QsLe8dLG4f qnEsQ951as+RzeB+gxCG7kFIxpz9joknde4FmJOv5IGvosONEHoeBA3/nGd29ZwSvPSl kQdjMvi4TKKbDRW2jfobKTyT7V3zB5bR2ztWMo5Ad40nffhotyHpYq8gjwhroisYxqHH oDPQ== 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=nPaAz0ocSxAKTJs7RTIRBsUIrURO8wj1m2EtWn9n8x0=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=nIZxhYBFBNNKStFaB1nCgEilTnjNYJAbpccKPPzzs3SmOfDKn/MuKFVnhMTnCkO0+K iYiC7e55+s21Gn6WVEfxC6G/Pm7e1OkNXfaLC7FqM0XGJUNkFTr0Gx7ay4GwHRvNSk5M Q1yPTqK1MrYWHhxsvnUqKVEyJN4r4WUYGHYxQk4w+uVPHCQ78oiHdf8oRB4D58mT/RF9 7EW60strlc4S6N3/Txv4AUVyW1mIBiXNTbkLtFZ0NSkR2kJHgpuFnj63S4n0JYIkd4fk rv7J4FEdPGLOl9a7uwkL2yu6KSjQzodP/FlE23NJcIpuFWb5os9+JEOReBewPFXGc5FS MfPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=n0gbiQvz; 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 pg11-20020a170907204b00b00988835e65a4si5225150ejb.246.2023.06.28.05.51.32; Wed, 28 Jun 2023 05:51:55 -0700 (PDT) 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=n0gbiQvz; 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 S231610AbjF1Mke (ORCPT + 99 others); Wed, 28 Jun 2023 08:40:34 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:60112 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbjF1Mho (ORCPT ); Wed, 28 Jun 2023 08:37:44 -0400 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 35SCTnM0024262; Wed, 28 Jun 2023 12:37:27 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=nPaAz0ocSxAKTJs7RTIRBsUIrURO8wj1m2EtWn9n8x0=; b=n0gbiQvzk0b/pg89AVjzh7Ia7Tpn59q5IKkwogaNPc1ImYWlze5VxD8CtMAoVP8VVIVo /4fEuGOaCgWzEOnyFJK8biLaAgXpsiajWrdL1RvLL5W8nWDE9jlv/kNj46YUrHKgbLzH z3pCVGQYoRnOM4y8q7YLxYSgsDoyS0jiMGRr4yFaVITibOTJIRF7A2bONHSJdfHdUKRQ DfmvLmI23zZIL0c8VavgYj0mPrd7C6d4nEHH1HWJJit1X12Q5CWjUNvsk46DQMtE1lyW Auq+yNGchg5zBlajqxPmSENF1zqiPdwuS+eFy+PIYi4VM8Kfj9XKXXw1Z60XLFbqSqm6 +g== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgemk0x8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:27 +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 35SCbQ4m028510 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:26 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.42; Wed, 28 Jun 2023 05:37:19 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register Date: Wed, 28 Jun 2023 18:04:46 +0530 Message-ID: <1687955688-20809-20-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: rZep0ltKHpRUsYbklWWZe3bUwLAa3_a2 X-Proofpoint-ORIG-GUID: rZep0ltKHpRUsYbklWWZe3bUwLAa3_a2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950901299751474?= X-GMAIL-MSGID: =?utf-8?q?1769950901299751474?= CrashDump collection is based on the DLOAD bit of TCSR register. To retain other bits, we read the register and modify only the DLOAD bit as the other bits have their own significance. Co-developed-by: Poovendhan Selvaraj Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 104d86e49b97..a9ff77d16c42 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -30,6 +30,11 @@ module_param(download_mode, bool, 0); #define SCM_HAS_IFACE_CLK BIT(1) #define SCM_HAS_BUS_CLK BIT(2) +#define QCOM_DOWNLOAD_FULLDUMP 0x1 +#define QCOM_DOWNLOAD_NODUMP 0x0 +#define QCOM_DOWNLOAD_MODE_SHIFT 4 +#define QCOM_DOWNLOAD_MODE_MASK 0x30 + struct qcom_scm { struct device *dev; struct clk *core_clk; @@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) static void qcom_scm_set_download_mode(bool enable) { bool avail; + int val; int ret = 0; avail = __qcom_scm_is_call_available(__scm->dev, @@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable) if (avail) { ret = __qcom_scm_set_dload_mode(__scm->dev, enable); } else if (__scm->dload_mode_addr) { - ret = qcom_scm_io_writel(__scm->dload_mode_addr, - enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0); + val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP); + val <<= QCOM_DOWNLOAD_MODE_SHIFT; + ret = qcom_scm_io_update_field(__scm->dload_mode_addr, + QCOM_DOWNLOAD_MODE_MASK, val); } else { dev_err(__scm->dev, "No available mechanism for setting download mode\n"); From patchwork Wed Jun 28 12:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8898746vqr; Wed, 28 Jun 2023 05:51:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66hSUoBYZUBIKwPJJReWztFsea/totYPy9cUTU5mIb/HRZbqu2mazGdSTJAFxl3hYwN5ft X-Received: by 2002:a17:906:d552:b0:98c:eef2:d0bc with SMTP id cr18-20020a170906d55200b0098ceef2d0bcmr18569839ejc.12.1687956670108; Wed, 28 Jun 2023 05:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956670; cv=none; d=google.com; s=arc-20160816; b=JZsF5bu4kXWRojHX7O8wad0I/yXjMu9I4KlzOQnowcvHu83DBP3RVGVX9CciEIy3GF xSuPYRRIm6H6gXk5dCq0LXCm2vDYMiHJnLPDgwr6NxVrvUg3Gvm39XsTkNmSDnxOjW2d zdpmqhc/ODw34CH+bCI+2kGOKrQQHzIPPTBt22mAkCEDA+Kir/zUw75gmNBh0m1fzObx +gr874H8jPWuEckURhPjhjLi+pOH0oElJsNDN5RefYjJL++ypwa61D0yN1EcfYGxV7/C MKP8ed2xU1IFcp8ZNdLmn3Lb2tQYo/Pzh0l9heX+8eyqejjU9K+j1ViARJx3hUI9iVJW Li/w== 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=Zb5MG63sitiRZUFxf3RKRHRma4JBHpqb+Ln3d7Df/+Q=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=wXttRxdF7OMBhds/W+xJCdaoODFkTNxNPtaF4HZjgS+afpEcGruAdNaikQ/t2O8Zys 9d0foPQeV5FJo8BPWGtOPTtnsuMCSLHtegsY+3q4zhxbHAUvkKBQ99W293H0VvNdzRok LEaYMC571TTR5QIPHaVVmCp5+U8OYPJf2qeBlvAsyU/lbxx5okqWjrCotMvGQInzwSoR Gbu39zitdnnr1K/4xPrVX4CblVPx+rZNQRiktQjBL1AWgeYvCSpDlk8Qd70vcXshRe8K CUhFLkZdf7AzzCnX3eDVz2RKWp+5jHwwn8PqaUPSy3rdC0H0S7QHNaSNslszz/pLn+Kr 8Xdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=he10HfoL; 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 br12-20020a170906d14c00b00992437c5888si1655198ejb.291.2023.06.28.05.50.45; Wed, 28 Jun 2023 05:51:10 -0700 (PDT) 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=he10HfoL; 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 S232047AbjF1Mm2 (ORCPT + 99 others); Wed, 28 Jun 2023 08:42:28 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:11634 "EHLO mx0a-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231438AbjF1Mhv (ORCPT ); Wed, 28 Jun 2023 08:37:51 -0400 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 35SAa7u7019129; Wed, 28 Jun 2023 12:37:34 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=Zb5MG63sitiRZUFxf3RKRHRma4JBHpqb+Ln3d7Df/+Q=; b=he10HfoLj32bTbZrJwY0IkLb1AoEt296ldCUgICu4zCNK5ATFwDEstqDNyUBqz0efI7v 3rnQPFKnpS/NB8+Atpe9fug72RIurCJXeF+PEh8h+WrwZ2jVRNc1lZyTcO+e78cyjNTS h4wIlCCjUvlVwsKAD2X1lyCOzrh7b+0UAcRwAm18BuCa4Cg4TLaSAtZWFqYPYIYU8wzn CZq37iT/s0ivVAD44jzaM2lebY61TjLUzikfpnJmiwJ+/s6pIFcN9NZprBsbOHUi9/nQ 8N0n+jhgUjIm6zptFfiSLbmT8jCZWxRUnTwMs5NzWd2FSibETeVxBPYbfqQ5RRSecd/S og== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rgaxcs965-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:33 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35SCbX1w026581 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:33 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.42; Wed, 28 Jun 2023 05:37:26 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode Date: Wed, 28 Jun 2023 18:04:47 +0530 Message-ID: <1687955688-20809-21-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: q1lv3eXeAZRz6UjnO61zGTQIqWaUPuiL X-Proofpoint-ORIG-GUID: q1lv3eXeAZRz6UjnO61zGTQIqWaUPuiL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 adultscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769950853678645151?= X-GMAIL-MSGID: =?utf-8?q?1769950853678645151?= Currently on Qualcomm SoC, download_mode is enabled if CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected. Refactor the code such that it supports multiple download modes and drop CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT config instead, give interface to set the download mode from module parameter. Signed-off-by: Mukesh Ojha --- drivers/firmware/Kconfig | 11 --------- drivers/firmware/qcom_scm.c | 56 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index b59e3041fd62..ff7e9f330559 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -215,17 +215,6 @@ config MTK_ADSP_IPC config QCOM_SCM tristate -config QCOM_SCM_DOWNLOAD_MODE_DEFAULT - bool "Qualcomm download mode enabled by default" - depends on QCOM_SCM - help - A device with "download mode" enabled will upon an unexpected - warm-restart enter a special debug mode that allows the user to - "download" memory content over USB for offline postmortem analysis. - The feature can be enabled/disabled on the kernel command line. - - Say Y here to enable "download mode" by default. - config SYSFB bool select BOOT_VESA_SUPPORT diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index a9ff77d16c42..946cb0f76a17 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -18,13 +18,13 @@ #include #include #include +#include #include #include #include "qcom_scm.h" -static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT); -module_param(download_mode, bool, 0); +static u32 download_mode; #define SCM_HAS_CORE_CLK BIT(0) #define SCM_HAS_IFACE_CLK BIT(1) @@ -82,6 +82,11 @@ static const char * const qcom_scm_convention_names[] = { [SMC_CONVENTION_LEGACY] = "smc legacy", }; +static const char * const download_mode_name[] = { + [QCOM_DOWNLOAD_NODUMP] = "off", + [QCOM_DOWNLOAD_FULLDUMP] = "full", +}; + static struct qcom_scm *__scm; static int qcom_scm_clk_enable(void) @@ -442,8 +447,9 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) return qcom_scm_call_atomic(__scm->dev, &desc, NULL); } -static void qcom_scm_set_download_mode(bool enable) +static void qcom_scm_set_download_mode(u32 download_mode) { + bool enable = !!download_mode; bool avail; int val; int ret = 0; @@ -454,7 +460,7 @@ static void qcom_scm_set_download_mode(bool enable) if (avail) { ret = __qcom_scm_set_dload_mode(__scm->dev, enable); } else if (__scm->dload_mode_addr) { - val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP); + val = download_mode; val <<= QCOM_DOWNLOAD_MODE_SHIFT; ret = qcom_scm_io_update_field(__scm->dload_mode_addr, QCOM_DOWNLOAD_MODE_MASK, val); @@ -1425,6 +1431,42 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data) return IRQ_HANDLED; } +static int get_download_mode(char *buffer, const struct kernel_param *kp) +{ + if (download_mode >= ARRAY_SIZE(download_mode_name)) + return sysfs_emit(buffer, "unknown mode\n"); + + return sysfs_emit(buffer, "%s\n", download_mode_name[download_mode]); +} + +static int set_download_mode(const char *val, const struct kernel_param *kp) +{ + u32 old = download_mode; + int ret; + + ret = sysfs_match_string(download_mode_name, val); + if (ret < 0) { + download_mode = old; + pr_err("qcom_scm: unknown download mode: %s\n", val); + return -EINVAL; + } + + download_mode = ret; + if (__scm) + qcom_scm_set_download_mode(download_mode); + + return 0; +} + +static const struct kernel_param_ops download_mode_param_ops = { + .get = get_download_mode, + .set = set_download_mode, +}; + +module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644); +MODULE_PARM_DESC(download_mode, + "download mode: off/full are acceptable values"); + static int qcom_scm_probe(struct platform_device *pdev) { struct qcom_scm *scm; @@ -1518,12 +1560,12 @@ static int qcom_scm_probe(struct platform_device *pdev) __get_convention(); /* - * If requested enable "download mode", from this point on warmboot + * If "download mode" is requested, from this point on warmboot * will cause the boot stages to enter download mode, unless * disabled below by a clean shutdown/reboot. */ if (download_mode) - qcom_scm_set_download_mode(true); + qcom_scm_set_download_mode(download_mode); return 0; } @@ -1531,7 +1573,7 @@ static int qcom_scm_probe(struct platform_device *pdev) static void qcom_scm_shutdown(struct platform_device *pdev) { /* Clean shutdown, disable download mode to allow normal restart */ - qcom_scm_set_download_mode(false); + qcom_scm_set_download_mode(QCOM_DOWNLOAD_NODUMP); } static const struct of_device_id qcom_scm_dt_match[] = { From patchwork Wed Jun 28 12:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mukesh Ojha X-Patchwork-Id: 113847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8900117vqr; Wed, 28 Jun 2023 05:53:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ano9QQaGBLVk4Yh8VJztmaRYmuGUSc/hR5tR9RNrrYWVOY+mfEFkHCwHfxsAmV4RdgiRY X-Received: by 2002:aa7:d851:0:b0:51d:8a53:d1f with SMTP id f17-20020aa7d851000000b0051d8a530d1fmr6866160eds.8.1687956827695; Wed, 28 Jun 2023 05:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687956827; cv=none; d=google.com; s=arc-20160816; b=ak1MO9tAXuLKNhVLR32VkMROXAwR2yK+T0XQ0GxM6Kyj4M8fMFHtiJLnRtyPA5zEIy T52ComBilUGtQLCB+Q5giQC4aVT/3sIupJEvI1iJ2gBQ8EPmqnDJCmGR5/TX9RkfaXos 4dzcoK6VA1G5ojygzl3jCErbOtDTIR3mmzC7WZp4YljsQB8Gf/+/Yc3FvQZyo7RnBi/M 8Tmm2OasprGRPE1knfK5IOJExJUot2zMHJo890Nf/2i53qJyy8qCxMpVkBtaga6yFJS5 Rl196KmKnmnfEQbUJv/B1RfiBmNy7tFP4mWMlZ2fwXziq79Oy/FrelQC2KZDP4MStFXU YKvg== 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=orV3xaRgOXdBv+EvZhahI6WQdstYeA90CZqOQkv6cLI=; fh=xfNbOz4I/Hg3jG8SBg8wTUJPSewLm0J/G1fLCBug3yE=; b=LxwsscVsJ+2FbsMQjyX1SUp06YhAX+Kk3Us1oWVWqrjm4NIuA6Nm1ie36MHstYOZe0 JnpYictxxEKcuFu7bFbBQeyeGaRTfHEsB/a6uhMgXDGoZda39kFcI5UFeaXPVfLRnSzq 94zXn2AWiII+cM0ItiV1FZWovDhP1lyUo6KWflIkBuGBvEwqZJRhsB7r1ZOBOKeUBfQD Hc5E5yzZfo53FARXb+Sn5ozQxyuTXIIvIwUljhv5IF6OrTOm046JvaFjPggYjfrElgrn Zw8zDNr62IlEj8A8sskoCKxy+/14re2rUgbkyW6U8KBU1QTZ82CVJ7gdPAJbwy86HVrM DHdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UkwnUQPz; 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 m3-20020aa7d343000000b0051be558d4dcsi4847052edr.205.2023.06.28.05.53.23; Wed, 28 Jun 2023 05:53:47 -0700 (PDT) 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=UkwnUQPz; 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 S232031AbjF1Mkl (ORCPT + 99 others); Wed, 28 Jun 2023 08:40:41 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]:7312 "EHLO mx0b-0031df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbjF1Mh5 (ORCPT ); Wed, 28 Jun 2023 08:37:57 -0400 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 35S8hwfV019656; Wed, 28 Jun 2023 12:37:41 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=orV3xaRgOXdBv+EvZhahI6WQdstYeA90CZqOQkv6cLI=; b=UkwnUQPzsvBy/N+7oBJ1VdTYqGgjVAQ70vfr1gECSNgCOZRfSiS5hMP42KYlrUYylgD6 /OJU1KE8h0ljrxHe67E7qXGcUvGotbUze+XittlcOXVHIbyodTjAwG5xNBw1rGX5dLtj SU9goPMK1v4ufPtn34pZDdnUxIynyeGoR00i3sfyqXYbs+Q9JPpNzkK0uZD8x2chWaqE jt3ZnTU3DNIuOXThieOJ+mkvbntdigmlV1B1dXZFhqKY7fqYD9EQg7SNoBBYNRaMXIW+ ntX9fQ8bsRl0gb9jW1B5FTBle9vlctw3Sk9AlfZB7pqwcGb2ileF5QCPHd1v3N9XFdbC +Q== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rg7x3skw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:40 +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 35SCbdFH010228 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:39 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.42; Wed, 28 Jun 2023 05:37:33 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , , CC: , , , , , , , , "Mukesh Ojha" Subject: [PATCH v4 21/21] firmware: qcom_scm: Add multiple download mode support Date: Wed, 28 Jun 2023 18:04:48 +0530 Message-ID: <1687955688-20809-22-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> References: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: 7N0NHCXx1HtIlnlWstC82DtCdSHMY6m1 X-Proofpoint-GUID: 7N0NHCXx1HtIlnlWstC82DtCdSHMY6m1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_08,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280111 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?1769951018844201113?= X-GMAIL-MSGID: =?utf-8?q?1769951018844201113?= Currently, scm driver only supports full dump when download mode is selected. Add support to enable minidump as well as enable it along with fulldump. Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 946cb0f76a17..52e3b613a1af 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -31,6 +31,8 @@ static u32 download_mode; #define SCM_HAS_BUS_CLK BIT(2) #define QCOM_DOWNLOAD_FULLDUMP 0x1 +#define QCOM_DOWNLOAD_MINIDUMP 0x2 +#define QCOM_DOWNLOAD_BOTHDUMP (QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP) #define QCOM_DOWNLOAD_NODUMP 0x0 #define QCOM_DOWNLOAD_MODE_SHIFT 4 #define QCOM_DOWNLOAD_MODE_MASK 0x30 @@ -85,6 +87,8 @@ static const char * const qcom_scm_convention_names[] = { static const char * const download_mode_name[] = { [QCOM_DOWNLOAD_NODUMP] = "off", [QCOM_DOWNLOAD_FULLDUMP] = "full", + [QCOM_DOWNLOAD_MINIDUMP] = "mini", + [QCOM_DOWNLOAD_BOTHDUMP] = "full,mini", }; static struct qcom_scm *__scm; @@ -1465,7 +1469,7 @@ static const struct kernel_param_ops download_mode_param_ops = { module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644); MODULE_PARM_DESC(download_mode, - "download mode: off/full are acceptable values"); + "download mode: off/full/mini/full,mini are acceptable values"); static int qcom_scm_probe(struct platform_device *pdev) {